Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/histolog.c @ 2073:990cad5123f3
Try to recover when a history log file is damaged
Mcabber used to hang when a history file contained NUL characters.
Thanks to nedko for the report.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 29 Sep 2013 10:44:42 +0200 |
parents | ec737f5f1d6f |
children | 09508eeb81dc |
comparison
equal
deleted
inserted
replaced
2072:0722fe4b7580 | 2073:990cad5123f3 |
---|---|
227 break; | 227 break; |
228 ln++; | 228 ln++; |
229 | 229 |
230 while (1) { | 230 while (1) { |
231 for (tail = data; *tail; tail++) ; | 231 for (tail = data; *tail; tail++) ; |
232 if (tail == data) { | |
233 // That would happen if the log file has NUL characters... | |
234 scr_LogPrint(LPRINT_LOGNORM, "Corrupted history file! Trying to recover."); | |
235 err = 1; | |
236 break; | |
237 } | |
232 noeol = (*(tail-1) != '\n'); | 238 noeol = (*(tail-1) != '\n'); |
233 if (!noeol) | 239 if (!noeol) |
234 break; | 240 break; |
235 /* TODO: duplicated code... could do better... */ | 241 /* TODO: duplicated code... could do better... */ |
236 if (tail == data + data_size-2) { | 242 if (tail == data + data_size-2) { |