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

Commit184fb14

Browse files
committed
Make regular-expression error messages a tad less obscure,
per gripe from Josh Berkus.
1 parentc41536e commit184fb14

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

‎src/backend/regex/regerror.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ static struct rerr
5959

6060
{
6161
{
62-
REG_NOMATCH,"REG_NOMATCH","regexec() failed to match"
62+
/* NOMATCH is not really an error condition, it just says no match */
63+
REG_NOMATCH,"REG_NOMATCH","no pattern match found"
6364
},
6465
{
65-
REG_BADPAT,"REG_BADPAT","invalidregular expression"
66+
REG_BADPAT,"REG_BADPAT","invalidregex struct"
6667
},
6768
{
6869
REG_ECOLLATE,"REG_ECOLLATE","invalid collating element"
@@ -77,28 +78,28 @@ static struct rerr
7778
REG_ESUBREG,"REG_ESUBREG","invalid backreference number"
7879
},
7980
{
80-
REG_EBRACK,"REG_EBRACK","brackets([ ]) not balanced"
81+
REG_EBRACK,"REG_EBRACK","brackets [ ] not balanced"
8182
},
8283
{
83-
REG_EPAREN,"REG_EPAREN","parentheses not balanced"
84+
REG_EPAREN,"REG_EPAREN","parentheses( )not balanced"
8485
},
8586
{
86-
REG_EBRACE,"REG_EBRACE","braces not balanced"
87+
REG_EBRACE,"REG_EBRACE","braces{ }not balanced"
8788
},
8889
{
89-
REG_BADBR,"REG_BADBR","invalid repetition count(s)"
90+
REG_BADBR,"REG_BADBR","invalid repetition count(s) in { }"
9091
},
9192
{
92-
REG_ERANGE,"REG_ERANGE","invalid character range"
93+
REG_ERANGE,"REG_ERANGE","invalid character range in [ ]"
9394
},
9495
{
95-
REG_ESPACE,"REG_ESPACE","out of memory"
96+
REG_ESPACE,"REG_ESPACE","ranout of memory"
9697
},
9798
{
98-
REG_BADRPT,"REG_BADRPT","repetition-operator operand invalid"
99+
REG_BADRPT,"REG_BADRPT","?, *, or + operand invalid"
99100
},
100101
{
101-
REG_EMPTY,"REG_EMPTY","empty(sub)expression"
102+
REG_EMPTY,"REG_EMPTY","empty expression or subexpression"
102103
},
103104
{
104105
REG_ASSERT,"REG_ASSERT","\"can't happen\" -- you found a bug"

‎src/backend/regex/regex.3

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,11 @@ include the following:
464464
.PP
465465
.nf
466466
.ta\w'REG_ECOLLATE'u+3n
467-
REG_NOMATCHregexec() failed tomatch
468-
REG_BADPATinvalidregular expression
467+
REG_NOMATCHno patternmatch found
468+
REG_BADPATinvalidregex struct
469469
REG_ECOLLATEinvalid collating element
470470
REG_ECTYPEinvalid character class
471-
REG_EESCAPE\e applied to unescapable character
471+
REG_EESCAPEtrailing backslash (\e)
472472
REG_ESUBREGinvalid backreference number
473473
REG_EBRACKbrackets [ ] not balanced
474474
REG_EPARENparentheses ( ) not balanced
@@ -477,7 +477,7 @@ REG_BADBRinvalid repetition count(s) in { }
477477
REG_ERANGEinvalid character range in [ ]
478478
REG_ESPACEran out of memory
479479
REG_BADRPT?, *, or + operand invalid
480-
REG_EMPTYempty(sub)expression
480+
REG_EMPTYempty expression or subexpression
481481
REG_ASSERT``can't happen''\(emyou found a bug
482482
REG_INVARGinvalid argument, e.g. negative-length string
483483
.fi

‎src/backend/utils/adt/regexp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.34 2001/01/24 19:43:14 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.35 2001/03/19 22:27:46 tgl Exp $
1212
*
1313
*Alistair Crooks added the code for the regex caching
1414
*agc - cached the regular expressions used - there's a good chance
@@ -140,7 +140,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags)
140140
/* re didn't compile */
141141
pg95_regerror(regcomp_result,&rev[oldest].cre_re,errMsg,
142142
sizeof(errMsg));
143-
elog(ERROR,"regcomp failed with error %s",errMsg);
143+
elog(ERROR,"Invalid regular expression: %s",errMsg);
144144
}
145145

146146
/* not reached */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp