| 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; |