This commit is contained in:
Vitor Santos Costa 2017-02-20 15:48:22 +00:00
commit f426d25bef
15 changed files with 84 additions and 201 deletions

View File

@ -1,4 +1,4 @@
/************************************************************************* /*************************************************************************
* * * *
* YAP Prolog * * YAP Prolog *
* * * *

View File

@ -450,9 +450,6 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
// ASCII, so both LATIN1 and UTF-8 // ASCII, so both LATIN1 and UTF-8
// Yap_DebugPlWriteln(inp->val.t); // Yap_DebugPlWriteln(inp->val.t);
char *s; char *s;
if (s0)
s = (char *)s0;
else
s = Malloc(0); s = Malloc(0);
if (snprintf(s, MaxTmp(PASS_REGS1) - 1, Int_FORMAT, if (snprintf(s, MaxTmp(PASS_REGS1) - 1, Int_FORMAT,
IntegerOfTerm(inp->val.t)) < 0) { IntegerOfTerm(inp->val.t)) < 0) {
@ -464,21 +461,9 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
} }
if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) { if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) {
char *s; char *s;
size_t sz = 1024;
// Yap_DebugPlWriteln(inp->val.t); // Yap_DebugPlWriteln(inp->val.t);
if (s0) { if (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &s, 1024)) {
s = (char *)s0; return NULL;
sz = strlen(s);
} else
s = Malloc(sz);
if (!s)
AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), s, char);
while (!Yap_FormatFloat(FloatOfTerm(inp->val.t), &s, sz - 1)) {
if (s0) {
s = Malloc(sz = 1024);
s0 = NULL;
} else
s = Realloc(s, sz + 1024);
} }
if (lengp) if (lengp)
*lengp = strlen(s); *lengp = strlen(s);
@ -488,9 +473,6 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
if (inp->type & YAP_STRING_BIG && IsBigIntTerm(inp->val.t)) { if (inp->type & YAP_STRING_BIG && IsBigIntTerm(inp->val.t)) {
// Yap_DebugPlWriteln(inp->val.t); // Yap_DebugPlWriteln(inp->val.t);
char *s; char *s;
if (s0)
s = 0;
else
s = Malloc(0); s = Malloc(0);
if (!Yap_mpz_to_string(Yap_BigIntOfTerm(inp->val.t), s, MaxTmp() - 1, 10)) { if (!Yap_mpz_to_string(Yap_BigIntOfTerm(inp->val.t), s, MaxTmp() - 1, 10)) {
AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), s, char); AUX_ERROR(inp->val.t, MaxTmp(PASS_REGS1), s, char);

View File

@ -385,15 +385,16 @@ int Yap_FormatFloat(Float f, char **s, size_t sz) {
sno = Yap_open_buf_write_stream(GLOBAL_Stream[LOCAL_c_output_stream].encoding, sno = Yap_open_buf_write_stream(GLOBAL_Stream[LOCAL_c_output_stream].encoding,
0); 0);
if (sno < 0) if (sno < 0)
return FALSE; return false;
wglb.lw = separator; wglb.lw = separator;
wglb.stream = GLOBAL_Stream + sno; wglb.stream = GLOBAL_Stream + sno;
wrputf(f, &wglb); wrputf(f, &wglb);
wrputc('\0', wglb.stream); wrputc('\0', wglb.stream);
so = Yap_MemExportStreamPtr(sno); so = Yap_MemExportStreamPtr(sno);
*s = Malloc( strlen(so) )+1;
strcpy(*s, so );
Yap_CloseStream(sno); Yap_CloseStream(sno);
*s = so; return true;
return TRUE;
} }
/* writes a data base reference */ /* writes a data base reference */
@ -568,7 +569,7 @@ static void write_string(const unsigned char *s,
int delta; int delta;
ptr += (delta = get_utf8(ptr, -1, &chr) ); ptr += (delta = get_utf8(ptr, -1, &chr) );
if (chr == '\0') if (chr == '\0') {
break; break;
if (delta == 0) {chr = *ptr++; } if (delta == 0) {chr = *ptr++; }
write_quoted(chr, qt, stream); write_quoted(chr, qt, stream);

View File

@ -8,6 +8,14 @@ set (CXX_SOURCES
yapi.cpp yapi.cpp
) )
set (CXX_HEADERS
yapa.hh
yapdb.hh
yapi.h
yapie.hh
yapq.hh
- yapt.hh
-)
list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE) list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE)

View File

@ -1,9 +0,0 @@
set (CXX_SOURCES
yapa.hh
yapdb.hh
yapi.cpp
yapi.hh
yapie.hh
yapq.hh
yapt.hh
)

View File

@ -72,6 +72,8 @@ extern void *protected_pop_text_stack(int lvl, void *safe, bool tmp,
#define NUMBER_OF_CHARS 256 #define NUMBER_OF_CHARS 256
extern char *Yap_chtype; extern char *Yap_chtype;
#define Yap_strlen(s) strlen((void *)(s))
typedef enum { typedef enum {
BG = 0, /* initial state */ BG = 0, /* initial state */
UC = 1, /* Upper case */ UC = 1, /* Upper case */

View File

@ -406,11 +406,3 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/../config.h.cmake
configure_file(${CMAKE_CURRENT_LIST_DIR}/../GitSHA1.c.in GitSHA1.c @ONLY) configure_file(${CMAKE_CURRENT_LIST_DIR}/../GitSHA1.c.in GitSHA1.c @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/os/YapIOConfig.h) configure_file(${CMAKE_CURRENT_LIST_DIR}/../os/YapIOConfig.h.cmake ${CMAKE_BINARY_DIR}/os/YapIOConfig.h)
check_include_files( "stdio.h;cudd.h" HAVE_CTYPE_HUDD_H )
check_include_files( "stdio.h;cuddI.h" HAVE_CUDD_H )
check_include_files( "cudd.h;cuddInt.h" HAVE_CUDDINT_H )
check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( "stdio.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )
configure_file (cmake/cudd_config.h.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cudd_config.h" )

View File

@ -1,152 +1,47 @@
# - Try to find the CUDD BDD package # Try to find CUDD headers and libraries.
# Once done this will define
# #
# CUDD_FOUND - system has CUDD # Usage of this module as follows:
# CUDD_LIBRARIES - Link these to use CUDD
# CUDD_INCLUDE_DIR - Include directory for using CUDD
# #
# Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org> # find_package(CUDD)
# #
# Redistribution and use is allowed according to the terms of the BSD license. # Variables used by this module, they can change the default behaviour and need
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. # to be set before calling find_package:
#
# CUDD_ROOT Set this variable to the root installation of
# libcudd if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# CUDD_FOUND System has CUDD libraries and headers
# CUDD_LIBRARIES The CUDD library
# CUDD_INCLUDE_DIR The location of CUDD headers
SET( CUDD_FOUND "NO" ) # Get hint from environment variable (if any)
if(NOT CUDD_ROOT AND DEFINED ENV{CUDD_ROOT})
set (CUDD_INCLUDE_SEARCH_PATH set(CUDD_ROOT "$ENV{CUDD_ROOT}" CACHE PATH "CUDD base directory location (optional, used for nonstandard installation paths)")
${CUDD_ROOT_DIR}/include mark_as_advanced(CUDD_ROOT)
${CMAKE_INSTALL_PREFIX}/include
/usr/local/yap/include
/usr/local/Yap/include
/usr/local/cudd/include
/usr/lib/cudd/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include/
/sw/include # Fink
/opt/local/include # MacPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
)
set (CUDD_LIB_SEARCH_PATH
${CUDD_ROOT_DIR}/lib
${CMAKE_INSTALL_PREFIX}/lib
/usr/lib
/usr/local/lib/cudd
/usr/local/cudd/lib
/usr/lib/cudd
/usr/lib/cudd/lib
/usr/freeware/lib )
if ($ENV{CUDD_ROOT})
list (APPEND CUDD_LIB_SEARCH_PATH
$ENV{CUDD_ROOT}/lib
$ENV{CUDD_ROOT}/lib-dbg
$ENV{CUDD_ROOT} )
list (APPEND CUDD_INCLUDE_SEARCH_PATH
$ENV{CUDD_ROOT}/include )
endif() endif()
if (${CUDD_ROOT}) # Search path for nonstandard locations
list (APPEND CUDD_LIB_SEARCH_PATH if(CUDD_ROOT)
${CUDD_ROOT}/lib set(CUDD_INCLUDE_PATH PATHS "${CUDD_ROOT}/include" NO_DEFAULT_PATH)
${CUDD_ROOT}/lib-dbg set(CUDD_LIBRARY_PATH PATHS "${CUDD_ROOT}/lib" NO_DEFAULT_PATH)
${CUDD_ROOT} )
list (APPEND CUDD_INCLUDE_SEARCH_PATH
${CUDD_ROOT}/include )
endif() endif()
# Check if we have cached results in case the last round was successful. # Search path for nonstandard locations
if(CUDD_ROOT_DIR)
find_package(PkgConfig) set(CUDD_INCLUDE_PATH PATHS "${CUDD_ROOT_DIR}/include" NO_DEFAULT_PATH)
set(CUDD_LIBRARY_PATH PATHS "${CUDD_ROOT_DIR}/lib" NO_DEFAULT_PATH)
find_path(CUDD_INCLUDE_DIR
NAMES cudd.h cudd/cudd.h
${CUDD_INCLUDE_SEARCH_PATH}
)
mark_as_advanced(CUDD_INCLUDE_DIR)
if (CUDD_INCLUDE_DIR)
find_library(CUDD_LIBRARIES
NAMES cudd
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_LIBRARIES)
SET( CUDD_FOUND "YES" )
find_library(CUDD_DDDMP_LIBRARY
NAMES dddmp
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_DDMP_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_DDMP_LIBRARY} )
endif() endif()
find_library(CUDD_EPD_LIBRARY find_path(CUDD_INCLUDE_DIR NAMES cudd.h cudd/cudd.h HINTS ${CUDD_INCLUDE_PATH})
NAMES epd find_library(CUDD_LIBRARIES NAMES cudd CUDDVC-2.5.0 HINTS ${CUDD_LIBRARY_PATH})
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_EPD_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_EPD_LIBRARY} )
endif()
find_library(CUDD_ST_LIBRARY
NAMES cuddst
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_ST_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_ST_LIBRARY} )
endif()
include(FindPackageHandleStandardArgs)
find_library(CUDD_UTIL_LIBRARY find_package_handle_standard_args(CUDD DEFAULT_MSG CUDD_LIBRARIES CUDD_INCLUDE_DIR)
NAMES cuddutil
PATHS mark_as_advanced(CUDD_ROOT CUDD_LIBRARIES CUDD_INCLUDE_DIR)
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_UTIL_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_ST_LIBRARY} )
endif()
find_library(CUDD_MTR_LIBRARY
NAMES mtr
PATHS
${CUDD_LIB_SEARCH_PATH}
)
if (CUDD_MTR_LIBRARY)
list( APPEND CUDD_LIBRARIES ${CUDD_MTR_LIBRARY} )
endif()
endif()
endif()
mark_as_advanced(CUDD_LIBRARIES)
mark_as_advanced (CUDD_FOUND)
find_package_handle_standard_args(CUDD DEFAULT_MSG CUDD_LIBRARIES CUDD_INCLUDE_DIR )

View File

@ -17,6 +17,14 @@ macro_log_feature (CUDD_FOUND "CUDD"
if (CUDD_FOUND) if (CUDD_FOUND)
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CUDD_INCLUDE_DIR} ) set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CUDD_INCLUDE_DIR} )
check_include_files( "stdio.h;cudd.h" HAVE_CTYPE_HUDD_H )
check_include_files( "stdio.h;cuddI.h" HAVE_CUDD_H )
check_include_files( "cudd.h;cuddInt.h" HAVE_CUDDINT_H )
check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( "stdio.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )
configure_file (cmake/cudd_config.h.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cudd_config.h" )
endif (CUDD_FOUND) endif (CUDD_FOUND)

16
configure vendored
View File

@ -68,11 +68,11 @@ set_config_var() {
cfg="${ENABLE_VARS}" cfg="${ENABLE_VARS}"
case "x$arg" in case "x$arg" in
"xy"|"xyes"|"xtrue") "xy"|"xyes"|"xtrue")
VAR_VALUE=yes VAR_VALUE=YES
;; ;;
"xn"|"xno"|"xfalse") "xn"|"xno"|"xfalse")
found=y found=y
VAR_VALUE=no VAR_VALUE=NO
;; ;;
**) **)
VAR_VALUE="" VAR_VALUE=""
@ -84,10 +84,10 @@ set_config_var() {
cfg="${ENABLE_VARS}" cfg="${ENABLE_VARS}"
case "x$arg" in case "x$arg" in
"xy"|"xyes"|"xtrue") "xy"|"xyes"|"xtrue")
VAR_VALUE=no VAR_VALUE=NO
;; ;;
"xn"|"xno"|"xfalse") "xn"|"xno"|"xfalse")
VAR_VALUE=yes VAR_VALUE=YES
;; ;;
**) **)
VAR_VALUE="" VAR_VALUE=""
@ -99,13 +99,13 @@ set_config_var() {
name="${1#--with-}" name="${1#--with-}"
cfg="${WITH_VARS}" cfg="${WITH_VARS}"
case "x$arg" in case "x$arg" in
"x"|"xy"|"xyes"|"xtrue") "x"|"xy"|"xyes"|"xtrue"|"xon")
is_with=n is_with=n
VAR_VALUE=yes VAR_VALUE=YES
``;; ``;;
"xn"|"xno"|"xfalse") "xn"|"xno"|"xfalse"|"xoff")
is_with=n is_with=n
VAR_VALUE=no VAR_VALUE=NO
;; ;;
**) **)
is_with=y is_with=y

View File

@ -10,10 +10,12 @@ for the relative license.
#include <stdio.h> #include <stdio.h>
#include "config.h" #include "config.h"
#include "cudd_config.h" #include "cudd_config.h"
#if HAVE_CUDD_CUDDINT_H #if HAVE_CUDD_CUDD_H
#include "cudd/cuddInt.h" #include "cudd/cudd.h"
#elif HAVE_CUDDINT_H #include "cudd/mtr.h"
#include "cuddInt.h" #elif HAVE_CUDD_H
#include "cudd.h"
#include "mtr.h"
#endif #endif
#include "YapInterface.h" #include "YapInterface.h"

View File

@ -61,6 +61,7 @@ yio.yap
add_custom_target (${YAP_STARTUP} ALL SOURCES ${PL_SOURCES} ${YAPOS_PL_SOURCES} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_custom_target (${YAP_STARTUP} ALL SOURCES ${PL_SOURCES} ${YAPOS_PL_SOURCES} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
if ( NOT CMAKE_CROSSCOMPILING )
# Create a startup.yss on the top directory. # Create a startup.yss on the top directory.
add_custom_command (TARGET ${YAP_STARTUP} add_custom_command (TARGET ${YAP_STARTUP}
COMMAND yap-bin -B COMMAND yap-bin -B
@ -68,6 +69,7 @@ add_custom_command (TARGET ${YAP_STARTUP}
WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR}
DEPENDS yap-bin ${PL_SOURCES} DEPENDS yap-bin ${PL_SOURCES}
) )
endif ( NOT CMAKE_CROSSCOMPILING )
install (FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP} install (FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}