summaryrefslogtreecommitdiff
path: root/handy.h
Commit message (Collapse)AuthorAgeFilesLines
* Assume we have sane C89 memcmp()Aaron Crane2017-10-211-7/+2
| | | | | | | "Sane" means that it works correctly on bytes with their high bit set, as C89 also requires. We therefore no longer need to probe for and/or use BSD bcmp().
* Assume we have C89 memset()Aaron Crane2017-10-211-5/+0
| | | | This means we also never need to consider using BSD bzero().
* Remove USE_STRUCT_COPY in favour of C89 struct assignmentAaron Crane2017-10-211-4/+0
| | | | | At least for now, we retain the StructCopy() macro, but its definition always just uses struct assignment.
* avoid 'the address of ... will always evaluate as ...' warns in mem macrosYves Orton2017-09-131-7/+10
| | | | | | | | | | | | | In f14cf363205 we added asserts to our memory macros (Copy(), Zero() etc) to ensure that the target is non-null. These asserts throw warnings like perl.c: In function ‘Perl_eval_sv’: perl.c:2976:264: warning: the address of ‘myop’ will always evaluate as ‘true’ [-Waddress] Zero(&myop, 1, UNOP); which is annoying. This patch changes how these asserts are coded so we avoid the warning. Thanks to Zefram for the fix.
* handy.h: White space onlyKarl Williamson2017-09-091-4/+4
| | | | ALign some things vertically for easier reading
* (perl #131746) avoid undefined behaviour in Copy() etcTony Cook2017-09-041-7/+7
| | | | | | | | | | | | | | | | | These functions depend on C library functions which have undefined behaviour when passed NULL pointers, even when passed a zero 'n' value. Some compilers use this information, ie. assume the pointers are non-NULL when optimizing any following code, so we do need to prevent such unguarded calls. My initial thought was to add conditionals to each macro to skip the call to the library function when n is zero, but this adds a cost to every use of these macros, even when the n value is always true. So instead I added asserts() which will give us a much more visible indicator of such broken code and revealed the pp_caller and Glob.xs issues also patched here.
* Use new paradigm for hdr file double inclusion guardKarl Williamson2017-06-021-3/+3
| | | | | | | | | | 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.
* handy.h: Guard controversial macro nameKarl Williamson2017-02-191-0/+5
| | | | | This is so their use cannot spread easily until we have sorted things out in 5.27
* There's an objection to fatalizing jumping into a construct.Abigail2017-01-161-0/+2
| | | | | | | | This reverts commit 84b32f52b10f9912b40ef378cd0b01f4aff80630. This reverts commit d30393aaade31b605724846a30a10dd1e96cd181. We need more debate on this one; either we should undeprecate it, or settle on an end-of-life version.
* Remove the deprecate() macro from handy.h.Abigail2017-01-161-2/+0
| | | | | | | Since we now require each deprecation message to come with a version in which the feature will disappear, and we have reworked the existing uses of this macro, there doesn't seem to be a need for this one anymore.
* Setting ${^ENCODE} will be fatal by 5.28.Abigail2017-01-161-0/+3
| | | | | Hence, we adapted the warning, to mention the version in which it will become a fatal error.
* Time limit the deprecation of :unique and :locked.Abigail2017-01-161-0/+3
| | | | | | | | | | | | | | | | The :unique and :locked attributes have had no effect since 5.8.8 and 5.005 respectively. They were deprecated in 5.12. They are now scheduled to be deleted in 5.28. There are two places the deprecation warning can be issued: in lib/attributes.pm, and in toke.c. The warnings were phrased differently, but since we're changing the warning anyway (as we added the version of Perl in which the attributes will disappear), we've used the same phrasing for this warning, regardless of where it is generated: Attribute "locked" is deprecated, and will disappear in Perl 5.28 Attribute "unique" is deprecated, and will disappear in Perl 5.28
* handy.h: Add missing right paren in macroKarl Williamson2016-12-291-1/+1
| | | | This only affected EBCDIC builds, causing syntax errors.
* Fix tiny POD typoAaron Crane2016-12-291-1/+1
|
* Deprecate toFOO_utf8()Karl Williamson2016-12-231-8/+36
| | | | Now that there are _safe versions, deprecate the unsafe ones.
* Convert core to use toFOO_utf8_safe()Karl Williamson2016-12-231-9/+9
|
* Add toFOO_utf8_safe() macrosKarl Williamson2016-12-231-16/+66
|
* For character case changing, create macros and useKarl Williamson2016-12-231-0/+6
| | | | | This creates several macros that future commits will use to provide a layer between the caller and the function.
* perlapi: Italicize some C<text> that isn't as-isKarl Williamson2016-12-231-18/+18
| | | | | This text appears in the middle of C<>, but is meant to be substituted for, instead of being typed in as-is.
* handy.h: White-space, comment onlyKarl Williamson2016-12-231-7/+10
|
* Deprecate isFOO_utf8() macrosKarl Williamson2016-12-231-83/+68
| | | | | | These macros are being replaced by a safe version; they now generate a deprecation message at each call site upon the first use there in each program run.
* Add isFOO_utf8_safe() macrosKarl Williamson2016-12-231-54/+237
| | | | | | | | | | | | | | | | The original API does not check that we aren't reading beyond the end of a buffer, apparently assuming that we could keep malformed UTF-8 out by use of gatekeepers, but that is currently impossible. This commit adds "safe" macros for determining if a UTF-8 sequence represents an alphabetic, a digit, etc. Each new macro has an extra parameter pointing to the end of the sequence, so that looking beyond the input string can be avoided. The macros aren't currently completely safe, as they don't test that there is at least a single valid byte in the input, except by an assertion in DEBUGGING builds. This is because typically they are called in code that makes that assumption, and frequently tests the current byte for one thing or another.
* perlapi: Add explanation for why certain macros don't exist.Karl Williamson2016-12-191-8/+26
| | | | This also fixes some orphaned references.
* perlapi: Clarify the isFOO_A() macros meaningsKarl Williamson2016-12-141-1/+2
|
* handy.h, hv.h: fixup hash s suffix macro definitions, move to hv.hYves Orton2016-10-191-8/+1
| | | | | | | | | | | | | For some reason s suffix macro definitions intended for handling constant string arguments were put into handy.h and not into hv.h. I think this is wrong, especially as the macro defintions have "drifted" and are not properly defined in terms the right base macros. Also we want to have such wrappers for the main hash functions, so move them all to hv.h, recode them properly in terms of the right base macros, and add support for the missing functions.
* handy.h: add _memEQs() and _memNEs() for use with constant stringsYves Orton2016-10-191-1/+7
| | | | | | | | | | | | memEQs() is already defined, and requires a length parameter for the first pointer argument. However some times we do not have this length handy and simply want to use the length of the constant string instead. In an ideal world, to be compatible with more s suffix macros, IMO the existing memEQs() should have been called something like memEQsl() maybe, and the ones I am adding would get the memEQs( name, but it didnt work out like that.
* handy.h: add strEQs() and strNEs() for comparing to constant stringsYves Orton2016-10-191-0/+5
| | | | | They use strncmp() and derive the length using STR_WITH_LEN style tricks in the wrapper call.
* Centralize definitions of MIN, MAXKarl Williamson2016-09-251-0/+9
| | | | | Instead of having each file have them, keep them in handy.h, but only for core compilations.
* handy.h: Comment memEQs and memNEsKarl Williamson2016-09-171-0/+1
|
* handy.h: Add memLT, memLE, memGT, memGEKarl Williamson2016-09-171-0/+5
| | | | | These correspond to strLT, etc. I am deferring documenting them in case this turns out to be a bad idea for some reason.
* handy.h: Clarify commentKarl Williamson2016-08-051-1/+1
|
* Improve isOCTAL() definitionKarl Williamson2016-08-051-4/+4
| | | | This potentially saves a branch
* Fix comment typos principal → principleDagfinn Ilmari Mannsåker2016-07-311-1/+1
| | | | | The ones in cpan/File-Temp/ have been submitted upstream as https://github.com/Perl-Toolchain-Gang/File-Temp/pull/20
* handy.h: Add missing parens in macroKarl Williamson2016-07-291-1/+1
| | | | | These should have been in the recent commit 6c5b02ac7a9ff1c91f2ca46bedd89ba9012bb34f
* handy.h: Consolidate some EBCDIC vs ASCII pathsKarl Williamson2016-07-281-65/+58
| | | | | | | This removes some '#ifdef EBCDIC' so as to make more code common between the platforms. This is at the expense of some efficiency, but the affected code only runs when compiling utilities, so ease of maintenance wins out.
* handy.h: Add commentKarl Williamson2016-07-281-1/+10
|
* handy.h: Generate compile error if macros called wrongKarl Williamson2016-07-281-1/+4
| | | | | | | | | This extends the mechanism we added in 5.24 to more macros to make sure that a macro is called with an integer and not a pointer. It adds a "| 0" to the macro parameter, which is illegal if the parameter is a pointer.
* handy.h: remove deprecated L<"section"> syntaxLukas Mai2016-06-111-6/+6
|
* Get -Accflags=-DPERL_MEM_LOG compiling againMatthew Horsfall2016-04-051-6/+0
| | | | | | | | It had rotted a bit Well, more than one probably. Move the declarations of the functions Perl_mem_log_alloc etc from handy.h into embed.fnc where whey belong, and where Malloc_t will have already been defined.
* handy.h: Add synonyms for macrosKarl Williamson2016-03-171-68/+97
| | | | | | | | | | | | | | I realized that we have inconsistent naming conventions for the isFOO_uni() macros, like isALPHA_uni(). The "_uni" suffix elsewhere refers to official Unicode code point numbers; whereas, for these macros it refers to the native code point numbers for code points below 256. And elsewhere, there are in some cases a _uni() and a uvchr() which mean different things. This commit adds '_uvchr' suffix equivalents for these macros, while dropping mention in the documentation of the '_uni' forms. Thus code following the new paradigm will not be confusing, while existing code will function unchanged.
* Simplify _MEM_WRAP_NEEDS_RUNTIME_CHECK()David Mitchell2016-03-041-2/+1
| | | | | And at the same time hopefully avoid some false-positive compiler warnings on HP-UX
* perlapi: Clarify that a literal string must end in a NULKarl Williamson2016-02-031-18/+23
| | | | Some entries already had this. For those, it standardizes the text.
* ensure isASCII argument is an integerLukas Mai2016-01-311-2/+3
| | | | This catches bugs such as the one fixed in commit dcf88e34.
* perlapi: Clarify 'string' vs. bufferKarl Williamson2015-12-221-22/+23
| | | | A string strictly is NUL terminated, but our terminology is lax
* Make FITS_IN_8_BITS() always true under CoverityJarkko Hietaniemi2015-10-231-0/+8
| | | | | | | | Similar in spirit to 3e94db23 Coverity id #28938 Coverity id #104778 Coverity id #131329
* Make __ASSERT__() empty under Coverity, avoiding many false alerts.Jarkko Hietaniemi2015-10-191-2/+7
| | | | (As suggested by khw.)
* fix some 32/64-bit compiler warningsDavid Mitchell2015-10-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | Some bits of code don't do well on a 32-bit system with 64-bit ints (-Duse64bitint) In particular: _MEM_WRAP_NEEDS_RUNTIME_CHECK: if sizeof(MEM_SIZE) > sizeof(n), then the shift count could be negative S_regmatch: ln and n were two different sizes and signesses, so comparing them warned. Since they were being mis-used as two convenient temporary booleans anyway, just use temporary booleans instead. Perl_sv_vcatpvfn_flags: the test/assertion (IV)elen < 0 was (I think) being used to test for signed/unsigned conversion wrap-around. elen is of type STRLEN which is a pointer-based type, so can be 32-bit while IV is 64-bit. Instead compare it to half the maximum value of a STRLEN var to see if it may have wrapped.
* Change EBCDIC macro definitionKarl Williamson2015-09-041-4/+5
| | | | | | This changes the definition of isUTF8_POSSIBLY_PROBLEMATIC() on EBCDIC platforms to use PL_charclass[] instead of PL_e2a[]. The new array is more likely to be in the memory cache.
* l1_char_class_tab.h: Add bits for UTF-EBCDICKarl Williamson2015-09-041-2/+10
| | | | This is for the next commit.
* Add macro for converting Latin1 to UTF-8, and use itKarl Williamson2015-09-041-2/+2
| | | | | | | | | This adds a macro that converts a code point in the ASCII 128-255 range to UTF-8, and changes existing code to use it when the range is known to be restricted to this one, rather than the previous macro which accepted a wider range (any code point representable by 2 bytes), but had an extra test on EBCDIC platforms, hence was larger than necessary and slightly slower.