This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl.h: Don't pollute global namespace
authorKarl Williamson <public@khwilliamson.com>
Thu, 15 Aug 2013 16:36:29 +0000 (10:36 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 24 Sep 2013 17:36:15 +0000 (11:36 -0600)
These structures are used internally in the regular expression files,
and are declared here only because of #include ordering issues.  Wrap
them in an #ifdef so only visible to the correct files.

perl.h

diff --git a/perl.h b/perl.h
index bb196e6..d9f7f17 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3272,8 +3272,13 @@ struct _sublex_info {
 
 typedef struct magic_state MGS;        /* struct magic_state defined in mg.c */
 
 
 typedef struct magic_state MGS;        /* struct magic_state defined in mg.c */
 
-struct scan_data_t;            /* Used in S_* functions in regcomp.c */
-struct regnode_charclass_class;        /* Used in S_* functions in regcomp.c */
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C)
+
+/* These have to be predeclared, as they are used in proto.h which is #included
+ * before their definitions in regcomp.h. */
+
+struct scan_data_t;
+struct regnode_charclass_class;
 
 /* A hopefully less confusing name.  The sub-classes are all Posix classes only
  * used under /l matching */
 
 /* A hopefully less confusing name.  The sub-classes are all Posix classes only
  * used under /l matching */
@@ -3283,6 +3288,8 @@ typedef struct regnode_ssc regnode_ssc;
 typedef struct RExC_state_t RExC_state_t;
 struct _reg_trie_data;
 
 typedef struct RExC_state_t RExC_state_t;
 struct _reg_trie_data;
 
+#endif
+
 struct ptr_tbl_ent {
     struct ptr_tbl_ent*                next;
     const void*                        oldval;
 struct ptr_tbl_ent {
     struct ptr_tbl_ent*                next;
     const void*                        oldval;