Fri, 21 Jul 2000 21:19:31 +0200
trunk: changeset 20
- Added 'bool' config file data type
- Brought tester*.c up-to-date
parser.c | file | annotate | diff | comparison | revisions | |
rules.mk | file | annotate | diff | comparison | revisions | |
tester.c | file | annotate | diff | comparison | revisions | |
tester2.c | file | annotate | diff | comparison | revisions | |
tester3.c | file | annotate | diff | comparison | revisions |
--- a/parser.c Sat Jul 01 14:18:56 2000 +0200 +++ b/parser.c Fri Jul 21 21:19:31 2000 +0200 @@ -446,7 +446,7 @@ static int arg_match(Token *tok, char c) { - static const char chs[]={0, 'l', 'd', 'c', 's', 'i', 0, 0}; + static const char chs[]={0, 'l', 'd', 'c', 's', 'i', 'b', 0, 0}; char c2; if(c=='.' || c=='*') @@ -472,6 +472,23 @@ return 0; } + if(c=='b'){ + if(c2=='l'){ + TOK_SET_BOOL(tok, TOK_LONG_VAL(tok)); + return 0; + }else if(c2=='i'){ + if(strcmp(TOK_IDENT_VAL(tok), "TRUE")==0){ + tok_free(tok); + TOK_SET_BOOL(tok, TRUE); + return 0; + }else if(strcmp(TOK_IDENT_VAL(tok), "FALSE")==0){ + tok_free(tok); + TOK_SET_BOOL(tok, FALSE); + return 0; + } + } + } + return E_TOKZ_INVALID_ARGUMENT; }
--- a/rules.mk Sat Jul 01 14:18:56 2000 +0200 +++ b/rules.mk Fri Jul 21 21:19:31 2000 +0200 @@ -42,10 +42,10 @@ $(CC) $(CFLAGS) -c $< -o $@ _clean: - rm -f core $(OBJS) $(DEPEND_FILE) + rm -f core $(OBJS) $(DEPEND_FILE) $(TO_CLEAN) _realclean: _clean - rm -f $(TARGETS) + rm -f $(TARGETS) $(TO_REALCLEAN) _depend: $(MAKE_DEPEND) *.c
--- a/tester.c Sat Jul 01 14:18:56 2000 +0200 +++ b/tester.c Fri Jul 21 21:19:31 2000 +0200 @@ -18,7 +18,7 @@ libtu_init(argv[0]); - if(!(tokz=tokz_open_file(stdin))) + if(!(tokz=tokz_open_file(stdin, "stdin"))) return EXIT_FAILURE; while(tokz_get_token(tokz, &tok)){
--- a/tester2.c Sat Jul 01 14:18:56 2000 +0200 +++ b/tester2.c Fri Jul 21 21:19:31 2000 +0200 @@ -32,7 +32,7 @@ static bool test2_fn(Tokenizer *tokz, int n, Token *toks) { - printf("test2_fn() %d %ld %f\n", n, TOK_LONG_VAL(toks+1), TOK_DOUBLE_VAL(toks+2)); + printf("test2_fn() %d %s %f\n", n, TOK_BOOL_VAL(toks+1) ? "TRUE" : "FALSE", TOK_DOUBLE_VAL(toks+2)); return TRUE; } @@ -50,7 +50,7 @@ static ConfOpt opts[]={ {"test", NULL, test_fn, NULL}, - {"t2", "ld", test2_fn, NULL}, + {"t2", "bd", test2_fn, NULL}, {"foo", "s?l", test3_fn, NULL}, {"sect", "s", sect_fn, opts}, {NULL, NULL, NULL, NULL} @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) { - libtu_init_argv0(argv[0], NULL); + libtu_init(argv[0]); parse_config_file(stdin, opts, TOKZ_ERROR_TOLERANT); return EXIT_SUCCESS;
--- a/tester3.c Sat Jul 01 14:18:56 2000 +0200 +++ b/tester3.c Fri Jul 21 21:19:31 2000 +0200 @@ -22,12 +22,18 @@ static OptParserOpt opts[]={ {'o', "opt", OPT_ARG, "OPTION", "foo bar baz quk asdf jklö äölk dfgh quik aaaa bbbb cccc dddd eeee ffff"}, {'f', "file", OPT_ARG, "FILE", "asdfsadlfölökjasdflökjasdflkjöasdflkjöas dlöfjkasdfölkjasdfölkjasdfasdflöjasdfkasödjlfkasdlföjasdölfjkölkasjdfasdfölkjasd asdöljfasöldf asdölfköasdlf asfdlök asdföljkadsfölasdfölasdölkfjasdölfasödlflöskflasdföaölsdf"}, - {'v', "view", 0, NULL, NULL}, - {'z', "zip", 0, NULL, NULL}, - {'x', "extract", 0, NULL, NULL}, + {'v', "view", 0, NULL, "asfasdf"}, + {'z', "zip", 0, NULL, "asdfasdf"}, + {'x', "extract", 0, NULL, "asdfasdf"}, {0, NULL, 0, NULL, NULL} }; +static OptParserCommonInfo tester3_cinfo={ + NULL, + usage, + NULL +}; + int main(int argc, char *argv[]) { @@ -35,7 +41,7 @@ libtu_init(argv[0]); - optparser_init(argc, argv, OPTP_NO_DASH, opts, NULL); + optparser_init(argc, argv, OPTP_NO_DASH, opts, &tester3_cinfo); while((opt=optparser_get_opt())){ switch(opt){