]> git.webhop.me Git - lcd4linux.git/commitdiff
plugin_file patch from Mark Richards
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 21 Mar 2007 05:01:11 +0000 (05:01 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 21 Mar 2007 05:01:11 +0000 (05:01 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@782 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

lcd4linux.c
plugin_file.c
plugin_imon.c

index 33a41e7fe94c68cc81ab444afdd39f52d82bd5c1..eee332b72a921a70606d232778ca0801f7a391a5 100644 (file)
@@ -82,7 +82,7 @@ static void interactive_mode(void)
     RESULT result = { 0, 0, 0, NULL };
 
     printf("\neval> ");
-    for (fgets(line, 1024, stdin); !feof(stdin); fgets(line, 1024, stdin)) {
+    for (fgets(line, sizeof(line), stdin); !feof(stdin); fgets(line, sizeof(line), stdin)) {
        if (line[strlen(line) - 1] == '\n')
            line[strlen(line) - 1] = '\0';
        if (strlen(line) > 0) {
index 3492ea5bb9cd85f9638acb6d31feb66712e73acb..a246870bdd9e89007e4c33fb3a2e6e18e39e3e4e 100644 (file)
@@ -55,7 +55,6 @@
 static void my_readline(RESULT * result, RESULT * arg1, RESULT * arg2)
 {
     char value[80], val2[80];
-    char *pos;
     FILE *fp;
     int reqline, i, size;
 
@@ -68,14 +67,12 @@ static void my_readline(RESULT * result, RESULT * arg1, RESULT * arg2)
        i = 0;
        while (!feof(fp) && i++ < reqline) {
            fgets(val2, sizeof(val2), fp);
-           size = strcspn(val2, "\n");
+           size = strcspn(val2, "\r\n");
            strncpy(value, val2, size);
            value[size] = '\0';
-           pos = strchr(val2, '\n');
            /* more than 80 chars, chew up rest of line */
-           while (!pos) {
+           while (!feof(fp) && strchr(val2, '\n') == NULL) {
                fgets(val2, sizeof(val2), fp);
-               pos = strchr(val2, '\n');
            }
        }
        fclose(fp);
index 943712d1d77b0a7867479fe5bc350bd6c6cf49e8..67217a56b0d568bf77ac49c64cb629fbc81ce0de 100644 (file)
@@ -185,7 +185,7 @@ static void phonebook(char *number)
     if (!fp)
        return;
 
-    while (fgets(line, 128, fp)) {
+    while (fgets(line, sizeof(line), fp)) {
        if (*line == '#')
            continue;
        if (!strncmp(line, number, strlen(number))) {