• R/O
  • SSH
  • HTTPS

yash: 提交


Commit MetaInfo

修訂4178 (tree)
時間2021-12-14 00:20:18
作者magicant

Log Message

Parse command substitution in regex correctly (#43395)

Change Summary

差異

--- yash/trunk/NEWS (revision 4177)
+++ yash/trunk/NEWS (revision 4178)
@@ -8,6 +8,13 @@
88 x: new bug
99
1010 ----------------------------------------------------------------------
11+Yash 2.53 (????-??-??)
12+
13+ * Fixed a bug where command substitutions contained in the regular
14+ expression inside the "[[ word =~ regex ]]" syntax were not
15+ parsed correctly.
16+
17+----------------------------------------------------------------------
1118 Yash 2.52 (2021-10-11)
1219
1320 = Unquoted multiple empty fields resulting from a single word
--- yash/trunk/parser.c (revision 4177)
+++ yash/trunk/parser.c (revision 4178)
@@ -2937,8 +2937,8 @@
29372937
29382938 /* So, before calling this function, the current token must have been parsed
29392939 * as usual by the `next_token' function. We start by examining the current
2940- * status to decide how we continue parsing possible remainder of the token.
2941- */
2940+ * status to determine how to continue parsing the token's possible
2941+ * remainder.*/
29422942 if (ps->token == NULL) {
29432943 switch (ps->src.contents[ps->index]) {
29442944 case L'(':
@@ -2954,8 +2954,13 @@
29542954 ps->index = ps->next_index;
29552955 }
29562956
2957- /* Find the end of the result from the previous `next_token' call. */
2958- wordunit_T **lastp = &ps->token;
2957+ /* Keep the word units from being overwritten while parsing inner commands
2958+ * that may be contained in the rest of the token. */
2959+ wordunit_T *token = ps->token;
2960+ ps->token = NULL;
2961+
2962+ /* Find the place to append results. */
2963+ wordunit_T **lastp = &token;
29592964 while (*lastp != NULL)
29602965 lastp = &(*lastp)->next;
29612966
@@ -3020,8 +3025,8 @@
30203025 MAKE_WORDUNIT_STRING;
30213026 ps->next_index = ps->index;
30223027 ps->index = grandstartindex;
3023- if (ps->token != NULL)
3024- ps->tokentype = TT_WORD;
3028+ wordfree(ps->token), ps->token = token;
3029+ ps->tokentype = TT_WORD;
30253030 return parse_double_bracket_operand(ps);
30263031 }
30273032
Show on old repository browser