Hello ML,

Here is a simple patch to support the multiline parsing.

Regards,

Fred.
>From 6ab05b5c9bb8f0a644652ba58376b21ccf800f4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= <flecai...@haproxy.com>
Date: Tue, 17 Apr 2018 10:54:08 +0200
Subject: [PATCH] MINOR: cfgparse: Add support for multiline parsing.

When an escaped trailing new line character is read, we make the parser
believe we have just read the number of bytes we read minus 2.

May be easily backported to versions 1.6 and newer.
---
 doc/configuration.txt | 4 +++-
 src/cfgparse.c        | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/configuration.txt b/doc/configuration.txt
index c687722..9e0408f 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -417,7 +417,9 @@ escaped by doubling or strong quoting them.
 
 Escaping is achieved by preceding a special character by a backslash ('\'):
 
-  \    to mark a space and differentiate it from a delimiter
+  \    to mark a space and differentiate it from a delimiter;
+       when followed by a trailing new line character, split the current
+       line into two parts (multiline parsing).
   \#   to mark a hash and differentiate it from a comment
   \\   to use a backslash
   \'   to use a single quote and differentiate it from strong quoting
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 621af6c..85c67a3 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -6980,6 +6980,12 @@ next_line:
 			continue;
 		}
 
+		if (end - line >= 2 && end[-2] == '\\') {
+			/* Make the parser erase the escaped trailing new line character. */
+			readbytes = end - line - 2;
+			continue;
+		}
+
 		readbytes = 0;
 
 		/* skip leading spaces */
-- 
2.1.4

Reply via email to