mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
regexp: Import change from JimTcl.
* regexp/jimregexp.h, regexp/jimregexp.c: Fix from JimTcl. -- Apply the change in JimTcl: commit ac35b8a6ec417f75b5ec86ca64ea1614a8170a38 Author: Steve Bennett <steveb@workware.net.au> Date: Mon May 4 20:43:46 2020 +1000 regexp: Improved error message Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
5fe3cdfc76
commit
91cb46d948
@ -723,7 +723,7 @@ static int regatom(regex_t *preg, int *flagp)
|
||||
pattern++;
|
||||
}
|
||||
|
||||
while (*pattern && *pattern != ']') {
|
||||
while (*pattern != ']') {
|
||||
/* Is this a range? a-z */
|
||||
int start;
|
||||
int end;
|
||||
@ -735,6 +735,11 @@ static int regatom(regex_t *preg, int *flagp)
|
||||
};
|
||||
int cc;
|
||||
|
||||
if (!*pattern) {
|
||||
preg->err = REG_ERR_UNMATCHED_BRACKET;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pattern += reg_utf8_tounicode_case(pattern, &start, nocase);
|
||||
if (start == '\\') {
|
||||
/* First check for class shorthand escapes */
|
||||
@ -758,6 +763,10 @@ static int regatom(regex_t *preg, int *flagp)
|
||||
preg->err = REG_ERR_NULL_CHAR;
|
||||
return 0;
|
||||
}
|
||||
if (start == '\\' && *pattern == 0) {
|
||||
preg->err = REG_ERR_INVALID_ESCAPE;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (pattern[0] == '-' && pattern[1] && pattern[1] != ']') {
|
||||
/* skip '-' */
|
||||
@ -769,6 +778,10 @@ static int regatom(regex_t *preg, int *flagp)
|
||||
preg->err = REG_ERR_NULL_CHAR;
|
||||
return 0;
|
||||
}
|
||||
if (start == '\\' && *pattern == 0) {
|
||||
preg->err = REG_ERR_INVALID_ESCAPE;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
reg_addrange(preg, start, end);
|
||||
@ -873,7 +886,7 @@ cc_switch:
|
||||
ch = *preg->regparse++;
|
||||
switch (ch) {
|
||||
case '\0':
|
||||
preg->err = REG_ERR_TRAILING_BACKSLASH;
|
||||
preg->err = REG_ERR_INVALID_ESCAPE;
|
||||
return 0;
|
||||
case 'A':
|
||||
ret = regnode(preg, BOLX);
|
||||
@ -1883,9 +1896,10 @@ size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_s
|
||||
"nested count",
|
||||
"internal error",
|
||||
"count follows nothing",
|
||||
"trailing backslash",
|
||||
"invalid escape \\ sequence",
|
||||
"corrupted program",
|
||||
"contains null char",
|
||||
"brackets [] not balanced",
|
||||
};
|
||||
const char *err;
|
||||
|
||||
|
@ -91,9 +91,10 @@ enum {
|
||||
REG_ERR_NESTED_COUNT,
|
||||
REG_ERR_INTERNAL,
|
||||
REG_ERR_COUNT_FOLLOWS_NOTHING,
|
||||
REG_ERR_TRAILING_BACKSLASH,
|
||||
REG_ERR_INVALID_ESCAPE,
|
||||
REG_ERR_CORRUPTED,
|
||||
REG_ERR_NULL_CHAR,
|
||||
REG_ERR_UNMATCHED_BRACKET,
|
||||
REG_ERR_NUM
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user