Beispiel #1
0
void knh_PleaseLetUsKnowYourOS(CTX ctx, const char *msg, const char *file, int line)
{
	if(CTX_isInteractive(ctx)) {
	fprintf(stderr,
		"\n\t==================================================================="
		"\n\t\t@%s:%d"
		"\n\t\t%s"
		"\n\t\tPlease let us know your platform (os, version, etc.)"
		"\n\t\t\t email: %s"
		"\n\t===================================================================\n",
		file, line, msg, K_EMAIL_BUG_REPORT);
	}
}
Beispiel #2
0
static void knh_setsignal(CTX ctx, void *block, size_t n)
#endif /* defined(K_USING_MINGW_) */
{
#if !defined(K_USING_MINGW_)
	struct sigaction sa = {};
	struct sigaction *sa_orig = (struct sigaction*)block;
#endif /* !defined(K_USING_MINGW_) */
	WCTX(ctx)->signal = 0;
	WCTX(ctx)->siginfo = NULL;

#ifndef K_USING_DEBUG
#if defined(K_USING_MINGW_)
	KNH_SIGNAL(SIGSEGV, trapSEGV);
	KNH_SIGNAL(SIGILL, trapILL);
#else
	sa.sa_sigaction = trapSEGV;
	sa.sa_flags     = SA_SIGINFO;
	KNH_SIGACTION(SIGSEGV, &sa, sa_orig, n);
	sa.sa_sigaction = trapILL;
	sa.sa_flags     = SA_SIGINFO;
	KNH_SIGACTION(SIGILL, &sa, sa_orig, n);
	sa.sa_sigaction = trapBUS;
	sa.sa_flags     = SA_SIGINFO;
	KNH_SIGACTION(SIGBUS, &sa, sa_orig, n);
#endif /* defined(K_USING_MINGW_) */
#endif

#if defined(K_USING_MINGW_)
	KNH_SIGNAL(SIGFPE, trapSIGFPE);
#else
	sa.sa_sigaction = trapSIGFPE;
	sa.sa_flags     = SA_SIGINFO|SA_NODEFER;
	KNH_SIGACTION(SIGFPE, &sa, sa_orig, n);
#endif /* defined(K_USING_MINGW_) */
	if(CTX_isInteractive(ctx)) {
		DBG_P("set SIGINT This is not so good");
#if defined(K_USING_MINGW_)
		KNH_SIGNAL(SIGINT, trapSIGINT);
#else
		sa.sa_sigaction = trapSIGINT;
		sa.sa_flags     = SA_SIGINFO|SA_NODEFER;
		KNH_SIGACTION(SIGINT, &sa, sa_orig, n);
#endif /* defined(K_USING_MINGW_) */
	}
}
Beispiel #3
0
static knh_String_t *Gamma_vperror(CTX ctx, int pe, const char *fmt, va_list ap)
{
	knh_String_t *msg = TS_EMPTY;
	int isPRINT = (pe <= KC_DWARN) ? 1 : 0;
	if(pe != KC_DEBUG && (CTX_isInteractive(ctx) || knh_isCompileOnly(ctx))) {
		isPRINT = 1;
	}
	if(Gamma_isQuiet(ctx->gma) || ctx->gma->uline == 0) {
		isPRINT = 0;
	}
	//DBG_P("/*isPRINT=%d*/ uline=%d", isPRINT, ctx->gma->uline);
	if(isPRINT == 1) {
		knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf);
		knh_write_uline(ctx, cwb->w, ctx->gma->uline);
		knh_write_ascii(ctx, cwb->w, KC__(pe));
		knh_vprintf(ctx, cwb->w, fmt, ap);
		msg = knh_cwb_newString(ctx, cwb);
		knh_Array_add(ctx, DP(ctx->gma)->errmsgs, msg);
		fprintf(stderr, "%s - %s%s\n", TERM_BNOTE(ctx, pe), S_tochar(msg), TERM_ENOTE(ctx, pe));
	}
	return msg;
}
Beispiel #4
0
static void knh_unsetsignal(CTX ctx, void *block, size_t n)
#endif /* defined(K_USING_MINGW_) */
{
#if !defined(K_USING_MINGW_)
	struct sigaction *sa_orig = (struct sigaction*)block;
	if(sa_orig != NULL) {
#endif /* !defined(K_USING_MINGW_) */
#ifndef K_USING_DEBUG
		KNH_SIGACTION2(SIGILL,  sa_orig, n);
#if !defined(K_USING_MINGW_)
		KNH_SIGACTION2(SIGBUS,  sa_orig, n);
#endif /* !defined(K_USING_MINGW_) */
		KNH_SIGACTION2(SIGSEGV, sa_orig, n);
#endif
		KNH_SIGACTION2(SIGFPE, sa_orig, n);
		if(CTX_isInteractive(ctx)) {
			KNH_SIGACTION2(SIGINT, sa_orig, n);
		}
#if !defined(K_USING_MINGW_)
	}
#endif /* !defined(K_USING_MINGW_) */
	WCTX(ctx)->signal = 0;
	WCTX(ctx)->siginfo = NULL;
}
Beispiel #5
0
void WARN_Semicolon(CTX ctx)
{
	if(!CTX_isInteractive(ctx)) Gamma_perror(ctx, KC_BAD, "needs ;");
}