summaryrefslogtreecommitdiffstats
path: root/source/param
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1999-12-21 02:15:53 +0000
committerJeremy Allison <jra@samba.org>1999-12-21 02:15:53 +0000
commit023f90e7664d358ddf73272597e75041f5413e9f (patch)
treecac060d659c9f52c65b3c580e7efc32de4e0af82 /source/param
parent886ad59d798175f037ea9249dcefa78660e4992a (diff)
downloadsamba-023f90e7664d358ddf73272597e75041f5413e9f.tar.gz
samba-023f90e7664d358ddf73272597e75041f5413e9f.tar.xz
samba-023f90e7664d358ddf73272597e75041f5413e9f.zip
Fix based on code from monyo@home.monyo.com to fix multibyte continuation
issues. Jeremy.
Diffstat (limited to 'source/param')
-rw-r--r--source/param/params.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/source/param/params.c b/source/param/params.c
index 74dd3d7a254..944bc3d1b43 100644
--- a/source/param/params.c
+++ b/source/param/params.c
@@ -157,28 +157,42 @@ static int EatComment( FILE *InFile )
return( c );
} /* EatComment */
+/*****************************************************************************
+ * Scan backards within a string to discover if the last non-whitespace
+ * character is a line-continuation character ('\\').
+ *
+ * Input: line - A pointer to a buffer containing the string to be
+ * scanned.
+ * pos - This is taken to be the offset of the end of the
+ * string. This position is *not* scanned.
+ *
+ * Output: The offset of the '\\' character if it was found, or -1 to
+ * indicate that it was not.
+ *
+ *****************************************************************************/
+
static int Continuation( char *line, int pos )
- /* ------------------------------------------------------------------------ **
- * Scan backards within a string to discover if the last non-whitespace
- * character is a line-continuation character ('\\').
- *
- * Input: line - A pointer to a buffer containing the string to be
- * scanned.
- * pos - This is taken to be the offset of the end of the
- * string. This position is *not* scanned.
- *
- * Output: The offset of the '\\' character if it was found, or -1 to
- * indicate that it was not.
- *
- * ------------------------------------------------------------------------ **
- */
- {
+{
+ int pos2 = 0;
+
pos--;
while( (pos >= 0) && isspace(line[pos]) )
pos--;
- return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
- } /* Continuation */
+ /* we should recognize if `\` is part of a multibyte character or not. */
+ while(pos2 <= pos) {
+ size_t skip = 0;
+ skip = skip_multibyte_char(line[pos2]);
+ if (skip) {
+ pos2 += skip;
+ } else if (pos == pos2) {
+ return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
+ } else {
+ pos2++;
+ }
+ }
+ return (-1);
+}
static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )