diff options
-rw-r--r-- | README.submodule | 2 | ||||
-rw-r--r-- | src/bind-lex.l | 17 | ||||
-rw-r--r-- | src/grecs.h | 2 | ||||
-rw-r--r-- | src/preproc.c | 34 | ||||
-rw-r--r-- | tests/Makefile.am | 15 | ||||
-rw-r--r-- | tests/bind.conf | 126 | ||||
-rw-r--r-- | tests/bind.dlz | 33 | ||||
-rw-r--r-- | tests/bind.ext.conf | 25 | ||||
-rw-r--r-- | tests/bind.int.conf | 17 | ||||
-rw-r--r-- | tests/bind.keys | 11 | ||||
-rw-r--r-- | tests/gcffmt.c | 8 | ||||
-rw-r--r-- | tests/parser-bind.at | 95 | ||||
-rw-r--r-- | tests/testsuite.at | 1 |
13 files changed, 363 insertions, 23 deletions
diff --git a/README.submodule b/README.submodule index 03428d4..3067e92 100644 --- a/README.submodule +++ b/README.submodule | |||
@@ -29,13 +29,13 @@ operations include value lookups by keyword paths, traversing trees | |||
29 | recursively, joining several trees together, reductions, etc. | 29 | recursively, joining several trees together, reductions, etc. |
30 | 30 | ||
31 | * Usage | 31 | * Usage |
32 | 32 | ||
33 | 1. Install grecs as a submodule: | 33 | 1. Install grecs as a submodule: |
34 | 34 | ||
35 | git submodule git.gnu.org.ua/gitroot/grecs.git grecs | 35 | git submodule git://git.gnu.org.ua/grecs.git grecs |
36 | 36 | ||
37 | 2. Add a call to GRECS_SETUP to your configure.ac. It can be as | 37 | 2. Add a call to GRECS_SETUP to your configure.ac. It can be as |
38 | simple as: | 38 | simple as: |
39 | 39 | ||
40 | GRECS_SETUP | 40 | GRECS_SETUP |
41 | 41 | ||
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 | |||
@@ -189,17 +189,30 @@ yywrap() | |||
189 | int | 189 | int |
190 | grecs_bind_new_source(const char *name) | 190 | grecs_bind_new_source(const char *name) |
191 | { | 191 | { |
192 | grecs_locus_t *loc = grecs_current_locus.file ? | 192 | grecs_locus_t *loc = grecs_current_locus.file ? |
193 | &grecs_current_locus : NULL; | 193 | &grecs_current_locus : NULL; |
194 | struct stat st; | 194 | struct stat st; |
195 | FILE *fp = fopen(name, "r"); | 195 | FILE *fp; |
196 | |||
197 | if (access(name, F_OK)) { | ||
198 | int ec = errno; | ||
199 | char *tmp = grecs_find_include_file(name, 0); | ||
200 | if (!tmp) { | ||
201 | grecs_error(loc, ec, _("cannot open `%s'"), name); | ||
202 | return 1; | ||
203 | } | ||
204 | name = grecs_install_text(tmp); | ||
205 | free(tmp); | ||
206 | } | ||
207 | |||
208 | fp = fopen(name, "r"); | ||
196 | if (!fp) { | 209 | if (!fp) { |
197 | grecs_error(loc, errno, _("cannot open `%s'"), name); | 210 | grecs_error(loc, errno, _("cannot open `%s'"), name); |
198 | return 1; | 211 | return 1; |
199 | } | 212 | } |
200 | if (fstat(fileno(fp), &st)) { | 213 | if (fstat(fileno(fp), &st)) { |
201 | grecs_error(loc, errno, _("can't state %s"), name); | 214 | grecs_error(loc, errno, _("can't state %s"), name); |
202 | fclose(fp); | 215 | fclose(fp); |
203 | return 1; | 216 | return 1; |
204 | } | 217 | } |
205 | if (_push_context(name, st.st_ino, st.st_dev)) { | 218 | if (_push_context(name, st.st_ino, st.st_dev)) { |
diff --git a/src/grecs.h b/src/grecs.h index b839d71..5eef48d 100644 --- a/src/grecs.h +++ b/src/grecs.h | |||
@@ -260,12 +260,14 @@ extern void (*grecs_log_setup_hook)(); | |||
260 | size_t grecs_preproc_fill_buffer(char *buf, size_t size); | 260 | size_t grecs_preproc_fill_buffer(char *buf, size_t size); |
261 | void grecs_preproc_add_include_dir(char *dir); | 261 | void grecs_preproc_add_include_dir(char *dir); |
262 | int grecs_preproc_init(const char *name); | 262 | int grecs_preproc_init(const char *name); |
263 | void grecs_preproc_done(void); | 263 | void grecs_preproc_done(void); |
264 | int grecs_preproc_run(const char *config_file, const char *extpp); | 264 | int grecs_preproc_run(const char *config_file, const char *extpp); |
265 | 265 | ||
266 | char *grecs_find_include_file(const char *name, int allow_cwd); | ||
267 | |||
266 | FILE *grecs_preproc_extrn_start(const char *file, pid_t *ppid); | 268 | FILE *grecs_preproc_extrn_start(const char *file, pid_t *ppid); |
267 | void grecs_preproc_extrn_shutdown(pid_t pid); | 269 | void grecs_preproc_extrn_shutdown(pid_t pid); |
268 | 270 | ||
269 | char *grecs_install_text(const char *str); | 271 | char *grecs_install_text(const char *str); |
270 | void grecs_destroy_text(void); | 272 | void grecs_destroy_text(void); |
271 | struct grecs_symtab *grecs_text_table(void); | 273 | struct grecs_symtab *grecs_text_table(void); |
diff --git a/src/preproc.c b/src/preproc.c index 8debdcf..4ab3066 100644 --- a/src/preproc.c +++ b/src/preproc.c | |||
@@ -469,14 +469,14 @@ pop_source() | |||
469 | 469 | ||
470 | pp_line_stmt(); | 470 | pp_line_stmt(); |
471 | 471 | ||
472 | return 0; | 472 | return 0; |
473 | } | 473 | } |
474 | 474 | ||
475 | static int | 475 | char * |
476 | try_file(const char *name, int allow_cwd, int err_not_found, char **newp) | 476 | grecs_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; |
480 | 480 | ||
481 | fd.name = name; | 481 | fd.name = name; |
482 | fd.namelen = strlen(name); | 482 | fd.namelen = strlen(name); |
@@ -492,22 +492,16 @@ try_file(const char *name, int allow_cwd, int err_not_found, char **newp) | |||
492 | grecs_list_remove_tail(include_path); | 492 | grecs_list_remove_tail(include_path); |
493 | } else | 493 | } else |
494 | pp_list_find(include_path, &fd); | 494 | pp_list_find(include_path, &fd); |
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 | ||
510 | static int | 504 | static int |
511 | parse_include(const char *text, int once) | 505 | parse_include(const char *text, int once) |
512 | { | 506 | { |
513 | struct wordsplit ws; | 507 | struct wordsplit ws; |
@@ -532,14 +526,19 @@ parse_include(const char *text, int once) | |||
532 | p[len - 1] = 0; | 526 | p[len - 1] = 0; |
533 | p++; | 527 | p++; |
534 | } | 528 | } |
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) |
543 | rc = push_source(p, once); | 542 | rc = push_source(p, once); |
544 | grecs_free(tmp); | 543 | grecs_free(tmp); |
545 | wordsplit_free(&ws); | 544 | wordsplit_free(&ws); |
@@ -570,24 +569,25 @@ grecs_preproc_run(const char *config_file, const char *extpp) | |||
570 | if (grecs_preproc_init(config_file)) | 569 | if (grecs_preproc_init(config_file)) |
571 | return 1; | 570 | return 1; |
572 | if (extpp) { | 571 | if (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); |
591 | grecs_free(cmd); | 591 | grecs_free(cmd); |
592 | return 1; | 592 | return 1; |
593 | } | 593 | } |
diff --git a/tests/Makefile.am b/tests/Makefile.am index f5d1f6f..1b47712 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am | |||
@@ -11,13 +11,25 @@ | |||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf meta1.conf git.conf | 17 | EXTRA_DIST = \ |
18 | $(TESTSUITE_AT)\ | ||
19 | testsuite\ | ||
20 | package.m4\ | ||
21 | gcf1.conf\ | ||
22 | bind.conf\ | ||
23 | bind.keys\ | ||