From 2a93a01f1ca8daa65965ea82057097ef9d3a412b Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 29 Jul 2004 18:15:19 +0000 Subject: [PATCH] fix severe bug in indexing of floating point numbers git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1110 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/index.c | 27 ++++++++++++++++++--------- C/iopreds.c | 8 ++++---- H/iopreds.h | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/C/index.c b/C/index.c index 9fccc2714..903e5437b 100644 --- a/C/index.c +++ b/C/index.c @@ -11,8 +11,11 @@ * File: index.c * * comments: Indexing a Prolog predicate * * * -* Last rev: $Date: 2004-07-23 19:01:14 $,$Author: vsc $ * +* Last rev: $Date: 2004-07-29 18:15:18 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.93 2004/07/23 19:01:14 vsc +* fix bad ref count in expand_clauses when copying indexing block +* * Revision 1.92 2004/06/29 19:04:42 vsc * fix multithreaded version * include new version of Ricardo's profiler @@ -2096,13 +2099,16 @@ move_next(ClauseDef *clause, UInt regno) case _glist_valy: return; case _get_atom: - case _get_float: - case _get_longint: - case _get_bigint: if (wreg == cl->u.xc.x) { clause->CurrentCode = NEXTOP(cl,xc); } return; + /* + matching is not guaranteed: + case _get_float: + case _get_longint: + case _get_bigint: + */ case _get_struct: if (wreg == cl->u.xf.x) { clause->CurrentCode = NEXTOP(cl,xf); @@ -2381,11 +2387,14 @@ skip_to_arg(ClauseDef *clause, PredEntry *ap, UInt argno, int at_point) case _unify_l_list: case _unify_atom: case _unify_l_atom: - case _unify_longint: - case _unify_l_longint: - case _unify_bigint: - case _unify_l_bigint: - case _unify_l_float: + /* + unification is not guaranteed + case _unify_longint: + case _unify_l_longint: + case _unify_bigint: + case _unify_l_bigint: + case _unify_l_float: + */ case _unify_struct: case _unify_l_struc: if (cl == clause->u.WorkPC) { diff --git a/C/iopreds.c b/C/iopreds.c index 636d54dac..f5fef4303 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -3760,7 +3760,7 @@ format(volatile Term otail, volatile Term oargs, int sno) int (* f_putc)(int, int); int has_tabs; jmp_buf format_botch; - void *old_handler; + volatile void *old_handler = NULL; volatile int old_pos; if (Stream[sno].status & InMemory_Stream_f) { @@ -4085,7 +4085,7 @@ format(volatile Term otail, volatile Term oargs, int sno) fstr = NULL; } if (Stream[sno].status & InMemory_Stream_f) { - old_handler = Stream[sno].u.mem_string.error_handler; + Stream[sno].u.mem_string.error_handler = old_handler; } format_clean_up(format_base, fstr, targs); Yap_JumpToEnv(ball); @@ -4193,7 +4193,7 @@ format(volatile Term otail, volatile Term oargs, int sno) fstr = NULL; } if (Stream[sno].status & InMemory_Stream_f) { - old_handler = Stream[sno].u.mem_string.error_handler; + Stream[sno].u.mem_string.error_handler = old_handler; } format_clean_up(format_base, fstr, targs); return FALSE; @@ -4216,7 +4216,7 @@ format(volatile Term otail, volatile Term oargs, int sno) if (tnum <= 8) targs = NULL; if (Stream[sno].status & InMemory_Stream_f) { - old_handler = Stream[sno].u.mem_string.error_handler; + Stream[sno].u.mem_string.error_handler = old_handler; } format_clean_up(format_base, fstr, targs); return (TRUE); diff --git a/H/iopreds.h b/H/iopreds.h index a36db8a85..00735d383 100644 --- a/H/iopreds.h +++ b/H/iopreds.h @@ -48,7 +48,7 @@ typedef struct stream_desc char *buf; /* where the file is being read from/written to */ Int max_size; /* maximum buffer size (may be changed dynamically) */ Int pos; - void *error_handler; + volatile void *error_handler; } mem_string; struct { #if defined(__MINGW32__) || _MSC_VER