# HG changeset patch # User jwe # Date 789677913 0 # Node ID 7a632c749c6780b540585b34d5080a53885c7958 # Parent 9a64a46f22241c9a46bb8306033ba5ccda5b9aab [project @ 1995-01-09 18:58:33 by jwe] diff -r 9a64a46f2224 -r 7a632c749c67 src/lex.l --- a/src/lex.l Sat Jan 07 19:29:47 1995 +0000 +++ b/src/lex.l Mon Jan 09 18:58:33 1995 +0000 @@ -450,7 +450,7 @@ %} {CCHAR} { - if (nesting_level.empty () && beginning_of_function) + if (! help_buf && beginning_of_function && nesting_level.empty ()) { grab_help_text (); beginning_of_function = 0; @@ -1093,59 +1093,60 @@ return curr_sym_tab->lookup (name, 1, 0); } -// Grab the help text from an function file. +// Grab the help text from an function file. Always overwrites the +// current contents of help_buf. static void grab_help_text (void) { - if (! help_buf) - { - ostrstream buf; + delete [] help_buf; + help_buf = 0; + + ostrstream buf; + + int in_comment = 1; + int c = 0; - int in_comment = 1; - int c = 0; - - while ((c = yyinput ()) != EOF) + while ((c = yyinput ()) != EOF) + { + if (in_comment) { - if (in_comment) + buf << (char) c; + if (c == '\n') + in_comment = 0; + } + else + { + switch (c) { - buf << (char) c; - if (c == '\n') - in_comment = 0; - } - else - { - switch (c) - { - case '%': - case '#': - in_comment = 1; - break; + case '%': + case '#': + in_comment = 1; + break; - case ' ': - case '\t': - break; + case ' ': + case '\t': + break; - default: - goto done; - } + default: + goto done; } } - - done: + } - if (c) - yyunput (c, yytext); + done: - buf << ends; + if (c) + yyunput (c, yytext); - help_buf = buf.str (); + buf << ends; + + help_buf = buf.str (); - if (! help_buf || ! *help_buf) - { - delete [] help_buf; - help_buf = 0; - } + if (! help_buf || ! *help_buf) + { + delete [] help_buf; + help_buf = 0; } }