# HG changeset patch # User jwe # Date 983219175 0 # Node ID 4f1a26a730fdc393fa286acd14c01e762c783a18 # Parent bc61e418f20079edd34efd1625b473134bd66c01 [project @ 2001-02-26 20:26:14 by jwe] diff -r bc61e418f200 -r 4f1a26a730fd src/ChangeLog --- a/src/ChangeLog Fri Feb 23 02:13:11 2001 +0000 +++ b/src/ChangeLog Mon Feb 26 20:26:15 2001 +0000 @@ -1,3 +1,11 @@ +2001-02-26 John W. Eaton + + * parse.y (gobble_leading_white_space): Handle CRLF here too. + * lex.l (check_for_garbage_after_fcn_def): Likewise. + + * lex.l: Add numeric value of character to error message for + unrecognized characters. + 2001-02-22 John W. Eaton * DLD-FUNCTIONS/minmax.cc (EMPTY_RETURN_CHECK): For empty matrix diff -r bc61e418f200 -r 4f1a26a730fd src/lex.l --- a/src/lex.l Fri Feb 23 02:13:11 2001 +0000 +++ b/src/lex.l Mon Feb 26 20:26:15 2001 +0000 @@ -588,7 +588,7 @@ if (begin_comment && (c == '#' || c == '%')) ; /* Skip leading comment characters. */ else - buf += (char) c; + buf += static_cast (c); } octave_comment_buffer::append (buf); @@ -719,9 +719,9 @@ . { current_input_column++; - error ("invalid character `%s' near line %d, column %d", - undo_string_escape (yytext[0]), input_line_number, - current_input_column); + error ("invalid character `%s' (ASCII %d) near line %d, column %d", + undo_string_escape (yytext[0]), static_cast (yytext[0]), + input_line_number, current_input_column); return LEXICAL_ERROR; } @@ -1228,7 +1228,7 @@ if (in_comment) { - help_buf += (char) c; + help_buf += static_cast (c); if (c == '\n') { @@ -1498,7 +1498,7 @@ if (in_comment) { if (! beginning_of_comment) - comment_buf += (char) c; + comment_buf += static_cast (c); } else { @@ -1510,7 +1510,7 @@ case '\n': if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); octave_comment_buffer::append (comment_buf); comment_buf.resize (0); in_comment = false; @@ -1520,7 +1520,7 @@ case '\r': if (in_comment) - comment_buf += (char) c; + comment_buf += static_cast (c); if (i < len) { c = text[i++]; @@ -1529,7 +1529,7 @@ { if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); octave_comment_buffer::append (comment_buf); in_comment = false; beginning_of_comment = false; @@ -1540,7 +1540,7 @@ default: if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; } break; @@ -1581,7 +1581,7 @@ case '\t': if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; } retval |= ATE_SPACE_OR_TAB; @@ -1591,7 +1591,7 @@ retval |= ATE_NEWLINE; if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); octave_comment_buffer::append (comment_buf); comment_buf.resize (0); in_comment = false; @@ -1605,7 +1605,7 @@ if (in_comment) { if (! beginning_of_comment) - comment_buf += (char) c; + comment_buf += static_cast (c); } else { @@ -1617,7 +1617,7 @@ case '.': if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; break; } @@ -1632,7 +1632,7 @@ case '\\': if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; break; } @@ -1647,7 +1647,7 @@ default: if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; break; } @@ -1743,7 +1743,7 @@ while ((c = yyinput ()) != EOF) { - buf << (char) c; + buf << static_cast (c); switch (c) { @@ -1751,7 +1751,7 @@ case '\t': if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; } break; @@ -1763,7 +1763,7 @@ if (in_comment) { if (! beginning_of_comment) - comment_buf += (char) c; + comment_buf += static_cast (c); } else { @@ -1778,7 +1778,7 @@ case '\n': if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); octave_comment_buffer::append (comment_buf); } current_input_column = 0; @@ -1787,7 +1787,7 @@ case '\r': if (in_comment) - comment_buf += (char) c; + comment_buf += static_cast (c); c = yyinput (); if (c == EOF) break; @@ -1795,7 +1795,7 @@ { if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); octave_comment_buffer::append (comment_buf); } current_input_column = 0; @@ -1803,10 +1803,12 @@ return true; } + // Fall through... + default: if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; } else @@ -1894,7 +1896,7 @@ { if (escape_pending) { - buf << (char) c; + buf << static_cast (c); escape_pending = 0; } else @@ -1903,7 +1905,7 @@ escape_pending = 0; else { - buf << (char) c; + buf << static_cast (c); escape_pending = 1; } } @@ -1912,7 +1914,7 @@ else if (c == '.') { if (! have_ellipsis_continuation (false)) - buf << (char) c; + buf << static_cast (c); } else if (c == '\n') { @@ -1922,12 +1924,12 @@ else if (c == delim) { if (escape_pending) - buf << (char) c; + buf << static_cast (c); else { c = yyinput (); if (c == delim) - buf << (char) c; + buf << static_cast (c); else { unput (c); @@ -1959,7 +1961,7 @@ } else { - buf << (char) c; + buf << static_cast (c); } escape_pending = 0; @@ -2348,18 +2350,7 @@ case ',': if (in_comment) { - comment_buf += (char) c; - beginning_of_comment = false; - } - break; - - case '\n': - if (in_comment) - { - comment_buf += (char) c; - octave_comment_buffer::append (comment_buf); - comment_buf.resize (0); - in_comment = false; + comment_buf += static_cast (c); beginning_of_comment = false; } break; @@ -2369,7 +2360,7 @@ if (in_comment) { if (! beginning_of_comment) - comment_buf += (char) c; + comment_buf += static_cast (c); } else { @@ -2378,10 +2369,42 @@ } break; + case '\n': + if (in_comment) + { + comment_buf += static_cast (c); + octave_comment_buffer::append (comment_buf); + comment_buf.resize (0); + in_comment = false; + beginning_of_comment = false; + } + break; + + case '\r': + if (in_comment) + comment_buf += static_cast (c); + c = yyinput (); + if (c == EOF) + break; + else if (c == '\n') + { + if (in_comment) + { + comment_buf += static_cast (c); + octave_comment_buffer::append (comment_buf); + comment_buf.resize (0); + in_comment = false; + beginning_of_comment = false; + } + break; + } + + // Fall through... + default: if (in_comment) { - comment_buf += (char) c; + comment_buf += static_cast (c); beginning_of_comment = false; break; } diff -r bc61e418f200 -r 4f1a26a730fd src/parse.y --- a/src/parse.y Fri Feb 23 02:13:11 2001 +0000 +++ b/src/parse.y Mon Feb 26 20:26:15 2001 +0000 @@ -2886,11 +2886,22 @@ { std::string help_txt; + // TRUE means we have already seen the first block of comments. bool first_comments_seen = false; + + // TRUE means we are at the beginning of a comment block. bool begin_comment = false; + + // TRUE means we have already cached the help text. bool have_help_text = false; + + // TRUE means we are currently reading a comment block. bool in_comment = false; + + // TRUE means we should discard the first space from the input + // (used to strip leading spaces from the help text). bool discard_space = true; + int c; while ((c = getc (ffile)) != EOF) @@ -2955,6 +2966,12 @@ have_help_text = true; break; + case '%': + case '#': + begin_comment = true; + in_comment = true; + break; + case '\n': if (first_comments_seen) have_help_text = true; @@ -2965,11 +2982,25 @@ } continue; - case '%': - case '#': - begin_comment = true; - in_comment = true; - break; + 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)