Skip to content

request: sprintf() comma compatibility #71

@simonhf

Description

@simonhf
#include <stdio.h>

// gcc           -O0 -o mpaland mpaland.c && ./mpaland
// gcc -DMPALAND -O0 -o mpaland mpaland.c && ./mpaland

#ifdef MPALAND
void _putchar(char character)
{
    putchar(character);
}

#include "printf/printf.c"
#endif

void main(void) {
    printf("- main() starting\n");
    printf("- value with comma: %'d\n", 1234);
    printf("- main() ending\n");
}

Run without mpaland printf:

$ gcc           -O0 -o mpaland mpaland.c && ./mpaland
- main() starting
- value with comma: 1234
- main() ending

Run with mpaland printf:

$ gcc -DMPALAND -O0 -o mpaland mpaland.c && ./mpaland
- main() starting
- value with comma: 'd
- main() ending

It would be great if mpaland / printf could be compatible with the sprintf() format comma syntax, even if commas are not printed due to the locale (as with the above example via glibc). It would be even better if mpaland / printf implemented comma output too, although obviously not by manipulating the locale...

[1] https://stackoverflow.com/questions/1449805/how-to-format-a-number-from-1123456789-to-1-123-456-789-in-c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions