aboutsummaryrefslogtreecommitdiff
path: root/src/preproc.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-16 19:31:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-16 19:31:53 +0300
commitc8865a0d524f3d545836bd4581329089a357661e (patch)
tree4fc437a07086c4304e7ec2446be2a504a3dbd507 /src/preproc.c
parent50e703a9a92e755f928699b705612cd4153ffb9f (diff)
downloadgrecs-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/preproc.c')
-rw-r--r--src/preproc.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/preproc.c b/src/preproc.c
index 8debdcf..4ab3066 100644
--- a/src/preproc.c
+++ b/src/preproc.c
@@ -472,8 +472,8 @@ pop_source()
472 return 0; 472 return 0;
473} 473}
474 474
475static int 475char *
476try_file(const char *name, int allow_cwd, int err_not_found, char **newp) 476grecs_find_include_file(const char *name, int allow_cwd)
477{ 477{
478 static char *cwd = "."; 478 static char *cwd = ".";
479 struct file_data fd; 479 struct file_data fd;
@@ -495,16 +495,10 @@ try_file(const char *name, int allow_cwd, int err_not_found, char **newp)
495 495
496 if (!fd.found) { 496 if (!fd.found) {
497 pp_list_find(std_include_path, &fd); 497 pp_list_find(std_include_path, &fd);
498 498 if (!fd.found)
499 if (!fd.found && err_not_found) { 499 return NULL;
500 grecs_error(&LOCUS, 0,
501 _("%s: No such file or directory"), name);
502 *newp = NULL;
503 }
504 } 500 }
505 if (fd.found) 501 return fd.buf;
506 *newp = fd.buf;
507 return fd.found;
508} 502}
509 503
510static int 504static int
@@ -535,8 +529,13 @@ parse_include(const char *text, int once)
535 else 529 else
536 allow_cwd = 1; 530 allow_cwd = 1;
537 531
538 if (p[0] != '/' && try_file(p, allow_cwd, 1, &tmp)) 532 if (p[0] != '/') {
539 p = tmp; 533 p = grecs_find_include_file(p, allow_cwd);
534 if (!p)
535 grecs_error(&LOCUS, 0,
536 _("%s: No such file or directory"),
537 p);
538 }
540 } 539 }
541 540
542 if (p) 541 if (p)
@@ -573,18 +572,19 @@ grecs_preproc_run(const char *config_file, const char *extpp)
573 FILE *outfile; 572 FILE *outfile;
574 char *setup_file; 573 char *setup_file;
575 char *cmd = NULL; 574 char *cmd = NULL;
576 575
577 if (try_file("pp-setup", 1, 0, &setup_file)) { 576 setup_file = grecs_find_include_file("pp-setup", 1);
577 if (setup_file) {
578 size_t size = 0; 578 size_t size = 0;
579 if (grecs_asprintf(&cmd, &size, 579 if (grecs_asprintf(&cmd, &size,
580 "%s %s -", extpp, setup_file)) 580 "%s %s -", extpp, setup_file))
581 grecs_alloc_die(); 581 grecs_alloc_die();
582 grecs_free(setup_file); 582 grecs_free(setup_file);
583 } else 583 } else
584 cmd = grecs_strdup (extpp); 584 cmd = grecs_strdup(extpp);
585 /*FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", cmd);*/ 585 /*FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", cmd);*/
586 outfile = popen(cmd, "w"); 586 outfile = popen(cmd, "w");
587 if (!outfile){ 587 if (!outfile) {
588 grecs_error(NULL, errno, 588 grecs_error(NULL, errno,
589 _("Unable to start external preprocessor `%s'"), 589 _("Unable to start external preprocessor `%s'"),
590 cmd); 590 cmd);

Return to:

Send suggestions and report system problems to the System administrator.