Sat, 05 Apr 2003 22:24:03 +0200
trunk: changeset 54
Makefile refixed
0 | 1 | /* |
2 | * libtu/parser.c | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
0 | 5 | * See the included file LICENSE for details. |
6 | */ | |
7 | ||
8 | #include <string.h> | |
14 | 9 | #include <errno.h> |
0 | 10 | |
5 | 11 | #include <libtu/parser.h> |
12 | #include <libtu/misc.h> | |
13 | #include <libtu/output.h> | |
0 | 14 | |
13 | 15 | #define MAX_TOKENS 256 |
16 | #define MAX_NEST 256 | |
0 | 17 | |
18 | ||
19 | enum{ | |
2 | 20 | P_NONE=1, |
0 | 21 | P_EOF, |
2 | 22 | P_STMT, |
23 | P_STMT_NS, | |
24 | P_STMT_SECT, | |
0 | 25 | P_BEG_SECT, |
26 | P_END_SECT | |
27 | }; | |
28 | ||
29 | ||
20 | 30 | /* */ |
0 | 31 | |
32 | ||
1 | 33 | static bool opt_include(Tokenizer *tokz, int n, Token *toks); |
34 | ||
35 | ||
36 | static ConfOpt common_opts[]={ | |
37 | {"include", "s", opt_include, NULL}, | |
38 | {NULL, NULL, NULL, NULL} | |
39 | }; | |
40 | ||
41 | ||
42 | /* */ | |
43 | ||
0 | 44 | |
2 | 45 | static int read_statement(Tokenizer *tokz, Token *tokens, int *ntok_ret) |
0 | 46 | { |
47 | int ntokens=0; | |
48 | Token *tok=NULL; | |
2 | 49 | int had_comma=0; /* 0 - no, 1 - yes, 2 - not had, not expected */ |
50 | int retval=0; | |
0 | 51 | int e=0; |
52 | ||
53 | while(1){ | |
2 | 54 | tok=&tokens[ntokens]; |
55 | ||
56 | if(!tokz_get_token(tokz, tok)){ | |
57 | e=1; | |
58 | continue; | |
59 | } | |
60 | ||
0 | 61 | if(ntokens==MAX_TOKENS-1){ |
62 | e=E_TOKZ_TOKEN_LIMIT; | |
2 | 63 | tokz_warn_error(tokz, tok->line, e); |
64 | if(!(tokz->flags&TOKZ_ERROR_TOLERANT)) | |
65 | break; | |
66 | }else{ | |
67 | ntokens++; | |
0 | 68 | } |
69 | ||
70 | if(!TOK_IS_OP(tok)){ | |
71 | if(ntokens==1 && !had_comma){ | |
22 | 72 | /* first token */ |
0 | 73 | had_comma=2; |
74 | }else{ | |
2 | 75 | if(had_comma==0) |
76 | goto syntax; | |
0 | 77 | |
78 | had_comma=0; | |
79 | } | |
80 | continue; | |
81 | } | |
82 | ||
83 | /* It is an operator */ | |
2 | 84 | ntokens--; |
0 | 85 | |
86 | switch(TOK_OP_VAL(tok)){ | |
87 | case OP_SCOLON: | |
2 | 88 | retval=(ntokens==0 ? P_NONE : P_STMT_NS); |
0 | 89 | break; |
90 | ||
91 | case OP_NEXTLINE: | |
2 | 92 | retval=(ntokens==0 ? P_NONE : P_STMT); |
93 | break; | |
0 | 94 | |
2 | 95 | case OP_L_BRC: |
96 | retval=(ntokens==0 ? P_BEG_SECT : P_STMT_SECT); | |
0 | 97 | break; |
98 | ||
2 | 99 | case OP_R_BRC: |
100 | if(ntokens==0){ | |
101 | retval=P_END_SECT; | |
102 | }else{ | |
103 | tokz_unget_token(tokz, tok); | |
104 | retval=P_STMT_NS; | |
105 | } | |
106 | break; | |
107 | ||
0 | 108 | case OP_EOF: |
2 | 109 | retval=(ntokens==0 ? P_EOF : P_STMT_NS); |
110 | ||
0 | 111 | if(had_comma==1){ |
112 | e=E_TOKZ_UNEXPECTED_EOF; | |
2 | 113 | goto handle_error; |
0 | 114 | } |
115 | ||
2 | 116 | goto end; |
0 | 117 | |
118 | case OP_COMMA: | |
2 | 119 | if(had_comma!=0) |
120 | goto syntax; | |
121 | ||
0 | 122 | had_comma=1; |
2 | 123 | continue; |
0 | 124 | |
125 | default: | |
2 | 126 | goto syntax; |
0 | 127 | } |
128 | ||
2 | 129 | if(had_comma!=1) |
130 | break; | |
131 | ||
132 | syntax: | |
133 | e=E_TOKZ_SYNTAX; | |
134 | handle_error: | |
135 | tokz_warn_error(tokz, tok->line, e); | |
136 | ||
137 | if(!(tokz->flags&TOKZ_ERROR_TOLERANT) || retval!=0) | |
138 | break; | |
0 | 139 | } |
140 | ||
2 | 141 | end: |
142 | if(e!=0) | |
143 | retval=-retval; | |
144 | ||
0 | 145 | *ntok_ret=ntokens; |
146 | ||
147 | return retval; | |
148 | } | |
149 | ||
150 | ||
2 | 151 | static bool find_beg_sect(Tokenizer *tokz) |
152 | { | |
24 | 153 | Token tok=TOK_INIT; |
2 | 154 | |
155 | while(tokz_get_token(tokz, &tok)){ | |
156 | if(TOK_IS_OP(&tok)){ | |
157 | if(TOK_OP_VAL(&tok)==OP_NEXTLINE) | |
158 | continue; | |
159 | ||
160 | if(TOK_OP_VAL(&tok)==OP_SCOLON) | |
161 | return FALSE; | |
162 | ||
163 | if(TOK_OP_VAL(&tok)==OP_L_BRC) | |
164 | return TRUE; | |
165 | } | |
166 | ||
167 | tokz_unget_token(tokz, &tok); | |
168 | break; | |
169 | } | |
170 | return FALSE; | |
171 | } | |
172 | ||
173 | ||
0 | 174 | /* */ |
175 | ||
176 | ||
2 | 177 | static const ConfOpt* lookup_option(const ConfOpt *opts, const char *name) |
178 | { | |
179 | while(opts->optname!=NULL){ | |
180 | if(strcmp(opts->optname, name)==0) | |
181 | return opts; | |
182 | opts++; | |
183 | } | |
184 | return NULL; | |
185 | } | |
186 | ||
0 | 187 | |
2 | 188 | static bool call_end_sect(Tokenizer *tokz, const ConfOpt *opts) |
189 | { | |
190 | opts=lookup_option(opts, "#end"); | |
191 | if(opts!=NULL) | |
192 | return opts->fn(tokz, 0, NULL); | |
0 | 193 | |
2 | 194 | return TRUE; |
0 | 195 | } |
196 | ||
197 | ||
2 | 198 | static bool call_cancel_sect(Tokenizer *tokz, const ConfOpt *opts) |
199 | { | |
200 | opts=lookup_option(opts, "#cancel"); | |
201 | if(opts!=NULL) | |
202 | return opts->fn(tokz, 0, NULL); | |
203 | ||
204 | return TRUE; | |
0 | 205 | } |
206 | ||
207 | ||
208 | /* */ | |
209 | ||
210 | ||
211 | bool parse_config_tokz(Tokenizer *tokz, const ConfOpt *options) | |
212 | { | |
213 | Token tokens[MAX_TOKENS]; | |
214 | bool alloced_optstack=FALSE; | |
2 | 215 | int i, t, ntokens=0; |
0 | 216 | int init_nest_lvl; |
2 | 217 | bool had_error; |
218 | int errornest=0; | |
35 | 219 | bool is_default=FALSE; |
0 | 220 | |
221 | /* Allocate tokz->optstack if it does not yet exist (if it does, | |
222 | * we have been called from an option handler) | |
223 | */ | |
224 | if(!tokz->optstack){ | |
225 | tokz->optstack=ALLOC_N(const ConfOpt*, MAX_NEST); | |
226 | if(!tokz->optstack){ | |
227 | warn_err(); | |
228 | return FALSE; | |
229 | } | |
230 | ||
231 | memset(tokz->optstack, 0, sizeof(ConfOpt*)*MAX_NEST); | |
232 | init_nest_lvl=tokz->nest_lvl=0; | |
233 | alloced_optstack=TRUE; | |
234 | }else{ | |
235 | init_nest_lvl=tokz->nest_lvl; | |
236 | } | |
237 | ||
238 | tokz->optstack[init_nest_lvl]=options; | |
239 | ||
2 | 240 | for(i=0; i<MAX_TOKENS; i++) |
0 | 241 | tok_init(&tokens[i]); |
242 | ||
243 | ||
244 | while(1){ | |
2 | 245 | had_error=FALSE; |
0 | 246 | |
247 | /* free the tokens */ | |
248 | while(ntokens--) | |
249 | tok_free(&tokens[ntokens]); | |
250 | ||
2 | 251 | /* read the tokens */ |
252 | t=read_statement(tokz, tokens, &ntokens); | |
253 | ||
254 | if((had_error=t<0)) | |
255 | t=-t; | |
256 | ||
257 | switch(t){ | |
258 | case P_STMT: | |
259 | case P_STMT_NS: | |
260 | case P_STMT_SECT: | |
261 | ||
262 | if(errornest) | |
263 | had_error=TRUE; | |
264 | else if(tokz->flags&TOKZ_PARSER_INDENT_MODE) | |
265 | verbose_indent(tokz->nest_lvl); | |
266 | ||
267 | if(!TOK_IS_IDENT(tokens+0)){ | |
268 | had_error=TRUE; | |
269 | tokz_warn_error(tokz, tokens->line, | |
270 | E_TOKZ_IDENTIFIER_EXPECTED); | |
271 | } | |
272 | ||
273 | if(t==P_STMT){ | |
274 | if(find_beg_sect(tokz)) | |
275 | t=P_STMT_SECT; | |
276 | } | |
277 | ||
22 | 278 | if(had_error) |
279 | break; | |
280 | ||
281 | /* Got the statement and its type */ | |
282 | ||
2 | 283 | options=lookup_option(tokz->optstack[tokz->nest_lvl], |
284 | TOK_IDENT_VAL(tokens+0)); | |
285 | if(options==NULL) | |
286 | options=lookup_option(common_opts, TOK_IDENT_VAL(tokens+0)); | |
35 | 287 | if(options==NULL && (tokz->flags&TOKZ_DEFAULT_OPTION)){ |
288 | options=lookup_option(tokz->optstack[tokz->nest_lvl], "#default"); | |
289 | is_default=(options!=NULL); | |
290 | } | |
2 | 291 | |
292 | if(options==NULL){ | |
293 | had_error=TRUE; | |
294 | tokz_warn_error(tokz, tokens->line, E_TOKZ_UNKNOWN_OPTION); | |
35 | 295 | }else if(!is_default) { |
2 | 296 | had_error=!check_args(tokz, tokens, ntokens, options->argfmt); |
297 | } | |
298 | ||
299 | if(had_error) | |
300 | break; | |
301 | ||
22 | 302 | /* Found the option and arguments are ok */ |
303 | ||
2 | 304 | if(options->opts!=NULL){ |
305 | if(t!=P_STMT_SECT){ | |
306 | had_error=TRUE; | |
307 | tokz_warn_error(tokz, tokz->line, E_TOKZ_LBRACE_EXPECTED); | |
308 | }else if(tokz->nest_lvl==MAX_NEST-1){ | |
309 | tokz_warn_error(tokz, tokz->line, E_TOKZ_MAX_NEST); | |
310 | had_error=TRUE; | |
311 | }else{ | |
22 | 312 | tokz->nest_lvl++; |
313 | tokz->optstack[tokz->nest_lvl]=options->opts; | |
2 | 314 | } |
315 | }else if(t==P_STMT_SECT){ | |
316 | had_error=TRUE; | |
317 | tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX); | |
318 | } | |
319 | ||
320 | if(!had_error && options->fn!=NULL){ | |
321 | had_error=!options->fn(tokz, ntokens, tokens); | |
322 | if(t==P_STMT_SECT && had_error) | |
323 | tokz->nest_lvl--; | |
324 | } | |
0 | 325 | break; |
2 | 326 | |
0 | 327 | case P_EOF: |
1 | 328 | if(tokz_popf(tokz)){ |
2 | 329 | break; |
330 | }else if(tokz->nest_lvl>0 || errornest>0){ | |
0 | 331 | tokz_warn_error(tokz, 0, E_TOKZ_UNEXPECTED_EOF); |
332 | had_error=TRUE; | |
333 | } | |
2 | 334 | goto eof; |
335 | ||
336 | case P_BEG_SECT: | |
337 | had_error=TRUE; | |
338 | errornest++; | |
339 | tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX); | |
0 | 340 | break; |
2 | 341 | |
0 | 342 | case P_END_SECT: |
22 | 343 | if(tokz->nest_lvl+errornest==0){ |
0 | 344 | tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX); |
345 | had_error=TRUE; | |
22 | 346 | } |
347 | ||
348 | if(had_error) | |
0 | 349 | break; |
350 | ||
20 | 351 | if(errornest!=0){ |
352 | errornest--; | |
353 | }else{ | |
22 | 354 | had_error=!call_end_sect(tokz, tokz->optstack[tokz->nest_lvl]); |
20 | 355 | tokz->nest_lvl--; |
356 | } | |
0 | 357 | |
358 | if(tokz->nest_lvl<init_nest_lvl) | |
2 | 359 | goto eof; |
360 | } | |
361 | ||
362 | if(!had_error) | |
363 | continue; | |
364 | ||
22 | 365 | if(t==P_STMT_SECT) |
2 | 366 | errornest++; |
367 | ||
368 | if(!(tokz->flags&TOKZ_ERROR_TOLERANT)) | |
369 | break; | |
370 | } | |
0 | 371 | |
2 | 372 | eof: |
373 | /* free the tokens */ | |
374 | while(ntokens--) | |
375 | tok_free(&tokens[ntokens]); | |
376 | ||
377 | while(tokz->nest_lvl>=init_nest_lvl){ | |
378 | if(tokz->flags&TOKZ_ERROR_TOLERANT || !had_error) | |
379 | call_end_sect(tokz, tokz->optstack[tokz->nest_lvl]); | |
380 | else | |
381 | call_cancel_sect(tokz, tokz->optstack[tokz->nest_lvl]); | |
0 | 382 | tokz->nest_lvl--; |
383 | } | |
384 | ||
385 | /* Free optstack if it was alloced by this call */ | |
386 | if(alloced_optstack){ | |
387 | free(tokz->optstack); | |
388 | tokz->optstack=NULL; | |
389 | tokz->nest_lvl=0; | |
390 | } | |
391 | ||
392 | if(tokz->flags&TOKZ_PARSER_INDENT_MODE) | |
393 | verbose_indent(init_nest_lvl); | |
394 | ||
395 | return !had_error; | |
396 | } | |
397 | ||
398 | ||
399 | /* */ | |
400 | ||
401 | ||
2 | 402 | bool parse_config(const char *fname, const ConfOpt *options, int flags) |
0 | 403 | { |
404 | Tokenizer *tokz; | |
405 | bool ret; | |
406 | ||
407 | tokz=tokz_open(fname); | |
408 | ||
409 | if(tokz==NULL) | |
410 | return FALSE; | |
2 | 411 | |
412 | tokz->flags|=flags&~TOKZ_READ_COMMENTS; | |
0 | 413 | |
414 | ret=parse_config_tokz(tokz, options); | |
415 | ||
416 | tokz_close(tokz); | |
417 | ||
418 | return ret; | |
419 | } | |
420 | ||
421 | ||
2 | 422 | bool parse_config_file(FILE *file, const ConfOpt *options, int flags) |
0 | 423 | { |
424 | Tokenizer *tokz; | |
425 | bool ret; | |
426 | ||
14 | 427 | tokz=tokz_open_file(file, NULL); |
0 | 428 | |
429 | if(tokz==NULL) | |
430 | return FALSE; | |
431 | ||
2 | 432 | tokz->flags|=flags&~TOKZ_READ_COMMENTS; |
433 | ||
0 | 434 | ret=parse_config_tokz(tokz, options); |
435 | ||
436 | tokz_close(tokz); | |
437 | ||
438 | return ret; | |
439 | } | |
440 | ||
441 | ||
442 | /* | |
443 | * Argument validity checking stuff | |
444 | */ | |
445 | ||
446 | ||
40 | 447 | static int arg_match(Token *tok, char c, bool si) |
0 | 448 | { |
20 | 449 | char c2=tok->type; |
0 | 450 | |
451 | if(c=='.' || c=='*') | |
2 | 452 | return 0; |
0 | 453 | |
454 | if(c2==c) | |
2 | 455 | return 0; |
0 | 456 | |
40 | 457 | if(si){ |
458 | if(c2=='i' && c=='s'){ | |
459 | TOK_SET_IDENT(tok, TOK_STRING_VAL(tok)); | |
460 | return 0; | |
461 | } | |
462 | ||
463 | if(c2=='s' && c=='i'){ | |
464 | TOK_SET_STRING(tok, TOK_IDENT_VAL(tok)); | |
465 | return 0; | |
466 | } | |
467 | } | |
468 | ||
0 | 469 | if(c2=='c' && c=='l'){ |
470 | TOK_SET_LONG(tok, TOK_CHAR_VAL(tok)); | |
2 | 471 | return 0; |
0 | 472 | } |
473 | ||
474 | if(c2=='l' && c=='c'){ | |
475 | TOK_SET_CHAR(tok, TOK_LONG_VAL(tok)); | |
2 | 476 | return 0; |
0 | 477 | } |
478 | ||
479 | if(c2=='l' && c=='d'){ | |
480 | TOK_SET_DOUBLE(tok, TOK_LONG_VAL(tok)); | |
2 | 481 | return 0; |
0 | 482 | } |
483 | ||
17 | 484 | if(c=='b'){ |
485 | if(c2=='l'){ | |
486 | TOK_SET_BOOL(tok, TOK_LONG_VAL(tok)); | |
487 | return 0; | |
488 | }else if(c2=='i'){ | |
489 | if(strcmp(TOK_IDENT_VAL(tok), "TRUE")==0){ | |
490 | tok_free(tok); | |
491 | TOK_SET_BOOL(tok, TRUE); | |
492 | return 0; | |
493 | }else if(strcmp(TOK_IDENT_VAL(tok), "FALSE")==0){ | |
494 | tok_free(tok); | |
495 | TOK_SET_BOOL(tok, FALSE); | |
496 | return 0; | |
497 | } | |
498 | } | |
499 | } | |
500 | ||
2 | 501 | return E_TOKZ_INVALID_ARGUMENT; |
0 | 502 | } |
503 | ||
504 | ||
40 | 505 | static int check_argument(const char **pret, Token *tok, const char *p, |
506 | bool si) | |
0 | 507 | { |
2 | 508 | int mode; |
509 | int e=E_TOKZ_TOO_MANY_ARGS; | |
0 | 510 | |
2 | 511 | again: |
512 | mode=0; | |
513 | ||
0 | 514 | if(*p=='*'){ |
515 | *pret=p; | |
2 | 516 | return 0; |
0 | 517 | }else if(*p=='?'){ |
518 | mode=1; | |
519 | p++; | |
520 | }else if(*p==':'){ | |
521 | mode=2; | |
522 | p++; | |
523 | }else if(*p=='+'){ | |
524 | *pret=p; | |
40 | 525 | return arg_match(tok, *(p-1), si); |
0 | 526 | } |
527 | ||
528 | while(*p!='\0'){ | |
40 | 529 | e=arg_match(tok, *p, si); |
2 | 530 | if(e==0){ |
0 | 531 | p++; |
532 | while(mode==2 && *p==':'){ | |
533 | if(*++p=='\0') | |
2 | 534 | break; /* Invalid argument format string, though... */ |
0 | 535 | p++; |
536 | } | |
537 | *pret=p; | |
2 | 538 | return 0; |
0 | 539 | } |
540 | ||
541 | if(mode==0) | |
542 | break; | |
543 | ||
544 | p++; | |
545 | ||
2 | 546 | if(mode==1) |
547 | goto again; | |
548 | ||
549 | /* mode==2 */ | |
0 | 550 | |
551 | if(*p!=':') | |
552 | break; | |
553 | p++; | |
2 | 554 | e=E_TOKZ_TOO_MANY_ARGS; |
0 | 555 | } |
556 | ||
557 | *pret=p; | |
2 | 558 | return e; |
0 | 559 | } |
560 | ||
561 | ||
562 | static bool args_at_end(const char *p) | |
563 | { | |
564 | if(p==NULL) | |
565 | return TRUE; | |
566 | ||
567 | while(*p!='\0'){ | |
568 | if(*p=='*' || *p=='+') | |
569 | p++; | |
570 | else if(*p=='?') | |
571 | p+=2; | |
572 | else | |
573 | return FALSE; | |
574 | } | |
575 | ||
576 | return TRUE; | |
577 | } | |
578 | ||
579 | ||
40 | 580 | bool do_check_args(const Tokenizer *tokz, Token *tokens, int ntokens, |
581 | const char *fmt, bool si) | |
0 | 582 | { |
583 | int i; | |
2 | 584 | int e; |
585 | ||
586 | if(fmt==NULL){ | |
587 | if(ntokens!=1) | |
588 | tokz_warn_error(tokz, tokens[0].line, E_TOKZ_TOO_MANY_ARGS); | |
589 | return ntokens==1; | |
590 | } | |
0 | 591 | |
2 | 592 | for(i=1; i<ntokens; i++){ |
40 | 593 | e=check_argument(&fmt, &tokens[i], fmt, si); |
2 | 594 | if(e!=0){ |
595 | tokz_warn_error(tokz, tokens[i].line, e); | |
0 | 596 | return FALSE; |
597 | } | |
598 | } | |
599 | ||
600 | if(!args_at_end(fmt)){ | |
601 | tokz_warn_error(tokz, tokens[i].line, E_TOKZ_TOO_FEW_ARGS); | |
602 | return FALSE; | |
603 | } | |
604 | ||
605 | return TRUE; | |
606 | } | |
607 | ||
1 | 608 | |
40 | 609 | bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, |
610 | const char *fmt) | |
611 | { | |
612 | return do_check_args(tokz, tokens, ntokens, fmt, FALSE); | |
613 | } | |
614 | ||
615 | ||
616 | bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens, | |
617 | const char *fmt) | |
618 | { | |
619 | return do_check_args(tokz, tokens, ntokens, fmt, TRUE); | |
620 | } | |
621 | ||
622 | ||
1 | 623 | /* */ |
624 | ||
625 | ||
14 | 626 | static bool try_include(Tokenizer *tokz, const char *fname) |
1 | 627 | { |
14 | 628 | FILE *f; |
629 | ||
630 | f=fopen(fname, "r"); | |
631 | ||
632 | if(f==NULL) | |
633 | return FALSE; | |
634 | ||
635 | if(!tokz_pushf_file(tokz, f, fname)){ | |
636 | fclose(f); | |
637 | return FALSE; | |
638 | } | |
639 | ||
640 | return TRUE; | |
641 | } | |
642 | ||
643 | ||
644 | static bool try_include_dir(Tokenizer *tokz, const char *dir, int dlen, | |
645 | const char *file) | |
646 | { | |
1 | 647 | char *tmpname; |
648 | bool retval; | |
649 | ||
14 | 650 | tmpname=scatn(dir, dlen, file, -1); |
1 | 651 | |
652 | if(tmpname==NULL){ | |
653 | warn_err(); | |
654 | return FALSE; | |
655 | } | |
656 | ||
14 | 657 | retval=try_include(tokz, tmpname); |
658 | ||
1 | 659 | free(tmpname); |
14 | 660 | |
1 | 661 | return retval; |
662 | } | |
663 | ||
14 | 664 | |
665 | static bool opt_include(Tokenizer *tokz, int n, Token *toks) | |
666 | { | |
667 | const char *fname=TOK_STRING_VAL(toks+1); | |
668 | const char *lastndx=NULL; | |
669 | bool retval, e; | |
670 | int i=0; | |
671 | ||
672 | if(fname[0]!='/' && tokz->name!=NULL) | |
673 | lastndx=strrchr(tokz->name, '/'); | |
674 | ||
675 | if(lastndx==NULL) | |
676 | retval=try_include(tokz, fname); | |
677 | else | |
678 | retval=try_include_dir(tokz, tokz->name, lastndx-tokz->name+1, fname); | |
679 | ||
680 | if(retval==TRUE) | |
681 | return TRUE; | |
682 | ||
683 | e=errno; | |
684 | ||
685 | if(tokz->includepaths!=NULL){ | |
686 | while(tokz->includepaths[i]!=NULL){ | |
687 | if(try_include_dir(tokz, tokz->includepaths[i], -1, fname)) | |
688 | return TRUE; | |
689 | i++; | |
690 | } | |
691 | } | |
692 | ||
693 | warn_obj(fname, "%s", strerror(e)); | |
694 | ||
695 | return FALSE; | |
696 | } | |
697 | ||
698 | ||
699 | extern void tokz_set_includepaths(Tokenizer *tokz, char **paths) | |
700 | { | |
701 | tokz->includepaths=paths; | |
702 | } | |
703 | ||
46 | 704 | |
705 | ||
706 | ConfOpt libtu_dummy_confopts[]={ | |
707 | END_CONFOPTS | |
708 | }; | |
709 | ||
710 | ||
711 | ||
712 | bool parse_config_tokz_skip_section(Tokenizer *tokz) | |
713 | { | |
714 | return parse_config_tokz(tokz, libtu_dummy_confopts); | |
715 | } |