Changeset 2b3dd78 in mainline for uspace/lib/posix/src/stdio/scanf.c


Ignore:
Timestamp:
2018-01-31T12:02:00Z (7 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5595841
Parents:
a0a9cc2 (diff), 14d789c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'upstream/master' into forwardport

change tmon includes because of new stdlib

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/src/stdio/scanf.c

    ra0a9cc2 r2b3dd78  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include <assert.h>
    3936
     
    119116        /* Initialize internal structures. */
    120117        self->consumed = 0;
    121         ssize_t fetched = posix_getline(
     118        ssize_t fetched = getline(
    122119            &self->window, &self->window_size, self->source.stream);
    123120        if (fetched != -1) {
     
    140137        /* Initialize internal structures. */
    141138        self->consumed = 0;
    142         self->fetched = posix_strlen(self->source.string);
     139        self->fetched = strlen(self->source.string);
    143140        self->window = (char *) self->source.string;
    144141        self->window_size = self->fetched + 1;
     
    158155                /* Do we need to fetch a new line from the source? */
    159156                if (*self->cursor == '\0') {
    160                         ssize_t fetched = posix_getline(&self->window,
     157                        ssize_t fetched = getline(&self->window,
    161158                            &self->window_size, self->source.stream);
    162159                        if (fetched != -1) {
     
    208205                 * containing newline, while at the same time newline is the character
    209206                 * that breaks the matching process. */
    210                 int rc = posix_fseek(
    211                     self->source.stream, -1, SEEK_CUR);
     207                int rc = fseek(self->source.stream, -1, SEEK_CUR);
    212208                if (rc == -1) {
    213209                        /* Seek failed.  */
    214210                        return 0;
    215211                }
    216                 ssize_t fetched = posix_getline(&self->window,
     212                ssize_t fetched = getline(&self->window,
    217213                    &self->window_size, self->source.stream);
    218214                if (fetched != -1) {
     
    266262        if (*self->cursor == '\0') {
    267263                /* Window was completely consumed, fetch new data. */
    268                 ssize_t fetched = posix_getline(&self->window,
     264                ssize_t fetched = getline(&self->window,
    269265                    &self->window_size, self->source.stream);
    270266                if (fetched != -1) {
     
    298294        /* Try to correct the difference between the stream position and what was
    299295         * actually consumed. If it is not possible, continue anyway. */
    300         posix_fseek(self->source.stream, self->consumed - self->fetched, SEEK_CUR);
     296        fseek(self->source.stream, self->consumed - self->fetched, SEEK_CUR);
    301297
    302298        /* Destruct internal structures. */
     
    563559                                }
    564560                                char *fmt_new = NULL;
    565                                 width = posix_strtol(fmt, &fmt_new, 10);
     561                                width = strtol(fmt, &fmt_new, 10);
    566562                                if (width != 0) {
    567563                                        fmt = fmt_new;
     
    625621
    626622                                const char *cur_borrowed = NULL;
     623                                char *cur_duplicated = NULL;
    627624                                const char *cur_limited = NULL;
    628                                 char *cur_updated = NULL;
     625                                const char *cur_updated = NULL;
    629626
    630627                                /* Borrow the cursor. Until it is returned to the provider
     
    637634                                 * than allowed by width. */
    638635                                if (width != -1) {
    639                                         cur_limited = posix_strndup(cur_borrowed, width);
     636                                        cur_duplicated = strndup(cur_borrowed, width);
     637                                        cur_limited = cur_duplicated;
    640638                                } else {
    641639                                        cur_limited = cur_borrowed;
    642640                                }
    643                                 cur_updated = (char *) cur_limited;
     641                                cur_updated = cur_limited;
    644642
    645643                                long long sres = 0;
     
    648646                                /* Try to convert the integer. */
    649647                                if (int_conv_unsigned) {
    650                                         ures = posix_strtoull(cur_limited, &cur_updated, int_conv_base);
     648                                        ures = strtoull(cur_limited, (char **) &cur_updated, int_conv_base);
    651649                                } else {
    652                                         sres = posix_strtoll(cur_limited, &cur_updated, int_conv_base);
     650                                        sres = strtoll(cur_limited, (char **) &cur_updated, int_conv_base);
    653651                                }
    654652
    655653                                /* Update the cursor so it can be returned to the provider. */
    656654                                cur_borrowed += cur_updated - cur_limited;
    657                                 if (width != -1 && cur_limited != NULL) {
     655                                if (cur_duplicated != NULL) {
    658656                                        /* Deallocate duplicated part of the cursor view. */
    659                                         free(cur_limited);
     657                                        free(cur_duplicated);
    660658                                }
    661659                                cur_limited = NULL;
    662660                                cur_updated = NULL;
     661                                cur_duplicated = NULL;
    663662                                /* Return the cursor to the provider. Input consistency is again
    664663                                 * the job of the provider, so we can report errors from
     
    797796                                const char *cur_borrowed = NULL;
    798797                                const char *cur_limited = NULL;
    799                                 char *cur_updated = NULL;
     798                                char *cur_duplicated = NULL;
     799                                const char *cur_updated = NULL;
    800800
    801801                                /* Borrow the cursor. Until it is returned to the provider
     
    808808                                 * than allowed by width. */
    809809                                if (width != -1) {
    810                                         cur_limited = posix_strndup(cur_borrowed, width);
     810                                        cur_duplicated = strndup(cur_borrowed, width);
     811                                        cur_limited = cur_duplicated;
    811812                                } else {
    812813                                        cur_limited = cur_borrowed;
    813814                                }
    814                                 cur_updated = (char *) cur_limited;
     815                                cur_updated = cur_limited;
    815816
    816817                                float fres = 0.0;
     
    821822                                switch (length_mod) {
    822823                                case LMOD_NONE:
    823                                         fres = posix_strtof(cur_limited, &cur_updated);
     824                                        fres = strtof(cur_limited, (char **) &cur_updated);
    824825                                        break;
    825826                                case LMOD_l:
    826                                         dres = posix_strtod(cur_limited, &cur_updated);
     827                                        dres = strtod(cur_limited, (char **) &cur_updated);
    827828                                        break;
    828829                                case LMOD_L:
    829                                         ldres = posix_strtold(cur_limited, &cur_updated);
     830                                        ldres = strtold(cur_limited, (char **) &cur_updated);
    830831                                        break;
    831832                                default:
     
    835836                                /* Update the cursor so it can be returned to the provider. */
    836837                                cur_borrowed += cur_updated - cur_limited;
    837                                 if (width != -1 && cur_limited != NULL) {
     838                                if (cur_duplicated != NULL) {
    838839                                        /* Deallocate duplicated part of the cursor view. */
    839                                         free(cur_limited);
     840                                        free(cur_duplicated);
    840841                                }
    841842                                cur_limited = NULL;
     
    11891190 * @return The number of converted output items or EOF on failure.
    11901191 */
    1191 int posix_vfscanf(
     1192int vfscanf(
    11921193    FILE *restrict stream, const char *restrict format, va_list arg)
    11931194{
     
    12091210 * @return The number of converted output items or EOF on failure.
    12101211 */
    1211 int posix_vsscanf(
     1212int vsscanf(
    12121213    const char *restrict s, const char *restrict format, va_list arg)
    12131214{
Note: See TracChangeset for help on using the changeset viewer.