• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3854 (tree)
Time2018-09-15 00:57:08
Authormagicant

Log Message

Simplify enable_alias check

Now alias substitution is performed only from the psubstitute_alias
function, it is more simple to test the enable_alias flag in it rather
than in its callers.

Change Summary

Incremental Difference

--- yash/trunk/parser.c (revision 3853)
+++ yash/trunk/parser.c (revision 3854)
@@ -868,6 +868,9 @@
868868 /* Performs alias substitution with the given parse state. */
869869 bool psubstitute_alias(parsestate_T *ps, substaliasflags_T flags)
870870 {
871+ if (!ps->enable_alias)
872+ return false;
873+
871874 size_t len = count_name_length(ps, is_alias_name_char);
872875 return substitute_alias_range(
873876 &ps->src, ps->index, ps->index + len, &ps->aliases, flags);
@@ -1121,7 +1124,7 @@
11211124 if (t != NULL)
11221125 return parse_compound_command(ps, t);
11231126
1124- if (ps->enable_alias && psubstitute_alias(ps, AF_NONGLOBAL)) {
1127+ if (psubstitute_alias(ps, AF_NONGLOBAL)) {
11251128 ps->reparse = true;
11261129 return NULL;
11271130 }
@@ -1165,8 +1168,7 @@
11651168 } else {
11661169 break;
11671170 }
1168- if (ps->enable_alias)
1169- psubstitute_alias_recursive(ps, AF_NONGLOBAL);
1171+ psubstitute_alias_recursive(ps, AF_NONGLOBAL);
11701172 }
11711173 return redirlastp;
11721174 }
@@ -1189,7 +1191,7 @@
11891191 pl_init(&wordlist);
11901192 while (ensure_buffer(ps, 1),
11911193 !is_command_delimiter_char(ps->src.contents[ps->index])) {
1192- if (!first && ps->enable_alias)
1194+ if (!first)
11931195 psubstitute_alias_recursive(ps, 0);
11941196 if ((redir = tryparse_redirect(ps)) != NULL) {
11951197 *redirlastp = redir;
@@ -1211,8 +1213,7 @@
12111213 void parse_redirect_list(parsestate_T *ps, redir_T **lastp)
12121214 {
12131215 for (;;) {
1214- if (ps->enable_alias)
1215- psubstitute_alias_recursive(ps, 0);
1216+ psubstitute_alias_recursive(ps, 0);
12161217
12171218 redir_T *redir = tryparse_redirect(ps);
12181219 if (redir == NULL)
@@ -1409,7 +1410,7 @@
14091410 * aliases are substituted before the word is parsed. */
14101411 wordunit_T *parse_word(parsestate_T *ps, bool globalaliases)
14111412 {
1412- if (globalaliases && ps->enable_alias)
1413+ if (globalaliases)
14131414 psubstitute_alias_recursive(ps, 0);
14141415
14151416 return parse_word_to(ps, is_token_delimiter_char);
Show on old repository browser