summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-11-11 19:32:12 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-11-11 19:32:12 (GMT)
commite811f452678383f5d77a7848bef5d10c62d62925 (patch)
tree482aff3ad09aaa3302505eb6f172cd9d2e770ff0 /generic/tclBinary.c
parent8139a5f733d5abf740e17c45a33dee8b607d2f7b (diff)
downloadtcl-e811f452678383f5d77a7848bef5d10c62d62925.zip
tcl-e811f452678383f5d77a7848bef5d10c62d62925.tar.gz
tcl-e811f452678383f5d77a7848bef5d10c62d62925.tar.bz2
[Patch 1830038]: Increased usage of macros to detect and take advantage of objTypes.
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 2cfaff5..bf81665 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBinary.c,v 1.37 2007/11/09 18:50:54 hobbs Exp $
+ * RCS: @(#) $Id: tclBinary.c,v 1.38 2007/11/11 19:32:14 msofer Exp $
*/
#include "tclInt.h"
@@ -397,7 +397,7 @@ SetByteArrayFromAny(
Tcl_UniChar ch;
if (objPtr->typePtr != &tclByteArrayType) {
- src = Tcl_GetStringFromObj(objPtr, &length);
+ src = TclGetStringFromObj(objPtr, &length);
srcEnd = src + length;
byteArrayPtr = (ByteArray *) ckalloc(BYTEARRAY_SIZE(length));
@@ -609,7 +609,7 @@ Tcl_BinaryObjCmd(
* places the formatted data into the buffer.
*/
- format = Tcl_GetString(objv[2]);
+ format = TclGetString(objv[2]);
arg = 3;
offset = 0;
length = 0;
@@ -695,10 +695,13 @@ Tcl_BinaryObjCmd(
int listc;
Tcl_Obj **listv;
- if (Tcl_ListObjGetElements(interp, objv[arg++], &listc,
+ /* The macro evals its args more than once: avoid arg++ */
+ if (TclListObjGetElements(interp, objv[arg], &listc,
&listv) != TCL_OK) {
return TCL_ERROR;
}
+ arg++;
+
if (count == BINARY_ALL) {
count = listc;
} else if (count > listc) {
@@ -774,7 +777,7 @@ Tcl_BinaryObjCmd(
*/
arg = 3;
- format = Tcl_GetString(objv[2]);
+ format = TclGetString(objv[2]);
cursor = buffer;
maxPos = cursor;
while (*format != 0) {
@@ -812,7 +815,8 @@ Tcl_BinaryObjCmd(
case 'B': {
unsigned char *last;
- str = Tcl_GetStringFromObj(objv[arg++], &length);
+ str = TclGetStringFromObj(objv[arg], &length);
+ arg++;
if (count == BINARY_ALL) {
count = length;
} else if (count == BINARY_NOCOUNT) {
@@ -873,7 +877,8 @@ Tcl_BinaryObjCmd(
unsigned char *last;
int c;
- str = Tcl_GetStringFromObj(objv[arg++], &length);
+ str = TclGetStringFromObj(objv[arg], &length);
+ arg++;
if (count == BINARY_ALL) {
count = length;
} else if (count == BINARY_NOCOUNT) {
@@ -973,7 +978,7 @@ Tcl_BinaryObjCmd(
listc = 1;
count = 1;
} else {
- Tcl_ListObjGetElements(interp, objv[arg], &listc, &listv);
+ TclListObjGetElements(interp, objv[arg], &listc, &listv);
if (count == BINARY_ALL) {
count = listc;
}
@@ -1035,7 +1040,7 @@ Tcl_BinaryObjCmd(
numberCachePtr = &numberCacheHash;
Tcl_InitHashTable(numberCachePtr, TCL_ONE_WORD_KEYS);
buffer = Tcl_GetByteArrayFromObj(objv[2], &length);
- format = Tcl_GetString(objv[3]);
+ format = TclGetString(objv[3]);
cursor = buffer;
arg = 4;
offset = 0;
@@ -1126,7 +1131,7 @@ Tcl_BinaryObjCmd(
src = buffer + offset;
valuePtr = Tcl_NewObj();
Tcl_SetObjLength(valuePtr, count);
- dest = Tcl_GetString(valuePtr);
+ dest = TclGetString(valuePtr);
if (cmd == 'b') {
for (i = 0; i < count; i++) {
@@ -1182,7 +1187,7 @@ Tcl_BinaryObjCmd(
src = buffer + offset;
valuePtr = Tcl_NewObj();
Tcl_SetObjLength(valuePtr, count);
- dest = Tcl_GetString(valuePtr);
+ dest = TclGetString(valuePtr);
if (cmd == 'h') {
for (i = 0; i < count; i++) {
@@ -1726,7 +1731,7 @@ FormatNumber(
case 'i':
case 'I':
case 'n':
- if (Tcl_GetLongFromObj(interp, src, &value) != TCL_OK) {
+ if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
return TCL_ERROR;
}
if (NeedReversing(type)) {
@@ -1748,7 +1753,7 @@ FormatNumber(
case 's':
case 'S':
case 't':
- if (Tcl_GetLongFromObj(interp, src, &value) != TCL_OK) {
+ if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
return TCL_ERROR;
}
if (NeedReversing(type)) {
@@ -1764,7 +1769,7 @@ FormatNumber(
* 8-bit integer values.
*/
case 'c':
- if (Tcl_GetLongFromObj(interp, src, &value) != TCL_OK) {
+ if (TclGetLongFromObj(interp, src, &value) != TCL_OK) {
return TCL_ERROR;
}
*(*cursorPtr)++ = (unsigned char) value;