mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
libast: regex: backport robustness improvements from 93v- beta
There are two main changes:
1. The regex code now creates and uses its own stack (env->mst)
instead of using the shared standard stack (stkstd). That seems
likely to be a good thing.
2. Missing mbinit() calls were inserted. The 93v- code uses a
completely different multibyte characters API, so these needed
to be translated back to the older API. But, as mbinit() is no
longer a no-op as of 300cd199, these calls do stop things from
breaking if a previous operation is interrupted mid-character.
I think there might be a couple of off-by-one errors fixed as well,
as there are two instances of this change:
- while ((index += skip[buf[index]]) < mid);
+ while (index < mid)
+ index += skip[buf[index]];
This commit is contained in:
parent
7c30a59e25
commit
1aa8f771d8
8 changed files with 89 additions and 60 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/***********************************************************************
|
||||
* *
|
||||
* This software is part of the ast package *
|
||||
* Copyright (c) 1985-2012 AT&T Intellectual Property *
|
||||
* Copyright (c) 1985-2013 AT&T Intellectual Property *
|
||||
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
|
||||
* and is licensed under the *
|
||||
* Eclipse Public License, Version 1.0 *
|
||||
|
|
@ -173,9 +173,9 @@ typedef struct regsubop_s
|
|||
|
||||
#define HIT SSIZE_MAX
|
||||
|
||||
#define bitclr(p,c) ((p)[((c)>>3)&037]&=(~(1<<((c)&07))))
|
||||
#define bitset(p,c) ((p)[((c)>>3)&037]|=(1<<((c)&07)))
|
||||
#define bittst(p,c) ((p)[((c)>>3)&037]&(1<<((c)&07)))
|
||||
#define bitclr(p,c) ((p)[(c)>>3]&=(~(1<<((c)&07))))
|
||||
#define bitset(p,c) ((p)[(c)>>3]|=(1<<((c)&07)))
|
||||
#define bittst(p,c) ((p)[(c)>>3]&(1<<((c)&07)))
|
||||
|
||||
#define setadd(p,c) bitset((p)->bits,c)
|
||||
#define setclr(p,c) bitclr((p)->bits,c)
|
||||
|
|
@ -537,6 +537,7 @@ typedef struct reglib_s /* library private regex_t info */
|
|||
Vector_t* bestpos; /* ditto for best match */
|
||||
regmatch_t* match; /* subexrs in current match */
|
||||
regmatch_t* best; /* ditto in best match yet */
|
||||
Stk_t* mst; /* match stack */
|
||||
Stk_pos_t stk; /* exec stack pos */
|
||||
size_t min; /* minimum match length */
|
||||
size_t nsub; /* internal re_nsub */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue