• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3891 (tree)
Time2018-09-23 17:00:18
Authormagicant

Log Message

parser: Clear reparse flag earlier

Now the reparse' flag is true only while stack unwinding is begin done.
The
reparse' flag is cleared just after stack unwinding ends.

Change Summary

Incremental Difference

--- yash/trunk/parser.c (revision 3890)
+++ yash/trunk/parser.c (revision 3891)
@@ -510,10 +510,10 @@
510510 struct plist_T pending_heredocs;
511511 /* false when alias substitution is suppressed */
512512 bool enable_alias;
513- /* true when alias substitution has occurred */
513+ /* true when non-global alias substitution has occurred */
514514 bool reparse;
515515 /* record of alias substitutions that are responsible for the current
516- * `startindex' */
516+ * `index' */
517517 struct aliaslist_T *aliases;
518518 } parsestate_T;
519519
@@ -1800,6 +1800,7 @@
18001800 lastp = &ao->next;
18011801 }
18021802 if (ps->reparse) {
1803+ ps->reparse = false;
18031804 assert(ao == NULL);
18041805 continue;
18051806 }
@@ -1813,7 +1814,6 @@
18131814 }
18141815 if (!toeol)
18151816 ps->error |= saveerror;
1816- ps->reparse = false;
18171817 return first;
18181818 }
18191819
@@ -1860,10 +1860,12 @@
18601860 }
18611861 if (ps->reparse) {
18621862 assert(p == NULL);
1863- if (first != NULL)
1863+ if (first != NULL) {
1864+ ps->reparse = false;
18641865 goto next;
1865- else
1866+ } else {
18661867 break;
1868+ }
18671869 }
18681870
18691871 if (ps->tokentype == TT_AMPAMP)
@@ -1893,11 +1895,14 @@
18931895 serror(ps, Ngt("ksh-like extended glob pattern `!(...)' "
18941896 "is not supported"));
18951897 next_token(ps);
1896- do {
1897- c = parse_commands_in_pipeline(ps);
1898- if (ps->reparse)
1899- assert(c == NULL);
1900- } while (ps->reparse);
1898+
1899+parse_after_bang:
1900+ c = parse_commands_in_pipeline(ps);
1901+ if (ps->reparse) {
1902+ ps->reparse = false;
1903+ assert(c == NULL);
1904+ goto parse_after_bang;
1905+ }
19011906 } else {
19021907 neg = false;
19031908 c = parse_commands_in_pipeline(ps);
@@ -1930,10 +1935,12 @@
19301935 }
19311936 if (ps->reparse) {
19321937 assert(c == NULL);
1933- if (first != NULL)
1938+ if (first != NULL) {
1939+ ps->reparse = false;
19341940 goto next;
1935- else
1941+ } else {
19361942 break;
1943+ }
19371944 }
19381945
19391946 if (ps->tokentype != TT_PIPE)
@@ -1951,8 +1958,6 @@
19511958 * NULL is returned. */
19521959 command_T *parse_command(parsestate_T *ps)
19531960 {
1954- ps->reparse = false;
1955-
19561961 if (ps->tokentype == TT_BANG || ps->tokentype == TT_IN ||
19571962 is_closing_tokentype(ps->tokentype)) {
19581963 print_errmsg_token_unexpected(ps);
@@ -1964,6 +1969,10 @@
19641969 return result;
19651970
19661971 if (psubstitute_alias(ps, AF_NONGLOBAL)) {
1972+ /* After alias substitution, we need to re-parse the new current token,
1973+ * which may be consumed by the caller of this function. We set the
1974+ * `reparse' flag to tell the caller to re-parse the token. The caller
1975+ * will reset the flag when staring re-parsing. */
19671976 ps->reparse = true;
19681977 return NULL;
19691978 }
Show on old repository browser