fix bad header
scan files for line count.
This commit is contained in:
parent
51bf90908f
commit
b0ce23f131
@ -1316,6 +1316,11 @@ signal. */
|
||||
#cmakedefine HAVE_STRING_H ${HAVE_STRING_H}
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#ifndef HAVE_STRLCPY
|
||||
#cmakedefine HAVE_STRLCPY ${HAVE_STRLCPY}
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strlwr' function. */
|
||||
#ifndef HAVE_STRLWR
|
||||
#cmakedefine HAVE_STRLWR ${HAVE_STRLWR}
|
||||
|
27
os/files.c
27
os/files.c
@ -307,26 +307,23 @@ static Int file_size(USES_REGS1) {
|
||||
}
|
||||
|
||||
static Int lines_in_file(USES_REGS1) {
|
||||
Int sno = Yap_CheckStream(ARG1, (Input_Stream_f | Output_Stream_f),
|
||||
"lines_in_file/2");
|
||||
Int sno = Yap_CheckStream(ARG1, (Input_Stream_f), "lines_in_file/2");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
if (GLOBAL_Stream[sno].status & Seekable_Stream_f &&
|
||||
!(GLOBAL_Stream[sno].status &
|
||||
(InMemory_Stream_f | Socket_Stream_f | Pipe_Stream_f))) {
|
||||
FILE *f = GLOBAL_Stream[sno].file;
|
||||
size_t count = 0;
|
||||
int ch;
|
||||
return false;
|
||||
FILE *f = GLOBAL_Stream[sno].file;
|
||||
size_t count = 0;
|
||||
int ch;
|
||||
#if __ANDROID__
|
||||
#define getw getc
|
||||
#endif
|
||||
while ((ch = getw(f)) >= 0) {
|
||||
if (ch == '\n')
|
||||
count++;
|
||||
if (!f)
|
||||
return false;
|
||||
while ((ch = getw(f)) >= 0) {
|
||||
if (ch == '\n') {
|
||||
count++;
|
||||
}
|
||||
return Yap_unify(ARG3, MkIntegerTerm(count));
|
||||
}
|
||||
return false;
|
||||
return Yap_unify(ARG2, MkIntegerTerm(count));
|
||||
}
|
||||
|
||||
static Int access_file(USES_REGS1) {
|
||||
@ -459,7 +456,7 @@ static Int is_absolute_file_name(USES_REGS1) { /* file_base_name(Stream,N) */
|
||||
Atom at;
|
||||
bool rc;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user