slang/slang-2.1.2-slerr.patch
Miroslav Lichvar 5181fc8a8d - fix integer underflow in compute_hash (#302181)
- fix SLang_set_error when called from signal handler (#297661)
2007-09-25 15:36:31 +00:00

78 lines
1.8 KiB
Diff

Index: slang/src/slerr.c
===================================================================
--- slang/src/slerr.c (revision 199)
+++ slang/src/slerr.c (revision 200)
@@ -384,6 +384,8 @@
}
Error_Message_Type;
+static char *Static_Error_Message = NULL;
+
struct _pSLerr_Error_Queue_Type
{
Error_Message_Type *head;
@@ -531,12 +533,11 @@
free_queued_messages (q);
}
-#if 0
- if (_pSLang_Error != SL_Usage_Error)
+ if (Static_Error_Message != NULL)
{
- print_error (_SLERR_MSG_ERROR, SLerr_strerror (_pSLang_Error));
+ print_error (_SLERR_MSG_ERROR, Static_Error_Message);
+ Static_Error_Message = NULL;
}
-#endif
}
/* This function returns a pointer to the first error message in the queue.
@@ -615,6 +616,7 @@
void _pSLerr_free_queued_messages (void)
{
+ Static_Error_Message = NULL;
free_queued_messages (Active_Error_Queue);
}
@@ -626,7 +628,10 @@
*/
if ((error == 0)
|| (_pSLang_Error == 0))
- _pSLang_Error = error;
+ {
+ Static_Error_Message = NULL;
+ _pSLang_Error = error;
+ }
if (_pSLinterpreter_Error_Hook != NULL)
(*_pSLinterpreter_Error_Hook) (_pSLang_Error);
@@ -707,9 +712,19 @@
{
set_error (error);
- if (_pSLang_Error == 0)
+ if (error == 0)
return 0;
+ if (error == SL_UserBreak_Error)
+ {
+ /* This function may be called from a SIGINT handler, in which case the
+ * error code will be SL_Usage_Error.
+ */
+ /* print_error (_SLERR_MSG_ERROR, SLerr_strerror (_pSLang_Error)); */
+ Static_Error_Message = SLerr_strerror (error);
+ return 0;
+ }
+
/* If a string is not in the message queue, then add one. */
if (Active_Error_Queue != NULL)
{
@@ -806,5 +821,6 @@
Suspend_Error_Messages = 0;
Default_Error_Queue = NULL;
Active_Error_Queue = NULL;
+ Static_Error_Message = NULL;
}