Skip to content

Commit

Permalink
Use new paradigm for hdr file double inclusion guard
Browse files Browse the repository at this point in the history
We changed to use symbols not likely to be used by non-Perl code that
could conflict, and which have trailing underbars, so they don't look
like a regular Perl #define.

See https://rt.perl.org/Ticket/Display.html?id=131110

There are many more header files which are not guarded.
  • Loading branch information
khwilliamson committed Jun 2, 2017
1 parent b063b0a commit 6a5bc5a
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions XSUB.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
*/

#ifndef _INC_PERL_XSUB_H
#define _INC_PERL_XSUB_H 1
#ifndef PERL_XSUB_H_
#define PERL_XSUB_H_ 1

/* first, some documentation for xsubpp-generated items */

Expand Down Expand Up @@ -703,7 +703,7 @@ Rethrows a previously caught exception. See L<perlguts/"Exception Handling">.
# endif /* NO_XSLOCKS */
#endif /* PERL_IMPLICIT_SYS && !PERL_CORE */

#endif /* _INC_PERL_XSUB_H */ /* include guard */
#endif /* PERL_XSUB_H_ */ /* include guard */

/*
* ex: set ts=8 sts=4 sw=4 et:
Expand Down
6 changes: 3 additions & 3 deletions dquote_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* License or the Artistic License, as specified in the README file.
*/

#ifndef DQUOTE_INLINE_H /* Guard against nested #inclusion */
#define DQUOTE_INLINE_H
#ifndef PERL_DQUOTE_INLINE_H_ /* Guard against nested #inclusion */
#define PERL_DQUOTE_INLINE_H_

/*
- regcurly - a little FSA that accepts {\d+,?\d*}
Expand Down Expand Up @@ -64,4 +64,4 @@ S_form_short_octal_warning(pTHX_
(int) (s - sans_leading_zeros), sans_leading_zeros,
*s);
}
#endif /* DQUOTE_INLINE_H */
#endif /* PERL_DQUOTE_INLINE_H_ */
6 changes: 3 additions & 3 deletions ebcdic_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/


#ifndef H_EBCDIC_TABLES /* Guard against nested #includes */
#define H_EBCDIC_TABLES 1
#ifndef PERL_EBCDIC_TABLES_H_ /* Guard against nested #includes */
#define PERL_EBCDIC_TABLES_H_ 1

/* This file contains definitions for various tables used in EBCDIC handling.
* More info is in utfebcdic.h */
Expand Down Expand Up @@ -437,6 +437,6 @@ EXTCONST U8 PL_fold_latin1[] = {

#endif /* EBCDIC 037 */

#endif /* H_EBCDIC_TABLES */
#endif /* PERL_EBCDIC_TABLES_H_ */

/* ex: set ro: */
6 changes: 3 additions & 3 deletions handy.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
/* IMPORTANT NOTE: Everything whose name begins with an underscore is for
* internal core Perl use only. */

#ifndef HANDY_H /* Guard against nested #inclusion */
#define HANDY_H
#ifndef PERL_HANDY_H_ /* Guard against nested #inclusion */
#define PERL_HANDY_H_

#if !defined(__STDC__)
#ifdef NULL
Expand Down Expand Up @@ -2521,7 +2521,7 @@ void Perl_mem_log_del_sv(const SV *sv, const char *filename, const int linenumbe

#endif

#endif /* HANDY_H */
#endif /* PERL_HANDY_H_ */

/*
* ex: set ts=8 sts=4 sw=4 et:
Expand Down
4 changes: 2 additions & 2 deletions malloc_ctl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MALLOC_CTL_H
# define MALLOC_CTL_H
#ifndef PERL_MALLOC_CTL_H_
# define PERL_MALLOC_CTL_H_

struct perl_mstats {
UV *nfree;
Expand Down
6 changes: 3 additions & 3 deletions perlio.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*
*/

#ifndef _PERLIO_H
#define _PERLIO_H
#ifndef PERLIO_H_
#define PERLIO_H_
/*
Interface for perl to IO functions.
There is a hierarchy of Configure determined #define controls:
Expand Down Expand Up @@ -336,7 +336,7 @@ typedef struct PerlIO_list_s PerlIO_list_t;
#endif

END_EXTERN_C
#endif /* _PERLIO_H */
#endif /* PERLIO_H_ */

/*
* ex: set ts=8 sts=4 sw=4 et:
Expand Down
6 changes: 3 additions & 3 deletions perliol.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _PERLIOL_H
#define _PERLIOL_H
#ifndef PERLIOL_H_
#define PERLIOL_H_

typedef struct {
PerlIO_funcs *funcs;
Expand Down Expand Up @@ -286,7 +286,7 @@ PERL_CALLCONV SSize_t PerlIOUnix_write(pTHX_ PerlIO *f, const void *vbuf, Size
/* Utf8 */
PERL_CALLCONV IV PerlIOUtf8_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);

#endif /* _PERLIOL_H */
#endif /* PERLIOL_H_ */

/*
* ex: set ts=8 sts=4 sw=4 et:
Expand Down
4 changes: 2 additions & 2 deletions reentr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* Any changes made here will be lost!
*/

#ifndef REENTR_H
#define REENTR_H
#ifndef PERL_REENTR_H_
#define PERL_REENTR_H_

/* If compiling for a threaded perl, we will macro-wrap the system/library
* interfaces (e.g. getpwent()) which have threaded versions
Expand Down
8 changes: 4 additions & 4 deletions regcharclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/


#ifndef H_REGCHARCLASS /* Guard against nested #includes */
#define H_REGCHARCLASS 1
#ifndef PERL_REGCHARCLASS_H_ /* Guard against nested #includes */
#define PERL_REGCHARCLASS_H_

#if 'A' == 65 /* ASCII/Latin1 */
/*
Expand Down Expand Up @@ -1851,7 +1851,7 @@

#endif /* EBCDIC 037 */

#endif /* H_REGCHARCLASS */
#endif /* PERL_REGCHARCLASS_H_ */

/* Generated from:
* 59e717586b720a821ee0d7397679d5322e38b49f6fb7840545aedf669c733b70 lib/Unicode/UCD.pm
Expand Down Expand Up @@ -1900,6 +1900,6 @@
* 717985d5fe0830f5b72ca21287a7d9f15ba6a383c29fbd3c47231d5f63edb68b lib/unicore/mktables
* cdecb300baad839a6f62791229f551a4fa33f3cbdca08e378dc976466354e778 lib/unicore/version
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
* c468aea5062ef84422219d74e83b6f3216f2823544b445f53ee1af71deeb2044 regen/regcharclass.pl
* 9ea6338945a7d70e5ea4b31ac7856c0b521df96be002e94b4b3b7d31debbf3ab regen/regcharclass.pl
* 393f8d882713a3ba227351ad0f00ea4839fda74fcf77dcd1cdf31519925adba5 regen/regcharclass_multi_char_folds.pl
* ex: set ro: */
6 changes: 3 additions & 3 deletions regen/ebcdic.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ ($$;$)

print $out_fh <<END;
#ifndef H_EBCDIC_TABLES /* Guard against nested #includes */
#define H_EBCDIC_TABLES 1
#ifndef PERL_EBCDIC_TABLES_H_ /* Guard against nested #includes */
#define PERL_EBCDIC_TABLES_H_ 1
/* This file contains definitions for various tables used in EBCDIC handling.
* More info is in utfebcdic.h */
Expand Down Expand Up @@ -222,6 +222,6 @@ END
print $out_fh get_conditional_compile_line_end();
}

print $out_fh "\n#endif /* H_EBCDIC_TABLES */\n";
print $out_fh "\n#endif /* PERL_EBCDIC_TABLES_H_ */\n";

read_only_bottom_close_and_rename($out_fh);
4 changes: 2 additions & 2 deletions regen/reentr.pl
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ sub open_print_header {

my $h = open_print_header('reentr.h');
print $h <<EOF;
#ifndef REENTR_H
#define REENTR_H
#ifndef PERL_REENTR_H_
#define PERL_REENTR_H_
/* If compiling for a threaded perl, we will macro-wrap the system/library
* interfaces (e.g. getpwent()) which have threaded versions
Expand Down
4 changes: 2 additions & 2 deletions regen/regcharclass.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ sub make_macro {
changed or removed without notice.
EOF
);
print $out_fh "\n#ifndef H_REGCHARCLASS /* Guard against nested #includes */\n#define H_REGCHARCLASS 1\n";
print $out_fh "\n#ifndef PERL_REGCHARCLASS_H_ /* Guard against nested #includes */\n#define PERL_REGCHARCLASS_H_\n";

my ( $op, $title, @txt, @types, %mods );
my $doit= sub ($) {
Expand Down Expand Up @@ -1452,7 +1452,7 @@ sub make_macro {
print $out_fh get_conditional_compile_line_end();
}

print $out_fh "\n#endif /* H_REGCHARCLASS */\n";
print $out_fh "\n#endif /* PERL_REGCHARCLASS_H_ */\n";

if($path eq '-') {
print $out_fh "/* ex: set ro: */\n";
Expand Down
6 changes: 3 additions & 3 deletions regen/unicode_constants.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

print $out_fh <<END;
#ifndef H_UNICODE_CONSTANTS /* Guard against nested #includes */
#define H_UNICODE_CONSTANTS 1
#ifndef PERL_UNICODE_CONSTANTS_H_ /* Guard against nested #includes */
#define PERL_UNICODE_CONSTANTS_H_ 1
/* This file contains #defines for the version of Unicode being used and
* various Unicode code points. The values the code point macros expand to
Expand Down Expand Up @@ -198,7 +198,7 @@ END
}
}

print $out_fh "\n#endif /* H_UNICODE_CONSTANTS */\n";
print $out_fh "\n#endif /* PERL_UNICODE_CONSTANTS_H_ */\n";

read_only_bottom_close_and_rename($out_fh);

Expand Down
4 changes: 2 additions & 2 deletions time64.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <time.h>
#include "time64_config.h"

#ifndef TIME64_H
# define TIME64_H
#ifndef PERL_TIME64_H_
# define PERL_TIME64_H_


/* Set our custom types */
Expand Down
6 changes: 3 additions & 3 deletions time64_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef TIME64_CONFIG_H
# define TIME64_CONFIG_H
#ifndef PERL_TIME64_CONFIG_H_
# define PERL_TIME64_CONFIG_H_

/* Configuration
-------------
Expand Down Expand Up @@ -82,4 +82,4 @@
#define SYSTEM_GMTIME_MAX CAT2(GMTIME_MAX,.0)
#define SYSTEM_GMTIME_MIN CAT2(GMTIME_MIN,.0)

#endif /* TIME64_CONFIG_H */
#endif /* PERL_TIME64_CONFIG_H_ */
6 changes: 3 additions & 3 deletions unicode_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/


#ifndef H_UNICODE_CONSTANTS /* Guard against nested #includes */
#define H_UNICODE_CONSTANTS 1
#ifndef PERL_UNICODE_CONSTANTS_H_ /* Guard against nested #includes */
#define PERL_UNICODE_CONSTANTS_H_ 1

/* This file contains #defines for the version of Unicode being used and
* various Unicode code points. The values the code point macros expand to
Expand Down Expand Up @@ -182,6 +182,6 @@ bytes.
/* The highest code point that has any type of case change */
#define HIGHEST_CASE_CHANGING_CP_FOR_USE_ONLY_BY_UTF8_DOT_C 0x1E943

#endif /* H_UNICODE_CONSTANTS */
#endif /* PERL_UNICODE_CONSTANTS_H_ */

/* ex: set ro: */
6 changes: 3 additions & 3 deletions utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*
*/

#ifndef H_UTF8 /* Guard against recursive inclusion */
#define H_UTF8 1
#ifndef PERL_UTF8_H_ /* Guard against recursive inclusion */
#define PERL_UTF8_H_ 1

/* Use UTF-8 as the default script encoding?
* Turning this on will break scripts having non-UTF-8 binary
Expand Down Expand Up @@ -1169,7 +1169,7 @@ L</is_utf8_string_loclen_flags> to check entire strings.
* retained solely for backwards compatibility */
#define IS_UTF8_CHAR(p, n) (isUTF8_CHAR(p, (p) + (n)) == n)

#endif /* H_UTF8 */
#endif /* PERL_UTF8_H_ */

/*
* ex: set ts=8 sts=4 sw=4 et:
Expand Down

0 comments on commit 6a5bc5a

Please sign in to comment.