From 7e95a39ccdb16ef1e4fbf753c71e1e283755aab8 Mon Sep 17 00:00:00 2001 From: "J.B. Langston" Date: Sun, 3 Sep 2017 15:31:10 -0500 Subject: [PATCH 1/2] Add warnings for bare CR in line endings --- crossassemblers/macro1/macro1.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crossassemblers/macro1/macro1.c b/crossassemblers/macro1/macro1.c index a3d6799..dad3def 100644 --- a/crossassemblers/macro1/macro1.c +++ b/crossassemblers/macro1/macro1.c @@ -1891,6 +1891,11 @@ void readLine() end_of_input = TRUE; } /* fgets failed */ + + char *ch; + if ( (ch = strchr(inpline, '\r')) != NULL && ch[1] != '\n' ) + fprintf( stderr, "Warning: bare CR found in input; check your line endings\n"); + ffseen = FALSE; for( ix = 0, iy = 0; inpline[ix] != '\0'; ix++ ) { if( inpline[ix] == '\f' ) { From c2efb1b257b3fd07be3832be7b11494d6c8af3ce Mon Sep 17 00:00:00 2001 From: "J.B. Langston" Date: Sun, 3 Sep 2017 22:12:24 -0500 Subject: [PATCH 2/2] Skip processing file if bare CR is found --- crossassemblers/macro1/macro1.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crossassemblers/macro1/macro1.c b/crossassemblers/macro1/macro1.c index dad3def..644c1f6 100644 --- a/crossassemblers/macro1/macro1.c +++ b/crossassemblers/macro1/macro1.c @@ -1832,6 +1832,7 @@ void readLine() WORD32 ix; WORD32 iy; char inpline[LINELEN]; + char *ch; /* XXX panic if nrepeats > 0 (if self-feeding, do the backup here?) */ @@ -1875,7 +1876,9 @@ void readLine() lineno++; /* Count lines read. */ listed = FALSE; /* Mark as not listed. */ READ_LINE: - if(( fgets( inpline, LINELEN - 1, infile )) == NULL ) { + if(( fgets( inpline, LINELEN - 1, infile )) == NULL || ((ch = strchr(inpline, '\r')) != NULL && ch[1] != '\n')) { + if ( (ch = strchr(inpline, '\r')) != NULL && ch[1] != '\n' && pass == 1) + fprintf( stderr, "%s: bare CR found in %s; check your line endings\n", save_argv[0], save_argv[filix_curr]); filix_curr++; /* Advance to next file. */ if( filix_curr < save_argc ) { /* More files? */ fclose( infile ); @@ -1891,11 +1894,6 @@ void readLine() end_of_input = TRUE; } /* fgets failed */ - - char *ch; - if ( (ch = strchr(inpline, '\r')) != NULL && ch[1] != '\n' ) - fprintf( stderr, "Warning: bare CR found in input; check your line endings\n"); - ffseen = FALSE; for( ix = 0, iy = 0; inpline[ix] != '\0'; ix++ ) { if( inpline[ix] == '\f' ) {