update to latest SWI.

This commit is contained in:
Vítor Santos Costa 2012-02-01 20:52:13 +00:00
parent 616ae30138
commit ad9e1d8ea4
4 changed files with 65 additions and 31 deletions

View File

@ -85,6 +85,9 @@ typedef uintptr_t word; /* Anonymous 4 byte object */
#define WORDS_PER_DOUBLE 2
#endif
#define allocForeignState(size) ((void *)Yap_AllocCodeSpace(size))
#define freeForeignState(ptr, size) Yap_FreeCodeSpace((void*)(ptr))
// numbers
typedef enum

34
os/pl-cstack.h Normal file
View File

@ -0,0 +1,34 @@
/* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@uva.nl
WWW: http://www.swi-prolog.org
Copyright (C): 1985-2011, University of Amsterdam
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PL_CSTACK_H_INCLUDED
#define PL_CSTACK_H_INCLUDED
COMMON(void) save_backtrace(const char *why);
COMMON(void) btrace_destroy(struct btrace *bt);
COMMON(void) print_backtrace(int last); /* 1..SAVE_TRACES */
COMMON(void) print_backtrace_named(const char *why);
COMMON(void) initBackTrace(void);
#endif /*PL_CSTACK_H_INCLUDED*/

View File

@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pl-incl.h"
@ -54,7 +54,7 @@ typedef struct
typedef struct
{ int current; /* current character */
const char_type *class; /* current class */
int do_enum; /* what to enumerate */
int do_enum; /* what to enumerate */
} generator;
@ -366,7 +366,7 @@ do_char_type(term_t chr, term_t class, control_t h, int how)
}
}
gen = allocHeap(sizeof(*gen));
gen = allocForeignState(sizeof(*gen));
gen->do_enum = do_enum;
if ( do_enum & ENUM_CHAR )
@ -385,10 +385,11 @@ do_char_type(term_t chr, term_t class, control_t h, int how)
case FRG_CUTTED:
gen = ForeignContextPtr(h);
if ( gen )
freeHeap(gen, sizeof(*gen));
freeForeignState(gen, sizeof(*gen));
default:
succeed;
}
if ( !(fid = PL_open_foreign_frame()) )
goto error;
@ -411,9 +412,9 @@ do_char_type(term_t chr, term_t class, control_t h, int how)
}
if ( advanceGen(gen) ) /* ok, found one */
ForeignRedoPtr(gen);
else
{ freeHeap(gen, sizeof(*gen)); /* the only one */
{ ForeignRedoPtr(gen);
} else
{ freeForeignState(gen, sizeof(*gen)); /* the only one */
succeed;
}
}
@ -425,7 +426,7 @@ do_char_type(term_t chr, term_t class, control_t h, int how)
}
error:
freeHeap(gen, sizeof(*gen));
freeForeignState(gen, sizeof(*gen));
fail;
}
@ -451,7 +452,7 @@ PRED_IMPL("iswctype", 2, iswctype, 0)
wctype_t t;
if ( !PL_get_char_ex(A1, &chr, FALSE) ||
!PL_get_chars_ex(A2, &s, CVT_ATOM) )
!PL_get_chars(A2, &s, CVT_ATOM|CVT_EXCEPTION) )
return FALSE;
if ( !(t=wctype(s)) )
@ -725,11 +726,11 @@ PRED_IMPL("setlocale", 3, setlocale, 0)
const lccat *lcp;
if ( !PL_get_chars_ex(A1, &what, CVT_ATOM) )
if ( !PL_get_chars(A1, &what, CVT_ATOM|CVT_EXCEPTION) )
fail;
if ( PL_is_variable(A3) )
locale = NULL;
else if ( !PL_get_chars_ex(A3, &locale, CVT_ATOM) )
else if ( !PL_get_chars(A3, &locale, CVT_ATOM|CVT_EXCEPTION) )
fail;
for ( lcp = lccats; lcp->name; lcp++ )
@ -748,8 +749,7 @@ PRED_IMPL("setlocale", 3, setlocale, 0)
}
}
return PL_error(NULL, 0, NULL, ERR_DOMAIN,
PL_new_atom("category"), A1);
return PL_domain_error("category", A1);
}
#else
@ -784,7 +784,7 @@ EndPredDefs
const char _PL_char_types[] = {
/* ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O 0-15 */
CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT,
CT, CT, CT, CT, CT, CT, CT, CT, CT, SP, SP, SP, SP, SP, CT, CT,
/* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ 16-31 */
CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT,
/* sp ! " # $ % & ' ( ) * + , - . / 32-47 */
@ -803,13 +803,14 @@ const char _PL_char_types[] = {
CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT,
CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT,
/* 160-255 (G1 graphics) */
/* ISO Latin 1 is assumed */
SP, SO, SO, SO, SO, SO, SO, SO, SO, SO, LC, SO, SO, SO, SO, SO,
SO, SO, SO, SO, SO, SO, SO, SO, SO, SO, LC, SO, SO, SO, SO, SO,
UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC,
UC, UC, UC, UC, UC, UC, UC, SO, UC, UC, UC, UC, UC, UC, UC, LC,
LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC,
LC, LC, LC, LC, LC, LC, LC, SO, LC, LC, LC, LC, LC, LC, LC, LC
/* ISO Latin 1 (=Unicode) is assumed */
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
SP, SY, SY, SY, SY, SY, SY, SY, SY, SY, LC, SY, SY, SO, SY, SY, /*00AX*/
SY, SY, SO, SO, SY, LC, SY, SY, SY, SO, LC, SY, SO, SO, SO, SY, /*00BX*/
UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, /*00CX*/
UC, UC, UC, UC, UC, UC, UC, SY, UC, UC, UC, UC, UC, UC, UC, LC, /*00DX*/
LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, /*00EX*/
LC, LC, LC, LC, LC, LC, LC, SY, LC, LC, LC, LC, LC, LC, LC, LC /*00FX*/
};
@ -841,14 +842,9 @@ initEncoding(void)
} else if ( (enc = setlocale(LC_CTYPE, NULL)) )
{ LD->encoding = ENC_ANSI; /* text encoding */
/* this does not work on the mac for some reason */
if (strchr(enc, '.')) {
enc = strchr(enc, '.');
/* skip '.' */
enc++;
}
if ( enc )
if ( (enc = strchr(enc, '.')) )
{ const enc_map *m;
enc++; /* skip '.' */
for ( m=map; m->name; m++ )
{ if ( strcmp(enc, m->name) == 0 )

View File

@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern const char _PL_char_types[]; /* array of character types */
@ -37,7 +37,8 @@ extern const char _PL_char_types[]; /* array of character types */
#define DI 10 /* Digit */
#define isControl(c) (_PL_char_types[(unsigned)(c) & 0xff] == CT)
#define isBlank(c) (_PL_char_types[(unsigned)(c) & 0xff] <= SP)
#define isBlank(c) (_PL_char_types[(unsigned)(c) & 0xff] == SP)
#define isGraph(c) (_PL_char_types[(unsigned)(c) & 0xff] > SP)
#define isDigit(c) (_PL_char_types[(unsigned)(c) & 0xff] == DI)
#define isLower(c) (_PL_char_types[(unsigned)(c) & 0xff] == LC)
#define isUpper(c) (_PL_char_types[(unsigned)(c) & 0xff] == UC)
@ -68,7 +69,7 @@ extern const char _PL_char_types[]; /* array of character types */
((unsigned)(c) <= 0xff ? (_PL_char_types[(unsigned char)(c)] t) : w)
#define isControlW(c) PlCharType(c, == CT, iswcntrl((wint_t)c))
#define isBlankW(c) PlCharType(c, <= SP, iswspace((wint_t)c))
#define isBlankW(c) PlCharType(c, == SP, iswspace((wint_t)c))
#define isDigitW(c) PlCharType(c, == DI, FALSE)
#define isLowerW(c) PlCharType(c, == LC, iswlower((wint_t)c))
#define isUpperW(c) PlCharType(c, == UC, iswupper((wint_t)c))