Changeset 5a6c28d1 in mainline for uspace/lib/c/test/stdio/scanf.c


Ignore:
Timestamp:
2018-06-13T15:50:53Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
39f84ce4
Parents:
f47a905
git-author:
Jiri Svoboda <jiri@…> (2018-06-12 17:50:36)
git-committer:
Jiri Svoboda <jiri@…> (2018-06-13 15:50:53)
Message:

Replace libposix scanf with libc scanf.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/test/stdio/scanf.c

    rf47a905 r5a6c28d1  
    5555
    5656        /* Empty format string */
    57         rc = xxsscanf("42", "");
     57        rc = sscanf("42", "");
    5858        PCUT_ASSERT_INT_EQUALS(0, rc);
    5959}
     
    6565
    6666        /* Decimal integer */
    67         rc = xxsscanf("42", "%d", &i);
     67        rc = sscanf("42", "%d", &i);
    6868        PCUT_ASSERT_INT_EQUALS(1, rc);
    6969        PCUT_ASSERT_TRUE(i == 42);
     
    7676
    7777        /* Two integers */
    78         rc = xxsscanf("42 43", "%d%d", &i, &j);
     78        rc = sscanf("42 43", "%d%d", &i, &j);
    7979        PCUT_ASSERT_INT_EQUALS(2, rc);
    8080        PCUT_ASSERT_TRUE(i == 42);
     
    8888
    8989        /* Decimal signed char */
    90         rc = xxsscanf("42", "%hhd", &sc);
     90        rc = sscanf("42", "%hhd", &sc);
    9191        PCUT_ASSERT_INT_EQUALS(1, rc);
    9292        PCUT_ASSERT_TRUE(sc == 42);
     
    9999
    100100        /* Decimal short */
    101         rc = xxsscanf("42", "%hd", &si);
     101        rc = sscanf("42", "%hd", &si);
    102102        PCUT_ASSERT_INT_EQUALS(1, rc);
    103103        PCUT_ASSERT_TRUE(si == 42);
     
    110110
    111111        /* Decimal long */
    112         rc = xxsscanf("42", "%ld", &li);
     112        rc = sscanf("42", "%ld", &li);
    113113        PCUT_ASSERT_INT_EQUALS(1, rc);
    114114        PCUT_ASSERT_TRUE(li == 42);
     
    121121
    122122        /* Decimal long long */
    123         rc = xxsscanf("42", "%lld", &lli);
     123        rc = sscanf("42", "%lld", &lli);
    124124        PCUT_ASSERT_INT_EQUALS(1, rc);
    125125        PCUT_ASSERT_TRUE(lli == 42);
     
    132132
    133133        /* Decimal intmax_t */
    134         rc = xxsscanf("42", "%jd", &imax);
     134        rc = sscanf("42", "%jd", &imax);
    135135        PCUT_ASSERT_INT_EQUALS(1, rc);
    136136        PCUT_ASSERT_TRUE(imax == 42);
     
    143143
    144144        /* Decimal size_t-sized */
    145         rc = xxsscanf("42", "%zd", &szi);
     145        rc = sscanf("42", "%zd", &szi);
    146146        PCUT_ASSERT_INT_EQUALS(1, rc);
    147147        PCUT_ASSERT_TRUE(szi == 42);
     
    154154
    155155        /* Decimal ptrdiff_t-sized */
    156         rc = xxsscanf("42", "%td", &pdi);
     156        rc = sscanf("42", "%td", &pdi);
    157157        PCUT_ASSERT_INT_EQUALS(1, rc);
    158158        PCUT_ASSERT_TRUE(pdi == 42);
     
    165165
    166166        /* Decimal integer followed by hexadecimal digit */
    167         rc = xxsscanf("42a", "%d", &i);
     167        rc = sscanf("42a", "%d", &i);
    168168        PCUT_ASSERT_INT_EQUALS(1, rc);
    169169        PCUT_ASSERT_TRUE(i == 42);
     
    176176
    177177        /* Decimal integer - detect no prefix */
    178         rc = xxsscanf("42", "%i", &i);
     178        rc = sscanf("42", "%i", &i);
    179179        PCUT_ASSERT_INT_EQUALS(1, rc);
    180180        PCUT_ASSERT_TRUE(i == 42);
     
    187187
    188188        /* Prefixed octal integer followed by decimal digit */
    189         rc = xxsscanf("019", "%i", &i);
     189        rc = sscanf("019", "%i", &i);
    190190        PCUT_ASSERT_INT_EQUALS(1, rc);
    191191        PCUT_ASSERT_TRUE(i == 1);
     
    198198
    199199        /* Prefixed hexadecimal integer followed by other character */
    200         rc = xxsscanf("0xag", "%i", &i);
     200        rc = sscanf("0xag", "%i", &i);
    201201        PCUT_ASSERT_INT_EQUALS(1, rc);
    202202        PCUT_ASSERT_TRUE(i == 10);
     
    209209
    210210        /* Decimal integer with '+' sign */
    211         rc = xxsscanf("+42", "%d", &i);
     211        rc = sscanf("+42", "%d", &i);
    212212        PCUT_ASSERT_INT_EQUALS(1, rc);
    213213        PCUT_ASSERT_TRUE(i == 42);
     
    220220
    221221        /* Decimal integer with '-' sign */
    222         rc = xxsscanf("-42", "%d", &i);
     222        rc = sscanf("-42", "%d", &i);
    223223        PCUT_ASSERT_INT_EQUALS(1, rc);
    224224        PCUT_ASSERT_TRUE(i == -42);
     
    231231
    232232        /* Hexadecimal integer with prefix and '-' sign */
    233         rc = xxsscanf("-0xa", "%i", &i);
     233        rc = sscanf("-0xa", "%i", &i);
    234234        PCUT_ASSERT_INT_EQUALS(1, rc);
    235235        PCUT_ASSERT_TRUE(i == -10);
     
    242242
    243243        /* Decimal unsigned integer */
    244         rc = xxsscanf("42", "%u", &u);
     244        rc = sscanf("42", "%u", &u);
    245245        PCUT_ASSERT_INT_EQUALS(1, rc);
    246246        PCUT_ASSERT_TRUE(u == 42);
     
    253253
    254254        /* Decimal unsigned char */
    255         rc = xxsscanf("42", "%hhu", &uc);
     255        rc = sscanf("42", "%hhu", &uc);
    256256        PCUT_ASSERT_INT_EQUALS(1, rc);
    257257        PCUT_ASSERT_TRUE(uc == 42);
     
    264264
    265265        /* Decimal unsigned short */
    266         rc = xxsscanf("42", "%hu", &su);
     266        rc = sscanf("42", "%hu", &su);
    267267        PCUT_ASSERT_INT_EQUALS(1, rc);
    268268        PCUT_ASSERT_TRUE(su == 42);
     
    275275
    276276        /* Decimal unsigned long */
    277         rc = xxsscanf("42", "%lu", &lu);
     277        rc = sscanf("42", "%lu", &lu);
    278278        PCUT_ASSERT_INT_EQUALS(1, rc);
    279279        PCUT_ASSERT_TRUE(lu == 42);
     
    286286
    287287        /* Decimal unsigned long long */
    288         rc = xxsscanf("42", "%llu", &llu);
     288        rc = sscanf("42", "%llu", &llu);
    289289        PCUT_ASSERT_INT_EQUALS(1, rc);
    290290        PCUT_ASSERT_TRUE(llu == 42);
     
    297297
    298298        /* Decimal uintmax_t */
    299         rc = xxsscanf("42", "%ju", &umax);
     299        rc = sscanf("42", "%ju", &umax);
    300300        PCUT_ASSERT_INT_EQUALS(1, rc);
    301301        PCUT_ASSERT_TRUE(umax == 42);
     
    308308
    309309        /* Decimal size_t */
    310         rc = xxsscanf("42", "%zu", &szu);
     310        rc = sscanf("42", "%zu", &szu);
    311311        PCUT_ASSERT_INT_EQUALS(1, rc);
    312312        PCUT_ASSERT_TRUE(szu == 42);
     
    319319
    320320        /* Decimal ptrdiff_t-sized unsigned int*/
    321         rc = xxsscanf("42", "%tu", &pdu);
     321        rc = sscanf("42", "%tu", &pdu);
    322322        PCUT_ASSERT_INT_EQUALS(1, rc);
    323323        PCUT_ASSERT_TRUE(pdu == 42);
     
    330330
    331331        /* Octal unsigned integer */
    332         rc = xxsscanf("52", "%o", &u);
     332        rc = sscanf("52", "%o", &u);
    333333        PCUT_ASSERT_INT_EQUALS(1, rc);
    334334        PCUT_ASSERT_TRUE(u == 052);
     
    341341
    342342        /* Hexadecimal unsigned integer */
    343         rc = xxsscanf("2a", "%x", &u);
     343        rc = sscanf("2a", "%x", &u);
    344344        PCUT_ASSERT_INT_EQUALS(1, rc);
    345345        PCUT_ASSERT_TRUE(u == 0x2a);
     
    352352
    353353        /* Hexadecimal unsigned integer unsing alternate specifier */
    354         rc = xxsscanf("2a", "%X", &u);
     354        rc = sscanf("2a", "%X", &u);
    355355        PCUT_ASSERT_INT_EQUALS(1, rc);
    356356        PCUT_ASSERT_TRUE(u == 0x2a);
     
    363363
    364364        /* Uppercase hexadecimal unsigned integer */
    365         rc = xxsscanf("2A", "%x", &u);
     365        rc = sscanf("2A", "%x", &u);
    366366        PCUT_ASSERT_INT_EQUALS(1, rc);
    367367        PCUT_ASSERT_TRUE(u == 0x2a);
    368368}
    369369
     370PCUT_TEST(hex_not_match_0x)
     371{
     372        int rc;
     373        unsigned u;
     374
     375        /* Make sure %x does not match 0x prefix */
     376        rc = sscanf("0x1", "%x", &u);
     377
     378        PCUT_ASSERT_INT_EQUALS(1, rc);
     379        PCUT_ASSERT_TRUE(u == 0);
     380}
     381
    370382PCUT_TEST(skipws)
    371383{
     
    374386
    375387        /* Skipping whitespace */
    376         rc = xxsscanf(" \t\n42", "%d", &i);
     388        rc = sscanf(" \t\n42", "%d", &i);
    377389        PCUT_ASSERT_INT_EQUALS(1, rc);
    378390        PCUT_ASSERT_TRUE(i == 42);
     
    385397
    386398        /* Percentile conversion */
    387         rc = xxsscanf(" \t\n%42", "%%%d", &i);
     399        rc = sscanf(" \t\n%42", "%%%d", &i);
    388400        PCUT_ASSERT_INT_EQUALS(1, rc);
    389401        PCUT_ASSERT_TRUE(i == 42);
     
    396408
    397409        /* Matching specific character */
    398         rc = xxsscanf("x42", "x%d", &i);
     410        rc = sscanf("x42", "x%d", &i);
    399411        PCUT_ASSERT_INT_EQUALS(1, rc);
    400412        PCUT_ASSERT_TRUE(i == 42);
     
    407419
    408420        /* Matching specific character should not skip whitespace */
    409         rc = xxsscanf(" x42", "x%d", &i);
     421        rc = sscanf(" x42", "x%d", &i);
    410422        PCUT_ASSERT_INT_EQUALS(0, rc);
    411423}
     
    417429
    418430        /* Skipping whitespace + match specific character */
    419         rc = xxsscanf(" x42", "\t\nx%d", &i);
     431        rc = sscanf(" x42", "\t\nx%d", &i);
    420432        PCUT_ASSERT_INT_EQUALS(1, rc);
    421433        PCUT_ASSERT_TRUE(i == 42);
     
    428440
    429441        /* Decimal with limited, but sufficient width */
    430         rc = xxsscanf("42", "%2d", &i);
     442        rc = sscanf("42", "%2d", &i);
    431443        PCUT_ASSERT_INT_EQUALS(1, rc);
    432444        PCUT_ASSERT_TRUE(i == 42);
     
    439451
    440452        /* Decimal with limited, smaller width */
    441         rc = xxsscanf("42", "%1d", &i);
     453        rc = sscanf("42", "%1d", &i);
    442454        PCUT_ASSERT_INT_EQUALS(1, rc);
    443455        PCUT_ASSERT_TRUE(i == 4);
     
    450462
    451463        /* Integer with hex prefix, format with limited, sufficient width */
    452         rc = xxsscanf("0x1", "%3i", &i);
     464        rc = sscanf("0x1", "%3i", &i);
    453465        PCUT_ASSERT_INT_EQUALS(1, rc);
    454466        PCUT_ASSERT_TRUE(i == 1);
     
    461473
    462474        /* Integer with hex prefix, format with limited, smaller width */
    463         rc = xxsscanf("0x1", "%2i", &i);
     475        rc = sscanf("0x1", "%2i", &i);
    464476        PCUT_ASSERT_INT_EQUALS(1, rc);
    465477        PCUT_ASSERT_TRUE(i == 0);
     
    472484
    473485        /* Integer with octal prefix, format with limited, sufficient width */
    474         rc = xxsscanf("012", "%3i", &i);
     486        rc = sscanf("012", "%3i", &i);
    475487        PCUT_ASSERT_INT_EQUALS(1, rc);
    476488        PCUT_ASSERT_TRUE(i == 012);
     
    483495
    484496        /* Integer with octal prefix, format with limited, smaller width */
    485         rc = xxsscanf("012", "%2i", &i);
     497        rc = sscanf("012", "%2i", &i);
    486498        PCUT_ASSERT_INT_EQUALS(1, rc);
    487499        PCUT_ASSERT_TRUE(i == 01);
     
    494506
    495507        /* Integer with octal prefix, format with width allowing just for 0 */
    496         rc = xxsscanf("012", "%1i", &i);
     508        rc = sscanf("012", "%1i", &i);
    497509        PCUT_ASSERT_INT_EQUALS(1, rc);
    498510        PCUT_ASSERT_TRUE(i == 0);
     
    505517
    506518        /* Pointer */
    507         rc = xxsscanf("0x12341234", "%p", &ptr);
    508         PCUT_ASSERT_INT_EQUALS(1, rc);
    509         PCUT_ASSERT_TRUE(ptr == (void *)0x12341234);
     519        rc = sscanf("0xABCDEF88", "%p", &ptr);
     520        PCUT_ASSERT_INT_EQUALS(1, rc);
     521        PCUT_ASSERT_TRUE(ptr == (void *)0xABCDEF88);
    510522}
    511523
     
    516528
    517529        /* Single character */
    518         rc = xxsscanf("x", "%c", &c);
     530        rc = sscanf("x", "%c", &c);
    519531        PCUT_ASSERT_INT_EQUALS(1, rc);
    520532        PCUT_ASSERT_TRUE(c == 'x');
     
    527539
    528540        /* Single whitespace character */
    529         rc = xxsscanf("\t", "%c", &c);
     541        rc = sscanf("\t", "%c", &c);
    530542        PCUT_ASSERT_INT_EQUALS(1, rc);
    531543        PCUT_ASSERT_TRUE(c == '\t');
     
    539551        /* Multiple characters */
    540552        memset(chars, 'X', chars_size);
    541         rc = xxsscanf("abc", "%3c", chars);
     553        rc = sscanf("abc", "%3c", chars);
    542554        PCUT_ASSERT_INT_EQUALS(1, rc);
    543555        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    554566        /* Fewer characters than requested */
    555567        memset(chars, 'X', chars_size);
    556         rc = xxsscanf("abc", "%5c", chars);
     568        rc = sscanf("abc", "%5c", chars);
    557569        PCUT_ASSERT_INT_EQUALS(1, rc);
    558570        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    569581        /* Reading characters but no found */
    570582        memset(chars, 'X', chars_size);
    571         rc = xxsscanf("", "%5c", chars);
     583        rc = sscanf("", "%5c", chars);
    572584        PCUT_ASSERT_INT_EQUALS(EOF, rc);
    573585        PCUT_ASSERT_TRUE(chars[0] == 'X');
     
    580592
    581593        /* Multiple characters with suppressed assignment */
    582         rc = xxsscanf("abc", "%*3c%n", &n);
     594        rc = sscanf("abc", "%*3c%n", &n);
    583595        PCUT_ASSERT_INT_EQUALS(0, rc);
    584596        PCUT_ASSERT_INT_EQUALS(3, n);
     
    592604        /* Multiple characters with memory allocation */
    593605        cp = NULL;
    594         rc = xxsscanf("abc", "%m3c", &cp);
     606        rc = sscanf("abc", "%m3c", &cp);
    595607        PCUT_ASSERT_INT_EQUALS(1, rc);
    596608        PCUT_ASSERT_NOT_NULL(cp);
     
    608620        /* String of non-whitespace characters, unlimited width */
    609621        memset(chars, 'X', chars_size);
    610         rc = xxsscanf(" abc d", "%s", chars);
     622        rc = sscanf(" abc d", "%s", chars);
    611623        PCUT_ASSERT_INT_EQUALS(1, rc);
    612624        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    624636        /* String of non-whitespace characters, until the end */
    625637        memset(chars, 'X', chars_size);
    626         rc = xxsscanf(" abc", "%s", chars);
     638        rc = sscanf(" abc", "%s", chars);
    627639        PCUT_ASSERT_INT_EQUALS(1, rc);
    628640        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    640652        /* String of non-whitespace characters, large enough width */
    641653        memset(chars, 'X', chars_size);
    642         rc = xxsscanf(" abc d", "%5s", chars);
     654        rc = sscanf(" abc d", "%5s", chars);
    643655        PCUT_ASSERT_INT_EQUALS(1, rc);
    644656        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    656668        /* Want string of non-whitespace, but got only whitespace */
    657669        memset(chars, 'X', chars_size);
    658         rc = xxsscanf(" ", "%s", chars);
     670        rc = sscanf(" ", "%s", chars);
    659671        PCUT_ASSERT_INT_EQUALS(EOF, rc);
    660672        PCUT_ASSERT_TRUE(chars[0] == 'X');
     
    668680        /* String of non-whitespace characters, small width */
    669681        memset(chars, 'X', chars_size);
    670         rc = xxsscanf(" abc", "%2s", chars);
     682        rc = sscanf(" abc", "%2s", chars);
    671683        PCUT_ASSERT_INT_EQUALS(1, rc);
    672684        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    682694
    683695        /* String of non-whitespace characters, assignment suppression */
    684         rc = xxsscanf(" abc d", "%*s%n", &n);
     696        rc = sscanf(" abc d", "%*s%n", &n);
    685697        PCUT_ASSERT_INT_EQUALS(0, rc);
    686698        PCUT_ASSERT_INT_EQUALS(4, n);
     
    693705
    694706        /* String of non-whitespace characters, memory allocation */
    695         rc = xxsscanf(" abc d", "%ms", &cp);
     707        rc = sscanf(" abc d", "%ms", &cp);
    696708        PCUT_ASSERT_INT_EQUALS(1, rc);
    697709        PCUT_ASSERT_NOT_NULL(cp);
     
    711723        /* Set conversion without width specified terminating before the end  */
    712724        memset(chars, 'X', chars_size);
    713         rc = xxsscanf("abcd42", "%[abc]d%d", chars, &i);
     725        rc = sscanf("abcd42", "%[abc]d%d", chars, &i);
    714726        PCUT_ASSERT_INT_EQUALS(2, rc);
    715727        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    728740        /* Set conversion without width specified, until the end */
    729741        memset(chars, 'X', chars_size);
    730         rc = xxsscanf("abc", "%[abc]", chars);
     742        rc = sscanf("abc", "%[abc]", chars);
    731743        PCUT_ASSERT_INT_EQUALS(1, rc);
    732744        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    744756        /* Set conversion with larger width */
    745757        memset(chars, 'X', chars_size);
    746         rc = xxsscanf("abcd", "%5[abc]", chars);
     758        rc = sscanf("abcd", "%5[abc]", chars);
    747759        PCUT_ASSERT_INT_EQUALS(1, rc);
    748760        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    760772        /* Set conversion with smaller width */
    761773        memset(chars, 'X', chars_size);
    762         rc = xxsscanf("abcd", "%3[abcd]", chars);
     774        rc = sscanf("abcd", "%3[abcd]", chars);
    763775        PCUT_ASSERT_INT_EQUALS(1, rc);
    764776        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    776788        /* Set conversion with negated scanset */
    777789        memset(chars, 'X', chars_size);
    778         rc = xxsscanf("abcd", "%[^d]", chars);
     790        rc = sscanf("abcd", "%[^d]", chars);
    779791        PCUT_ASSERT_INT_EQUALS(1, rc);
    780792        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    792804        /* Set conversion with ']' in scanset */
    793805        memset(chars, 'X', chars_size);
    794         rc = xxsscanf("]bcd", "%[]bc]", chars);
     806        rc = sscanf("]bcd", "%[]bc]", chars);
    795807        PCUT_ASSERT_INT_EQUALS(1, rc);
    796808        PCUT_ASSERT_TRUE(chars[0] == ']');
     
    808820        /* Set conversion with ']' in inverted scanset */
    809821        memset(chars, 'X', chars_size);
    810         rc = xxsscanf("abc]", "%[^]def]", chars);
     822        rc = sscanf("abc]", "%[^]def]", chars);
    811823        PCUT_ASSERT_INT_EQUALS(1, rc);
    812824        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    823835
    824836        /* Set conversion with assignment suppression */
    825         rc = xxsscanf("abcd42", "%*[abc]%n", &n);
     837        rc = sscanf("abcd42", "%*[abc]%n", &n);
    826838        PCUT_ASSERT_INT_EQUALS(0, rc);
    827839        PCUT_ASSERT_INT_EQUALS(3, n);
     
    835847        /* Set conversion with memory allocation */
    836848        cp = NULL;
    837         rc = xxsscanf("abcd42", "%m[abcd]", &cp);
     849        rc = sscanf("abcd42", "%m[abcd]", &cp);
    838850        PCUT_ASSERT_INT_EQUALS(1, rc);
    839851        PCUT_ASSERT_NOT_NULL(cp);
     
    852864
    853865        /* Decimal integer with suppressed assignment */
    854         rc = xxsscanf("42", "%*d%n", &n);
     866        rc = sscanf("42", "%*d%n", &n);
    855867        PCUT_ASSERT_INT_EQUALS(0, rc);
    856868        PCUT_ASSERT_INT_EQUALS(2, n);
     
    865877        /* Count of characters read */
    866878        memset(chars, 'X', chars_size);
    867         rc = xxsscanf("abcd", "%3c%n", chars, &n);
     879        rc = sscanf("abcd", "%3c%n", chars, &n);
    868880        PCUT_ASSERT_INT_EQUALS(1, rc);
    869881        PCUT_ASSERT_TRUE(chars[0] == 'a');
     
    880892
    881893        /* Float with just integer part */
    882         rc = xxsscanf("42", "%f", &f);
     894        rc = sscanf("42", "%f", &f);
    883895        PCUT_ASSERT_INT_EQUALS(1, rc);
    884896        PCUT_ASSERT_TRUE(f == 42.0);
     
    891903
    892904        /* Double with just integer part */
    893         rc = xxsscanf("42", "%lf", &d);
     905        rc = sscanf("42", "%lf", &d);
    894906        PCUT_ASSERT_INT_EQUALS(1, rc);
    895907        PCUT_ASSERT_TRUE(d == 42.0);
     
    902914
    903915        /* Long double with just integer part */
    904         rc = xxsscanf("42", "%Lf", &ld);
     916        rc = sscanf("42", "%Lf", &ld);
    905917        PCUT_ASSERT_INT_EQUALS(1, rc);
    906918        PCUT_ASSERT_TRUE(ld == 42.0);
     
    913925
    914926        /* Float with just hexadecimal integer part */
    915         rc = xxsscanf("0x2a", "%f", &f);
     927        rc = sscanf("0x2a", "%f", &f);
    916928        PCUT_ASSERT_INT_EQUALS(1, rc);
    917929        PCUT_ASSERT_TRUE(f == 0x2a.0p0);
     
    924936
    925937        /* Float with sign and integer part */
    926         rc = xxsscanf("-42", "%f", &f);
     938        rc = sscanf("-42", "%f", &f);
    927939        PCUT_ASSERT_INT_EQUALS(1, rc);
    928940        PCUT_ASSERT_TRUE(f == -42.0);
     
    935947
    936948        /* Float with integer and fractional part */
    937         rc = xxsscanf("4.2", "%f", &f);
     949        rc = sscanf("4.2", "%f", &f);
    938950        PCUT_ASSERT_INT_EQUALS(1, rc);
    939951        /* 1/10 is not exactly representable in binary floating point */
     
    948960
    949961        /* Float with integer part and unsigned exponent */
    950         rc = xxsscanf("42e1", "%f", &f);
     962        rc = sscanf("42e1", "%f", &f);
    951963        PCUT_ASSERT_INT_EQUALS(1, rc);
    952964        PCUT_ASSERT_TRUE(f == 420.0);
     
    959971
    960972        /* Float with integer part and positive exponent */
    961         rc = xxsscanf("42e+1", "%f", &f);
     973        rc = sscanf("42e+1", "%f", &f);
    962974        PCUT_ASSERT_INT_EQUALS(1, rc);
    963975        PCUT_ASSERT_TRUE(f == 420.0);
     
    970982
    971983        /* Float with integer part and negative exponent */
    972         rc = xxsscanf("42e-1", "%f", &f);
     984        rc = sscanf("42e-1", "%f", &f);
    973985        PCUT_ASSERT_INT_EQUALS(1, rc);
    974986        /* 1/10 is not exactly representable in binary floating point */
     
    983995
    984996        /* Float with integer, fractional parts and unsigned exponent */
    985         rc = xxsscanf("4.2e1", "%f", &f);
     997        rc = sscanf("4.2e1", "%f", &f);
    986998        PCUT_ASSERT_INT_EQUALS(1, rc);
    987999        PCUT_ASSERT_TRUE(f == 42.0);
     
    9941006
    9951007        /* Hexadecimal float with integer and fractional part */
    996         rc = xxsscanf("0x2.a", "%f", &f);
     1008        rc = sscanf("0x2.a", "%f", &f);
    9971009        PCUT_ASSERT_INT_EQUALS(1, rc);
    9981010        PCUT_ASSERT_TRUE(f == 0x2.ap0);
     
    10071019         * Hexadecimal float with integer part and unsigned exponent
    10081020         */
    1009         rc = xxsscanf("0x2ap1", "%f", &f);
     1021        rc = sscanf("0x2ap1", "%f", &f);
    10101022        PCUT_ASSERT_INT_EQUALS(1, rc);
    10111023        PCUT_ASSERT_TRUE(f == 0x2ap1);
     
    10201032         * Hexadecimal float with integer part and negative exponent
    10211033         */
    1022         rc = xxsscanf("0x2ap-1", "%f", &f);
     1034        rc = sscanf("0x2ap-1", "%f", &f);
    10231035        PCUT_ASSERT_INT_EQUALS(1, rc);
    10241036        PCUT_ASSERT_TRUE(f == 0x2ap-1);
     
    10341046         * exponent
    10351047         */
    1036         rc = xxsscanf("0x2.ap4", "%f", &f);
     1048        rc = sscanf("0x2.ap4", "%f", &f);
    10371049        PCUT_ASSERT_INT_EQUALS(1, rc);
    10381050        PCUT_ASSERT_TRUE(f == 0x2.ap4);
     
    10451057
    10461058        /* Float with just integer part and limited width */
    1047         rc = xxsscanf("1234", "%3f", &f);
     1059        rc = sscanf("1234", "%3f", &f);
    10481060        PCUT_ASSERT_INT_EQUALS(1, rc);
    10491061        PCUT_ASSERT_TRUE(f == 123.0);
     
    10561068
    10571069        /* Float with integer, fractional part and limited width */
    1058         rc = xxsscanf("12.34", "%4f", &f);
     1070        rc = sscanf("12.34", "%4f", &f);
    10591071        PCUT_ASSERT_INT_EQUALS(1, rc);
    10601072        /* 1/10 is not exactly representable in binary floating point */
     
    10691081
    10701082        /* Float with width only enough to cover an integral part */
    1071         rc = xxsscanf("12.34", "%3f", &f);
     1083        rc = sscanf("12.34", "%3f", &f);
    10721084        PCUT_ASSERT_INT_EQUALS(1, rc);
    10731085        PCUT_ASSERT_TRUE(f == 12.0);
     
    10801092
    10811093        /* Float with width too small to cover the exponent number */
    1082         rc = xxsscanf("12.34e+2", "%7f", &f);
     1094        rc = sscanf("12.34e+2", "%7f", &f);
    10831095        PCUT_ASSERT_INT_EQUALS(1, rc);
    10841096        /* 1/10 is not exactly representable in binary floating point */
     
    10931105
    10941106        /* Float with width too small to cover the exponent sign and number */
    1095         rc = xxsscanf("12.34e+2", "%6f", &f);
     1107        rc = sscanf("12.34e+2", "%6f", &f);
    10961108        PCUT_ASSERT_INT_EQUALS(1, rc);
    10971109        /* 1/10 is not exactly representable in binary floating point */
     
    11061118
    11071119        /* Float with width too small to cover the exponent part */
    1108         rc = xxsscanf("12.34e+2", "%5f", &f);
     1120        rc = sscanf("12.34e+2", "%5f", &f);
    11091121        PCUT_ASSERT_INT_EQUALS(1, rc);
    11101122        /* 1/10 is not exactly representable in binary floating point */
     
    11191131
    11201132        /* Float using alternate form 'F' */
    1121         rc = xxsscanf("42e1", "%F", &f);
     1133        rc = sscanf("42e1", "%F", &f);
    11221134        PCUT_ASSERT_INT_EQUALS(1, rc);
    11231135        PCUT_ASSERT_TRUE(f == 420.0);
     
    11301142
    11311143        /* Float using alternate form 'a' */
    1132         rc = xxsscanf("42e1", "%a", &f);
     1144        rc = sscanf("42e1", "%a", &f);
    11331145        PCUT_ASSERT_INT_EQUALS(1, rc);
    11341146        PCUT_ASSERT_TRUE(f == 420.0);
     
    11411153
    11421154        /* Float using alternate form 'e' */
    1143         rc = xxsscanf("42e1", "%e", &f);
     1155        rc = sscanf("42e1", "%e", &f);
    11441156        PCUT_ASSERT_INT_EQUALS(1, rc);
    11451157        PCUT_ASSERT_TRUE(f == 420.0);
     
    11521164
    11531165        /* Float using alternate form 'g' */
    1154         rc = xxsscanf("42e1", "%g", &f);
     1166        rc = sscanf("42e1", "%g", &f);
    11551167        PCUT_ASSERT_INT_EQUALS(1, rc);
    11561168        PCUT_ASSERT_TRUE(f == 420.0);
     
    11631175
    11641176        /* Float using alternate form 'A' */
    1165         rc = xxsscanf("42e1", "%A", &f);
     1177        rc = sscanf("42e1", "%A", &f);
    11661178        PCUT_ASSERT_INT_EQUALS(1, rc);
    11671179        PCUT_ASSERT_TRUE(f == 420.0);
     
    11741186
    11751187        /* Float using alternate form 'E' */
    1176         rc = xxsscanf("42e1", "%E", &f);
     1188        rc = sscanf("42e1", "%E", &f);
    11771189        PCUT_ASSERT_INT_EQUALS(1, rc);
    11781190        PCUT_ASSERT_TRUE(f == 420.0);
     
    11851197
    11861198        /* Float using alternate form 'G' */
    1187         rc = xxsscanf("42e1", "%G", &f);
     1199        rc = sscanf("42e1", "%G", &f);
    11881200        PCUT_ASSERT_INT_EQUALS(1, rc);
    11891201        PCUT_ASSERT_TRUE(f == 420.0);
Note: See TracChangeset for help on using the changeset viewer.