version 1.1.1.1, 2012/02/21 23:37:57
|
version 1.1.1.2, 2014/06/15 19:53:28
|
Line 307 typedef trio_longlong_t trio_int64_t;
|
Line 307 typedef trio_longlong_t trio_int64_t;
|
#define NAN_LOWER "nan" |
#define NAN_LOWER "nan" |
#define NAN_UPPER "NAN" |
#define NAN_UPPER "NAN" |
|
|
|
#if !defined(HAVE_ISASCII) && !defined(isascii) |
|
# define isascii(x) ((unsigned int)(x) < 128) |
|
#endif |
|
|
/* Various constants */ |
/* Various constants */ |
enum { |
enum { |
TYPE_PRINT = 1, |
TYPE_PRINT = 1, |
Line 376 enum {
|
Line 380 enum {
|
/* Maximal string lengths for user-defined specifiers */ |
/* Maximal string lengths for user-defined specifiers */ |
MAX_USER_NAME = 64, |
MAX_USER_NAME = 64, |
MAX_USER_DATA = 256, |
MAX_USER_DATA = 256, |
| |
/* Maximal length of locale separator strings */ |
/* Maximal length of locale separator strings */ |
MAX_LOCALE_SEPARATOR_LENGTH = MB_LEN_MAX, |
MAX_LOCALE_SEPARATOR_LENGTH = MB_LEN_MAX, |
/* Maximal number of integers in grouping */ |
/* Maximal number of integers in grouping */ |
Line 1020 TRIO_ARGS2((name, prev),
|
Line 1024 TRIO_ARGS2((name, prev),
|
trio_userdef_t **prev) |
trio_userdef_t **prev) |
{ |
{ |
trio_userdef_t *def; |
trio_userdef_t *def; |
| |
if (internalEnterCriticalRegion) |
if (internalEnterCriticalRegion) |
(void)internalEnterCriticalRegion(NULL); |
(void)internalEnterCriticalRegion(NULL); |
| |
for (def = internalUserDef; def; def = def->next) |
for (def = internalUserDef; def; def = def->next) |
{ |
{ |
/* Case-sensitive string comparison */ |
/* Case-sensitive string comparison */ |
if (trio_equal_case(def->name, name)) |
if (trio_equal_case(def->name, name)) |
break; |
break; |
| |
if (prev) |
if (prev) |
*prev = def; |
*prev = def; |
} |
} |
| |
if (internalLeaveCriticalRegion) |
if (internalLeaveCriticalRegion) |
(void)internalLeaveCriticalRegion(NULL); |
(void)internalLeaveCriticalRegion(NULL); |
| |
return def; |
return def; |
} |
} |
#endif |
#endif |
Line 1200 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1204 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
|
|
/* One and only one of arglist and argarray must be used */ |
/* One and only one of arglist and argarray must be used */ |
assert((arglist != NULL) ^ (argarray != NULL)); |
assert((arglist != NULL) ^ (argarray != NULL)); |
| |
/* |
/* |
* The 'parameters' array is not initialized, but we need to |
* The 'parameters' array is not initialized, but we need to |
* know which entries we have used. |
* know which entries we have used. |
Line 1213 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1217 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
(void)mblen(NULL, 0); |
(void)mblen(NULL, 0); |
#endif |
#endif |
| |
while (format[index]) |
while (format[index]) |
{ |
{ |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
Line 1291 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1295 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
/* Skip if no precision */ |
/* Skip if no precision */ |
if (QUALIFIER_DOT == format[index]) |
if (QUALIFIER_DOT == format[index]) |
break; |
break; |
| |
/* After the first dot we have the precision */ |
/* After the first dot we have the precision */ |
flags |= FLAGS_PRECISION; |
flags |= FLAGS_PRECISION; |
if ((QUALIFIER_STAR == format[index]) |
if ((QUALIFIER_STAR == format[index]) |
Line 1336 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1340 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
else if (dots == 1) /* Base */ |
else if (dots == 1) /* Base */ |
{ |
{ |
dots++; |
dots++; |
| |
/* After the second dot we have the base */ |
/* After the second dot we have the base */ |
flags |= FLAGS_BASE; |
flags |= FLAGS_BASE; |
if ((QUALIFIER_STAR == format[index]) |
if ((QUALIFIER_STAR == format[index]) |
Line 1535 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1539 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
} |
} |
else |
else |
return TRIO_ERROR_RETURN(TRIO_EINVAL, index); |
return TRIO_ERROR_RETURN(TRIO_EINVAL, index); |
| |
flags |= FLAGS_FIXED_SIZE; |
flags |= FLAGS_FIXED_SIZE; |
break; |
break; |
#endif |
#endif |
Line 1563 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1567 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
gotSticky = TRUE; |
gotSticky = TRUE; |
break; |
break; |
#endif |
#endif |
| |
#if defined(QUALIFIER_VARSIZE) |
#if defined(QUALIFIER_VARSIZE) |
case QUALIFIER_VARSIZE: |
case QUALIFIER_VARSIZE: |
flags |= FLAGS_VARSIZE_PARAMETER; |
flags |= FLAGS_VARSIZE_PARAMETER; |
Line 1628 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1632 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
indices[varsize] = pos; |
indices[varsize] = pos; |
varsize = pos++; |
varsize = pos++; |
} |
} |
| |
indices[currentParam] = pos; |
indices[currentParam] = pos; |
| |
switch (format[index++]) |
switch (format[index++]) |
{ |
{ |
#if defined(SPECIFIER_CHAR_UPPER) |
#if defined(SPECIFIER_CHAR_UPPER) |
Line 1689 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1693 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
} |
} |
} |
} |
break; |
break; |
| |
case SPECIFIER_INTEGER: |
case SPECIFIER_INTEGER: |
parameters[pos].type = FORMAT_INT; |
parameters[pos].type = FORMAT_INT; |
break; |
break; |
| |
case SPECIFIER_UNSIGNED: |
case SPECIFIER_UNSIGNED: |
flags |= FLAGS_UNSIGNED; |
flags |= FLAGS_UNSIGNED; |
parameters[pos].type = FORMAT_INT; |
parameters[pos].type = FORMAT_INT; |
Line 1793 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1797 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
{ |
{ |
unsigned int max; |
unsigned int max; |
int without_namespace = TRUE; |
int without_namespace = TRUE; |
| |
parameters[pos].type = FORMAT_USER_DEFINED; |
parameters[pos].type = FORMAT_USER_DEFINED; |
parameters[pos].user_name[0] = NIL; |
parameters[pos].user_name[0] = NIL; |
tmpformat = (char *)&format[index]; |
tmpformat = (char *)&format[index]; |
| |
while ((ch = format[index])) |
while ((ch = format[index])) |
{ |
{ |
index++; |
index++; |
Line 1845 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1849 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
} |
} |
break; |
break; |
#endif /* defined(SPECIFIER_USER_DEFINED_BEGIN) */ |
#endif /* defined(SPECIFIER_USER_DEFINED_BEGIN) */ |
| |
default: |
default: |
/* Bail out completely to make the error more obvious */ |
/* Bail out completely to make the error more obvious */ |
return TRIO_ERROR_RETURN(TRIO_EINVAL, index); |
return TRIO_ERROR_RETURN(TRIO_EINVAL, index); |
Line 1853 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1857 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
|
|
/* Count the number of times this entry has been used */ |
/* Count the number of times this entry has been used */ |
usedEntries[currentParam] += 1; |
usedEntries[currentParam] += 1; |
| |
/* Find last sticky parameters */ |
/* Find last sticky parameters */ |
if (gotSticky && !(flags & FLAGS_STICKY)) |
if (gotSticky && !(flags & FLAGS_STICKY)) |
{ |
{ |
Line 1876 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1880 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
} |
} |
} |
} |
} |
} |
| |
parameters[pos].indexAfterSpecifier = index; |
parameters[pos].indexAfterSpecifier = index; |
parameters[pos].flags = flags; |
parameters[pos].flags = flags; |
parameters[pos].width = width; |
parameters[pos].width = width; |
Line 1884 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1888 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
parameters[pos].base = (base == NO_BASE) ? BASE_DECIMAL : base; |
parameters[pos].base = (base == NO_BASE) ? BASE_DECIMAL : base; |
parameters[pos].varsize = varsize; |
parameters[pos].varsize = varsize; |
pos++; |
pos++; |
| |
if (! positional) |
if (! positional) |
parameterPosition++; |
parameterPosition++; |
| |
} /* if identifier */ |
} /* if identifier */ |
| |
} /* while format characters left */ |
} /* while format characters left */ |
|
|
for (num = 0; num <= maxParam; num++) |
for (num = 0; num <= maxParam; num++) |
Line 1901 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1905 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
else /* double references detected */ |
else /* double references detected */ |
return TRIO_ERROR_RETURN(TRIO_EDBLREF, num); |
return TRIO_ERROR_RETURN(TRIO_EDBLREF, num); |
} |
} |
| |
i = indices[num]; |
i = indices[num]; |
|
|
/* |
/* |
Line 1969 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 1973 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
if (TYPE_SCAN == type) |
if (TYPE_SCAN == type) |
{ |
{ |
if (argarray == NULL) |
if (argarray == NULL) |
parameters[i].data.pointer = | parameters[i].data.pointer = |
(trio_pointer_t)va_arg(*arglist, trio_pointer_t); |
(trio_pointer_t)va_arg(*arglist, trio_pointer_t); |
else |
else |
{ |
{ |
Line 2009 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
Line 2013 TRIO_ARGS5((type, format, parameters, arglist, argarra
|
varsize = parameters[i].varsize; |
varsize = parameters[i].varsize; |
} |
} |
parameters[i].flags &= ~FLAGS_ALL_VARSIZES; |
parameters[i].flags &= ~FLAGS_ALL_VARSIZES; |
| |
if (varsize <= (int)sizeof(int)) |
if (varsize <= (int)sizeof(int)) |
; |
; |
else if (varsize <= (int)sizeof(long)) |
else if (varsize <= (int)sizeof(long)) |
Line 2213 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2217 TRIO_ARGS6((self, number, flags, width, precision, bas
|
number &= (unsigned long)-1; |
number &= (unsigned long)-1; |
else |
else |
number &= (unsigned int)-1; |
number &= (unsigned int)-1; |
| |
/* Build number */ |
/* Build number */ |
pointer = bufferend = &buffer[sizeof(buffer) - 1]; |
pointer = bufferend = &buffer[sizeof(buffer) - 1]; |
*pointer-- = NIL; |
*pointer-- = NIL; |
Line 2260 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2264 TRIO_ARGS6((self, number, flags, width, precision, bas
|
count = (! ((flags & FLAGS_LEFTADJUST) || (precision == NO_PRECISION))) |
count = (! ((flags & FLAGS_LEFTADJUST) || (precision == NO_PRECISION))) |
? precision |
? precision |
: 0; |
: 0; |
| |
/* Adjust width further */ |
/* Adjust width further */ |
if (isNegative || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) |
if (isNegative || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) |
width--; |
width--; |
Line 2495 TRIO_ARGS4((self, wch, flags, width),
|
Line 2499 TRIO_ARGS4((self, wch, flags, width),
|
|
|
if (width == NO_WIDTH) |
if (width == NO_WIDTH) |
width = sizeof(buffer); |
width = sizeof(buffer); |
| |
size = wctomb(buffer, wch); |
size = wctomb(buffer, wch); |
if ((size <= 0) || (size > width) || (buffer[0] == NIL)) |
if ((size <= 0) || (size > width) || (buffer[0] == NIL)) |
return 0; |
return 0; |
Line 2537 TRIO_ARGS5((self, wstring, flags, width, precision),
|
Line 2541 TRIO_ARGS5((self, wstring, flags, width, precision),
|
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
(void)mblen(NULL, 0); |
(void)mblen(NULL, 0); |
#endif |
#endif |
| |
if (wstring == NULL) |
if (wstring == NULL) |
{ |
{ |
TrioWriteString(self, NULL, flags, width, precision); |
TrioWriteString(self, NULL, flags, width, precision); |
return; |
return; |
} |
} |
| |
if (NO_PRECISION == precision) |
if (NO_PRECISION == precision) |
{ |
{ |
length = INT_MAX; |
length = INT_MAX; |
Line 2638 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2642 TRIO_ARGS6((self, number, flags, width, precision, bas
|
BOOLEAN_T keepTrailingZeroes; |
BOOLEAN_T keepTrailingZeroes; |
BOOLEAN_T keepDecimalPoint; |
BOOLEAN_T keepDecimalPoint; |
trio_long_double_t epsilon; |
trio_long_double_t epsilon; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->OutStream)); |
assert(VALID(self->OutStream)); |
assert(((base >= MIN_BASE) && (base <= MAX_BASE)) || (base == NO_BASE)); |
assert(((base >= MIN_BASE) && (base <= MAX_BASE)) || (base == NO_BASE)); |
Line 2653 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2657 TRIO_ARGS6((self, number, flags, width, precision, bas
|
: NAN_LOWER, |
: NAN_LOWER, |
flags, width, precision); |
flags, width, precision); |
return; |
return; |
| |
case TRIO_FP_INFINITE: |
case TRIO_FP_INFINITE: |
if (isNegative) |
if (isNegative) |
{ |
{ |
Line 2680 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2684 TRIO_ARGS6((self, number, flags, width, precision, bas
|
/* Finitude */ |
/* Finitude */ |
break; |
break; |
} |
} |
| |
/* Normal numbers */ |
/* Normal numbers */ |
if (flags & FLAGS_LONGDOUBLE) |
if (flags & FLAGS_LONGDOUBLE) |
{ |
{ |
Line 2728 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2732 TRIO_ARGS6((self, number, flags, width, precision, bas
|
precision = FLT_DIG; |
precision = FLT_DIG; |
} |
} |
} |
} |
| |
if (isNegative) |
if (isNegative) |
number = -number; |
number = -number; |
|
|
if (isHex) |
if (isHex) |
flags |= FLAGS_FLOAT_E; |
flags |= FLAGS_FLOAT_E; |
| |
if (flags & FLAGS_FLOAT_G) |
if (flags & FLAGS_FLOAT_G) |
{ |
{ |
if (precision == 0) |
if (precision == 0) |
Line 2787 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2791 TRIO_ARGS6((self, number, flags, width, precision, bas
|
|
|
integerNumber = floorl(number); |
integerNumber = floorl(number); |
fractionNumber = number - integerNumber; |
fractionNumber = number - integerNumber; |
| |
/* |
/* |
* Truncated number. |
* Truncated number. |
* |
* |
Line 2802 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2806 TRIO_ARGS6((self, number, flags, width, precision, bas
|
: zeroes + precision; |
: zeroes + precision; |
|
|
dblFractionBase = TrioPower(base, fractionDigits); |
dblFractionBase = TrioPower(base, fractionDigits); |
| |
workNumber = number + 0.5 / dblFractionBase; |
workNumber = number + 0.5 / dblFractionBase; |
if (floorl(number) != floorl(workNumber)) |
if (floorl(number) != floorl(workNumber)) |
{ |
{ |
Line 2855 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2859 TRIO_ARGS6((self, number, flags, width, precision, bas
|
integerThreshold = INT_MAX; |
integerThreshold = INT_MAX; |
fractionThreshold = INT_MAX; |
fractionThreshold = INT_MAX; |
} |
} |
| |
/* |
/* |
* Calculate expected width. |
* Calculate expected width. |
* sign + integer part + thousands separators + decimal point |
* sign + integer part + thousands separators + decimal point |
Line 2891 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2895 TRIO_ARGS6((self, number, flags, width, precision, bas
|
((requireTwoDigitExponent ? sizeof("E+0") : sizeof("E+")) - 1); |
((requireTwoDigitExponent ? sizeof("E+0") : sizeof("E+")) - 1); |
if (isHex) |
if (isHex) |
expectedWidth += sizeof("0X") - 1; |
expectedWidth += sizeof("0X") - 1; |
| |
/* Output prefixing */ |
/* Output prefixing */ |
if (flags & FLAGS_NILPADDING) |
if (flags & FLAGS_NILPADDING) |
{ |
{ |
Line 2937 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2941 TRIO_ARGS6((self, number, flags, width, precision, bas
|
self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); |
self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); |
} |
} |
} |
} |
| |
/* Output the integer part and thousand separators */ |
/* Output the integer part and thousand separators */ |
dblIntegerBase = 1.0 / TrioPower(base, integerDigits - 1); |
dblIntegerBase = 1.0 / TrioPower(base, integerDigits - 1); |
for (i = 0; i < integerDigits; i++) |
for (i = 0; i < integerDigits; i++) |
Line 2953 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2957 TRIO_ARGS6((self, number, flags, width, precision, bas
|
self->OutStream(self, digits[(int)fmodl(workNumber, dblBase)]); |
self->OutStream(self, digits[(int)fmodl(workNumber, dblBase)]); |
} |
} |
dblIntegerBase *= dblBase; |
dblIntegerBase *= dblBase; |
| |
if (((flags & (FLAGS_FLOAT_E | FLAGS_QUOTE)) == FLAGS_QUOTE) |
if (((flags & (FLAGS_FLOAT_E | FLAGS_QUOTE)) == FLAGS_QUOTE) |
&& TrioFollowedBySeparator(integerDigits - i)) |
&& TrioFollowedBySeparator(integerDigits - i)) |
{ |
{ |
Line 2965 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 2969 TRIO_ARGS6((self, number, flags, width, precision, bas
|
} |
} |
} |
} |
} |
} |
| |
/* Insert decimal point and build the fraction part */ |
/* Insert decimal point and build the fraction part */ |
trailingZeroes = 0; |
trailingZeroes = 0; |
|
|
Line 3014 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 3018 TRIO_ARGS6((self, number, flags, width, precision, bas
|
} |
} |
} |
} |
} |
} |
| |
if (keepTrailingZeroes) |
if (keepTrailingZeroes) |
{ |
{ |
while (trailingZeroes > 0) |
while (trailingZeroes > 0) |
Line 3023 TRIO_ARGS6((self, number, flags, width, precision, bas
|
Line 3027 TRIO_ARGS6((self, number, flags, width, precision, bas
|
trailingZeroes--; |
trailingZeroes--; |
} |
} |
} |
} |
| |
/* Output exponent */ |
/* Output exponent */ |
if (exponentDigits > 0) |
if (exponentDigits > 0) |
{ |
{ |
Line 3080 TRIO_ARGS3((data, format, parameters),
|
Line 3084 TRIO_ARGS3((data, format, parameters),
|
int precision; |
int precision; |
int base; |
int base; |
int index; |
int index; |
| |
index = 0; |
index = 0; |
i = 0; |
i = 0; |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
(void)mblen(NULL, 0); |
(void)mblen(NULL, 0); |
#endif |
#endif |
| |
while (format[index]) |
while (format[index]) |
{ |
{ |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
Line 3120 TRIO_ARGS3((data, format, parameters),
|
Line 3124 TRIO_ARGS3((data, format, parameters),
|
/* Skip the parameter entries */ |
/* Skip the parameter entries */ |
while (parameters[i].type == FORMAT_PARAMETER) |
while (parameters[i].type == FORMAT_PARAMETER) |
i++; |
i++; |
| |
flags = parameters[i].flags; |
flags = parameters[i].flags; |
|
|
/* Find width */ |
/* Find width */ |
Line 3140 TRIO_ARGS3((data, format, parameters),
|
Line 3144 TRIO_ARGS3((data, format, parameters),
|
width = -width; |
width = -width; |
} |
} |
} |
} |
| |
/* Find precision */ |
/* Find precision */ |
if (flags & FLAGS_PRECISION) |
if (flags & FLAGS_PRECISION) |
{ |
{ |
Line 3171 TRIO_ARGS3((data, format, parameters),
|
Line 3175 TRIO_ARGS3((data, format, parameters),
|
/* Get base from parameter list */ |
/* Get base from parameter list */ |
base = (int)parameters[base].data.number.as_signed; |
base = (int)parameters[base].data.number.as_signed; |
} |
} |
| |
switch (parameters[i].type) |
switch (parameters[i].type) |
{ |
{ |
case FORMAT_CHAR: |
case FORMAT_CHAR: |
Line 3251 TRIO_ARGS3((data, format, parameters),
|
Line 3255 TRIO_ARGS3((data, format, parameters),
|
case FORMAT_POINTER: |
case FORMAT_POINTER: |
{ |
{ |
trio_reference_t reference; |
trio_reference_t reference; |
| |
reference.data = data; |
reference.data = data; |
reference.parameter = ¶meters[i]; |
reference.parameter = ¶meters[i]; |
trio_print_pointer(&reference, parameters[i].data.pointer); |
trio_print_pointer(&reference, parameters[i].data.pointer); |
Line 3354 TRIO_ARGS3((data, format, parameters),
|
Line 3358 TRIO_ARGS3((data, format, parameters),
|
} |
} |
break; |
break; |
#endif /* defined(FORMAT_USER_DEFINED) */ |
#endif /* defined(FORMAT_USER_DEFINED) */ |
| |
default: |
default: |
break; |
break; |
} /* switch parameter type */ |
} /* switch parameter type */ |
Line 3564 TRIO_ARGS2((self, output),
|
Line 3568 TRIO_ARGS2((self, output),
|
|
|
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->location)); |
assert(VALID(self->location)); |
| |
buffer = (char **)self->location; |
buffer = (char **)self->location; |
|
|
if (self->processed < self->max) |
if (self->processed < self->max) |
Line 3632 TRIO_VARGS2((format, va_alist),
|
Line 3636 TRIO_VARGS2((format, va_alist),
|
va_list args; |
va_list args; |
|
|
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioFormat(stdout, 0, TrioOutStreamFile, format, &args, NULL); |
status = TrioFormat(stdout, 0, TrioOutStreamFile, format, &args, NULL); |
TRIO_VA_END(args); |
TRIO_VA_END(args); |
Line 3699 TRIO_VARGS3((file, format, va_alist),
|
Line 3703 TRIO_VARGS3((file, format, va_alist),
|
|
|
assert(VALID(file)); |
assert(VALID(file)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioFormat(file, 0, TrioOutStreamFile, format, &args, NULL); |
status = TrioFormat(file, 0, TrioOutStreamFile, format, &args, NULL); |
TRIO_VA_END(args); |
TRIO_VA_END(args); |
Line 3723 TRIO_ARGS3((file, format, args),
|
Line 3727 TRIO_ARGS3((file, format, args),
|
{ |
{ |
assert(VALID(file)); |
assert(VALID(file)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioFormat(file, 0, TrioOutStreamFile, format, &args, NULL); |
return TrioFormat(file, 0, TrioOutStreamFile, format, &args, NULL); |
} |
} |
|
|
Line 3744 TRIO_ARGS3((file, format, args),
|
Line 3748 TRIO_ARGS3((file, format, args),
|
{ |
{ |
assert(VALID(file)); |
assert(VALID(file)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioFormat(file, 0, TrioOutStreamFile, format, NULL, args); |
return TrioFormat(file, 0, TrioOutStreamFile, format, NULL, args); |
} |
} |
|
|
Line 3771 TRIO_VARGS3((fd, format, va_alist),
|
Line 3775 TRIO_VARGS3((fd, format, va_alist),
|
va_list args; |
va_list args; |
|
|
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, &args, NULL); |
status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, &args, NULL); |
TRIO_VA_END(args); |
TRIO_VA_END(args); |
Line 3794 TRIO_ARGS3((fd, format, args),
|
Line 3798 TRIO_ARGS3((fd, format, args),
|
va_list args) |
va_list args) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, &args, NULL); |
return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, &args, NULL); |
} |
} |
|
|
Line 3814 TRIO_ARGS3((fd, format, args),
|
Line 3818 TRIO_ARGS3((fd, format, args),
|
trio_pointer_t *args) |
trio_pointer_t *args) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, NULL, args); |
return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, NULL, args); |
} |
} |
|
|
Line 3904 TRIO_VARGS3((buffer, format, va_alist),
|
Line 3908 TRIO_VARGS3((buffer, format, va_alist),
|
|
|
assert(VALID(buffer)); |
assert(VALID(buffer)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioFormat(&buffer, 0, TrioOutStreamString, format, &args, NULL); |
status = TrioFormat(&buffer, 0, TrioOutStreamString, format, &args, NULL); |
*buffer = NIL; /* Terminate with NIL character */ |
*buffer = NIL; /* Terminate with NIL character */ |
Line 4098 TRIO_ARGS4((buffer, max, format, args),
|
Line 4102 TRIO_ARGS4((buffer, max, format, args),
|
{ |
{ |
int status; |
int status; |
size_t buf_len; |
size_t buf_len; |
| |
assert(VALID(buffer)); |
assert(VALID(buffer)); |
assert(VALID(format)); |
assert(VALID(format)); |
|
|
Line 4126 TRIO_VARGS2((format, va_alist),
|
Line 4130 TRIO_VARGS2((format, va_alist),
|
char *result = NULL; |
char *result = NULL; |
|
|
assert(VALID(format)); |
assert(VALID(format)); |
| |
info = trio_xstring_duplicate(""); |
info = trio_xstring_duplicate(""); |
if (info) |
if (info) |
{ |
{ |
Line 4151 TRIO_ARGS2((format, args),
|
Line 4155 TRIO_ARGS2((format, args),
|
{ |
{ |
trio_string_t *info; |
trio_string_t *info; |
char *result = NULL; |
char *result = NULL; |
| |
assert(VALID(format)); |
assert(VALID(format)); |
| |
info = trio_xstring_duplicate(""); |
info = trio_xstring_duplicate(""); |
if (info) |
if (info) |
{ |
{ |
Line 4180 TRIO_VARGS3((result, format, va_alist),
|
Line 4184 TRIO_VARGS3((result, format, va_alist),
|
assert(VALID(format)); |
assert(VALID(format)); |
|
|
*result = NULL; |
*result = NULL; |
| |
info = trio_xstring_duplicate(""); |
info = trio_xstring_duplicate(""); |
if (info == NULL) |
if (info == NULL) |
{ |
{ |
Line 4211 TRIO_ARGS3((result, format, args),
|
Line 4215 TRIO_ARGS3((result, format, args),
|
{ |
{ |
int status; |
int status; |
trio_string_t *info; |
trio_string_t *info; |
| |
assert(VALID(format)); |
assert(VALID(format)); |
|
|
*result = NULL; |
*result = NULL; |
| |
info = trio_xstring_duplicate(""); |
info = trio_xstring_duplicate(""); |
if (info == NULL) |
if (info == NULL) |
{ |
{ |
Line 4264 TRIO_ARGS3((result, format, args),
|
Line 4268 TRIO_ARGS3((result, format, args),
|
@param name |
@param name |
@return Handle. |
@return Handle. |
*/ |
*/ |
TRIO_PUBLIC trio_pointer_t | TRIO_PUBLIC trio_pointer_t |
trio_register |
trio_register |
TRIO_ARGS2((callback, name), |
TRIO_ARGS2((callback, name), |
trio_callback_t callback, |
trio_callback_t callback, |
Line 4291 TRIO_ARGS2((callback, name),
|
Line 4295 TRIO_ARGS2((callback, name),
|
} |
} |
return NULL; |
return NULL; |
} |
} |
| |
/* Bail out if namespace is too long */ |
/* Bail out if namespace is too long */ |
if (trio_length(name) >= MAX_USER_NAME) |
if (trio_length(name) >= MAX_USER_NAME) |
return NULL; |
return NULL; |
| |
/* Bail out if namespace already is registered */ |
/* Bail out if namespace already is registered */ |
def = TrioFindNamespace(name, &prev); |
def = TrioFindNamespace(name, &prev); |
if (def) |
if (def) |
return NULL; |
return NULL; |
} |
} |
| |
def = (trio_userdef_t *)TRIO_MALLOC(sizeof(trio_userdef_t)); |
def = (trio_userdef_t *)TRIO_MALLOC(sizeof(trio_userdef_t)); |
if (def) |
if (def) |
{ |
{ |
if (internalEnterCriticalRegion) |
if (internalEnterCriticalRegion) |
(void)internalEnterCriticalRegion(NULL); |
(void)internalEnterCriticalRegion(NULL); |
| |
if (name) |
if (name) |
{ |
{ |
/* Link into internal list */ |
/* Link into internal list */ |
Line 4352 TRIO_ARGS1((handle),
|
Line 4356 TRIO_ARGS1((handle),
|
{ |
{ |
if (internalEnterCriticalRegion) |
if (internalEnterCriticalRegion) |
(void)internalEnterCriticalRegion(NULL); |
(void)internalEnterCriticalRegion(NULL); |
| |
if (prev == NULL) |
if (prev == NULL) |
internalUserDef = NULL; |
internalUserDef = NULL; |
else |
else |
prev->next = def->next; |
prev->next = def->next; |
| |
if (internalLeaveCriticalRegion) |
if (internalLeaveCriticalRegion) |
(void)internalLeaveCriticalRegion(NULL); |
(void)internalLeaveCriticalRegion(NULL); |
} |
} |
Line 4377 TRIO_ARGS1((ref),
|
Line 4381 TRIO_ARGS1((ref),
|
#if defined(FORMAT_USER_DEFINED) |
#if defined(FORMAT_USER_DEFINED) |
assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); |
assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); |
#endif |
#endif |
| |
return (((trio_reference_t *)ref)->parameter->user_data); |
return (((trio_reference_t *)ref)->parameter->user_data); |
} |
} |
|
|
/************************************************************************* |
/************************************************************************* |
* trio_get_argument [public] |
* trio_get_argument [public] |
*/ |
*/ |
trio_pointer_t | trio_pointer_t |
trio_get_argument |
trio_get_argument |
TRIO_ARGS1((ref), |
TRIO_ARGS1((ref), |
trio_pointer_t ref) |
trio_pointer_t ref) |
Line 4392 TRIO_ARGS1((ref),
|
Line 4396 TRIO_ARGS1((ref),
|
#if defined(FORMAT_USER_DEFINED) |
#if defined(FORMAT_USER_DEFINED) |
assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); |
assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); |
#endif |
#endif |
| |
return ((trio_reference_t *)ref)->parameter->data.pointer; |
return ((trio_reference_t *)ref)->parameter->data.pointer; |
} |
} |
|
|
Line 4924 TRIO_VARGS3((ref, format, va_alist),
|
Line 4928 TRIO_VARGS3((ref, format, va_alist),
|
va_list arglist; |
va_list arglist; |
|
|
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(arglist, format); |
TRIO_VA_START(arglist, format); |
status = TrioFormatRef((trio_reference_t *)ref, format, &arglist, NULL); |
status = TrioFormatRef((trio_reference_t *)ref, format, &arglist, NULL); |
TRIO_VA_END(arglist); |
TRIO_VA_END(arglist); |
Line 4942 TRIO_ARGS3((ref, format, arglist),
|
Line 4946 TRIO_ARGS3((ref, format, arglist),
|
va_list arglist) |
va_list arglist) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioFormatRef((trio_reference_t *)ref, format, &arglist, NULL); |
return TrioFormatRef((trio_reference_t *)ref, format, &arglist, NULL); |
} |
} |
|
|
Line 4957 TRIO_ARGS3((ref, format, argarray),
|
Line 4961 TRIO_ARGS3((ref, format, argarray),
|
trio_pointer_t *argarray) |
trio_pointer_t *argarray) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioFormatRef((trio_reference_t *)ref, format, NULL, argarray); |
return TrioFormatRef((trio_reference_t *)ref, format, NULL, argarray); |
} |
} |
|
|
Line 5206 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
Line 5210 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
switch (ch) |
switch (ch) |
{ |
{ |
case QUALIFIER_MINUS: /* Scanlist ranges */ |
case QUALIFIER_MINUS: /* Scanlist ranges */ |
| |
/* |
/* |
* Both C99 and UNIX98 describes ranges as implementation- |
* Both C99 and UNIX98 describes ranges as implementation- |
* defined. |
* defined. |
Line 5233 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
Line 5237 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
return TRIO_ERROR_RETURN(TRIO_EINVAL, index); |
return TRIO_ERROR_RETURN(TRIO_EINVAL, index); |
if (range_begin > range_end) |
if (range_begin > range_end) |
return TRIO_ERROR_RETURN(TRIO_ERANGE, index); |
return TRIO_ERROR_RETURN(TRIO_ERANGE, index); |
| |
for (i = (int)range_begin; i <= (int)range_end; i++) |
for (i = (int)range_begin; i <= (int)range_end; i++) |
characterclass[i]++; |
characterclass[i]++; |
| |
ch = range_end; |
ch = range_end; |
break; |
break; |
| |
#if TRIO_EXTENSION |
#if TRIO_EXTENSION |
|
|
case SPECIFIER_GROUP: |
case SPECIFIER_GROUP: |
| |
switch (format[index + 1]) |
switch (format[index + 1]) |
{ |
{ |
case QUALIFIER_DOT: /* Collating symbol */ |
case QUALIFIER_DOT: /* Collating symbol */ |
Line 5262 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
Line 5266 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
} |
} |
if (format[++i] != SPECIFIER_UNGROUP) |
if (format[++i] != SPECIFIER_UNGROUP) |
return -1; |
return -1; |
| |
index = i; |
index = i; |
break; |
break; |
| |
case QUALIFIER_EQUAL: /* Equivalence class expressions */ |
case QUALIFIER_EQUAL: /* Equivalence class expressions */ |
{ |
{ |
unsigned int j; |
unsigned int j; |
unsigned int k; |
unsigned int k; |
| |
if (internalCollationUnconverted) |
if (internalCollationUnconverted) |
{ |
{ |
/* Lazy evaluation of collation array */ |
/* Lazy evaluation of collation array */ |
Line 5294 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
Line 5298 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
} |
} |
if (format[++i] != SPECIFIER_UNGROUP) |
if (format[++i] != SPECIFIER_UNGROUP) |
return -1; |
return -1; |
| |
index = i; |
index = i; |
} |
} |
break; |
break; |
| |
case QUALIFIER_COLON: /* Character class expressions */ |
case QUALIFIER_COLON: /* Character class expressions */ |
| |
if (trio_equal_max(CLASS_ALNUM, sizeof(CLASS_ALNUM) - 1, |
if (trio_equal_max(CLASS_ALNUM, sizeof(CLASS_ALNUM) - 1, |
&format[index])) |
&format[index])) |
{ |
{ |
Line 5400 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
Line 5404 TRIO_ARGS4((format, indexPointer, flagsPointer, charac
|
break; |
break; |
} |
} |
break; |
break; |
| |
#endif /* TRIO_EXTENSION */ |
#endif /* TRIO_EXTENSION */ |
| |
default: |
default: |
characterclass[(int)ch]++; |
characterclass[(int)ch]++; |
break; |
break; |
Line 5448 TRIO_ARGS5((self, target, flags, width, base),
|
Line 5452 TRIO_ARGS5((self, target, flags, width, base),
|
} |
} |
internalDigitsUnconverted = FALSE; |
internalDigitsUnconverted = FALSE; |
} |
} |
| |
TrioSkipWhitespaces(self); |
TrioSkipWhitespaces(self); |
| |
if (!(flags & FLAGS_UNSIGNED)) |
if (!(flags & FLAGS_UNSIGNED)) |
{ |
{ |
/* Leading sign */ |
/* Leading sign */ |
Line 5464 TRIO_ARGS5((self, target, flags, width, base),
|
Line 5468 TRIO_ARGS5((self, target, flags, width, base),
|
isNegative = TRUE; |
isNegative = TRUE; |
} |
} |
} |
} |
| |
count = self->processed; |
count = self->processed; |
| |
if (flags & FLAGS_ALTERNATIVE) |
if (flags & FLAGS_ALTERNATIVE) |
{ |
{ |
switch (base) |
switch (base) |
Line 5527 TRIO_ARGS5((self, target, flags, width, base),
|
Line 5531 TRIO_ARGS5((self, target, flags, width, base),
|
} |
} |
else |
else |
break; |
break; |
| |
number *= base; |
number *= base; |
number += digit; |
number += digit; |
gotNumber = TRUE; /* we need at least one digit */ |
gotNumber = TRUE; /* we need at least one digit */ |
Line 5538 TRIO_ARGS5((self, target, flags, width, base),
|
Line 5542 TRIO_ARGS5((self, target, flags, width, base),
|
/* Was anything read at all? */ |
/* Was anything read at all? */ |
if (!gotNumber) |
if (!gotNumber) |
return FALSE; |
return FALSE; |
| |
if (target) |
if (target) |
*target = (isNegative) ? -((trio_intmax_t)number) : number; |
*target = (isNegative) ? -((trio_intmax_t)number) : number; |
return TRUE; |
return TRUE; |
Line 5558 TRIO_ARGS4((self, target, flags, width),
|
Line 5562 TRIO_ARGS4((self, target, flags, width),
|
int i; |
int i; |
char ch; |
char ch; |
trio_uintmax_t number; |
trio_uintmax_t number; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->InStream)); |
assert(VALID(self->InStream)); |
|
|
Line 5603 TRIO_ARGS4((self, target, flags, width),
|
Line 5607 TRIO_ARGS4((self, target, flags, width),
|
break; |
break; |
} |
} |
} |
} |
| |
if (target) |
if (target) |
target[i] = ch; |
target[i] = ch; |
} |
} |
Line 5622 TRIO_ARGS4((self, target, flags, width),
|
Line 5626 TRIO_ARGS4((self, target, flags, width),
|
int width) |
int width) |
{ |
{ |
int i; |
int i; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->InStream)); |
assert(VALID(self->InStream)); |
|
|
TrioSkipWhitespaces(self); |
TrioSkipWhitespaces(self); |
| |
/* |
/* |
* Continue until end of string is reached, a whitespace is encountered, |
* Continue until end of string is reached, a whitespace is encountered, |
* or width is exceeded |
* or width is exceeded |
Line 5663 TRIO_ARGS4((self, target, flags, width),
|
Line 5667 TRIO_ARGS4((self, target, flags, width),
|
int amount = 0; |
int amount = 0; |
trio_wchar_t wch; |
trio_wchar_t wch; |
char buffer[MB_LEN_MAX + 1]; |
char buffer[MB_LEN_MAX + 1]; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->InStream)); |
assert(VALID(self->InStream)); |
|
|
Line 5720 TRIO_ARGS4((self, target, flags, width),
|
Line 5724 TRIO_ARGS4((self, target, flags, width),
|
{ |
{ |
int i; |
int i; |
int size; |
int size; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->InStream)); |
assert(VALID(self->InStream)); |
|
|
Line 5729 TRIO_ARGS4((self, target, flags, width),
|
Line 5733 TRIO_ARGS4((self, target, flags, width),
|
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) |
(void)mblen(NULL, 0); |
(void)mblen(NULL, 0); |
#endif |
#endif |
| |
/* |
/* |
* Continue until end of string is reached, a whitespace is encountered, |
* Continue until end of string is reached, a whitespace is encountered, |
* or width is exceeded |
* or width is exceeded |
Line 5767 TRIO_ARGS5((self, target, characterclass, flags, width
|
Line 5771 TRIO_ARGS5((self, target, characterclass, flags, width
|
{ |
{ |
int ch; |
int ch; |
int i; |
int i; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->InStream)); |
assert(VALID(self->InStream)); |
|
|
Line 5782 TRIO_ARGS5((self, target, characterclass, flags, width
|
Line 5786 TRIO_ARGS5((self, target, characterclass, flags, width
|
target[i] = (char)ch; |
target[i] = (char)ch; |
self->InStream(self, &ch); |
self->InStream(self, &ch); |
} |
} |
| |
if (target) |
if (target) |
target[i] = NIL; |
target[i] = NIL; |
return TRUE; |
return TRUE; |
Line 5811 TRIO_ARGS4((self, target, flags, width),
|
Line 5815 TRIO_ARGS4((self, target, flags, width),
|
BOOLEAN_T isHex = FALSE; |
BOOLEAN_T isHex = FALSE; |
|
|
doubleString[0] = 0; |
doubleString[0] = 0; |
| |
if ((width == NO_WIDTH) || (width > (int)sizeof(doubleString) - 1)) |
if ((width == NO_WIDTH) || (width > (int)sizeof(doubleString) - 1)) |
width = sizeof(doubleString) - 1; |
width = sizeof(doubleString) - 1; |
| |
TrioSkipWhitespaces(self); |
TrioSkipWhitespaces(self); |
| |
/* |
/* |
* Read entire double number from stream. trio_to_double requires |
* Read entire double number from stream. trio_to_double requires |
* a string as input, but InStream can be anything, so we have to |
* a string as input, but InStream can be anything, so we have to |
Line 5902 TRIO_ARGS4((self, target, flags, width),
|
Line 5906 TRIO_ARGS4((self, target, flags, width),
|
self->InStream(self, &ch); |
self->InStream(self, &ch); |
} |
} |
break; |
break; |
| |
default: |
default: |
break; |
break; |
} |
} |
| |
while ((ch != EOF) && (index - start < width)) |
while ((ch != EOF) && (index - start < width)) |
{ |
{ |
/* Integer part */ |
/* Integer part */ |
Line 5966 TRIO_ARGS4((self, target, flags, width),
|
Line 5970 TRIO_ARGS4((self, target, flags, width),
|
return FALSE; |
return FALSE; |
|
|
doubleString[index] = 0; |
doubleString[index] = 0; |
| |
if (flags & FLAGS_LONGDOUBLE) |
if (flags & FLAGS_LONGDOUBLE) |
{ |
{ |
*((trio_long_double_t *)target) = trio_to_long_double(doubleString, NULL); |
*((trio_long_double_t *)target) = trio_to_long_double(doubleString, NULL); |
Line 5992 TRIO_ARGS3((self, target, flags),
|
Line 5996 TRIO_ARGS3((self, target, flags),
|
char buffer[sizeof(internalNullString)]; |
char buffer[sizeof(internalNullString)]; |
|
|
flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | FLAGS_NILPADDING); |
flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | FLAGS_NILPADDING); |
| |
if (TrioReadNumber(self, |
if (TrioReadNumber(self, |
&number, |
&number, |
flags, |
flags, |
Line 6013 TRIO_ARGS3((self, target, flags),
|
Line 6017 TRIO_ARGS3((self, target, flags),
|
: buffer, |
: buffer, |
0, |
0, |
sizeof(internalNullString) - 1)) |
sizeof(internalNullString) - 1)) |
{ | { |
if (trio_equal_case(buffer, internalNullString)) |
if (trio_equal_case(buffer, internalNullString)) |
{ |
{ |
if (target) |
if (target) |
Line 6077 TRIO_ARGS3((data, format, parameters),
|
Line 6081 TRIO_ARGS3((data, format, parameters),
|
} |
} |
} |
} |
#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ |
#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ |
| |
if ((EOF == ch) && (parameters[i].type != FORMAT_COUNT)) |
if ((EOF == ch) && (parameters[i].type != FORMAT_COUNT)) |
{ |
{ |
return (assignment > 0) ? assignment : EOF; |
return (assignment > 0) ? assignment : EOF; |
} |
} |
| |
if (CHAR_IDENTIFIER == format[index]) |
if (CHAR_IDENTIFIER == format[index]) |
{ |
{ |
if (CHAR_IDENTIFIER == format[index + 1]) |
if (CHAR_IDENTIFIER == format[index + 1]) |
Line 6101 TRIO_ARGS3((data, format, parameters),
|
Line 6105 TRIO_ARGS3((data, format, parameters),
|
/* Skip the parameter entries */ |
/* Skip the parameter entries */ |
while (parameters[i].type == FORMAT_PARAMETER) |
while (parameters[i].type == FORMAT_PARAMETER) |
i++; |
i++; |
| |
flags = parameters[i].flags; |
flags = parameters[i].flags; |
/* Find width */ |
/* Find width */ |
width = parameters[i].width; |
width = parameters[i].width; |
Line 6117 TRIO_ARGS3((data, format, parameters),
|
Line 6121 TRIO_ARGS3((data, format, parameters),
|
/* Get base from parameter list */ |
/* Get base from parameter list */ |
base = (int)parameters[base].data.number.as_signed; |
base = (int)parameters[base].data.number.as_signed; |
} |
} |
| |
switch (parameters[i].type) |
switch (parameters[i].type) |
{ |
{ |
case FORMAT_INT: |
case FORMAT_INT: |
Line 6165 TRIO_ARGS3((data, format, parameters),
|
Line 6169 TRIO_ARGS3((data, format, parameters),
|
} |
} |
} |
} |
break; /* FORMAT_INT */ |
break; /* FORMAT_INT */ |
| |
case FORMAT_STRING: |
case FORMAT_STRING: |
#if TRIO_WIDECHAR |
#if TRIO_WIDECHAR |
if (flags & FLAGS_WIDECHAR) |
if (flags & FLAGS_WIDECHAR) |
Line 6229 TRIO_ARGS3((data, format, parameters),
|
Line 6233 TRIO_ARGS3((data, format, parameters),
|
} |
} |
/* Skip over group specifier */ |
/* Skip over group specifier */ |
index++; |
index++; |
| |
memset(characterclass, 0, sizeof(characterclass)); |
memset(characterclass, 0, sizeof(characterclass)); |
rc = TrioGetCharacterClass(format, |
rc = TrioGetCharacterClass(format, |
&index, |
&index, |
Line 6291 TRIO_ARGS3((data, format, parameters),
|
Line 6295 TRIO_ARGS3((data, format, parameters),
|
} |
} |
} |
} |
break; /* FORMAT_COUNT */ |
break; /* FORMAT_COUNT */ |
| |
case FORMAT_CHAR: |
case FORMAT_CHAR: |
#if TRIO_WIDECHAR |
#if TRIO_WIDECHAR |
if (flags & FLAGS_WIDECHAR) |
if (flags & FLAGS_WIDECHAR) |
Line 6353 TRIO_ARGS3((data, format, parameters),
|
Line 6357 TRIO_ARGS3((data, format, parameters),
|
} |
} |
else |
else |
return assignment; |
return assignment; |
| |
index++; |
index++; |
} |
} |
} |
} |
Line 6392 TRIO_ARGS6((source, sourceSize, InStream, format, argl
|
Line 6396 TRIO_ARGS6((source, sourceSize, InStream, format, argl
|
TrioSetLocale(); |
TrioSetLocale(); |
} |
} |
#endif |
#endif |
| |
status = TrioParse(TYPE_SCAN, format, parameters, arglist, argarray); |
status = TrioParse(TYPE_SCAN, format, parameters, arglist, argarray); |
if (status < 0) |
if (status < 0) |
return status; |
return status; |
Line 6431 TRIO_ARGS2((self, intPointer),
|
Line 6435 TRIO_ARGS2((self, intPointer),
|
self->processed++; |
self->processed++; |
self->committed++; |
self->committed++; |
} |
} |
| |
if (VALID(intPointer)) |
if (VALID(intPointer)) |
{ |
{ |
*intPointer = self->current; |
*intPointer = self->current; |
Line 6468 TRIO_ARGS2((self, intPointer),
|
Line 6472 TRIO_ARGS2((self, intPointer),
|
self->committed++; |
self->committed++; |
self->processed++; |
self->processed++; |
} |
} |
| |
if (VALID(intPointer)) |
if (VALID(intPointer)) |
{ |
{ |
*intPointer = self->current; |
*intPointer = self->current; |
Line 6485 TRIO_ARGS2((self, intPointer),
|
Line 6489 TRIO_ARGS2((self, intPointer),
|
int *intPointer) |
int *intPointer) |
{ |
{ |
trio_custom_t *data; |
trio_custom_t *data; |
| |
assert(VALID(self)); |
assert(VALID(self)); |
assert(VALID(self->location)); |
assert(VALID(self->location)); |
|
|
Line 6494 TRIO_ARGS2((self, intPointer),
|
Line 6498 TRIO_ARGS2((self, intPointer),
|
self->current = (data->stream.in == NULL) |
self->current = (data->stream.in == NULL) |
? NIL |
? NIL |
: (data->stream.in)(data->closure); |
: (data->stream.in)(data->closure); |
| |
if (self->current == NIL) |
if (self->current == NIL) |
{ |
{ |
self->current = EOF; |
self->current = EOF; |
Line 6504 TRIO_ARGS2((self, intPointer),
|
Line 6508 TRIO_ARGS2((self, intPointer),
|
self->processed++; |
self->processed++; |
self->committed++; |
self->committed++; |
} |
} |
| |
if (VALID(intPointer)) |
if (VALID(intPointer)) |
{ |
{ |
*intPointer = self->current; |
*intPointer = self->current; |
Line 6537 TRIO_ARGS2((self, intPointer),
|
Line 6541 TRIO_ARGS2((self, intPointer),
|
self->processed++; |
self->processed++; |
self->committed++; |
self->committed++; |
} |
} |
| |
if (VALID(intPointer)) |
if (VALID(intPointer)) |
{ |
{ |
*intPointer = self->current; |
*intPointer = self->current; |
Line 6578 TRIO_VARGS2((format, va_alist),
|
Line 6582 TRIO_VARGS2((format, va_alist),
|
va_list args; |
va_list args; |
|
|
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioScan((trio_pointer_t)stdin, 0, |
status = TrioScan((trio_pointer_t)stdin, 0, |
TrioInStreamFile, |
TrioInStreamFile, |
Line 6594 TRIO_ARGS2((format, args),
|
Line 6598 TRIO_ARGS2((format, args),
|
va_list args) |
va_list args) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)stdin, 0, |
return TrioScan((trio_pointer_t)stdin, 0, |
TrioInStreamFile, |
TrioInStreamFile, |
format, &args, NULL); |
format, &args, NULL); |
Line 6607 TRIO_ARGS2((format, args),
|
Line 6611 TRIO_ARGS2((format, args),
|
trio_pointer_t *args) |
trio_pointer_t *args) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)stdin, 0, |
return TrioScan((trio_pointer_t)stdin, 0, |
TrioInStreamFile, |
TrioInStreamFile, |
format, NULL, args); |
format, NULL, args); |
Line 6628 TRIO_VARGS3((file, format, va_alist),
|
Line 6632 TRIO_VARGS3((file, format, va_alist),
|
|
|
assert(VALID(file)); |
assert(VALID(file)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioScan((trio_pointer_t)file, 0, |
status = TrioScan((trio_pointer_t)file, 0, |
TrioInStreamFile, |
TrioInStreamFile, |
Line 6646 TRIO_ARGS3((file, format, args),
|
Line 6650 TRIO_ARGS3((file, format, args),
|
{ |
{ |
assert(VALID(file)); |
assert(VALID(file)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)file, 0, |
return TrioScan((trio_pointer_t)file, 0, |
TrioInStreamFile, |
TrioInStreamFile, |
format, &args, NULL); |
format, &args, NULL); |
Line 6661 TRIO_ARGS3((file, format, args),
|
Line 6665 TRIO_ARGS3((file, format, args),
|
{ |
{ |
assert(VALID(file)); |
assert(VALID(file)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)file, 0, |
return TrioScan((trio_pointer_t)file, 0, |
TrioInStreamFile, |
TrioInStreamFile, |
format, NULL, args); |
format, NULL, args); |
Line 6681 TRIO_VARGS3((fd, format, va_alist),
|
Line 6685 TRIO_VARGS3((fd, format, va_alist),
|
va_list args; |
va_list args; |
|
|
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioScan((trio_pointer_t)&fd, 0, |
status = TrioScan((trio_pointer_t)&fd, 0, |
TrioInStreamFileDescriptor, |
TrioInStreamFileDescriptor, |
Line 6698 TRIO_ARGS3((fd, format, args),
|
Line 6702 TRIO_ARGS3((fd, format, args),
|
va_list args) |
va_list args) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)&fd, 0, |
return TrioScan((trio_pointer_t)&fd, 0, |
TrioInStreamFileDescriptor, |
TrioInStreamFileDescriptor, |
format, &args, NULL); |
format, &args, NULL); |
Line 6712 TRIO_ARGS3((fd, format, args),
|
Line 6716 TRIO_ARGS3((fd, format, args),
|
trio_pointer_t *args) |
trio_pointer_t *args) |
{ |
{ |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)&fd, 0, |
return TrioScan((trio_pointer_t)&fd, 0, |
TrioInStreamFileDescriptor, |
TrioInStreamFileDescriptor, |
format, NULL, args); |
format, NULL, args); |
Line 6735 TRIO_VARGS4((stream, closure, format, va_alist),
|
Line 6739 TRIO_VARGS4((stream, closure, format, va_alist),
|
|
|
assert(VALID(stream)); |
assert(VALID(stream)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
data.stream.in = stream; |
data.stream.in = stream; |
data.closure = closure; |
data.closure = closure; |
Line 6753 TRIO_ARGS4((stream, closure, format, args),
|
Line 6757 TRIO_ARGS4((stream, closure, format, args),
|
va_list args) |
va_list args) |
{ |
{ |
trio_custom_t data; |
trio_custom_t data; |
| |
assert(VALID(stream)); |
assert(VALID(stream)); |
assert(VALID(format)); |
assert(VALID(format)); |
|
|
Line 6771 TRIO_ARGS4((stream, closure, format, args),
|
Line 6775 TRIO_ARGS4((stream, closure, format, args),
|
trio_pointer_t *args) |
trio_pointer_t *args) |
{ |
{ |
trio_custom_t data; |
trio_custom_t data; |
| |
assert(VALID(stream)); |
assert(VALID(stream)); |
assert(VALID(format)); |
assert(VALID(format)); |
|
|
Line 6795 TRIO_VARGS3((buffer, format, va_alist),
|
Line 6799 TRIO_VARGS3((buffer, format, va_alist),
|
|
|
assert(VALID(buffer)); |
assert(VALID(buffer)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
TRIO_VA_START(args, format); |
TRIO_VA_START(args, format); |
status = TrioScan((trio_pointer_t)&buffer, 0, |
status = TrioScan((trio_pointer_t)&buffer, 0, |
TrioInStreamString, |
TrioInStreamString, |
Line 6813 TRIO_ARGS3((buffer, format, args),
|
Line 6817 TRIO_ARGS3((buffer, format, args),
|
{ |
{ |
assert(VALID(buffer)); |
assert(VALID(buffer)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)&buffer, 0, |
return TrioScan((trio_pointer_t)&buffer, 0, |
TrioInStreamString, |
TrioInStreamString, |
format, &args, NULL); |
format, &args, NULL); |
Line 6828 TRIO_ARGS3((buffer, format, args),
|
Line 6832 TRIO_ARGS3((buffer, format, args),
|
{ |
{ |
assert(VALID(buffer)); |
assert(VALID(buffer)); |
assert(VALID(format)); |
assert(VALID(format)); |
| |
return TrioScan((trio_pointer_t)&buffer, 0, |
return TrioScan((trio_pointer_t)&buffer, 0, |
TrioInStreamString, |
TrioInStreamString, |
format, NULL, args); |
format, NULL, args); |