summaryrefslogtreecommitdiff
path: root/dquote_static.c
diff options
context:
space:
mode:
authorAndy Dougherty <doughera@lafayette.edu>2010-09-22 13:44:36 -0400
committerAndy Dougherty <doughera@lafayette.edu>2010-09-22 13:44:36 -0400
commit04e98a4df2ab89550ea2ab5f96ddd3932e2e1ec9 (patch)
tree315e2c2bedf6c6b6bfbb24da4fdb3216631cb018 /dquote_static.c
parent2748c776108ea3c2dab18eeb6a710e819486df17 (diff)
downloadperl-04e98a4df2ab89550ea2ab5f96ddd3932e2e1ec9.tar.gz
Extract regcurly as a static inline function.
This patch extracts regcurly from regcomp.c and converts it to a static inline function in a new file dquote_static.c that is now #included by regcomp.c and toke.c. This change will require 'make regen'.
Diffstat (limited to 'dquote_static.c')
-rw-r--r--dquote_static.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/dquote_static.c b/dquote_static.c
new file mode 100644
index 0000000000..c6d22e2dd0
--- /dev/null
+++ b/dquote_static.c
@@ -0,0 +1,51 @@
+/* dquote_static.c
+ *
+ * This file contains static inline functions that are related to
+ * parsing double-quotish expressions, but are used in more than
+ * one file.
+ *
+ * It is currently #included by regcomp.c and toke.c.
+*/
+
+/*
+ - regcurly - a little FSA that accepts {\d+,?\d*}
+ Pulled from regcomp.c.
+ */
+
+/* embed.pl doesn't yet know how to handle static inline functions, so
+ manually decorate it here with gcc-style attributes.
+*/
+PERL_STATIC_INLINE I32
+regcurly(register const char *s)
+ __attribute__warn_unused_result__
+ __attribute__pure__
+ __attribute__nonnull__(1);
+
+PERL_STATIC_INLINE I32
+regcurly(register const char *s)
+{
+ assert(s);
+
+ if (*s++ != '{')
+ return FALSE;
+ if (!isDIGIT(*s))
+ return FALSE;
+ while (isDIGIT(*s))
+ s++;
+ if (*s == ',')
+ s++;
+ while (isDIGIT(*s))
+ s++;
+ if (*s != '}')
+ return FALSE;
+ return TRUE;
+}
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ *
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */