[GRASS-SVN] r62448 - in grass/trunk: include/defs lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 28 12:24:25 PDT 2014
Author: hcho
Date: 2014-10-28 12:24:25 -0700 (Tue, 28 Oct 2014)
New Revision: 62448
Modified:
grass/trunk/include/defs/gis.h
grass/trunk/lib/gis/ls_filter.c
Log:
G_ls_*_filter: Add case-insensitive option to the ls filters
Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h 2014-10-28 16:34:01 UTC (rev 62447)
+++ grass/trunk/include/defs/gis.h 2014-10-28 19:24:25 UTC (rev 62448)
@@ -414,8 +414,8 @@
/* ls_filter.c */
#ifdef HAVE_REGEX_H
-void *G_ls_regex_filter(const char *, int, int);
-void *G_ls_glob_filter(const char *, int);
+void *G_ls_regex_filter(const char *, int, int, int);
+void *G_ls_glob_filter(const char *, int, int);
void G_free_ls_filter(void *);
#endif
Modified: grass/trunk/lib/gis/ls_filter.c
===================================================================
--- grass/trunk/lib/gis/ls_filter.c 2014-10-28 16:34:01 UTC (rev 62447)
+++ grass/trunk/lib/gis/ls_filter.c 2014-10-28 19:24:25 UTC (rev 62448)
@@ -146,15 +146,17 @@
{
regex_t *regex = closure;
- return filename[0] != '.' &&
- regexec(regex, filename, 0, NULL, 0) == 0;
+ return filename[0] != '.' && regexec(regex, filename, 0, NULL, 0) == 0;
}
-void *G_ls_regex_filter(const char *pat, int exclude, int extended)
+void *G_ls_regex_filter(const char *pat, int exclude, int extended,
+ int ignorecase)
{
regex_t *regex = G_malloc(sizeof(regex_t));
- if (regcomp(regex, pat, (extended ? REG_EXTENDED : 0) | REG_NOSUB) != 0) {
+ if (regcomp(regex, pat, REG_NOSUB |
+ (extended ? REG_EXTENDED : 0) |
+ (ignorecase ? REG_ICASE : 0)) != 0) {
G_free(regex);
return NULL;
}
@@ -167,7 +169,7 @@
return regex;
}
-void *G_ls_glob_filter(const char *pat, int exclude)
+void *G_ls_glob_filter(const char *pat, int exclude, int ignorecase)
{
struct buffer buf;
regex_t *regex;
@@ -179,7 +181,7 @@
return NULL;
}
- regex = G_ls_regex_filter(buf.buf, exclude, 1);
+ regex = G_ls_regex_filter(buf.buf, exclude, 1, ignorecase);
fini(&buf);
More information about the grass-commit
mailing list