]> mj.ucw.cz Git - libucw.git/commitdiff
bin/config: String type has no prefix again.
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Wed, 17 May 2006 12:49:52 +0000 (14:49 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Wed, 17 May 2006 12:49:52 +0000 (14:49 +0200)
lib/shell/config.c
lib/shell/config.t

index 4a0910d1e725c9d4a95db55ba3ea66fdd80a701e..a4ac005a40300cbe54a627eb5da1ae808ee41590 100644 (file)
@@ -47,7 +47,7 @@ Usage: config [-C<configfile>] [-S<section>.<option>=<value>] <sections>\n\
 <value>\t\t[a-zA-Z0-9.-/]* | 'string without single quotes'<value> | \"c-like string\"<value>\n\
 \n\
 Types:\n\
-:\t\tString\n\
+<empty>\t\tString\n\
 #\t\t32-bit integer\n\
 ##\t\t64-bit integer\n\
 $\t\tFloating point number\n\
@@ -158,10 +158,10 @@ parse_section(struct section *section)
            }
          item->cf.cls = CC_STATIC;
          item->cf.number = 1;
-         switch (*pos++)
+         switch (*pos)
            {
              case '#':
-               if (*pos == '#')
+               if (*++pos == '#')
                  {
                    pos++;
                    item->cf.type = CT_U64;
@@ -170,13 +170,14 @@ parse_section(struct section *section)
                  item->cf.type = CT_INT;
                break;
              case '$':
+               pos++;
                item->cf.type = CT_DOUBLE;
                break;
-             case ':':
+             default:
+               if (!Cword(*pos))
+                 die("Invalid type syntax");
                item->cf.type = CT_STRING;
                break;
-             default:
-               die("Invalid type syntax");
            }
          parse_white();
          item->cf.name = parse_name();
index a6206971701c6fd25e6c1ee18c44339e3da94c1e..97fad73d8a6749e8322a241b3b8fc6a82371251c 100644 (file)
@@ -1,6 +1,6 @@
 # Tests for configuration parser
 
-Run:   obj/lib/shell/config -C/dev/null -S 'sec1{int1=23; long1=1234567812345678; long2=4321; str1="s1"; str2="s2"}' 'sec1 {#int1; ##long1; -:str1; :str2; #int2=123; ##long2=1234; #int3=0x10; #int4; $dbl1=001.100; $dbl2}; sec2{:str3}'
+Run:   obj/lib/shell/config -C/dev/null -S 'sec1{int1=23; long1=1234567812345678; long2=4321; str1="s1"; str2="s2"}' 'sec1 {#int1; ##long1; -str1; str2; #int2=123; ##long2=1234; #int3=0x10; #int4; $dbl1=001.100; $dbl2}; sec2{str3}'
 Out:   CF_sec1_int1='23'
        CF_sec1_long1='1234567812345678'
        CF_sec1_str2='s2'
@@ -12,13 +12,13 @@ Out:        CF_sec1_int1='23'
        CF_sec1_dbl2='0'
        CF_sec2_str3=''
 
-Run:   obj/lib/shell/config -C/dev/null -S 'sec1{list1 1 a1 b1; list1:clear; list1 2 a2 b2 3 a3 b3}' 'sec1 {@list1 {#int1; :str1; -:str2}}'
+Run:   obj/lib/shell/config -C/dev/null -S 'sec1{list1 1 a1 b1; list1:clear; list1 2 a2 b2 3 a3 b3}' 'sec1 {@list1 {#int1; str1; -str2}}'
 Out:   CF_sec1_list1_int1[1]='2'
        CF_sec1_list1_str1[1]='a2'
        CF_sec1_list1_int1[2]='3'
        CF_sec1_list1_str1[2]='a3'
 
-Run:   obj/lib/shell/config -C/dev/null -S 'sec1{ar1 a b c d; ar1 a b c; ar2 1 2; ar3 1.1}' 'sec1 {:ar1[]; #ar2[2]; $ar3[-2]}'
+Run:   obj/lib/shell/config -C/dev/null -S 'sec1{ar1 a b c d; ar1 a b c; ar2 1 2; ar3 1.1}' 'sec1 {ar1[]; #ar2[2]; $ar3[-2]}'
 Out:   CF_sec1_ar1[1]='a'
        CF_sec1_ar1[2]='b'
        CF_sec1_ar1[3]='c'
@@ -26,7 +26,7 @@ Out:  CF_sec1_ar1[1]='a'
        CF_sec1_ar2[2]='2'
        CF_sec1_ar3[1]='1.1'
 
-Run:   obj/lib/shell/config -C/dev/null -S 'sec1{list1 {str1=1; list2=a b c}; list1 {str1=2; list2=d e}}' 'sec1 {@list1 {:str1; @list2{:str2}}}'
+Run:   obj/lib/shell/config -C/dev/null -S 'sec1{list1 {str1=1; list2=a b c}; list1 {str1=2; list2=d e}}' 'sec1 {@list1 {str1; @list2{str2}}}'
 Out:   CF_sec1_list1_str1[1]='1'
        CF_sec1_list1_list2_str2[1]='a'
        CF_sec1_list1_list2_str2[2]='b'
@@ -35,5 +35,5 @@ Out:  CF_sec1_list1_str1[1]='1'
        CF_sec1_list1_list2_str2[4]='d'
        CF_sec1_list1_list2_str2[5]='e'
 
-Run:   obj/lib/shell/config -C/dev/null 'sec{:str=a'\''b"c'\''d"\\e'\''f"g}'
+Run:   obj/lib/shell/config -C/dev/null 'sec{str=a'\''b"c'\''d"\\e'\''f"g}'
 Out:   CF_sec_str='ab"cd\e'\''fg'