On 19/01/2022 02.42, Simon Glass wrote: > At present this has a minor bug in that it reads the byte before the > start of the string.
Only for an empty string, AFAICS. Which is a bug, of course, but mostly the caller is to blame. Also it doesn't handle a non-numeric prefix which is > only one character long. > > Fix these bugs with a reworked implementation. How does your new implementation handle the case of no prefix at all, i.e. "456"? Shouldn't that also work? Or a single-digit "7"? Both the old and new seem to have a bug in that the end parameter is essentially ignored. If I have const char *s = "abc123"; and do trailing_strtoln(s, s+5); I'd expect 12. Rasmus