diff options
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r-- | generic/tclTest.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c index 0d35b7a..53fa384 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -1295,7 +1295,7 @@ TestcmdtokenCmd( nextCommandTokenRefId++; refPtr->nextPtr = firstCommandTokenRef; firstCommandTokenRef = refPtr; - sprintf(buf, "%d", refPtr->id); + snprintf(buf, sizeof(buf), "%d", refPtr->id); Tcl_AppendResult(interp, buf, NULL); } else { if (sscanf(argv[2], "%d", &id) != 1) { @@ -2758,7 +2758,7 @@ ExitProcOdd( char buf[16 + TCL_INTEGER_SPACE]; int len; - sprintf(buf, "odd %d\n", (int)PTR2INT(clientData)); + snprintf(buf, sizeof(buf), "odd %d\n", (int)PTR2INT(clientData)); len = strlen(buf); if (len != (int) write(1, buf, len)) { Tcl_Panic("ExitProcOdd: unable to write to stdout"); @@ -2772,7 +2772,7 @@ ExitProcEven( char buf[16 + TCL_INTEGER_SPACE]; int len; - sprintf(buf, "even %d\n", (int)PTR2INT(clientData)); + snprintf(buf, sizeof(buf), "even %d\n", (int)PTR2INT(clientData)); len = strlen(buf); if (len != (int) write(1, buf, len)) { Tcl_Panic("ExitProcEven: unable to write to stdout"); @@ -2817,7 +2817,7 @@ TestexprlongCmd( if (result != TCL_OK) { return result; } - sprintf(buf, ": %ld", exprResult); + snprintf(buf, sizeof(buf), ": %ld", exprResult); Tcl_AppendResult(interp, buf, NULL); return TCL_OK; } @@ -2859,7 +2859,7 @@ TestexprlongobjCmd( if (result != TCL_OK) { return result; } - sprintf(buf, ": %ld", exprResult); + snprintf(buf, sizeof(buf), ": %ld", exprResult); Tcl_AppendResult(interp, buf, NULL); return TCL_OK; } @@ -4533,7 +4533,7 @@ TestregexpObjCmd( varName = Tcl_GetString(objv[2]); TclRegExpRangeUniChar(regExpr, TCL_INDEX_NONE, &start, &end); - sprintf(resinfo, "%d %d", start, end-1); + snprintf(resinfo, sizeof(resinfo), "%d %d", start, end-1); value = Tcl_SetVar2(interp, varName, NULL, resinfo, 0); if (value == NULL) { Tcl_AppendResult(interp, "couldn't set variable \"", @@ -4547,7 +4547,7 @@ TestregexpObjCmd( Tcl_RegExpGetInfo(regExpr, &info); varName = Tcl_GetString(objv[2]); - sprintf(resinfo, "%ld", info.extendStart); + snprintf(resinfo, sizeof(resinfo), "%ld", info.extendStart); value = Tcl_SetVar2(interp, varName, NULL, resinfo, 0); if (value == NULL) { Tcl_AppendResult(interp, "couldn't set variable \"", @@ -5320,7 +5320,7 @@ TestgetvarfullnameCmd( * * This procedure implements the "gettimes" command. It is used for * computing the time needed for various basic operations such as reading - * variables, allocating memory, sprintf, converting variables, etc. + * variables, allocating memory, snprintf, converting variables, etc. * * Results: * A standard Tcl result. @@ -5439,15 +5439,15 @@ GetTimesObjCmd( fprintf(stderr, " %.3f usec per Tcl_GetInt of \"12345\"\n", timePer/100000); - /* sprintf 100000 times */ - fprintf(stderr, "sprintf of 12345 100000 times\n"); + /* snprintf 100000 times */ + fprintf(stderr, "snprintf of 12345 100000 times\n"); Tcl_GetTime(&start); for (i = 0; i < 100000; i++) { - sprintf(newString, "%d", 12345); + snprintf(newString, sizeof(newString), "%d", 12345); } Tcl_GetTime(&stop); timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec); - fprintf(stderr, " %.3f usec per sprintf of 12345\n", + fprintf(stderr, " %.3f usec per snprintf of 12345\n", timePer/100000); /* hashtable lookup 100000 times */ @@ -6124,7 +6124,7 @@ TestChannelCmd( Tcl_Channel chan; /* The opaque type. */ size_t len; /* Length of subcommand string. */ int IOQueued; /* How much IO is queued inside channel? */ - char buf[TCL_INTEGER_SPACE];/* For sprintf. */ + char buf[TCL_INTEGER_SPACE];/* For snprintf. */ int mode; /* rw mode of the channel */ if (argc < 2) { @@ -7038,10 +7038,10 @@ TestGetIndexFromObjStructObjCmd( return TCL_ERROR; } else if (idx[1] != target) { char buffer[64]; - sprintf(buffer, "%d", idx[1]); + snprintf(buffer, sizeof(buffer), "%d", idx[1]); Tcl_AppendResult(interp, "index value comparison failed: got ", buffer, NULL); - sprintf(buffer, "%d", target); + snprintf(buffer, sizeof(buffer), "%d", target); Tcl_AppendResult(interp, " when ", buffer, " expected", NULL); return TCL_ERROR; } |