win32 support, especially win does not allow file streaming in memory
This commit is contained in:
parent
3af377d610
commit
e4e59dedf7
@ -24,7 +24,7 @@ static int GETW(int sno) {
|
|||||||
case ENC_ISO_ANSI: {
|
case ENC_ISO_ANSI: {
|
||||||
char buf[8];
|
char buf[8];
|
||||||
int out;
|
int out;
|
||||||
int wch;
|
wchar_t wch;
|
||||||
mbstate_t mbstate;
|
mbstate_t mbstate;
|
||||||
|
|
||||||
memset((void *)&(mbstate), 0, sizeof(mbstate_t));
|
memset((void *)&(mbstate), 0, sizeof(mbstate_t));
|
||||||
|
@ -196,6 +196,9 @@ void Yap_DefaultStreamOps(StreamDesc *st) {
|
|||||||
if (st->status & (Promptable_Stream_f)) {
|
if (st->status & (Promptable_Stream_f)) {
|
||||||
st->stream_wgetc = get_wchar;
|
st->stream_wgetc = get_wchar;
|
||||||
Yap_ConsoleOps(st, true);
|
Yap_ConsoleOps(st, true);
|
||||||
|
} else if (st->status & (InMemory_Stream_f)) {
|
||||||
|
st->stream_wgetc = get_wchar;
|
||||||
|
Yap_ConsoleOps(st, true);
|
||||||
} else if (st->encoding == LOCAL_encoding) {
|
} else if (st->encoding == LOCAL_encoding) {
|
||||||
st->stream_wgetc = get_wchar_from_file;
|
st->stream_wgetc = get_wchar_from_file;
|
||||||
} else
|
} else
|
||||||
|
7
os/mem.c
7
os/mem.c
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************
|
/*************************************************************************post/////85
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
* *
|
* *
|
||||||
@ -82,12 +82,12 @@ MemGetc (int sno)
|
|||||||
|
|
||||||
spos = s->u.mem_string.pos;
|
spos = s->u.mem_string.pos;
|
||||||
if (spos == s->u.mem_string.max_size) {
|
if (spos == s->u.mem_string.max_size) {
|
||||||
return post_process_eof(s);
|
return EOF;
|
||||||
} else {
|
} else {
|
||||||
ch = s->u.mem_string.buf[spos];
|
ch = s->u.mem_string.buf[spos];
|
||||||
s->u.mem_string.pos = ++spos;
|
s->u.mem_string.pos = ++spos;
|
||||||
}
|
}
|
||||||
return post_process_read_char(ch, s);
|
return ch;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -446,4 +446,3 @@ Yap_InitMems( void )
|
|||||||
Yap_InitCPred ("peek_mem_write_stream", 3, peek_mem_write_stream, SyncPredFlag);
|
Yap_InitCPred ("peek_mem_write_stream", 3, peek_mem_write_stream, SyncPredFlag);
|
||||||
CurrentModule = cm;
|
CurrentModule = cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
os/sysbits.c
29
os/sysbits.c
@ -541,14 +541,14 @@ DirName(const char *X) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *myrealpath( const char *path)
|
static const char *myrealpath( const char *path, char *out)
|
||||||
{
|
{
|
||||||
#if _WIN32 || defined(__MINGW32__)
|
#if _WIN32 || defined(__MINGW32__)
|
||||||
DWORD retval=0;
|
DWORD retval=0;
|
||||||
|
|
||||||
// notice that the file does not need to exist
|
// notice that the file does not need to exist
|
||||||
retval = GetFullPathName(path,
|
retval = GetFullPathName(path,
|
||||||
YAP_FILENAME_MAX,
|
MAX_PATH-1,
|
||||||
out,
|
out,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
@ -594,9 +594,10 @@ static const char *myrealpath( const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
char *out = malloc(strlen(path)+1);
|
char *rc = malloc(strlen(path)+1);
|
||||||
strcpy( out, path);
|
strcpy( rc, path);
|
||||||
return out;
|
const char * f = rc;
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@ -605,9 +606,10 @@ expandVars(const char *spec)
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
#if _WIN32 || defined(__MINGW32__)
|
#if _WIN32 || defined(__MINGW32__)
|
||||||
char u[YAP_FILENAME_MAX+1];
|
char u[YAP_FILENAME_MAX+1];
|
||||||
|
char *out;
|
||||||
|
|
||||||
// first pass, remove Unix style stuff
|
// first pass, remove Unix style stuff
|
||||||
if ((ou=unix2win(spec, YAP_FILENAME_MAX)) == NULL)
|
if ((out=unix2win(spec, u, YAP_FILENAME_MAX)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
spec = u;
|
spec = u;
|
||||||
#endif
|
#endif
|
||||||
@ -639,7 +641,7 @@ Yap_AbsoluteFile(const char *spec, bool ok)
|
|||||||
rc = PlExpandVars(spec, NULL, NULL);
|
rc = PlExpandVars(spec, NULL, NULL);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = spec;
|
rc = spec;
|
||||||
if ((p = myrealpath(rc) ) ) {
|
if ((p = myrealpath(rc, NULL )) ) {
|
||||||
return p;
|
return p;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -672,7 +674,7 @@ Yap_AbsoluteFileInBuffer(const char *spec, char *out, size_t sz, bool ok)
|
|||||||
rc = spec;
|
rc = spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p = myrealpath(rc) ) ) {
|
if ((p = myrealpath(rc, out) ) ) {
|
||||||
if (!out) {
|
if (!out) {
|
||||||
out = LOCAL_FileNameBuf;
|
out = LOCAL_FileNameBuf;
|
||||||
sz = YAP_FILENAME_MAX-1;
|
sz = YAP_FILENAME_MAX-1;
|
||||||
@ -702,15 +704,14 @@ do_glob(const char *spec, bool glob_vs_wordexp)
|
|||||||
WIN32_FIND_DATA find;
|
WIN32_FIND_DATA find;
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
CELL *dest;
|
CELL *dest;
|
||||||
|
char *espec;
|
||||||
|
Term tf;
|
||||||
|
|
||||||
// first pass, remove Unix style stuff
|
// first pass, remove Unix style stuff
|
||||||
if (unix2win(espec, u, YAP_FILENAME_MAX) == NULL)
|
if ((espec =unix2win(spec, u, YAP_FILENAME_MAX)) == NULL)
|
||||||
return TermNil;
|
return TermNil;
|
||||||
espec = (const char *)u;
|
espec = (const char *)u;
|
||||||
|
|
||||||
if (!use_system_expansion) {
|
|
||||||
return MkPairTerm(MkAtomTerm(Yap_LookupAtom(espec)), TermNil);
|
|
||||||
}
|
|
||||||
hFind = FindFirstFile(espec, &find);
|
hFind = FindFirstFile(espec, &find);
|
||||||
|
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
@ -860,6 +861,7 @@ prolog_realpath( USES_REGS1 )
|
|||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
|
char out[YAP_FILENAME_MAX];
|
||||||
|
|
||||||
if (IsAtomTerm(t1)) {
|
if (IsAtomTerm(t1)) {
|
||||||
cmd = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
cmd = RepAtom(AtomOfTerm(t1))->StrOfAE;
|
||||||
@ -868,7 +870,7 @@ prolog_realpath( USES_REGS1 )
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const char *rc = myrealpath( cmd );
|
const char *rc = myrealpath( cmd , out);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
PlIOError( SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, strerror(errno));
|
PlIOError( SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
@ -2297,4 +2299,3 @@ Yap_InitSysPreds(void)
|
|||||||
Yap_InitCPred ("rmdir", 2, p_rmdir, SyncPredFlag);
|
Yap_InitCPred ("rmdir", 2, p_rmdir, SyncPredFlag);
|
||||||
Yap_InitCPred ("make_directory", 1, make_directory, SyncPredFlag);
|
Yap_InitCPred ("make_directory", 1, make_directory, SyncPredFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user