Mercurial > pidgin.yaz
comparison src/buddy.c @ 4855:e4bfaba117e4
[gaim-migrate @ 5182]
the real solution is to count string length better ;-)
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 22 Mar 2003 16:43:41 +0000 |
parents | d1c17e81055e |
children | ac9ed6c5594f |
comparison
equal
deleted
inserted
replaced
4854:3755ec4e3951 | 4855:e4bfaba117e4 |
---|---|
892 g_free(tmp); | 892 g_free(tmp); |
893 tmp = new; | 893 tmp = new; |
894 } | 894 } |
895 | 895 |
896 if(tmp) { | 896 if(tmp) { |
897 char *temp; | 897 char buf[32]; |
898 | 898 char *c = tmp; |
899 int length = 0, vis=0; | |
900 gboolean inside = FALSE; | |
899 g_strdelimit(tmp, "\n", ' '); | 901 g_strdelimit(tmp, "\n", ' '); |
900 | 902 |
901 if(strlen(tmp) > 20) { | 903 while(*c && vis < 20) { |
902 char *c1, *c2; | 904 if(*c == '&') |
903 | 905 inside = TRUE; |
904 statustext = g_strdup_printf("%.20s... ", tmp); | 906 if(!inside) |
905 | 907 vis++; |
906 if ((c1 = strrchr(statustext, '&')) != NULL) { | 908 if(*c == ';') |
907 if ((c2 = strrchr(statustext, ';')) == NULL || | 909 inside = FALSE; |
908 c2 < c1) { | 910 length++; |
909 | 911 c++; /* this is fun */ |
910 char *new_statustext; | |
911 | |
912 /* We must escape this broken entity. */ | |
913 new_statustext = g_new0(char, strlen(statustext) + 5); | |
914 | |
915 strncpy(new_statustext, statustext, c1 - statustext); | |
916 sprintf(new_statustext + (c1 - statustext), | |
917 "&%s", c1 + 1); | |
918 | |
919 g_free(statustext); | |
920 | |
921 statustext = new_statustext; | |
922 } | |
923 } | |
924 | |
925 } | 912 } |
913 | |
914 if(vis == 20) | |
915 g_snprintf(buf, sizeof(buf), "%%.%ds...", length); | |
926 else | 916 else |
927 statustext = g_strdup_printf("%s ", tmp); | 917 g_snprintf(buf, sizeof(buf), "%%s "); |
918 | |
919 statustext = g_strdup_printf(buf, tmp); | |
928 | 920 |
929 g_free(tmp); | 921 g_free(tmp); |
930 } | 922 } |
931 } | 923 } |
932 | 924 |