fix some bugs on OS X and fix a bug that caused style attributes

to be misaligned for lines with tabs in them.
pull/37/merge
Tim Stack 13 years ago
parent 099edac3ba
commit 9fb10d5340

4
aclocal.m4 vendored

@ -13,8 +13,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
[m4_warning([this file was generated for autoconf 2.65.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
[m4_warning([this file was generated for autoconf 2.68.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])

571
configure vendored

File diff suppressed because it is too large Load Diff

@ -154,11 +154,11 @@ int log_format::log_scanf(const char *line,
int curr_fmt = -1, retval = 0;
va_list args;
va_start(args, time_out);
while (next_format(fmt, curr_fmt, this->lf_fmt_lock)) {
va_start(args, time_out);
time_dest[0] = '\0';
retval = vsscanf(line, fmt[curr_fmt], args);
if (retval < expected_matches) {
retval = 0;
@ -199,9 +199,9 @@ int log_format::log_scanf(const char *line,
if (!found)
retval = 0;
}
}
va_end(args);
va_end(args);
}
return retval;
}

@ -66,6 +66,29 @@ static void line_ready_tramp(char *line)
rl_callback_handler_remove();
}
static int reliable_send(int sock, char *buf, size_t len)
{
int retval;
while ((retval = send(sock, buf, len, 0)) == -1) {
if (errno == ENOBUFS) {
fd_set ready_wfds;
FD_ZERO(&ready_wfds);
FD_SET(sock, &ready_wfds);
select(sock + 1, NULL, &ready_wfds, NULL, NULL);
}
else if (errno == EINTR) {
continue;
}
else {
break;
}
}
return retval;
}
char *readline_context::completion_generator(const char *text, int state)
{
static vector<string> matches;
@ -296,6 +319,7 @@ void readline_curses::start(void)
int context, prompt_start = 0;
char type[32];
fprintf(stderr, "msg: %s\n", msg);
msg[rc] = '\0';
if (sscanf(msg, "f:%d:%n", &context, &prompt_start) == 1 &&
prompt_start != 0 &&
@ -340,10 +364,10 @@ void readline_curses::start(void)
fprintf(stderr, "got timeout\n");
got_timeout = 0;
snprintf(msg, sizeof(msg), "t:%s", rl_line_buffer);
if (write(this->rc_command_pipe[RCF_SLAVE],
msg,
strlen(msg)) == -1) {
perror("write failed");
if (reliable_send(this->rc_command_pipe[RCF_SLAVE],
msg,
strlen(msg)) == -1) {
perror("got_timeout: write failed");
exit(1);
}
}
@ -423,8 +447,10 @@ void readline_curses::line_ready(const char *line)
snprintf(msg, sizeof(msg), "d:%s", expanded.in());
break;
}
if (write(this->rc_command_pipe[RCF_SLAVE], msg, strlen(msg)) == -1) {
perror("write failed");
if (reliable_send(this->rc_command_pipe[RCF_SLAVE],
msg,
strlen(msg)) == -1) {
perror("line_ready: write failed");
exit(1);
}
}
@ -486,7 +512,7 @@ void readline_curses::handle_key(int ch)
bch = this->map_input(ch, len);
if (write(this->rc_pty[RCF_MASTER], bch, len) == -1) {
perror("write failed");
perror("handle_key: write failed");
}
fprintf(stderr, "to child %d\n", bch[0]);
if (ch == '\t' || ch == '\r') {
@ -501,10 +527,10 @@ void readline_curses::focus(int context, const char *prompt)
this->rc_active_context = context;
snprintf(buffer, sizeof(buffer), "f:%d:%s", context, prompt);
if (write(this->rc_command_pipe[RCF_MASTER],
if (reliable_send(this->rc_command_pipe[RCF_MASTER],
buffer,
strlen(buffer) + 1) == -1) {
perror("write failed");
perror("focus: write failed");
}
wmove(this->vc_window, this->get_actual_y(), 0);
wclrtoeol(this->vc_window);
@ -517,10 +543,11 @@ void readline_curses::add_possibility(int context, string type, string value)
snprintf(buffer, sizeof(buffer),
"ap:%d:%s:%s",
context, type.c_str(), value.c_str());
if (write(this->rc_command_pipe[RCF_MASTER],
buffer,
strlen(buffer) + 1) == -1) {
perror("write failed");
fprintf(stderr, "msg: %s\n", buffer);
if (reliable_send(this->rc_command_pipe[RCF_MASTER],
buffer,
strlen(buffer) + 1) == -1) {
perror("add_possibility: write failed");
}
}
@ -531,10 +558,10 @@ void readline_curses::rem_possibility(int context, string type, string value)
snprintf(buffer, sizeof(buffer),
"rp:%d:%s:%s",
context, type.c_str(), value.c_str());
if (write(this->rc_command_pipe[RCF_MASTER],
buffer,
strlen(buffer) + 1) == -1) {
perror("write failed");
if (reliable_send(this->rc_command_pipe[RCF_MASTER],
buffer,
strlen(buffer) + 1) == -1) {
perror("rem_possiblity: write failed");
}
}

@ -250,10 +250,10 @@ public:
return this->tc_match_count;
};
void match_reset() {
this->tc_match_count = 0;
this->tc_bookmarks[&BM_SEARCH].clear();
}
void match_reset() {
this->tc_match_count = 0;
this->tc_bookmarks[&BM_SEARCH].clear();
};
typedef std::map<std::string, highlighter> highlight_map_t;

@ -21,6 +21,7 @@ void view_curses::mvwattrline(WINDOW *window,
string_attrs_t &sa = al.get_attrs();
string &line = al.get_string();
string_attrs_t::iterator iter;
std::vector<size_t> tab_list;
char *buffer;
line_width = lr.length();
@ -30,6 +31,7 @@ void view_curses::mvwattrline(WINDOW *window,
size_t tab;
while ((tab = line.find('\t')) != string::npos) {
tab_list.push_back(tab);
line = line.replace(tab, 1, 8, ' ');
}
while ((tab = line.find('\r')) != string::npos) {
@ -50,10 +52,23 @@ void view_curses::mvwattrline(WINDOW *window,
for (iter = sa.begin(); iter != sa.end(); iter++) {
struct line_range attr_range = iter->first;
std::vector<size_t>::iterator tab_iter;
assert(attr_range.lr_start >= 0);
assert(attr_range.lr_end >= -1);
tab_iter = lower_bound(tab_list.begin(),
tab_list.end(),
attr_range.lr_start);
attr_range.lr_start += (8 * (tab_iter - tab_list.begin()));
if (attr_range.lr_end != -1) {
tab_iter = lower_bound(tab_list.begin(),
tab_list.end(),
attr_range.lr_end);
attr_range.lr_end += (8 * (tab_iter - tab_list.begin()));
}
attr_range.lr_start = max(0, attr_range.lr_start - lr.lr_start);
if (attr_range.lr_end == -1) {
attr_range.lr_end = line_width;

Loading…
Cancel
Save