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}
|
||||
|
15
os/files.c
15
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))) {
|
||||
return false;
|
||||
FILE *f = GLOBAL_Stream[sno].file;
|
||||
size_t count = 0;
|
||||
int ch;
|
||||
#if __ANDROID__
|
||||
#define getw getc
|
||||
#endif
|
||||
if (!f)
|
||||
return false;
|
||||
while ((ch = getw(f)) >= 0) {
|
||||
if (ch == '\n')
|
||||
if (ch == '\n') {
|
||||
count++;
|
||||
}
|
||||
return Yap_unify(ARG3, MkIntegerTerm(count));
|
||||
}
|
||||
return false;
|
||||
return Yap_unify(ARG2, MkIntegerTerm(count));
|
||||
}
|
||||
|
||||
static Int access_file(USES_REGS1) {
|
||||
|
Reference in New Issue
Block a user