From 5be409c981e54efd335f311f082bc6a3dc18fadf Mon Sep 17 00:00:00 2001 From: sje Date: Mon, 2 Jul 2007 04:28:46 +0000 Subject: fix for nick formatting git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@238 4f64403b-2f21-0410-a795-97e2b3489a10 --- MySpace/formatting.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'MySpace/formatting.cpp') diff --git a/MySpace/formatting.cpp b/MySpace/formatting.cpp index 891f75e..e66d0f6 100644 --- a/MySpace/formatting.cpp +++ b/MySpace/formatting.cpp @@ -1,7 +1,7 @@ #include "common.h" #include "formatting.h" -void entitize(char *buff, int size) { +void entitize_msg(char *buff, int size) { char *tmp = new char[size]; int in = 0, out = 0; @@ -23,7 +23,7 @@ void entitize(char *buff, int size) { buff[size - 1] = 0; } -void unentitize(char *buff) { +void unentitize_msg(char *buff) { int in = 0, out = 0; while(buff[in]) { if(buff[in] == '&') { @@ -45,6 +45,39 @@ void unentitize(char *buff) { buff[out] = 0; } +void entitize_nick(char *buff, int size) { + char *tmp = new char[size]; + + int in = 0, out = 0; + while(buff[in] && out < size) { + switch(buff[in]) { + case '\'': in++; strncpy(tmp + out, "'", size - out); out += 5; break; + default: + tmp[out++] = buff[in++]; + } + } + tmp[out] = 0; + + strncpy(buff, tmp, size); + delete tmp; + buff[size - 1] = 0; +} + +void unentitize_nick(char *buff) { + int in = 0, out = 0; + while(buff[in]) { + if(buff[in] == '&') { + if(strncmp(buff + in, "'", 5) == 0) { + buff[out++] = '\''; in += 5; + } else + buff[out++] = buff[in++]; + } else + buff[out++] = buff[in++]; + } + buff[out] = 0; +} + + void strip_tags(char *buff) { int in = 0, out = 0; while(buff[in]) { -- cgit v1.2.3