# HG changeset patch # User jwe # Date 1155711323 0 # Node ID 51cbaa2539f4667247ee51e1e4d79f87d96caae5 # Parent 25da9a7d5f6d72aa9f068e5647606d93719e6be1 [project @ 2006-08-16 06:55:23 by jwe] diff -r 25da9a7d5f6d -r 51cbaa2539f4 src/ChangeLog --- a/src/ChangeLog Wed Aug 16 06:52:19 2006 +0000 +++ b/src/ChangeLog Wed Aug 16 06:55:23 2006 +0000 @@ -1,3 +1,8 @@ +2006-08-16 John W. Eaton + + * parse.y (gobble_leading_white_space): New arg, SKIP_CODE. + Change all uses. + 2006-08-15 John W. Eaton * help.cc (help_from_file): Call get_help_from_file with new file diff -r 25da9a7d5f6d -r 51cbaa2539f4 src/parse.y --- a/src/parse.y Wed Aug 16 06:52:19 2006 +0000 +++ b/src/parse.y Wed Aug 16 06:55:23 2006 +0000 @@ -3003,14 +3003,28 @@ // grab them all at once. If UPDATE_POS is TRUE, line and column // number information is updated. If SAVE_COPYRIGHT is TRUE, then // comments that are recognized as a copyright notice are saved in the -// comment buffer. +// comment buffer. If SKIP_CODE is TRUE, then ignore code, otherwise +// stop at the first non-whitespace character that is not part of a +// comment. + +// FIXME -- skipping code will fail for something like this: +// +// function foo (x) +// fprintf ('%d\n', x); +// +// % This is the help for foo. +// +// because we recognize the '%' in the fprintf format as a comment +// character. Fixing this will probably require actually parsing the +// file properly. // FIXME -- grab_help_text() in lex.l duplicates some of this // code! static std::string gobble_leading_white_space (FILE *ffile, bool in_parts, - bool update_pos, bool save_copyright) + bool update_pos, bool save_copyright, + bool skip_code) { std::string help_txt; @@ -3111,10 +3125,15 @@ continue; default: - if (update_pos) - current_input_column--; - ungetc (c, ffile); - goto done; + if (skip_code) + continue; + else + { + if (update_pos) + current_input_column--; + ungetc (c, ffile); + goto done; + } } } } @@ -3132,8 +3151,8 @@ } if (in_parts && help_txt.empty ()) - help_txt = gobble_leading_white_space (ffile, in_parts, - update_pos, false); + help_txt = gobble_leading_white_space (ffile, in_parts, update_pos, + false, skip_code); } return help_txt; @@ -3157,7 +3176,7 @@ { unwind_protect::add (safe_fclose, fptr); - retval = gobble_leading_white_space (fptr, true, true, false); + retval = gobble_leading_white_space (fptr, true, true, false, true); unwind_protect::run (); } @@ -3180,7 +3199,7 @@ long pos = ftell (ffile); - gobble_leading_white_space (ffile, false, false, false); + gobble_leading_white_space (ffile, false, false, false, false); char buf [10]; fgets (buf, 10, ffile); @@ -3280,14 +3299,14 @@ reset_parser (); std::string txt - = gobble_leading_white_space (ffile, true, true, true); + = gobble_leading_white_space (ffile, true, true, true, false); help_buf.push (txt); octave_comment_buffer::append (txt); // FIXME -- this should not be necessary. - gobble_leading_white_space (ffile, false, true, false); + gobble_leading_white_space (ffile, false, true, false, false); int status = yyparse ();