summaryrefslogtreecommitdiff
path: root/regen/embed.pl
Commit message (Collapse)AuthorAgeFilesLines
* silence -Wformat-nonliteral compiler warningsDavid Mitchell2013-11-281-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the security risks associated with user-supplied formats being passed to C-level printf() style functions (eg %n), gcc has a -Wformat-nonliteral warning that complains whenever such a function is passed a non-literal format string. This commit silences all such warnings in core and ext/. The main changes are 1) the 'f' (format) flag in embed.fnc is now handled slightly more cleverly. Rather than just applying to functions whose last arg is '...' (and where the format arg is assumed to be the previous arg), it can now handle non-'...' functions: arg checking is disabled, but format checking is sill done: it works by assuming that an arg called 'fmt', 'pat' or 'f' is the format string (and dies if fails to find exactly one such arg). 2) with the new embed.fnc functionally, more functions have been marked with the 'f' flag. When such a function passes its fmt arg onto an inner printf-like function, we simply disable the warning for that call using GCC_DIAG_IGNORE(-Wformat-nonliteral), since we know that the caller must have already checked it. 3) In quite a few places the format string isn't literal, but it *is* constant (e.g. PL_warn_uninit_sv). For those cases, again disable the warning. 4) In pp_formline(), a particular format was was one of several different literal strings depending on circumstances. Rather than assigning this string to a temporary variable, incorporate the ?: branches directly in the function call arg. gcc is clever enough to decide the arg is then always literal.
* mark Perl_my_strftime with format attributeDavid Mitchell2013-11-281-2/+7
| | | | | | | | | | | | | | mark this function with __attribute__format__null_ok__(__strftime__,pTHX_1,0) so that compiler checks and warnings about strftime-style format args can be checked. Rather than adding new flag(s) to embed.fnc, I just enhanced the f flag to treat it as strftime-style rather than printf if the function name matches /strftime/. This was quicker, and we're unlikely to have many such functions.
* regen/embed.pl: Extract out duplicate code into a fcnKarl Williamson2013-02-081-20/+13
|
* regen/embed.pl: Warn if have > 1 i, p, and s flagsKarl Williamson2013-02-081-2/+7
| | | | These should be mutually exclusive
* regen/embed.pl: Add sanity test for entriesKarl Williamson2012-12-281-0/+3
| | | | | A void returning function should not be required to have its return value tested.
* Disable PL_sawampersandFather Chrysostomos2012-11-271-0/+6
| | | | | | | | | | | | | | | | | | | PL_sawampersand actually causes bugs (e.g., perl #4289), because the behaviour changes. eval '$&' after a match will produce different results depending on whether $& was seen before the match. Using copy-on-write for the pre-match copy (preceding patches do that) alleviates the slowdown caused by mentioning $&. The copy doesn’t happen unless the string is modified after the match. It’s now a post- match copy. So we no longer need to do things differently depending on whether $& has been seen. PL_sawampersand is now #defined to be equal to what it would be if every program began with $',$&,$`. I left the PL_sawampersand code in place, in case this commit proves immature. Running Configure with -Accflags=PERL_SAWAMPERSAND will reënable the PL_sawampersand mechanism.
* regen/embed.pl: flag 'i' didn't work with 'n'Karl Williamson2012-11-241-1/+1
|
* regen/embed.pl: Fix uninit variable warning.Karl Williamson2012-11-191-1/+1
|
* fix C++ builds broken by cdc4a174060Daniel Dragan2012-10-101-4/+7
| | | | | | | | | | | | | In commit cdc4a174060 static noreturn function, on a C++ build, (specific example, GCC ) got a post preprocessor prototype of "extern "C" static void S_fn_doesnt_return(". GCC generates a compile error if "extern "C"" and static used together. Plain C build were not affected. This commit fixed the problem by creating 2 new static exclusive macros, so extern "C" does not wind up on statics in a C++ build. The macros allow enough flexibility so any compiler/platform that needs a noreturn declaration specifier instead of a noreturn function attribute can have one.
* have embed.pl add PERL_CALLCONV_NO_RET to noreturn staticsDaniel Dragan2012-10-091-0/+3
| | | | | | | | | In commit 12a2785c7e8 PERL_CALLCONV_NO_RET was added to allow MS Visual C's noreturn to work. In that commit, statics did not get a PERL_CALLCONV_NO_RET so Visual C may not always figure out that a certain static is a noreturn. This patch fixes that and allows statics to be Visual C noreturns. I observed a drop in the .text section from 0xBEAAF to 0xBE8CF on no DEBUGGING 32 bit VC 2003 -01 -GL/-LTCG after applying this.
* Fixup indentationJan Dubois2012-07-181-6/+9
|
* Adding support for Visual C's __declspec(noreturn) function declarations to perlDaniel Dragan2012-07-181-2/+5
| | | | | | | | | This will reduce the machine code size on Visual C Perl, by removing C stack clean up opcodes and possible jmp opcodes after croak() and similar functions. Perl's existing __attribute__noreturn__ macro (and therefore GCC's __attribute__((noreturn)) ) is fundamentally incompatible with MS's implementation for noreturn functions. win32.h already has _MSC_VER aware code blocks, so adding more isn't a problem.
* In embed.pl, inline walk_table() into its only caller.Nicholas Clark2011-08-251-27/+6
|
* Eliminate global.sym, as makedef.pl can generate it internally.Nicholas Clark2011-08-251-21/+0
| | | | | | | | global.sym was a file listing the exported symbols, generated by regen/embed.pl from embed.fnc and regen/opcodes, which was only used by makedef.pl Move the code that generates global.sym from regen/embed.pl to makedef.pl, and thereby eliminate the need to ship a 907 line generated file.
* Add regen/embed_lib.pl, for the code that processes embed.fnc and regen/opcodesNicholas Clark2011-08-251-133/+1
| | | | | Move setup_embed() and the helper functions add_level() and current_group() to it from regen/embed.pl
* In embed.pl, move processing embed.fnc and regen/opcodes into a function.Nicholas Clark2011-08-251-86/+91
|
* In embed.pl, refactor the handling of varargs *_nocontext wrappers.Nicholas Clark2011-08-251-12/+17
| | | | This is what commit 125218eb5a6d12e7 should have been. :-)
* In embed.pl, simplify the code that parses regen/opcodes.Nicholas Clark2011-08-251-4/+2
| | | | | As @embed is sorted later, the order that we add entries to it doesn't matter. Hence add them immediately, avoiding the need to iterate over the "seen" hash.
* embed.pl was relying on embed.fnc starting with a pre-processor directive.Nicholas Clark2011-08-251-12/+24
| | | | Fix this subtle bug, and add comments.
* Simplify embedvar.h, removing a level of macro indirection for PL_* variables.Nicholas Clark2011-08-111-48/+15
| | | | | | | For the default (non-multiplicity) configuration, PERLVAR*() macros now directly expand their arguments to tokens such as C<PL_defgv>, instead of expanding to C<PL_Idefgv>. This removes over 350 lines from F<embedvar.h>, which defined macros to map from C<PL_Idefgv> to C<PL_defgv> and so forth.
* In embed.pl, inline hide() and bincompat_var() into their only call point.Nicholas Clark2011-08-071-12/+2
| | | | | | hide() has only been used by bincompat_var() since commit acfe0abcedaf592f in 2001, and bincompat_var() only used in one place at the top level since commit 87b9e16005b9e39b in 2010.
* In embed.pl, refactor readvars() to return a sorted list.Nicholas Clark2011-08-071-18/+15
| | | | | | | | Previously it would assign to the hash reference passed to it. However, the rest of the code only ever used the keys of that hash, in sorted order, so it is simpler to change readvars() to return that list directly. Also move the declaration of the lexical $sym down to its first point of use.
* In embed.pl, remove unused parameter $keep_pre from readvars().Nicholas Clark2011-08-071-3/+2
| | | | | $keep_pre was added by commit c6af7a1aaf1f569e in 1998, and the last user removed by commit 51371543ca1a75ed in 1999.
* Move PL_sh_path to perl.h (except for OS/2), as it's const char[]Nicholas Clark2011-06-121-0/+4
| | | | | | | | On OS/2, keep it in perlvars.h, as it's not const there. makedef.pl doesn't pay attention to C pre-processor symbols, so it will always see the declaration in perlvars.h, and add the symbol to the linker file, so no need to mention sh_path in globvar.sym. Add special case logic in regen/embed.pl to make the embedvar.h macros for PL_sh_path defined only on OS/2.
* Move PL_{No,Yes,hexdigit} from perlvars.h to perl.h, as all are const char[]Nicholas Clark2011-06-121-11/+1
| | | | | | | | | | | They were converted in perl.h from const char[] to #define in 31fb120917c4f65d, then re-instated as const char[], but in perlvars.h, in 3fe35a814d0a98f4. There's no need for compile-time constants to jump through the hoops of perlvars.h, even for Symbian, as the various "EXTCONST" variables already in perl.h demonstrate. These were the only 3 users of the the PERLVARISC macro, so eliminate that, and all related code.
* Rename do_not_edit() to open_print_header(), and move open_new() into it.Nicholas Clark2011-05-191-22/+19
| | | | This removes duplication of open_new() calls.
* Add a 'quote' argument to read_only_top(), to pass in an optional Tolkien.Nicholas Clark2011-05-191-6/+6
| | | | Use this in embed.pl for perlapi.c, and reentr.pl for reentr.c.
* Rename safer_open() to open_new(), and eliminate the first parameter.Nicholas Clark2011-05-191-6/+6
| | | | Update the SHA256s where necessary in the generated files.
* embed.fnc: Add inline function capabilityKarl Williamson2011-01-291-3/+6
| | | | This patch adds to embed.pl the capability to generate static inline functions.
* Change close_and_rename() to read_only_bottom_close_and_rename()Nicholas Clark2011-01-231-18/+9
| | | | | | | | | | All users of close_and_rename() were printing out the appropriate "ex: set ro:" string to the file handle immediately before closing it. So move that into the common function and rename it to reflect what it now does. [Except overload.pl, which should have been, given that it calls read_only_top()] Print a newline above the "ex: set ro:" line. This removes many newlines from the regen scripts, but does add newlines to a couple of generated files.
* In regen/*.pl, refactor the repeated code for close and rename if different.Nicholas Clark2011-01-231-18/+12
| | | | | | | Pass the final file name as an optional second argument of safer_open() and store it with the file handle. Add a function close_and_rename() which closes the file handle, then retrieves the final name, and renames the temporary file if the two differ.
* Move all the generated file header printing into read_only_top()Nicholas Clark2011-01-231-39/+7
| | | | | | | | | Previously all the scripts in regen/ had code to generate header comments (buffer-read-only, "do not edit this file", and optionally regeneration script, regeneration data, copyright years and filename). This change results in some minor reformatting of header blocks, and standardises the copyright line as "Larry Wall and others".
* In embed.pl, move the logic for perlapi.c's Tolkien quote out from do_not_edit()Nicholas Clark2011-01-221-12/+13
| | | | | | Previously do_not_edit() has a special case for this based on the filename parameter. Now the code to add the comment is next to the relevant call to do_not_edit().
* Generate pp_* prototypes in pp_proto.h, and remove pp.symNicholas Clark2011-01-091-28/+9
| | | | | | | | | | | Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13 locations that relied on them. regen/opcode.pl now generates prototypes for the PP functions directly, into pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads this, removing the only ordering dependency in the regen scripts. opcode.pl is now responsible for prototypes for pp_* functions. (embed.pl remains responsible for ck_* functions, reading from regen/opcodes)
* embed.pl can read the names of ck_* functions direct from regen/opcodesNicholas Clark2011-01-091-6/+20
| | | | Previously regen/opcode.pl wrote them to pp.sym for regen/embed.pl to read.
* embed.pl -> regen/embed.plFather Chrysostomos2010-10-131-2/+2
| | | | so newcomers can find it more easily
* Move regen scripts to regen/Steffen Mueller2010-10-101-0/+867
Moves the various scripts that are called by regen.pl to a subdirectory to reduce clutter.