Style optimization in newly added POSIX range []] conformance, redo
'for' loop as do...while and remove variable unneded now
This commit is contained in:
parent
4d775b7759
commit
e728d480d2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26492
@ -170,11 +170,9 @@ rangematch(pattern, test, flags, newp)
|
||||
int flags;
|
||||
char **newp;
|
||||
{
|
||||
int negate, ok, first;
|
||||
int negate, ok;
|
||||
char c, c2;
|
||||
|
||||
first = 1;
|
||||
|
||||
/*
|
||||
* A bracket expression starting with an unquoted circumflex
|
||||
* character produces unspecified results (IEEE 1003.2-1992,
|
||||
@ -193,8 +191,9 @@ rangematch(pattern, test, flags, newp)
|
||||
* itself in a bracket expression if it occurs first in the list.
|
||||
* -- POSIX.2 2.8.3.2
|
||||
*/
|
||||
for (ok = 0, c = *pattern++; c != ']' || first; c = *pattern++) {
|
||||
first = 0;
|
||||
ok = 0;
|
||||
c = *pattern++;
|
||||
do {
|
||||
if (c == '\\' && !(flags & FNM_NOESCAPE))
|
||||
c = *pattern++;
|
||||
if (c == EOS)
|
||||
@ -225,7 +224,8 @@ rangematch(pattern, test, flags, newp)
|
||||
ok = 1;
|
||||
} else if (c == test)
|
||||
ok = 1;
|
||||
}
|
||||
} while ((c = *pattern++) != ']');
|
||||
|
||||
*newp = (char *)pattern;
|
||||
return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
|
||||
}
|
||||
|
@ -170,11 +170,9 @@ rangematch(pattern, test, flags, newp)
|
||||
int flags;
|
||||
char **newp;
|
||||
{
|
||||
int negate, ok, first;
|
||||
int negate, ok;
|
||||
char c, c2;
|
||||
|
||||
first = 1;
|
||||
|
||||
/*
|
||||
* A bracket expression starting with an unquoted circumflex
|
||||
* character produces unspecified results (IEEE 1003.2-1992,
|
||||
@ -193,8 +191,9 @@ rangematch(pattern, test, flags, newp)
|
||||
* itself in a bracket expression if it occurs first in the list.
|
||||
* -- POSIX.2 2.8.3.2
|
||||
*/
|
||||
for (ok = 0, c = *pattern++; c != ']' || first; c = *pattern++) {
|
||||
first = 0;
|
||||
ok = 0;
|
||||
c = *pattern++;
|
||||
do {
|
||||
if (c == '\\' && !(flags & FNM_NOESCAPE))
|
||||
c = *pattern++;
|
||||
if (c == EOS)
|
||||
@ -225,7 +224,8 @@ rangematch(pattern, test, flags, newp)
|
||||
ok = 1;
|
||||
} else if (c == test)
|
||||
ok = 1;
|
||||
}
|
||||
} while ((c = *pattern++) != ']');
|
||||
|
||||
*newp = (char *)pattern;
|
||||
return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user