Commit 5ca9b6fb authored by Petr Machata's avatar Petr Machata

Replace one manual loop in glob.c with a call to memchr

- In the process, get rid of use of uninitialized i for cases that
  length is 0.  Since length should be > 0 anyway in that code, add
  an assert covering that.
parent aeb54901
......@@ -27,13 +27,11 @@
static ssize_t
match_character_class(const char *glob, size_t length, size_t from)
{
size_t i = 0;
if (length > 0)
for (i = from + 2; i < length - 1 && glob[++i] != ':'; )
;
if (i >= length || glob[++i] != ']')
assert(length > 0);
const char *colon = memchr(glob + from + 2, ':', length - 1);
if (colon == NULL || colon[1] != ']')
return -1;
return i;
return colon - glob;
}
static ssize_t
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment