From 2b2da0beab8dc24c79b94b40fed2f9bf08999d82 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 9 Jul 2015 01:48:34 +0200 Subject: degesch: support CASEMAPPING=rfc1459-strict --- common.c | 21 +++++++++++++++++++++ degesch.c | 7 +++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/common.c b/common.c index 12e1eff..62efb6f 100644 --- a/common.c +++ b/common.c @@ -58,6 +58,16 @@ (link)->next = (following); \ BLOCK_END +#define TRIVIAL_STRXFRM(name, fn) \ + static size_t \ + name (char *dest, const char *src, size_t n) \ + { \ + size_t len = strlen (src); \ + while (n-- && (*dest++ = (fn) (*src++))) \ + ; \ + return len; \ + } + static void transform_str (char *s, int (*tolower) (int c)) { @@ -103,6 +113,17 @@ strncasecmp_ascii (const char *a, const char *b, size_t n) return 0; } +static int +irc_tolower_strict (int c) +{ + if (c == '[') return '{'; + if (c == ']') return '}'; + if (c == '\\') return '|'; + return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c; +} + +TRIVIAL_STRXFRM (irc_strxfrm_strict, irc_tolower_strict) + static char * resolve_relative_runtime_filename (const char *filename) { diff --git a/degesch.c b/degesch.c index 556c149..ef77c2a 100644 --- a/degesch.c +++ b/degesch.c @@ -5669,12 +5669,11 @@ static void irc_handle_isupport_casemapping (struct server *s, char *value) { if (!strcmp (value, "ascii")) - irc_set_casemapping (s, tolower_ascii, tolower_ascii_strxfrm); + irc_set_casemapping (s, tolower_ascii, tolower_ascii_strxfrm); else if (!strcmp (value, "rfc1459")) - irc_set_casemapping (s, irc_tolower, irc_strxfrm); + irc_set_casemapping (s, irc_tolower, irc_strxfrm); else if (!strcmp (value, "rfc1459-strict")) - // TODO: implement - irc_set_casemapping (s, irc_tolower, irc_strxfrm); + irc_set_casemapping (s, irc_tolower_strict, irc_strxfrm_strict); } static void -- cgit v1.2.3-70-g09d2