PERFORCE change 12822 for review

[email protected] (Chris Nandor) Fri, 2 Nov 2001 17:47:24 -0500
Newsgroups perl.perl5.changes.mac
Message-ID <p05100304b808d2f0c858@[10.0.1.177]>
Change 12822 by pudge@pudge-mobile on 2001/11/02 21:38:22

	Several fixes for various exit problems and clearing out
	task queue, as well as another (incomplete) go at
	fixing error message handling

Affected files ...

.... //depot/maint-5.6/macperl/macos/macish.c#8 edit
.... //depot/maint-5.6/macperl/macos/macish.h#9 edit
.... //depot/maint-5.6/macperl/macos/macperl/MPConsole.cp#3 edit

Differences ...

==== //depot/maint-5.6/macperl/macos/macish.c#8 (text) ====
Index: perl/macos/macish.c
--- perl/macos/macish.c.~1~	Fri Nov  2 14:45:06 2001
+++ perl/macos/macish.c	Fri Nov  2 14:45:06 2001
@@ -811,6 +811,17 @@
 	}
 }
 
+void MacPerl_ClearAsyncTasks()
+{
+	QElemPtr			elem;
+	MacPerl_AsyncTask * task;
+	
+	gMacPerl_HasAsyncTasks = false;
+	while (elem = sMacPerlAsyncQueue.qHead) {
+		Dequeue(elem, &sMacPerlAsyncQueue);
+	}
+}
+
 /*
  * Asynchronous tasks come in handy to exit gracefully from the middle of a script
  */
@@ -893,6 +904,8 @@
 {
 	gMacPerl_StartClock = LMGetTicks();
 
+	MacPerl_ClearAsyncTasks();
+
 	sSpinControl.fTask.fPending		=  	false;
 	sSpinControl.fTask.fProc		= 	StartSpinControl;
 
@@ -910,11 +923,11 @@
 		gMacPerl_Perl5DB = val;
 }
 
-static const char * strnstr(const char * msg, const char * str, size_t len)
+static const char * strnstr(const char * msg, const char * str, int len)
 {
 	char s1 = *str++;
 	
-	while (len--)
+	while (len-- > 0)
 		if (*msg++ == s1) {
 			const char * s = str;
 			const char * m = msg;
@@ -961,6 +974,10 @@
 
 	/* Look for " line \d" */
 	while (line = strnstr(line+1, " line ", msg+len-line-1)) {
+		/* Invariants:
+		 * To process: [msg, msg+len[
+		 * msg < line < msg+len
+		 */
 		if (line[6] >= '0' && line[6] <= '9') {
 			/* Got line, now look for end of line number */
 			const char * endline = line+7;
@@ -981,6 +998,7 @@
 			at	= strnstr(msg, " at ", line-msg-1);
 	
 			if (at) {
+				/* msg <= at < line */
 				const char * anotherat;
 				
 				/* Look for intervening "at". This part gives misleading results if the filename

==== //depot/maint-5.6/macperl/macos/macish.h#9 (text) ====
Index: perl/macos/macish.h
--- perl/macos/macish.h.~1~	Fri Nov  2 14:45:06 2001
+++ perl/macos/macish.h	Fri Nov  2 14:45:06 2001
@@ -221,7 +221,6 @@
 	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)
 

==== //depot/maint-5.6/macperl/macos/macperl/MPConsole.cp#3 (text) ====
Index: perl/macos/macperl/MPConsole.cp
--- perl/macos/macperl/MPConsole.cp.~1~	Fri Nov  2 14:45:06 2001
+++ perl/macos/macperl/MPConsole.cp	Fri Nov  2 14:45:06 2001
@@ -5,6 +5,12 @@
 Language	:	MPW C/C++
 
 $Log: MPConsole.cp,v $
+Revision 1.6  2001/11/02 22:36:17  pudge
+Sync with perforce
+
+Revision 1.5  2001/10/29 10:38:01  neeri
+Another go at our perennial favorite (MacPerl Bug #422129)
+
 Revision 1.4  2001/10/11 05:19:31  neeri
 Fix exit code (MacPerl bug #422129)
 
@@ -599,14 +605,14 @@
 
 /********************* A kinder, gentler, spin **********************/
 
-extern "C" void Perl_my_exit(int status);
-
 bool MPConsoleSpin(bool /* wait */)
 {
 	if (gAborting && gRunningPerl) {
 		ResetConsole();
 
-		MacPerl_Exit(-128);
+		raise(SIGINT);
+		// don't raise SIGINT again
+		gAborting = false;
 	} 
 		
 	// 
End of Patch.