comparison src/lex.l @ 991:18be848f10a9

[project @ 1994-12-15 06:06:46 by jwe]
author jwe
date Thu, 15 Dec 1994 06:07:08 +0000
parents 4b483cf9f6b0
children 641c05eaed01
comparison
equal deleted inserted replaced
990:d2dd114ba5dd 991:18be848f10a9
639 639
640 // Only ask for input from stdin if we are expecting interactive 640 // Only ask for input from stdin if we are expecting interactive
641 // input. 641 // input.
642 if (interactive && ! (reading_fcn_file || get_input_from_eval_string)) 642 if (interactive && ! (reading_fcn_file || get_input_from_eval_string))
643 yyrestart (stdin); 643 yyrestart (stdin);
644
645 // Delete the buffer for help text.
646 delete [] help_buf;
647 help_buf = 0;
644 } 648 }
645 649
646 // Replace backslash escapes in a string with the real values. 650 // Replace backslash escapes in a string with the real values.
647 651
648 static void 652 static void
983 tmp_local_sym_tab = new symbol_table (); 987 tmp_local_sym_tab = new symbol_table ();
984 curr_sym_tab = tmp_local_sym_tab; 988 curr_sym_tab = tmp_local_sym_tab;
985 defining_func = 1; 989 defining_func = 1;
986 promptflag--; 990 promptflag--;
987 beginning_of_function = 1; 991 beginning_of_function = 1;
988 help_buf[0] = '\0';
989 if (! (reading_fcn_file || reading_script_file)) 992 if (! (reading_fcn_file || reading_script_file))
990 input_line_number = 1; 993 input_line_number = 1;
991 return FCN; 994 return FCN;
992 } 995 }
993 } 996 }
1088 // Grab the help text from an function file. 1091 // Grab the help text from an function file.
1089 1092
1090 static void 1093 static void
1091 grab_help_text (void) 1094 grab_help_text (void)
1092 { 1095 {
1093 int max_len = HELP_BUF_LENGTH - 1; 1096 if (! help_buf)
1094 1097 {
1095 int in_comment = 1; 1098 ostrstream buf;
1096 int len = 0; 1099
1097 int c = 0; 1100 int in_comment = 1;
1098 1101 int c = 0;
1099 while ((c = yyinput ()) != EOF) 1102
1100 { 1103 while ((c = yyinput ()) != EOF)
1101 if (in_comment)
1102 { 1104 {
1103 help_buf[len++] = c; 1105 if (in_comment)
1104 if (c == '\n')
1105 in_comment = 0;
1106 }
1107 else
1108 {
1109 switch (c)
1110 { 1106 {
1111 case '%': 1107 buf << (char) c;
1112 case '#': 1108 if (c == '\n')
1113 in_comment = 1; 1109 in_comment = 0;
1114 break; 1110 }
1115 1111 else
1116 case ' ': 1112 {
1117 case '\t': 1113 switch (c)
1118 break; 1114 {
1119 1115 case '%':
1120 default: 1116 case '#':
1121 goto done; 1117 in_comment = 1;
1118 break;
1119
1120 case ' ':
1121 case '\t':
1122 break;
1123
1124 default:
1125 goto done;
1126 }
1122 } 1127 }
1123 } 1128 }
1124 1129
1125 if (len > max_len) 1130 done:
1131
1132 if (c)
1133 yyunput (c, yytext);
1134
1135 buf << ends;
1136
1137 help_buf = buf.str ();
1138
1139 if (! help_buf || ! *help_buf)
1126 { 1140 {
1127 warning ("grab_help_text: buffer overflow after caching %d chars", 1141 delete [] help_buf;
1128 max_len); 1142 help_buf = 0;
1129 break;
1130 } 1143 }
1131 } 1144 }
1132
1133 done:
1134
1135 if (c)
1136 yyunput (c, yytext);
1137
1138 help_buf[len] = '\0';
1139 } 1145 }
1140 1146
1141 // Return 1 if the given character matches any character in the given 1147 // Return 1 if the given character matches any character in the given
1142 // string. 1148 // string.
1143 1149