commit ddea8b93209ece2509d0b26850b8056360a08d71
Author: Oswald Buddenhagen <[email protected]>
Date: Wed Sep 25 20:56:52 2013 +0200
support backslash-escaping in the config file
note that no attempt is made at making this work in the compat wrapper.
src/config.c | 16 +++++++++++++---
src/mbsync.1 | 3 ++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/config.c b/src/config.c
index 2c2a086..7bf8aa3 100644
--- a/src/config.c
+++ b/src/config.c
@@ -48,7 +48,7 @@ static char *
get_arg( conffile_t *cfile, int required, int *comment )
{
char *ret, *p, *t;
- int quoted;
+ int escaped, quoted;
char c;
p = cfile->rest;
@@ -64,9 +64,14 @@ get_arg( conffile_t *cfile, int required, int *comment )
}
ret = 0;
} else {
- for (quoted = 0, ret = t = p; c; c = *p) {
+ for (escaped = 0, quoted = 0, ret = t = p; c; c = *p) {
p++;
- if (c == '"')
+ if (escaped && c >= 32) {
+ escaped = 0;
+ *t++ = c;
+ } else if (c == '\\')
+ escaped = 1;
+ else if (c == '"')
quoted ^= 1;
else if (!quoted && isspace( (unsigned char) c ))
break;
@@ -74,6 +79,11 @@ get_arg( conffile_t *cfile, int required, int *comment )
*t++ = c;
}
*t = 0;
+ if (escaped) {
+ error( "%s:%d: unterminated escape sequence\n",
cfile->file, cfile->line );
+ cfile->err = 1;
+ ret = 0;
+ }
if (quoted) {
error( "%s:%d: missing closing quote\n", cfile->file,
cfile->line );
cfile->err = 1;
diff --git a/src/mbsync.1 b/src/mbsync.1
index 965e65f..bdf5d3c 100644
--- a/src/mbsync.1
+++ b/src/mbsync.1
@@ -88,7 +88,8 @@ If specified twice, suppress warning messages as well.
The configuration file is mandatory; \fBmbsync\fR will not run without it.
Lines starting with a hash mark (\fB#\fR) are comments and are ignored
entirely.
Configuration items are keywords followed by one or more arguments;
-arguments containing spaces must be enclosed in double quotes (\fB"\fR).
+arguments containing spaces must be enclosed in double quotes (\fB"\fR),
+and literal double quotes and backslashes (\fB\\\fR) must be backslash-escaped.
All keywords (including those used as arguments) are case-insensitive.
Bash-like home directory expansion using the tilde (\fB~\fR) is supported
in all options which represent local paths.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel