Tcl Source Code

Artifact [265b35d1c9]
Login

Artifact 265b35d1c9e8473c686496653dfb8eae13f35943:

Attachment "1194015.patch" to ticket [1194015fff] added by dgp 2005-07-06 01:15:23.
Index: generic/tclInt.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.decls,v
retrieving revision 1.89
diff -u -r1.89 tclInt.decls
--- generic/tclInt.decls	14 May 2005 20:46:44 -0000	1.89
+++ generic/tclInt.decls	5 Jul 2005 18:05:34 -0000
@@ -114,9 +114,10 @@
 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)
 }
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.240
diff -u -r1.240 tclInt.h
--- generic/tclInt.h	24 Jun 2005 20:07:21 -0000	1.240
+++ generic/tclInt.h	5 Jul 2005 18:05:34 -0000
@@ -2826,6 +2826,18 @@
 
 /*
  *----------------------------------------------------------------
+ * 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
Index: generic/tclIntDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIntDecls.h,v
retrieving revision 1.80
diff -u -r1.80 tclIntDecls.h
--- generic/tclIntDecls.h	14 May 2005 20:46:45 -0000	1.80
+++ generic/tclIntDecls.h	5 Jul 2005 18:05:34 -0000
@@ -170,11 +170,7 @@
 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 @@
     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 @@
 #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 */
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.118
diff -u -r1.118 tclStubInit.c
--- generic/tclStubInit.c	7 Jun 2005 02:07:27 -0000	1.118
+++ generic/tclStubInit.c	5 Jul 2005 18:05:34 -0000
@@ -103,7 +103,7 @@
     NULL, /* 21 */
     TclFindElement, /* 22 */
     TclFindProc, /* 23 */
-    TclFormatInt, /* 24 */
+    NULL, /* 24 */
     TclFreePackageInfo, /* 25 */
     NULL, /* 26 */
     NULL, /* 27 */
Index: generic/tclUtil.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclUtil.c,v
retrieving revision 1.60
diff -u -r1.60 tclUtil.c
--- generic/tclUtil.c	14 May 2005 20:46:46 -0000	1.60
+++ generic/tclUtil.c	5 Jul 2005 18:05:35 -0000
@@ -2196,91 +2196,6 @@
 /*
  *----------------------------------------------------------------------
  *
- * 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