From 4605b90ff1e0de5b12e04647cd5dacd9848a9a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 23 Oct 2020 02:12:30 +0200 Subject: release 1.2.1 --- CHANGELOG.txt | 9 ++++----- src/tt.input.c | 16 ++++++++++++---- src/tt.output.c | 1 + tt.c | 2 ++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 677db61..72cea05 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,5 @@ -CHANGELOG ----------------------- 1.2 ---------------------- 2020-05-29 +CHANGELOG --------------------- 1.2.1 ---------------------- 2020-05-28 -NEW: tt is now itself compiled using tt. The source files, which are - organized "literately" and tangled to tt.c, are located in src/. - A preliminary HTML version of the source exists in doc/. -FIX: Empty references are now handled properly. \ No newline at end of file +NEW: tt now removes carriage returns on systems where they are not used + or accounted for. This means that you can easily use tt on + Unix-like systems with files created on Windows. \ No newline at end of file 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; diff --git a/tt.c b/tt.c index 66acdb2..94f3c35 100644 --- a/tt.c +++ b/tt.c @@ -97,6 +97,7 @@ int main(int argc, char *argv[]) { if (line == NULL) err(1, "malloc"); while ((b = getchar()) != EOF) { c = b; + if (c == '\r') continue; if (c != '\n') { if (line_l + 1 > line_s) { line_s += 20; @@ -133,6 +134,7 @@ int main(int argc, char *argv[]) { while ((b = fgetc(fo)) != EOF) { c = b; + if (c == '\r') continue; if (c != '\n') { if (line_l + 1 > line_s) { line_s += 20; -- cgit v1.2.3