fix format bug

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1069 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-05-18 15:13:05 +00:00
parent a6f1b27c09
commit cfd90835a0

View File

@ -3795,7 +3795,7 @@ format(Term tail, Term args, int sno)
if (ch == '*') { if (ch == '*') {
ch = *fptr++; ch = *fptr++;
has_repeats = TRUE; has_repeats = TRUE;
if (targ > tnum) { if (targ > tnum-1) {
goto do_consistency_error; goto do_consistency_error;
} }
repeats = fetch_index_from_args(targs[targ++]); repeats = fetch_index_from_args(targs[targ++]);
@ -3817,7 +3817,7 @@ format(Term tail, Term args, int sno)
switch (ch) { switch (ch) {
case 'a': case 'a':
/* print an atom */ /* print an atom */
if (has_repeats || targ > tnum) if (has_repeats || targ > tnum-1)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (IsVarTerm(t)) if (IsVarTerm(t))
@ -3830,7 +3830,7 @@ format(Term tail, Term args, int sno)
{ {
Int nch, i; Int nch, i;
if (targ > tnum) if (targ > tnum-1)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (IsVarTerm(t)) if (IsVarTerm(t))
@ -3855,7 +3855,7 @@ format(Term tail, Term args, int sno)
Float fl; Float fl;
char *ptr; char *ptr;
if (targ > tnum) if (targ > tnum-1)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (IsVarTerm(t)) if (IsVarTerm(t))
@ -3888,7 +3888,7 @@ format(Term tail, Term args, int sno)
case 'd': case 'd':
case 'D': case 'D':
/* print a decimal, using weird . stuff */ /* print a decimal, using weird . stuff */
if (targ > tnum) if (targ > tnum-1)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (IsVarTerm(t)) if (IsVarTerm(t))
@ -3944,7 +3944,7 @@ format(Term tail, Term args, int sno)
Int numb, radix, div = 1; Int numb, radix, div = 1;
/* print a decimal, using weird . stuff */ /* print a decimal, using weird . stuff */
if (targ > tnum) if (targ > tnum-1)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (IsVarTerm(t)) if (IsVarTerm(t))
@ -3982,7 +3982,7 @@ format(Term tail, Term args, int sno)
break; break;
} }
case 's': case 's':
if (targ > tnum) if (targ > tnum-1)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
if (!format_print_str (sno, repeats, has_repeats, t)) { if (!format_print_str (sno, repeats, has_repeats, t)) {
@ -3990,12 +3990,12 @@ format(Term tail, Term args, int sno)
} }
break; break;
case 'i': case 'i':
if (targ > tnum || has_repeats) if (targ > tnum-1 || has_repeats)
goto do_consistency_error; goto do_consistency_error;
targ++; targ++;
break; break;
case 'k': case 'k':
if (targ > tnum || has_repeats) if (targ > tnum-1 || has_repeats)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
*--ASP = MkIntTerm(0); *--ASP = MkIntTerm(0);
@ -4003,7 +4003,7 @@ format(Term tail, Term args, int sno)
ASP++; ASP++;
break; break;
case 'p': case 'p':
if (targ > tnum || has_repeats) if (targ > tnum-1 || has_repeats)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
*--ASP = MkIntTerm(0); *--ASP = MkIntTerm(0);
@ -4027,7 +4027,7 @@ format(Term tail, Term args, int sno)
ASP++; ASP++;
break; break;
case 'q': case 'q':
if (targ > tnum || has_repeats) if (targ > tnum-1 || has_repeats)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
*--ASP = MkIntTerm(0); *--ASP = MkIntTerm(0);
@ -4035,7 +4035,7 @@ format(Term tail, Term args, int sno)
ASP++; ASP++;
break; break;
case 'w': case 'w':
if (targ > tnum || has_repeats) if (targ > tnum-1 || has_repeats)
goto do_consistency_error; goto do_consistency_error;
t = targs[targ++]; t = targs[targ++];
*--ASP = MkIntTerm(0); *--ASP = MkIntTerm(0);