From 97e4cdfcb0b4b2979b356a2cdf6ab0eba0ff101b Mon Sep 17 00:00:00 2001 From: crc Date: Sat, 27 Jan 2018 20:36:11 +0000 Subject: [PATCH] unu, muri now build under gcc-2.92; full build works under Haiku/BeOS (disable GOPHER in rre first) FossilOrigin-Name: b24fcc586b4c07494bfaeb882c9cf1ac37289c1e3afc51348090937a2a17b7cd --- literate/Muri.md | 6 ++++-- literate/Unu.md | 6 ++++-- tools/muri.c | 6 ++++-- tools/unu.c | 5 +++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/literate/Muri.md b/literate/Muri.md index f9cbb61..403e158 100644 --- a/literate/Muri.md +++ b/literate/Muri.md @@ -244,10 +244,12 @@ part of pass1()). ~~~ void pass2(char *fname) { - char *buffer = (char *)source; + char *buffer; FILE *fp; + int inBlock; + inBlock = 0; + buffer = (char *)source; here = 0; - int inBlock = 0; fp = fopen(fname, "r"); while (!feof(fp)) { read_line(fp, buffer); diff --git a/literate/Unu.md b/literate/Unu.md index 7b7cca3..edcf6a6 100644 --- a/literate/Unu.md +++ b/literate/Unu.md @@ -29,14 +29,16 @@ I use this for readability purposes. ~~~ void read_line(FILE *file, char *line_buffer) { + int ch, count; + if (file == NULL || line_buffer == NULL) { printf("Error: file or line buffer pointer is null."); exit(1); } - int ch = getc(file); - int count = 0; + ch = getc(file); + count = 0; while ((ch != '\n') && (ch != EOF)) { line_buffer[count] = ch; diff --git a/tools/muri.c b/tools/muri.c index 94e3c9a..2fdb5d7 100644 --- a/tools/muri.c +++ b/tools/muri.c @@ -126,10 +126,12 @@ void pass1(char *fname) { fclose(fp); } void pass2(char *fname) { - char *buffer = (char *)source; + char *buffer; FILE *fp; + int inBlock; + inBlock = 0; + buffer = (char *)source; here = 0; - int inBlock = 0; fp = fopen(fname, "r"); while (!feof(fp)) { read_line(fp, buffer); diff --git a/tools/unu.c b/tools/unu.c index 2ace731..7d954d6 100644 --- a/tools/unu.c +++ b/tools/unu.c @@ -4,13 +4,14 @@ #include #define KiB * 1024 void read_line(FILE *file, char *line_buffer) { + int ch, count; if (file == NULL || line_buffer == NULL) { printf("Error: file or line buffer pointer is null."); exit(1); } - int ch = getc(file); - int count = 0; + ch = getc(file); + count = 0; while ((ch != '\n') && (ch != EOF)) { line_buffer[count] = ch; count++;