static void displaysettings(struct termios *m, int all) { const struct key *kbd = keys; const struct mode *mod = modes; struct winsize winsize; speed_t in, out; tcflag_t *bitsp, mask; const char *linestr; in = cfgetispeed(m); out = cfgetospeed(m); if (!in || in == out) { if (all || out != B38400) printtoken("speed %s baud;", baudtostr(out)); } else { printtoken("ispeed %s baud;", baudtostr(in)); printtoken("ospeed %s baud;", baudtostr(out)); } if (all) { if (ioctl(STDIN_FILENO, TIOCGWINSZ, &winsize)) eprintf("TIOCGWINSZ <stdin>:"); printtoken("rows %u;", winsize.ws_row); printtoken("columns %u;", winsize.ws_col); } printtoken("\n"); if (all || m->c_line != 0) { linestr = linetostr(m->c_line); if (linestr) printtoken("line = %s;", linestr); else printtoken("line = %u;", (unsigned)(m->c_line)); } if (all || (m->c_cc[VMIN] != 1 && !(m->c_lflag & ICANON))) printtoken("min = %u;", (unsigned)(m->c_cc[VMIN])); if (all || (m->c_cc[VTIME] != 0 && !(m->c_lflag & ICANON))) printtoken("time = %u;", (unsigned)(m->c_cc[VTIME])); printtoken("\n"); for (; kbd->op; kbd++) if (all || m->c_cc[kbd->index] != kbd->sanevalue) printtoken("%s = %s;", kbd->op, keytostr(m->c_cc[kbd->index])); printtoken("\n"); for (; mod->op; mod++) { switch (mod->type) { case CTRL: bitsp = &m->c_cflag; break; case IN: bitsp = &m->c_iflag; break; case OUT: bitsp = &m->c_oflag; break; case LOCAL: bitsp = &m->c_lflag; break; default: bitsp = 0; break; } if (!bitsp || (mod->flags & DUP)) continue; mask = mod->clear ? mod->clear : mod->set; if ((*bitsp & mask) == mod->set) { if (all || !isdefault(mod->flags)) printtoken("%s", mod->op); } else if (mod->flags & BOOL) { if (all || isdefault(mod->flags)) printtoken("-%s", mod->op); } } printtoken("\n"); }
/* ARGSUSED */ static int compile_goto_error(int f, int n) { struct buffer *bp; struct mgwin *wp; char *fname, *line, *lp, *ln; int lineno; char *adjf, path[NFILEN]; const char *errstr; struct line *last; compile_win = curwp; compile_buffer = curbp; last = blastlp(compile_buffer); retry: /* last line is compilation result */ if (curwp->w_dotp == last) return (FALSE); if ((line = linetostr(curwp->w_dotp)) == NULL) return (FALSE); lp = line; if ((fname = strsep(&lp, ":")) == NULL || *fname == '\0') goto fail; if ((ln = strsep(&lp, ":")) == NULL || *ln == '\0') goto fail; lineno = (int)strtonum(ln, INT_MIN, INT_MAX, &errstr); if (errstr) goto fail; if (fname && fname[0] != '/') { if (getbufcwd(path, sizeof(path)) == FALSE) goto fail; if (strlcat(path, fname, sizeof(path)) >= sizeof(path)) goto fail; adjf = path; } else { adjf = adjustname(fname, TRUE); } free(line); if (adjf == NULL) return (FALSE); if ((bp = findbuffer(adjf)) == NULL) return (FALSE); if ((wp = popbuf(bp, WNONE)) == NULL) return (FALSE); curbp = bp; curwp = wp; if (bp->b_fname[0] == '\0') readin(adjf); gotoline(FFARG, lineno); return (TRUE); fail: free(line); if (curwp->w_dotp != blastlp(curbp)) { curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_rflag |= WFMOVE; goto retry; } dobeep(); ewprintf("No more hits"); return (FALSE); }