- Timestamp:
- Nov 4, 2024 12:58:52 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grep/lib/dfa.c
r3532 r3658 1227 1227 if (backslash) 1228 1228 goto normal_char; 1229 /* kmk: cl v19.29.30139/amd64 messes this function up when optimizing 1230 for speed, workaround is to optimize it for size instead. The 1231 symptom is that the following SED expression fail to match: 1232 s/^[0-9a-fA-F]\{1,\} \(00[0-9a-fA-F]*\) ABS *notype *External *| \([^.]\{1,\}\)\.\(.*$\)/ 1=\1 2=\2 3=\3/ 1233 1234 Seems the exact problem is that it gets the indexing here wrong: 1235 dfa->lex.ptr[!(dfa->syntax.syntax_bits & RE_NO_BK_PARENS) & (dfa->lex.ptr[0] == '\\')] 1236 It forgets to do the ` dfa->lex.ptr[0] == '\\' ` part and instead 1237 ANDs with a register initialized to zero. Rewriting the 1238 expressions using the tinary operator works around the problem, 1239 although the resulting code is a lot bulkier. 1240 */ 1229 1241 if (dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_ANCHORS 1230 1242 || dfa->lex.left == 0 1243 #ifdef _MSC_VER /* see above */ 1244 || (!(dfa->syntax.syntax_bits & RE_NO_BK_PARENS) 1245 ? dfa->lex.left > 1 && dfa->lex.ptr[dfa->lex.ptr[0] == '\\'] == ')' 1246 : dfa->lex.left > 0 && dfa->lex.ptr[0] == ')') 1247 #else 1231 1248 || ((dfa->lex.left 1232 1249 > !(dfa->syntax.syntax_bits & RE_NO_BK_PARENS)) … … 1234 1251 & (dfa->lex.ptr[0] == '\\')] 1235 1252 == ')')) 1253 #endif 1254 #ifdef _MSC_VER /* see above */ 1255 || (!(dfa->syntax.syntax_bits & RE_NO_BK_VBAR) 1256 ? dfa->lex.left > 1 && dfa->lex.ptr[dfa->lex.ptr[0] == '\\'] == '|' 1257 : dfa->lex.left > 0 && dfa->lex.ptr[0] == '|') 1258 #else 1236 1259 || ((dfa->lex.left 1237 1260 > !(dfa->syntax.syntax_bits & RE_NO_BK_VBAR)) … … 1239 1262 & (dfa->lex.ptr[0] == '\\')] 1240 1263 == '|')) 1264 #endif 1241 1265 || ((dfa->syntax.syntax_bits & RE_NEWLINE_ALT) 1242 1266 && dfa->lex.left > 0 && dfa->lex.ptr[0] == '\n'))
Note:
See TracChangeset
for help on using the changeset viewer.