Thanks for your reply and apologies for sending a buggy patch. Yes I agree it's probably slower, but I doubt it has significant impact on the whole runtime. The insignifcant slowdown might be worth it, if you would find
the code much clearer. In any case, I'm attaching an updated version of the patch, where I proved c and c1 are eqvivalent at the end, up to the bound of 5 bytes, so should be fine this time.
From 4911d9676f1914fb4691061887396f2b21a0d036 Mon Sep 17 00:00:00 2001
From: Timotej Kapus <tk1713@ic.ac.uk>
Date: Wed, 24 Oct 2018 23:47:22 +0100
Subject: [PATCH] maint: change 3 loops to strspn calls
* src/ifdef.c: Change 3 loops to equivalent calls to strspn
---
src/ifdef.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/ifdef.c b/src/ifdef.c
index 0ecc2c0..4533e3a 100644
--- a/src/ifdef.c
+++ b/src/ifdef.c
@@ -313,13 +313,13 @@ do_printf_spec (FILE *out, char const *spec,
/* Scan printf-style SPEC of the form %[-'0]*[0-9]*(.[0-9]*)?[cdoxX]. */
/* assert (*f == '%'); */
f++;
- while ((c = *f++) == '-' || c == '\'' || c == '0')
- continue;
- while (ISDIGIT (c))
- c = *f++;
- if (c == '.')
- while (ISDIGIT (c = *f++))
- continue;
+ f += strspn(f, "-\'0") + 1;
+ if(ISDIGIT(c = *(f - 1)))
+ f += strspn(f, "0123456789") + 1;
+ if ((c = *(f - 1)) == '.') {
+ f += strspn(f, "0123456789") + 1;
+ c = *(f - 1);
+ }
c1 = *f++;
switch (c)
--
2.7.4