mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-28 20:51:06 +01:00
regexp: Check if ->pmatch != NULL.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
ece1764c12
commit
29eb843fa5
@ -1214,12 +1214,16 @@ static int regtry( regex_t *preg, const char *string )
|
|||||||
preg->reginput = string;
|
preg->reginput = string;
|
||||||
|
|
||||||
for (i = 0; i < preg->nmatch; i++) {
|
for (i = 0; i < preg->nmatch; i++) {
|
||||||
|
if (preg->pmatch) {
|
||||||
preg->pmatch[i].rm_so = -1;
|
preg->pmatch[i].rm_so = -1;
|
||||||
preg->pmatch[i].rm_eo = -1;
|
preg->pmatch[i].rm_eo = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (regmatch(preg, 1)) {
|
if (regmatch(preg, 1)) {
|
||||||
|
if (preg->pmatch) {
|
||||||
preg->pmatch[0].rm_so = string - preg->start;
|
preg->pmatch[0].rm_so = string - preg->start;
|
||||||
preg->pmatch[0].rm_eo = preg->reginput - preg->start;
|
preg->pmatch[0].rm_eo = preg->reginput - preg->start;
|
||||||
|
}
|
||||||
return(1);
|
return(1);
|
||||||
} else
|
} else
|
||||||
return(0);
|
return(0);
|
||||||
@ -1569,13 +1573,13 @@ static int regmatch(regex_t *preg, int prog)
|
|||||||
if (regmatch(preg, next)) {
|
if (regmatch(preg, next)) {
|
||||||
if (OP(preg, scan) < CLOSE) {
|
if (OP(preg, scan) < CLOSE) {
|
||||||
int no = OP(preg, scan) - OPEN;
|
int no = OP(preg, scan) - OPEN;
|
||||||
if (no < preg->nmatch && preg->pmatch[no].rm_so == -1) {
|
if (no < preg->nmatch && preg->pmatch && preg->pmatch[no].rm_so == -1) {
|
||||||
preg->pmatch[no].rm_so = save - preg->start;
|
preg->pmatch[no].rm_so = save - preg->start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int no = OP(preg, scan) - CLOSE;
|
int no = OP(preg, scan) - CLOSE;
|
||||||
if (no < preg->nmatch && preg->pmatch[no].rm_eo == -1) {
|
if (no < preg->nmatch && preg->pmatch && preg->pmatch[no].rm_eo == -1) {
|
||||||
preg->pmatch[no].rm_eo = save - preg->start;
|
preg->pmatch[no].rm_eo = save - preg->start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ typedef struct {
|
|||||||
* it anyway.
|
* it anyway.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct regexp {
|
struct regexp {
|
||||||
/* -- public -- */
|
/* -- public -- */
|
||||||
int re_nsub; /* number of parenthesized subexpressions */
|
int re_nsub; /* number of parenthesized subexpressions */
|
||||||
|
|
||||||
@ -64,9 +64,9 @@ typedef struct regexp {
|
|||||||
/* Input to regexec() */
|
/* Input to regexec() */
|
||||||
regmatch_t *pmatch; /* submatches will be stored here */
|
regmatch_t *pmatch; /* submatches will be stored here */
|
||||||
int nmatch; /* size of pmatch[] */
|
int nmatch; /* size of pmatch[] */
|
||||||
} regexp;
|
};
|
||||||
|
|
||||||
typedef regexp regex_t;
|
typedef struct regexp regex_t;
|
||||||
|
|
||||||
#define REG_EXTENDED 0
|
#define REG_EXTENDED 0
|
||||||
#define REG_NEWLINE 1
|
#define REG_NEWLINE 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user