Mercurial > pidgin.yaz
changeset 1191:4fd0d35826fe
[gaim-migrate @ 1201]
thanks to decklin for this patch.
for some reason the logic in strcpy_withhtml looks funny to me. i'm sure it's just me though.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 03 Dec 2000 09:50:39 +0000 |
parents | c3ebd5932e32 |
children | a97e334ecfa2 |
files | src/away.c src/dialogs.c src/gaim.h src/server.c src/util.c |
diffstat | 5 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/away.c Sat Dec 02 20:02:59 2000 +0000 +++ b/src/away.c Sun Dec 03 09:50:39 2000 +0000 @@ -89,7 +89,6 @@ } } - void do_away_message(GtkWidget *w, struct away_message *a) { GtkWidget *back; @@ -178,7 +177,7 @@ buf2 = g_malloc(strlen(awaymessage->message)*4 + 1); - strcpy(buf2, awaymessage->message); + strncpy_withhtml(buf2, awaymessage->message, strlen(awaymessage->message)*4 + 1); serv_set_away(buf2); g_free(buf2); gtk_widget_show(imaway);
--- a/src/dialogs.c Sat Dec 02 20:02:59 2000 +0000 +++ b/src/dialogs.c Sun Dec 03 09:50:39 2000 +0000 @@ -1297,7 +1297,8 @@ buf = g_malloc(1); buf[0] = 0; } - g_snprintf(buf, MIN(strlen(junk) * 2, 4096), "%s", junk); + //g_snprintf(buf, MIN(strlen(junk) * 2, 4096), "%s", junk); + strncpy_withhtml(buf, junk, MIN(strlen(junk) * 2, 4096)); serv_set_info(gc, buf); g_free(buf); }
--- a/src/gaim.h Sat Dec 02 20:02:59 2000 +0000 +++ b/src/gaim.h Sun Dec 03 09:50:39 2000 +0000 @@ -550,6 +550,7 @@ extern void set_first_user (char *); extern int do_auto_login (char *); extern int file_is_dir (char *, GtkWidget *); +extern void strncpy_withhtml(gchar *, const gchar *, size_t); /* Functions in server.c */ /* input to serv */
--- a/src/server.c Sat Dec 02 20:02:59 2000 +0000 +++ b/src/server.c Sun Dec 03 09:50:39 2000 +0000 @@ -97,7 +97,7 @@ if (strlen(gc->user->user_info)) { buf = g_malloc(strlen(gc->user->user_info) * 4); - strcpy(buf, gc->user->user_info); + strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); serv_set_info(gc, buf); g_free(buf); }
--- a/src/util.c Sat Dec 02 20:02:59 2000 +0000 +++ b/src/util.c Sun Dec 03 09:50:39 2000 +0000 @@ -1232,3 +1232,16 @@ } } } + +void strncpy_withhtml(gchar *dest, const gchar *src, size_t destsize) +{ + gchar *sp = src, *dp = dest; + + while (dp < dest+destsize) { + if (*sp == '\n' && dp < dest+destsize-4) { + strcpy(dp, "<BR>"); + sp++; dp += 4; + } + else *dp++ = *sp++; + } +}