std::string Version::preprocessorDefinition() const { SmallString<64> define("-D__SWIFT_COMPILER_VERSION="); llvm::raw_svector_ostream OS(define); uint64_t versionConstant = 0; auto NumComponents = Components.size(); if (NumComponents > 0) versionConstant += Components[0] * 1000 * 1000 * 1000; // Component 2 is not used. if (NumComponents > 2) versionConstant += Components[2] * 1000 * 1000; if (NumComponents > 3) versionConstant += Components[3] * 1000; if (NumComponents > 4) versionConstant += Components[4]; OS << versionConstant; return OS.str().str(); }
int main(void){ char s[]="tudo puta e viado."; clock_t Ti, Tf; //scanf("%[^\n]",&s); printf("%s\n",s ); Ti=clock(); string_inverte(s); Tf=clock(); printf("%s\nem tempo: %f",s,(Tf-Ti) ); //usando pilha char t[]="tudo puta e viado."; lista pilha; int cont=0; char aux; printf("\npilha\n"); Ti=clock(); define(&pilha); while(t[cont]!='.'){ while(t[cont]!=' ' && t[cont]!='.'){ empilha(&pilha,t[cont]); cont++; } while(pilha.total>0){ aux=desempilha(&pilha); printf("%c",aux ); } printf(" "); if(t[cont]!='.'){ cont++; } } Tf=clock(); printf("\npilha com tempo: %f\n",(Tf-Ti) ); return 0; }
void SDFLoader::load() { std::ifstream infile(_filename); std::string line; while(std::getline(infile, line)) { std::istringstream iss(line); std::vector<std::string> tokens{std::istream_iterator<std::string>{iss}, std::istream_iterator<std::string>{}}; if (tokens.size() > 0 && tokens[0].substr(0, 1) == "#") { continue; } if (tokens[0] == "render" && tokens.size() == 5) { render(tokens); } else if(tokens[0] == "define") { define(tokens); } else { throw std::runtime_error("illegal sdf line"); } } }
void UmlActivityParameter::html(Q3CString pfix, unsigned int rank, unsigned int level) { define(); fw.write("<table><tr><td><div class=\"element\">Activity action pin <b>"); writeq(name()); fw.write("</b></div></td></tr></table>\n"); Q3CString s = defaultValue(); if (! s.isEmpty()) { fw.write("<p>Default value :</p><ul>"); fw.write("<pre>\n"); writeq(s); fw.write("</pre></ul>"); } UmlPinParameter::html(pfix, rank, level); unload(FALSE, FALSE); }
int get_next_line(int const fd, char **line) { static t_var *get_in[MAX_FD]; if (fd >= MAX_FD || fd < 0 || line == NULL) return (-1); if (get_in[fd] && get_in[fd]->file_lecture == 0) return (0); if (!get_in[fd] && !define(&get_in[fd])) return (-1); while (get_in[fd]->file_lecture > 0 && !((return_line(get_in[fd])))) { while (get_in[fd]->tampon + BUFF_SIZE > get_in[fd]->len) if (!add_memory_size(get_in[fd])) return (-1); get_in[fd]->file_lecture = read(fd, get_in[fd]->memory + get_in[fd]->tampon, BUFF_SIZE); get_in[fd]->tampon = get_in[fd]->tampon + get_in[fd]->file_lecture; } return (return_handle(&get_in[fd], get_in[fd], line)); }
int main(){ //declaração das variáveis int i, ch, nl, np; int *Rep = NULL; bignum perm; char frase[MAXDIGITS]; //Armazenado a frase digitada pelo usário printf ("Por favor digite a frase desejada\n"); scanf (" %[^\n]", frase); //A função define, define a quantidade de letras e de palavras contidas na frase, e as armazenas em nl e np respectivamente define (frase, &nl, &np); //A função reteptição armazena a quantidade de vezes que as letras (a-z) forma repetidas armazenado em um vetor Rep = repeticao (frase); //Controle caso a locação de memórias do vetor não for bem sucedida if (!Rep){ printf ("Ocorreu um erro estranho\n"); return 0; } //Imprime os dados obitidos printf("----------------\n"); printf ("A frase digitada foi: %s\n", frase); printf ("Ela possui %d letras e %d palavras\n", nl, np); printf("----------------\n"); printf ("Letras repetidas\n"); for (i=0; i<ALF; i++){ ch = 97; if (Rep[i] != 0){ printf("%c -> %d repeticoes\n",ch+i, Rep[i]); } } printf("----------------\n"); //A funcao calclando_com_corretas calcula qual é o numero de combianacoes exatas calculando_com_corretas ( nl, np, Rep, &perm); printf ("A frase digitada pode ser escrita de "); //Exibindo o resultado print_bignum (&perm); printf ("maneiras\n"); //FIM DO PROGRAMA return 0; }
void register_builtin_definitions(void) { struct macro macro = { {IDENTIFIER, NULL, 0}, OBJECT_LIKE, 0, /* parameters */ }; macro.name.strval = "__STDC_VERSION__"; macro.replacement = parse("199409L", ¯o.size); define(macro); macro.name.strval = "__STDC__"; macro.replacement = parse("1", ¯o.size); define(macro); macro.name.strval = "__STDC_HOSTED__"; macro.replacement = parse("1", ¯o.size); define(macro); macro.name.strval = "__LINE__"; macro.replacement = parse("0", ¯o.size); define(macro); macro.name.strval = "__x86_64__"; macro.replacement = parse("1", ¯o.size); define(macro); /* For some reason this is not properly handled by macros in musl. */ macro.name.strval = "__inline"; macro.replacement = parse(" ", ¯o.size); define(macro); macro.name.strval = "__FILE__"; macro.replacement = calloc(1, sizeof(*macro.replacement)); macro.replacement[0].token.token = STRING; macro.replacement[0].token.strval = current_file.path; macro.replacement[0].token.intval = 0; define(macro); register__builtin_va_end(); }
int org(int size, char *label, char *op, int *errorPtr) { int newLoc; bool backRef; if (size) NEWERROR(*errorPtr, INV_SIZE_CODE); if (!*op) { NEWERROR(*errorPtr, SYNTAX); return NORMAL; } if (offsetMode) { loc = locOffset; // restore loc used prior to Offset directive offsetMode = false; // turn off offset mode } op = eval(op, &newLoc, &backRef, errorPtr); if (*errorPtr < SEVERE && !backRef) { NEWERROR(*errorPtr, INV_FORWARD_REF); } else if (*errorPtr < ERRORN) { if (isspace(*op) || !*op) { // Check for an odd value, adjust to one higher if (newLoc & 1) { NEWERROR(*errorPtr, ODD_ADDRESS); newLoc++; } loc = newLoc; // Define the label attached to this directive, if any if (*label) define(label, loc, pass2, true, errorPtr); // Show new location counter on listing listLoc(); } else NEWERROR(*errorPtr, SYNTAX); } return NORMAL; }
void ds(int size, char *label, char *op, int *errorPtr) { int blockSize; char backRef; char *eval(); if (size == SHORT) { NEWERROR(*errorPtr, INV_SIZE_CODE); size = WORD; } else if (!size) size = WORD; /* Move location counter to a word boundary and fix the listing if doing DS.W or DS.L (but not if doing DS.B, so DS.B's can be contiguous) */ if ((size & (WORD | LONG)) && (loc & 1)) { loc++; listLoc(); } /* Define the label attached to this directive, if any */ if (*label) define(label, loc, pass2, errorPtr); /* Evaluate the size of the block (in bytes, words, or longwords) */ op = eval(op, &blockSize, &backRef, errorPtr); if (*errorPtr < SEVERE && !backRef) { NEWERROR(*errorPtr, INV_FORWARD_REF); return; } if (*errorPtr > SEVERE) return; if (!isspace(*op) && *op) { NEWERROR(*errorPtr, SYNTAX); return; } if (blockSize < 0) { NEWERROR(*errorPtr, INV_LENGTH); return; } loc += blockSize * size; }
void ShootEmUp::escapeCheck() { if (_count321 != 0) return; if (_escapeCount > 0) { _escapeCount--; return; } // Escape_count = 0; now what ? if (_escaping) { if (_gotOut) { newEscape(); _escaping = false; _vm->_graphics->seuDrawPicture(_escapeStock * 90 + 20, 30, kStocks + 4); } else { _vm->_graphics->seuDrawPicture(_escapeStock * 90 + 20, 30, kStocks + 5); _escapeCount = 20; _gotOut = true; define(_escapeStock * 90 + 20, 50, 24, 0, 2, 17, false, true); // Escaped! gain(-10); _hasEscaped[_escapeStock] = true; _howManyHaveEscaped++; if (_howManyHaveEscaped == 7) { _vm->_graphics->seuDrawPicture(266, 90, 23); _time = 0; } } } else { _escapeStock = getStockNumber(_vm->_rnd->getRandomNumber(6)); _escaping = true; _gotOut = false; _vm->_graphics->seuDrawPicture(_escapeStock * 90 + 20, 30, kStocks + 2); // Smiling! _escapeCount = 200; } }
int processline(const char *line,FILE *fd,FILE *fw) { int ret,i; char *fields[10]; for(i=0;i<10;++i) *(fields+i)=malloc(100); split(line,fields,' '); //if it is a macro call then expand for(i=0;i<nami;++i) { ret=strcmp(namtab[i].name,fields[0]); if(ret==0) { expand(line,fw); return 1; } } //if it is a macro definiton than , define it ret=strcmp(fields[1],"MACRO"); if(ret==0) { define(line,fields[0],fd); return 1; } //else write in into the output file fprintf(fw,line); fprintf(fw,"\n"); for(i=0;i<10;++i) free(*(fields+i)); return 1; }
void TestEval::eval_lambda() { EnvPtr env = libraryEnvironment(); ValuePtr value = eval(env, "((lambda (a b c) (+ a b c)) 1 2 3)"); CHECK("Integer type", value->isNumber() && value->isExact()); CHECK_EQUAL("Integer content", int, 6, value->vInt()); value = eval(env, "(define foo (lambda (a b c) (+ a b c)))\n(foo 1 2 3)\n"); CHECK("Integer type", value->isNumber() && value->isExact()); CHECK_EQUAL("Integer content", int, 6, value->vInt()); value = eval(env, "\n\ (define (accum n) (lambda (a) (set! n (+ a n)) n))\n \ (define foo (accum 5))\n\ (define bar (accum 100))\n\ (foo 10) ;Comment\n\ (bar 10)\n\ (foo 10)"); CHECK("Integer type", value->isNumber() && value->isExact()); CHECK_EQUAL("Integer content", int, 25, value->vInt()); }
static void directive() { Tok *t; char *dir; t = ppnoexpand(); dir = t->v; if(strcmp(dir, "include") == 0) include(); else if(strcmp(dir, "define") == 0) define(); else if(strcmp(dir, "if") == 0) pif(); else if(strcmp(dir, "elseif") == 0) elseif(); else if(strcmp(dir, "else") == 0) pelse(); else if(strcmp(dir, "endif") == 0) endif(); else errorposf(&t->pos, "invalid directive %s", dir); }
void init_preprocess(void) { int i; char *cp; init_symtbl(); for (i = 0; predefs[i]; i++) { cp = copyofstr("1"); check_os_malloc(cp); define(predefs[i], -1, (unsigned char *) cp, DEF_PREDEF); } init_include(); keep_comments = 0; no_line_lines = 0; do_at_ctrls = 0; incldep = 0; willbefirst = 1; quote = 0; ifstack = 0; n_skipped_ifs = 0; }
int main(int argc, char** argv){ note n[6]; for(int i=0;i<6;i++){ n[i].start = 1.0; n[i].length = 1.0; } define(n); for(int i = 0;i<6;i++) printf("%.2f\t%g\n", n[i].start, n[i].length); return 0; }
//-------------------------------------------------------- // FAIL directive (ck) // Displays the message following the FAIL directive. // Increments the Assemblers error count just like any other error. // int failError(int size, char *label, char *message, int *errorPtr) { if (size) { // if .size code specified NEWERROR(*errorPtr, INV_SIZE_CODE); // error, invalid size code return NORMAL; } // Define the label attached to this include directive, if any if (*label) define(label, loc, pass2, true, errorPtr); if (!*message) // if no message sprintf(buffer, "ERROR: Unspecified user defined error. \n"); else { strncpy(buffer, message, 254); buffer[255] = '\0'; } NEWERROR(*errorPtr, FAIL_ERROR); // Automatically listed because it's treated like an error return NORMAL; }
int set(int size, char *label, char *op, int *errorPtr) { int value; int error; bool backRef; symbolDef *symbol; if (size) NEWERROR(*errorPtr, INV_SIZE_CODE); if (!*op) { NEWERROR(*errorPtr, SYNTAX); return NORMAL; } error = OK; op = eval(op, &value, &backRef, errorPtr); // if (*errorPtr < SEVERE && !backRef) { // ck 4-18-03 // NEWERROR(*errorPtr, INV_FORWARD_REF); // } // else if (*errorPtr < ERRORN) // ck 4-18-03 if (isspace(*op) || !*op) if (!*label) { NEWERROR(*errorPtr, LABEL_REQUIRED); } else { error = OK; symbol = define(label, value, pass2, false, &error); // ck 4-18-03 symbol->flags |= REDEFINABLE; if (pass2 & listFlag) { sprintf(listPtr, "=%08lX ", value); listPtr += 10; } } else NEWERROR(*errorPtr, SYNTAX); return NORMAL; }
/*********************************************************************** * SECTION directive (ck) ***********************************************************************/ int section(int size, char *label, char *op, int *errorPtr) { int value; int newLoc; bool backRef = true; if (size) NEWERROR(*errorPtr, INV_SIZE_CODE); if (offsetMode) { loc = locOffset; // restore loc used prior to Offset directive offsetMode = false; // turn off offset mode } if (*op) { // if section number eval(op, &value, &backRef, errorPtr); // evaluate section number if (*errorPtr < SEVERE && !backRef) { NEWERROR(*errorPtr, INV_FORWARD_REF); } else if (*errorPtr < ERRORN) { if (value < 0 || value > 15) { // if illegal section number NEWERROR(*errorPtr, SYNTAX); return NORMAL; } sectionLoc[sectI] = loc; // save current loc to current section loc = sectionLoc[value]; // set loc to new section sectI = value; // new section number // Show new location counter on listing listLoc(); } else { NEWERROR(*errorPtr, SYNTAX); } } else if (!*label) // else no section number if no label NEWERROR(*errorPtr, LABEL_REQUIRED); if (*label) // if label define(label, sectI, pass2, true, errorPtr); // define to sectI return NORMAL; }
BString MakeHeaderGuard(const char *name) { BString define(name); define.ReplaceSet(" .-","_"); // Normally, we'd just put something like : // define[i] = toupper(define[i]); // in a loop, but the BString defines for Zeta are screwed up, so we're going to have to // work around them. char *buffer = define.LockBuffer(define.CountChars() + 1); for (int32 i = 0; i < define.CountChars(); i++) buffer[i] = toupper(buffer[i]); define.UnlockBuffer(); BString guard; guard << "#ifndef " << define << "\n" << "#define " << define << "\n" "\n" "\n" "\n" "#endif\n"; return guard; }
Cell eval(Cell exp, Cell env) { if (is_self_evaluating(exp)) { return exp; } else if (is_atom(exp)) { return lookup(exp, env); } else if (is_tagged(exp, atom("define"))) { return define(car(cdr(exp)), eval(car(cdr(cdr(exp))), env), env); } else if (is_tagged(exp, atom("set!"))) { return set(car(cdr(exp)), eval(car(cdr(cdr(exp))), env), env); } else if (is_tagged(exp, atom("if"))) { Cell cond = eval(car(cdr(exp)), env); if (is_atom(cond) && is_eq(cond, atom("#f"))) { exp = car(cdr(cdr(cdr(exp)))); } else { exp = car(cdr(cdr(exp))); } return eval(exp, env); } else if (is_tagged(exp, atom("vau"))) { return procedure(exp, env); } else if (is_pair(exp)) { Cell proc = eval(car(exp), env); if (is_primitive(proc)) { return (proc->primitive)(eval_operands(cdr(exp), env)); } else if (is_procedure(proc)) { Cell src = car(proc); Cell e = car(cdr(cdr(src))); Cell para = cons(e, cons(car(cdr(src)), null)); Cell args = cons(env, cons(cdr(exp), null)); Cell body = car(cdr(cdr(cdr(src)))); return eval(body, extend_env(para, args, cdr(proc))); } } fprintf(stderr, "eval illegal state\n"); return atom("#<void>"); }
CFStencil::CFStencil(const Box& a_b, int a_nComp) { setDefaultValues(); define(a_b, a_nComp); }
void dc(int size, char *label, char *op, int *errorPtr) { int outVal; char backRef; char string[260], *p, *collect(), *eval(); if (size == SHORT) { NEWERROR(*errorPtr, INV_SIZE_CODE); size = WORD; } else if (!size) size = WORD; /* Move location counter to a word boundary and fix the listing if doing DC.W or DC.L (but not if doing DC.B, so DC.B's can be contiguous) */ if ((size & (WORD | LONG)) && (loc & 1)) { loc++; listLoc(); } /* Define the label attached to this directive, if any */ if (*label) define(label, loc, pass2, errorPtr); /* Check for the presence of the operand list */ if (!*op) { NEWERROR(*errorPtr, SYNTAX); return; } do { if (*op == '\'') { op = collect(++op, string); if (!isspace(*op) && *op != ',') { NEWERROR(*errorPtr, SYNTAX); return; } p = string; while (*p) { outVal = *p++; if (size > BYTE) outVal = (outVal << 8) + *p++; if (size > WORD) { outVal = (outVal << 16) + (*p++ << 8); outVal += *p++; } if (pass2) output(outVal, size); loc += size; } } else { op = eval(op, &outVal, &backRef, errorPtr); if (*errorPtr > SEVERE) return; if (!isspace(*op) && *op != ',') { NEWERROR(*errorPtr, SYNTAX); return; } if (pass2) output(outVal, size); loc += size; if (size == BYTE && (outVal < -128 || outVal > 255)) { NEWERROR(*errorPtr, INV_8_BIT_DATA); } else if (size == WORD && (outVal < -32768 || outVal > 65535)) NEWERROR(*errorPtr, INV_16_BIT_DATA); } } while (*op++ == ','); --op; if (!isspace(*op) && *op) NEWERROR(*errorPtr, SYNTAX); }
/* * execute command tree */ int execute(struct op * volatile t, /* if XEXEC don't fork */ volatile int flags, volatile int * volatile xerrok) { int i; volatile int rv = 0, dummy = 0; int pv[2]; const char ** volatile ap = NULL; char ** volatile up; const char *s, *ccp; struct ioword **iowp; struct tbl *tp = NULL; char *cp; if (t == NULL) return (0); /* Caller doesn't care if XERROK should propagate. */ if (xerrok == NULL) xerrok = &dummy; if ((flags&XFORK) && !(flags&XEXEC) && t->type != TPIPE) /* run in sub-process */ return (exchild(t, flags & ~XTIME, xerrok, -1)); newenv(E_EXEC); if (trap) runtraps(0); /* we want to run an executable, do some variance checks */ if (t->type == TCOM) { /* check if this is 'var=<<EOF' */ if ( /* we have zero arguments, i.e. no programme to run */ t->args[0] == NULL && /* we have exactly one variable assignment */ t->vars[0] != NULL && t->vars[1] == NULL && /* we have exactly one I/O redirection */ t->ioact != NULL && t->ioact[0] != NULL && t->ioact[1] == NULL && /* of type "here document" (or "here string") */ (t->ioact[0]->flag & IOTYPE) == IOHERE && /* the variable assignment begins with a valid varname */ (ccp = skip_wdvarname(t->vars[0], true)) != t->vars[0] && /* and has no right-hand side (i.e. "varname=") */ ccp[0] == CHAR && ccp[1] == '=' && ccp[2] == EOS && /* plus we can have a here document content */ herein(t->ioact[0], &cp) == 0 && cp && *cp) { char *sp = cp, *dp; size_t n = ccp - t->vars[0] + 2, z; /* drop redirection (will be garbage collected) */ t->ioact = NULL; /* set variable to its expanded value */ z = strlen(cp) + 1; if (notoktomul(z, 2) || notoktoadd(z * 2, n)) internal_errorf(Toomem, (unsigned long)-1); dp = alloc(z * 2 + n, ATEMP); memcpy(dp, t->vars[0], n); t->vars[0] = dp; dp += n; while (*sp) { *dp++ = QCHAR; *dp++ = *sp++; } *dp = EOS; /* free the expanded value */ afree(cp, APERM); } /* * Clear subst_exstat before argument expansion. Used by * null commands (see comexec() and c_eval()) and by c_set(). */ subst_exstat = 0; /* for $LINENO */ current_lineno = t->lineno; /* * POSIX says expand command words first, then redirections, * and assignments last.. */ up = eval(t->args, t->u.evalflags | DOBLANK | DOGLOB | DOTILDE); if (flags & XTIME) /* Allow option parsing (bizarre, but POSIX) */ timex_hook(t, &up); ap = (const char **)up; if (Flag(FXTRACE) && ap[0]) { shf_puts(substitute(str_val(global("PS4")), 0), shl_out); for (i = 0; ap[i]; i++) shf_fprintf(shl_out, "%s%c", ap[i], ap[i + 1] ? ' ' : '\n'); shf_flush(shl_out); } if (ap[0]) tp = findcom(ap[0], FC_BI|FC_FUNC); } flags &= ~XTIME; if (t->ioact != NULL || t->type == TPIPE || t->type == TCOPROC) { e->savefd = alloc2(NUFILE, sizeof(short), ATEMP); /* initialise to not redirected */ memset(e->savefd, 0, NUFILE * sizeof(short)); } /* mark for replacement later (unless TPIPE) */ vp_pipest->flag |= INT_L; /* do redirection, to be restored in quitenv() */ if (t->ioact != NULL) for (iowp = t->ioact; *iowp != NULL; iowp++) { if (iosetup(*iowp, tp) < 0) { exstat = rv = 1; /* * Redirection failures for special commands * cause (non-interactive) shell to exit. */ if (tp && tp->type == CSHELL && (tp->flag & SPEC_BI)) errorfz(); /* Deal with FERREXIT, quitenv(), etc. */ goto Break; } } switch (t->type) { case TCOM: rv = comexec(t, tp, (const char **)ap, flags, xerrok); break; case TPAREN: rv = execute(t->left, flags | XFORK, xerrok); break; case TPIPE: flags |= XFORK; flags &= ~XEXEC; e->savefd[0] = savefd(0); e->savefd[1] = savefd(1); while (t->type == TPIPE) { openpipe(pv); /* stdout of curr */ ksh_dup2(pv[1], 1, false); /** * Let exchild() close pv[0] in child * (if this isn't done, commands like * (: ; cat /etc/termcap) | sleep 1 * will hang forever). */ exchild(t->left, flags | XPIPEO | XCCLOSE, NULL, pv[0]); /* stdin of next */ ksh_dup2(pv[0], 0, false); closepipe(pv); flags |= XPIPEI; t = t->right; } /* stdout of last */ restfd(1, e->savefd[1]); /* no need to re-restore this */ e->savefd[1] = 0; /* Let exchild() close 0 in parent, after fork, before wait */ i = exchild(t, flags | XPCLOSE | XPIPEST, xerrok, 0); if (!(flags&XBGND) && !(flags&XXCOM)) rv = i; break; case TLIST: while (t->type == TLIST) { execute(t->left, flags & XERROK, NULL); t = t->right; } rv = execute(t, flags & XERROK, xerrok); break; case TCOPROC: { #ifndef MKSH_NOPROSPECTOFWORK sigset_t omask; /* * Block sigchild as we are using things changed in the * signal handler */ sigprocmask(SIG_BLOCK, &sm_sigchld, &omask); e->type = E_ERRH; if ((i = kshsetjmp(e->jbuf))) { sigprocmask(SIG_SETMASK, &omask, NULL); quitenv(NULL); unwind(i); /* NOTREACHED */ } #endif /* Already have a (live) co-process? */ if (coproc.job && coproc.write >= 0) errorf("coprocess already exists"); /* Can we re-use the existing co-process pipe? */ coproc_cleanup(true); /* do this before opening pipes, in case these fail */ e->savefd[0] = savefd(0); e->savefd[1] = savefd(1); openpipe(pv); if (pv[0] != 0) { ksh_dup2(pv[0], 0, false); close(pv[0]); } coproc.write = pv[1]; coproc.job = NULL; if (coproc.readw >= 0) ksh_dup2(coproc.readw, 1, false); else { openpipe(pv); coproc.read = pv[0]; ksh_dup2(pv[1], 1, false); /* closed before first read */ coproc.readw = pv[1]; coproc.njobs = 0; /* create new coprocess id */ ++coproc.id; } #ifndef MKSH_NOPROSPECTOFWORK sigprocmask(SIG_SETMASK, &omask, NULL); /* no more need for error handler */ e->type = E_EXEC; #endif /* * exchild() closes coproc.* in child after fork, * will also increment coproc.njobs when the * job is actually created. */ flags &= ~XEXEC; exchild(t->left, flags | XBGND | XFORK | XCOPROC | XCCLOSE, NULL, coproc.readw); break; } case TASYNC: /* * XXX non-optimal, I think - "(foo &)", forks for (), * forks again for async... parent should optimise * this to "foo &"... */ rv = execute(t->left, (flags&~XEXEC)|XBGND|XFORK, xerrok); break; case TOR: case TAND: rv = execute(t->left, XERROK, xerrok); if ((rv == 0) == (t->type == TAND)) rv = execute(t->right, XERROK, xerrok); flags |= XERROK; if (xerrok) *xerrok = 1; break; case TBANG: rv = !execute(t->right, XERROK, xerrok); flags |= XERROK; if (xerrok) *xerrok = 1; break; case TDBRACKET: { Test_env te; te.flags = TEF_DBRACKET; te.pos.wp = t->args; te.isa = dbteste_isa; te.getopnd = dbteste_getopnd; te.eval = test_eval; te.error = dbteste_error; rv = test_parse(&te); break; } case TFOR: case TSELECT: { volatile bool is_first = true; ap = (t->vars == NULL) ? e->loc->argv + 1 : (const char **)eval((const char **)t->vars, DOBLANK | DOGLOB | DOTILDE); e->type = E_LOOP; while ((i = kshsetjmp(e->jbuf))) { if ((e->flags&EF_BRKCONT_PASS) || (i != LBREAK && i != LCONTIN)) { quitenv(NULL); unwind(i); } else if (i == LBREAK) { rv = 0; goto Break; } } /* in case of a continue */ rv = 0; if (t->type == TFOR) { while (*ap != NULL) { setstr(global(t->str), *ap++, KSH_UNWIND_ERROR); rv = execute(t->left, flags & XERROK, xerrok); } } else { /* TSELECT */ for (;;) { if (!(ccp = do_selectargs(ap, is_first))) { rv = 1; break; } is_first = false; setstr(global(t->str), ccp, KSH_UNWIND_ERROR); execute(t->left, flags & XERROK, xerrok); } } break; } case TWHILE: case TUNTIL: e->type = E_LOOP; while ((i = kshsetjmp(e->jbuf))) { if ((e->flags&EF_BRKCONT_PASS) || (i != LBREAK && i != LCONTIN)) { quitenv(NULL); unwind(i); } else if (i == LBREAK) { rv = 0; goto Break; } } /* in case of a continue */ rv = 0; while ((execute(t->left, XERROK, NULL) == 0) == (t->type == TWHILE)) rv = execute(t->right, flags & XERROK, xerrok); break; case TIF: case TELIF: if (t->right == NULL) /* should be error */ break; rv = execute(t->left, XERROK, NULL) == 0 ? execute(t->right->left, flags & XERROK, xerrok) : execute(t->right->right, flags & XERROK, xerrok); break; case TCASE: i = 0; ccp = evalstr(t->str, DOTILDE); for (t = t->left; t != NULL && t->type == TPAT; t = t->right) { for (ap = (const char **)t->vars; *ap; ap++) { if (i || ((s = evalstr(*ap, DOTILDE|DOPAT)) && gmatchx(ccp, s, false))) { rv = execute(t->left, flags & XERROK, xerrok); i = 0; switch (t->u.charflag) { case '&': i = 1; /* FALLTHROUGH */ case '|': goto TCASE_next; } goto TCASE_out; } } i = 0; TCASE_next: /* empty */; } TCASE_out: break; case TBRACE: rv = execute(t->left, flags & XERROK, xerrok); break; case TFUNCT: rv = define(t->str, t); break; case TTIME: /* * Clear XEXEC so nested execute() call doesn't exit * (allows "ls -l | time grep foo"). */ rv = timex(t, flags & ~XEXEC, xerrok); break; case TEXEC: /* an eval'd TCOM */ s = t->args[0]; up = makenv(); restoresigs(); cleanup_proc_env(); { union mksh_ccphack cargs; cargs.ro = t->args; execve(t->str, cargs.rw, up); rv = errno; } if (rv == ENOEXEC) scriptexec(t, (const char **)up); else errorf("%s: %s", s, cstrerror(rv)); } Break: exstat = rv & 0xFF; if (vp_pipest->flag & INT_L) { unset(vp_pipest, 1); vp_pipest->flag = DEFINED | ISSET | INTEGER | RDONLY | ARRAY | INT_U; vp_pipest->val.i = rv; } /* restores IO */ quitenv(NULL); if ((flags&XEXEC)) /* exit child */ unwind(LEXIT); if (rv != 0 && !(flags & XERROK) && (xerrok == NULL || !*xerrok)) { if (Flag(FERREXIT) & 0x80) { /* inside eval */ Flag(FERREXIT) = 0; } else { trapsig(ksh_SIGERR); if (Flag(FERREXIT)) unwind(LERROR); } } return (rv); }
int main(void){ grafo G; define(&G); char entrada='N'; int data, data2; while(entrada!='@'){ //interface printf("inserir vertice: (V)\n"); printf("inserir aresta: (A)\n"); printf("visualizar grafo: (G)\n"); printf("remover vertice: (R)\n"); printf("remover aresta: (r)\n"); printf("sair: (@)\n"); scanf(" %c",&entrada); //logica do programa if(entrada=='V'){ printf("ensira -1 para sair da entrada de vertices\n"); printf("ensira vertice que deseja: \n"); scanf("%d",&data); while(data!=-1){ insere_vertice(&G,data); scanf("%d",&data); } } else if(entrada=='A'){ printf("ensira -1 para sair da entrada de arestas\n"); printf("ensira a aresta e o vertice que deseja ligar:\n"); scanf("%d %d",&data,&data2); while(data!=-1){ insere_aresta(&G,data,data2); insere_aresta(&G,data2,data); scanf("%d %d",&data,&data2); } } else if(entrada=='G'){ vizualiza(&G); } else if(entrada=='R'){ printf("ensira -1 para sair da remocao de vertice\n"); printf("ensira o vertice que deseja remover\n"); scanf("%d",&data); while(data!=-1){ remove_vertice(&G,data); scanf("%d",&data); } } else if(entrada=='r'){ printf("ensira -1 para sair da remocao de arestas\n"); printf("ensira aresta e o vertice que deseja remover\n"); scanf(" %d %d",&data,&data2); while(data!=-1){ remove_aresta(&G,data,data2); remove_aresta(&G,data2,data); scanf(" %d %d",&data,&data2); } } printf("---------------------------------------------------------------------------\n"); //scanf(" %c",&entrada); } return 0; }
Protocol::Protocol() { define(RecordPacket::fromBlock); }
static u_i4 pp_directive( FILE *input, STACK_FRAME *stack , bool ifdef ) { i4 n, len; char *words[ MAX_LINE / 2 ], *temp, *p; char *parse_val, *parse_end; STACK_FRAME stack_frame; bool def_dir; u_i4 rtn = NONE; stack_frame.prev = stack; stack_frame.display_mode = TRUE; p = temp = STalloc( infile->yytext ); CMnext( p ); n = sizeof( words ); STgetwords( p, &n, words ); /* process the directive, watch out for the empty directive */ if (n == 0) { ; /* empty directive */ } else if( STequal( words[ 0 ], ERx( "define" ) ) != 0 ) { /* If a symbol was specified look for the value to give it */ if (n > 1) { /* Scan for the 'define' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the 'define' keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'define' */ /* keyword and the specified symbol name */ while (CMwhite(parse_val)) CMnext(parse_val); /* Skip over the symbol name */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Skip over white space after the symbol name */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point we have scanned to the beginning */ /* of the defined value for the symbol, Trim off */ /* any trailing white space */ STtrmwhite(parse_val); /* Define value found, could be the empty string, "" */ if( active( &stack_frame ) ) { define( words[ 1 ], parse_val, FALSE ); } } rtn = DEFINE; } else if( active( &stack_frame ) && STequal( words[ 0 ], ERx( "undef" ) ) != 0 ) { if (n > 1) { undefine( words[ 1 ] ); } rtn = UNDEF; } else if( STequal( words[ 0 ], ERx( "if" ) ) != 0 ) { /* If an expression was specified look for its evaluation */ if (n > 1) { /* Scan for the 'if' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the 'if' keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'if' */ /* keyword and the expression */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point we have scanned to the beginning */ /* of the expression.*/ if( active( &stack_frame ) ) { /* Evaluate boolean expression found */ stack_frame.display_mode = pp_eval_boolexp( &parse_val, ERx("") ); } (void) pp_input( input, &stack_frame, TRUE ); } rtn = IF; } else if( STequal( words[ 0 ], ERx( "ifdef" ) ) != 0 ) { if( active(&stack_frame) && is_defined(words[1], NULL) == OK) { stack_frame.display_mode = TRUE; } else stack_frame.display_mode = FALSE; (void) pp_input( input, &stack_frame, TRUE ); rtn = IFDEF; } else if( STequal( words[ 0 ], ERx( "ifndef" ) ) != 0 ) { if( active(&stack_frame) && is_defined(words[1], NULL) != OK) { stack_frame.display_mode = TRUE; } else stack_frame.display_mode = FALSE; (void) pp_input( input, &stack_frame, TRUE ); rtn = IFNDEF; } else if( STequal( words[ 0 ], ERx( "else" ) ) != 0 ) { if( !ifdef ) { SIfprintf( stderr, E_YAPP007 ); yydump(); } stack_frame.prev->display_mode = ( stack_frame.prev->display_mode == TRUE ) ? FALSE : TRUE; rtn = ELSE; } else if( STequal( words[ 0 ], ERx( "endif" ) ) != 0 ) { rtn = ENDIF; } else if( STequal( words[ 0 ], ERx( "include" ) ) != 0 ) { /* Look for the include filename */ if (n > 1) { /* Scan for the 'include' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the include keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'include' */ /* keyword and the specified filename */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point were expecting "file" or <file> */ /* remember the character which ends the filename */ def_dir = TRUE; if (CMcmpcase(parse_val, ERx("\"")) == 0) { parse_end = ERx("\""); } else if (CMcmpcase(parse_val, ERx("<")) == 0) { parse_end = ERx(">"); def_dir = FALSE; } else { parse_end = ERx(""); } /* Save the include file name in the temp string. */ /* Note, this overwrites the parsed words of the */ /* record since but these are no longer needed. */ p = temp; CMnext(parse_val); while (*parse_val != EOS) { if (CMcmpcase(parse_val, parse_end) == 0) { /* Terminate the file name and call */ /* pp_file to process the file. */ STcopy(ERx(""), p); pp_file(stack, temp, def_dir); break; } CMcpychar(parse_val, p); CMnext(parse_val); CMnext(p); } } rtn = DEFINE; } /* display everthing but legal directives */ if (rtn == NONE && active( &stack_frame ) ) yyputline( infile->yytext ); MEfree( temp ); return( rtn ); }
main( i4 argc, char **argv ) { bool usage = FALSE; STACK_FRAME stack_frame; char *filename = NULL; char buf[ MAX_LOC + 1]; i4 i; stack_frame.prev = NULL; stack_frame.display_mode = TRUE; /* Initialize the Include directory list, make sure the resulting */ /* path is not NULL by calling LOfaddpath with an empty path string */ ihead.next = NULL; ihead.pathloc = &defdir; STcopy(ERx(""), buf); LOfroms(PATH, buf, ihead.pathloc); /* Clear the default path */ /* Process the command line */ for( i = 1; i < argc; i++ ) { char *p; char *v; /* process -C options */ if( STbcompare( argv[ i ], 0, ERx( "-C" ), 0, TRUE ) == 0) { pass_comments = TRUE; continue; } /* process -D options */ if( STbcompare( argv[ i ], 2, ERx( "-D" ), 2, TRUE ) == 0 && STlength( argv[ i ] ) > 2 ) { p = argv[ i ]; CMnext( p ); CMnext( p ); /* Check for a value specified, -Dsymbol=value */ if (NULL == (v = STindex(p, ERx("="), STlength(p)) ) ) v = ERx(""); else CMnext(v); define( p, v, FALSE ); continue; } /* process -H option */ if( STbcompare( argv[ i ], 2, ERx( "-H" ), 2, TRUE ) == 0 && STlength( argv[ i ] ) > 2 ) { p = argv[ i ]; CMnext( p ); CMnext( p ); define( p, ERx(""), TRUE ); continue; } /* process -I option */ if( STbcompare( argv[ i ], 2, ERx( "-I" ), 2, TRUE ) == 0 && STlength( argv[ i ] ) > 2 ) { p = argv[ i ]; CMnext( p ); CMnext( p ); yyadd_path( p ); continue; } if( *argv[ i ] != '-' ) { /* file name must be final argument */ if( i != argc - 1 ) { usage = TRUE; break; } filename = argv[ i ]; } else usage = TRUE; break; } if( usage ) { SIfprintf( stderr, E_YAPP000 ); PCexit( FAIL ); } pp_file( &stack_frame, filename, TRUE ); PCexit( OK ); }
int find_includes(struct filepointer *filep, struct inclist *file, struct inclist *file_red, int recursion, boolean failOK, struct IncludesCollection* incCollection, struct symhash *symbols) { char *line; int type; boolean recfailOK; while ((line = get_line(filep))) { switch(type = deftype(line, filep, file_red, file, TRUE, symbols)) { case IF: doif: type = find_includes(filep, file, file_red, recursion+1, failOK, incCollection, symbols); while ((type == ELIF) || (type == ELIFFALSE) || (type == ELIFGUESSFALSE)) type = gobble(filep, file, file_red, symbols); if (type == ELSE) gobble(filep, file, file_red, symbols); break; case IFFALSE: case IFGUESSFALSE: doiffalse: if (type == IFGUESSFALSE || type == ELIFGUESSFALSE) recfailOK = TRUE; else recfailOK = failOK; type = gobble(filep, file, file_red, symbols); if (type == ELSE) find_includes(filep, file, file_red, recursion+1, recfailOK, incCollection, symbols); else if (type == ELIF) goto doif; else if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE)) goto doiffalse; break; case IFDEF: case IFNDEF: if ((type == IFDEF && hash_lookup(line, symbols)) || (type == IFNDEF && !hash_lookup(line, symbols))) { debug(1,(type == IFNDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": doit")); type = find_includes(filep, file, file_red, recursion+1, failOK, incCollection, symbols); while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE) type = gobble(filep, file, file_red, symbols); if (type == ELSE) gobble(filep, file, file_red, symbols); } else { debug(1,(type == IFDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": gobble")); type = gobble(filep, file, file_red, symbols); if (type == ELSE) find_includes(filep, file, file_red, recursion + 1, failOK, incCollection, symbols); else if (type == ELIF) goto doif; else if (type == ELIFFALSE || type == ELIFGUESSFALSE) goto doiffalse; } break; case ELSE: case ELIFFALSE: case ELIFGUESSFALSE: case ELIF: if (!recursion) gobble(filep, file, file_red, symbols); /*fall-through*/ case ENDIF: if (recursion) return type; /*fall-through*/ case DEFINE: define(line, &symbols); break; case UNDEF: if (!*line) { warning("%s, line %d: incomplete undef == \"%s\"\n", file_red->i_file, filep->f_line, line); break; } hash_undefine(line, symbols); break; case INCLUDE: add_include(filep, file, file_red, line, FALSE, failOK, incCollection, symbols); break; case INCLUDEDOT: add_include(filep, file, file_red, line, TRUE, failOK, incCollection, symbols); break; case ERROR: warning("%s: %d: %s\n", file_red->i_file, filep->f_line, line); break; case PRAGMA: case IDENT: case SCCS: case EJECT: break; case -1: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: unknown directive == \"%s\"\n", filep->f_line, line); break; case -2: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: incomplete include == \"%s\"\n", filep->f_line, line); break; } } return -1; }
void EBCellFAB::clone(const EBCellFAB& a_arg) { define(a_arg.m_ebisBox, a_arg.m_region, a_arg.m_nComp); }
OracleResultSet::OracleResultSet(OracleStatement* parent, bool valid) : _parent(parent), _valid(valid), _rowsProcessed(-1) { ub4 counter = 1; sb4 parm_status; ub2 dtype; ub4 colnamelen; unsigned short columnlen; char colbuf[COL_NAME_LEN]; sword status = 0; OCIParam *mypard; parm_status = OCIParamGet(_parent->getStatementHandle(), OCI_HTYPE_STMT, _parent->getErrorHandle(), (dvoid **) &mypard, counter); while( _valid && parm_status == OCI_SUCCESS ) { colMeta meta; // Get the data type status = OCIAttrGet( (dvoid*) mypard, (ub4) OCI_DTYPE_PARAM, (dvoid*) &dtype, (ub4*) 0, (ub4) OCI_ATTR_DATA_TYPE, (OCIError*) _parent->getErrorHandle() ); _parent->getOracleConnectionParent ()->checkErr((text*)_errmsg, _parent->getErrorHandle(), status); meta.dataType = dtype; // Get the column name text *colname; OCIError *e= (OCIError*) _parent->getErrorHandle(); status = OCIAttrGet( (dvoid*) mypard, (ub4) OCI_DTYPE_PARAM, (dvoid**) &colname, (ub4*) &colnamelen, (ub4) OCI_ATTR_NAME, e ); if (! _parent->getOracleConnectionParent ()->checkErr( (text*)_errmsg, _parent->getErrorHandle(), status) ) { cerr << "ERR: Cannot retreive name for column" << counter << endl; meta.colName = "UNKNOWN"; } else { strncpy(colbuf, (char*)colname, colnamelen); colbuf[colnamelen] = 0; meta.colName = colbuf; } // Get the column length status = OCIAttrGet( (dvoid*) mypard, (ub4) OCI_DTYPE_PARAM, (dvoid*) &columnlen, (ub4*) 0, (ub4) OCI_ATTR_DATA_SIZE, (OCIError*) _parent->getErrorHandle() ); if (! _parent->getOracleConnectionParent ()->checkErr( (text*)_errmsg, _parent->getErrorHandle(), status) ) { cerr << "ERR: Cannot get length for column " << counter << endl; meta.columnLen = 0; } else { meta.columnLen = columnlen; } // Get the next descriptor ++counter; parm_status = OCIParamGet(_parent->getStatementHandle(), OCI_HTYPE_STMT, _parent->getErrorHandle(), (dvoid **) &mypard, counter); _meta.push_back(meta); } ORSMetaData::iterator beg = _meta.begin(); ORSMetaData::iterator end = _meta.end(); counter = 1; _currentRow = new char*[_meta.size()]; if (beg == end) { PANICV( "No columns found.!"); } while(beg != end && status != OCI_NO_DATA) { unsigned short len = (*beg).columnLen; _currentRow[counter-1] = new char[len+1]; memset(_currentRow[counter-1], 0, len+1); // Define our data buffer sword status = define((ub4)counter, (dvoid*)_currentRow[counter-1], (sb4)len+1); if (! _parent->getOracleConnectionParent ()->checkErr( (text*)_errmsg, _parent->getErrorHandle(), status) ) { PANICV("ERR: (OCIDefineByPos): %s", _errmsg ); } ++beg; ++counter; } }