bebbo / libnix

libnix (v4): a C link library for AmigaOS/m68k
14 stars 9 forks source link

sscanf %n increases the return count #54

Closed BSzili closed 1 year ago

BSzili commented 1 year ago

The %n conversion specifier mistakenly increases the return count for sscanf. I made a small test program that can be built with m68k-amigaos-gcc -noixemul -Wall -o sscanftest sscanftest.c

#include <stdio.h>
int main(void)
{
    char buff[] = {"1234"};
    int intVal, numRead;
    int params = sscanf(buff, "%u%n", &intVal, &numRead);
    printf("intVal %d numRead %d params %d\n", intVal, numRead, params);
    return 0;
}

It should produce the output intVal 1234 numRead 4 params 1, but instead params becomes 2 with libnix.

BSzili commented 1 year ago

ae98273f87d3f2ce750ff397e6518a6847d4c642 fixed it, thanks!