[GRASS-SVN] r62449 - in grass/trunk/general: g.list g.remove
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 28 12:26:20 PDT 2014
Author: hcho
Date: 2014-10-28 12:26:20 -0700 (Tue, 28 Oct 2014)
New Revision: 62449
Modified:
grass/trunk/general/g.list/main.c
grass/trunk/general/g.remove/main.c
Log:
g.list/g.remove: Add -i flag for case-insensitive search
Modified: grass/trunk/general/g.list/main.c
===================================================================
--- grass/trunk/general/g.list/main.c 2014-10-28 19:24:25 UTC (rev 62448)
+++ grass/trunk/general/g.list/main.c 2014-10-28 19:26:20 UTC (rev 62449)
@@ -55,6 +55,7 @@
} opt;
struct
{
+ struct Flag *ignorecase;
struct Flag *regex;
struct Flag *extended;
struct Flag *type;
@@ -125,6 +126,11 @@
opt.output->description = _("If not given or '-' then standard output");
opt.output->guisection = _("Print");
+ flag.ignorecase = G_define_flag();
+ flag.ignorecase->key = 'i';
+ flag.ignorecase->description = _("Ignore case");
+ flag.ignorecase->guisection = _("Pattern");
+
flag.regex = G_define_flag();
flag.regex->key = 'r';
flag.regex->description =
@@ -181,7 +187,8 @@
if (opt.pattern->answer) {
if (flag.regex->answer || flag.extended->answer)
filter = G_ls_regex_filter(opt.pattern->answer, 0,
- (int)flag.extended->answer);
+ (int)flag.extended->answer,
+ (int)flag.ignorecase->answer);
else {
/* handle individual map names */
if (strchr(opt.pattern->answer, ',')) {
@@ -190,10 +197,12 @@
pattern = (char *)G_malloc(strlen(opt.pattern->answer) + 3);
sprintf(pattern, "{%s}", opt.pattern->answer);
- filter = G_ls_glob_filter(pattern, 0);
+ filter = G_ls_glob_filter(pattern, 0,
+ (int)flag.ignorecase->answer);
}
else
- filter = G_ls_glob_filter(opt.pattern->answer, 0);
+ filter = G_ls_glob_filter(opt.pattern->answer, 0,
+ (int)flag.ignorecase->answer);
}
if (!filter)
G_fatal_error(_("Unable to compile pattern <%s>"),
@@ -205,7 +214,8 @@
if (opt.exclude->answer) {
if (flag.regex->answer || flag.extended->answer)
exclude = G_ls_regex_filter(opt.exclude->answer, 1,
- (int)flag.extended->answer);
+ (int)flag.extended->answer,
+ (int)flag.ignorecase->answer);
else {
/* handle individual map names */
if (strchr(opt.exclude->answer, ',')) {
@@ -214,10 +224,12 @@
pattern = (char *)G_malloc(strlen(opt.exclude->answer) + 3);
sprintf(pattern, "{%s}", opt.exclude->answer);
- exclude = G_ls_glob_filter(pattern, 1);
+ exclude = G_ls_glob_filter(pattern, 1,
+ (int)flag.ignorecase->answer);
}
else
- exclude = G_ls_glob_filter(opt.exclude->answer, 1);
+ exclude = G_ls_glob_filter(opt.exclude->answer, 1,
+ (int)flag.ignorecase->answer);
}
if (!exclude)
G_fatal_error(_("Unable to compile pattern <%s>"),
Modified: grass/trunk/general/g.remove/main.c
===================================================================
--- grass/trunk/general/g.remove/main.c 2014-10-28 19:24:25 UTC (rev 62448)
+++ grass/trunk/general/g.remove/main.c 2014-10-28 19:26:20 UTC (rev 62449)
@@ -49,6 +49,7 @@
} opt;
struct
{
+ struct Flag *ignorecase;
struct Flag *regex;
struct Flag *extended;
struct Flag *force;
@@ -110,6 +111,11 @@
opt.exclude->description = _("File name exclusion pattern (default: none)");
opt.exclude->guisection = _("Pattern");
+ flag.ignorecase = G_define_flag();
+ flag.ignorecase->key = 'i';
+ flag.ignorecase->description = _("Ignore case");
+ flag.ignorecase->guisection = _("Pattern");
+
flag.regex = G_define_flag();
flag.regex->key = 'r';
flag.regex->description =
@@ -153,7 +159,8 @@
exclude = NULL;
if ((flag.regex->answer || flag.extended->answer) && opt.pattern->answer)
- filter = G_ls_regex_filter(pattern, 0, (int)flag.extended->answer);
+ filter = G_ls_regex_filter(pattern, 0, (int)flag.extended->answer,
+ (int)flag.ignorecase->answer);
else {
/* handle individual map names */
if (strchr(pattern, ',')) {
@@ -162,10 +169,10 @@
buf = (char *)G_malloc(strlen(pattern) + 3);
sprintf(buf, "{%s}", pattern);
- filter = G_ls_glob_filter(buf, 0);
+ filter = G_ls_glob_filter(buf, 0, (int)flag.ignorecase->answer);
}
else
- filter = G_ls_glob_filter(pattern, 0);
+ filter = G_ls_glob_filter(pattern, 0, (int)flag.ignorecase->answer);
}
if (!filter)
G_fatal_error(_("Unable to compile pattern <%s>"), pattern);
@@ -174,7 +181,8 @@
if ((flag.regex->answer || flag.extended->answer) &&
opt.exclude->answer)
exclude_filter = G_ls_regex_filter(exclude, 1,
- (int)flag.extended->answer);
+ (int)flag.extended->answer,
+ (int)flag.ignorecase->answer);
else {
/* handle individual map names */
if (strchr(exclude, ',')) {
@@ -183,10 +191,12 @@
buf = (char *)G_malloc(strlen(exclude) + 3);
sprintf(buf, "{%s}", exclude);
- exclude_filter = G_ls_glob_filter(buf, 1);
+ exclude_filter = G_ls_glob_filter(buf, 1,
+ (int)flag.ignorecase->answer);
}
else
- exclude_filter = G_ls_glob_filter(exclude, 1);
+ exclude_filter = G_ls_glob_filter(exclude, 1,
+ (int)flag.ignorecase->answer);
}
if (!exclude_filter)
G_fatal_error(_("Unable to compile pattern <%s>"), exclude);
More information about the grass-commit
mailing list