/* * ip_clrtoeol -- * Clear from the current cursor to the end of the line. * * PUBLIC: int ip_clrtoeol __P((SCR *)); */ int ip_clrtoeol(SCR *sp) { IP_BUF ipb; IP_PRIVATE *ipp = IPP(sp); /* Temporary hack until we can pass screen pointers * or name screens */ if (IS_VSPLIT(sp)) { size_t x, y, spcnt; IP_PRIVATE *ipp; int error; ipp = IPP(sp); y = ipp->row; x = ipp->col; error = 0; for (spcnt = sp->cols - x; spcnt > 0 && ! error; --spcnt) error = ip_addstr(sp, " ", 1); if (sp->coff == 0) error |= ip_addstr(sp, "|", 1); error |= ip_move(sp, y, x); return error; } ipb.code = SI_CLRTOEOL; return (vi_send(ipp->o_fd, NULL, &ipb)); }
int main(int argc, char **argv) { int k, ec=0; FILE *f=NULL; bfspace *p=NULL; ip *i=NULL; cell w,h; int ssize = DEFAULT_STACK_SIZE; int sssize = DEFAULT_STACKSTACK_SIZE; global_argv = argv; global_argc = argc; if (argc < 2) usage(); fungeprog_arg = -1; for(k=1; k<argc; k++) { #ifndef FBBI_MINIMAL if((!strcmp(argv[k], "-F")) || (!strcmp(argv[k], "-not-fast")) || (!strcmp(argv[k], "--not-fast"))) fast=0; if((!strcmp(argv[k], "-f")) || (!strcmp(argv[k], "-fast")) || (!strcmp(argv[k], "--fast"))) fast=1; if((!strcmp(argv[k], "-w")) || (!strcmp(argv[k], "-warn")) || (!strcmp(argv[k], "--warn"))) warn=1; if((!strcmp(argv[k], "-t")) || (!strcmp(argv[k], "-trace")) || (!strcmp(argv[k], "--trace"))) trace=1; if((!strcmp(argv[k], "-s")) || (!strcmp(argv[k], "-script")) || (!strcmp(argv[k], "--script"))) script = 1; if((!strcmp(argv[k], "-u")) || (!strcmp(argv[k], "-unefunge")) || (!strcmp(argv[k], "--unefunge"))) une = 1; if((!strcmp(argv[k], "-93")) || (!strcmp(argv[k], "-befunge93")) || (!strcmp(argv[k], "--befunge-93")) || (!strcmp(argv[k], "--befunge93"))) b93 = 1; if((!strcmp(argv[k], "-mc")) || (!strcmp(argv[k], "-maxcells")) || (!strcmp(argv[k], "--max-cells")) || (!strcmp(argv[k], "--maxcells"))) { ssize = atoi(argv[++k]); } else if((!strcmp(argv[k], "-ms")) || (!strcmp(argv[k], "-maxstacks")) || (!strcmp(argv[k], "--max-stacks")) || (!strcmp(argv[k], "--maxstacks"))) { sssize = atoi(argv[++k]); } else #endif if(argv[k][0] != '-') { fungeprog_arg = k; break; } } if (fungeprog_arg == -1) usage(); /* initialize */ srand(time(0)); DEBUG("Allocating Funge-Space"); if ((p = bfspace_alloc(NULL)) != NULL) { DEBUG("Allocating IP"); if ((i = ip_alloc(p, ssize, sssize)) != NULL) { DEBUG("Opening Source File"); if ((f=fopen(argv[fungeprog_arg],"r")) != NULL) { #ifdef FBBI_MSDOS #ifndef FBBI_ANSI setmode(fileno(f), O_BINARY); #endif #endif DEBUG("Reading Source File"); if (bfspace_fread(i->bs, f, 0, 0, &w, &h, 0)) { fclose(f); #ifndef FBBI_MINIMAL if ((w > 79) || (h > 24)) { if(b93 && warn) fprintf(stderr, "fbbi warning: " "source too large for Befunge-93-Space (%ld x %ld)\n", w+1, h+1); } if (h >= 1) { if(une && warn) fprintf(stderr, "fbbi warning: " "source too large for Unefunge-98-Space (%ld x %ld)\n", w+1, h+1); } if (script) { while (bfspace_fetch(i->bs, 0, i->y) == ((long)0 | (long)'#')) i->y++; } #endif DEBUG("* Begin Interpret *"); while (!i->hm) { DEBUG("Moving IP"); ip_move(i); #ifndef FBBI_MINIMAL if(bpt && i->x == bx && i->y == by) trace=1; #endif DEBUG("Getting Instruction"); i->ir = bfspace_fetch(i->bs, i->x, i->y); #ifndef FBBI_MINIMAL if (b93 && ((i->x < 0) || (i->y < 0) || (i->x > 79) || (i->y > 24)) ) { if(warn) fprintf(stderr, "fbbi warning: " "beyond Befunge-93-Space at (%ld,%ld)\n", i->x, i->y); } if (trace) { perform_trace(i); if (i->hm) break; } #endif DEBUG("Executing Instruction"); if (i->sm && ((char)i->ir != '"')) { ip_push(i, i->ir); } else { if ((i->ir < 32) || (i->ir > 126)) { fi_unimp(i); } else { #ifndef FBBI_MINIMAL if(b93) b93instable[(char)i->ir-32](i); else #endif instable[(char)i->ir-32](i); } } } DEBUG("* End Interpret *"); ec = (int)i->ec; DEBUG("Freeing IP"); ip_free(i); DEBUG("Freeing Funge-Space"); bfspace_free(p); } else { DEBUG("Freeing IP"); ip_free(i); DEBUG("Freeing Funge-Space"); bfspace_free(p); fclose(f); #ifndef FBBI_MINIMAL fprintf(stderr, "fbbi error: can't load file\n"); #endif exit(1); } } else { DEBUG("Freeing IP"); ip_free(i); DEBUG("Freeing Funge-Space"); bfspace_free(p); #ifndef FBBI_MINIMAL fprintf(stderr, "fbbi error: can't open file\n"); #endif exit(1); } } else { DEBUG("Freeing Funge-Space"); bfspace_free(p); #ifndef FBBI_MINIMAL fprintf(stderr, "fbbi error: can't allocate ip\n"); #endif exit(1); } } else { #ifndef FBBI_MINIMAL fprintf(stderr, "fbbi error: can't allocate befunge-space\n"); #endif exit(1); } return ec; }