From c0b89ac5bfb90835ef01573267020e42d4fe070c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 23 Aug 2015 12:17:05 +0200 Subject: Imported Upstream version 1.8.0 --- spectro/aglob.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) mode change 100644 => 100755 spectro/aglob.c (limited to 'spectro/aglob.c') diff --git a/spectro/aglob.c b/spectro/aglob.c old mode 100644 new mode 100755 index e700f76..2ba37d5 --- 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"); -- cgit v1.2.3