[Bug libgcc/60494] New: A better strtol

olafvdspek at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Mar 10 21:46:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60494

            Bug ID: 60494
           Summary: A better strtol
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olafvdspek at gmail dot com

strtol doesn't support non-null-terminated input, often requiring input to be
copied into a null-terminater string before it can be parsed.
It skips whitespace, which may not be desired.
It stops when a non-number character is read, which may not be desired.
It returns 0 on error, which may not be desired eithers Sometimes one wants to
distinguish between 0 and error.
Could a better strtol (and variants) be provided? Something like 

int strtol2(long* out, const char* s, size_t n, char** endptr, int base);

It should not skip whitespace. 
If endptr is NULL, it should return an error if garbage is read after the
number.



More information about the Gcc-bugs mailing list