tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Gomez" <>
Subject Re: mod_jk pointer error for i5/OS V5R4
Date Tue, 03 Jul 2007 13:35:49 GMT
What about doing ?


unsigned char ch;

while (*p)
     ch =  (unsigned char)*p++;
     header[i++] = toupper(ch);

2007/7/3, Ron Egyed <>:
> FYI,
> The following code in the sc_for_req_header function in module jk_ajp_common was getting
a pointer error on version V5R4 of i5/OS (AS400).
> while (*p)
>       header[i++] = toupper((unsigned char)*p++);
> IBM provided two solutions to this problem.
> I tried the 2nd solution of wrapping the toupper in parenthesis and the code works correctly
when compiled with LOCALE(*LOCALEUTF).
> IBM's explanation. . .
> The reason for the different behavior is that the toupper() routine is implemented as
a macro within the header file and the parameter is evaluated twice for the *LOCALEUTF version
of the routine.
> The standard indicates that the routines within <ctype.h> may be implemented as
macros -
> Any routine which may be implemented as a macro is allowed to evaluate the parameter
any number of times and thus using code like xxx(*p++) where xxx is a runtime routine is not
portable.  The standard does not state this for every routine which may be a macro, but it
is true in all macro cases.  Here is an example within the standard which explicitly states
this fact for the getc() routine -
.  Here is an excerpt from that web page:
> Because it may be implemented as a macro, getc() may treat incorrectly a stream argument
with side effects. In particular, getc(*f++) will not necessarily work as expected. Therefore,
use of this function should be preceded by "#undef getc" in such situations; fgetc() could
also be used.
> This yields the following solutions for such code:
> 1) use #undef toupper after <ctype.h> is included.
> 2) a second solution is to wrap the toupper call in parenthesis - e.g. (toupper)((unsigned
> Either of these solutions can be used to 'disable' the macro version and allow both methods
to work correctly.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message