From cf0f037ac861a3f4fd877e79f3e53877a446f722 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 22 Jan 2016 21:35:48 -0600 Subject: Factor out insanitize() from seq.c to next_printf() in lib. --- lib/lib.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index b0ac4715..6559030c 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -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; +} -- cgit v1.2.3