summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXHLEvents.c
diff options
context:
space:
mode:
authordas <das>2009-08-24 00:56:00 (GMT)
committerdas <das>2009-08-24 00:56:00 (GMT)
commit28787944f9f2ad8e4c2cdc29106f88114026fd29 (patch)
tree1718b6cfd9d929cbe9db0be0b282003ab4082868 /macosx/tkMacOSXHLEvents.c
parent756e87236145fe779fef07a6d805766282070a58 (diff)
downloadtk-28787944f9f2ad8e4c2cdc29106f88114026fd29.zip
tk-28787944f9f2ad8e4c2cdc29106f88114026fd29.tar.gz
tk-28787944f9f2ad8e4c2cdc29106f88114026fd29.tar.bz2
* macosx/tkMacOSXHLEvents.c (ScriptHandler): Fix "do script" apple
* carbon/tkMacOSXHLEvents.c (ScriptHandler): event handler issues on recent OS X releases by using AE coercion to 'utf8' for text data and to 'fsrf' for alias data. (reported by Youness Alaoui on tcl-mac)
Diffstat (limited to 'macosx/tkMacOSXHLEvents.c')
-rw-r--r--macosx/tkMacOSXHLEvents.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 9fee118..6157d48 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.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: tkMacOSXHLEvents.c,v 1.21 2009/07/06 20:29:21 dkf Exp $
+ * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.22 2009/08/24 00:56:00 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -506,6 +506,7 @@ ScriptHandler(
{
OSStatus theErr;
AEDescList theDesc;
+ Size size;
int tclErr = -1;
Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon;
char errString[128];
@@ -531,66 +532,49 @@ ScriptHandler(
AEPutParamPtr(reply, keyErrorString, typeChar, errString,
strlen(errString));
theErr = -1771;
- } else if (theDesc.descriptorType == (DescType) typeChar) {
- /*
- * We've had some data sent to us. Evaluate it.
- */
-
- Tcl_DString encodedText;
- short i;
- Size size = AEGetDescDataSize(&theDesc);
- char *data = ckalloc(size + 1);
-
- AEGetDescData(&theDesc, data, size);
- data[size] = 0;
- for (i = 0; i < size; i++) {
- if (data[i] == '\r') {
- data[i] = '\n';
- }
- }
- AEReplaceDescData(theDesc.descriptorType, data, size + 1, &theDesc);
- Tcl_ExternalToUtfDString(NULL, data, size, &encodedText);
- tclErr = Tcl_EvalEx(interp, Tcl_DStringValue(&encodedText),
- Tcl_DStringLength(&encodedText), TCL_EVAL_GLOBAL);
- Tcl_DStringFree(&encodedText);
- } else if (theDesc.descriptorType == (DescType) typeAlias) {
+ } else if (theDesc.descriptorType == (DescType) typeAlias &&
+ AEGetParamPtr(event, keyDirectObject, typeFSRef, NULL, NULL,
+ 0, &size) == noErr && size == sizeof(FSRef)) {
/*
* We've had a file sent to us. Source it.
*/
- Boolean dummy;
FSRef file;
- Size theSize = AEGetDescDataSize(&theDesc);
- AliasPtr alias = (AliasPtr) ckalloc(theSize);
-
- if (alias) {
- AEGetDescData(&theDesc, alias, theSize);
-
- theErr = FSResolveAlias(NULL, &alias, &file, &dummy);
- ckfree((char*)alias);
- } else {
- theErr = memFullErr;
- }
+ theErr = AEGetParamPtr(event, keyDirectObject, typeFSRef, NULL, &file,
+ size, NULL);
if (theErr == noErr) {
Tcl_DString scriptName;
theErr = FSRefToDString(&file, &scriptName);
if (theErr == noErr) {
- Tcl_EvalFile(interp, Tcl_DStringValue(&scriptName));
+ tclErr = Tcl_EvalFile(interp, Tcl_DStringValue(&scriptName));
Tcl_DStringFree(&scriptName);
+ } else {
+ sprintf(errString, "AEDoScriptHandler: file not found");
+ AEPutParamPtr(reply, keyErrorString, typeChar, errString,
+ strlen(errString));
}
- } else {
- sprintf(errString, "AEDoScriptHandler: file not found");
- AEPutParamPtr(reply, keyErrorString, typeChar, errString,
- strlen(errString));
+ }
+ } else if (AEGetParamPtr(event, keyDirectObject, typeUTF8Text, NULL, NULL,
+ 0, &size) == noErr && size) {
+ /*
+ * We've had some data sent to us. Evaluate it.
+ */
+
+ char *data = ckalloc(size + 1);
+ theErr = AEGetParamPtr(event, keyDirectObject, typeUTF8Text, NULL, data,
+ size, NULL);
+ if (theErr == noErr) {
+ tclErr = Tcl_EvalEx(interp, data, size, TCL_EVAL_GLOBAL);
}
} else {
/*
* Umm, don't recognize what we've got...
*/
- sprintf(errString, "AEDoScriptHandler: invalid script type '%-4.4s',"
- " must be 'alis' or 'TEXT'", (char*) &theDesc.descriptorType);
+ sprintf(errString, "AEDoScriptHandler: invalid script type '%-4.4s', "
+ "must be 'alis' or coercable to 'utf8'",
+ (char*) &theDesc.descriptorType);
AEPutParamPtr(reply, keyErrorString, typeChar, errString,
strlen(errString));
theErr = -1770;
@@ -679,7 +663,7 @@ MissedAnyParameters(
Size actualSize;
OSStatus err;
- err = ChkErr(AEGetAttributePtr, theEvent, keyMissedKeywordAttr,
+ err = AEGetAttributePtr(theEvent, keyMissedKeywordAttr,
typeWildCard, &returnedType, NULL, 0, &actualSize);
return (err != errAEDescNotFound);