From: Mike Baker Date: Fri, 12 May 2006 18:47:57 +0000 (+0000) Subject: add wildcard support to menuconfig (again) X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=95c94007503f7044d0d220964c52fa291c8903c7;p=librecmc%2Flibrecmc.git add wildcard support to menuconfig (again) SVN-Revision: 3768 --- diff --git a/openwrt/scripts/config/lex.zconf.c_shipped b/openwrt/scripts/config/lex.zconf.c_shipped index 2712384f6e..5e01ee5318 100644 --- a/openwrt/scripts/config/lex.zconf.c_shipped +++ b/openwrt/scripts/config/lex.zconf.c_shipped @@ -20,6 +20,7 @@ #include #include #include +#include /* end standard C headers. */ @@ -2259,32 +2260,52 @@ void zconf_initscan(const char *name) void zconf_nextfile(const char *name) { - struct file *file = file_lookup(name); - struct buffer *buf = malloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); - - current_buf->state = YY_CURRENT_BUFFER; - zconfin = zconf_fopen(name); - if (!zconfin) { - printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + size_t i; + int retval; + glob_t files; + char *filename; + struct file *file; + struct buffer *buf; + + retval = glob(name, GLOB_ERR | GLOB_MARK, NULL, &files); + if (retval == GLOB_NOSPACE || retval == GLOB_ABORTED || retval == GLOB_NOMATCH) { + printf("%s:%d: glob failed: %s \"%s\"\n", zconf_curname(), zconf_lineno(), + retval == GLOB_NOSPACE ? "failed to allocate memory" : + retval == GLOB_ABORTED ? "read error" : "no match", + name); exit(1); } - zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); - buf->parent = current_buf; - current_buf = buf; - if (file->flags & FILE_BUSY) { - printf("recursive scan (%s)?\n", name); - exit(1); - } - if (file->flags & FILE_SCANNED) { - printf("file %s already scanned?\n", name); - exit(1); + for (i = files.gl_pathc-1; i != (size_t)-1; --i) { + filename = files.gl_pathv[i]; + + file = file_lookup(filename); + buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(filename); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), filename); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", filename); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", filename); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; } - file->flags |= FILE_BUSY; - file->lineno = 1; - file->parent = current_file; - current_file = file; } static void zconf_endfile(void) diff --git a/openwrt/scripts/config/zconf.l b/openwrt/scripts/config/zconf.l index cfa46077c6..7acb60f8e7 100644 --- a/openwrt/scripts/config/zconf.l +++ b/openwrt/scripts/config/zconf.l @@ -12,6 +12,7 @@ #include #include #include +#include #define LKC_DIRECT_LINK #include "lkc.h" @@ -293,32 +294,52 @@ void zconf_initscan(const char *name) void zconf_nextfile(const char *name) { - struct file *file = file_lookup(name); - struct buffer *buf = malloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); - - current_buf->state = YY_CURRENT_BUFFER; - yyin = zconf_fopen(name); - if (!yyin) { - printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); + size_t i; + int retval; + glob_t files; + char *filename; + struct file *file; + struct buffer *buf; + + retval = glob(name, GLOB_ERR | GLOB_MARK, NULL, &files); + if (retval == GLOB_NOSPACE || retval == GLOB_ABORTED || retval == GLOB_NOMATCH) { + printf("%s:%d: glob failed: %s \"%s\"\n", zconf_curname(), zconf_lineno(), + retval == GLOB_NOSPACE ? "failed to allocate memory" : + retval == GLOB_ABORTED ? "read error" : "no match", + name); exit(1); } - yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); - buf->parent = current_buf; - current_buf = buf; - if (file->flags & FILE_BUSY) { - printf("recursive scan (%s)?\n", name); - exit(1); - } - if (file->flags & FILE_SCANNED) { - printf("file %s already scanned?\n", name); - exit(1); + for (i = files.gl_pathc-1; i != (size_t)-1; --i) { + filename = files.gl_pathv[i]; + + file = file_lookup(filename); + buf = malloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(filename); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), filename); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + if (file->flags & FILE_BUSY) { + printf("recursive scan (%s)?\n", filename); + exit(1); + } + if (file->flags & FILE_SCANNED) { + printf("file %s already scanned?\n", filename); + exit(1); + } + file->flags |= FILE_BUSY; + file->lineno = 1; + file->parent = current_file; + current_file = file; } - file->flags |= FILE_BUSY; - file->lineno = 1; - file->parent = current_file; - current_file = file; } static void zconf_endfile(void)