summaryrefslogtreecommitdiff
path: root/spectro/aglob.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-08-23 12:22:51 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-08-23 12:22:51 +0200
commitbc3604d9b226ac475a104cd8ae2ca2d1d4a27984 (patch)
treee796661f371a94a50edfdc693388bb911b253dfd /spectro/aglob.c
parent509016be676f7915d635fa57144d2a441e3090ca (diff)
parentc0b89ac5bfb90835ef01573267020e42d4fe070c (diff)
Merge new upstream release
Diffstat (limited to 'spectro/aglob.c')
-rwxr-xr-x[-rw-r--r--]spectro/aglob.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/spectro/aglob.c b/spectro/aglob.c
index e700f76..2ba37d5 100644..100755
--- a/spectro/aglob.c
+++ b/spectro/aglob.c
@@ -102,8 +102,34 @@ int aglob_create(aglob *g, char *spath) {
g->first = 1;
g->ff = _findfirst(spath, &g->ffs);
#else /* UNIX */
+ char *tpath, *d, *s;
+
+ /* Make a copy of the pattern with extra space */
+ if ((tpath = malloc(4 * strlen(spath)+1)) == NULL) {
+ a1loge(g_log, 1, "aglob_create: malloc failed\n");
+ return 1;
+ }
+ strcpy(tpath, spath);
+
+ /* If there is a file extension, make it case insensitive */
+ if ((s = strrchr(spath, '.')) != NULL) {
+ d = tpath + (s - spath);
+ while (*s != '\000') {
+ if (isalpha(*s)) {
+ *d++ = '[';
+ *d++ = tolower(*s);
+ *d++ = toupper(*s++);
+ *d++ = ']';
+ } else {
+ *d++ = *s++;
+ }
+ }
+ *d++ = '\000';
+//printf("~` converted '%s' to '%s'\n",spath,tpath);
+ }
memset(&g->g, 0, sizeof(g->g));
- g->rv = glob(spath, GLOB_NOSORT, NULL, &g->g);
+ g->rv = glob(tpath, GLOB_NOSORT, NULL, &g->g);
+ free(tpath);
//a1loge(g_log, 0, "~1 glob '%s' returns %d and gl_pathc = %d\n",spath,g->rv,g->g.gl_pathc);
if (g->rv == GLOB_NOSPACE) {
a1loge(g_log, 1, "aglob_create: glob returned GLOB_NOSPACE\n");