static void do_compile_error(EditState *s, int dir) { QEmacsState *qs = s->qe_state; EditState *e; EditBuffer *b; int offset, offset1, found_offset; char filename[MAX_FILENAME_SIZE], *q; int line_num, c; /* CG: should have a buffer flag for error source. * first check if current buffer is an error source. * if not, then scan for appropriate error source * in buffer least recently used order */ if ((b = eb_find("*compilation*")) == NULL && (b = eb_find("*shell*")) == NULL && (b = eb_find("*errors*")) == NULL) { put_status(s, "No compilation buffer"); return; } /* find next/prev error */ offset = error_offset; if (offset < 0) { offset = 0; goto find_error; } for (;;) { if (dir > 0) { if (offset >= b->total_size) { put_status(s, "No more errors"); return; } for (;;) { c = eb_nextc(b, offset, &offset); if (c == '\n') break; } } else { if (offset <= 0) { put_status(s, "No previous error"); return; } eb_prevc(b, offset, &offset); for (;;) { c = eb_prevc(b, offset, &offset1); if (c == '\n') break; offset = offset1; } } find_error: found_offset = offset; /* extract filename */ q = filename; for (;;) { c = eb_nextc(b, offset, &offset); if (c == '\n' || c == '\t' || c == ' ') goto next_line; if (c == ':') break; if ((q - filename) < (int)sizeof(filename) - 1) *q++ = c; } *q = '\0'; /* extract line number */ line_num = 0; for (;;) { c = eb_nextc(b, offset, &offset); if (c == ':') break; if (!isdigit(c)) goto next_line; line_num = line_num * 10 + c - '0'; } if (line_num >= 1) { if (line_num != last_line_num || strcmp(filename, last_filename) != 0) { last_line_num = line_num; pstrcpy(last_filename, sizeof(last_filename), filename); break; } } next_line: offset = found_offset; } error_offset = found_offset; /* update offsets */ for (e = qs->first_window; e != NULL; e = e->next_window) { if (e->b == b) { e->offset = error_offset; } } /* CG: Should remove popups, sidepanes, helppanes... */ /* go to the error */ do_load(s, filename); do_goto_line(s, line_num); }
static void do_compile_error(EditState *s, int dir) { QEmacsState *qs = &qe_state; EditState *e; EditBuffer *b; int offset, offset1, found_offset; char filename[1024], *q; int line_num, c; b = eb_find("*compilation*"); if (!b) { b = eb_find("*shell*"); if (!b) { put_status(s, "No compilation buffer"); return; } } /* find next/prev error */ offset = error_offset; if (offset < 0) { offset = 0; goto find_error; } for(;;) { if (dir > 0) { if (offset >= b->total_size) { put_status(s, "No more errors"); return; } for(;;) { c = eb_nextc(b, offset, &offset); if (c == '\n') break; } } else { if (offset <= 0) { put_status(s, "No previous error"); return; } eb_prevc(b, offset, &offset); for(;;) { c = eb_prevc(b, offset, &offset1); if (c == '\n') break; offset = offset1; } } find_error: found_offset = offset; /* extract filename */ q = filename; for(;;) { c = eb_nextc(b, offset, &offset); if (c == '\n' || c == '\t' || c == ' ') goto next_line; if (c == ':') break; if ((q - filename) < sizeof(filename) - 1) *q++ = c; } *q = '\0'; /* extract line number */ line_num = 0; for(;;) { c = eb_nextc(b, offset, &offset); if (c == ':') break; if (!isdigit(c)) goto next_line; line_num = line_num * 10 + c - '0'; } if (line_num >= 1) { if (line_num != last_line_num || strcmp(filename, last_filename) != 0) { last_line_num = line_num; pstrcpy(last_filename, sizeof(last_filename), filename); break; } } next_line: offset = found_offset; } error_offset = found_offset; /* update offsets */ for(e = qs->first_window; e != NULL; e = e->next_window) { if (e->b == b) { e->offset = error_offset; } } /* go to the error */ do_load(s, filename); do_goto_line(s, line_num); }