From 8e230e1dd6d28935b6965d664bbe7dbfc7e402ba Mon Sep 17 00:00:00 2001 From: YeLincoln Date: Sun, 17 May 2015 16:03:29 +0800 Subject: [PATCH] use fgets to get a line instead of getline function getline undefined when I compile it with MinGW --- src/mfoc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mfoc.c b/src/mfoc.c index 1caf290..e2448e0 100644 --- a/src/mfoc.c +++ b/src/mfoc.c @@ -54,7 +54,6 @@ //SLRE #include "slre.h" -#include "slre.c" nfc_context *context; @@ -120,9 +119,7 @@ int main(int argc, char *const argv[]) //File pointers for the keyfile FILE * fp; - char * line = NULL; - size_t len = 0; - ssize_t read; + char line[20]; //Regexp declarations static const char *regex = "([0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])"; @@ -155,7 +152,7 @@ int main(int argc, char *const argv[]) fprintf(stderr, "Cannot open keyfile: %s, exiting\n", optarg); exit(EXIT_FAILURE); } - while ((read = getline(&line, &len, fp)) != -1) { + while ( fgets(line, 20, fp)) { int i, j = 0, str_len = strlen(line); while (j < str_len &&