From 09478956c8636b739de1ea86ab79b7182435f0e1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 3 Jun 2008 07:42:06 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=1437 "Zeilenumbruch im Einheitennamen" - apply fixes to existing data. --- src/common/kernel/binarystore.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/common/kernel/binarystore.c b/src/common/kernel/binarystore.c index 83c9d96c9..78961dc4d 100644 --- a/src/common/kernel/binarystore.c +++ b/src/common/kernel/binarystore.c @@ -151,6 +151,7 @@ bin_w_str(struct storage * store, const char * tok) return result; } +#define FIX_INVALID_CHARS static char * bin_r_str(struct storage * store) { @@ -162,6 +163,16 @@ bin_r_str(struct storage * store) fread(result, sizeof(char), len, file(store)); result[len] = 0; +#ifdef FIX_INVALID_CHARS + { + char * p = strpbrk(result, "\n\r"); + while (p) { + log_error(("Invalid character %d in input string \"%s\".\n", *p, result)); + strcpy(p, p+1); + p = strpbrk(p, "\n\r"); + } + } +#endif return result; } return NULL; @@ -187,6 +198,16 @@ bin_r_str_buf(struct storage * store, char * result, size_t size) } else { result[len] = 0; } +#ifdef FIX_INVALID_CHARS + { + char * p = strpbrk(result, "\n\r"); + while (p) { + log_error(("Invalid character %d in input string \"%s\".\n", *p, result)); + strcpy(p, p+1); + p = strpbrk(p, "\n\r"); + } + } +#endif } }