int caccept(int addr, cell count, int up) { int c; int p; if (isinteractive()) { linemode(); } // Uses the operating system's terminal driver to do the line editing for (p = addr; count > 0; count--) { c = nextchar(); if (c == '\n' || c == EOF) { break; } CHARS(p++) = c; } if (isinteractive()) { // We must do this because the terminal driver does the echoing, // and the 'return' that ends the line puts the cursor at column 0 V(NUM_OUT) = 0; } return ((cell)(p - addr)); }
int builtin_exit(char *argv[]) { long i; char *endptr; assert(argv && argv[0]); if (!argv[1]) exit(shell->status); if (argv[2]) { fprintf(stderr, "42sh : exit : too many arguments\n"); return 1; } i = strtol(argv[1], &endptr, 10); if (isinteractive()) fprintf(stderr, "exit\n"); if (*endptr) fprintf(stderr, "42sh: exit: %s: numeric argument required\n", argv[1]); exit((!*endptr) ? i : 255); return 1; }
SCOPE2 int parse(int delim, int sp, int up) { int bufend = V(TICK_SOURCE) + V(NUM_SOURCE); int nextc = V(TICK_SOURCE) + V(TO_IN); int wordstart = nextc; int c; DS(sp) = wordstart; do { if (nextc >= bufend) { V(TO_IN) = nextc - V(TICK_SOURCE); return(nextc - wordstart); } c = CHARS(nextc++); } while ( c != delim && (c > ' ' || delim != ' ' || isinteractive() != 0 ) ); V(TO_IN) = nextc - V(TICK_SOURCE); return (nextc - wordstart - 1); }