diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-28 03:42:31 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-28 03:42:31 +0000 |
commit | 41eb300ff6500f9f14a2a67b3934423f51c17108 (patch) | |
tree | 3a202df08597c20234ea3e61de28476c2f2cb73b | |
parent | 727752d2d2968e67784935dd35c32a97c0c13a7c (diff) | |
download | busybox-w32-41eb300ff6500f9f14a2a67b3934423f51c17108.tar.gz busybox-w32-41eb300ff6500f9f14a2a67b3934423f51c17108.tar.bz2 busybox-w32-41eb300ff6500f9f14a2a67b3934423f51c17108.zip |
ash: shrink on top of previous change
function old new delta
readtoken1 3201 3221 +20
xxreadtoken 306 313 +7
pungetc 13 12 -1
ash_main 1380 1379 -1
setinputfile 196 192 -4
plinno 4 - -4
parsenleft 4 - -4
parsenextc 4 - -4
parselleft 4 - -4
setinputstring 67 62 -5
pushstring 123 114 -9
pgetc 455 438 -17
pushfile 69 31 -38
popfile 114 76 -38
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 2/8 up/down: 27/-129) Total: -102 bytes
text data bss dec hex filename
798750 564 7756 807070 c509e busybox_old
798664 560 7748 806972 c503c busybox_unstripped
-rw-r--r-- | shell/ash.c | 239 |
1 files changed, 128 insertions, 111 deletions
diff --git a/shell/ash.c b/shell/ash.c index e1df89418..05e2f630d 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -1033,8 +1033,8 @@ struct alias; | |||
1033 | 1033 | ||
1034 | struct strpush { | 1034 | struct strpush { |
1035 | struct strpush *prev; /* preceding string on stack */ | 1035 | struct strpush *prev; /* preceding string on stack */ |
1036 | char *prevstring; | 1036 | char *prev_string; |
1037 | int prevnleft; | 1037 | int prev_left_in_line; |
1038 | #if ENABLE_ASH_ALIAS | 1038 | #if ENABLE_ASH_ALIAS |
1039 | struct alias *ap; /* if push was associated with an alias */ | 1039 | struct alias *ap; /* if push was associated with an alias */ |
1040 | #endif | 1040 | #endif |
@@ -1045,9 +1045,9 @@ struct parsefile { | |||
1045 | struct parsefile *prev; /* preceding file on stack */ | 1045 | struct parsefile *prev; /* preceding file on stack */ |
1046 | int linno; /* current line */ | 1046 | int linno; /* current line */ |
1047 | int fd; /* file descriptor (or -1 if string) */ | 1047 | int fd; /* file descriptor (or -1 if string) */ |
1048 | int nleft; /* number of chars left in this line */ | 1048 | int left_in_line; /* number of chars left in this line */ |
1049 | int lleft; /* number of chars left in this buffer */ | 1049 | int left_in_buffer; /* number of chars left in this buffer past the line */ |
1050 | char *nextc; /* next char in buffer */ | 1050 | char *next_to_pgetc; /* next char in buffer */ |
1051 | char *buf; /* input buffer */ | 1051 | char *buf; /* input buffer */ |
1052 | struct strpush *strpush; /* for pushing strings at this level */ | 1052 | struct strpush *strpush; /* for pushing strings at this level */ |
1053 | struct strpush basestrpush; /* so pushing one is fast */ | 1053 | struct strpush basestrpush; /* so pushing one is fast */ |
@@ -9084,19 +9084,48 @@ enum { | |||
9084 | INPUT_NOFILE_OK = 2, | 9084 | INPUT_NOFILE_OK = 2, |
9085 | }; | 9085 | }; |
9086 | 9086 | ||
9087 | static int plinno = 1; /* input line number */ | ||
9088 | /* number of characters left in input buffer */ | ||
9089 | static int parsenleft; /* copy of parsefile->nleft */ | ||
9090 | static int parselleft; /* copy of parsefile->lleft */ | ||
9091 | /* next character in input buffer */ | ||
9092 | static char *parsenextc; /* copy of parsefile->nextc */ | ||
9093 | |||
9094 | static smallint checkkwd; | 9087 | static smallint checkkwd; |
9095 | /* values of checkkwd variable */ | 9088 | /* values of checkkwd variable */ |
9096 | #define CHKALIAS 0x1 | 9089 | #define CHKALIAS 0x1 |
9097 | #define CHKKWD 0x2 | 9090 | #define CHKKWD 0x2 |
9098 | #define CHKNL 0x4 | 9091 | #define CHKNL 0x4 |
9099 | 9092 | ||
9093 | /* | ||
9094 | * Push a string back onto the input at this current parsefile level. | ||
9095 | * We handle aliases this way. | ||
9096 | */ | ||
9097 | #if !ENABLE_ASH_ALIAS | ||
9098 | #define pushstring(s, ap) pushstring(s) | ||
9099 | #endif | ||
9100 | static void | ||
9101 | pushstring(char *s, struct alias *ap) | ||
9102 | { | ||
9103 | struct strpush *sp; | ||
9104 | int len; | ||
9105 | |||
9106 | len = strlen(s); | ||
9107 | INT_OFF; | ||
9108 | if (g_parsefile->strpush) { | ||
9109 | sp = ckzalloc(sizeof(*sp)); | ||
9110 | sp->prev = g_parsefile->strpush; | ||
9111 | } else { | ||
9112 | sp = &(g_parsefile->basestrpush); | ||
9113 | } | ||
9114 | g_parsefile->strpush = sp; | ||
9115 | sp->prev_string = g_parsefile->next_to_pgetc; | ||
9116 | sp->prev_left_in_line = g_parsefile->left_in_line; | ||
9117 | #if ENABLE_ASH_ALIAS | ||
9118 | sp->ap = ap; | ||
9119 | if (ap) { | ||
9120 | ap->flag |= ALIASINUSE; | ||
9121 | sp->string = s; | ||
9122 | } | ||
9123 | #endif | ||
9124 | g_parsefile->next_to_pgetc = s; | ||
9125 | g_parsefile->left_in_line = len; | ||
9126 | INT_ON; | ||
9127 | } | ||
9128 | |||
9100 | static void | 9129 | static void |
9101 | popstring(void) | 9130 | popstring(void) |
9102 | { | 9131 | { |
@@ -9105,7 +9134,9 @@ popstring(void) | |||
9105 | INT_OFF; | 9134 | INT_OFF; |
9106 | #if ENABLE_ASH_ALIAS | 9135 | #if ENABLE_ASH_ALIAS |
9107 | if (sp->ap) { | 9136 | if (sp->ap) { |
9108 | if (parsenextc[-1] == ' ' || parsenextc[-1] == '\t') { | 9137 | if (g_parsefile->next_to_pgetc[-1] == ' ' |
9138 | || g_parsefile->next_to_pgetc[-1] == '\t' | ||
9139 | ) { | ||
9109 | checkkwd |= CHKALIAS; | 9140 | checkkwd |= CHKALIAS; |
9110 | } | 9141 | } |
9111 | if (sp->string != sp->ap->val) { | 9142 | if (sp->string != sp->ap->val) { |
@@ -9117,8 +9148,8 @@ popstring(void) | |||
9117 | } | 9148 | } |
9118 | } | 9149 | } |
9119 | #endif | 9150 | #endif |
9120 | parsenextc = sp->prevstring; | 9151 | g_parsefile->next_to_pgetc = sp->prev_string; |
9121 | parsenleft = sp->prevnleft; | 9152 | g_parsefile->left_in_line = sp->prev_left_in_line; |
9122 | g_parsefile->strpush = sp->prev; | 9153 | g_parsefile->strpush = sp->prev; |
9123 | if (sp != &(g_parsefile->basestrpush)) | 9154 | if (sp != &(g_parsefile->basestrpush)) |
9124 | free(sp); | 9155 | free(sp); |
@@ -9130,8 +9161,8 @@ preadfd(void) | |||
9130 | { | 9161 | { |
9131 | int nr; | 9162 | int nr; |
9132 | char *buf = g_parsefile->buf; | 9163 | char *buf = g_parsefile->buf; |
9133 | parsenextc = buf; | ||
9134 | 9164 | ||
9165 | g_parsefile->next_to_pgetc = buf; | ||
9135 | #if ENABLE_FEATURE_EDITING | 9166 | #if ENABLE_FEATURE_EDITING |
9136 | retry: | 9167 | retry: |
9137 | if (!iflag || g_parsefile->fd != STDIN_FILENO) | 9168 | if (!iflag || g_parsefile->fd != STDIN_FILENO) |
@@ -9182,8 +9213,9 @@ preadfd(void) | |||
9182 | * Refill the input buffer and return the next input character: | 9213 | * Refill the input buffer and return the next input character: |
9183 | * | 9214 | * |
9184 | * 1) If a string was pushed back on the input, pop it; | 9215 | * 1) If a string was pushed back on the input, pop it; |
9185 | * 2) If an EOF was pushed back (parsenleft < -BIGNUM) or we are reading | 9216 | * 2) If an EOF was pushed back (g_parsefile->left_in_line < -BIGNUM) |
9186 | * from a string so we can't refill the buffer, return EOF. | 9217 | * or we are reading from a string so we can't refill the buffer, |
9218 | * return EOF. | ||
9187 | * 3) If the is more stuff in this buffer, use it else call read to fill it. | 9219 | * 3) If the is more stuff in this buffer, use it else call read to fill it. |
9188 | * 4) Process input up to the next newline, deleting nul characters. | 9220 | * 4) Process input up to the next newline, deleting nul characters. |
9189 | */ | 9221 | */ |
@@ -9197,8 +9229,10 @@ preadbuffer(void) | |||
9197 | 9229 | ||
9198 | while (g_parsefile->strpush) { | 9230 | while (g_parsefile->strpush) { |
9199 | #if ENABLE_ASH_ALIAS | 9231 | #if ENABLE_ASH_ALIAS |
9200 | if (parsenleft == -1 && g_parsefile->strpush->ap | 9232 | if (g_parsefile->left_in_line == -1 |
9201 | && parsenextc[-1] != ' ' && parsenextc[-1] != '\t' | 9233 | && g_parsefile->strpush->ap |
9234 | && g_parsefile->next_to_pgetc[-1] != ' ' | ||
9235 | && g_parsefile->next_to_pgetc[-1] != '\t' | ||
9202 | ) { | 9236 | ) { |
9203 | pgetc_debug("preadbuffer PEOA"); | 9237 | pgetc_debug("preadbuffer PEOA"); |
9204 | return PEOA; | 9238 | return PEOA; |
@@ -9206,43 +9240,51 @@ preadbuffer(void) | |||
9206 | #endif | 9240 | #endif |
9207 | popstring(); | 9241 | popstring(); |
9208 | /* try "pgetc" now: */ | 9242 | /* try "pgetc" now: */ |
9209 | pgetc_debug("internal pgetc at %d:%p'%s'", parsenleft, parsenextc, parsenextc); | 9243 | pgetc_debug("preadbuffer internal pgetc at %d:%p'%s'", |
9210 | if (--parsenleft >= 0) | 9244 | g_parsefile->left_in_line, |
9211 | return signed_char2int(*parsenextc++); | 9245 | g_parsefile->next_to_pgetc, |
9212 | } | 9246 | g_parsefile->next_to_pgetc); |
9213 | /* on both branches above parsenleft < 0. | 9247 | if (--g_parsefile->left_in_line >= 0) |
9248 | return (unsigned char)(*g_parsefile->next_to_pgetc++); | ||
9249 | } | ||
9250 | /* on both branches above g_parsefile->left_in_line < 0. | ||
9214 | * "pgetc" needs refilling. | 9251 | * "pgetc" needs refilling. |
9215 | */ | 9252 | */ |
9216 | 9253 | ||
9217 | /* -90 is -BIGNUM. Below we use -99 to mark "EOF on read", | 9254 | /* -90 is -BIGNUM. Below we use -99 to mark "EOF on read", |
9218 | * pungetc() may decrement it a few times. -90 is enough. | 9255 | * pungetc() may increment it a few times. |
9256 | * Assuming it won't increment it to 0. | ||
9219 | */ | 9257 | */ |
9220 | if (parsenleft < -90 || g_parsefile->buf == NULL) { | 9258 | if (g_parsefile->left_in_line < -90 || g_parsefile->buf == NULL) { |
9221 | pgetc_debug("preadbuffer PEOF1"); | 9259 | pgetc_debug("preadbuffer PEOF1"); |
9222 | /* even in failure keep them in lock step, | 9260 | /* even in failure keep left_in_line and next_to_pgetc |
9223 | * for correct pungetc. */ | 9261 | * in lock step, for correct multi-layer pungetc. |
9224 | parsenextc++; | 9262 | * left_in_line was decremented before preadbuffer(), |
9263 | * must inc next_to_pgetc: */ | ||
9264 | g_parsefile->next_to_pgetc++; | ||
9225 | return PEOF; | 9265 | return PEOF; |
9226 | } | 9266 | } |
9227 | 9267 | ||
9228 | more = parselleft; | 9268 | more = g_parsefile->left_in_buffer; |
9229 | if (more <= 0) { | 9269 | if (more <= 0) { |
9230 | flush_stdout_stderr(); | 9270 | flush_stdout_stderr(); |
9231 | again: | 9271 | again: |
9232 | more = preadfd(); | 9272 | more = preadfd(); |
9233 | if (more <= 0) { | 9273 | if (more <= 0) { |
9234 | parselleft = parsenleft = -99; | 9274 | /* don't try reading again */ |
9275 | g_parsefile->left_in_line = -99; | ||
9235 | pgetc_debug("preadbuffer PEOF2"); | 9276 | pgetc_debug("preadbuffer PEOF2"); |
9236 | parsenextc++; | 9277 | g_parsefile->next_to_pgetc++; |
9237 | return PEOF; | 9278 | return PEOF; |
9238 | } | 9279 | } |
9239 | } | 9280 | } |
9240 | 9281 | ||
9241 | /* Find out where's the end of line. | 9282 | /* Find out where's the end of line. |
9242 | * Set parsenleft/parselleft acordingly. | 9283 | * Set g_parsefile->left_in_line |
9284 | * and g_parsefile->left_in_buffer acordingly. | ||
9243 | * NUL chars are deleted. | 9285 | * NUL chars are deleted. |
9244 | */ | 9286 | */ |
9245 | q = parsenextc; | 9287 | q = g_parsefile->next_to_pgetc; |
9246 | for (;;) { | 9288 | for (;;) { |
9247 | char c; | 9289 | char c; |
9248 | 9290 | ||
@@ -9254,37 +9296,47 @@ preadbuffer(void) | |||
9254 | } else { | 9296 | } else { |
9255 | q++; | 9297 | q++; |
9256 | if (c == '\n') { | 9298 | if (c == '\n') { |
9257 | parsenleft = q - parsenextc - 1; | 9299 | g_parsefile->left_in_line = q - g_parsefile->next_to_pgetc - 1; |
9258 | break; | 9300 | break; |
9259 | } | 9301 | } |
9260 | } | 9302 | } |
9261 | 9303 | ||
9262 | if (more <= 0) { | 9304 | if (more <= 0) { |
9263 | parsenleft = q - parsenextc - 1; | 9305 | g_parsefile->left_in_line = q - g_parsefile->next_to_pgetc - 1; |
9264 | if (parsenleft < 0) | 9306 | if (g_parsefile->left_in_line < 0) |
9265 | goto again; | 9307 | goto again; |
9266 | break; | 9308 | break; |
9267 | } | 9309 | } |
9268 | } | 9310 | } |
9269 | parselleft = more; | 9311 | g_parsefile->left_in_buffer = more; |
9270 | 9312 | ||
9271 | if (vflag) { | 9313 | if (vflag) { |
9272 | char save = *q; | 9314 | char save = *q; |
9273 | *q = '\0'; | 9315 | *q = '\0'; |
9274 | out2str(parsenextc); | 9316 | out2str(g_parsefile->next_to_pgetc); |
9275 | *q = save; | 9317 | *q = save; |
9276 | } | 9318 | } |
9277 | 9319 | ||
9278 | pgetc_debug("preadbuffer at %d:%p'%s'", parsenleft, parsenextc, parsenextc); | 9320 | pgetc_debug("preadbuffer at %d:%p'%s'", |
9279 | return signed_char2int(*parsenextc++); | 9321 | g_parsefile->left_in_line, |
9322 | g_parsefile->next_to_pgetc, | ||
9323 | g_parsefile->next_to_pgetc); | ||
9324 | return (unsigned char)(*g_parsefile->next_to_pgetc++); | ||
9280 | } | 9325 | } |
9281 | 9326 | ||
9282 | #define pgetc_as_macro() (--parsenleft >= 0 ? signed_char2int(*parsenextc++) : preadbuffer()) | 9327 | #define pgetc_as_macro() \ |
9328 | (--g_parsefile->left_in_line >= 0 \ | ||
9329 | ? (unsigned char)(*g_parsefile->next_to_pgetc++) \ | ||
9330 | : preadbuffer() \ | ||
9331 | ) | ||
9283 | 9332 | ||
9284 | static int | 9333 | static int |
9285 | pgetc(void) | 9334 | pgetc(void) |
9286 | { | 9335 | { |
9287 | pgetc_debug("pgetc at %d:%p'%s'", parsenleft, parsenextc, parsenextc); | 9336 | pgetc_debug("pgetc_fast at %d:%p'%s'", |
9337 | g_parsefile->left_in_line, | ||
9338 | g_parsefile->next_to_pgetc, | ||
9339 | g_parsefile->next_to_pgetc); | ||
9288 | return pgetc_as_macro(); | 9340 | return pgetc_as_macro(); |
9289 | } | 9341 | } |
9290 | 9342 | ||
@@ -9303,6 +9355,10 @@ pgetc2(void) | |||
9303 | { | 9355 | { |
9304 | int c; | 9356 | int c; |
9305 | do { | 9357 | do { |
9358 | pgetc_debug("pgetc_fast at %d:%p'%s'", | ||
9359 | g_parsefile->left_in_line, | ||
9360 | g_parsefile->next_to_pgetc, | ||
9361 | g_parsefile->next_to_pgetc); | ||
9306 | c = pgetc_fast(); | 9362 | c = pgetc_fast(); |
9307 | } while (c == PEOA); | 9363 | } while (c == PEOA); |
9308 | return c; | 9364 | return c; |
@@ -9343,45 +9399,12 @@ pfgets(char *line, int len) | |||
9343 | static void | 9399 | static void |
9344 | pungetc(void) | 9400 | pungetc(void) |
9345 | { | 9401 | { |
9346 | parsenleft++; | 9402 | g_parsefile->left_in_line++; |
9347 | parsenextc--; | 9403 | g_parsefile->next_to_pgetc--; |
9348 | pgetc_debug("pushed back to %d:%p'%s'", parsenleft, parsenextc, parsenextc); | 9404 | pgetc_debug("pushed back to %d:%p'%s'", |
9349 | } | 9405 | g_parsefile->left_in_line, |
9350 | 9406 | g_parsefile->next_to_pgetc, | |
9351 | /* | 9407 | g_parsefile->next_to_pgetc); |
9352 | * Push a string back onto the input at this current parsefile level. | ||
9353 | * We handle aliases this way. | ||
9354 | */ | ||
9355 | #if !ENABLE_ASH_ALIAS | ||
9356 | #define pushstring(s, ap) pushstring(s) | ||
9357 | #endif | ||
9358 | static void | ||
9359 | pushstring(char *s, struct alias *ap) | ||
9360 | { | ||
9361 | struct strpush *sp; | ||
9362 | int len; | ||
9363 | |||
9364 | len = strlen(s); | ||
9365 | INT_OFF; | ||
9366 | if (g_parsefile->strpush) { | ||
9367 | sp = ckzalloc(sizeof(*sp)); | ||
9368 | sp->prev = g_parsefile->strpush; | ||
9369 | } else { | ||
9370 | sp = &(g_parsefile->basestrpush); | ||
9371 | } | ||
9372 | g_parsefile->strpush = sp; | ||
9373 | sp->prevstring = parsenextc; | ||
9374 | sp->prevnleft = parsenleft; | ||
9375 | #if ENABLE_ASH_ALIAS | ||
9376 | sp->ap = ap; | ||
9377 | if (ap) { | ||
9378 | ap->flag |= ALIASINUSE; | ||
9379 | sp->string = s; | ||
9380 | } | ||
9381 | #endif | ||
9382 | parsenextc = s; | ||
9383 | parsenleft = len; | ||
9384 | INT_ON; | ||
9385 | } | 9408 | } |
9386 | 9409 | ||
9387 | /* | 9410 | /* |
@@ -9393,10 +9416,6 @@ pushfile(void) | |||
9393 | { | 9416 | { |
9394 | struct parsefile *pf; | 9417 | struct parsefile *pf; |
9395 | 9418 | ||
9396 | g_parsefile->nleft = parsenleft; | ||
9397 | g_parsefile->lleft = parselleft; | ||
9398 | g_parsefile->nextc = parsenextc; | ||
9399 | g_parsefile->linno = plinno; | ||
9400 | pf = ckzalloc(sizeof(*pf)); | 9419 | pf = ckzalloc(sizeof(*pf)); |
9401 | pf->prev = g_parsefile; | 9420 | pf->prev = g_parsefile; |
9402 | pf->fd = -1; | 9421 | pf->fd = -1; |
@@ -9418,10 +9437,6 @@ popfile(void) | |||
9418 | popstring(); | 9437 | popstring(); |
9419 | g_parsefile = pf->prev; | 9438 | g_parsefile = pf->prev; |
9420 | free(pf); | 9439 | free(pf); |
9421 | parsenleft = g_parsefile->nleft; | ||
9422 | parselleft = g_parsefile->lleft; | ||
9423 | parsenextc = g_parsefile->nextc; | ||
9424 | plinno = g_parsefile->linno; | ||
9425 | INT_ON; | 9440 | INT_ON; |
9426 | } | 9441 | } |
9427 | 9442 | ||
@@ -9464,8 +9479,9 @@ setinputfd(int fd, int push) | |||
9464 | g_parsefile->fd = fd; | 9479 | g_parsefile->fd = fd; |
9465 | if (g_parsefile->buf == NULL) | 9480 | if (g_parsefile->buf == NULL) |
9466 | g_parsefile->buf = ckmalloc(IBUFSIZ); | 9481 | g_parsefile->buf = ckmalloc(IBUFSIZ); |
9467 | parselleft = parsenleft = 0; | 9482 | g_parsefile->left_in_buffer = 0; |
9468 | plinno = 1; | 9483 | g_parsefile->left_in_line = 0; |
9484 | g_parsefile->linno = 1; | ||
9469 | } | 9485 | } |
9470 | 9486 | ||
9471 | /* | 9487 | /* |
@@ -9506,10 +9522,10 @@ setinputstring(char *string) | |||
9506 | { | 9522 | { |
9507 | INT_OFF; | 9523 | INT_OFF; |
9508 | pushfile(); | 9524 | pushfile(); |
9509 | parsenextc = string; | 9525 | g_parsefile->next_to_pgetc = string; |
9510 | parsenleft = strlen(string); | 9526 | g_parsefile->left_in_line = strlen(string); |
9511 | g_parsefile->buf = NULL; | 9527 | g_parsefile->buf = NULL; |
9512 | plinno = 1; | 9528 | g_parsefile->linno = 1; |
9513 | INT_ON; | 9529 | INT_ON; |
9514 | } | 9530 | } |
9515 | 9531 | ||
@@ -10653,7 +10669,7 @@ readtoken1(int firstc, int syntax, char *eofmark, int striptabs) | |||
10653 | (void) &prevsyntax; | 10669 | (void) &prevsyntax; |
10654 | (void) &syntax; | 10670 | (void) &syntax; |
10655 | #endif | 10671 | #endif |
10656 | startlinno = plinno; | 10672 | startlinno = g_parsefile->linno; |
10657 | bqlist = NULL; | 10673 | bqlist = NULL; |
10658 | quotef = 0; | 10674 | quotef = 0; |
10659 | oldstyle = 0; | 10675 | oldstyle = 0; |
@@ -10681,7 +10697,7 @@ readtoken1(int firstc, int syntax, char *eofmark, int striptabs) | |||
10681 | if (syntax == BASESYNTAX) | 10697 | if (syntax == BASESYNTAX) |
10682 | goto endword; /* exit outer loop */ | 10698 | goto endword; /* exit outer loop */ |
10683 | USTPUTC(c, out); | 10699 | USTPUTC(c, out); |
10684 | plinno++; | 10700 | g_parsefile->linno++; |
10685 | if (doprompt) | 10701 | if (doprompt) |
10686 | setprompt(2); | 10702 | setprompt(2); |
10687 | c = pgetc(); | 10703 | c = pgetc(); |
@@ -10835,7 +10851,7 @@ readtoken1(int firstc, int syntax, char *eofmark, int striptabs) | |||
10835 | if (syntax != BASESYNTAX && !parsebackquote && eofmark == NULL) | 10851 | if (syntax != BASESYNTAX && !parsebackquote && eofmark == NULL) |
10836 | raise_error_syntax("unterminated quoted string"); | 10852 | raise_error_syntax("unterminated quoted string"); |
10837 | if (varnest != 0) { | 10853 | if (varnest != 0) { |
10838 | startlinno = plinno; | 10854 | startlinno = g_parsefile->linno; |
10839 | /* { */ | 10855 | /* { */ |
10840 | raise_error_syntax("missing '}'"); | 10856 | raise_error_syntax("missing '}'"); |
10841 | } | 10857 | } |
@@ -10890,7 +10906,7 @@ checkend: { | |||
10890 | continue; | 10906 | continue; |
10891 | if (*p == '\n' && *q == '\0') { | 10907 | if (*p == '\n' && *q == '\0') { |
10892 | c = PEOF; | 10908 | c = PEOF; |
10893 | plinno++; | 10909 | g_parsefile->linno++; |
10894 | needprompt = doprompt; | 10910 | needprompt = doprompt; |
10895 | } else { | 10911 | } else { |
10896 | pushstring(line, NULL); | 10912 | pushstring(line, NULL); |
@@ -11166,7 +11182,7 @@ parsebackq: { | |||
11166 | case '\\': | 11182 | case '\\': |
11167 | pc = pgetc(); | 11183 | pc = pgetc(); |
11168 | if (pc == '\n') { | 11184 | if (pc == '\n') { |
11169 | plinno++; | 11185 | g_parsefile->linno++; |
11170 | if (doprompt) | 11186 | if (doprompt) |
11171 | setprompt(2); | 11187 | setprompt(2); |
11172 | /* | 11188 | /* |
@@ -11189,11 +11205,11 @@ parsebackq: { | |||
11189 | #if ENABLE_ASH_ALIAS | 11205 | #if ENABLE_ASH_ALIAS |
11190 | case PEOA: | 11206 | case PEOA: |
11191 | #endif | 11207 | #endif |
11192 | startlinno = plinno; | 11208 | startlinno = g_parsefile->linno; |
11193 | raise_error_syntax("EOF in backquote substitution"); | 11209 | raise_error_syntax("EOF in backquote substitution"); |
11194 | 11210 | ||
11195 | case '\n': | 11211 | case '\n': |
11196 | plinno++; | 11212 | g_parsefile->linno++; |
11197 | needprompt = doprompt; | 11213 | needprompt = doprompt; |
11198 | break; | 11214 | break; |
11199 | 11215 | ||
@@ -11334,7 +11350,7 @@ xxreadtoken(void) | |||
11334 | if (needprompt) { | 11350 | if (needprompt) { |
11335 | setprompt(2); | 11351 | setprompt(2); |
11336 | } | 11352 | } |
11337 | startlinno = plinno; | 11353 | startlinno = g_parsefile->linno; |
11338 | for (;;) { /* until token or start of word found */ | 11354 | for (;;) { /* until token or start of word found */ |
11339 | c = pgetc_fast(); | 11355 | c = pgetc_fast(); |
11340 | if (c == ' ' || c == '\t' USE_ASH_ALIAS( || c == PEOA)) | 11356 | if (c == ' ' || c == '\t' USE_ASH_ALIAS( || c == PEOA)) |
@@ -11349,7 +11365,7 @@ xxreadtoken(void) | |||
11349 | pungetc(); | 11365 | pungetc(); |
11350 | break; /* return readtoken1(...) */ | 11366 | break; /* return readtoken1(...) */ |
11351 | } | 11367 | } |
11352 | startlinno = ++plinno; | 11368 | startlinno = ++g_parsefile->linno; |
11353 | if (doprompt) | 11369 | if (doprompt) |
11354 | setprompt(2); | 11370 | setprompt(2); |
11355 | } else { | 11371 | } else { |
@@ -11358,7 +11374,7 @@ xxreadtoken(void) | |||
11358 | p = xxreadtoken_chars + sizeof(xxreadtoken_chars) - 1; | 11374 | p = xxreadtoken_chars + sizeof(xxreadtoken_chars) - 1; |
11359 | if (c != PEOF) { | 11375 | if (c != PEOF) { |
11360 | if (c == '\n') { | 11376 | if (c == '\n') { |
11361 | plinno++; | 11377 | g_parsefile->linno++; |
11362 | needprompt = doprompt; | 11378 | needprompt = doprompt; |
11363 | } | 11379 | } |
11364 | 11380 | ||
@@ -11400,7 +11416,7 @@ xxreadtoken(void) | |||
11400 | if (needprompt) { | 11416 | if (needprompt) { |
11401 | setprompt(2); | 11417 | setprompt(2); |
11402 | } | 11418 | } |
11403 | startlinno = plinno; | 11419 | startlinno = g_parsefile->linno; |
11404 | for (;;) { /* until token or start of word found */ | 11420 | for (;;) { /* until token or start of word found */ |
11405 | c = pgetc_fast(); | 11421 | c = pgetc_fast(); |
11406 | switch (c) { | 11422 | switch (c) { |
@@ -11416,7 +11432,7 @@ xxreadtoken(void) | |||
11416 | continue; | 11432 | continue; |
11417 | case '\\': | 11433 | case '\\': |
11418 | if (pgetc() == '\n') { | 11434 | if (pgetc() == '\n') { |
11419 | startlinno = ++plinno; | 11435 | startlinno = ++g_parsefile->linno; |
11420 | if (doprompt) | 11436 | if (doprompt) |
11421 | setprompt(2); | 11437 | setprompt(2); |
11422 | continue; | 11438 | continue; |
@@ -11424,7 +11440,7 @@ xxreadtoken(void) | |||
11424 | pungetc(); | 11440 | pungetc(); |
11425 | goto breakloop; | 11441 | goto breakloop; |
11426 | case '\n': | 11442 | case '\n': |
11427 | plinno++; | 11443 | g_parsefile->linno++; |
11428 | needprompt = doprompt; | 11444 | needprompt = doprompt; |
11429 | RETURN(TNL); | 11445 | RETURN(TNL); |
11430 | case PEOF: | 11446 | case PEOF: |
@@ -13454,7 +13470,7 @@ static void | |||
13454 | init(void) | 13470 | init(void) |
13455 | { | 13471 | { |
13456 | /* from input.c: */ | 13472 | /* from input.c: */ |
13457 | basepf.nextc = basepf.buf = basebuf; | 13473 | basepf.next_to_pgetc = basepf.buf = basebuf; |
13458 | 13474 | ||
13459 | /* from trap.c: */ | 13475 | /* from trap.c: */ |
13460 | signal(SIGCHLD, SIG_DFL); | 13476 | signal(SIGCHLD, SIG_DFL); |
@@ -13575,7 +13591,8 @@ reset(void) | |||
13575 | evalskip = 0; | 13591 | evalskip = 0; |
13576 | loopnest = 0; | 13592 | loopnest = 0; |
13577 | /* from input.c: */ | 13593 | /* from input.c: */ |
13578 | parselleft = parsenleft = 0; /* clear input buffer */ | 13594 | g_parsefile->left_in_buffer = 0; |
13595 | g_parsefile->left_in_line = 0; /* clear input buffer */ | ||
13579 | popallfiles(); | 13596 | popallfiles(); |
13580 | /* from parser.c: */ | 13597 | /* from parser.c: */ |
13581 | tokpushback = 0; | 13598 | tokpushback = 0; |