This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract regcurly as a static inline function.
authorAndy Dougherty <doughera@lafayette.edu>
Wed, 22 Sep 2010 17:44:36 +0000 (13:44 -0400)
committerAndy Dougherty <doughera@lafayette.edu>
Wed, 22 Sep 2010 17:44:36 +0000 (13:44 -0400)
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'.

MANIFEST
dquote_static.c [new file with mode: 0644]
embed.fnc
regcomp.c
toke.c

index 3e9583a..4a5abf9 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2997,6 +2997,7 @@ djgpp/fixpmain            DOS/DJGPP port
 doio.c                 I/O operations
 doop.c                 Support code for various operations
 dosish.h               Some defines for MS/DOSish machines
+dquote_static.c                Static functions for double quotish contexts
 dump.c                 Debugging output
 embed.fnc              Database used by embed.pl
 embed.h                        Maps symbols to safer names
diff --git a/dquote_static.c b/dquote_static.c
new file mode 100644 (file)
index 0000000..c6d22e2
--- /dev/null
@@ -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:
+ */
index ebe3d7c..619a0be 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -169,7 +169,6 @@ npR |MEM_SIZE|malloc_good_size      |size_t nbytes
 
 AnpR   |void*  |get_context
 Anp    |void   |set_context    |NN void *t
-EXpRnPM        |I32    |regcurly       |NN const char *s
 
 END_EXTERN_C
 
index 2871e4a..de95789 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -85,6 +85,8 @@
 #  include "regcomp.h"
 #endif
 
+#include "dquote_static.c"
+
 #ifdef op
 #undef op
 #endif /* op */
@@ -9006,31 +9008,6 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode *p, const regnode *val,
 #endif
 
 /*
- - regcurly - a little FSA that accepts {\d+,?\d*}
- */
-#ifndef PERL_IN_XSUB_RE
-I32
-Perl_regcurly(register const char *s)
-{
-    PERL_ARGS_ASSERT_REGCURLY;
-
-    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;
-}
-#endif
-
-/*
  - regdump - dump a regexp onto Perl_debug_log in vaguely comprehensible form
  */
 #ifdef DEBUGGING
diff --git a/toke.c b/toke.c
index c4ff0c2..961866b 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -39,6 +39,7 @@ Individual members of C<PL_parser> have their own documentation.
 #include "EXTERN.h"
 #define PERL_IN_TOKE_C
 #include "perl.h"
+#include "dquote_static.c"
 
 #define new_constant(a,b,c,d,e,f,g)    \
        S_new_constant(aTHX_ a,b,STR_WITH_LEN(c),d,e,f, g)