phoenix-rtos / phoenix-rtos-project

Sample project using Phoenix-RTOS
https://phoenix-rtos.com
BSD 3-Clause "New" or "Revised" License
45 stars 32 forks source link

Fscanf /vfscanf problem with setting file position indicator #639

Closed maska989 closed 1 year ago

maska989 commented 1 year ago
#include <stdio.h>
int main(void)
{
    char c[1];
    FILE *rd;

    rd = fopen("test", "w+");

    fputs("abc", rd);

    fseek(rd, 0, SEEK_SET);
    printf("\nposi before = %ld\n", ftell(rd));

    fscanf(rd, "%c", c);
    printf("\nposi after = %ld\n", ftell(rd));

    fclose(rd);
}
gerard5 commented 1 year ago

@maska989 I added a fix, please verify if it works in your test cases.

maska989 commented 1 year ago

@gerard5 Works like a charm.

maska989 commented 1 year ago

https://github.com/phoenix-rtos/phoenix-rtos-tests/blob/c13ef424dff7c1f0f88f02e4a67104f6d9ed5d22/libc/stdio_scanf.c#L3330-L3333