Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb44d92b

Browse files
committed
Sync regex code with Tcl 8.6.4.
Sync our regex code with upstream changes since last time we did this,which was Tcl 8.5.11 (see commit08fd6ff).The only functional change here is to disbelieve that an octal escape isthree digits long if it would exceed \377. That's a bug fix, but it'sa minor one and could change the interpretation of working regexes, sodon't back-patch.In addition to that, s/INFINITY/DUPINF/ to eliminate the risk of collisionswith <math.h>'s macro, and s/LOCAL/NOPROP/ because that also seems likean unnecessarily collision-prone macro name.There were some other cosmetic changes in their copy that I did not adopt,notably a rather half-hearted attempt at renaming some of the C functionsin a more verbose style. (I'm not necessarily against the concept, butrenaming just a few functions in the package is not an improvement.)
1 parentd0f18cd commitb44d92b

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

‎src/backend/regex/regc_lex.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,12 @@ lexescape(struct vars * v)
860860
c=lexdigits(v,8,1,3);
861861
if (ISERR())
862862
FAILW(REG_EESCAPE);
863+
if (c>0xff)
864+
{
865+
/* out of range, so we handled one digit too much */
866+
v->now--;
867+
c >>=3;
868+
}
863869
RETV(PLAIN,c);
864870
break;
865871
default:

‎src/backend/regex/regcomp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -960,13 +960,13 @@ parseqatom(struct vars * v,
960960
{
961961
case'*':
962962
m=0;
963-
n=INFINITY;
963+
n=DUPINF;
964964
qprefer= (v->nextvalue) ?LONGER :SHORTER;
965965
NEXT();
966966
break;
967967
case'+':
968968
m=1;
969-
n=INFINITY;
969+
n=DUPINF;
970970
qprefer= (v->nextvalue) ?LONGER :SHORTER;
971971
NEXT();
972972
break;
@@ -984,7 +984,7 @@ parseqatom(struct vars * v,
984984
if (SEE(DIGIT))
985985
n=scannum(v);
986986
else
987-
n=INFINITY;
987+
n=DUPINF;
988988
if (m>n)
989989
{
990990
ERR(REG_BADBR);
@@ -1146,8 +1146,8 @@ parseqatom(struct vars * v,
11461146
* really care where its submatches are.
11471147
*/
11481148
dupnfa(v->nfa,atom->begin,atom->end,s,atom->begin);
1149-
assert(m >=1&&m!=INFINITY&&n >=1);
1150-
repeat(v,s,atom->begin,m-1, (n==INFINITY) ?n :n-1);
1149+
assert(m >=1&&m!=DUPINF&&n >=1);
1150+
repeat(v,s,atom->begin,m-1, (n==DUPINF) ?n :n-1);
11511151
f=COMBINE(qprefer,atom->flags);
11521152
t=subre(v,'.',f,s,atom->end);/* prefix and atom */
11531153
NOERR();
@@ -1268,7 +1268,7 @@ repeat(struct vars * v,
12681268
#defineSOME 2
12691269
#defineINF 3
12701270
#definePAIR(x,y) ((x)*4 + (y))
1271-
#defineREDUCE(x) ( ((x) ==INFINITY) ? INF : (((x) > 1) ? SOME : (x)) )
1271+
#defineREDUCE(x) ( ((x) ==DUPINF) ? INF : (((x) > 1) ? SOME : (x)) )
12721272
constintrm=REDUCE(m);
12731273
constintrn=REDUCE(n);
12741274
structstate*s;
@@ -2026,7 +2026,7 @@ stdump(struct subre * t,
20262026
if (t->min!=1||t->max!=1)
20272027
{
20282028
fprintf(f," {%d,",t->min);
2029-
if (t->max!=INFINITY)
2029+
if (t->max!=DUPINF)
20302030
fprintf(f,"%d",t->max);
20312031
fprintf(f,"}");
20322032
}

‎src/backend/regex/regexec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ cbrdissect(struct vars * v,
865865
if (tlen %brlen!=0)
866866
returnREG_NOMATCH;
867867
numreps=tlen /brlen;
868-
if (numreps<min|| (numreps>max&&max!=INFINITY))
868+
if (numreps<min|| (numreps>max&&max!=DUPINF))
869869
returnREG_NOMATCH;
870870

871871
/* okay, compare the actual string contents */
@@ -964,7 +964,7 @@ citerdissect(struct vars * v,
964964
* sub-match endpoints in endpts[1..max_matches].
965965
*/
966966
max_matches=end-begin;
967-
if (max_matches>t->max&&t->max!=INFINITY)
967+
if (max_matches>t->max&&t->max!=DUPINF)
968968
max_matches=t->max;
969969
if (max_matches<min_matches)
970970
max_matches=min_matches;
@@ -1149,7 +1149,7 @@ creviterdissect(struct vars * v,
11491149
* sub-match endpoints in endpts[1..max_matches].
11501150
*/
11511151
max_matches=end-begin;
1152-
if (max_matches>t->max&&t->max!=INFINITY)
1152+
if (max_matches>t->max&&t->max!=DUPINF)
11531153
max_matches=t->max;
11541154
if (max_matches<min_matches)
11551155
max_matches=min_matches;

‎src/include/regex/regguts.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@
7878
#endif
7979

8080
/* want size of a char in bits, and max value in bounded quantifiers */
81-
#ifndefCHAR_BIT
82-
#include<limits.h>
83-
#endif
8481
#ifndef_POSIX2_RE_DUP_MAX
8582
#define_POSIX2_RE_DUP_MAX255/* normally from <limits.h> */
8683
#endif
@@ -95,7 +92,7 @@
9592
#definexxx1
9693

9794
#defineDUPMAX_POSIX2_RE_DUP_MAX
98-
#defineINFINITY(DUPMAX+1)
95+
#defineDUPINF(DUPMAX+1)
9996

10097
#defineREMAGIC 0xfed7/* magic number for main struct */
10198

@@ -419,15 +416,15 @@ struct subre
419416
#defineLONGER 01/* prefers longer match */
420417
#defineSHORTER 02/* prefers shorter match */
421418
#defineMIXED 04/* mixed preference below */
422-
#defineCAP 010/* capturing parens below */
419+
#defineCAP 010/* capturing parens below */
423420
#defineBACKR 020/* back reference below */
424421
#defineINUSE 0100/* in use in final tree */
425-
#defineLOCAL 03/* bits which may not propagate up */
422+
#defineNOPROP 03/* bits which may not propagate up */
426423
#defineLMIX(f) ((f)<<2)/* LONGER -> MIXED */
427424
#defineSMIX(f) ((f)<<1)/* SHORTER -> MIXED */
428-
#defineUP(f) (((f)&~LOCAL) | (LMIX(f) & SMIX(f) & MIXED))
425+
#defineUP(f) (((f)&~NOPROP) | (LMIX(f) & SMIX(f) & MIXED))
429426
#defineMESSY(f) ((f)&(MIXED|CAP|BACKR))
430-
#definePREF(f) ((f)&LOCAL)
427+
#definePREF(f) ((f)&NOPROP)
431428
#definePREF2(f1,f2) ((PREF(f1) != 0) ? PREF(f1) : PREF(f2))
432429
#defineCOMBINE(f1,f2) (UP((f1)|(f2)) | PREF2(f1, f2))
433430
shortid;/* ID of subre (1..ntree-1) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp