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}
|
#cmakedefine HAVE_STRING_H ${HAVE_STRING_H}
|
||||||
#endif
|
#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. */
|
/* Define to 1 if you have the `strlwr' function. */
|
||||||
#ifndef HAVE_STRLWR
|
#ifndef HAVE_STRLWR
|
||||||
#cmakedefine HAVE_STRLWR ${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) {
|
static Int lines_in_file(USES_REGS1) {
|
||||||
Int sno = Yap_CheckStream(ARG1, (Input_Stream_f | Output_Stream_f),
|
Int sno = Yap_CheckStream(ARG1, (Input_Stream_f), "lines_in_file/2");
|
||||||
"lines_in_file/2");
|
|
||||||
if (sno < 0)
|
if (sno < 0)
|
||||||
return (FALSE);
|
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;
|
FILE *f = GLOBAL_Stream[sno].file;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
int ch;
|
int ch;
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
#define getw getc
|
#define getw getc
|
||||||
#endif
|
#endif
|
||||||
|
if (!f)
|
||||||
|
return false;
|
||||||
while ((ch = getw(f)) >= 0) {
|
while ((ch = getw(f)) >= 0) {
|
||||||
if (ch == '\n')
|
if (ch == '\n') {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return Yap_unify(ARG3, MkIntegerTerm(count));
|
|
||||||
}
|
}
|
||||||
return false;
|
return Yap_unify(ARG2, MkIntegerTerm(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int access_file(USES_REGS1) {
|
static Int access_file(USES_REGS1) {
|
||||||
|
Reference in New Issue
Block a user