Mercurial > hg > octave-max
changeset 4540:491ac5f9d120
[project @ 2003-10-16 17:34:07 by jwe]
author | jwe |
---|---|
date | Thu, 16 Oct 2003 17:34:07 +0000 |
parents | 5c6f7daf1e3f |
children | 3774dc061cdc |
files | src/ChangeLog src/parse.y |
diffstat | 2 files changed, 28 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-10-16 John W. Eaton <jwe@bevo.che.wisc.edu> + + * parse.y (text_getc): New static function. + (gobble_leading_white_space): Use it to simplify EOL processing. + 2003-10-15 John W. Eaton <jwe@bevo.che.wisc.edu> * file-io.cc (fopen_mode_to_ios_mode): Ignore "t" in mode string.
--- a/src/parse.y +++ b/src/parse.y @@ -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--;