]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Let' be able to buffer multiple lines with a backslash 3055/head
authorJorge Pereira <jpereiran@gmail.com>
Fri, 18 Oct 2019 02:58:07 +0000 (23:58 -0300)
committerJorge Pereira <jpereiran@gmail.com>
Fri, 18 Oct 2019 12:54:05 +0000 (09:54 -0300)
src/bin/unit_test_attribute.c

index 36cd61578b8a371ab8dc27fb7f663de62a67ae7c..0518201aa38fa27c60a08357bc86a1ba2db5fc9f 100644 (file)
@@ -1646,6 +1646,7 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features,
         *      Loop over lines in the file or stdin
         */
        while (fgets(buffer, sizeof(buffer), fp) != NULL) {
+               bool                    backslash = strchr(buffer, '\\') ? true : false;
                char                    *p = strchr(buffer, '\n');
                command_entry_t *command;
                command_result_t        result = { .rcode = RESULT_OK };        /* Reset to OK */
@@ -1663,6 +1664,22 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features,
                        *p = '\0';
                }
 
+               /*
+                *      Backslash? then keep buffering.
+                */
+               if (backslash) {
+                       size_t len = strlen(buffer) - 2; /* take over: '\' + '\n' */
+
+                       while (fgets(&buffer[len], (sizeof(buffer) - len), fp)) {
+                               if (strchr(buffer, '\\')) {
+                                       len = strlen(buffer) - 2;
+                                       continue;
+                               }
+
+                               if (strchr(buffer, '\n')) break; /* continue the game */
+                       }
+               }
+
                p = buffer;
                fr_skip_whitespace(p);
                if (*p == '\0') continue;                               /* Blank line */