Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5a6c28d1 in mainline


Ignore:
Timestamp:
2018-06-13T15:50:53Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
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.

Location:
uspace/lib
Files:
1 deleted
7 edited

Legend:

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

    rf47a905 r5a6c28d1  
    624624        v = 0;
    625625        do {
    626                 digit = digit_value(c); // XXX
     626                digit = digit_value(c);
    627627                if (digit >= base)
    628628                        break;
     
    12661266}
    12671267
    1268 int xxvfscanf(FILE *f, const char *fmt, va_list ap)
     1268int vfscanf(FILE *f, const char *fmt, va_list ap)
    12691269{
    12701270        const char *cp;
     
    13231323}
    13241324
    1325 int xxfscanf(FILE *f, const char *fmt, ...)
     1325int fscanf(FILE *f, const char *fmt, ...)
    13261326{
    13271327        va_list args;
     
    13291329
    13301330        va_start(args, fmt);
    1331         rc = xxvfscanf(f, fmt, args);
     1331        rc = vfscanf(f, fmt, args);
    13321332        va_end(args);
    13331333
     
    13351335}
    13361336
    1337 int xxvscanf(const char *fmt, va_list ap)
    1338 {
    1339         return xxvfscanf(stdin, fmt, ap);
    1340 }
    1341 
    1342 int xxscanf(const char *fmt, ...)
     1337int vscanf(const char *fmt, va_list ap)
     1338{
     1339        return vfscanf(stdin, fmt, ap);
     1340}
     1341
     1342int scanf(const char *fmt, ...)
    13431343{
    13441344        va_list args;
     
    13461346
    13471347        va_start(args, fmt);
    1348         rc = xxvscanf(fmt, args);
     1348        rc = vscanf(fmt, args);
    13491349        va_end(args);
    13501350
  • uspace/lib/c/generic/stdio/sscanf.c

    rf47a905 r5a6c28d1  
    4040#include "../private/sstream.h"
    4141
    42 int xxvsscanf(const char *s, const char *fmt, va_list ap)
     42int vsscanf(const char *s, const char *fmt, va_list ap)
    4343{
    4444        FILE f;
    4545
    4646        __sstream_init(s, &f);
    47         return xxvfscanf(&f, fmt, ap);
     47        return vfscanf(&f, fmt, ap);
    4848}
    4949
    50 int xxsscanf(const char *s, const char *fmt, ...)
     50int sscanf(const char *s, const char *fmt, ...)
    5151{
    5252        va_list args;
     
    5454
    5555        va_start(args, fmt);
    56         rc = xxvsscanf(s, fmt, args);
     56        rc = vsscanf(s, fmt, args);
    5757        va_end(args);
    5858
  • uspace/lib/c/include/stdio.h

    rf47a905 r5a6c28d1  
    101101extern int vsnprintf(char *, size_t, const char *, va_list);
    102102
    103 extern int xxscanf(const char *, ...);
    104 extern int xxvscanf(const char *, va_list);
    105 extern int xxfscanf(FILE *, const char *, ...);
    106 extern int xxvfscanf(FILE *, const char *, va_list);
    107 extern int xxsscanf(const char *, const char *, ...);
    108 extern int xxvsscanf(const char *, const char *, va_list);
     103/* Formatted input */
     104extern int scanf(const char *, ...);
     105extern int vscanf(const char *, va_list);
     106extern int fscanf(FILE *, const char *, ...);
     107extern int vfscanf(FILE *, const char *, va_list);
     108extern int sscanf(const char *, const char *, ...);
     109extern int vsscanf(const char *, const char *, va_list);
    109110
    110111/* File stream functions */
  • 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);
  • uspace/lib/posix/Makefile

    rf47a905 r5a6c28d1  
    7070        src/signal.c \
    7171        src/stdio.c \
    72         src/stdio/scanf.c \
    7372        src/stdlib.c \
    7473        src/stdlib/strtold.c \
  • uspace/lib/posix/include/posix/stdio.h

    rf47a905 r5a6c28d1  
    164164extern int vsprintf(char *__restrict__ s, const char *__restrict__ format, va_list ap);
    165165
    166 /* Formatted Input */
    167 extern int fscanf(
    168     FILE *__restrict__ stream, const char *__restrict__ format, ...);
    169 extern int vfscanf(
    170     FILE *__restrict__ stream, const char *__restrict__ format, va_list arg);
    171 extern int scanf(const char *__restrict__ format, ...);
    172 extern int vscanf(const char *__restrict__ format, va_list arg);
    173 extern int sscanf(
    174     const char *__restrict__ s, const char *__restrict__ format, ...);
    175 extern int vsscanf(
    176     const char *__restrict__ s, const char *__restrict__ format, va_list arg);
    177 
    178166/* File Locking */
    179167extern void flockfile(FILE *file);
  • uspace/lib/posix/src/stdio.c

    rf47a905 r5a6c28d1  
    351351
    352352/**
    353  * Convert formatted input from the stream.
    354  *
    355  * @param stream Input stream.
    356  * @param format Format description.
    357  * @return The number of converted output items or EOF on failure.
    358  */
    359 int fscanf(FILE *restrict stream, const char *restrict format, ...)
    360 {
    361         va_list list;
    362         va_start(list, format);
    363         int result = vfscanf(stream, format, list);
    364         va_end(list);
    365         return result;
    366 }
    367 
    368 /**
    369  * Convert formatted input from the standard input.
    370  *
    371  * @param format Format description.
    372  * @return The number of converted output items or EOF on failure.
    373  */
    374 int scanf(const char *restrict format, ...)
    375 {
    376         va_list list;
    377         va_start(list, format);
    378         int result = vscanf(format, list);
    379         va_end(list);
    380         return result;
    381 }
    382 
    383 /**
    384  * Convert formatted input from the standard input.
    385  *
    386  * @param format Format description.
    387  * @param arg Output items.
    388  * @return The number of converted output items or EOF on failure.
    389  */
    390 int vscanf(const char *restrict format, va_list arg)
    391 {
    392         return vfscanf(stdin, format, arg);
    393 }
    394 
    395 /**
    396  * Convert formatted input from the string.
    397  *
    398  * @param s Input string.
    399  * @param format Format description.
    400  * @return The number of converted output items or EOF on failure.
    401  */
    402 int sscanf(const char *restrict s, const char *restrict format, ...)
    403 {
    404         va_list list;
    405         va_start(list, format);
    406         int result = vsscanf(s, format, list);
    407         va_end(list);
    408         return result;
    409 }
    410 
    411 /**
    412353 * Acquire file stream for the thread.
    413354 *
Note: See TracChangeset for help on using the changeset viewer.