aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2005-07-17 22:50:05 +0000
committerFelix Fietkau <nbd@openwrt.org>2005-07-17 22:50:05 +0000
commitef69b8d26a7c4250ed183cc2e1df394c0ef62282 (patch)
tree4ed7f643c3127c36f7fa16bc276caf27fab5f337 /package
parent9309365917156e7dc01c10dfdb2297bd712c7c55 (diff)
downloadupstream-ef69b8d26a7c4250ed183cc2e1df394c0ef62282.tar.gz
upstream-ef69b8d26a7c4250ed183cc2e1df394c0ef62282.tar.bz2
upstream-ef69b8d26a7c4250ed183cc2e1df394c0ef62282.zip
add wildcard support to menuconfig
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@1493 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/config/lex.zconf.c_shipped65
-rw-r--r--package/config/zconf.l65
2 files changed, 86 insertions, 44 deletions
diff --git a/package/config/lex.zconf.c_shipped b/package/config/lex.zconf.c_shipped
index b877bb6b3c..83026dfaa4 100644
--- a/package/config/lex.zconf.c_shipped
+++ b/package/config/lex.zconf.c_shipped
@@ -20,6 +20,7 @@
#include <string.h>
#include <errno.h>
#include <stdlib.h>
+#include <glob.h>
/* end standard C headers. */
@@ -3622,32 +3623,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 struct buffer *zconf_endfile(void)
diff --git a/package/config/zconf.l b/package/config/zconf.l
index 55517b2877..3a4947a88a 100644
--- a/package/config/zconf.l
+++ b/package/config/zconf.l
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <glob.h>
#define LKC_DIRECT_LINK
#include "lkc.h"
@@ -301,32 +302,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 struct buffer *zconf_endfile(void)