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 */ /* XXX: could be more efficient */
if (conf_backlog && log_has_backlog(LINK(ic)->log, chan->name)) { if (conf_backlog && log_has_backlog(LINK(ic)->log, chan->name)) {
char *line; char *line;
while ((line = log_backread(LINK(ic)->log, chan->name))) { int skip = 0;
write_line(CONN(ic), line); while ((line =
log_backread(LINK(ic)->log, chan->name, &skip))) {
if (!skip)
write_line(CONN(ic), line);
free(line); free(line);
} }
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", chan->name, 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 */ /* backlog privates */
char *str; char *str;
while ((str = log_backread(LINK(ic)->log, S_PRIVATES))) { int skip = 0;
write_line(CONN(ic), str); while ((str = log_backread(LINK(ic)->log, S_PRIVATES, &skip))) {
if (!skip)
write_line(CONN(ic), str);
free(str); free(str);
} }
} }

View File

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

View File

@ -88,7 +88,7 @@ void log_disconnected(log_t *logdata);
void log_ping_timeout(log_t *logdata); void log_ping_timeout(log_t *logdata);
void log_client_disconnected(log_t *logdata); void log_client_disconnected(log_t *logdata);
void log_client_connected(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); int log_has_backlog(log_t *logdata, char *destination);
void log_flush_all(void); void log_flush_all(void);
void log_client_none_connected(log_t *logdata); void log_client_none_connected(log_t *logdata);