# HG changeset patch # User tuomov # Date 1022452050 -7200 # Node ID 0a050a9536a17afce0cf086aae5e87e504b48113 # Parent ebea551c80dcfc39fc51dc1342fe0fe7c41a1a62 trunk: changeset 43 Added check_args_loose diff -r ebea551c80dc -r 0a050a9536a1 include/libtu/parser.h --- a/include/libtu/parser.h Tue Jan 22 01:24:03 2002 +0100 +++ b/include/libtu/parser.h Mon May 27 00:27:30 2002 +0200 @@ -43,5 +43,7 @@ extern bool parse_config_file(FILE *file, const ConfOpt *options, int flags); extern bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, const char *fmt); +extern bool check_args_loose(const Tokenizer *tokz, Token *tokens, int ntokens, + const char *fmt); #endif /* LIBTU_PARSER_H */ diff -r ebea551c80dc -r 0a050a9536a1 parser.c --- a/parser.c Tue Jan 22 01:24:03 2002 +0100 +++ b/parser.c Mon May 27 00:27:30 2002 +0200 @@ -444,7 +444,7 @@ */ -static int arg_match(Token *tok, char c) +static int arg_match(Token *tok, char c, bool si) { char c2=tok->type; @@ -454,6 +454,18 @@ if(c2==c) return 0; + if(si){ + if(c2=='i' && c=='s'){ + TOK_SET_IDENT(tok, TOK_STRING_VAL(tok)); + return 0; + } + + if(c2=='s' && c=='i'){ + TOK_SET_STRING(tok, TOK_IDENT_VAL(tok)); + return 0; + } + } + if(c2=='c' && c=='l'){ TOK_SET_LONG(tok, TOK_CHAR_VAL(tok)); return 0; @@ -490,7 +502,8 @@ } -static int check_argument(const char **pret, Token *tok, const char *p) +static int check_argument(const char **pret, Token *tok, const char *p, + bool si) { int mode; int e=E_TOKZ_TOO_MANY_ARGS; @@ -509,11 +522,11 @@ p++; }else if(*p=='+'){ *pret=p; - return arg_match(tok, *(p-1)); + return arg_match(tok, *(p-1), si); } while(*p!='\0'){ - e=arg_match(tok, *p); + e=arg_match(tok, *p, si); if(e==0){ p++; while(mode==2 && *p==':'){ @@ -564,8 +577,8 @@ } -bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, - const char *fmt) +bool do_check_args(const Tokenizer *tokz, Token *tokens, int ntokens, + const char *fmt, bool si) { int i; int e; @@ -577,7 +590,7 @@ } for(i=1; i