• Home
  • Raw
  • Download

Lines Matching full:spec

101 #define SECUREC_FILED_WIDTH_ENOUGH(spec) ((spec)->widthSet == 0 || (spec)->width > 0)  argument
102 #define SECUREC_FILED_WIDTH_DEC(spec) do { \ argument
103 if ((spec)->widthSet != 0) { \
104 --(spec)->width; \
120 #define SECUREC_ARRAY_WIDTH_IS_WRONG(spec) ((spec).arrayWidth == 0 || \ argument
121 ((spec).isWCharOrLong <= 0 && (spec).arrayWidth > SECUREC_STRING_MAX_LEN) || \
122 ((spec).isWCharOrLong > 0 && (spec).arrayWidth > SECUREC_WCHAR_STRING_MAX_LEN))
124 #define SECUREC_ARRAY_WIDTH_IS_WRONG(spec) ((spec).arrayWidth == 0 || (spec).arrayWidth > SECUREC_S… argument
337 SECUREC_INLINE int SecAssignFloatW(const SecFloatSpec *floatSpec, const SecScanSpec *spec) argument
357 SecAssignFloat(tempFloatStr, spec->numberWidth, spec->argPtr);
439 SECUREC_INLINE int SecInputFloatSign(SecFileStream *stream, SecScanSpec *spec, SecFloatSpec *floatS… argument
441 if (!SECUREC_FILED_WIDTH_ENOUGH(spec)) {
444 spec->ch = SecGetChar(stream, &(spec->charCount));
445 if (spec->ch == SECUREC_CHAR('+') || spec->ch == SECUREC_CHAR('-')) {
446 SECUREC_FILED_WIDTH_DEC(spec); /* Make sure the count after un get char is correct */
447 if (spec->ch == SECUREC_CHAR('-')) {
455 SecUnGetChar(spec->ch, stream, &(spec->charCount));
460 SECUREC_INLINE int SecInputFloatDigit(SecFileStream *stream, SecScanSpec *spec, SecFloatSpec *float… argument
463 while (SECUREC_FILED_WIDTH_ENOUGH(spec)) {
464 spec->ch = SecGetChar(stream, &(spec->charCount));
465 if (SecIsDigit(spec->ch) == 0) {
466 SecUnGetChar(spec->ch, stream, &(spec->charCount));
469 … SECUREC_FILED_WIDTH_DEC(spec); /* Must be behind un get char, otherwise the logic is incorrect */
470 spec->numberState = SECUREC_NUMBER_STATE_STARTED;
471 floatSpec->floatStr[floatSpec->floatStrUsedLen] = (SecChar)spec->ch;
484 SECUREC_INLINE int SecInputFloatE(SecFileStream *stream, SecScanSpec *spec, SecFloatSpec *floatSpec) argument
486 if (SecInputFloatSign(stream, spec, floatSpec) == -1) {
489 if (SecInputFloatDigit(stream, spec, floatSpec) != 0) {
495 SECUREC_INLINE int SecInputFloatFractional(SecFileStream *stream, SecScanSpec *spec, SecFloatSpec *… argument
497 if (SECUREC_FILED_WIDTH_ENOUGH(spec)) {
498 spec->ch = SecGetChar(stream, &(spec->charCount));
499 if (SecIsFloatDecimal((SecChar)spec->ch) == 0) {
500 SecUnGetChar(spec->ch, stream, &(spec->charCount));
503 … SECUREC_FILED_WIDTH_DEC(spec); /* Must be behind un get char, otherwise the logic is incorrect */
505 floatSpec->floatStr[floatSpec->floatStrUsedLen] = (SecChar)spec->ch;
510 if (SecInputFloatDigit(stream, spec, floatSpec) != 0) {
517 SECUREC_INLINE int SecInputFloatExponent(SecFileStream *stream, SecScanSpec *spec, SecFloatSpec *fl… argument
520 if (spec->numberState == SECUREC_NUMBER_STATE_STARTED && SECUREC_FILED_WIDTH_ENOUGH(spec)) {
521 spec->ch = SecGetChar(stream, &(spec->charCount));
522 if (spec->ch != SECUREC_CHAR('e') && spec->ch != SECUREC_CHAR('E')) {
523 SecUnGetChar(spec->ch, stream, &(spec->charCount));
526 … SECUREC_FILED_WIDTH_DEC(spec); /* Must be behind un get char, otherwise the logic is incorrect */
532 if (SecInputFloatE(stream, spec, floatSpec) != 0) {
543 SECUREC_INLINE int SecInputFloat(SecFileStream *stream, SecScanSpec *spec, SecFloatSpec *floatSpec) argument
548 if (SecInputFloatSign(stream, spec, floatSpec) != 0) {
551 if (SecInputFloatDigit(stream, spec, floatSpec) != 0) {
554 if (SecInputFloatFractional(stream, spec, floatSpec) != 0) {
557 if (SecInputFloatExponent(stream, spec, floatSpec) != 0) {
563 if (spec->numberState == SECUREC_NUMBER_STATE_STARTED) {
587 SECUREC_INLINE void SecUpdateWcharFlagByType(SecUnsignedChar ch, SecScanSpec *spec) argument
589 if (spec->isWCharOrLong != 0) {
596 spec->isWCharOrLong = 1; /* On windows wide char version %c %s %[ is wide char */
598 spec->isWCharOrLong = -1; /* On linux all version %c %s %[ is multi char */
603 spec->isWCharOrLong = -1; /* On windows wide char version %C %S is multi char */
605 spec->isWCharOrLong = 1; /* On linux all version %C %S is wide char */
614 SECUREC_INLINE void SecDecodeScanQualifierL(const SecUnsignedChar **format, SecScanSpec *spec) argument
618 spec->numberArgType = 1;
619 spec->numberWidth = SECUREC_NUM_WIDTH_LONG_LONG;
622 spec->numberWidth = SECUREC_NUM_WIDTH_LONG;
625 spec->numberArgType = 1;
627 spec->isWCharOrLong = 1;
636 SECUREC_INLINE void SecDecodeScanQualifierI(const SecUnsignedChar **format, SecScanSpec *spec, int … argument
641 spec->numberArgType = 1;
651 spec->numberArgType = SecNumberArgType(sizeof(void *));
654 spec->numberArgType = SecNumberArgType(sizeof(void *));
659 SECUREC_INLINE int SecDecodeScanWidth(const SecUnsignedChar **format, SecScanSpec *spec) argument
663 spec->widthSet = 1;
664 if (SECUREC_MUL_TEN_ADD_BEYOND_MAX(spec->width)) {
667spec->width = (int)SECUREC_MUL_TEN((unsigned int)spec->width) + (unsigned char)(*fmt - SECUREC_CHA…
677 SECUREC_INLINE void SecSetDefaultScanSpec(SecScanSpec *spec) argument
680 spec->argPtr = NULL;
681 spec->arrayWidth = 0;
682 spec->number64 = 0;
683 spec->number = 0;
684 spec->numberWidth = SECUREC_NUM_WIDTH_INT; /* 0 = SHORT, 1 = int, > 1 long or L_DOUBLE */
685 spec->numberArgType = 0; /* 1 for 64-bit integer, 0 otherwise */
686 spec->width = 0;
687 spec->widthSet = 0;
688 spec->convChr = 0;
689 spec->oriConvChr = 0;
690 spec->isWCharOrLong = 0;
691 spec->suppress = 0;
693 spec->beyondMax = 0;
695 spec->negative = 0;
696 spec->numberState = SECUREC_NUMBER_STATE_DEFAULT;
703 SECUREC_INLINE void SecDecodeScanQualifier(const SecUnsignedChar **format, SecScanSpec *spec, int … argument
710 --spec->numberWidth; /* The h for SHORT , hh for CHAR */
711 spec->isWCharOrLong = -1;
715 spec->numberWidth = SECUREC_NUM_WIDTH_LONG_LONG; /* For intmax_t or uintmax_t */
716 spec->numberArgType = 1;
725 spec->numberWidth = SECUREC_NUM_WIDTH_LONG_LONG;
726 spec->numberArgType = 1;
728 spec->numberWidth = SECUREC_NUM_WIDTH_LONG;
733 spec->numberWidth = SECUREC_NUM_WIDTH_LONG_LONG;
734 spec->numberArgType = 1;
737 SecDecodeScanQualifierL(format, spec);
740 spec->isWCharOrLong = 1;
743 spec->suppress = 1;
746 SecDecodeScanQualifierI(format, spec, finishFlag);
756 SECUREC_INLINE int SecDecodeScanFlag(const SecUnsignedChar **format, SecScanSpec *spec) argument
764 if (SecDecodeScanWidth(&fmt, spec) != 0) {
767 SecDecodeScanQualifier(&fmt, spec, &finishFlag);
811 SECUREC_INLINE void SecAddEndingZero(void *ptr, const SecScanSpec *spec) argument
813 if (spec->suppress == 0) {
816 if (spec->isWCharOrLong > 0) {
823 SECUREC_INLINE void SecDecodeClearArg(SecScanSpec *spec, va_list argList) argument
834 spec->argPtr = (void *)va_arg(argListSave, void *);
837 spec->arrayWidth = ((size_t)(va_arg(argListSave, size_t))) & 0xffffffffUL;
855 SecScanSpec spec; local
870 SecSetDefaultScanSpec(&spec);
871 if (SecDecodeScanFlag(&fmt, &spec) != 0) {
876 SecUpdateWcharFlagByType(*fmt, &spec);
877 if (spec.suppress != 0) {
893 SecDecodeClearArg(&spec, argList);
895 if (spec.arrayWidth == 0 || spec.argPtr == NULL) {
899 SecAddEndingZero(spec.argPtr, &spec);
906 SECUREC_INLINE void SecAssignNumber(const SecScanSpec *spec) argument
908 void *argPtr = spec->argPtr;
909 if (spec->numberArgType != 0) {
912 *(SecInt64 UNALIGNED *)argPtr = (SecInt64)(spec->number64);
915 *(SecInt64 UNALIGNED *)argPtr = *(SecUnsignedInt64 *)(&(spec->number64));
919 *(SecInt64 UNALIGNED *)argPtr = (SecInt64)(spec->number64);
923 if (spec->numberWidth > SECUREC_NUM_WIDTH_INT) {
925 *(long UNALIGNED *)argPtr = (long)(spec->number);
926 } else if (spec->numberWidth == SECUREC_NUM_WIDTH_INT) {
927 *(int UNALIGNED *)argPtr = (int)(spec->number);
928 } else if (spec->numberWidth == SECUREC_NUM_WIDTH_SHORT) {
930 *(short UNALIGNED *)argPtr = (short)(spec->number);
933 *(char UNALIGNED *)argPtr = (char)(spec->number);
960 static void SecDecodeNumberDecimal(SecScanSpec *spec) argument
969 if (spec->number > decimalEdge) {
970 spec->beyondMax = 1;
973 spec->number = SECUREC_MUL_TEN(spec->number);
975 if (spec->number == SECUREC_MUL_TEN(decimalEdge)) {
977 SecUnsignedInt64 number64As = (unsigned long)SECUREC_MAX_64BITS_VALUE - spec->number;
978 if (number64As < (SecUnsignedInt64)((SecUnsignedInt)spec->ch - SECUREC_CHAR('0'))) {
979 spec->beyondMax = 1;
983 spec->number += (unsigned long)((SecUnsignedInt)spec->ch - SECUREC_CHAR('0'));
989 static void SecDecodeNumberHex(SecScanSpec *spec) argument
992 if (SECUREC_LONG_HEX_BEYOND_MAX(spec->number)) {
993 spec->beyondMax = 1;
996 spec->number = SECUREC_MUL_SIXTEEN(spec->number);
997 spec->number += (unsigned long)(unsigned int)SecHexValueOfChar(spec->ch);
1003 static void SecDecodeNumberOctal(SecScanSpec *spec) argument
1006 if (SECUREC_LONG_OCTAL_BEYOND_MAX(spec->number)) {
1007 spec->beyondMax = 1;
1010 spec->number = SECUREC_MUL_EIGHT(spec->number);
1011 spec->number += (unsigned long)((SecUnsignedInt)spec->ch - SECUREC_CHAR('0'));
1016 SECUREC_INLINE void SecFinishNumberNegativeOther(SecScanSpec *spec) argument
1018 if (SECUREC_CONVERT_IS_SIGNED(spec->oriConvChr)) {
1019 if (spec->number > SECUREC_MIN_LONG_NEG_VALUE) {
1020 spec->number = SECUREC_MIN_LONG_NEG_VALUE;
1022 spec->number = (unsigned long)(0U - spec->number); /* Wrap with unsigned long numbers */
1024 if (spec->beyondMax != 0) {
1025 if (spec->numberWidth < SECUREC_NUM_WIDTH_INT) {
1026 spec->number = 0;
1028 if (spec->numberWidth == SECUREC_NUM_WIDTH_LONG) {
1029 spec->number = SECUREC_MIN_LONG_NEG_VALUE;
1033 spec->number = (unsigned long)(0U - spec->number); /* Wrap with unsigned long numbers */
1034 if (spec->beyondMax != 0) {
1035 spec->number = (unsigned long)SECUREC_MAX_64BITS_VALUE;
1040 SECUREC_INLINE void SecFinishNumberNegativeInt(SecScanSpec *spec) argument
1042 if (SECUREC_CONVERT_IS_SIGNED(spec->oriConvChr)) {
1045 if ((spec->number > SECUREC_MIN_64BITS_NEG_VALUE)) {
1046 spec->number = 0;
1048spec->number = (unsigned int)(0U - (unsigned int)spec->number); /* Wrap with unsigned int numbers …
1053 if ((spec->number > SECUREC_MIN_32BITS_NEG_VALUE)) {
1054 spec->number = SECUREC_MIN_32BITS_NEG_VALUE;
1056spec->number = (unsigned int)(0U - (unsigned int)spec->number); /* Wrap with unsigned int numbers …
1060 if (spec->beyondMax != 0) {
1063 spec->number = 0;
1067 spec->number = SECUREC_MIN_32BITS_NEG_VALUE;
1073 if (spec->number > SECUREC_MAX_32BITS_VALUE_INC) {
1074 spec->number = SECUREC_MAX_32BITS_VALUE;
1076spec->number = (unsigned int)(0U - (unsigned int)spec->number); /* Wrap with unsigned int numbers …
1079spec->number = (unsigned int)(0U - (unsigned int)spec->number); /* Wrap with unsigned int numbers …
1081 if (spec->beyondMax != 0) {
1082 spec->number = (unsigned long)SECUREC_MAX_64BITS_VALUE;
1088 SECUREC_INLINE void SecFinishNumberPositiveOther(SecScanSpec *spec) argument
1090 if (SECUREC_CONVERT_IS_SIGNED(spec->oriConvChr)) {
1091 if (spec->number > SECUREC_MAX_LONG_POS_VALUE) {
1092 spec->number = SECUREC_MAX_LONG_POS_VALUE;
1094 if ((spec->beyondMax != 0 && spec->numberWidth < SECUREC_NUM_WIDTH_INT)) {
1095 spec->number = (unsigned long)SECUREC_MAX_64BITS_VALUE;
1097 if (spec->beyondMax != 0 && spec->numberWidth == SECUREC_NUM_WIDTH_LONG) {
1098 spec->number = SECUREC_MAX_LONG_POS_VALUE;
1101 if (spec->beyondMax != 0) {
1102 spec->number = (unsigned long)SECUREC_MAX_64BITS_VALUE;
1108 SECUREC_INLINE void SecFinishNumberPositiveInt(SecScanSpec *spec) argument
1110 if (SECUREC_CONVERT_IS_SIGNED(spec->oriConvChr)) {
1113 if (spec->number > SECUREC_MAX_64BITS_POS_VALUE) {
1114 spec->number = (unsigned long)SECUREC_MAX_64BITS_VALUE;
1117 if (spec->beyondMax != 0 && SecIsLongBitEqual(SECUREC_LP64_BIT_WIDTH) != 0) {
1118 spec->number = (unsigned long)SECUREC_MAX_64BITS_VALUE;
1122 if (spec->number > SECUREC_MAX_32BITS_POS_VALUE) {
1123 spec->number = SECUREC_MAX_32BITS_POS_VALUE;
1126 if (spec->beyondMax != 0 && SecIsLongBitEqual(SECUREC_LP32_BIT_WIDTH) != 0) {
1127 spec->number = SECUREC_MAX_32BITS_POS_VALUE;
1131 if (spec->beyondMax != 0) {
1132 spec->number = SECUREC_MAX_32BITS_VALUE;
1142 static void SecDecodeNumber64Decimal(SecScanSpec *spec) argument
1145 if (spec->number64 > SECUREC_MAX_64BITS_VALUE_DIV_TEN) {
1146 spec->beyondMax = 1;
1149 spec->number64 = SECUREC_MUL_TEN(spec->number64);
1151 if (spec->number64 == SECUREC_MAX_64BITS_VALUE_CUT_LAST_DIGIT) {
1152 SecUnsignedInt64 number64As = (SecUnsignedInt64)SECUREC_MAX_64BITS_VALUE - spec->number64;
1153 if (number64As < (SecUnsignedInt64)((SecUnsignedInt)spec->ch - SECUREC_CHAR('0'))) {
1154 spec->beyondMax = 1;
1158 spec->number64 += (SecUnsignedInt64)((SecUnsignedInt)spec->ch - SECUREC_CHAR('0'));
1164 static void SecDecodeNumber64Hex(SecScanSpec *spec) argument
1167 if (SECUREC_QWORD_HEX_BEYOND_MAX(spec->number64)) {
1168 spec->beyondMax = 1;
1171 spec->number64 = SECUREC_MUL_SIXTEEN(spec->number64);
1172 spec->number64 += (SecUnsignedInt64)(unsigned int)SecHexValueOfChar(spec->ch);
1178 static void SecDecodeNumber64Octal(SecScanSpec *spec) argument
1181 if (SECUREC_QWORD_OCTAL_BEYOND_MAX(spec->number64)) {
1182 spec->beyondMax = 1;
1185 spec->number64 = SECUREC_MUL_EIGHT(spec->number64);
1186 spec->number64 += (SecUnsignedInt64)((SecUnsignedInt)spec->ch - SECUREC_CHAR('0'));
1194 SECUREC_INLINE int SecDecodeNumber(SecScanSpec *spec) argument
1197 static void (*secDecodeNumberHex[SECUREC_DECODE_NUMBER_FUNC_NUM])(SecScanSpec *spec) = {
1200 static void (*secDecodeNumberOctal[SECUREC_DECODE_NUMBER_FUNC_NUM])(SecScanSpec *spec) = {
1203 static void (*secDecodeNumberDecimal[SECUREC_DECODE_NUMBER_FUNC_NUM])(SecScanSpec *spec) = {
1206 if (spec->convChr == 'x' || spec->convChr == 'p') {
1207 if (SecIsXdigit(spec->ch) != 0) {
1208 (*secDecodeNumberHex[spec->numberArgType])(spec);
1214 if (SecIsDigit(spec->ch) == 0) {
1217 if (spec->convChr == 'o') {
1218 if (spec->ch < SECUREC_CHAR('8')) { /* Octal maximum limit '8' */
1219 (*secDecodeNumberOctal[spec->numberArgType])(spec);
1224 (*secDecodeNumberDecimal[spec->numberArgType])(spec);
1232 static void SecFinishNumber(SecScanSpec *spec) argument
1235 if (spec->negative != 0) {
1236 if (spec->numberWidth == SECUREC_NUM_WIDTH_INT) {
1237 SecFinishNumberNegativeInt(spec);
1239 SecFinishNumberNegativeOther(spec);
1242 if (spec->numberWidth == SECUREC_NUM_WIDTH_INT) {
1243 SecFinishNumberPositiveInt(spec);
1245 SecFinishNumberPositiveOther(spec);
1249 if (spec->negative != 0) {
1251 if (spec->oriConvChr != 'p') {
1252 spec->number = (unsigned long)(0U - spec->number); /* Wrap with unsigned long numbers */
1255 spec->number = (unsigned long)(0U - spec->number); /* Wrap with unsigned long numbers */
1265 static void SecFinishNumber64(SecScanSpec *spec) argument
1268 if (spec->negative != 0) {
1269 if (SECUREC_CONVERT_IS_SIGNED(spec->oriConvChr)) {
1270 if (spec->number64 > SECUREC_MIN_64BITS_NEG_VALUE) {
1271 spec->number64 = SECUREC_MIN_64BITS_NEG_VALUE;
1273spec->number64 = (SecUnsignedInt64)(0U - spec->number64); /* Wrap with unsigned int64 numbers */
1275 if (spec->beyondMax != 0) {
1276 spec->number64 = SECUREC_MIN_64BITS_NEG_VALUE;
1279spec->number64 = (SecUnsignedInt64)(0U - spec->number64); /* Wrap with unsigned int64 numbers */
1280 if (spec->beyondMax != 0) {
1281 spec->number64 = SECUREC_MAX_64BITS_VALUE;
1285 if (SECUREC_CONVERT_IS_SIGNED(spec->oriConvChr)) {
1286 if (spec->number64 > SECUREC_MAX_64BITS_POS_VALUE) {
1287 spec->number64 = SECUREC_MAX_64BITS_POS_VALUE;
1289 if (spec->beyondMax != 0) {
1290 spec->number64 = SECUREC_MAX_64BITS_POS_VALUE;
1293 if (spec->beyondMax != 0) {
1294 spec->number64 = SECUREC_MAX_64BITS_VALUE;
1299 if (spec->negative != 0) {
1301 if (spec->oriConvChr != 'p') {
1302spec->number64 = (SecUnsignedInt64)(0U - spec->number64); /* Wrap with unsigned int64 numbers */
1305spec->number64 = (SecUnsignedInt64)(0U - spec->number64); /* Wrap with unsigned int64 numbers */
1393 SECUREC_INLINE int SecDecodeLeadByte(SecScanSpec *spec, const SecUnsignedChar **format, SecFileStre… argument
1397 int ch1 = (int)spec->ch;
1398 int ch2 = SecGetChar(stream, &(spec->charCount));
1399 spec->ch = (SecInt)ch2;
1402 SecUnGetChar(ch2, stream, &(spec->charCount));
1403 SecUnGetChar(ch1, stream, &(spec->charCount));
1413 int ch3 = (int)SecGetChar(stream, &(spec->charCount));
1414 spec->ch = (SecInt)ch3;
1416 SecUnGetChar(ch3, stream, &(spec->charCount));
1426 --spec->charCount;
1428 SecUnGetChar(ch3, stream, &(spec->charCount));
1431 --spec->charCount; /* Only count as one character read */
1435 SecUnGetChar(spec->ch, stream, &(spec->charCount));
1497 SECUREC_INLINE int SecInputForWchar(SecScanSpec *spec) argument
1499 void *endPtr = spec->argPtr;
1500 if (spec->isWCharOrLong > 0) {
1501 *(wchar_t UNALIGNED *)endPtr = (wchar_t)spec->ch;
1503 --spec->arrayWidth;
1508 SECUREC_MASK_MSVC_CRT_WARNING temp = wctomb(tmpBuf, (wchar_t)spec->ch);
1514 if (((size_t)(unsigned int)temp) > spec->arrayWidth) {
1517 if (memcpy_s(endPtr, spec->arrayWidth, tmpBuf, (size_t)(unsigned int)temp) != EOK) {
1521 spec->arrayWidth -= (size_t)(unsigned int)temp;
1526 spec->argPtr = endPtr;
1533 SECUREC_INLINE wchar_t SecConvertInputCharToWchar(SecScanSpec *spec, SecFileStream *stream) argument
1538 temp[0] = (char)spec->ch;
1541 if (SecIsLeadByte(spec->ch) != 0) {
1542 spec->ch = SecGetChar(stream, &(spec->charCount));
1543 temp[1] = (char)spec->ch;
1551 if (SecIsLeadByte(spec->ch) != 0) {
1556 spec->ch = SecGetChar(stream, &(spec->charCount));
1557 temp[di] = (char)spec->ch;
1572 …(void)spec; /* To clear e438 last value assigned not used , the compiler will optimize this c…
1580 SECUREC_INLINE int SecInputForChar(SecScanSpec *spec, SecFileStream *stream) argument
1582 void *endPtr = spec->argPtr;
1583 if (spec->isWCharOrLong > 0) {
1585 *(wchar_t UNALIGNED *)endPtr = SecConvertInputCharToWchar(spec, stream);
1587 --spec->arrayWidth;
1593 *(char *)endPtr = (char)spec->ch;
1595 --spec->arrayWidth;
1597 spec->argPtr = endPtr;
1606 SECUREC_INLINE int SecInputNumberDigital(SecFileStream *stream, SecScanSpec *spec) argument
1608 static void (*secFinishNumber[SECUREC_DECODE_NUMBER_FUNC_NUM])(SecScanSpec *spec) = {
1611 while (SECUREC_FILED_WIDTH_ENOUGH(spec)) {
1612 spec->ch = SecGetChar(stream, &(spec->charCount));
1614 if (SecDecodeNumber(spec) != 0) {
1615 SecUnGetChar(spec->ch, stream, &(spec->charCount));
1618 … SECUREC_FILED_WIDTH_DEC(spec); /* Must be behind un get char, otherwise the logic is incorrect */
1619 spec->numberState = SECUREC_NUMBER_STATE_STARTED;
1622 (*secFinishNumber[spec->numberArgType])(spec);
1623 if (spec->numberState == SECUREC_NUMBER_STATE_STARTED) {
1633 SECUREC_INLINE int SecInputNumber(SecFileStream *stream, SecScanSpec *spec) argument
1636 if (spec->ch == SECUREC_CHAR('+') || spec->ch == SECUREC_CHAR('-')) {
1637 if (spec->ch == SECUREC_CHAR('-')) {
1638 spec->negative = 1;
1641 if (SECUREC_CONVERT_IS_UNSIGNED(spec->oriConvChr)) {
1646 SECUREC_FILED_WIDTH_DEC(spec); /* Do not need to check width here, must be greater than 0 */
1647 spec->ch = SecGetChar(stream, &(spec->charCount)); /* Eat + or - */
1648spec->ch = SecGetChar(stream, &(spec->charCount)); /* Get next character, used for the '0' judgmen…
1649 …SecUnGetChar(spec->ch, stream, &(spec->charCount)); /* Not sure if it was actually read, so push b…
1652 if (spec->oriConvChr == 'i') {
1653 spec->convChr = 'd'; /* The i could be d, o, or x, use d as default */
1656 if (spec->ch == SECUREC_CHAR('0') && (spec->oriConvChr == 'x' || spec->oriConvChr == 'i') &&
1657 SECUREC_FILED_WIDTH_ENOUGH(spec)) {
1659 SECUREC_FILED_WIDTH_DEC(spec);
1660 spec->ch = SecGetChar(stream, &(spec->charCount)); /* ch is '0' */
1663 if (!SECUREC_FILED_WIDTH_ENOUGH(spec)) {
1664 /* The number or number64 in spec has been set 0 */
1668spec->ch = SecGetChar(stream, &(spec->charCount)); /* Get next char to check x or X, do not dec wi…
1669 if ((SecChar)spec->ch == SECUREC_CHAR('x') || (SecChar)spec->ch == SECUREC_CHAR('X')) {
1670 spec->convChr = 'x';
1671 SECUREC_FILED_WIDTH_DEC(spec); /* Make incorrect width for x or X */
1673 if (spec->oriConvChr == 'i') {
1674 spec->convChr = 'o';
1677 SecUnGetChar(spec->ch, stream, &(spec->charCount));
1679 spec->numberState = SECUREC_NUMBER_STATE_STARTED;
1682 return SecInputNumberDigital(stream, spec);
1689 SECUREC_INLINE int SecInputString(SecFileStream *stream, SecScanSpec *spec, argument
1692 void *startPtr = spec->argPtr;
1696 while (SECUREC_FILED_WIDTH_ENOUGH(spec)) {
1697 SECUREC_FILED_WIDTH_DEC(spec);
1698 spec->ch = SecGetChar(stream, &(spec->charCount));
1703 if (spec->ch != SECUREC_EOF && (SecCanInputCharacter(spec->convChr) != 0 ||
1704 SecCanInputString(spec->convChr, spec->ch) != 0 ||
1705 SecCanInputForBracket(spec->convChr, spec->ch, bracketTable) != 0)) {
1706 if (spec->suppress != 0) {
1712 if (spec->arrayWidth == 0) {
1717 errNoMem = SecInputForWchar(spec);
1719 errNoMem = SecInputForChar(spec, stream);
1725 SecUnGetChar(spec->ch, stream, &(spec->charCount));
1732 SecAddEndingZero(startPtr, spec);
1735 if ((spec->suppress != 0 && suppressed == 0) ||
1736 (spec->suppress == 0 && startPtr == spec->argPtr)) {
1740 if (spec->convChr != 'c') {
1742 SecAddEndingZero(spec->argPtr, spec);
1744 if (spec->suppress == 0) {
1793 SecScanSpec spec; local
1803 spec.ch = 0; /* Need to initialize to 0 */
1804 spec.charCount = 0; /* Need to initialize to 0 */
1811 spec.ch = SecSkipSpaceChar(stream, &(spec.charCount));
1814 SecUnGetChar(spec.ch, stream, &(spec.charCount));
1820 spec.ch = SecGetChar(stream, &(spec.charCount));
1821 if ((int)(*format) != (int)(spec.ch)) {
1822 SecUnGetChar(spec.ch, stream, &(spec.charCount));
1827 if (SecIsLeadByte(spec.ch) != 0) {
1828 if (SecDecodeLeadByte(&spec, &format, stream) != 0) {
1838 SecSetDefaultScanSpec(&spec);
1839 if (SecDecodeScanFlag(&format, &spec) != 0) {
1844 if (!SECUREC_FILED_WIDTH_ENOUGH(&spec)) {
1851 SecUpdateWcharFlagByType(*format, &spec);
1853 spec.convChr = SECUREC_TO_LOWERCASE(*format);
1854 spec.oriConvChr = spec.convChr; /* convChr may be modified to handle integer logic */
1855 if (spec.convChr != 'n') {
1856 if (spec.convChr != 'c' && spec.convChr != SECUREC_BRACE) {
1857 spec.ch = SecSkipSpaceChar(stream, &(spec.charCount));
1859 spec.ch = SecGetChar(stream, &(spec.charCount));
1861 if (spec.ch == SECUREC_EOF) {
1868 switch (spec.oriConvChr) {
1870 if (spec.widthSet == 0) {
1871 spec.widthSet = 1;
1872 spec.width = 1;
1879 SecUnGetChar(spec.ch, stream, &(spec.charCount));
1881 if (spec.suppress == 0) {
1882 spec.argPtr = (void *)va_arg(argList, void *);
1883 if (spec.argPtr == NULL) {
1891 spec.arrayWidth = ((size_t)(va_arg(argList, size_t))) & 0xffffffffUL;
1893 spec.arrayWidth = (size_t)va_arg(argList, size_t);
1895 if (SECUREC_ARRAY_WIDTH_IS_WRONG(spec)) {
1901 if (spec.convChr != 'c') {
1902 --spec.arrayWidth;
1906 spec.argPtr = NULL;
1909 if (spec.convChr == SECUREC_BRACE) {
1925 SecAddEndingZero(spec.argPtr, &spec);
1933 if (SecInputString(stream, &spec, &bracketTable, &doneCount) != 0) {
1940 spec.numberWidth = SECUREC_NUM_WIDTH_INT;
1942 spec.numberArgType = 1;
1951 SecUnGetChar(spec.ch, stream, &(spec.charCount));
1952 if (SecInputNumber(stream, &spec) != 0) {
1956 if (spec.suppress == 0) {
1957 spec.argPtr = (void *)va_arg(argList, void *);
1958 if (spec.argPtr == NULL) {
1963 SecAssignNumber(&spec);
1968 if (spec.suppress == 0) {
1969 spec.argPtr = (void *)va_arg(argList, void *);
1970 if (spec.argPtr == NULL) {
1975 spec.number = (unsigned long)(unsigned int)(spec.charCount);
1976 spec.numberArgType = 0;
1977 SecAssignNumber(&spec);
1984 SecUnGetChar(spec.ch, stream, &(spec.charCount));
1986 if (SecInputFloat(stream, &spec, &floatSpec) != 0) {
1990 if (spec.suppress == 0) {
1991 spec.argPtr = (void *)va_arg(argList, void *);
1992 if (spec.argPtr == NULL) {
1998 if (SecAssignFloatW(&floatSpec, &spec) != 0) {
2003 SecAssignFloat(floatSpec.floatStr, spec.numberWidth, spec.argPtr);
2013 if ((int)(*format) != (int)spec.ch) {
2014 SecUnGetChar(spec.ch, stream, &(spec.charCount));
2039 if (spec.ch == SECUREC_EOF) {