PERFORCE change 12193 for review
[email protected] (Chris Nandor) Tue, 25 Sep 2001 00:07:04 -0400
| Newsgroups | perl.perl5.changes.mac |
|---|---|
| Message-ID | <p0510030bb7d5b3420a33@[10.0.1.177]> |
Change 12193 by pudge@pudge-mobile on 2001/09/25 02:53:42
Fixes for multiline error parsing (Bug #459263); cmd-.
not working, cursor not spinning (Bug #422129); external
editor problems (Bug #456329); escape/cmd-. not activating
"Cancel" in Save dialog box (Bug #446960); Runtimes not
executing on launch (Bug #464441).
Affected files ...
... //depot/maint-5.6/macperl/macos/macish.c#6 edit
... //depot/maint-5.6/macperl/macos/macish.h#6 edit
... //depot/maint-5.6/macperl/macos/macperl/MPEditor.c#2 edit
... //depot/maint-5.6/macperl/macos/macperl/MPGlobals.h#2 edit
... //depot/maint-5.6/macperl/macos/macperl/MPScript.c#2 edit
... //depot/maint-5.6/macperl/macos/macperl/MacPerl.r#3 edit
Differences ...
==== //depot/maint-5.6/macperl/macos/macish.c#6 (text) ====
Index: perl/macos/macish.c
--- perl/macos/macish.c.~1~ Mon Sep 24 21:00:06 2001
+++ perl/macos/macish.c Mon Sep 24 21:00:06 2001
@@ -18,6 +18,7 @@
#undef modff
#include <fp.h>
#include <LowMem.h>
+#include <Timer.h>
char **environ;
static char ** gEnviron;
@@ -775,9 +776,130 @@
return t->tms_utime;
}
+/********************* Asynchronous Event management ************
+ * MacPerl maintains an os queue of tasks to be executed at a
+ * reasonably "sane" time (in runops, to be more exact).
+ */
+
+static QHdr sMacPerlAsyncQueue;
+
+Boolean MacPerl_QueueAsyncTask(MacPerl_AsyncTask * task)
+{
+ if (task->fPending) /* Already queued. Race condition resolved below */
+ return false;
+ task->fPending = true;
+ if (!Dequeue((QElemPtr) task, &sMacPerlAsyncQueue)) /* Just in case somebody beat us in the race */
+ return false;
+ Enqueue((QElemPtr) task, &sMacPerlAsyncQueue);
+
+ gMacPerl_HasAsyncTasks = true; /* Flag for main loop to call async event processing */
+
+ return true;
+}
+
+void MacPerl_DoAsyncTasks()
+{
+ QElemPtr elem;
+ MacPerl_AsyncTask * task;
+
+ gMacPerl_HasAsyncTasks = false; /* Though this might be set again while we process */
+ while (elem = sMacPerlAsyncQueue.qHead) {
+ Dequeue(elem, &sMacPerlAsyncQueue);
+ task = (MacPerl_AsyncTask *) elem; /* Remove from queue */
+ task->fProc(task); /* Call procedure */
+ task->fPending = false; /* Allow it to be queued again */
+ }
+}
+
+/*
+ * Asynchronous tasks come in handy to exit gracefully from the middle of a script
+ */
+static MacPerl_AsyncTask sAsyncExit;
+static int sExitStatus;
+
+static void AsyncExit(MacPerl_AsyncTask * task)
+{
+ dTHX;
+
+ my_exit(sExitStatus);
+}
+
+void _exit(int status)
+{
+ if (MacPerl_QueueAsyncTask(&sAsyncExit))
+ sExitStatus = status;
+}
+
+/********************* Cursor Spin management *******************
+ * The other built in asynchronous task is cursor spinning.
+ */
+
+static struct SpinControlRec {
+ TMTask fTimer;
+ MacPerl_AsyncTask fTask;
+} sSpinControl;
+
+#define SPIN_FREQUENCY 200
+
+static void SpinTimer(struct SpinControlRec * spin)
+{
+ MacPerl_QueueAsyncTask(&spin->fTask); /* Queue task for a safe time */
+ PrimeTime((QElem *) &spin->fTimer, SPIN_FREQUENCY);
+}
+
+#if GENERATINGCFM
+static RoutineDescriptor uSpinTimer =
+ BUILD_ROUTINE_DESCRIPTOR(uppTimerProcInfo, SpinTimer);
+#elif defined(__MWERKS__)
+static pascal void uSpinTimer(struct SpinControlRec * param : __A1) { SpinTimer(param); }
+#else
+void * GetA1() ONEWORDINLINE(0x2009);
+static pascal void uSpinTimer() \
+ { SpinTimer((struct SpinControlRec *)GetA1()); }
+#endif
+
+static void SpinMacCursor(MacPerl_AsyncTask * task)
+{
+ sleep(0);
+}
+
+static void StopSpinControl()
+{
+ RmvTime((QElem *) &sSpinControl.fTimer);
+}
+
+/*
+ * It seeems that calling Perl_call_atexit at init time is suicidal, so
+ * we don't kick off the whole thing until we are well within the interpreter
+ */
+
+static void StartSpinControl(MacPerl_AsyncTask * task)
+{
+ dTHX;
+
+ sSpinControl.fTimer.tmAddr = (TimerUPP)&uSpinTimer;
+ sSpinControl.fTimer.tmCount = 0;
+ sSpinControl.fTimer.tmWakeUp = 0;
+ sSpinControl.fTimer.tmReserved = 0;
+ sSpinControl.fTask.fProc = SpinMacCursor;
+
+ InsTime((QElem *) &sSpinControl.fTimer);
+ PrimeTime((QElem *) &sSpinControl.fTimer, SPIN_FREQUENCY);
+
+ Perl_call_atexit(aTHX_ StopSpinControl, NULL);
+}
+
void MacPerl_init()
{
gMacPerl_StartClock = LMGetTicks();
+
+ sSpinControl.fTask.fPending = false;
+ sSpinControl.fTask.fProc = StartSpinControl;
+
+ sAsyncExit.fPending = false;
+ sAsyncExit.fProc = AsyncExit;
+
+ MacPerl_QueueAsyncTask(&sSpinControl.fTask);
}
void
@@ -842,11 +964,17 @@
if (line[6] >= '0' && line[6] <= '9') {
/* Got line, now look for end of line number */
const char * endline = line+7;
+ const char * newline;
- while (*endline >= '0' && *endline <= '9')
+ while (*endline >= '0' && *endline <= '9' && endline < msg+len)
++endline;
- if (*endline == ' ')
+ if (*endline == ' ' && endline < msg+len)
++endline;
+ for (newline = endline; *newline != '\n' && newline < msg+len; ++newline)
+ ;
+ if (*newline == '\n' && newline < msg+len)
+ ++newline;
+
/* Got it, now look for preceding " at ." length reduced by 1 because file name
* must be at least 1 character long.
*/
@@ -863,14 +991,19 @@
/* OK, we got them both, write the original message prefixed with # */
WriteMsg(io, msg, at-msg, true);
- WriteMsg(io, endline, msg+len-endline, false);
+ PerlIO_write(io, endline, newline-endline);
PerlIO_write(io, "File \'", 6);
PerlIO_write(io, at+4, line-at-4);
PerlIO_write(io, "\'; Line ", 8);
PerlIO_write(io, line+6, endline-line-6);
PerlIO_write(io, "\n", 1);
- return;
+ len -= newline-msg;
+ msg = newline;
+ line = msg;
+
+ if (!len) /* We're done */
+ return;
}
}
}
==== //depot/maint-5.6/macperl/macos/macish.h#6 (text) ====
Index: perl/macos/macish.h
--- perl/macos/macish.h.~1~ Mon Sep 24 21:00:06 2001
+++ perl/macos/macish.h Mon Sep 24 21:00:06 2001
@@ -206,6 +206,19 @@
#define PERL_SYS_TERM() MALLOC_TERM
#endif
+MP_EXT Boolean gMacPerl_HasAsyncTasks;
+void MacPerl_DoAsyncTasks();
+#define PERL_ASYNC_CHECK() while (gMacPerl_HasAsyncTasks) MacPerl_DoAsyncTasks()
+typedef struct MacPerl_AsyncTask {
+ void * qLink; /* Don't set */
+ short qType; /* Queue type. Ignore */
+ Boolean fPending; /* Is element queued already? */
+ Boolean fill;
+ void (*fProc)(struct MacPerl_AsyncTask * task); /* Procedure to call */
+} MacPerl_AsyncTask;
+Boolean MacPerl_QueueAsyncTask(MacPerl_AsyncTask * task);
+Boolean MacPerl_QueueAsyncExit();
+
#define PERL_WRITE_MSG_TO_CONSOLE(io, msg, len) MacPerl_WriteMsg(io, msg, len)
#define BIT_BUCKET "Dev:Null"
==== //depot/maint-5.6/macperl/macos/macperl/MPEditor.c#2 (text) ====
Index: perl/macos/macperl/MPEditor.c
--- perl/macos/macperl/MPEditor.c.~1~ Mon Sep 24 21:00:06 2001
+++ perl/macos/macperl/MPEditor.c Mon Sep 24 21:00:06 2001
@@ -6,6 +6,9 @@
Language : MPW C
$Log: MPEditor.c,v $
+Revision 1.2 2001/09/10 07:39:03 neeri
+External editor would sometimes corrupt files (MacPerl Bug #456329)
+
Revision 1.1 2000/11/30 08:37:29 neeri
Sources & Resources
@@ -475,7 +478,7 @@
HLock((Handle) gExternalFiles);
mycell.h = mycell.v = 0;
for (; mycell.v<gExternalFileCount; ++mycell.v) {
- StringPtr name = gExternalFiles[0][mycell.v].name;
+ StringPtr name = gExternalFiles[0][mycell.v << 1].name;
LSetCell(name+1, *name, mycell, gPickList);
}
HUnlock((Handle) gExternalFiles);
@@ -666,7 +669,7 @@
}
HSetState((Handle) gExternalFiles, state);
if (refCon != 2) {
- Munger((Handle) gExternalFiles, i*sizeof(FSSpec), nil, 2*sizeof(FSSpec), nil, 0);
+ Munger((Handle) gExternalFiles, (i<<1)*sizeof(FSSpec), nil, 2*sizeof(FSSpec), nil, 0);
if (!--gExternalFileCount) {
DisposeHandle((Handle) gExternalFiles);
gExternalFiles = 0;
==== //depot/maint-5.6/macperl/macos/macperl/MPGlobals.h#2 (text) ====
Index: perl/macos/macperl/MPGlobals.h
--- perl/macos/macperl/MPGlobals.h.~1~ Mon Sep 24 21:00:06 2001
+++ perl/macos/macperl/MPGlobals.h Mon Sep 24 21:00:06 2001
@@ -163,9 +163,9 @@
Save Changes Dialog Items
*/
-#define aaSave 1
-#define aaDiscard 2
-#define aaCancel 3
+#define aaSave 1
+#define aaCancel 2
+#define aaDiscard 3
#define kOSEvent app4Evt /*event used by MultiFinder*/
#define kSuspendResumeMessage 1 /*high byte of suspend/resume event message*/
==== //depot/maint-5.6/macperl/macos/macperl/MPScript.c#2 (text) ====
Index: perl/macos/macperl/MPScript.c
--- perl/macos/macperl/MPScript.c.~1~ Mon Sep 24 21:00:06 2001
+++ perl/macos/macperl/MPScript.c Mon Sep 24 21:00:06 2001
@@ -5,6 +5,9 @@
Language : MPW C
$Log: MPScript.c,v $
+Revision 1.5 2001/09/13 07:28:10 neeri
+Fix signal handling (MacPerlBug #422129)
+
Revision 1.4 2001/04/16 02:42:43 neeri
run_perl no longer longjmps (MacPerl bug #232703)
@@ -281,9 +284,8 @@
{
if (gRunningPerl)
longjmp(gExitPerl, -status-1);
- else {
+ else
ExitToShell();
- }
}
static atexitfn PerlExitFn[20];
@@ -293,9 +295,8 @@
{
if (gRunningPerl)
PerlExitFn[PerlExitCnt++] = func;
- else {
+ else
return atexit(func);
- }
return 0;
}
@@ -318,10 +319,6 @@
pascal void InitPerlEnviron()
{
- /* gDebugLogName = "Dev:Console:Debug Log";
- gExit = MP_Exit;
- gAtExit = MP_AtExit;
- */
gMacPerl_AlwaysExtract = true;
gMacPerl_HandleEvent = HandleEvent;
}
@@ -617,7 +614,6 @@
ShowWindowStatus();
- signal(SIGINT, exit);
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
@@ -1011,18 +1007,16 @@
pascal Boolean DoRuntime()
{
-#if 0
FSSpec spec;
if (gRuntimeScript = Get1NamedResource('TEXT', (StringPtr) "\p!")) {
spec.vRefNum = gAppVol;
- spec.parID = gAppDir;
+ spec.parID = gAppDir;
PLstrcpy(spec.name, LMGetCurApName());
strcpy(gMacPerl_PseudoFileName, GUSIFSp2FullPath(&spec));
-
+
DetachResource(gRuntimeScript);
}
-#endif
return false;
}
==== //depot/maint-5.6/macperl/macos/macperl/MacPerl.r#3 (text) ====
Index: perl/macos/macperl/MacPerl.r
--- perl/macos/macperl/MacPerl.r.~1~ Mon Sep 24 21:00:06 2001
+++ perl/macos/macperl/MacPerl.r Mon Sep 24 21:00:06 2001
@@ -9,6 +9,12 @@
Language : MPW C
$Log: MacPerl.r,v $
+Revision 1.8 2001/09/24 04:31:55 neeri
+Include cursors in build (MacPerl Bug #432129)
+
+Revision 1.7 2001/09/02 00:41:01 pudge
+Sync with perforce
+
Revision 1.6 2001/04/17 03:59:58 pudge
Minor version/config changes
@@ -185,6 +191,18 @@
include "MacPerl.rsrc" 'icm#'(265);
include "MacPerl.rsrc" 'icm#'(266);
+include "Perl.rsrc" 'CURS' (146);
+include "Perl.rsrc" 'CURS' (144);
+include "Perl.rsrc" 'CURS' (145);
+include "Perl.rsrc" 'CURS' (147);
+include "Perl.rsrc" 'CURS' (148);
+include "Perl.rsrc" 'CURS' (160);
+include "Perl.rsrc" 'CURS' (161);
+include "Perl.rsrc" 'CURS' (162);
+include "Perl.rsrc" 'CURS' (163);
+include "Perl.rsrc" 'acur' (0);
+include "Perl.rsrc" 'acur' (128);
+
#include "MPVersion.r";
resource 'vers' (1) {
@@ -275,7 +293,7 @@
reserved,
/* 3840 * 1024,
1536 * 1024 */
- 10 * 1024 * 1024,
+ 15 * 1024 * 1024,
2 * 1024 * 1024
};
@@ -479,8 +497,8 @@
resource 'DITL' (SaveAlert) {
{ { 74, 303, 94, 362}, Button { enabled, "Save"},
+ { 74, 231, 94, 290}, Button { enabled, "Cancel"},
{ 74, 65, 94, 150}, Button { enabled, "Don¹t Save"},
- { 74, 231, 94, 290}, Button { enabled, "Cancel"},
{ 10, 65, 59, 363}, StaticText {disabled, "Save changes to ³^0²?"},
{ 10, 20, 42, 52}, Icon {disabled, 2},
{ 0, 0, 0, 0}, HelpItem {disabled, HMScanhdlg { SaveAlert } },
End of Patch.