diff options
author | Karl Williamson <khw@cpan.org> | 2016-12-17 17:25:29 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2016-12-23 11:41:32 -0700 |
commit | eaf412bfffcc8de096d1389f01cecba0beca4c8d (patch) | |
tree | 3c784db08348ffa8f5f26263a4bdb55d74e03a98 /configpm | |
parent | 42c03a9af95fa27e50f4171d10a497b969c5f994 (diff) | |
download | perl-eaf412bfffcc8de096d1389f01cecba0beca4c8d.tar.gz |
utf8.c Extract common code into macros
The 3 case changing functions: to upper, lower, and title case are
essentially identical except for what they call to actually do the
change; those being different macros or functions.
The fourth function, to fold, is identical to the other three for the
first part of its code, but diverges at the end in order to handle some
special cases.
This commit replaces the first part of the bodies of these 4 functions
by a common macro. And it replaces the remainder of the first 3
functions by another common macro.
I'm not a fan of this kind of macro to use in generating code, but it
seems the best way to keep these definitions in sync. (It has to be a
macro instead of a function because one of the parameters is a macro,
which you can't pass to a function. I suppose one could create
functions that just calls their macro, and get around it that way, but
it doesn't seem worth it.)
This commit just moved the code to the macro, and I manually verified
that there were no logic changes.
1 of the passed-in functions requires one less argument (the final one)
than the other 3. I originally tried to do something with the C
preprocessor to get around that, but it didn't work with the Win32
version of the preprocessor, so I gave up and added a dummy parameter to
the fourth function, which is static so that's ok to do. Below, for the
record is my original attempt:
/* These two macros are used to make optional a parameter to the
* passed-in function to the macros just above. If the passed-in
* function doesn't take the parameter, use PLACEHOLDER in the macro
* call; otherwise surround the parameter by a PARAM() call */
#define PARAM(parameter) ,parameter
#define PLACEHOLDER /* Something for the preprocessor to grab onto */
And within the macro, it called the function like this:
L1_func(*p, ustrp, lenp/*,*/ L1_func_extra_param)
Diffstat (limited to 'configpm')
0 files changed, 0 insertions, 0 deletions