Skip to content

Commit

Permalink
Fix unwanted indentation in StdStream.print
Browse files Browse the repository at this point in the history
When printing via `StdStream.print` strings containing the null
terminator, we were just printing the string until the null terminator
and replacing the unprinted characters by padding the printed string
with space characters.

This behavior made `String.size()` inconsistent with what `fprintf` was
really printing.

This behavior has been introduced in #1768, which ensure we respected
the buffer size.

Closes #4171
  • Loading branch information
leonardoce committed Aug 21, 2022
1 parent f3f3b8d commit 259695b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/libponyrt/lang/stdfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,8 @@ PONY_API size_t pony_os_stdin_read(char* buffer, size_t space)

PONY_API void pony_os_std_print(FILE* fp, char* buffer, size_t len)
{
if(len == 0)
fprintf(fp, "\n");
else
fprintf(fp, "%*.*s\n", (int)len, (int)len, buffer);
fwrite(buffer, len, 1, fp);
fprintf(fp, "\n");
}

PONY_API void pony_os_std_write(FILE* fp, char* buffer, size_t len)
Expand Down

0 comments on commit 259695b

Please sign in to comment.