summaryrefslogtreecommitdiff
path: root/glob.c
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-08-22 20:34:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-08-22 20:34:56 +0900
commit517f5529d7008eba87b8b2fee5ec9ec0a5075f6e (patch)
treec71720a9b41309713c089478f921165bd2d63b25 /glob.c
parent689b9dbb8d7f88ab91e7741932ed000b6e49be9a (diff)
downloadltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.tar.gz
ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.tar.bz2
ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.zip
Imported Upstream version 0.7.91upstream/0.7.91upstream
Diffstat (limited to 'glob.c')
-rw-r--r--glob.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/glob.c b/glob.c
index 9af633f..4f826c7 100644
--- a/glob.c
+++ b/glob.c
@@ -1,6 +1,6 @@
/*
* This file is part of ltrace.
- * Copyright (C) 2007, 2008, 2012 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2007,2008,2012,2013 Petr Machata, Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -27,13 +27,11 @@
static ssize_t
match_character_class(const char *glob, size_t length, size_t from)
{
- size_t i;
- 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
@@ -63,14 +61,9 @@ match_brack(const char *glob, size_t length, size_t from, int *exclmp)
}
++i; /* skip any character, including [ or ] */
- int escape = 0;
for (; i < length; ++i) {
char c = glob[i];
- if (escape) {
- ++i;
- escape = 0;
-
- } else if (c == '[' && glob[i + 1] == ':') {
+ if (c == '[' && glob[i + 1] == ':') {
ssize_t j = match_character_class(glob, length, i);
if (j < 0)
goto fail;
@@ -180,7 +173,7 @@ glob_to_regex(const char *glob, char **retp)
goto fail;
}
*retp = buf;
- return REG_NOERROR;
+ return 0;
}
int
@@ -188,7 +181,7 @@ globcomp(regex_t *preg, const char *glob, int cflags)
{
char *regex = NULL;
int status = glob_to_regex(glob, &regex);
- if (status != REG_NOERROR)
+ if (status != 0)
return status;
assert(regex != NULL);
status = regcomp(preg, regex, cflags);