int main() { char op; while (scanf("%c", &op) != EOF) { if (op < 'a') { op += 'a' - 'A'; } switch (op) { case 'd': { getlinenum(); n = argv[1]; set_init(n); /*if (n > 6000000) { for (;;); }*/ break; } case 'c': { int i, st, ed; getlinenum(); for (i = 1, st = argv[1], ed = argv[2]; (i <= argv[3])/* && (st <= n) && (ed <= n) && (st > 0) && (ed > 0) */; ++i, st += argv[5], ed += argv[4]) { set_connect(st, ed); } break; } case 'q': { int i, st, ed; int s1 = 0; int s2 = 0; getlinenum(); for (i = 1, st = argv[1], ed = argv[2]; (i <= argv[3])/* && (st <= n) && (ed <= n) && (st > 0) && (ed > 0) */; ++i, st += argv[5], ed += argv[4]) { if (set_isconnect(st, ed)) { ++s1; } else { ++s2; } } printf("%d - %d\n", s1, s2); break; } default: { break; } } } return 0; }
static int currentline (lua_State *L, CallInfo *ci) { int pc = currentpc(L, ci); if (pc < 0) return -1; /* only active lua functions have current-line information */ else return getlinenum(ci_func(ci)->l.p, pc); }
void *utf8fan2jian_init(const char *unihan) { char *data,*hzbuf,*hz,*hzfan,*hzjian; TCMAP *map; int hznum,hzlen; data = loadfile(unihan,NULL); if(!data) return NULL; hznum = getlinenum(data,"\n"); map = tcmapnew2(hznum); hzbuf = data; while((hz = getaline(hzbuf,"\n", &hzlen)) != NULL) { hzjian = strchr(hz,'='); if(!hzjian) return NULL; *hzjian++ = 0; hzfan = hz; trim(hzfan); trim(hzjian); tcmapput2(map,hzfan,hzjian); hzbuf = hz + hzlen + 1; } xfree(data); return map; }
int main(int argc, char **argv) { if (argc <= 1) { help(); exit(1); } getlinenum(argc, argv); for (filenum = 1; filenum < argc; ++filenum) { if (*argv[filenum] == '/') continue; fp = fopen(argv[filenum], "rb"); if (!fp) { fputs(head1, stderr); fputs(argv[filenum], stderr); fputs("\" not found.", stderr); fputs(head2, stderr); } else { fputs(head1, stderr); fputs(argv[filenum], stderr); gettail(); fputs(head2, stderr); for (cc = getc(fp); cc != EOF; cc = getc(fp)) { #ifdef __MSDOS__ if (cc != '\r') { fputc(cc, stdout); } #else fputc(cc, stdout); #endif } fclose(fp); } } return EXIT_SUCCESS; }
// Redisplay the mode line for the window pointed to by winp. If popbuf is NULL, display a fully-formatted mode line containing // the current buffer's name and filename (but in condensed form if the current terminal width is less than 96 columns); // otherwise, display only the buffer name and filename of buffer "popbuf". This is the only routine that has any idea of how // the mode line is formatted. You can change the mode line format by hacking at this routine. Called by "update" any time // there is a dirty window. void wupd_modeline(EWindow *winp,Buffer *popbuf) { int c; int n; // Cursor position. Buffer *bufp; ModeSpec *msp; int lchar; int condensed = term.t_ncol < 80 ? -1 : term.t_ncol < 96 ? 1 : 0; char wkbuf[32]; // Work buffer. static struct { // Mode display parameters. int leadch,trailch; uint flags; } *mdp,md[] = { {'(',')',0}, {'[',']',0}, {-1,-1,0}}; n = winp->w_toprow + winp->w_nrows; // Row location. // Note that we assume that setting REVERSE will cause the terminal driver to draw with the inverted relationship of // fcolor and bcolor, so that when we say to set the foreground color to "white" and background color to "black", the // fact that "reverse" is enabled means that the terminal driver actually draws "black" on a background of "white". // Makes sense, no? This way, devices for which the color controls are optional will still get the "reverse" signals. vscreen[n]->v_left = 0; vscreen[n]->v_right = term.t_ncol; #if COLOR vscreen[n]->v_flags |= VFCHGD | VFCOLOR; // Redraw next time. vscreen[n]->v_rfcolor = 7; // Black on. vscreen[n]->v_rbcolor = 0; // White... #else vscreen[n]->v_flags |= VFCHGD; // Redraw next time. #endif vtmove(n,0); // Seek to right line. if(winp == curwp) // Make the current buffer stand out. lchar = '='; #if REVSTA else if(opflags & OPHAVEREV) lchar = ' '; #endif else lchar = '-'; // Full display? if(popbuf == NULL) { bufp = winp->w_bufp; vtputc((bufp->b_flags & BFTRUNC) ? '#' : lchar); // "#" if truncated. vtputc((bufp->b_flags & BFCHGD) ? '*' : lchar); // "*" if changed. vtputc((bufp->b_flags & BFNARROW) ? '<' : lchar); // "<" if narrowed. vtputc(' '); n = 4; // Display program name and version. if(!condensed) { sprintf(wkbuf,"%s %s ",Myself,Version); n += vtputs(wkbuf); } // Are we horizontally scrolled? if(winp->w_face.wf_fcol > 0) { sprintf(wkbuf,"[<%d] ",winp->w_face.wf_fcol); n += vtputs(wkbuf); } // Display the screen number if bottom window and there's more than one screen. if(winp->w_nextp == NULL && scrcount() > 1) { sprintf(wkbuf,"S%hu ",cursp->s_num); n += vtputs(wkbuf); } // Display keyboard macro recording state. if(kmacro.km_state == KMRECORD) n += vtputs("*R* "); // Display the line and/or column point position if enabled and winp is current window. if(winp == curwp) { if(curbp->b_modes & MDLINE) { sprintf(wkbuf,"L:%ld ",getlinenum(bufp,winp->w_face.wf_dot.lnp)); n += vtputs(wkbuf); } if(curbp->b_modes & MDCOL) { sprintf(wkbuf,"C:%d ",getccol()); n += vtputs(wkbuf); } } // Display the modes, in short form if condensed display. md[0].flags = modetab[MDR_GLOBAL].flags & modetab[MDR_SHOW].flags; md[1].flags = winp->w_bufp->b_modes; mdp = md; do { msp = ((c = mdp->leadch) == '[') ? bmodeinfo : gmodeinfo; do { if(mdp->flags & msp->mask) { n += vtputc(c); c = ' '; if(condensed >= 0) n += vtputs(msp->mlname); else { n += vtputc(msp->mlname[0]); if(msp->mlname[1] != '\0') n += vtputc(msp->mlname[1]); } } } while((++msp)->name != NULL); if(c != mdp->leadch) { n += vtputc(mdp->trailch); n += vtputc(' '); } } while((++mdp)->leadch > 0); #if 0 // Display internal modes on modeline. vtputc(lchar); vtputc((winp->w_flags & WFCOLOR) ? 'C' : lchar); vtputc((winp->w_flags & WFMODE) ? 'M' : lchar); vtputc((winp->w_flags & WFHARD) ? 'H' : lchar); vtputc((winp->w_flags & WFEDIT) ? 'E' : lchar); vtputc((winp->w_flags & WFMOVE) ? 'V' : lchar); vtputc((winp->w_flags & WFFORCE) ? 'F' : lchar); vtputc(lchar); n += 8; #endif n += wupd_tab(lchar); } else { n = 0; bufp = popbuf; vtputc(lchar); n += wupd_tab(lchar) + 1; } // Display the buffer name. n += vtputs(bufp->b_bname) + 1; vtputc(' '); // Display the filename in the remaining space using strfit(). if(bufp->b_fname != NULL) { char wkbuf[TT_MAXCOLS]; n += wupd_tab(lchar); if(condensed < 0) { vtputc(*text34); // "File: " vtputc(':'); vtputc(' '); n += 3; } else n += vtputs(text34); // "File: " n += vtputs(strfit(wkbuf,term.t_ncol - n - 1,bufp->b_fname,0)) + 1; vtputc(' '); } // If it's the current window, not a pop-up, "pwd" mode, and room still available, display the working directory as // well. if(winp == curwp && popbuf == NULL && (modetab[MDR_GLOBAL].flags & MDWKDIR) && ((int) term.t_ncol - n) > 12) { char *wdp; char wkbuf[TT_MAXCOLS]; n += wupd_tab(lchar); n += vtputs(text274); // "WD: " (void) getwkdir(&wdp,false); n += vtputs(strfit(wkbuf,term.t_ncol - n - 1,wdp,0)) + 1; vtputc(' '); } // Pad to full width. while(n < (int) term.t_ncol) { vtputc(lchar); ++n; } }