summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInt.decls9
-rw-r--r--generic/tclInt.h14
-rw-r--r--generic/tclIntDecls.h15
-rw-r--r--generic/tclStubInit.c4
-rw-r--r--generic/tclUtil.c87
5 files changed, 25 insertions, 104 deletions
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index f4f29c7..8af2153 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tclInt.decls,v 1.89 2005/05/14 20:46:44 das Exp $
+# RCS: @(#) $Id: tclInt.decls,v 1.90 2005/07/05 18:15:55 dgp Exp $
library tcl
@@ -114,9 +114,10 @@ declare 22 generic {
declare 23 generic {
Proc *TclFindProc(Interp *iPtr, CONST char *procName)
}
-declare 24 generic {
- int TclFormatInt(char *buffer, long n)
-}
+# Replaced with macro (see tclInt.h) in Tcl 8.5
+#declare 24 generic {
+# int TclFormatInt(char *buffer, long n)
+#}
declare 25 generic {
void TclFreePackageInfo(Interp *iPtr)
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 4219d86..7137443 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.240 2005/06/24 20:07:21 kennykb Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.241 2005/07/05 18:15:56 dgp Exp $
*/
#ifndef _TCLINT
@@ -2826,6 +2826,18 @@ MODULE_SCOPE void TclBNInitBignumFromLong( mp_int* bignum, long initVal );
/*
*----------------------------------------------------------------
+ * Macro used by the Tcl core to write the string rep of a long
+ * integer to a character buffer.
+ * The ANSI C "prototype" for this macro is:
+ *
+ * MODULE_SCOPE int TclFormatInt _ANSI_ARGS_((char *buf, long n));
+ *----------------------------------------------------------------
+ */
+
+#define TclFormatInt(buf, n) sprintf((buf), "%ld", (long)(n))
+
+/*
+ *----------------------------------------------------------------
* Macros used by the Tcl core to set a Tcl_Obj's numeric representation
* avoiding the corresponding function calls in time critical parts of the
* core. They should only be called on unshared objects. The ANSI C
diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h
index 3e5827e..b379778 100644
--- a/generic/tclIntDecls.h
+++ b/generic/tclIntDecls.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIntDecls.h,v 1.80 2005/05/14 20:46:45 das Exp $
+ * RCS: @(#) $Id: tclIntDecls.h,v 1.81 2005/07/05 18:15:56 dgp Exp $
*/
#ifndef _TCLINTDECLS
@@ -170,11 +170,7 @@ EXTERN int TclFindElement _ANSI_ARGS_((Tcl_Interp * interp,
EXTERN Proc * TclFindProc _ANSI_ARGS_((Interp * iPtr,
CONST char * procName));
#endif
-#ifndef TclFormatInt_TCL_DECLARED
-#define TclFormatInt_TCL_DECLARED
-/* 24 */
-EXTERN int TclFormatInt _ANSI_ARGS_((char * buffer, long n));
-#endif
+/* Slot 24 is reserved */
#ifndef TclFreePackageInfo_TCL_DECLARED
#define TclFreePackageInfo_TCL_DECLARED
/* 25 */
@@ -1200,7 +1196,7 @@ typedef struct TclIntStubs {
void *reserved21;
int (*tclFindElement) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * listStr, int listLength, CONST char ** elementPtr, CONST char ** nextPtr, int * sizePtr, int * bracePtr)); /* 22 */
Proc * (*tclFindProc) _ANSI_ARGS_((Interp * iPtr, CONST char * procName)); /* 23 */
- int (*tclFormatInt) _ANSI_ARGS_((char * buffer, long n)); /* 24 */
+ void *reserved24;
void (*tclFreePackageInfo) _ANSI_ARGS_((Interp * iPtr)); /* 25 */
void *reserved26;
void *reserved27;
@@ -1507,10 +1503,7 @@ extern TclIntStubs *tclIntStubsPtr;
#define TclFindProc \
(tclIntStubsPtr->tclFindProc) /* 23 */
#endif
-#ifndef TclFormatInt
-#define TclFormatInt \
- (tclIntStubsPtr->tclFormatInt) /* 24 */
-#endif
+/* Slot 24 is reserved */
#ifndef TclFreePackageInfo
#define TclFreePackageInfo \
(tclIntStubsPtr->tclFreePackageInfo) /* 25 */
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index fa9d4a5..5a9c60b 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStubInit.c,v 1.118 2005/06/07 02:07:27 dgp Exp $
+ * RCS: @(#) $Id: tclStubInit.c,v 1.119 2005/07/05 18:15:58 dgp Exp $
*/
#include "tclInt.h"
@@ -103,7 +103,7 @@ TclIntStubs tclIntStubs = {
NULL, /* 21 */
TclFindElement, /* 22 */
TclFindProc, /* 23 */
- TclFormatInt, /* 24 */
+ NULL, /* 24 */
TclFreePackageInfo, /* 25 */
NULL, /* 26 */
NULL, /* 27 */
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 2c787c2..248a38d 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.60 2005/05/14 20:46:46 das Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.61 2005/07/05 18:15:59 dgp Exp $
*/
#include "tclInt.h"
@@ -2196,91 +2196,6 @@ TclNeedSpace(start, end)
/*
*----------------------------------------------------------------------
*
- * TclFormatInt --
- *
- * This procedure formats an integer into a sequence of decimal digit
- * characters in a buffer. If the integer is negative, a minus sign is
- * inserted at the start of the buffer. A null character is inserted at
- * the end of the formatted characters. It is the caller's
- * responsibility to ensure that enough storage is available. This
- * procedure has the effect of sprintf(buffer, "%d", n) but is faster.
- *
- * Results:
- * An integer representing the number of characters formatted, not
- * including the terminating \0.
- *
- * Side effects:
- * The formatted characters are written into the storage pointer to
- * by the "buffer" argument.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TclFormatInt(buffer, n)
- char *buffer; /* Points to the storage into which the
- * formatted characters are written. */
- long n; /* The integer to format. */
-{
- long intVal;
- int i;
- int numFormatted, j;
- char *digits = "0123456789";
-
- /*
- * Check first whether "n" is zero.
- */
-
- if (n == 0) {
- buffer[0] = '0';
- buffer[1] = 0;
- return 1;
- }
-
- /*
- * Check whether "n" is the maximum negative value. This is
- * -2^(m-1) for an m-bit word, and has no positive equivalent;
- * negating it produces the same value.
- */
-
- if (n == -n) {
- sprintf(buffer, "%ld", n);
- return strlen(buffer);
- }
-
- /*
- * Generate the characters of the result backwards in the buffer.
- */
-
- intVal = (n < 0? -n : n);
- i = 0;
- buffer[0] = '\0';
- do {
- i++;
- buffer[i] = digits[intVal % 10];
- intVal = intVal/10;
- } while (intVal > 0);
- if (n < 0) {
- i++;
- buffer[i] = '-';
- }
- numFormatted = i;
-
- /*
- * Now reverse the characters.
- */
-
- for (j = 0; j < i; j++, i--) {
- char tmp = buffer[i];
- buffer[i] = buffer[j];
- buffer[j] = tmp;
- }
- return numFormatted;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TclLooksLikeInt --
*
* This procedure decides whether the leading characters of a