diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-16 19:31:53 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-16 19:31:53 +0300 |
commit | c8865a0d524f3d545836bd4581329089a357661e (patch) | |
tree | 4fc437a07086c4304e7ec2446be2a504a3dbd507 /src | |
parent | 50e703a9a92e755f928699b705612cd4153ffb9f (diff) | |
download | grecs-c8865a0d524f3d545836bd4581329089a357661e.tar.gz grecs-c8865a0d524f3d545836bd4581329089a357661e.tar.bz2 |
Add bind testsuite.
* README.submodule: Update URL.
* src/bind-lex.l (grecs_bind_new_source): Scan include path.
* src/grecs.h (grecs_find_include_file): new proto.
* src/preproc.c (try_file): Rename to grecs_find_include_file. Change
signature and return type. All uses updated.
* tests/Makefile.am (EXTRA_DIST): Add new configs.
(TESTSUITE_AT): Add parser-bind.at.
* tests/gcffmt.c: Add -I (-include) option.
* tests/testsuite.at: Include parser-bind.at.
* tests/bind.conf: New file.
* tests/bind.dlz: New file.
* tests/bind.ext.conf: New file.
* tests/bind.int.conf: New file.
* tests/bind.keys: New file.
* tests/parser-bind.at: New file.
Diffstat (limited to 'src')
-rw-r--r-- | src/bind-lex.l | 17 | ||||
-rw-r--r-- | src/grecs.h | 2 | ||||
-rw-r--r-- | src/preproc.c | 34 |
3 files changed, 34 insertions, 19 deletions
diff --git a/src/bind-lex.l b/src/bind-lex.l index 12dddf7..a5cf644 100644 --- a/src/bind-lex.l +++ b/src/bind-lex.l @@ -194,3 +194,16 @@ grecs_bind_new_source(const char *name) struct stat st; - FILE *fp = fopen(name, "r"); + FILE *fp; + + if (access(name, F_OK)) { + int ec = errno; + char *tmp = grecs_find_include_file(name, 0); + if (!tmp) { + grecs_error(loc, ec, _("cannot open `%s'"), name); + return 1; + } + name = grecs_install_text(tmp); + free(tmp); + } + + fp = fopen(name, "r"); if (!fp) { @@ -198,3 +211,3 @@ grecs_bind_new_source(const char *name) return 1; - } + } if (fstat(fileno(fp), &st)) { diff --git a/src/grecs.h b/src/grecs.h index b839d71..5eef48d 100644 --- a/src/grecs.h +++ b/src/grecs.h @@ -265,2 +265,4 @@ int grecs_preproc_run(const char *config_file, const char *extpp); +char *grecs_find_include_file(const char *name, int allow_cwd); + FILE *grecs_preproc_extrn_start(const char *file, pid_t *ppid); diff --git a/src/preproc.c b/src/preproc.c index 8debdcf..4ab3066 100644 --- a/src/preproc.c +++ b/src/preproc.c @@ -474,4 +474,4 @@ pop_source() -static int -try_file(const char *name, int allow_cwd, int err_not_found, char **newp) +char * +grecs_find_include_file(const char *name, int allow_cwd) { @@ -497,12 +497,6 @@ try_file(const char *name, int allow_cwd, int err_not_found, char **newp) pp_list_find(std_include_path, &fd); - - if (!fd.found && err_not_found) { - grecs_error(&LOCUS, 0, - _("%s: No such file or directory"), name); - *newp = NULL; - } + if (!fd.found) + return NULL; } - if (fd.found) - *newp = fd.buf; - return fd.found; + return fd.buf; } @@ -537,4 +531,9 @@ parse_include(const char *text, int once) - if (p[0] != '/' && try_file(p, allow_cwd, 1, &tmp)) - p = tmp; + if (p[0] != '/') { + p = grecs_find_include_file(p, allow_cwd); + if (!p) + grecs_error(&LOCUS, 0, + _("%s: No such file or directory"), + p); + } } @@ -575,4 +574,5 @@ grecs_preproc_run(const char *config_file, const char *extpp) char *cmd = NULL; - - if (try_file("pp-setup", 1, 0, &setup_file)) { + + setup_file = grecs_find_include_file("pp-setup", 1); + if (setup_file) { size_t size = 0; @@ -583,6 +583,6 @@ grecs_preproc_run(const char *config_file, const char *extpp) } else - cmd = grecs_strdup (extpp); + cmd = grecs_strdup(extpp); /*FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", cmd);*/ outfile = popen(cmd, "w"); - if (!outfile){ + if (!outfile) { grecs_error(NULL, errno, |