fix bad header

scan files for line count.
This commit is contained in:
Vitor Santos Costa 2016-09-27 12:32:48 -05:00
parent 51bf90908f
commit b0ce23f131
2 changed files with 17 additions and 15 deletions

View File

@ -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}

View File

@ -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) {