1
0
forked from bip/bip

Fixed empty line bug.

This commit is contained in:
nohar 2006-11-12 13:22:32 +00:00
parent 98dcc2e4d4
commit ae65ababf1
3 changed files with 21 additions and 6 deletions

View File

@ -578,8 +578,11 @@ static void irc_send_join(struct link_client *ic, struct channel *chan)
/* XXX: could be more efficient */
if (conf_backlog && log_has_backlog(LINK(ic)->log, chan->name)) {
char *line;
while ((line = log_backread(LINK(ic)->log, chan->name))) {
write_line(CONN(ic), line);
int skip = 0;
while ((line =
log_backread(LINK(ic)->log, chan->name, &skip))) {
if (!skip)
write_line(CONN(ic), line);
free(line);
}
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", chan->name,
@ -723,8 +726,10 @@ static void irc_cli_make_join(struct link_client *ic)
/* backlog privates */
char *str;
while ((str = log_backread(LINK(ic)->log, S_PRIVATES))) {
write_line(CONN(ic), str);
int skip = 0;
while ((str = log_backread(LINK(ic)->log, S_PRIVATES, &skip))) {
if (!skip)
write_line(CONN(ic), str);
free(str);
}
}

View File

@ -858,7 +858,7 @@ char *log_beautify(char *buf, char *dest)
return ret;
}
char *log_backread(log_t *logdata, char *destination)
char *log_backread(log_t *logdata, char *destination, int *skip)
{
char *buf;
size_t pos = 0;
@ -867,6 +867,8 @@ char *log_backread(log_t *logdata, char *destination)
int c;
char *ret;
*skip = 0;
if (!conf_always_backlog && logdata->connected)
return NULL;
@ -955,6 +957,10 @@ next_file:
goto next_file;
}
buf[pos] = 0;
if (pos == 0) {
*skip = 1;
return buf;
}
ret = log_beautify(buf, destination);
if (ret == NULL) {
pos = 0;
@ -1008,6 +1014,10 @@ next_file:
if (conf_always_backlog && c == EOF)
lf->backlog_offset--;
buf[pos] = 0;
if (pos == 0) {
*skip = 1;
return buf;
}
ret = log_beautify(buf, destination);
if (ret == NULL) {
pos = 0;

View File

@ -88,7 +88,7 @@ void log_disconnected(log_t *logdata);
void log_ping_timeout(log_t *logdata);
void log_client_disconnected(log_t *logdata);
void log_client_connected(log_t *logdata);
char *log_backread(log_t *logdata, char *destination);
char *log_backread(log_t *logdata, char *destination, int *skip);
int log_has_backlog(log_t *logdata, char *destination);
void log_flush_all(void);
void log_client_none_connected(log_t *logdata);