summaryrefslogtreecommitdiff
path: root/handy.h
Commit message (Collapse)AuthorAgeFilesLines
* Evaluate arg to FITS_IN_8_BITS just onceKarl Williamson2021-09-071-4/+4
| | | | | | | | | | | | | | | This had been changed by 9555181b32f9b30122a8ea4e779c2c9916cec9f8 to evaluating multiple times. (sizeof() also is called with the parameter, but that doesn't actually evaluate the parameter.) The previous version of this commit used a comparison with 0xFF, but gcc is smart enough to realise that `comparison is always true due to limited range of data type`, but not smart enough to realise that the sizeof makes that code unreachable. Hence with -Wtype-limits we get thousands of warnings. Using >> defeats the warnings.
* handy.h: Skip non-ptr assertion on old gcc'sKarl Williamson2021-08-251-4/+11
| | | | See https://github.com/Perl/perl5/issues/18655, which this fixes.
* Make paradigm into a macroKarl Williamson2021-08-251-7/+9
| | | | | | | | | | | | | | | | | | | | These macros use (x) | 0 to get a compiler error if x is a pointer rather than a value. This was instituted because there was confusion in them as to what they were called with. But the purpose of the paradigm wasn't obvious to even some experts; it was documented in every file in which it was used, but not at every occurrence. And, not every compiler can cope with them, it turns out. Making the paradigm into a macro, which this commit does, makes the uses self-documenting, albeit at the expense of cluttering up the macro definition somewhat; and allows the mechanism to be turned off if necessary for some compilers. Since it will be enabled for the majority of compilers, the potential bugs will be caught anyway.
* handy.h: Fix internal macroKarl Williamson2021-08-071-1/+1
| | | | | | | | | | I found this reading code. The macro is supposed to check for something not being in the ASCII range, but instead checked that the input is invariant under UTF-8. These concepts evaluate to the same thing on ASCII platforms, but differently on EBCDIC ones. The calls to this macro are such that there isn't a bug that surfaces here, but the code generated is slightly different, and it should be fixed to prevent any future issues.
* Remove EBCDIC-only codeKarl Williamson2021-08-071-4/+1
| | | | The previous commit stopped using this code, so can just get rid of it.
* handy.h: Refactor FITS_IN_8_BITS()Karl Williamson2021-07-301-3/+3
| | | | | By using a cast to U8, the '&' operation can be elminated, and the macro easier to read.
* perlapi: Consolidate and revise pod for toCASE_CHANGEfoo()Karl Williamson2021-07-171-111/+151
| | | | | | This finishes the work started by 3cb048e540f681a46e641b466030b55feaf5d337 for toLOWERfoo, using the same paradigm, for the rest of the case changing macros and functions.
* handy.h: Fix #ifdefKarl Williamson2021-02-281-1/+1
| | | | | | The prior code had a comment that indicated uncertainty about its correctness. I found a case where it didn't work, and am changing it accordingly. I have more confidence that this is right.
* handy.h: Add clarifying commentKarl Williamson2021-02-021-0/+1
|
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-21/+21
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* perlapi: Document line_tKarl Williamson2020-12-271-1/+8
|
* Revert "Don't test for 16-bit inputs in inRANGE()"Karl Williamson2020-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This effectively reverts commit 4c2aa7c802893d0276551ade1b9d5dcd1226afc4. That commit removed checking for 16 bit inputs because an assert in a macro was making compilations fail in some compilers that couldn't handle the complexity. This inadvertently broke systems which use C language shorts in certain places, such Mingw and Win32 with their use of UTF16, not typically found on other platforms. At the time, we weren't smoking Mingw so we didn't know about it there, but the Win32 failures on Win32 were "fixed" by another commit which disabled assertions of this type completely. It turns out the issue was passing too long a string to assert(). Commits 92a0bb2 and 88086fd removed a bunch of unnecessary and/or duplicate asserts, bringing the size down, so that the 16 bit checks can be added back in without breaking these compilers. The reverted commit mentioned HP compilers as having problems. The only such box we currently have available for testing is HP-31, and the reversion works fine on it, even before 92a0bb2 and 88086fd. This fixes GH #18364
* inRANGE, withinCOUNT: Split so can avoid assertsKarl Williamson2020-12-061-8/+22
| | | | | | | | | | This commit splits these macros up into components that are separately callable. The components are considered internal core only, and the purpose is to avoid duplicate assert() calls that were causing some compilers to crash from not being able to handle the size. In particular, this commit refactors inRANGE so that the asserts are done only once, shortening what it expands to.
* handy.h: Fix typo in commentKarl Williamson2020-12-061-1/+1
|
* Fix and update documentation of memEQ, memNE, ...Karl Williamson2020-12-031-4/+6
| | | | This fixes GH #18379
* Restrict scope/Shorten some very long macro namesKarl Williamson2020-11-221-6/+11
| | | | | | The names were intended to force people to not use them outside their intended scopes. But by restricting those scopes in the first place, we don't need such unwieldy names
* Make API some C99 typedef work-aroundsKarl Williamson2020-11-181-8/+13
| | | | | I added these some releases ago, but kept them private. No untoward things have happened, so I'm now making them API.
* Fix defns of e.g. U8_MAX/MINKarl Williamson2020-11-101-36/+56
| | | | | | Actually trying to compile these with Devel::PPPort revealed that there were combinations of the conditionals which led to some of the symbols not getting defined.
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-23/+23
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* perlapi: WIDEST_UTYPE is a typedefKarl Williamson2020-11-021-1/+1
|
* perlapi: StructCopy isn't conventionalKarl Williamson2020-11-021-1/+1
| | | | so suppress the usage line.
* Consolidate and revise pod for toLOWERfoo()Karl Williamson2020-10-171-42/+56
|
* Fix typosSamanta Navarro2020-10-031-2/+2
| | | | | | | | | For: https://github.com/Perl/perl5/pull/18201 Committer: Samanta Navarro is now a Perl author. To keep 'make test_porting' happy: Increment $VERSION in several files. Regenerate uconfig.h via './perl -Ilib regen/uconfig_h.pl'.
* perlapi: Fix function prototypesKarl Williamson2020-09-141-4/+4
| | | | These were wrong, and Devel::PPPort found the mistakes.
* perlapi: Fix typo.Karl Williamson2020-09-141-1/+1
|
* Fix input type on isFOO macrosKarl Williamson2020-09-141-114/+114
| | | | These macros accept any UV as input, but not a signed number
* gv_fetchpvn and gv_fetchpvn_flags are identicalKarl Williamson2020-09-141-2/+1
|
* Use macro instead of its expansionKarl Williamson2020-09-091-1/+1
| | | | | We already have a macro that expands to what this code does; it's clearer to use it.
* perlapi: Fix poor wording in MUTABLE_PTRKarl Williamson2020-09-071-2/+2
|
* perlapi: Display PERL_VERSION_xy betterKarl Williamson2020-09-051-10/+5
| | | | Now that we have the tools to show these as a whole list, do so
* Document MUTABLE_PTR, MUTABLE_AV, ...Karl Williamson2020-09-051-7/+23
|
* perlapi: Don't show a return type for __ASSERT_Karl Williamson2020-09-051-1/+1
|
* Change formal parameter name of gv_fetchpv*Karl Williamson2020-09-051-4/+5
| | | | This is a flags parameter, not a particular single flag
* perlapi: Improve display of isFOOKarl Williamson2020-09-051-254/+198
| | | | The character classification macro variants are now presented as a list
* perlapi: Display toFOO betterKarl Williamson2020-09-041-9/+9
| | | | | The character case change macro variants are now displayed all together
* Reorganize perlapiKarl Williamson2020-09-041-10/+40
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Change some =head1 to apidoc_section linesKarl Williamson2020-09-041-2/+2
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* Fixup handy.h to use PERL_VERSION macro☢ ℕicolas ℝ2020-08-021-10/+10
| | | | | | | | | | | handy.h was recently updated in 4a1bbd3d but this is not using the accurate definitions of the new semantic versions introduced as part of #18020 They are: - PERL_VERSION_MAJOR - PERL_VERSION_MINOR - PERL_VERSION_PATCH
* More preparation for 7.0 in versioningKarl Williamson2020-08-021-15/+75
| | | | | | | | | | | | This modifies the macros introduced in 9b6e95106e18e4fd33678d0df9b2293fd4f8ab9c that allow one to determine how the version of the perl currently being compiled compares to an arbitrary one. The modification is based on changes in the plan, including renaming of variables. This also introduces the use of '*' for the subversion (or micro as it is now called) to make conversion from the soon-to-be deprecated PERL_VERSION macro more rote, with less thinking involved.
* Use UINTMAX_C() in nBIT_MASK() definitionDagfinn Ilmari Mannsåker2020-07-201-5/+1
| | | | | | We already have a macro for constants of the largest available type, use that instead of HAS_LONG_LONG, which is (erroneously?) not defined under MSVC.
* handy.h: Add commentsKarl Williamson2020-07-171-1/+4
|
* handy.h: Create nBIT_UMAX() macroKarl Williamson2020-07-171-0/+3
| | | | This encapsulates a common paradigm
* handy.h: Create nBIT_MASK(n) macroKarl Williamson2020-07-171-0/+7
| | | | | This encapsulates a common paradigm, making sure that it is done correctly for the platform's size.
* handy.h: Update commentKarl Williamson2020-07-171-1/+1
|
* MUTABLE_PTR() Rmv non-standard syntaxKarl Williamson2020-07-171-1/+1
| | | | | Variables in C are beginning with an underscore are reserved for use by the C implementation. Change this non-conformant usage.
* Add PERL_VERSION_GE macro, and kinKarl Williamson2020-07-171-1/+39
| | | | | This moves things from vutil.h, and into handy.h; this is required for v7
* Fix a bunch of repeated-word typosDagfinn Ilmari Mannsåker2020-05-221-1/+1
| | | | | Mostly in comments and docs, but some in diagnostic messages and one case of 'or die die'.
* Move cntrl_to_mnemonic() to util.c from regcomp.cKarl Williamson2020-01-231-2/+5
| | | | | This is in preparation for it being used elsewhere, to reduce duplication of code.
* l1_char_class_tab.h: Add bits for binary, octal digitsKarl Williamson2020-01-131-1/+3
| | | | | | The motivation behind these extra bits is to allow three functions that deal with, respectively, binary, octal, and hex data to use the same paradigm, and hence be collapsible into a single function.
* handy.h: Convert XDIGIT_VALUE to branchlessKarl Williamson2020-01-131-11/+16
| | | | | | | | | | This removes a branch and an array lookup in the XDIGIT_VALUE() macro. It adds some shifts, masks, and additions instead, though replacing a mask and addition in the old way. A somewhat more complicated version could be made for EBCDIC, but I'm not bothering to do that, using an array lookup to convert the salient value to ASCII, so on EBCDIC there isn't an array lookup removal.