diff options
author | Rob Landley <rob@landley.net> | 2016-01-22 21:35:48 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-01-22 21:35:48 -0600 |
commit | cf0f037ac861a3f4fd877e79f3e53877a446f722 (patch) | |
tree | d141c65d6c3563d271e8049f8229114797f9f86e /lib/lib.c | |
parent | 83c6d225795f94840b6acbba0955c65ef0340e7e (diff) | |
download | toybox-cf0f037ac861a3f4fd877e79f3e53877a446f722.tar.gz |
Factor out insanitize() from seq.c to next_printf() in lib.
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1015,3 +1015,21 @@ char *show_uuid(char *uuid) return libbuf; } + +// Returns pointer to letter at end, 0 if none. *start = initial % +char *next_printf(char *s, char **start) +{ + for (; *s; s++) { + if (*s != '%') continue; + if (*++s == '%') continue; + if (start) *start = s-1; + while (0 <= stridx("0'#-+ ", *s)) s++; + while (isdigit(*s)) s++; + if (*s == '.') s++; + while (isdigit(*s)) s++; + + return s; + } + + return 0; +} |