# HG changeset patch # User jwe # Date 1066325647 0 # Node ID 491ac5f9d1207bb6742cc9653cfb9497fcb04ac4 # Parent 5c6f7daf1e3f3a453d34ed5da3a5833b17b2ad1e [project @ 2003-10-16 17:34:07 by jwe] diff -r 5c6f7daf1e3f -r 491ac5f9d120 src/ChangeLog --- a/src/ChangeLog Thu Oct 16 04:01:30 2003 +0000 +++ b/src/ChangeLog Thu Oct 16 17:34:07 2003 +0000 @@ -1,3 +1,8 @@ +2003-10-16 John W. Eaton + + * parse.y (text_getc): New static function. + (gobble_leading_white_space): Use it to simplify EOL processing. + 2003-10-15 John W. Eaton * file-io.cc (fopen_mode_to_ios_mode): Ignore "t" in mode string. diff -r 5c6f7daf1e3f -r 491ac5f9d120 src/parse.y --- a/src/parse.y Thu Oct 16 04:01:30 2003 +0000 +++ b/src/parse.y Thu Oct 16 17:34:07 2003 +0000 @@ -3060,6 +3060,27 @@ return retval; } +static int +text_getc (FILE *f) +{ + int c = getc (f); + + // Convert CRLF into just LF. + + if (c == '\r') + { + c = getc (f); + + if (c != '\n') + { + ungetc (c, f); + c = '\r'; + } + } + + return c; +} + // Eat whitespace and comments from FFILE, returning the text of the // comments read if it doesn't look like a copyright notice. If // IN_PARTS, consider each block of comments separately; otherwise, @@ -3095,7 +3116,7 @@ int c; - while ((c = getc (ffile)) != EOF) + while ((c = text_getc (ffile)) != EOF) { if (update_pos) current_input_column++; @@ -3134,7 +3155,7 @@ if (in_parts) { - if ((c = getc (ffile)) != EOF) + if ((c = text_getc (ffile)) != EOF) { if (update_pos) current_input_column--; @@ -3173,26 +3194,6 @@ } continue; - case '\r': - c = getc (ffile); - if (update_pos) - current_input_column++; - if (c == EOF) - goto done; - else if (c == '\n') - { - if (first_comments_seen) - have_help_text = true; - if (update_pos) - { - input_line_number++; - current_input_column = 0; - } - continue; - } - - // Fall through... - default: if (update_pos) current_input_column--;