From: Karel Zak Date: Mon, 7 Jun 2010 10:57:03 +0000 (+0200) Subject: libmount: use mangle function from lib/ X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7043ced3d98e19e9e9daa832368d5a68e931524c;p=util-linux libmount: use mangle function from lib/ Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c index e103aad8..5dbcfa67 100644 --- a/shlibs/mount/src/tab_parse.c +++ b/shlibs/mount/src/tab_parse.c @@ -11,6 +11,7 @@ #include #include "nls.h" +#include "mangle.h" #include "mountP.h" static inline char *skip_spaces(char *s) @@ -31,29 +32,6 @@ static inline char *skip_nonspaces(char *s) return s; } -#define isoctal(a) (((a) & ~7) == '0') - -/* returns malloced pointer - no more strdup required */ -static void unmangle(char *s, char *buf, size_t len) -{ - size_t sz = 0; - assert(s); - - while(*s && sz < len - 1) { - if (*s == '\\' && sz + 4 < len - 1 && isoctal(s[1]) && - isoctal(s[2]) && isoctal(s[3])) { - - *buf++ = 64*(s[1] & 7) + 8*(s[2] & 7) + (s[3] & 7); - s += 4; - sz += 4; - } else { - *buf++ = *s++; - sz++; - } - } - *buf = '\0'; -} - static size_t next_word_size(char *s, char **start, char **end) { char *e; @@ -88,7 +66,7 @@ static char *next_word(char **s) if (!res) return NULL; - unmangle(*s, res, sz); + unmangle_to_buffer(*s, res, sz); *s = end + 1; return res; }