avoid using registry, clean-up
This commit is contained in:
parent
605dd2abc1
commit
c633eac236
1
C/save.c
1
C/save.c
@ -1820,7 +1820,6 @@ Restore(char *s, char *lib_dir USES_REGS)
|
|||||||
initIO();
|
initIO();
|
||||||
/* reset time */
|
/* reset time */
|
||||||
Yap_ReInitWallTime();
|
Yap_ReInitWallTime();
|
||||||
Yap_InitSysPath();
|
|
||||||
#if USE_DL_MALLOC || USE_SYSTEM_MALLOC
|
#if USE_DL_MALLOC || USE_SYSTEM_MALLOC
|
||||||
if (!AuxSp) {
|
if (!AuxSp) {
|
||||||
Yap_InitPreAllocCodeSpace( 0 );
|
Yap_InitPreAllocCodeSpace( 0 );
|
||||||
|
158
C/sysbits.c
158
C/sysbits.c
@ -116,7 +116,7 @@ static int chdir(char *);
|
|||||||
|
|
||||||
void exit(int);
|
void exit(int);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef __WINDOWS__
|
||||||
void
|
void
|
||||||
Yap_WinError(char *yap_error)
|
Yap_WinError(char *yap_error)
|
||||||
{
|
{
|
||||||
@ -211,119 +211,120 @@ Yap_dir_separator (int ch)
|
|||||||
char *libdir = NULL;
|
char *libdir = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
static Int
|
||||||
Yap_InitSysPath(void) {
|
initSysPath(Term tlib, Term tcommons) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int len;
|
int len;
|
||||||
int dir_done = FALSE;
|
int dir_done = FALSE;
|
||||||
int commons_done = FALSE;
|
int commons_done = FALSE;
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
Int rcl, rcc;
|
||||||
|
|
||||||
|
#if _MSC_VER || defined(__MINGW32__) || defined(__MSYS__)
|
||||||
{
|
{
|
||||||
char *dir;
|
char *dir;
|
||||||
if ((dir = Yap_RegistryGetString("library")) &&
|
if ((dir = Yap_RegistryGetString("library")) &&
|
||||||
is_directory(dir)) {
|
is_directory(dir)) {
|
||||||
Yap_PutValue(AtomSystemLibraryDir,
|
if (! Yap_unify( tlib,
|
||||||
MkAtomTerm(Yap_LookupAtom(dir)));
|
MkAtomTerm(Yap_LookupAtom(dir))) )
|
||||||
dir_done = TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((dir = Yap_RegistryGetString("prolog_commons")) &&
|
if ((dir = Yap_RegistryGetString("prolog_commons")) &&
|
||||||
is_directory(dir)) {
|
is_directory(dir)) {
|
||||||
Yap_PutValue(AtomPrologCommonsDir,
|
if (! Yap_unify( tcommons,
|
||||||
MkAtomTerm(Yap_LookupAtom(dir)));
|
MkAtomTerm(Yap_LookupAtom(dir))) )
|
||||||
commons_done = TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dir_done && commons_done)
|
if (dir_done && commons_done)
|
||||||
return;
|
return rcl && rcc;
|
||||||
#endif
|
#endif
|
||||||
strncpy(LOCAL_FileNameBuf, YAP_SHAREDIR, YAP_FILENAME_MAX);
|
strncpy(LOCAL_FileNameBuf, YAP_SHAREDIR, YAP_FILENAME_MAX);
|
||||||
if (is_directory(LOCAL_FileNameBuf)) {
|
strncat(LOCAL_FileNameBuf,"/", YAP_FILENAME_MAX);
|
||||||
strncat(LOCAL_FileNameBuf,"/", YAP_FILENAME_MAX);
|
len = strlen(LOCAL_FileNameBuf);
|
||||||
len = strlen(LOCAL_FileNameBuf);
|
if (!dir_done) {
|
||||||
strncat(LOCAL_FileNameBuf, "Yap", YAP_FILENAME_MAX);
|
strncat(LOCAL_FileNameBuf, "Yap", YAP_FILENAME_MAX);
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
if (is_directory(LOCAL_FileNameBuf))
|
||||||
if (!dir_done && is_directory(LOCAL_FileNameBuf))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
Yap_PutValue(AtomSystemLibraryDir,
|
if (! Yap_unify( tlib,
|
||||||
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
|
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf))) )
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
return FALSE;
|
||||||
dir_done = TRUE;
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
}
|
||||||
if (!commons_done)
|
if (!commons_done) {
|
||||||
#endif
|
LOCAL_FileNameBuf[len] = '\0';
|
||||||
{
|
strncat(LOCAL_FileNameBuf, "PrologCommons", YAP_FILENAME_MAX);
|
||||||
LOCAL_FileNameBuf[len] = '\0';
|
if (is_directory(LOCAL_FileNameBuf)) {
|
||||||
strncat(LOCAL_FileNameBuf, "PrologCommons", YAP_FILENAME_MAX);
|
if (! Yap_unify( tcommons,
|
||||||
if (is_directory(LOCAL_FileNameBuf))
|
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf))) )
|
||||||
Yap_PutValue(AtomPrologCommonsDir,
|
return FALSE;
|
||||||
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
|
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
|
||||||
commons_done = TRUE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dir_done && commons_done)
|
if (dir_done && commons_done)
|
||||||
return;
|
return rcl && rcc;
|
||||||
|
|
||||||
#if _MSC_VER || defined(__MINGW32__)
|
#if __WINDOWS__
|
||||||
{
|
{
|
||||||
size_t buflen;
|
size_t buflen;
|
||||||
char *pt;
|
char *pt;
|
||||||
|
|
||||||
/* couldn't find it where it was supposed to be,
|
/* couldn't find it where it was supposed to be,
|
||||||
let's try using the executable */
|
let's try using the executable */
|
||||||
if (!GetModuleFileName( NULL, LOCAL_FileNameBuf, YAP_FILENAME_MAX)) {
|
if (!GetModuleFileName( NULL, LOCAL_FileNameBuf, YAP_FILENAME_MAX)) {
|
||||||
|
Yap_WinError( "could not find executable name" );
|
||||||
|
/* do nothing */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
buflen = strlen(LOCAL_FileNameBuf);
|
||||||
|
pt = LOCAL_FileNameBuf+buflen;
|
||||||
|
while (*--pt != '\\') {
|
||||||
|
/* skip executable */
|
||||||
|
if (pt == LOCAL_FileNameBuf) {
|
||||||
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
|
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
buflen = strlen(LOCAL_FileNameBuf);
|
}
|
||||||
pt = LOCAL_FileNameBuf+buflen;
|
while (*--pt != '\\') {
|
||||||
while (*--pt != '\\') {
|
/* skip parent directory "bin\\" */
|
||||||
/* skip executable */
|
if (pt == LOCAL_FileNameBuf) {
|
||||||
if (pt == LOCAL_FileNameBuf) {
|
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
|
||||||
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
|
/* do nothing */
|
||||||
/* do nothing */
|
return FALSE;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (*--pt != '\\') {
|
}
|
||||||
/* skip parent directory "bin\\" */
|
/* now, this is a possible location for the ROOT_DIR, let's look for a share directory here */
|
||||||
if (pt == LOCAL_FileNameBuf) {
|
pt[1] = '\0';
|
||||||
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "could not find executable name");
|
/* grosse */
|
||||||
/* do nothing */
|
strncat(LOCAL_FileNameBuf,"lib\\Yap",YAP_FILENAME_MAX);
|
||||||
}
|
libdir = Yap_AllocCodeSpace(strlen(LOCAL_FileNameBuf)+1);
|
||||||
}
|
strncpy(libdir, LOCAL_FileNameBuf, strlen(LOCAL_FileNameBuf)+1);
|
||||||
/* now, this is a possible location for the ROOT_DIR, let's look for a share directory here */
|
pt[1] = '\0';
|
||||||
pt[1] = '\0';
|
strncat(LOCAL_FileNameBuf,"share",YAP_FILENAME_MAX);
|
||||||
/* grosse */
|
|
||||||
strncat(LOCAL_FileNameBuf,"lib\\Yap",YAP_FILENAME_MAX);
|
|
||||||
libdir = Yap_AllocCodeSpace(strlen(LOCAL_FileNameBuf)+1);
|
|
||||||
strncpy(libdir, LOCAL_FileNameBuf, strlen(LOCAL_FileNameBuf)+1);
|
|
||||||
pt[1] = '\0';
|
|
||||||
strncat(LOCAL_FileNameBuf,"share",YAP_FILENAME_MAX);
|
|
||||||
}
|
}
|
||||||
strncat(LOCAL_FileNameBuf,"\\", YAP_FILENAME_MAX);
|
strncat(LOCAL_FileNameBuf,"\\", YAP_FILENAME_MAX);
|
||||||
len = strlen(LOCAL_FileNameBuf);
|
len = strlen(LOCAL_FileNameBuf);
|
||||||
strncat(LOCAL_FileNameBuf, "Yap", YAP_FILENAME_MAX);
|
strncat(LOCAL_FileNameBuf, "Yap", YAP_FILENAME_MAX);
|
||||||
if (!dir_done && is_directory(LOCAL_FileNameBuf))
|
if (!dir_done && is_directory(LOCAL_FileNameBuf)) {
|
||||||
{
|
if (! Yap_unify( tlib,
|
||||||
Yap_PutValue(AtomSystemLibraryDir,
|
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf))) )
|
||||||
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!commons_done)
|
LOCAL_FileNameBuf[len] = '\0';
|
||||||
{
|
strncat(LOCAL_FileNameBuf, "PrologCommons", YAP_FILENAME_MAX);
|
||||||
LOCAL_FileNameBuf[len] = '\0';
|
if (!commons_done && is_directory(LOCAL_FileNameBuf)) {
|
||||||
strncat(LOCAL_FileNameBuf, "PrologCommons", YAP_FILENAME_MAX);
|
if (! Yap_unify( tcommons,
|
||||||
if (is_directory(LOCAL_FileNameBuf))
|
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf))) )
|
||||||
Yap_PutValue(AtomPrologCommonsDir,
|
return FALSE;
|
||||||
MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
return dir_done && commons_done;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_libraries_path( USES_REGS1 )
|
||||||
|
{
|
||||||
|
return initSysPath( ARG1, ARG2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
@ -3030,6 +3031,7 @@ Yap_InitSysPreds(void)
|
|||||||
Yap_InitCPred ("release_random_state", 1, p_release_random_state, SafePredFlag);
|
Yap_InitCPred ("release_random_state", 1, p_release_random_state, SafePredFlag);
|
||||||
#endif
|
#endif
|
||||||
Yap_InitCPred ("log_event", 1, p_log_event, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred ("log_event", 1, p_log_event, SafePredFlag|SyncPredFlag);
|
||||||
|
Yap_InitCPred ("library_directories", 2, p_libraries_path, SafePredFlag);
|
||||||
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
|
||||||
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
||||||
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
||||||
|
@ -370,7 +370,6 @@ UInt Yap_cputime(void);
|
|||||||
Int Yap_walltime(void);
|
Int Yap_walltime(void);
|
||||||
int Yap_dir_separator(int);
|
int Yap_dir_separator(int);
|
||||||
int Yap_volume_header(char *);
|
int Yap_volume_header(char *);
|
||||||
void Yap_InitSysPath(void);
|
|
||||||
int Yap_signal_index(const char *);
|
int Yap_signal_index(const char *);
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
void Yap_SetTextFile(char *);
|
void Yap_SetTextFile(char *);
|
||||||
|
13
misc/yap.nsi
13
misc/yap.nsi
@ -71,21 +71,18 @@ Section "Base system (required)"
|
|||||||
; SYSTEM STUFF
|
; SYSTEM STUFF
|
||||||
File /r ${ROOTDIR}\share\Yap\*
|
File /r ${ROOTDIR}\share\Yap\*
|
||||||
|
|
||||||
|
SetOutPath $INSTDIR\share\PrologCommons
|
||||||
|
; SYSTEM STUFF
|
||||||
|
File /r ${ROOTDIR}\share\PrologCommons
|
||||||
|
|
||||||
SetOutPath $INSTDIR\share\doc\Yap
|
SetOutPath $INSTDIR\share\doc\Yap
|
||||||
File ${ROOTDIR}\share\doc\Yap\html\*
|
File /r ${ROOTDIR}\share\doc\Yap\html\*
|
||||||
; File ${ROOTDIR}\share\doc\Yap\refman.pdf
|
; File ${ROOTDIR}\share\doc\Yap\refman.pdf
|
||||||
; File ${ROOTDIR}\share\doc\Yap\yap.info
|
; File ${ROOTDIR}\share\doc\Yap\yap.info
|
||||||
File ${ROOTDIR}\share\doc\Yap\Artistic
|
File ${ROOTDIR}\share\doc\Yap\Artistic
|
||||||
File ${ROOTDIR}\share\doc\Yap\README.TXT
|
File ${ROOTDIR}\share\doc\Yap\README.TXT
|
||||||
File ${ROOTDIR}\share\doc\Yap\COPYING
|
File ${ROOTDIR}\share\doc\Yap\COPYING
|
||||||
|
|
||||||
WriteRegStr HKLM ${REGKEY} "home" "$INSTDIR"
|
|
||||||
WriteRegStr HKLM ${REGKEY} "bin" "$INSTDIR\bin\yap.exe"
|
|
||||||
WriteRegStr HKLM ${REGKEY} "dlls" "$INSTDIR\lib\Yap"
|
|
||||||
WriteRegStr HKLM ${REGKEY} "startup" "$INSTDIR\lib\Yap\startup.yss"
|
|
||||||
WriteRegStr HKLM ${REGKEY} "library" "$INSTDIR\share\Yap"
|
|
||||||
WriteRegStr HKLM ${REGKEY} "commons" "$INSTDIR\share\PrologCommons"
|
|
||||||
|
|
||||||
; Write uninstaller
|
; Write uninstaller
|
||||||
!ifdef WIN64
|
!ifdef WIN64
|
||||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YAP64" "DisplayName" "YAP64 (remove only)"
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YAP64" "DisplayName" "YAP64 (remove only)"
|
||||||
|
16
pl/absf.yap
16
pl/absf.yap
@ -538,21 +538,33 @@ remove_from_path(New) :- '$check_path'(New,Path),
|
|||||||
`library( _File_ )` are searched by the predicates consult/1,
|
`library( _File_ )` are searched by the predicates consult/1,
|
||||||
reconsult/1, use_module/1, ensure_loaded/1, and load_files/2.
|
reconsult/1, use_module/1, ensure_loaded/1, and load_files/2.
|
||||||
|
|
||||||
|
This directory is initialized through the system predicate
|
||||||
|
library_directories/2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
:- multifile user:library_directory/1.
|
:- multifile user:library_directory/1.
|
||||||
|
|
||||||
:- dynamic user:library_directory/1.
|
:- dynamic user:library_directory/1.
|
||||||
|
|
||||||
/**
|
user:library_directory( Path ):-
|
||||||
@pred user:commons_directory(?Directory:atom) is nondet, dynamic
|
library_directories( Path, _ ).
|
||||||
|
|
||||||
|
/**
|
||||||
|
@pred user:commons_directory(? _Directory_:atom) is nondet, dynamic
|
||||||
|
|
||||||
|
State the location of the Commons Prolog Initiative.
|
||||||
|
|
||||||
|
This directory is initialized through the system predicate
|
||||||
|
library_directories/2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
:- multifile user:commons_directory/1.
|
:- multifile user:commons_directory/1.
|
||||||
|
|
||||||
:- dynamic user:commons_directory/1.
|
:- dynamic user:commons_directory/1.
|
||||||
|
|
||||||
|
user:commons_directory( Path ):-
|
||||||
|
library_directories( _, Path ).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred user:prolog_file_type(?Suffix:atom, ?Handler:atom) is nondet, dynamic
|
@pred user:prolog_file_type(?Suffix:atom, ?Handler:atom) is nondet, dynamic
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user