summaryrefslogtreecommitdiffstats
path: root/macosx/tclMacOSXFCmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tclMacOSXFCmd.c')
-rw-r--r--macosx/tclMacOSXFCmd.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c
index 064f9e3..e27fdff 100644
--- a/macosx/tclMacOSXFCmd.c
+++ b/macosx/tclMacOSXFCmd.c
@@ -84,11 +84,11 @@ static int SetOSTypeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void UpdateStringOfOSType(Tcl_Obj *objPtr);
static const Tcl_ObjType tclOSTypeType = {
- "osType", /* name */
- NULL, /* freeIntRepProc */
- NULL, /* dupIntRepProc */
- UpdateStringOfOSType, /* updateStringProc */
- SetOSTypeFromAny /* setFromAnyProc */
+ "osType", /* name */
+ NULL, /* freeIntRepProc */
+ NULL, /* dupIntRepProc */
+ UpdateStringOfOSType, /* updateStringProc */
+ SetOSTypeFromAny /* setFromAnyProc */
};
enum {
@@ -131,10 +131,10 @@ typedef struct {
int
TclMacOSXGetFileAttribute(
- Tcl_Interp *interp, /* The interp we are using for errors. */
- int objIndex, /* The index of the attribute. */
- Tcl_Obj *fileName, /* The name of the file (UTF-8). */
- Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
+ Tcl_Interp *interp, /* The interp we are using for errors. */
+ int objIndex, /* The index of the attribute. */
+ Tcl_Obj *fileName, /* The name of the file (UTF-8). */
+ Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
#ifdef HAVE_GETATTRLIST
int result;
@@ -192,18 +192,18 @@ TclMacOSXGetFileAttribute(
OSSwapBigToHostInt32(finder->type));
break;
case MACOSX_HIDDEN_ATTRIBUTE:
- *attributePtrPtr = Tcl_NewBooleanObj(
+ TclNewIntObj(*attributePtrPtr,
(finder->fdFlags & kFinfoIsInvisible) != 0);
break;
case MACOSX_RSRCLENGTH_ATTRIBUTE:
- *attributePtrPtr = Tcl_NewWideIntObj(*rsrcForkSize);
+ TclNewIntObj(*attributePtrPtr, *rsrcForkSize);
break;
}
return TCL_OK;
#else
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Mac OS X file attributes not supported", -1));
- Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", (char *)NULL);
return TCL_ERROR;
#endif /* HAVE_GETATTRLIST */
}
@@ -335,7 +335,7 @@ TclMacOSXSetFileAttribute(
if (newRsrcForkSize != 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"setting nonzero rsrclength not supported", -1));
- Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", (char *)NULL);
return TCL_ERROR;
}
@@ -376,7 +376,7 @@ TclMacOSXSetFileAttribute(
#else
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Mac OS X file attributes not supported", -1));
- Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "UNSUPPORTED", (char *)NULL);
return TCL_ERROR;
#endif
}
@@ -517,7 +517,7 @@ TclMacOSXMatchType(
bzero(&alist, sizeof(struct attrlist));
alist.bitmapcount = ATTR_BIT_MAP_COUNT;
alist.commonattr = ATTR_CMN_FNDRINFO;
- if (getattrlist(pathName, &alist, &finfo, sizeof(fileinfobuf), 0) != 0) {
+ if (getattrlist(pathName, &alist, &finfo, sizeof(fileinfobuf), 0)) {
return 0;
}
if ((types->perm & TCL_GLOB_PERM_HIDDEN) &&
@@ -636,18 +636,19 @@ SetOSTypeFromAny(
Tcl_Obj *objPtr) /* Pointer to the object to convert */
{
const char *string;
- int length, result = TCL_OK;
+ int result = TCL_OK;
Tcl_DString ds;
Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
+ int length;
- string = Tcl_GetStringFromObj(objPtr, &length);
+ string = TclGetStringFromObj(objPtr, &length);
Tcl_UtfToExternalDString(encoding, string, length, &ds);
if (Tcl_DStringLength(&ds) > 4) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected Macintosh OS type but got \"%s\": ", string));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "MAC_OSTYPE", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "MAC_OSTYPE", (char *)NULL);
}
result = TCL_ERROR;
} else {
@@ -656,9 +657,9 @@ SetOSTypeFromAny(
memcpy(bytes, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
osType = (OSType) bytes[0] << 24 |
- (OSType) bytes[1] << 16 |
- (OSType) bytes[2] << 8 |
- (OSType) bytes[3];
+ (OSType) bytes[1] << 16 |
+ (OSType) bytes[2] << 8 |
+ (OSType) bytes[3];
TclFreeIntRep(objPtr);
objPtr->internalRep.longValue = (long) osType;
objPtr->typePtr = &tclOSTypeType;
@@ -689,22 +690,22 @@ SetOSTypeFromAny(
static void
UpdateStringOfOSType(
- Tcl_Obj *objPtr) /* OSType object whose string rep to
+ Tcl_Obj *objPtr) /* OSType object whose string rep to
* update. */
{
- char string[5];
OSType osType = (OSType) objPtr->internalRep.longValue;
Tcl_DString ds;
Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman");
unsigned len;
-
- string[0] = (char) (osType >> 24);
- string[1] = (char) (osType >> 16);
- string[2] = (char) (osType >> 8);
- string[3] = (char) (osType);
- string[4] = '\0';
- Tcl_ExternalToUtfDString(encoding, string, -1, &ds);
- len = (unsigned) Tcl_DStringLength(&ds) + 1;
+ char src[5];
+
+ src[0] = (char) (osType >> 24);
+ src[1] = (char) (osType >> 16);
+ src[2] = (char) (osType >> 8);
+ src[3] = (char) (osType);
+ src[4] = '\0';
+ Tcl_ExternalToUtfDString(encoding, src, -1, &ds);
+ len = (unsigned)Tcl_DStringLength(&ds) + 1;
objPtr->bytes = ckalloc(len);
memcpy(objPtr->bytes, Tcl_DStringValue(&ds), len);
objPtr->length = Tcl_DStringLength(&ds);