From 169c55b9496aaa8517f18f9f288b9fdf759040df Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Wed, 12 Nov 2008 23:13:57 +0000 Subject: Simplify, use 'o' printf conversion specifier to print number in octal. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4904 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/lib-config/write.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/lib-config/write.c b/src/lib-config/write.c index 26c40a7e..c5f0a617 100644 --- a/src/lib-config/write.c +++ b/src/lib-config/write.c @@ -85,20 +85,6 @@ static int config_has_specials(const char *text) return FALSE; } -static int get_octal(int decimal) -{ - int octal, pos; - - octal = 0; pos = 0; - while (decimal > 0) { - octal += (decimal & 7)*(pos == 0 ? 1 : pos); - decimal /= 8; - pos += 10; - } - - return octal; -} - static char *config_escape_string(const char *text) { GString *str; @@ -111,7 +97,7 @@ static char *config_escape_string(const char *text) if (*text == '\\' || *text == '"') g_string_sprintfa(str, "\\%c", *text); else if ((unsigned char) *text < 32) - g_string_sprintfa(str, "\\%03d", get_octal(*text)); + g_string_sprintfa(str, "\\%03o", *text); else g_string_append_c(str, *text); text++; -- cgit v1.2.3