Skip to content

Commit

Permalink
Remove extra crlf from ast_fprint (#2555)
Browse files Browse the repository at this point in the history
the print routine in ast.c already prints a crlf so the one printed
in ast_fprint is unnecessary, this change removes the extra crlf.

To test I added some consecutive ast_print statements to
suggest_alt_name:
```
   if(case_ast != NULL)
   {
+    AST_GET_CHILDREN(case_ast, first, second);
+    printf("suggest_alt_name:    ast "); ast_print(ast, 200);
+    printf("suggest_alt_name:  first "); ast_print(first, 200);
+    printf("suggest_alt_name: second "); ast_print(second, 200);
+
+    return NULL;
+
```
Before this change the output would be:
```
$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))

suggest_alt_name:  first box

suggest_alt_name: second (id doIt)

suggest_alt_name:    ast (reference (id astr))

suggest_alt_name:  first (id aStr)

suggest_alt_name: second (nominal (id $0) (id String) x val x x)

Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^
```
After removing the extra crlf in this change the output is nicer:
```
$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))
suggest_alt_name:  first box
suggest_alt_name: second (id doIt)
suggest_alt_name:    ast (reference (id astr))
suggest_alt_name:  first (id aStr)
suggest_alt_name: second (nominal (id $0) (id String) x val x x)
Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^
```
  • Loading branch information
winksaville authored and jemc committed Feb 21, 2018
1 parent 0c034b6 commit e93d552
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/libponyc/ast/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,6 @@ void ast_fprint(FILE* fp, ast_t* ast, size_t width)
return;

print(fp, ast, 0, NOT_SPECIAL, width);
fprintf(fp, "\n");
}

void ast_fprintverbose(FILE* fp, ast_t* ast)
Expand Down

0 comments on commit e93d552

Please sign in to comment.