comparison src/util.c @ 2603:24664768a739

[gaim-migrate @ 2616] i shouldn't have modified gaim.h like i did. *slaps own wrists* Do as I say, not as I do. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 25 Oct 2001 05:05:05 +0000
parents 35c23df11d16
children 3e2f455cb924
comparison
equal deleted inserted replaced
2602:c9192dea2bb1 2603:24664768a739
1164 if (in[n] == '3') 1164 if (in[n] == '3')
1165 n++; 1165 n++;
1166 n += 2; 1166 n += 2;
1167 continue; 1167 continue;
1168 } 1168 }
1169 /* why are we removing newlines and carriage returns?
1169 if ((c == 0x0D) || (c == 0x0A)) { 1170 if ((c == 0x0D) || (c == 0x0A)) {
1170 n++; 1171 n++;
1171 continue; 1172 continue;
1172 } 1173 }
1174 */
1173 if (c < 128) 1175 if (c < 128)
1174 result[i++] = (char)c; 1176 result[i++] = (char)c;
1175 else { 1177 else {
1176 result[i++] = (char)((c >> 6) | 192); 1178 result[i++] = (char)((c >> 6) | 192);
1177 result[i++] = (char)((c & 63) | 128); 1179 result[i++] = (char)((c & 63) | 128);
1179 n++; 1181 n++;
1180 } 1182 }
1181 result[i] = '\0'; 1183 result[i] = '\0';
1182 1184
1183 return result; 1185 return result;
1186 }
1187
1188 void strip_linefeed(gchar *text)
1189 {
1190 int i, j;
1191 gchar *text2 = g_malloc(strlen(text) + 1);
1192
1193 for (i = 0, j = 0; text[i]; i++)
1194 if (text[i] != '\r')
1195 text2[j++] = text[i];
1196 text2[j] = '\0';
1197
1198 strcpy(text, text2);
1199 g_free(text2);
1200 }
1201
1202 char *add_cr(char *text)
1203 {
1204 char *ret = NULL;
1205 int count = 0, i, j;
1206
1207 if (text[0] == '\n')
1208 count++;
1209 for (i = 1; i < strlen(text); i++)
1210 if (text[i] == '\n' && text[i - 1] != '\r')
1211 count++;
1212
1213 if (count == 0)
1214 return g_strdup(text);
1215
1216 ret = g_malloc0(strlen(text) + count + 1);
1217
1218 i = 0; j = 0;
1219 if (text[i] == '\n')
1220 ret[j++] = '\r';
1221 ret[j++] = text[i++];
1222 for (; i < strlen(text); i++) {
1223 if (text[i] == '\n' && text[i - 1] != '\r')
1224 ret[j++] = '\r';
1225 ret[j++] = text[i];
1226 }
1227
1228 debug_printf("got: %s, leaving with %s\n", text, ret);
1229
1230 return ret;
1184 } 1231 }
1185 1232
1186 time_t get_time(int year, int month, int day, int hour, int min, int sec) 1233 time_t get_time(int year, int month, int day, int hour, int min, int sec)
1187 { 1234 {
1188 struct tm tm; 1235 struct tm tm;