improve-strspn-for-bsd_indent.patch
text/x-patch
Filename: improve-strspn-for-bsd_indent.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/tools/pg_bsd_indent/lexi.c | 20 | 0 |
diff --git a/src/tools/pg_bsd_indent/lexi.c b/src/tools/pg_bsd_indent/lexi.c
index 943bf7ce6b..1af8167493 100644
--- a/src/tools/pg_bsd_indent/lexi.c
+++ b/src/tools/pg_bsd_indent/lexi.c
@@ -212,6 +212,26 @@ is_func_definition(char *tp)
return false;
}
+static size_t
+strspn_n(const char *s1, const char *s2)
+{
+ const char *p = s1, *spanp;
+ char c, sc;
+ /*
+ * Skip any characters in s2, excluding the terminating \0 and \n.
+ */
+cont:
+ c = *p++;
+ for (spanp = s2; (sc = *spanp++) != 0;)
+ if (sc == c)
+ goto cont;
+ else if (sc == '\n')
+ break;
+ return (p - 1 - s1);
+}
+
+#define strspn(s1, s2) strspn_n(s1, s2)
+
int
lexi(struct parser_state *state)
{