try to fix -l and -L from scripts
saved states should always interpret getting read() == 0 as EOF. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1662 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
9a941730f7
commit
0a96eab20d
8
C/save.c
8
C/save.c
@ -184,7 +184,7 @@ myread(int fd, char *buff, Int len)
|
|||||||
{
|
{
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
int nchars = read(fd, buff, len);
|
int nchars = read(fd, buff, len);
|
||||||
if (nchars < 0) {
|
if (nchars <= 0) {
|
||||||
return do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, "bad read on saved state");
|
return do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, "bad read on saved state");
|
||||||
}
|
}
|
||||||
len -= nchars;
|
len -= nchars;
|
||||||
@ -617,11 +617,13 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
|||||||
char pp[80];
|
char pp[80];
|
||||||
char msg[256];
|
char msg[256];
|
||||||
CELL hp_size, gb_size, lc_size, tr_size, mode;
|
CELL hp_size, gb_size, lc_size, tr_size, mode;
|
||||||
|
int n;
|
||||||
|
|
||||||
/* make sure we always check if there are enough bytes */
|
/* make sure we always check if there are enough bytes */
|
||||||
/* skip the first line */
|
/* skip the first line */
|
||||||
|
pp[0] = '\0';
|
||||||
do {
|
do {
|
||||||
if (read(splfild, pp, 1) < 0) {
|
if ((n = read(splfild, pp, 1)) <= 0) {
|
||||||
do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan first line from saved state");
|
do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan first line from saved state");
|
||||||
return FAIL_RESTORE;
|
return FAIL_RESTORE;
|
||||||
}
|
}
|
||||||
@ -631,7 +633,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
|||||||
{
|
{
|
||||||
int count = 0, n, to_read = Unsigned(strlen(msg) + 1);
|
int count = 0, n, to_read = Unsigned(strlen(msg) + 1);
|
||||||
while (count < to_read) {
|
while (count < to_read) {
|
||||||
if ((n = read(splfild, pp, to_read-count)) < 0) {
|
if ((n = read(splfild, pp, to_read-count)) <= 0) {
|
||||||
do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan version info from saved state");
|
do_system_error(PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,"failed to scan version info from saved state");
|
||||||
return FAIL_RESTORE;
|
return FAIL_RESTORE;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
<h2>Yap-5.1.2:</h2>
|
<h2>Yap-5.1.2:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li> FIXED: -l and -L options (again?).</li>
|
||||||
|
<li> FIXED: if we cannot read more chars in saved state we're dead.</li>
|
||||||
<li> FIXED: termination info for failed and detached threads (obs Paulo Moura).</li>
|
<li> FIXED: termination info for failed and detached threads (obs Paulo Moura).</li>
|
||||||
<li> FIXED: check_callable should check for modules (obs Paulo Moura).</li>
|
<li> FIXED: check_callable should check for modules (obs Paulo Moura).</li>
|
||||||
<li> NEW: add thread_sleep/1, mostly works like system:sleep/1 (request from Paulo Moura).</li>
|
<li> NEW: add thread_sleep/1, mostly works like system:sleep/1 (request from Paulo Moura).</li>
|
||||||
|
@ -433,44 +433,30 @@ parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'L':
|
case 'L':
|
||||||
p++;
|
|
||||||
iap->HaltAfterConsult = TRUE;
|
iap->HaltAfterConsult = TRUE;
|
||||||
if (*p != '\0') {
|
|
||||||
iap->YapPrologRCFile = p;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (--argc == 0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
" [ YAP unrecoverable error: missing file name with option 'L' ]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
p = *++argv;
|
|
||||||
if (p[0] == '-' && p[1] == '-' && p[2] == '\0') {
|
|
||||||
if (--argc == 0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
" [ YAP unrecoverable error: missing filename with option 'L' ]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
p = *++argv;
|
|
||||||
iap->YapPrologRCFile = p;
|
|
||||||
argc = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
iap->YapPrologRCFile = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if ((*argv)[0] == '\0')
|
p++;
|
||||||
|
if (!*++argv) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%% YAP unrecoverable error: missing boot file name\n");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
iap->YapPrologRCFile = *argv;
|
iap->YapPrologRCFile = *argv;
|
||||||
else {
|
|
||||||
argc--;
|
argc--;
|
||||||
if (argc == 0) {
|
|
||||||
fprintf(stderr," [ YAP unrecoverable error: missing file name with option 'l' ]\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
argv++;
|
if (*p) {
|
||||||
iap->YapPrologRCFile = *argv;
|
/* we have something, usually, of the form:
|
||||||
|
-L --
|
||||||
|
FileName
|
||||||
|
ExtraArgs
|
||||||
|
*/
|
||||||
|
/* being called from a script */
|
||||||
|
while (*p && (*p == ' ' || *p == '\t'))
|
||||||
|
p++;
|
||||||
|
if (p[0] == '-' && p[1] == '-') {
|
||||||
|
/* ignore what is next */
|
||||||
|
argc = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* run goal before top-level */
|
/* run goal before top-level */
|
||||||
|
Reference in New Issue
Block a user