fix open/3 munging filenames in write mode
This commit is contained in:
parent
6ff24e9a16
commit
ab1b8cea39
@ -291,7 +291,7 @@ Read-only flag telling the maximum arity of a functor. Takes the value
|
|||||||
"256", NULL),
|
"256", NULL),
|
||||||
YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false", NULL),
|
YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false", NULL),
|
||||||
YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, booleanFlag,
|
YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, booleanFlag,
|
||||||
"true", NULL), /**< `open_expands_filename `
|
"false", NULL), /**< `open_expands_filename `
|
||||||
|
|
||||||
If `true` the open/3 builtin performs filename-expansion
|
If `true` the open/3 builtin performs filename-expansion
|
||||||
before opening a file (SICStus Prolog like). If `false` it does not
|
before opening a file (SICStus Prolog like). If `false` it does not
|
||||||
|
@ -129,6 +129,7 @@ simultaneously opened streams is 17.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
told :- current_output(Stream),
|
told :- current_output(Stream),
|
||||||
|
flush_output(Stream),
|
||||||
!,
|
!,
|
||||||
set_output(user),
|
set_output(user),
|
||||||
close(Stream).
|
close(Stream).
|
||||||
|
11
os/sysbits.c
11
os/sysbits.c
@ -7,7 +7,6 @@
|
|||||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||||
* *
|
* *
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* PrologPathProkoh
|
|
||||||
* *
|
* *
|
||||||
* File: sysbits.c *
|
* File: sysbits.c *
|
||||||
* Last rev: 4/03/88 *
|
* Last rev: 4/03/88 *
|
||||||
@ -519,12 +518,13 @@ static const char *myrealpath(const char *path, char *out) {
|
|||||||
}
|
}
|
||||||
// rc = NULL;
|
// rc = NULL;
|
||||||
if (errno == ENOENT || errno == EACCES) {
|
if (errno == ENOENT || errno == EACCES) {
|
||||||
char base[YAP_FILENAME_MAX];
|
char base[YAP_FILENAME_MAX+1];
|
||||||
strncpy(base, path, YAP_FILENAME_MAX - 1);
|
strncpy(base, path, YAP_FILENAME_MAX - 1);
|
||||||
rc = realpath(dirname(base), NULL);
|
rc = realpath(dirname(base), NULL);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
const char *b = basename(base);
|
// base may haave been destroyed
|
||||||
|
const char *b = basename(path);
|
||||||
size_t e = strlen(rc);
|
size_t e = strlen(rc);
|
||||||
size_t bs = strlen(b);
|
size_t bs = strlen(b);
|
||||||
|
|
||||||
@ -585,6 +585,11 @@ static const char *expandVars(const char *spec, char *u) {
|
|||||||
const char *Yap_AbsoluteFile(const char *spec, char *rc0, bool ok) {
|
const char *Yap_AbsoluteFile(const char *spec, char *rc0, bool ok) {
|
||||||
const char *p;
|
const char *p;
|
||||||
const char *rc;
|
const char *rc;
|
||||||
|
if (!ok) {
|
||||||
|
if (!rc0)
|
||||||
|
rc0 = malloc(strlen(spec)+1);
|
||||||
|
return strcpy(rc0, spec);
|
||||||
|
}
|
||||||
rc = PlExpandVars(spec, NULL, rc0);
|
rc = PlExpandVars(spec, NULL, rc0);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = spec;
|
rc = spec;
|
||||||
|
Reference in New Issue
Block a user