diff options
author | John Ankarström <john@ankarstrom.se> | 2020-10-23 02:12:30 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2020-10-23 02:12:30 +0200 |
commit | 4605b90ff1e0de5b12e04647cd5dacd9848a9a74 (patch) | |
tree | 4fc6bcadbeabaea9c3941047123ed462b8087ca9 /src | |
parent | c3143fbdb7ea46539023e11cb30a7b14434030f3 (diff) | |
download | tt-master.tar.gz |
Diffstat (limited to 'src')
-rw-r--r-- | src/tt.input.c | 16 | ||||
-rw-r--r-- | src/tt.output.c | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/tt.input.c b/src/tt.input.c index 1f88f7d..b601e68 100644 --- a/src/tt.input.c +++ b/src/tt.input.c @@ -82,10 +82,18 @@ int i; int b; int c; -// On every iteration, tt checks whether the read character is a newline. If -// not, the character is added to the line variable, which is re-allocated if -// necessary. The line_l, keeping track of the line's length, is incremented -// as well: -> main.input +// First of all, tt ignores any carriage returns: -> main.input + + if (c == '\r') continue; + +// On Windows, where carriage returns are used, they will automatically be +// removed anyway. On systems that don't use carriage returns, they might not +// be stripped from the input, which is why tt ignores them. + +// Otherwise, on every iteration, tt checks whether the read character is a +// newline. If not, the character is added to the line variable, which is +// re-allocated if necessary. The line_l, keeping track of the line's length, +// is incremented as well: -> main.input if (c != '\n') { if (line_l + 1 > line_s) { diff --git a/src/tt.output.c b/src/tt.output.c index b1d8e34..5cfa5b6 100644 --- a/src/tt.output.c +++ b/src/tt.output.c @@ -65,6 +65,7 @@ while ((b = fgetc(fo)) != EOF) { c = b; + if (c == '\r') continue; if (c != '\n') { if (line_l + 1 > line_s) { line_s += 20; |