From: Jorge Pereira Date: Fri, 18 Oct 2019 02:58:07 +0000 (-0300) Subject: Let' be able to buffer multiple lines with a backslash X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=784aaf1191f2ab3ead0f62451ae552ebe97e58a2;p=thirdparty%2Ffreeradius-server.git Let' be able to buffer multiple lines with a backslash --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 36cd61578b8..0518201aa38 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -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 */