Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/tre/dist/lib check more eo, initialize shift, r...



details:   https://anonhg.NetBSD.org/src/rev/07e84d9c3bc4
branches:  trunk
changeset: 357482:07e84d9c3bc4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 12 20:56:37 2017 +0000

description:
check more eo, initialize shift, remove useless variable.

diffstat:

 external/bsd/tre/dist/lib/regexec.c |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (35 lines):

diff -r 08745a1dffbd -r 07e84d9c3bc4 external/bsd/tre/dist/lib/regexec.c
--- a/external/bsd/tre/dist/lib/regexec.c       Sun Nov 12 20:04:51 2017 +0000
+++ b/external/bsd/tre/dist/lib/regexec.c       Sun Nov 12 20:56:37 2017 +0000
@@ -199,26 +199,25 @@
        size_t nmatch, regmatch_t pmatch[], int eflags)
 {
        size_t shift, len, i;
-       int startend, ret;
+       int ret;
        tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
        regmatch_t *p;
 
        if (eflags & REG_STARTEND) {
-               if (pmatch == NULL || pmatch->rm_so < 0
+               if (pmatch == NULL || pmatch->rm_so < 0 || pmatch->rm_eo < 0
                    || pmatch->rm_so > pmatch->rm_eo)
                        return REG_INVARG;
                str += shift = pmatch->rm_so;
                len = pmatch->rm_eo - pmatch->rm_so;
-               eflags = (unsigned)(eflags & ~REG_STARTEND);
-               startend = 1;
+               eflags &= ~REG_STARTEND;
        } else {
+               shift = 0;
                len = (size_t)-1;
-               startend = 0;
        }
 
        ret = tre_regnexec(preg, str, len, nmatch, pmatch, eflags);
 
-       if (!ret && !(tnfa->cflags & REG_NOSUB) && startend) {
+       if (!ret && !(tnfa->cflags & REG_NOSUB) && len != (size_t)-1) {
                for (i = nmatch, p = pmatch; i > 0; p++, i--) {
                        if (p->rm_so >= 0) p->rm_so += shift;
                        if (p->rm_eo >= 0) p->rm_eo += shift;



Home | Main Index | Thread Index | Old Index