No longer uses fgetln() - that call is not part of the POSIX specs, and is
not supported by the GLIBC stdio that we now have. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7369 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,26 +14,28 @@
|
|||||||
#define NEW_FORTUNE "The path has been shown - we are the ones who must walk it"
|
#define NEW_FORTUNE "The path has been shown - we are the ones who must walk it"
|
||||||
|
|
||||||
|
|
||||||
static void read_file(FILE *f)
|
static void
|
||||||
|
read_file(FILE *f)
|
||||||
{
|
{
|
||||||
|
char buffer[2048];
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
char *buffer, *tmp;
|
|
||||||
size_t bytes = 0;
|
|
||||||
|
|
||||||
while ((buffer = fgetln(f, &bytes)) != NULL) {
|
while ((fgets(buffer, sizeof(buffer), f)) != NULL) {
|
||||||
if (*buffer == '#')
|
size_t bytes = strlen(buffer);
|
||||||
|
|
||||||
|
if (buffer[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
tmp = (char*) malloc(bytes + 1);
|
|
||||||
if (!tmp)
|
if (buffer[bytes - 1] != '\n')
|
||||||
break;
|
buffer[bytes - 1] = '\n';
|
||||||
memcpy(tmp, buffer, bytes);
|
|
||||||
if (tmp[bytes - 1] != '\n')
|
fprintf(stdout, "%d: %s", ++lines, buffer);
|
||||||
tmp[bytes - 1] = '\n';
|
|
||||||
fprintf(stdout, "%d: %s", ++lines, tmp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user