mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:13:02 +01:00
fix for issue #254
This commit is contained in:
parent
773a75b948
commit
48cf4ebf02
@ -39,4 +39,4 @@ int complete_line(ToxWindow *self, const void *list, int n_items, int size);
|
||||
return diff between old len and new len of ctx->line, -1 if no matches or > 1 match */
|
||||
int dir_match(ToxWindow *self, Tox *m, const wchar_t *line);
|
||||
|
||||
#endif /* #define AUTOCOMPLETE_H */
|
||||
#endif /* #define AUTOCOMPLETE_H */
|
||||
|
12
src/log.c
12
src/log.c
@ -89,8 +89,8 @@ static int init_logging_session(char *name, const char *selfkey, const char *oth
|
||||
snprintf(log_path, sizeof(log_path), "%s%s%s-%s%s%s.log", user_config_dir, LOGDIR, self_id, name, namedash, other_id);
|
||||
|
||||
free(user_config_dir);
|
||||
|
||||
log->file = fopen(log_path, "a+");
|
||||
|
||||
snprintf(log->path, sizeof(log->path), "%s", log_path);
|
||||
|
||||
if (log->file == NULL)
|
||||
@ -160,7 +160,7 @@ void load_chat_history(ToxWindow *self, struct chatlog *log)
|
||||
struct stat st;
|
||||
|
||||
if (stat(log->path, &st) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "* Failed to stat log file");
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to stat log file");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -174,9 +174,15 @@ void load_chat_history(ToxWindow *self, struct chatlog *log)
|
||||
if (hstbuf == NULL)
|
||||
exit_toxic_err("failed in load_chat_history", FATALERR_MEMORY);
|
||||
|
||||
if (fseek(log->file, 0L, SEEK_SET) == -1) {
|
||||
free(hstbuf);
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to read log file");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fread(hstbuf, sz, 1, log->file) != 1) {
|
||||
free(hstbuf);
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "* Failed to read log file");
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to read log file");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user