void fpecatch(int sig) { extern Node *curnode; char buf[1024]; snprintf(buf, sizeof buf, "floating point exception\n"); write(STDERR_FILENO, buf, strlen(buf)); if (compile_time != 2 && NR && *NR > 0) { snprintf(buf, sizeof buf, " input record number %d", (int) (*FNR)); write(STDERR_FILENO, buf, strlen(buf)); if (strcmp(*FILENAME, "-") != 0) { snprintf(buf, sizeof buf, ", file %s", *FILENAME); write(STDERR_FILENO, buf, strlen(buf)); } write(STDERR_FILENO, "\n", 1); } if (compile_time != 2 && curnode) { snprintf(buf, sizeof buf, " source line number %d", curnode->lineno); write(STDERR_FILENO, buf, strlen(buf)); } else if (compile_time != 2 && lineno) { snprintf(buf, sizeof buf, " source line number %d", lineno); write(STDERR_FILENO, buf, strlen(buf)); } if (compile_time == 1 && cursource() != NULL) { snprintf(buf, sizeof buf, " source file %s", cursource()); write(STDERR_FILENO, buf, strlen(buf)); } write(STDERR_FILENO, "\n", 1); if (dbg > 1) /* core dump if serious debugging on */ abort(); _exit(1); }
void error() { extern Node *curnode; fprintf(stderr, "\n"); if (compile_time != 2 && NR && *NR > 0) { fprintf(stderr, " input record number %d", (int) (*FNR)); if (strcmp(*FILENAME, "-") != 0) fprintf(stderr, ", file %s", *FILENAME); fprintf(stderr, "\n"); } if (compile_time != 2 && curnode) fprintf(stderr, " source line number %d", curnode->lineno); else if (compile_time != 2 && lineno) fprintf(stderr, " source line number %d", lineno); if (compile_time == 1 && cursource() != NULL) fprintf(stderr, " source file %s", cursource()); fprintf(stderr, "\n"); eprint(); }
void SYNTAX(const char *fmt, ...) { extern char *cmdname, *curfname; static int been_here = 0; va_list varg; if (been_here++ > 2) return; fprintf(stderr, "%s: ", cmdname); va_start(varg, fmt); vfprintf(stderr, fmt, varg); va_end(varg); fprintf(stderr, " at source line %d", lineno); if (curfname != NULL) fprintf(stderr, " in function %s", curfname); if (compile_time == 1 && cursource() != NULL) fprintf(stderr, " source file %s", cursource()); fprintf(stderr, "\n"); errorflag = 2; eprint(); }