changed awk and sed to use qse_setintrhandler()
This commit is contained in:
		| @ -18,8 +18,9 @@ endif | ||||
| bin_PROGRAMS = qseawk | ||||
|  | ||||
| qseawk_SOURCES = awk.c | ||||
| qseawk_LDFLAGS = -L../../lib/awk -L../../lib/cmn  | ||||
| qseawk_LDADD = -lqseawk -lqsecmn $(LIBM) $(LIBLTDL)  | ||||
| qseawk_CFLAGS = $(PTHREAD_CFLAGS) | ||||
| qseawk_LDFLAGS = -L../../lib/awk -L../../lib/sys -L../../lib/cmn  | ||||
| qseawk_LDADD = -lqseawk -lqsesys -lqsecmn $(LIBM) $(LIBLTDL) $(PTHREAD_LIBS) | ||||
|  | ||||
| if WIN32 | ||||
| if WCHAR | ||||
|  | ||||
| @ -107,18 +107,19 @@ CONFIG_CLEAN_FILES = | ||||
| CONFIG_CLEAN_VPATH_FILES = | ||||
| am__installdirs = "$(DESTDIR)$(bindir)" | ||||
| PROGRAMS = $(bin_PROGRAMS) | ||||
| am_qseawk_OBJECTS = awk.$(OBJEXT) | ||||
| am_qseawk_OBJECTS = qseawk-awk.$(OBJEXT) | ||||
| qseawk_OBJECTS = $(am_qseawk_OBJECTS) | ||||
| am__DEPENDENCIES_1 = | ||||
| @WCHAR_TRUE@@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) | ||||
| qseawk_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ | ||||
| 	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) | ||||
| 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ | ||||
| 	$(am__DEPENDENCIES_1) | ||||
| AM_V_lt = $(am__v_lt_@AM_V@) | ||||
| am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | ||||
| am__v_lt_0 = --silent | ||||
| am__v_lt_1 =  | ||||
| qseawk_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||||
| 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||||
| 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(qseawk_CFLAGS) $(CFLAGS) \ | ||||
| 	$(qseawk_LDFLAGS) $(LDFLAGS) -o $@ | ||||
| AM_V_P = $(am__v_P_@AM_V@) | ||||
| am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) | ||||
| @ -360,9 +361,11 @@ AUTOMAKE_OPTIONS = nostdinc | ||||
| AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ | ||||
| 	$(LTDLINCL) $(am__append_1) $(am__append_2) | ||||
| qseawk_SOURCES = awk.c | ||||
| qseawk_LDFLAGS = -L../../lib/awk -L../../lib/cmn $(am__append_4) | ||||
| qseawk_LDADD = -lqseawk -lqsecmn $(LIBM) $(LIBLTDL) $(am__append_3) \ | ||||
| 	$(am__append_5) | ||||
| qseawk_CFLAGS = $(PTHREAD_CFLAGS) | ||||
| qseawk_LDFLAGS = -L../../lib/awk -L../../lib/sys -L../../lib/cmn \ | ||||
| 	$(am__append_4) | ||||
| qseawk_LDADD = -lqseawk -lqsesys -lqsecmn $(LIBM) $(LIBLTDL) \ | ||||
| 	$(PTHREAD_LIBS) $(am__append_3) $(am__append_5) | ||||
| all: all-am | ||||
|  | ||||
| .SUFFIXES: | ||||
| @ -457,7 +460,7 @@ mostlyclean-compile: | ||||
| distclean-compile: | ||||
| 	-rm -f *.tab.c | ||||
|  | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk.Po@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qseawk-awk.Po@am__quote@ | ||||
|  | ||||
| .c.o: | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||||
| @ -480,6 +483,20 @@ distclean-compile: | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< | ||||
|  | ||||
| qseawk-awk.o: awk.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qseawk_CFLAGS) $(CFLAGS) -MT qseawk-awk.o -MD -MP -MF $(DEPDIR)/qseawk-awk.Tpo -c -o qseawk-awk.o `test -f 'awk.c' || echo '$(srcdir)/'`awk.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/qseawk-awk.Tpo $(DEPDIR)/qseawk-awk.Po | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='awk.c' object='qseawk-awk.o' libtool=no @AMDEPBACKSLASH@ | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qseawk_CFLAGS) $(CFLAGS) -c -o qseawk-awk.o `test -f 'awk.c' || echo '$(srcdir)/'`awk.c | ||||
|  | ||||
| qseawk-awk.obj: awk.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qseawk_CFLAGS) $(CFLAGS) -MT qseawk-awk.obj -MD -MP -MF $(DEPDIR)/qseawk-awk.Tpo -c -o qseawk-awk.obj `if test -f 'awk.c'; then $(CYGPATH_W) 'awk.c'; else $(CYGPATH_W) '$(srcdir)/awk.c'; fi` | ||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/qseawk-awk.Tpo $(DEPDIR)/qseawk-awk.Po | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='awk.c' object='qseawk-awk.obj' libtool=no @AMDEPBACKSLASH@ | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qseawk_CFLAGS) $(CFLAGS) -c -o qseawk-awk.obj `if test -f 'awk.c'; then $(CYGPATH_W) 'awk.c'; else $(CYGPATH_W) '$(srcdir)/awk.c'; fi` | ||||
|  | ||||
| mostlyclean-libtool: | ||||
| 	-rm -f *.lo | ||||
|  | ||||
|  | ||||
| @ -36,6 +36,7 @@ | ||||
| #include <qse/cmn/glob.h> | ||||
| #include <qse/cmn/sio.h> | ||||
| #include <qse/cmn/fmt.h> | ||||
| #include <qse/sys/intr.h> | ||||
|  | ||||
| #include <string.h> | ||||
| #include <signal.h> | ||||
| @ -49,11 +50,7 @@ | ||||
| #if defined(_WIN32) | ||||
| #	include <winsock2.h> | ||||
| #	include <windows.h> | ||||
| #	include <tchar.h> | ||||
| #	include <process.h> | ||||
| #elif defined(__OS2__) | ||||
| #	define INCL_DOSPROCESS | ||||
| #	define INCL_DOSEXCEPTIONS | ||||
| #	define INCL_ERRORS | ||||
| #	include <os2.h> | ||||
| #elif defined(__DOS__) | ||||
| @ -122,57 +119,7 @@ static void dprint (const qse_char_t* fmt, ...) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| #if defined(_WIN32) | ||||
| static BOOL WINAPI stop_run (DWORD ctrl_type) | ||||
| { | ||||
| 	if (ctrl_type == CTRL_C_EVENT || | ||||
| 	    ctrl_type == CTRL_CLOSE_EVENT) | ||||
| 	{ | ||||
| 		qse_awk_rtx_stop (app_rtx); | ||||
| 		return TRUE; | ||||
| 	} | ||||
|  | ||||
| 	return FALSE; | ||||
| } | ||||
| #elif defined(__OS2__) | ||||
|  | ||||
| static ULONG _System stop_run ( | ||||
| 	PEXCEPTIONREPORTRECORD p1, | ||||
| 	PEXCEPTIONREGISTRATIONRECORD p2, | ||||
| 	PCONTEXTRECORD p3, | ||||
| 	PVOID pv) | ||||
| { | ||||
| 	if (p1->ExceptionNum == XCPT_SIGNAL) | ||||
| 	{ | ||||
| 		if (p1->ExceptionInfo[0] == XCPT_SIGNAL_INTR || | ||||
| 		    p1->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC || | ||||
| 		    p1->ExceptionInfo[0] == XCPT_SIGNAL_BREAK) | ||||
| 		{ | ||||
| 			APIRET rc; | ||||
|  | ||||
| 			qse_awk_rtx_stop (app_rtx); | ||||
| 			rc = DosAcknowledgeSignalException (p1->ExceptionInfo[0]); | ||||
| 			return (rc != NO_ERROR)? 1: XCPT_CONTINUE_EXECUTION;  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return XCPT_CONTINUE_SEARCH; /* exception not resolved */ | ||||
| } | ||||
|  | ||||
| #elif defined(__DOS__) | ||||
|  | ||||
| static void setsignal (int sig, void(*handler)(int)) | ||||
| { | ||||
| 	signal (sig, handler); | ||||
| } | ||||
|  | ||||
| static void stop_run (int sig) | ||||
| { | ||||
| 	qse_awk_rtx_stop (app_rtx); | ||||
| } | ||||
|  | ||||
| #else | ||||
|  | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) && defined(SIGPIPE) | ||||
| static int setsignal (int sig, void(*handler)(int), int restart) | ||||
| { | ||||
| 	struct sigaction sa_int; | ||||
| @ -196,50 +143,33 @@ static int setsignal (int sig, void(*handler)(int), int restart) | ||||
| 	} | ||||
| 	return sigaction (sig, &sa_int, NULL); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| static void stop_run (int sig) | ||||
| static void stop_run (void* arg) | ||||
| { | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) | ||||
| 	int e = errno; | ||||
| #endif | ||||
|  | ||||
| 	qse_awk_rtx_stop (app_rtx); | ||||
|  | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) | ||||
| 	errno = e; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #if defined(__OS2__) | ||||
| static EXCEPTIONREGISTRATIONRECORD os2_excrr = { 0 }; | ||||
| #endif | ||||
|  | ||||
| static void set_intr_run (void) | ||||
| { | ||||
| #if defined(_WIN32) | ||||
| 	SetConsoleCtrlHandler (stop_run, TRUE); | ||||
| #elif defined(__OS2__) | ||||
| 	APIRET rc; | ||||
| 	os2_excrr.ExceptionHandler = (ERR)stop_run; | ||||
| 	rc = DosSetExceptionHandler (&os2_excrr); | ||||
| 	/*if (rc != NO_ERROR)...*/ | ||||
| #elif defined(__DOS__) | ||||
| 	setsignal (SIGINT, stop_run); | ||||
| #else | ||||
| 	/*setsignal (SIGINT, stop_run, 1); TO BE MORE COMPATIBLE WITH WIN32*/ | ||||
| 	setsignal (SIGINT, stop_run, 0); | ||||
| 	qse_setintrhandler (stop_run, QSE_NULL); | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) && defined(SIGPIPE) | ||||
| 	setsignal (SIGPIPE, SIG_IGN, 0); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static void unset_intr_run (void) | ||||
| { | ||||
| #if defined(_WIN32) | ||||
| 	SetConsoleCtrlHandler (stop_run, FALSE); | ||||
| #elif defined(__OS2__) | ||||
| 	APIRET rc; | ||||
| 	rc = DosUnsetExceptionHandler (&os2_excrr); | ||||
| 	/*if (rc != NO_ERROR) ...*/ | ||||
| #elif defined(__DOS__) | ||||
| 	setsignal (SIGINT, SIG_DFL); | ||||
| #else | ||||
| 	setsignal (SIGINT, SIG_DFL, 1); | ||||
| 	qse_clearintrhandler (); | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) && defined(SIGPIPE) | ||||
| 	setsignal (SIGPIPE, SIG_DFL, 0); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| @ -7,8 +7,9 @@ AM_CPPFLAGS = \ | ||||
| bin_PROGRAMS = qsesed | ||||
|  | ||||
| qsesed_SOURCES = sed.c | ||||
| qsesed_LDFLAGS = -L../../lib/sed -L../../lib/cmn  | ||||
| qsesed_LDADD = -lqsesed -lqsecmn | ||||
| qsesed_CFLAGS = $(PTHREAD_CFLAGS) | ||||
| qsesed_LDFLAGS = -L../../lib/sed -L../../lib/sys -L../../lib/cmn  | ||||
| qsesed_LDADD = -lqsesed -lqsesys -lqsecmn $(PTHREAD_LIBS) | ||||
|  | ||||
| if WIN32  | ||||
| if WCHAR | ||||
|  | ||||
| @ -100,17 +100,17 @@ CONFIG_CLEAN_FILES = | ||||
| CONFIG_CLEAN_VPATH_FILES = | ||||
| am__installdirs = "$(DESTDIR)$(bindir)" | ||||
| PROGRAMS = $(bin_PROGRAMS) | ||||
| am_qsesed_OBJECTS = sed.$(OBJEXT) | ||||
| am_qsesed_OBJECTS = qsesed-sed.$(OBJEXT) | ||||
| qsesed_OBJECTS = $(am_qsesed_OBJECTS) | ||||
| am__DEPENDENCIES_1 = | ||||
| @WCHAR_TRUE@@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) | ||||
| qsesed_DEPENDENCIES = $(am__DEPENDENCIES_2) | ||||
| qsesed_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) | ||||
| AM_V_lt = $(am__v_lt_@AM_V@) | ||||
| am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | ||||
| am__v_lt_0 = --silent | ||||
| am__v_lt_1 =  | ||||
| qsesed_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||||
| 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||||
| 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(qsesed_CFLAGS) $(CFLAGS) \ | ||||
| 	$(qsesed_LDFLAGS) $(LDFLAGS) -o $@ | ||||
| AM_V_P = $(am__v_P_@AM_V@) | ||||
| am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) | ||||
| @ -354,8 +354,10 @@ AM_CPPFLAGS = \ | ||||
| 	-I$(top_srcdir)/include  | ||||
|  | ||||
| qsesed_SOURCES = sed.c | ||||
| qsesed_LDFLAGS = -L../../lib/sed -L../../lib/cmn  | ||||
| qsesed_LDADD = -lqsesed -lqsecmn $(am__append_1) | ||||
| qsesed_CFLAGS = $(PTHREAD_CFLAGS) | ||||
| qsesed_LDFLAGS = -L../../lib/sed -L../../lib/sys -L../../lib/cmn  | ||||
| qsesed_LDADD = -lqsesed -lqsesys -lqsecmn $(PTHREAD_LIBS) \ | ||||
| 	$(am__append_1) | ||||
| all: all-am | ||||
|  | ||||
| .SUFFIXES: | ||||
| @ -450,7 +452,7 @@ mostlyclean-compile: | ||||
| distclean-compile: | ||||
| 	-rm -f *.tab.c | ||||
|  | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed.Po@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qsesed-sed.Po@am__quote@ | ||||
|  | ||||
| .c.o: | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||||
| @ -473,6 +475,20 @@ distclean-compile: | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< | ||||
|  | ||||
| qsesed-sed.o: sed.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qsesed_CFLAGS) $(CFLAGS) -MT qsesed-sed.o -MD -MP -MF $(DEPDIR)/qsesed-sed.Tpo -c -o qsesed-sed.o `test -f 'sed.c' || echo '$(srcdir)/'`sed.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/qsesed-sed.Tpo $(DEPDIR)/qsesed-sed.Po | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='sed.c' object='qsesed-sed.o' libtool=no @AMDEPBACKSLASH@ | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qsesed_CFLAGS) $(CFLAGS) -c -o qsesed-sed.o `test -f 'sed.c' || echo '$(srcdir)/'`sed.c | ||||
|  | ||||
| qsesed-sed.obj: sed.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qsesed_CFLAGS) $(CFLAGS) -MT qsesed-sed.obj -MD -MP -MF $(DEPDIR)/qsesed-sed.Tpo -c -o qsesed-sed.obj `if test -f 'sed.c'; then $(CYGPATH_W) 'sed.c'; else $(CYGPATH_W) '$(srcdir)/sed.c'; fi` | ||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/qsesed-sed.Tpo $(DEPDIR)/qsesed-sed.Po | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='sed.c' object='qsesed-sed.obj' libtool=no @AMDEPBACKSLASH@ | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(qsesed_CFLAGS) $(CFLAGS) -c -o qsesed-sed.obj `if test -f 'sed.c'; then $(CYGPATH_W) 'sed.c'; else $(CYGPATH_W) '$(srcdir)/sed.c'; fi` | ||||
|  | ||||
| mostlyclean-libtool: | ||||
| 	-rm -f *.lo | ||||
|  | ||||
|  | ||||
| @ -37,17 +37,14 @@ | ||||
| #include <qse/cmn/mbwc.h> | ||||
| #include <qse/cmn/glob.h> | ||||
| #include <qse/cmn/fmt.h> | ||||
| #include <qse/sys/intr.h> | ||||
|  | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
|  | ||||
| #if defined(_WIN32) | ||||
| #	include <windows.h> | ||||
| #	include <tchar.h> | ||||
| #	include <process.h> | ||||
| #elif defined(__OS2__) | ||||
| #	define INCL_DOSPROCESS | ||||
| #	define INCL_DOSEXCEPTIONS | ||||
| #	define INCL_ERRORS | ||||
| #	include <os2.h> | ||||
| #	include <signal.h> | ||||
| @ -71,7 +68,7 @@ static struct | ||||
| 	0, | ||||
| 	0 | ||||
| }; | ||||
| 	 | ||||
|  | ||||
| static qse_char_t* g_output_file = QSE_NULL; | ||||
| static int g_infile_pos = 0; | ||||
| static int g_option = 0; | ||||
| @ -462,57 +459,8 @@ void print_exec_error (qse_sed_t* sed) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| #if defined(_WIN32) | ||||
| static BOOL WINAPI stop_run (DWORD ctrl_type) | ||||
| { | ||||
| 	if (ctrl_type == CTRL_C_EVENT || | ||||
| 	    ctrl_type == CTRL_CLOSE_EVENT) | ||||
| 	{ | ||||
| 		qse_sed_stop (g_sed); | ||||
| 		return TRUE; | ||||
| 	} | ||||
|  | ||||
| 	return FALSE; | ||||
| } | ||||
| #elif defined(__OS2__) | ||||
|  | ||||
| static ULONG _System stop_run ( | ||||
| 	PEXCEPTIONREPORTRECORD p1, | ||||
| 	PEXCEPTIONREGISTRATIONRECORD p2, | ||||
| 	PCONTEXTRECORD p3, | ||||
| 	PVOID pv) | ||||
| { | ||||
| 	if (p1->ExceptionNum == XCPT_SIGNAL) | ||||
| 	{ | ||||
| 		if (p1->ExceptionInfo[0] == XCPT_SIGNAL_INTR || | ||||
| 		    p1->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC || | ||||
| 		    p1->ExceptionInfo[0] == XCPT_SIGNAL_BREAK) | ||||
| 		{ | ||||
| 			APIRET rc; | ||||
|  | ||||
| 			qse_sed_stop (g_sed); | ||||
| 			rc = DosAcknowledgeSignalException (p1->ExceptionInfo[0]); | ||||
| 			return (rc != NO_ERROR)? 1: XCPT_CONTINUE_EXECUTION;  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return XCPT_CONTINUE_SEARCH; /* exception not resolved */ | ||||
| } | ||||
|  | ||||
| #elif defined(__DOS__) | ||||
|  | ||||
| static void setsignal (int sig, void(*handler)(int)) | ||||
| { | ||||
| 	signal (sig, handler); | ||||
| } | ||||
|  | ||||
| static void stop_run (int sig) | ||||
| { | ||||
| 	qse_sed_stop (g_sed); | ||||
| } | ||||
|  | ||||
| #else | ||||
|  | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) && defined(SIGPIPE) | ||||
| static int setsignal (int sig, void(*handler)(int), int restart) | ||||
| { | ||||
| 	struct sigaction sa_int; | ||||
| @ -536,52 +484,38 @@ static int setsignal (int sig, void(*handler)(int), int restart) | ||||
| 	} | ||||
| 	return sigaction (sig, &sa_int, NULL); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| static void stop_run (int sig) | ||||
| static void stop_run (void* arg) | ||||
| { | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) | ||||
| 	int e = errno; | ||||
| #endif | ||||
|  | ||||
| 	qse_sed_stop (g_sed); | ||||
|  | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) | ||||
| 	errno = e; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #if defined(__OS2__) | ||||
| static EXCEPTIONREGISTRATIONRECORD os2_excrr = { 0 }; | ||||
| #endif | ||||
|  | ||||
| static void set_intr_run (void) | ||||
| { | ||||
| #if defined(_WIN32) | ||||
| 	SetConsoleCtrlHandler (stop_run, TRUE); | ||||
| #elif defined(__OS2__) | ||||
| 	APIRET rc; | ||||
| 	os2_excrr.ExceptionHandler = (ERR)stop_run; | ||||
| 	rc = DosSetExceptionHandler (&os2_excrr); | ||||
| 	/*if (rc != NO_ERROR)...*/ | ||||
| #elif defined(__DOS__) | ||||
| 	setsignal (SIGINT, stop_run); | ||||
| #else | ||||
| 	/*setsignal (SIGINT, stop_run, 1); TO BE MORE COMPATIBLE WITH WIN32*/ | ||||
| 	setsignal (SIGINT, stop_run, 0); | ||||
| 	qse_setintrhandler (stop_run, QSE_NULL); | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) && defined(SIGPIPE) | ||||
| 	setsignal (SIGPIPE, SIG_IGN, 0); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static void unset_intr_run (void) | ||||
| { | ||||
| #if defined(_WIN32) | ||||
| 	SetConsoleCtrlHandler (stop_run, FALSE); | ||||
| #elif defined(__OS2__) | ||||
| 	APIRET rc; | ||||
| 	rc = DosUnsetExceptionHandler (&os2_excrr); | ||||
| 	/*if (rc != NO_ERROR) ...*/ | ||||
| #elif defined(__DOS__) | ||||
| 	setsignal (SIGINT, SIG_DFL); | ||||
| #else | ||||
| 	setsignal (SIGINT, SIG_DFL, 1); | ||||
| 	qse_clearintrhandler (); | ||||
| #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) && defined(SIGPIPE) | ||||
| 	setsignal (SIGPIPE, SIG_DFL, 0); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| #if defined(QSE_ENABLE_SEDTRACER) | ||||
| static void trace_exec (qse_sed_t* sed, qse_sed_tracer_op_t op, const qse_sed_cmd_t* cmd) | ||||
| { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user