| ︙ | | |
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
-
+
|
Tcl_Interp *interp, /* Used for error reporting. May be NULL. */
Tcl_Obj *objPtr, /* Object to receive the internal rep. */
const char *expected, /* Description of the type of number the
* caller expects to be able to parse
* ("integer", "boolean value", etc.). */
const char *bytes, /* Pointer to the start of the string to
* scan. */
size_t numBytes, /* Maximum number of bytes to scan, see
Tcl_Size numBytes, /* Maximum number of bytes to scan, see
* above. */
const char **endPtrPtr, /* Place to store pointer to the character
* that terminated the scan. */
int flags) /* Flags governing the parse. */
{
enum State {
INITIAL, SIGNUM, ZERO, ZERO_X,
|
| ︙ | | |
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
-
+
-
+
|
* point in the parse. */
int numDigitsAfterDp = 0; /* Number of digits scanned after the decimal
* point. */
int exponentSignum = 0; /* Signum of the exponent of a floating point
* number. */
long exponent = 0; /* Exponent of a floating point number. */
const char *p; /* Pointer to next character to scan. */
size_t len; /* Number of characters remaining after p. */
Tcl_Size len; /* Number of characters remaining after p. */
const char *acceptPoint; /* Pointer to position after last character in
* an acceptable number. */
size_t acceptLen; /* Number of characters following that
Tcl_Size acceptLen; /* Number of characters following that
* point. */
int status = TCL_OK; /* Status to return to caller. */
char d = 0; /* Last hexadecimal digit scanned; initialized
* to avoid a compiler warning. */
int shift = 0; /* Amount to shift when accumulating binary */
mp_err err = MP_OKAY;
int under = 0; /* Flag trailing '_' as error if true once
|
| ︙ | | |
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
-
+
|
if (bytes == NULL) {
if (interp == NULL && endPtrPtr == NULL) {
if (TclHasInternalRep(objPtr, &tclDictType)) {
/* A dict can never be a (single) number */
return TCL_ERROR;
}
if (TclHasInternalRep(objPtr, &tclListType.objType)) {
size_t length;
Tcl_Size length;
/* A list can only be a (single) number if its length == 1 */
TclListObjLengthM(NULL, objPtr, &length);
if (length != 1) {
return TCL_ERROR;
}
}
}
|
| ︙ | | |
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
|
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
|
-
+
|
if (status != TCL_OK) {
if (interp != NULL) {
Tcl_Obj *msg = Tcl_ObjPrintf("expected %s but got \"",
expected);
Tcl_AppendLimitedToObj(msg, bytes, numBytes, 50, "");
Tcl_AppendToObj(msg, "\"", TCL_INDEX_NONE);
Tcl_AppendToObj(msg, "\"", -1);
Tcl_SetObjResult(interp, msg);
Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL);
}
}
/*
* Free memory.
|
| ︙ | | |
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
|
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
|
-
+
|
* Infinite values can't convert to bignum.
*/
if (isinf(d)) {
if (interp != NULL) {
const char *s = "integer value too large to represent";
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, TCL_INDEX_NONE));
Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1));
Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", s, NULL);
}
return TCL_ERROR;
}
fract = frexp(d, &expt);
if (expt <= 0) {
|
| ︙ | | |