void date_alphatime(enum nilop op) { char buf[16], *p; int h, m, s; const char *suffix; if (extract_time(&h, &m, &s, 100)) return; xset(buf, '\0', sizeof(buf)); if (UState.t12) { if (h >= 12) { h -= 12; suffix = " PM"; } else suffix = " AM"; if (h == 0) h = 12; } else suffix = ""; p = num_arg(buf, h); *p++ = ':'; p = num_arg_0(p, m, 2); *p++ = ':'; p = num_arg_0(p, s, 2); scopy(p, suffix); add_string(buf); }
static int sigmaAllocate(void) { if (State.have_stats == 0) { SizeStatRegs = sizeof(STAT_DATA) >> 1; // in 16 bit words! if (move_retstk(-SizeStatRegs)) { SizeStatRegs = 0; err(ERR_RAM_FULL); return 1; } State.have_stats = 1; sigmaCheck(); xset(StatRegs, 0, sizeof(STAT_DATA)); }
/* Date and times to the Alpha register */ void date_alphadate(enum nilop op) { decNumber x; int d, m, y; char buf[16]; char *p; getX(&x); xset(buf, '\0', sizeof(buf)); if (extract_date(&x, &y, &m, &d)) { err(ERR_BAD_DATE); return; } switch (UState.date_mode) { default: p = num_arg(buf, y); *p++ = '-'; p = num_arg_0(p, m, 2); *p++ = '-'; num_arg_0(p, d, 2); break; case DATE_DMY: p = num_arg(buf, d); *p++ = '.'; p = num_arg_0(p, m, 2); *p++ = '.'; num_arg_0(p, y, 4); break; case DATE_MDY: p = num_arg(buf, m); *p++ = '/'; p = num_arg_0(p, d, 2); *p++ ='/'; num_arg_0(p, y, 4); break; } add_string(buf); }
static int dumpop(const opcode c, int pt) { char tracebuf[25]; const char *s, *m; if (c == RARG(RARG_ALPHA, 0)) return 0; xset(tracebuf, '\0', sizeof(tracebuf)); s = prt(c, tracebuf); if (strcmp(s, "???") != 0) { char t[100], *q = t; int l = 35; if (c == RARG(RARG_ALPHA, ' ')) strcpy(tracebuf+2, "[space]"); q += sprintf(t, "%04x ", (unsigned int)c); while (*s != '\0') { const unsigned char z = 0xff & *s++; m = pretty(z); if (m == NULL) { *q++ = z; l--; } else { l -= slen(m) + 2; q += sprintf(q, "[%s]", m); } } *q++ = '\0'; if (pt) { printf("%s", t); rarg_values(c, l); putchar('\n'); } return 1; } return 0; }
/*ARGSUSED*/ void dolet(Char **v, struct command *dummy) { Char *p; Char *vp, c, op; int hadsub; int subscr; USE(dummy); v++; p = *v++; if (p == 0) { prvars(); return; } do { hadsub = 0; vp = p; if (letter(*p)) for (; alnum(*p); p++) continue; if (vp == p || !letter(*vp)) stderror(ERR_NAME | ERR_VARBEGIN); if (*p == '[') { hadsub++; p = getinx(p, &subscr); } if (*p == 0 && *v) p = *v++; if ((op = *p) != 0) *p++ = 0; else stderror(ERR_NAME | ERR_ASSIGN); /* * if there is no expression after the '=' then print a "Syntax Error" * message - strike */ if (*p == '\0' && *v == NULL) stderror(ERR_NAME | ERR_ASSIGN); vp = Strsave(vp); cleanup_push(vp, xfree); if (op == '=') { c = '='; p = xset(p, &v); } else { c = *p++; if (any("+-", c)) { if (c != op || *p) stderror(ERR_NAME | ERR_UNKNOWNOP); p = Strsave(STR1); } else { if (any("<>", op)) { if (c != op) stderror(ERR_NAME | ERR_UNKNOWNOP); stderror(ERR_NAME | ERR_SYNTAX); } if (c != '=') stderror(ERR_NAME | ERR_UNKNOWNOP); p = xset(p, &v); } } cleanup_push(p, xfree); if (op == '=') { if (hadsub) asx(vp, subscr, p); else setv(vp, p, VAR_READWRITE); cleanup_ignore(p); } else if (hadsub) { struct varent *gv = getvx(vp, subscr); Char *val; val = operate(op, gv->vec[subscr - 1], p); cleanup_push(val, xfree); asx(vp, subscr, val); cleanup_ignore(val); cleanup_until(val); } else { Char *val; val = operate(op, varval(vp), p); cleanup_push(val, xfree); setv(vp, val, VAR_READWRITE); cleanup_ignore(val); cleanup_until(val); } update_vars(vp); cleanup_until(vp); } while ((p = *v++) != NULL); }
void /*ARGSUSED*/ dolet(Char **v, struct command *t) { Char *p; Char *vp, c, op; bool hadsub; int subscr; v++; p = *v++; if (p == 0) { prvars(); return; } do { hadsub = 0; vp = p; if (letter(*p)) for (; alnum(*p); p++) continue; if (vp == p || !letter(*vp)) stderror(ERR_NAME | ERR_VARBEGIN); if ((p - vp) > MAXVARLEN) stderror(ERR_NAME | ERR_VARTOOLONG); if (*p == '[') { hadsub++; p = getinx(p, &subscr); } if (*p == 0 && *v) p = *v++; if ((op = *p) != '\0') *p++ = 0; else stderror(ERR_NAME | ERR_ASSIGN); if (*p == '\0' && *v == NULL) stderror(ERR_NAME | ERR_ASSIGN); vp = Strsave(vp); if (op == '=') { c = '='; p = xset(p, &v); } else { c = *p++; if (any("+-", c)) { if (c != op || *p) stderror(ERR_NAME | ERR_UNKNOWNOP); p = Strsave(STR1); } else { if (any("<>", op)) { if (c != op) stderror(ERR_NAME | ERR_UNKNOWNOP); c = *p++; stderror(ERR_NAME | ERR_SYNTAX); } if (c != '=') stderror(ERR_NAME | ERR_UNKNOWNOP); p = xset(p, &v); } } if (op == '=') if (hadsub) asx(vp, subscr, p); else set(vp, p); else if (hadsub) { struct varent *gv = getvx(vp, subscr); asx(vp, subscr, operate(op, gv->vec[subscr - 1], p)); } else set(vp, operate(op, value(vp), p)); if (eq(vp, STRpath)) { exportpath(adrof(STRpath)->vec); dohash(NULL, NULL); } free(vp); if (c != '=') free(p); } while ((p = *v++) != NULL); }
void dolet(tchar **v) { tchar *p; tchar *vp, c, op; bool hadsub; int subscr; v++; p = *v++; if (p == 0) { prvars(); return; } do { hadsub = 0; for (vp = p; alnum(*p); p++) continue; if (vp == p || !letter(*vp)) goto letsyn; if (*p == '[') { hadsub++; p = getinx(p, &subscr); } if (*p == 0 && *v) p = *v++; if (op = *p) *p++ = 0; else goto letsyn; vp = savestr(vp); if (op == '=') { c = '='; p = xset(p, &v); } else { c = *p++; /* if (any(c, "+-")) { */ if (c == '+' || c == '-') { if (c != op || *p) goto letsyn; p = plusplus; } else { /* if (any(op, "<>")) { */ if (op == '<' || op == '>') { if (c != op) goto letsyn; c = *p++; letsyn: bferr("Syntax error"); } if (c != '=') goto letsyn; p = xset(p, &v); } } if (op == '=') if (hadsub) asx(vp, subscr, p); else set(vp, p); else if (hadsub) #ifndef V6 /* avoid bug in vax CC */ { struct varent *gv = getvx(vp, subscr); asx(vp, subscr, operate(op, gv->vec[subscr - 1], p)); } #else asx(vp, subscr, operate(op, getvx(vp, subscr)->vec[subscr - 1], p)); #endif else set(vp, operate(op, value(vp), p)); if (eq(vp, S_path /* "path" */)) { exportpath(adrof(S_path /* "path" */)->vec); dohash(xhash); } if (eq(vp, S_cdpath /* "cdpath" */)) dohash(xhash2); xfree(vp); if (c != '=') xfree(p); } while (p = *v++);
void dump_opcodes(FILE *f) { int c, d; char cmdname[16]; char cmdpretty[500]; const char *p; for (c=0; c<65536; c++) { if (isDBL(c)) { const unsigned int cmd = opDBL(c); if ((c & 0xff) != 0) continue; if (cmd >= num_multicmds) continue; #ifdef INCLUDE_MULTI_DELETE if (cmd == DBL_DELPROG) continue; #endif xset(cmdname, '\0', 16); xcopy(cmdname, multicmds[cmd].cmd, NAME_LEN); prettify(cmdname, cmdpretty); fprintf(f, "0x%04x\tmult\t%s\n", c, cmdpretty); } else if (isRARG(c)) { const unsigned int cmd = RARG_CMD(c); unsigned int limit; if (cmd >= NUM_RARG) continue; #ifdef INCLUDE_MULTI_DELETE if (cmd == RARG_DELPROG) continue; #endif limit = argcmds[cmd].lim; if (cmd != RARG_ALPHA && (c & RARG_IND) != 0) continue; p = catcmd(c, cmdname); if (strcmp(p, "???") == 0) continue; prettify(p, cmdpretty); if (cmd == RARG_ALPHA) { if ((c & 0xff) == 0) continue; if ((c & 0xff) == ' ') fprintf(f, "0x%04x\tcmd\t[alpha] [space]\n", c); else fprintf(f, "0x%04x\tcmd\t[alpha] %s\n", c, cmdpretty); continue; } else if (cmd == RARG_CONST || cmd == RARG_CONST_CMPLX) { fprintf(f, "0x%04x\tcmd\t%s# %s\n", c, cmd == RARG_CONST_CMPLX?"[cmplx]":"", cmdpretty); continue; } else if (cmd == RARG_CONV) { fprintf(f, "0x%04x\tcmd\t%s\n", c, cmdpretty); continue; } else if (cmd == RARG_CONST_INT) { p = prt(c, cmdname); if (strcmp(p, "???") != 0) fprintf(f, "0x%04x\tcmd\t%s\n", c, p); if ((c & 0xff) != 0) continue; limit = 0; } if ((c & 0xff) != 0) continue; fprintf(f, "0x%04x\targ\t%s\tmax=%u", c, cmdpretty, limit); if (argcmds[cmd].indirectokay) fprintf(f, ",indirect"); if (argcmds[cmd].stos) fprintf(f, ",stostack"); else if (argcmds[cmd].stckreg) fprintf(f, ",stack"); if (argcmds[cmd].cmplx) fprintf(f, ",complex"); fprintf(f, "\n"); } else { p = catcmd(c, cmdname); if (strcmp(p, "???") == 0) continue; prettify(p, cmdpretty); d = argKIND(c); switch (opKIND(c)) { default: break; case KIND_MON: if (d < num_monfuncs && (! isNULL(monfuncs[d].mondreal) || ! isNULL(monfuncs[d].monint))) break; continue; case KIND_DYA: if (d < num_dyfuncs && (! isNULL(dyfuncs[d].dydreal) || ! isNULL(dyfuncs[d].dydint))) break; continue; case KIND_CMON: if (d < num_monfuncs && ! isNULL(monfuncs[d].mondcmplx)) { if (cmdname[0] == COMPLEX_PREFIX) break; fprintf(f, "0x%04x\tcmd\t[cmplx]%s\n", c, cmdpretty); } continue; case KIND_CDYA: if (d < num_dyfuncs && ! isNULL(dyfuncs[d].dydcmplx)) { if (cmdname[0] == COMPLEX_PREFIX) break; fprintf(f, "0x%04x\tcmd\t[cmplx]%s\n", c, cmdpretty); } continue; case KIND_NIL: d = c & 0xff; if (d == OP_CLALL || d == OP_RESET) { continue; } } fprintf(f, "0x%04x\tcmd\t%s\n", c, cmdpretty); } } }