- case 'd': case 'u': case 'o': case 'x': case 'X': case 'p': {
- /* NOTE: the u, o, x, X and p conversion specifiers imply
- the value is unsigned; d implies a signed value */
-
- int arg_sign = 0;
- /* 0 if numeric argument is zero (or if pointer is NULL for 'p'),
- +1 if greater than zero (or nonzero for unsigned arguments),
- -1 if negative (unsigned argument is never negative) */
-
- int int_arg = 0; unsigned int uint_arg = 0;
- /* only defined for length modifier h, or for no length modifiers */
-
- long int long_arg = 0; unsigned long int ulong_arg = 0;
- /* only defined for length modifier l */
-
- void *ptr_arg = NULL;
- /* pointer argument value -only defined for p conversion */
+ }
+ case 's':
+ str_arg = va_arg(ap, const char *);
+ if (!str_arg)
+ str_arg_l = 0;
+ /* make sure not to address string beyond the specified precision !!! */
+ else if (!precision_specified)
+ str_arg_l = strlen(str_arg);
+ /* truncate string if necessary as requested by precision */
+ else if (precision == 0)
+ str_arg_l = 0;
+ else {
+ /* memchr on HP does not like n > 2^31 !!! */
+ char *q = (char *) memchr(str_arg, '\0',
+ precision <=
+ 0x7fffffff ? precision : 0x7fffffff);
+ str_arg_l = !q ? precision : (q - str_arg);
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case 'd':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ case 'p':{
+ /* NOTE: the u, o, x, X and p conversion specifiers imply
+ the value is unsigned; d implies a signed value */
+
+ int arg_sign = 0;
+ /* 0 if numeric argument is zero (or if pointer is NULL for 'p'),
+ +1 if greater than zero (or nonzero for unsigned arguments),
+ -1 if negative (unsigned argument is never negative) */
+
+ int int_arg = 0;
+ unsigned int uint_arg = 0;
+ /* only defined for length modifier h, or for no length modifiers */
+
+ long int long_arg = 0;
+ unsigned long int ulong_arg = 0;
+ /* only defined for length modifier l */
+
+ void *ptr_arg = NULL;
+ /* pointer argument value -only defined for p conversion */