diff options
author | das <das> | 2003-05-14 19:21:20 (GMT) |
---|---|---|
committer | das <das> | 2003-05-14 19:21:20 (GMT) |
commit | e7e62365449aec7d4e02ab0a58d7b185a74342e8 (patch) | |
tree | 18a23b38b5ab18b3714c78cd1f0f131855938b1f /mac/tclMacResource.c | |
parent | 12f7a06929318bdfae5af285f1502aa2f5d4aa86 (diff) | |
download | tcl-e7e62365449aec7d4e02ab0a58d7b185a74342e8.zip tcl-e7e62365449aec7d4e02ab0a58d7b185a74342e8.tar.gz tcl-e7e62365449aec7d4e02ab0a58d7b185a74342e8.tar.bz2 |
Implementation of TIP 118:
* generic/tclFCmd.c (TclFileAttrsCmd): return the list of attributes
that can be retrieved without error for a given file, instead of
aborting the whole command when any error occurs.
* unix/tclUnixFCmd.c: added support for new file attributes and for
copying Mac OS X file attributes & resource fork during [file copy].
* generic/tclInt.decls: added declarations of new external commands
needed by new file attributes support in tclUnixFCmd.c.
* macosx/tclMacOSXFCmd.c (new): Mac OS X specific implementation of
new file attributes and of attribute & resource fork copying.
* mac/tclMacFCmd.c: added implementation of -rsrclength attribute &
fixes to other attributes for consistency with OSX implementation.
* mac/tclMacResource.c: fixes to OSType handling.
* doc/file.n: documentation of [file attributes] changes.
* unix/configure.in: check for APIs needed by new file attributes.
* unix/Makefile.in:
* unix/tcl.m4: added new platform specifc tclMacOSXFCmd.c source.
* unix/configure:
* generic/tclStubInit.c:
* generic/tclIntPlatDecls.h: regen.
* tools/genStubs.tcl: fixes to completely broken code trying to
prevent overlap of "aqua", "macosx", "x11" and "unix" stub entries.
* tests/unixFCmd.test: added tests of -readonly attribute.
* tests/macOSXFCmd.test (new): tests of macosx file attributes and
of preservation of attributes & resource fork during [file copy].
* tests/macFCmd.test: restore -readonly attribute of test dir, as
otherwise its removal can fail on unices supporting -readonly.
Diffstat (limited to 'mac/tclMacResource.c')
-rw-r--r-- | mac/tclMacResource.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/mac/tclMacResource.c b/mac/tclMacResource.c index 78f0bc5..49e1110 100644 --- a/mac/tclMacResource.c +++ b/mac/tclMacResource.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: tclMacResource.c,v 1.14 2002/06/05 11:59:49 das Exp $ + * RCS: @(#) $Id: tclMacResource.c,v 1.15 2003/05/14 19:21:24 das Exp $ */ #include <Errors.h> @@ -1711,24 +1711,29 @@ SetOSTypeFromAny( Tcl_ObjType *oldTypePtr = objPtr->typePtr; char *string; int length; - long newOSType; + OSType newOSType = 0UL; + Tcl_DString ds; /* * Get the string representation. Make it up-to-date if necessary. */ string = Tcl_GetStringFromObj(objPtr, &length); + Tcl_UtfToExternalDString(NULL, string, length, &ds); - if (length != 4) { + if (Tcl_DStringLength(&ds) > sizeof(OSType)) { if (interp != NULL) { Tcl_ResetResult(interp); Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "expected Macintosh OS type but got \"", string, "\"", (char *) NULL); } + Tcl_DStringFree(&ds); return TCL_ERROR; } - newOSType = *((long *) string); + memcpy(&newOSType, Tcl_DStringValue(&ds), + (size_t) Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); /* * The conversion to resource type succeeded. Free the old internalRep @@ -1767,9 +1772,16 @@ static void UpdateStringOfOSType( register Tcl_Obj *objPtr) /* Int object whose string rep to update. */ { - objPtr->bytes = ckalloc(5); - sprintf(objPtr->bytes, "%-4.4s", &(objPtr->internalRep.longValue)); - objPtr->length = 4; + char string[sizeof(OSType)+1]; + Tcl_DString ds; + + memcpy(string, &(objPtr->internalRep.longValue), sizeof(OSType)); + string[sizeof(OSType)] = '\0'; + Tcl_ExternalToUtfDString(NULL, string, -1, &ds); + objPtr->bytes = ckalloc(Tcl_DStringLength(&ds) + 1); + memcpy(objPtr->bytes, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds) + 1); + objPtr->length = Tcl_DStringLength(&ds); + Tcl_DStringFree(&ds); } /* |