diff --git a/C/adtdefs.c b/C/adtdefs.c index 342323be8..9006e7047 100644 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -21,6 +21,10 @@ static char SccsId[] = "%W% %G%"; #define ADTDEFS_C +#ifdef __SUNPRO_CC +#define inline +#endif + #include "Yap.h" Prop STD_PROTO(PredPropByFunc,(Functor, SMALLUNSGN)); Prop STD_PROTO(PredPropByAtom,(Atom, SMALLUNSGN)); diff --git a/C/alloc.c b/C/alloc.c index 5af303e06..095c7961f 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -12,7 +12,7 @@ * Last rev: * * mods: * * comments: allocating space * -* version:$Id: alloc.c,v 1.12 2002-01-26 05:37:31 vsc Exp $ * +* version:$Id: alloc.c,v 1.13 2002-02-22 06:12:18 vsc Exp $ * *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -451,12 +451,14 @@ InitWorkSpace(Int s) MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (a != (MALLOC_T)MMAP_ADDR) { Error(SYSTEM_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a); + return(NULL); } #elif defined(__APPLE__) a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); if (a != (MALLOC_T)MMAP_ADDR) { Error(SYSTEM_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR,a ); + return(NULL); } #else fd = open("/dev/zero", O_RDWR); @@ -470,7 +472,7 @@ InitWorkSpace(Int s) #else Error(SYSTEM_ERROR, TermNil, "mkstemp could not create temporary file %s", file); #endif - return FALSE; + return NULL; } #else #if HAVE_TMPNAM @@ -484,7 +486,7 @@ InitWorkSpace(Int s) fd = open(file, O_CREAT|O_RDWR); if (fd < 0) { Error(SYSTEM_ERROR, TermNil, "mmap could not open %s", file); - return FALSE; + return NULL; } if (lseek(fd, s, SEEK_SET) < 0) { Error(SYSTEM_ERROR, TermNil, "mmap could not lseek in mmapped file %s", file); @@ -492,11 +494,11 @@ InitWorkSpace(Int s) } if (write(fd, "", 1) < 0) { Error(SYSTEM_ERROR, TermNil, "mmap could not write in mmapped file %s", file); - return FALSE; + return NULL; } if (unlink(file) < 0) { Error(SYSTEM_ERROR,TermNil, "mmap could not unlink mmapped file %s", file); - return FALSE; + return NULL; } } #if USE_FIXED @@ -504,17 +506,19 @@ InitWorkSpace(Int s) MAP_PRIVATE | MAP_FIXED, fd, 0); if (a != (MALLOC_T)MMAP_ADDR) { Error(SYSTEM_ERROR, TermNil, "mmap could not map at %p, got %p", (void *)MMAP_ADDR, a); + return NULL; } #else a = mmap(0, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); if ((CELL)a & YAP_PROTECTED_MASK) { close(fd); - Error(FATAL_ERROR, TermNil, "mmapped address %p collides with YAP tags ***", a); + Error(FATAL_ERROR, TermNil, "mmapped address %p collides with YAP tags", a); + return NULL; } if (close(fd) == -1) { - Error(SYSTEM_ERROR, TermNil, "while closing mmaped file ***"); - return FALSE; + Error(SYSTEM_ERROR, TermNil, "while closing mmaped file"); + return NULL; } #endif #endif diff --git a/C/amasm.c b/C/amasm.c index a6580818d..2f9100b62 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -88,7 +88,7 @@ STATIC_PROTO(void a_gl, (op_numbers)); STATIC_PROTO(void a_bfunc, (CELL)); STATIC_PROTO(AREG compile_cmp_flags, (char *)); STATIC_PROTO(void a_igl, (op_numbers)); -STATIC_PROTO(void a_ucons, (op_numbers)); +STATIC_PROTO(void a_ucons, (compiler_vm_op)); STATIC_PROTO(void a_uvar, (void)); STATIC_PROTO(void a_wvar, (void)); STATIC_PROTO(void do_pass, (void)); @@ -1223,7 +1223,7 @@ a_gl(op_numbers opcode) * the head of the first argument, because of indexing */ static void -a_ucons(op_numbers opcode) +a_ucons(compiler_vm_op opcode) { #if AGGREGATE_OPS PInstr *np = cpc->nextInst; diff --git a/C/arrays.c b/C/arrays.c index bbb129057..80bccb267 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -1260,38 +1260,31 @@ replace_array_references(Term t0) Term t; t = Deref(t0); - do { - if (IsVarTerm(t)) { - /* we found a variable */ - return (MkPairTerm(t, TermNil)); - } - else if (IsAtomOrIntTerm(t)) { - return (MkPairTerm(t, TermNil)); - } - else if (IsPairTerm(t)) { - Term VList = MkVarTerm(); - CELL *h0 = H; + if (IsVarTerm(t)) { + /* we found a variable */ + return (MkPairTerm(t, TermNil)); + } else if (IsAtomOrIntTerm(t)) { + return (MkPairTerm(t, TermNil)); + } else if (IsPairTerm(t)) { + Term VList = MkVarTerm(); + CELL *h0 = H; - H += 2; - replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0, - VList); - return (MkPairTerm(AbsPair(h0), VList)); - } - else { - Term VList = MkVarTerm(); - CELL *h0 = H; - Functor f = FunctorOfTerm(t); + H += 2; + replace_array_references_complex(RepPair(t) - 1, RepPair(t) + 1, h0, + VList); + return (MkPairTerm(AbsPair(h0), VList)); + } else { + Term VList = MkVarTerm(); + CELL *h0 = H; + Functor f = FunctorOfTerm(t); - *H++ = (CELL) (f); - H += ArityOfFunctor(f); - replace_array_references_complex(RepAppl(t), - RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1, - VList); - return (MkPairTerm(AbsAppl(h0), VList)); - } - } while (TRUE); - /* make lcc happy */ - return(FALSE); + *H++ = (CELL) (f); + H += ArityOfFunctor(f); + replace_array_references_complex(RepAppl(t), + RepAppl(t) + ArityOfFunctor(FunctorOfTerm(t)), h0 + 1, + VList); + return (MkPairTerm(AbsAppl(h0), VList)); + } } static Int diff --git a/C/c_interface.c b/C/c_interface.c index 8049d5ff6..88805d5f1 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -774,7 +774,7 @@ YapReset(void) X_API void YapExit(int retval) { - exit_yap(retval, NULL); + exit_yap(retval); } X_API void diff --git a/C/cdmgr.c b/C/cdmgr.c index fd5e1b18a..dd079106e 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -2098,7 +2098,7 @@ p_system_pred(void) if (IsExtensionFunctor(funt)) { return(FALSE); } - while (funt == FunctorModule) { + if (funt == FunctorModule) { Term nmod = ArgOfTerm(1, t1); if (IsVarTerm(nmod)) { Error(INSTANTIATION_ERROR,ARG1,"system_predicate/1"); @@ -2135,7 +2135,7 @@ p_cut_transparent(void) if (IsExtensionFunctor(funt)) { return(FALSE); } - while (funt == FunctorModule) { + if (funt == FunctorModule) { Term nmod = ArgOfTerm(1, t1); if (IsVarTerm(nmod)) { Error(INSTANTIATION_ERROR,ARG1,"system_predicate/1"); diff --git a/C/compiler.c b/C/compiler.c index b48cfa63d..d8783956e 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -573,7 +573,6 @@ c_arg(Int argno, Term t, unsigned int arity) if (!(CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) { READ_UNLOCK(CurrentPred->PRWLock); FAIL("can not compile data base reference",TYPE_ERROR_CALLABLE,t); - return; } else { emit((onhead ? get_atom_op : put_atom_op), (CELL) t, argno); } diff --git a/C/corout.c b/C/corout.c index 47ed1ad71..bd9830cd4 100644 --- a/C/corout.c +++ b/C/corout.c @@ -857,8 +857,8 @@ static int can_unify_complex(register CELL *pt0, case (CELL)FunctorBigInt: if (mpz_cmp(BigIntOfTerm(d0),BigIntOfTerm(d1)) == 0) continue; goto comparison_failed; - default: #endif /* USE_GMP */ + default: goto comparison_failed; } } @@ -994,8 +994,8 @@ can_unify(Term t1, Term t2, Term *Vars) case (CELL)FunctorBigInt: if (mpz_cmp(BigIntOfTerm(t1),BigIntOfTerm(t2)) == 0) return(TRUE); return(FALSE); - default: #endif /* USE_GMP */ + default: return(FALSE); } } diff --git a/C/dbase.c b/C/dbase.c index 0a64876d1..ef8cc00bb 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -2038,7 +2038,8 @@ GetDBTerm(DBRef DBSP) if (H+NOf > ASP-CalculateStackGap()) { if (PrologMode & InErrorMode) { if (H+NOf > ASP) - exit_yap( 1, "No Stack for Error Handling\n"); + YP_fprintf(YP_stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n"); + exit_yap( 1); } else { return((Term)0); } diff --git a/C/errors.c b/C/errors.c index 98a64e318..565379c1b 100644 --- a/C/errors.c +++ b/C/errors.c @@ -191,19 +191,12 @@ DumpActiveGoals (void) #endif /* DEBUG */ void -exit_yap (int value, char *msg) +exit_yap (int value) { - if (msg != NIL) { - if (value == 0) - /* no error */ - YP_fprintf(YP_stderr, msg); - else - /* error */ - YP_fprintf(YP_stderr, "[ YAP unrecoverable error: %s ]\n", msg); - } #if defined(YAPOR) unmap_memory(); #endif /* YAPOR || TABLING */ + ShutdownLoadForeign(); exit(value); } @@ -295,23 +288,21 @@ detect_bug_location(char *tp, int psize) } } -void -ShutdownYAP(int value) -{ - ShutdownLoadForeign(); - exit(value); -} +/* This needs to be a static because I can't trust the stack (WIN32), and + I can't trust the Yap stacks (error) */ +#define YAP_BUF_SIZE 512 + +static char tmpbuf[YAP_BUF_SIZE]; yamop * Error (yap_error_number type, Term where, char *format,...) { va_list ap; - char p[512]; CELL nt[2]; Functor fun; int serious; - char *tp = p; - int psize = 512; + char *tp = tmpbuf; + int psize = YAP_BUF_SIZE; /* disallow recursive error handling */ if (PrologMode & InErrorMode) { @@ -320,50 +311,54 @@ Error (yap_error_number type, Term where, char *format,...) /* now build the error string */ if (format != NULL) { #if HAVE_VSNPRINTF - (void) vsnprintf(p, 512, format, ap); + (void) vsnprintf(tmpbuf, 512, format, ap); #else - (void) vsprintf(p, format, ap); + (void) vsprintf(tmpbuf, format, ap); #endif } else { - p[0] = '\0'; + tmpbuf[0] = '\0'; } va_end (ap); - fprintf(stderr,"[ ERROR WITHIN ERROR: %s ]\n", p); + fprintf(stderr,"[ ERROR WITHIN ERROR: %s ]\n", tmpbuf); exit(1); } if (P == (yamop *)(FAILCODE)) return(P); - /* PURE_ABORT may not have set where correctly */ - if (type == PURE_ABORT) + /* PURE_ABORT may not have set where correctly, BootMode may not have the data terms ready */ + if (type == PURE_ABORT || PrologMode & BootMode) { where = TermNil; - else + PrologMode &= ~AbortMode; + PrologMode |= InErrorMode; + } else { where = CopyTerm(Deref(where)); - if (IsVarTerm(where)) { - /* we must be careful someone gave us a copy to a local variable */ - Term t = MkVarTerm(); - unify(t, where); - where = Deref(where); + if (IsVarTerm(where)) { + /* we must be careful someone gave us a copy to a local variable */ + Term t = MkVarTerm(); + unify(t, where); + where = Deref(where); + } + /* Exit Abort Mode, if we were there */ + PrologMode &= ~AbortMode; + PrologMode |= InErrorMode; + where = CopyTerm(where); } - /* Exit Abort Mode, if we were there */ - PrologMode &= ~AbortMode; - PrologMode |= InErrorMode; - where = CopyTerm(where); va_start (ap, format); /* now build the error string */ if (format != NULL) { #if HAVE_VSNPRINTF - (void) vsnprintf(p, 512, format, ap); + (void) vsnprintf(tmpbuf, YAP_BUF_SIZE, format, ap); #else - (void) vsprintf(p, format, ap); + (void) vsprintf(tmpbuf, format, ap); #endif } else - p[0] = '\0'; + tmpbuf[0] = '\0'; va_end (ap); if (PrologMode & BootMode) { /* crash in flames! */ - exit_yap (1, p); + fprintf(stderr,"[ Fatal Error: %s exiting.... ]\n",tmpbuf); + exit_yap (1); } #ifdef DEBUGX DumpActiveGoals(); @@ -371,19 +366,19 @@ Error (yap_error_number type, Term where, char *format,...) switch (type) { case INTERNAL_ERROR: { - YP_fprintf(YP_stderr,"[ Internal YAP Error: %s exiting.... ]\n",p); + YP_fprintf(YP_stderr,"[ Internal YAP Error: %s exiting.... ]\n",tmpbuf); serious = TRUE; - detect_bug_location(tp, psize); - YP_fprintf(YP_stderr,"[ Bug found while executing %s ]\n",tp); - ShutdownYAP (1); + detect_bug_location(tmpbuf, YAP_BUF_SIZE); + YP_fprintf(YP_stderr,"[ Bug found while executing %s ]\n",tmpbuf); + exit_yap (1); } case FATAL_ERROR: { - YP_fprintf(YP_stderr,"[ Fatal YAP Error: %s exiting.... ]\n",p); - ShutdownYAP (1); + YP_fprintf(YP_stderr,"[ Fatal YAP Error: %s exiting.... ]\n",tmpbuf); + exit_yap (1); } case PURE_ABORT: - nt[0] = MkAtomTerm(LookupAtom(p)); + nt[0] = MkAtomTerm(LookupAtom(tmpbuf)); fun = MkFunctor(LookupAtom("abort"),2); serious = TRUE; break; @@ -393,15 +388,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("array_overflow")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -413,15 +408,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("array_type")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -433,15 +428,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("io_mode")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -453,15 +448,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("mutable")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -473,15 +468,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("non_empty_list")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -493,15 +488,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("not_less_than_zero")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -513,15 +508,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("not_newline")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -533,15 +528,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("not_zero")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -553,15 +548,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("out_of_range")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -573,15 +568,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("operator_priority")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -593,15 +588,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("operator_specifier")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -613,15 +608,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("radix")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -633,15 +628,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("shift_count_overflow")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -653,15 +648,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("source_sink")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -673,15 +668,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("stream")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -693,15 +688,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("stream_or_alias")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -713,15 +708,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("stream_position")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -733,15 +728,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("syntax_error_handler")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -753,15 +748,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("time_out_spec")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("domain_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -773,15 +768,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("source_sink")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("existence_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -793,15 +788,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("array")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("existence_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -813,15 +808,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("stream")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("existence_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -833,14 +828,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("float_overflow")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("evaluation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -852,14 +847,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("int_overflow")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("evaluation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -871,14 +866,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("undefined")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("evaluation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -890,14 +885,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("float_underflow")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("evaluation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -909,14 +904,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("underflow")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("evaluation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -928,14 +923,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("zero_divisor")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("evaluation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -946,13 +941,13 @@ Error (yap_error_number type, Term where, char *format,...) int i; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); nt[0] = MkAtomTerm(LookupAtom("instantiation_error")); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -964,16 +959,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("access")); ti[1] = MkAtomTerm(LookupAtom("private_procedure")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -985,16 +980,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("create")); ti[1] = MkAtomTerm(LookupAtom("array")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1006,16 +1001,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("create")); ti[1] = MkAtomTerm(LookupAtom("operator")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1027,16 +1022,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("input")); ti[1] = MkAtomTerm(LookupAtom("binary_stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1048,16 +1043,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("input")); ti[1] = MkAtomTerm(LookupAtom("past_end_of_stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1069,16 +1064,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("input")); ti[1] = MkAtomTerm(LookupAtom("stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1090,16 +1085,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("input")); ti[1] = MkAtomTerm(LookupAtom("text_stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1111,16 +1106,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("modify")); ti[1] = MkAtomTerm(LookupAtom("static_procedure")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1132,16 +1127,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("new")); ti[1] = MkAtomTerm(LookupAtom("alias")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1153,16 +1148,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("open")); ti[1] = MkAtomTerm(LookupAtom("source_sink")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1174,16 +1169,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("output")); ti[1] = MkAtomTerm(LookupAtom("binary_stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1195,16 +1190,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("output")); ti[1] = MkAtomTerm(LookupAtom("stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1216,16 +1211,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("output")); ti[1] = MkAtomTerm(LookupAtom("text_stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1237,16 +1232,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("reposition")); ti[1] = MkAtomTerm(LookupAtom("stream")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1258,16 +1253,16 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[3]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("resize")); ti[1] = MkAtomTerm(LookupAtom("array")); ti[2] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1279,14 +1274,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("character")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("representation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1298,14 +1293,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("character_code")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("representation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1317,14 +1312,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("max_arity")); nt[0] = MkApplTerm(MkFunctor(LookupAtom("representation_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1336,14 +1331,14 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[1]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("syntax_error"),1), 1, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1354,13 +1349,13 @@ Error (yap_error_number type, Term where, char *format,...) int i; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); nt[0] = MkAtomTerm(LookupAtom("system_error")); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1372,15 +1367,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("array")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1392,15 +1387,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("atom")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1412,15 +1407,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("atomic")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1432,15 +1427,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("byte")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1452,15 +1447,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("callable")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1472,15 +1467,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("character")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1492,15 +1487,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("compound")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1512,15 +1507,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("db_reference")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1532,15 +1527,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("db_term")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1552,15 +1547,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("evaluable")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1572,15 +1567,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("float")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1592,15 +1587,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("integer")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1612,15 +1607,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("key")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1632,15 +1627,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("list")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1652,15 +1647,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("number")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1672,15 +1667,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("predicate_indicator")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1692,15 +1687,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("pointer")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1712,15 +1707,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("unsigned_byte")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1732,15 +1727,15 @@ Error (yap_error_number type, Term where, char *format,...) Term ti[2]; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); ti[0] = MkAtomTerm(LookupAtom("variable")); ti[1] = where; nt[0] = MkApplTerm(MkFunctor(LookupAtom("type_error"),2), 2, ti); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1751,13 +1746,13 @@ Error (yap_error_number type, Term where, char *format,...) int i; #if HAVE_STRNCAT - strncat(p, " in ", psize); + strncat(tmpbuf, " in ", psize); #else - strcat(p, " in "); + strcat(tmpbuf, " in "); #endif - i = strlen(p); + i = strlen(tmpbuf); nt[0] = MkAtomTerm(LookupAtom("system_error")); - tp = p+i; + tp = tmpbuf+i; psize -= i; fun = MkFunctor(LookupAtom("error"),2); serious = TRUE; @@ -1768,7 +1763,7 @@ Error (yap_error_number type, Term where, char *format,...) ErrorMessage = RepAtom(AtomOfTerm(nt[0]))->StrOfAE; detect_bug_location(tp, psize); } - nt[1] = MkAtomTerm(LookupAtom(p)); + nt[1] = MkAtomTerm(LookupAtom(tmpbuf)); if (serious) { if (type == PURE_ABORT) JumpToEnv(MkAtomTerm(LookupAtom("abort"))); diff --git a/C/iopreds.c b/C/iopreds.c index 8d95229dd..f59b6758a 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -2479,7 +2479,7 @@ p_peek_mem_write_stream (void) while (i > 0) { --i; tf = MkPairTerm(MkIntTerm(Stream[sno].u.mem_string.buf[i]),tf); - while (H + 1024 >= ASP) { + if (H + 1024 >= ASP) { H = HI; if (!gc(3, ENV, P)) { Error(SYSTEM_ERROR, TermNil, "YAP could not grow stack in peek_mem_write_stream/2"); diff --git a/C/save.c b/C/save.c index 780cd7361..3ca952b91 100644 --- a/C/save.c +++ b/C/save.c @@ -1457,7 +1457,7 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries) if (!growtrail((ADDR)(basep + (NOfE*2))-TrailTop)) { Error(SYSTEM_ERROR, TermNil, "not enough space to restore hash tables for indexing"); - exit_yap(1, ""); + exit_yap(1); } } } diff --git a/C/stdpreds.c b/C/stdpreds.c index 2bd73c91d..91768b81a 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -653,7 +653,7 @@ p_atom_concat(void) if (cptr+sz >= top-1024) { ReleasePreAllocCodeSpace((ADDR)cpt0); if (!growheap(FALSE)) { - Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in recorda/3 ]\n"); + Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in atom_concat/2 ]\n"); return(FALSE); } goto restart; @@ -1250,9 +1250,10 @@ p_halt(void) } out = IntegerOfTerm(t); if (yap_flags[HALT_AFTER_CONSULT_FLAG]) { - exit_yap(out, ""); + exit_yap(out); } else { - exit_yap(out, "\n\n[ Prolog execution halted ]\n"); + YP_fprintf(YP_stderr, "\n\n[ Prolog execution halted ]\n"); + exit_yap(out); } return (TRUE); } @@ -1262,9 +1263,10 @@ static Int p_halt0(void) { /* halt */ if (yap_flags[HALT_AFTER_CONSULT_FLAG]) { - exit_yap(0, ""); + exit_yap(0); } else { - exit_yap(0, "\n\n[ Prolog execution halted ]\n"); + YP_fprintf(YP_stderr, "\n\n[ Prolog execution halted ]\n"); + exit_yap(0); } return (TRUE); } diff --git a/C/sysbits.c b/C/sysbits.c index 1ce8aa594..e9cbb39ff 100644 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1090,7 +1090,7 @@ InteractSIGINT(int ch) { return(1); case 'e': /* exit */ - exit_yap(0, ""); + exit_yap(0); return(-1); case 't': /* start tracing */ @@ -1296,7 +1296,8 @@ ReceiveSignal (int s) /* These signals are not handled by WIN32 and not the Macintosh */ case SIGQUIT: case SIGKILL: - exit_yap (SIGKILL, "\n\n\n[ Quit signal received ]\n\n"); + YP_fprintf(YP_stderr, "\n\n\n[ Quit signal received ]\n\n"); + exit_yap (SIGKILL); #endif #if defined(SIGUSR1) case SIGUSR1: @@ -2180,6 +2181,8 @@ VaxFixFrame (dummy) #ifdef _WIN32 +#include + int WINAPI STD_PROTO(win_yap, (HANDLE, DWORD, LPVOID)); int WINAPI win_yap(HANDLE hinst, DWORD reason, LPVOID reserved) diff --git a/C/tracer.c b/C/tracer.c index 01b87f36d..8f183d970 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -112,7 +112,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) /* extern int gc_calls; */ vsc_count++; - if (vsc_count < 6000) return; + /* if (vsc_count < 6000) return;*/ /* if (vsc_count == 6469) { printf("Here I go\n"); } @@ -120,7 +120,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) /* if (vsc_count > 500000) exit(0); */ /* if (gc_calls < 1) return;*/ #if defined(__GNUC__) - YP_fprintf(YP_stderr,"%llu (%p,%p: %x %x %x) ", vsc_count, H, ENV, *(CELL *)0x910e088, *(CELL *)0x910e024, *(CELL *)0x910d658); + YP_fprintf(YP_stderr,"%llu ", vsc_count); #endif /* check_trail_consistency(); */ if (pred == NULL) { diff --git a/C/userpreds.c b/C/userpreds.c index 10359a328..17a25ca2c 100644 --- a/C/userpreds.c +++ b/C/userpreds.c @@ -537,7 +537,7 @@ p_exit() register Term t = Deref(ARG1); if (IsVarTerm(t) || !IsIntTerm(t)) return (FALSE); - exit_yap((int) IntOfTerm(t), NIL); + exit_yap((int) IntOfTerm(t)); return(FALSE); } diff --git a/C/ypsocks.c b/C/ypsocks.c index c9cdf9fa0..7eb76cdbc 100644 --- a/C/ypsocks.c +++ b/C/ypsocks.c @@ -39,16 +39,9 @@ #if HAVE_IO_H #include #endif -#if HAVE_WINSOCK2_H +#if _MSC_VER || defined(__MINGW32__) +#include #include -#ifdef HAVE_SYS_UN_H -#undef HAVE_SYS_UN_H -#endif -#elif HAVE_WINSOCK_H -#include -#ifdef HAVE_SYS_UN_H -#undef HAVE_SYS_UN_H -#endif #else #if HAVE_SYS_SOCKET_H #include @@ -77,10 +70,6 @@ #if HAVE_SYS_PARAM_H #include #endif -#endif /* HAVE_WINSOCK_H */ -#if _MSC_VER || defined(__MINGW32__) -#include -#include #endif /* make sure we can compile in any platform */ @@ -882,6 +871,7 @@ p_socket_accept(void) Error(SYSTEM_ERROR, TermNil, "socket_accept/3 (accept)"); #endif + return(FALSE); } if ((s = inet_ntoa(caddr.sin_addr)) == NULL) { #if HAVE_STRERROR @@ -944,15 +934,18 @@ p_socket_buffering(void) return(FALSE); if (IsVarTerm(t4)) { bufsize = BUFSIZ; - } - if (!IsIntegerTerm(t4)) { - Error(TYPE_ERROR_INTEGER,t4,"socket_buffering/4"); - return(FALSE); - } - bufsize = IntegerOfTerm(t4); - if ((Int)bufsize < 0) { - Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t4,"socket_buffering/4"); - return(FALSE); + } else { + Int siz; + if (!IsIntegerTerm(t4)) { + Error(TYPE_ERROR_INTEGER,t4,"socket_buffering/4"); + return(FALSE); + } + siz = IntegerOfTerm(t4); + if (siz < 0) { + Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t4,"socket_buffering/4"); + return(FALSE); + } + bufsize = siz; } if (writing) { setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); diff --git a/H/Yapproto.h b/H/Yapproto.h index 9989fa66f..950eeb312 100644 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -10,7 +10,7 @@ * File: Yap.proto * * mods: * * comments: Function declarations for YAP * -* version: $Id: Yapproto.h,v 1.11 2002-02-12 18:24:20 vsc Exp $ * +* version: $Id: Yapproto.h,v 1.12 2002-02-22 06:12:18 vsc Exp $ * *************************************************************************/ /* prototype file for Yap */ @@ -137,9 +137,8 @@ void STD_PROTO(InitBackDB,(void)); void STD_PROTO(InitDBPreds,(void)); /* errors.c */ -void STD_PROTO(exit_yap,(int,char *)); +void STD_PROTO(exit_yap,(int)); yamop *STD_PROTO(Error,(yap_error_number,Term,char *msg, ...)); -void STD_PROTO(ShutdownYAP,(int)); /* eval.c */