Use fgets() not fgetln() for portability.
This commit is contained in:
@@ -35,7 +35,7 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *fp = stdin;
|
FILE *fp = stdin;
|
||||||
char *buf, *cp;
|
char buf[2048], *cp, *ep;
|
||||||
int errors = 0, tests = 0, lineno;
|
int errors = 0, tests = 0, lineno;
|
||||||
struct gl_entry entry;
|
struct gl_entry entry;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -59,13 +59,17 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
memset(&entry, 0, sizeof(entry));
|
memset(&entry, 0, sizeof(entry));
|
||||||
while ((buf = fgetln(fp, &len)) != NULL) {
|
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
||||||
lineno++;
|
lineno++;
|
||||||
if (buf[len - 1] != '\n') {
|
len = strlen(buf);
|
||||||
fprintf(stderr, "globtest: missing newline at EOF\n");
|
if (len > 0) {
|
||||||
exit(1);
|
if (buf[len - 1] != '\n') {
|
||||||
|
fprintf(stderr,
|
||||||
|
"globtest: missing newline at EOF\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
buf[--len] = '\0';
|
||||||
}
|
}
|
||||||
buf[--len] = '\0';
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
continue; /* blank line */
|
continue; /* blank line */
|
||||||
|
|
||||||
@@ -93,23 +97,23 @@ main(int argc, char **argv)
|
|||||||
memcpy(entry.pattern, buf + 1, len);
|
memcpy(entry.pattern, buf + 1, len);
|
||||||
entry.pattern[len] = '\0';
|
entry.pattern[len] = '\0';
|
||||||
|
|
||||||
buf = cp + 2;
|
cp += 2;
|
||||||
if (*buf++ != '<') {
|
if (*cp++ != '<') {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"globtest: invalid entry on line %d\n",
|
"globtest: invalid entry on line %d\n",
|
||||||
lineno);
|
lineno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ((cp = strchr(buf, '>')) == NULL) {
|
entry.flags = (int)strtol(cp, &ep, 0);
|
||||||
|
if (*ep != '>') {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"globtest: invalid entry on line %d\n",
|
"globtest: invalid entry on line %d\n",
|
||||||
lineno);
|
lineno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
entry.flags = (int)strtol(buf, &cp, 0);
|
if (entry.flags < 0 || entry.flags > 0x2000) {
|
||||||
if (*cp != '>' || entry.flags < 0 || entry.flags > 0x2000) {
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"globtest: invalid flags: %s\n", buf);
|
"globtest: invalid flags: %s\n", cp);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
entry.nresults = 0;
|
entry.nresults = 0;
|
||||||
|
Reference in New Issue
Block a user