/* dup : duplicate top element and push it in the stack */ void dup(void) { push(peek()); }
int main(int argc, char ** argv) { clock_t t0; t0 = clock(); bool print = true; if (argc==1) { help(); exit(0); } std::string cmd(argv[1]); //primitive programs that do not require help pages and summary statistics by default if (argc>1 && cmd=="view") { print = view(argc-1, ++argv); } else if (argc>1 && cmd=="index") { print = index(argc-1, ++argv); } else if (argc>1 && cmd=="merge") { print = merge(argc-1, ++argv); } else if (argc>1 && cmd=="paste") { print = paste(argc-1, ++argv); } else if (argc>1 && cmd=="concat") { print = concat(argc-1, ++argv); } else if (argc>1 && cmd=="subset") { subset(argc-1, ++argv); } else if (argc>1 && cmd=="decompose") { decompose(argc-1, ++argv); } else if (argc>1 && cmd=="normalize") { print = normalize(argc-1, ++argv); } else if (argc>1 && cmd=="config") { config(argc-1, ++argv); } else if (argc>1 && cmd=="mergedups") { merge_duplicate_variants(argc-1, ++argv); } else if (argc>1 && cmd=="remove_overlap") { remove_overlap(argc-1, ++argv); } else if (argc>1 && cmd=="peek") { peek(argc-1, ++argv); } else if (argc>1 && cmd=="partition") { partition(argc-1, ++argv); } else if (argc>1 && cmd=="annotate_variants") { annotate_variants(argc-1, ++argv); } else if (argc>1 && cmd=="annotate_regions") { annotate_regions(argc-1, ++argv); } else if (argc>1 && cmd=="annotate_dbsnp_rsid") { annotate_dbsnp_rsid(argc-1, ++argv); } else if (argc>1 && cmd=="discover") { discover(argc-1, ++argv); } else if (argc>1 && cmd=="merge_candidate_variants") { merge_candidate_variants(argc-1, ++argv); } else if (argc>1 && cmd=="union_variants") { union_variants(argc-1, ++argv); } else if (argc>1 && cmd=="genotype") { genotype2(argc-1, ++argv); } else if (argc>1 && cmd=="characterize") { genotype(argc-1, ++argv); } else if (argc>1 && cmd=="construct_probes") { construct_probes(argc-1, ++argv); } else if (argc>1 && cmd=="profile_indels") { profile_indels(argc-1, ++argv); } else if (argc>1 && cmd=="profile_snps") { profile_snps(argc-1, ++argv); } else if (argc>1 && cmd=="profile_mendelian") { profile_mendelian(argc-1, ++argv); } else if (argc>1 && cmd=="profile_na12878") { profile_na12878(argc-1, ++argv); } else if (argc>1 && cmd=="profile_chrom") { profile_chrom(argc-1, ++argv); } else if (argc>1 && cmd=="align") { align(argc-1, ++argv); } else if (argc>1 && cmd=="compute_features") { compute_features(argc-1, ++argv); } else if (argc>1 && cmd=="profile_afs") { profile_afs(argc-1, ++argv); } else if (argc>1 && cmd=="profile_hwe") { profile_hwe(argc-1, ++argv); } else if (argc>1 && cmd=="profile_len") { profile_len(argc-1, ++argv); } else if (argc>1 && cmd=="annotate_str") { annotate_str(argc-1, ++argv); } else if (argc>1 && cmd=="consolidate_variants") { consolidate_variants(argc-1, ++argv); } else { std::clog << "Command not found: " << argv[1] << "\n\n"; help(); exit(1); } if (print) { clock_t t1; t1 = clock(); print_time((float)(t1-t0)/CLOCKS_PER_SEC); } return 0; }
int _xkbcommon_lex(YYSTYPE *yylval, YYLTYPE *yylloc, struct scanner *s) { enum yytokentype tok; skip_more_whitespace_and_comments: /* Skip spaces. */ while (isspace(peek(s))) next(s); /* Skip comments. */ if (lit(s, "//") || chr(s, '#')) { while (!eof(s) && !eol(s)) next(s); goto skip_more_whitespace_and_comments; } /* See if we're done. */ if (eof(s)) return END_OF_FILE; /* New token. */ yylloc->first_line = yylloc->last_line = s->line; yylloc->first_column = yylloc->last_column = s->column; s->buf_pos = 0; /* String literal. */ if (chr(s, '\"')) { while (!eof(s) && !eol(s) && peek(s) != '\"') { if (chr(s, '\\')) { uint8_t o; if (chr(s, '\\')) buf_append(s, '\\'); else if (chr(s, 'n')) buf_append(s, '\n'); else if (chr(s, 't')) buf_append(s, '\t'); else if (chr(s, 'r')) buf_append(s, '\r'); else if (chr(s, 'b')) buf_append(s, '\b'); else if (chr(s, 'f')) buf_append(s, '\f'); else if (chr(s, 'v')) buf_append(s, '\v'); else if (chr(s, 'e')) buf_append(s, '\033'); else if (oct(s, &o)) buf_append(s, (char) o); else return scanner_error(yylloc, s, "illegal escape sequence in string literal"); } else { buf_append(s, next(s)); } } if (!buf_append(s, '\0') || !chr(s, '\"')) return scanner_error(yylloc, s, "unterminated string literal"); yylval->str = strdup(s->buf); if (!yylval->str) return scanner_error(yylloc, s, "scanner out of memory"); return STRING; } /* Key name literal. */ if (chr(s, '<')) { while (isgraph(peek(s)) && peek(s) != '>') buf_append(s, next(s)); if (!buf_append(s, '\0') || !chr(s, '>')) return scanner_error(yylloc, s, "unterminated key name literal"); /* Empty key name literals are allowed. */ yylval->sval = xkb_atom_intern(s->ctx, s->buf, s->buf_pos - 1); return KEYNAME; } /* Operators and punctuation. */ if (chr(s, ';')) return SEMI; if (chr(s, '{')) return OBRACE; if (chr(s, '}')) return CBRACE; if (chr(s, '=')) return EQUALS; if (chr(s, '[')) return OBRACKET; if (chr(s, ']')) return CBRACKET; if (chr(s, '(')) return OPAREN; if (chr(s, ')')) return CPAREN; if (chr(s, '.')) return DOT; if (chr(s, ',')) return COMMA; if (chr(s, '+')) return PLUS; if (chr(s, '-')) return MINUS; if (chr(s, '*')) return TIMES; if (chr(s, '!')) return EXCLAM; if (chr(s, '~')) return INVERT; /* Identifier. */ if (isalpha(peek(s)) || peek(s) == '_') { s->buf_pos = 0; while (isalnum(peek(s)) || peek(s) == '_') buf_append(s, next(s)); if (!buf_append(s, '\0')) return scanner_error(yylloc, s, "identifier too long"); /* Keyword. */ tok = keyword_to_token(s->buf); if ((int) tok != -1) return tok; yylval->str = strdup(s->buf); if (!yylval->str) return scanner_error(yylloc, s, "scanner out of memory"); return IDENT; } /* Number literal (hexadecimal / decimal / float). */ if (number(s, &yylval->num, &tok)) { if (tok == ERROR_TOK) return scanner_error(yylloc, s, "malformed number literal"); return tok; } return scanner_error(yylloc, s, "unrecognized token"); }
bool WinHttpStream::canRead() const { byte b; return peek(&b,1) != 0; }
int yylex() { int c, n; static char *buf = 0; static int bufsize = 500; if (buf == 0 && (buf = (char *) malloc(bufsize)) == NULL) ERROR "out of space in yylex" FATAL; if (sc) { sc = 0; RET('}'); } if (reg) { reg = 0; return regexpr(); } for (;;) { c = gettok(&buf, &bufsize); if (c == 0) return 0; if (isalpha(c) || c == '_') return word(buf); if (isdigit(c) || c == '.') { yylval.cp = setsymtab(buf, tostring(buf), atof(buf), CON|NUM, symtab); /* should this also have STR set? */ RET(NUMBER); } yylval.i = c; switch (c) { case '\n': /* {EOL} */ RET(NL); case '\r': /* assume \n is coming */ case ' ': /* {WS}+ */ case '\t': break; case '#': /* #.* strip comments */ while ((c = input()) != '\n' && c != 0) ; unput(c); break; case ';': RET(';'); case '\\': if (peek() == '\n') { input(); lineno++; } else if (peek() == '\r') { input(); input(); /* \n */ lineno++; } else { RET(c); } break; case '&': if (peek() == '&') { input(); RET(AND); } else RET('&'); case '|': if (peek() == '|') { input(); RET(BOR); } else RET('|'); case '!': if (peek() == '=') { input(); yylval.i = NE; RET(NE); } else if (peek() == '~') { input(); yylval.i = NOTMATCH; RET(MATCHOP); } else RET(NOT); case '~': yylval.i = MATCH; RET(MATCHOP); case '<': if (peek() == '=') { input(); yylval.i = LE; RET(LE); } else { yylval.i = LT; RET(LT); } case '=': if (peek() == '=') { input(); yylval.i = EQ; RET(EQ); } else { yylval.i = ASSIGN; RET(ASGNOP); } case '>': if (peek() == '=') { input(); yylval.i = GE; RET(GE); } else if (peek() == '>') { input(); yylval.i = APPEND; RET(APPEND); } else { yylval.i = GT; RET(GT); } case '+': if (peek() == '+') { input(); yylval.i = INCR; RET(INCR); } else if (peek() == '=') { input(); yylval.i = ADDEQ; RET(ASGNOP); } else RET('+'); case '-': if (peek() == '-') { input(); yylval.i = DECR; RET(DECR); } else if (peek() == '=') { input(); yylval.i = SUBEQ; RET(ASGNOP); } else RET('-'); case '*': if (peek() == '=') { /* *= */ input(); yylval.i = MULTEQ; RET(ASGNOP); } else if (peek() == '*') { /* ** or **= */ input(); /* eat 2nd * */ if (peek() == '=') { input(); yylval.i = POWEQ; RET(ASGNOP); } else { RET(POWER); } } else RET('*'); case '/': if (peek() == '=') { input(); yylval.i = DIVEQ; RET(ASGNOP); } else RET('/'); case '%': if (peek() == '=') { input(); yylval.i = MODEQ; RET(ASGNOP); } else RET('%'); case '^': if (peek() == '=') { input(); yylval.i = POWEQ; RET(ASGNOP); } else RET(POWER); case '$': /* BUG: awkward, if not wrong */ c = gettok(&buf, &bufsize); if (c == '(' || c == '[' || (infunc && (n=isarg(buf)) >= 0)) { unputstr(buf); RET(INDIRECT); } else if (isalpha(c)) { if (strcmp(buf, "NF") == 0) { /* very special */ unputstr("(NF)"); RET(INDIRECT); } yylval.cp = setsymtab(buf, "", 0.0, STR|NUM, symtab); RET(IVAR); } else { unputstr(buf); RET(INDIRECT); } case '}': if (--bracecnt < 0) ERROR "extra }" SYNTAX; sc = 1; RET(';'); case ']': if (--brackcnt < 0) ERROR "extra ]" SYNTAX; RET(']'); case ')': if (--parencnt < 0) ERROR "extra )" SYNTAX; RET(')'); case '{': bracecnt++; RET('{'); case '[': brackcnt++; RET('['); case '(': parencnt++; RET('('); case '"': return string(); /* BUG: should be like tran.c ? */ default: RET(c); } } }
static inline int isthisnonword(MMIOT *f, int i) { return isthisspace(f, i) || ispunct(peek(f,i)); }
const char* Buffer::findCRLF() const { const char* crlf = std::search(peek(), beginWrite(), kCRLF, kCRLF+2); return crlf == beginWrite() ? NULL : crlf; }
static int action(jsminCtx *ctx, int d) { int res = JSMIN_OK; switch (d) { case 1: OUTC(ctx, ctx->theA); if ( (ctx->theY == '\n' || ctx->theY == ' ') && (ctx->theA == '+' || ctx->theA == '-' || ctx->theA == '*' || ctx->theA == '/') && (ctx->theB == '+' || ctx->theB == '-' || ctx->theB == '*' || ctx->theB == '/') ) { OUTC(ctx, ctx->theY); } case 2: ctx->theA = ctx->theB; if (ctx->theA == '\'' || ctx->theA == '"' || ctx->theA == '`') { for (;;) { OUTC(ctx, ctx->theA); ctx->theA = get(ctx); if (ctx->theA == ctx->theB) { break; } if (ctx->theA == '\\') { OUTC(ctx, ctx->theA); ctx->theA = get(ctx); } if (ctx->theA == EOF) { error(ctx,"Unterminated string literal."); return JSMIN_ERROR; } } } case 3: res = next(ctx, &ctx->theB); if (res != JSMIN_OK) return res; if (ctx->theB == '/' && ( ctx->theA == '(' || ctx->theA == ',' || ctx->theA == '=' || ctx->theA == ':' || ctx->theA == '[' || ctx->theA == '!' || ctx->theA == '&' || ctx->theA == '|' || ctx->theA == '?' || ctx->theA == '+' || ctx->theA == '-' || ctx->theA == '~' || ctx->theA == '*' || ctx->theA == '/' || ctx->theA == '{' || ctx->theA == '\n' )) { OUTC(ctx, ctx->theA); if (ctx->theA == '/' || ctx->theA == '*') { OUTC(ctx, ' '); } OUTC(ctx, ctx->theB); for (;;) { ctx->theA = get(ctx); if (ctx->theA == '[') { for (;;) { OUTC(ctx, ctx->theA); ctx->theA = get(ctx); if (ctx->theA == ']') { break; } if (ctx->theA == '\\') { OUTC(ctx, ctx->theA); ctx->theA = get(ctx); } if (ctx->theA == EOF) { error(ctx, "Unterminated set in Regular Expression literal."); return JSMIN_ERROR; } } } else if (ctx->theA == '/') { switch (peek(ctx)) { case '/': case '*': error(ctx, "Unterminated set in Regular Expression literal."); return JSMIN_ERROR; } break; } else if (ctx->theA =='\\') { OUTC(ctx, ctx->theA); ctx->theA = get(ctx); } if (ctx->theA == EOF) { error(ctx, "Unterminated Regular Expression literal."); return JSMIN_ERROR; } OUTC(ctx, ctx->theA); } res = next(ctx, &ctx->theB); if (res != JSMIN_OK) return res; } } return JSMIN_OK; }
int jsmin(jsminCtx *ctx) { int res = JSMIN_OK; ctx->theLookahead = EOF; ctx->theX = EOF; ctx->theY = EOF; if (peek(ctx) == 0xEF) { get(ctx); get(ctx); get(ctx); } ctx->theA = '\n'; res = action(ctx,3); if (res != JSMIN_OK) return res; while (ctx->theA != EOF) { switch (ctx->theA) { case ' ': res = action(ctx, isAlphanum(ctx->theB) ? 1 : 2); if (res != JSMIN_OK) return res; break; case '\n': switch (ctx->theB) { case '{': case '[': case '(': case '+': case '-': case '!': case '~': res = action(ctx, 1); if (res != JSMIN_OK) return res; break; case ' ': res = action(ctx, 3); if (res != JSMIN_OK) return res; break; default: res = action(ctx, isAlphanum(ctx->theB) ? 1 : 2); if (res != JSMIN_OK) return res; } break; default: switch (ctx->theB) { case ' ': res = action(ctx, isAlphanum(ctx->theA) ? 1 : 3); if (res != JSMIN_OK) return res; break; case '\n': switch (ctx->theA) { case '}': case ']': case ')': case '+': case '-': case '"': case '\'': case '`': res = action(ctx, 1); if (res != JSMIN_OK) return res; break; default: res = action(ctx, isAlphanum(ctx->theA) ? 1 : 3); if (res != JSMIN_OK) return res; } break; default: res = action(ctx, 1); if (res != JSMIN_OK) return res; break; } } } return res; }
/* return current token id from scanner */ static int peek_id(Parser *p) { return peek(p)->id; }
FarmAnimal* AnimalPen::peekAtNextAnimal() {//not working FarmAnimal* temp; temp = peek(); return(temp); }
void conv_c(PR *pr, u_char *p, size_t bufsize) { char buf[10]; char const *str; wchar_t wc; size_t clen, oclen; int converr, pad, width; u_char peekbuf[MB_LEN_MAX]; if (pr->mbleft > 0) { str = "**"; pr->mbleft--; goto strpr; } switch(*p) { case '\0': str = "\\0"; goto strpr; /* case '\a': */ case '\007': str = "\\a"; goto strpr; case '\b': str = "\\b"; goto strpr; case '\f': str = "\\f"; goto strpr; case '\n': str = "\\n"; goto strpr; case '\r': str = "\\r"; goto strpr; case '\t': str = "\\t"; goto strpr; case '\v': str = "\\v"; goto strpr; default: break; } /* * Multibyte characters are disabled for hexdump(1) for backwards * compatibility and consistency (none of its other output formats * recognize them correctly). */ converr = 0; if (odmode && MB_CUR_MAX > 1) { oclen = 0; retry: clen = mbrtowc(&wc, (const char *)p, bufsize, &pr->mbstate); if (clen == 0) clen = 1; else if (clen == (size_t)-1 || (clen == (size_t)-2 && p == peekbuf)) { memset(&pr->mbstate, 0, sizeof(pr->mbstate)); wc = *p; clen = 1; converr = 1; } else if (clen == (size_t)-2) { /* * Incomplete character; peek ahead and see if we * can complete it. */ oclen = bufsize; bufsize = peek(p = peekbuf, MB_CUR_MAX); goto retry; } clen += oclen; } else { wc = *p; clen = 1; } if (!converr && iswprint(wc)) { if (!odmode) { *pr->cchar = 'c'; (void)printf(pr->fmt, (int)wc); } else { *pr->cchar = 'C'; assert(strcmp(pr->fmt, "%3C") == 0); width = wcwidth(wc); assert(width >= 0); pad = 3 - width; if (pad < 0) pad = 0; (void)printf("%*s%C", pad, "", wc); pr->mbleft = clen - 1; } } else { (void)sprintf(buf, "%03o", (int)*p); str = buf; strpr: *pr->cchar = 's'; (void)printf(pr->fmt, str); } }
static void process() { /* Loop through the program text, looking for patterns. */ int c, i, left = 0; line_nr = 1; c = get(FALSE); for (;;) { if (c == EOF) { break; } else if (c == '\'' || c == '"' || c == '`') { emit(c); string(c, FALSE); c = 0; /* The most complicated case is the slash. It can mean division or a regexp literal or a line comment or a block comment. A block comment can also be a pattern to be expanded. */ } else if (c == '/') { /* A slash slash comment skips to the end of the file. */ if (peek() == '/') { emit('/'); for (;;) { c = get(TRUE); if (c == '\n' || c == '\r' || c == EOF) { break; } } c = get(FALSE); /* The first component of a slash star comment might be the tag. */ } else { if (peek() == '*') { get(FALSE); for (i = 0; i < MAX_TAG_LENGTH; i += 1) { c = get(FALSE); if (!is_alphanum(c)) { break; } tag[i] = (char)c; } tag[i] = 0; unget(c); /* Did the tag match something? */ i = (i == 0) ? -1 : match(); if (i >= 0) { expand(i); c = get(FALSE); } else { /* If the tag didn't match, then echo the comment. */ emits("/*"); emits(tag); for (;;) { if (c == EOF) { error("unterminated comment."); } if (c == '/') { c = get(TRUE); if (c == '*') { error("nested comment."); } } else if (c == '*') { c = get(TRUE); if (c == '/') { break; } } else { c = get(TRUE); } } c = get(FALSE); } } else { emit('/'); /* We are looking at a single slash. Is it a division operator, or is it the start of a regexp literal? It is not possible to tell for sure without doing a complete parse of the program, and we are not going to do that. Instead, we are adopting the convention that a regexp literal must have one of a small set of characters to its left. */ if (pre_regexp(left)) { regexp(FALSE); } left = '/'; c = get(FALSE); } } } else { /* The character was nothing special, so just echo it. If it wasn't whitespace, remember it as the character to the left of the next character. */ emit(c); if (c > ' ') { left = c; } c = get(FALSE); } } }
/* reverse Polish calculator */ int main() { int type; double op2; char s[MAXOP]; while ((type = getop(s)) != EOF) { switch(type) { case NUMBER: push(atof(s)); break; case NEGATIVE_NUMBER: push(-1 * atof(s)); break; case '+': push(pop() + pop()); break; case '*': push(pop() * pop()); break; case '-': op2 = pop(); push(pop() - op2); break; case '/': op2 = pop(); if (op2 != 0.0) push(pop() / op2); else printf("error: zero divisor\n"); break; case '%': op2 = pop(); push((int)pop() % (int)op2); break; case '\n': //do nothing break; case POP: printf("\t%.8g\n", pop()); break; case PEEK: printf("\t%.8g\n", peek()); break; case DUPLICATE: dup(); break; case SWAP: swap(); break; case CLEAR: clear(); break; default: printf("error: unknown command %s\n", s); break; } } return 0; //return SUCCESS }
static u_int32_t peek(void) { char c, *end; fixnum_t x; int ch, base; if (toktype != TOK_NONE) return toktype; c = nextchar(); if (ios_eof(F)) return TOK_NONE; if (c == '(') { toktype = TOK_OPEN; } else if (c == ')') { toktype = TOK_CLOSE; } else if (c == '[') { toktype = TOK_OPENB; } else if (c == ']') { toktype = TOK_CLOSEB; } else if (c == '\'') { toktype = TOK_QUOTE; } else if (c == '`') { toktype = TOK_BQ; } else if (c == '"') { toktype = TOK_DOUBLEQUOTE; } else if (c == '#') { ch = ios_getc(F); c = (char)ch; if (ch == IOS_EOF) lerror(ParseError, "read: invalid read macro"); if (c == '.') { toktype = TOK_SHARPDOT; } else if (c == '\'') { toktype = TOK_SHARPQUOTE; } else if (c == '\\') { uint32_t cval; if (ios_getutf8(F, &cval) == IOS_EOF) lerror(ParseError, "read: end of input in character constant"); if (cval == (uint32_t)'u' || cval == (uint32_t)'U' || cval == (uint32_t)'x') { read_token('u', 0); if (buf[1] != '\0') { // not a solitary 'u','U','x' if (!read_numtok(&buf[1], &tokval, 16)) lerror(ParseError, "read: invalid hex character constant"); cval = numval(tokval); } } else if (cval >= 'a' && cval <= 'z') { read_token((char)cval, 0); tokval = symbol(buf); if (buf[1] == '\0') /* one character */; else if (tokval == nulsym) cval = 0x00; else if (tokval == alarmsym) cval = 0x07; else if (tokval == backspacesym) cval = 0x08; else if (tokval == tabsym) cval = 0x09; else if (tokval == linefeedsym) cval = 0x0A; else if (tokval == newlinesym) cval = 0x0A; else if (tokval == vtabsym) cval = 0x0B; else if (tokval == pagesym) cval = 0x0C; else if (tokval == returnsym) cval = 0x0D; else if (tokval == escsym) cval = 0x1B; else if (tokval == spacesym) cval = 0x20; else if (tokval == deletesym) cval = 0x7F; else lerrorf(ParseError, "read: unknown character #\\%s", buf); } toktype = TOK_NUM; tokval = mk_wchar(cval); } else if (c == '(') { toktype = TOK_SHARPOPEN; } else if (c == '<') { lerror(ParseError, "read: unreadable object"); } else if (isdigit(c)) { read_token(c, 1); c = (char)ios_getc(F); if (c == '#') toktype = TOK_BACKREF; else if (c == '=') toktype = TOK_LABEL; else lerror(ParseError, "read: invalid label"); errno = 0; x = strtol(buf, &end, 10); if (*end != '\0' || errno) lerror(ParseError, "read: invalid label"); tokval = fixnum(x); } else if (c == '!') { // #! single line comment for shbang script support do { ch = ios_getc(F); } while (ch != IOS_EOF && (char)ch != '\n'); return peek(); } else if (c == '|') { // multiline comment int commentlevel=1; while (1) { ch = ios_getc(F); hashpipe_gotc: if (ch == IOS_EOF) lerror(ParseError, "read: eof within comment"); if ((char)ch == '|') { ch = ios_getc(F); if ((char)ch == '#') { commentlevel--; if (commentlevel == 0) break; else continue; } goto hashpipe_gotc; } else if ((char)ch == '#') { ch = ios_getc(F); if ((char)ch == '|') commentlevel++; else goto hashpipe_gotc; } } // this was whitespace, so keep peeking return peek(); } else if (c == ';') { // datum comment (void)do_read_sexpr(UNBOUND); // skip return peek(); } else if (c == ':') { // gensym ch = ios_getc(F); if ((char)ch == 'g') ch = ios_getc(F); read_token((char)ch, 0); errno = 0; x = strtol(buf, &end, 10); if (*end != '\0' || buf[0] == '\0' || errno) lerror(ParseError, "read: invalid gensym label"); toktype = TOK_GENSYM; tokval = fixnum(x); } else if (symchar(c)) { read_token(ch, 0); if (((c == 'b' && (base= 2)) || (c == 'o' && (base= 8)) || (c == 'd' && (base=10)) || (c == 'x' && (base=16))) && (isdigit_base(buf[1],base) || buf[1]=='-')) { if (!read_numtok(&buf[1], &tokval, base)) lerrorf(ParseError, "read: invalid base %d constant", base); return (toktype=TOK_NUM); } toktype = TOK_SHARPSYM; tokval = symbol(buf); } else { lerror(ParseError, "read: unknown read macro"); } } else if (c == ',') { toktype = TOK_COMMA; ch = ios_getc(F); if (ch == IOS_EOF) return toktype; if ((char)ch == '@') toktype = TOK_COMMAAT; else if ((char)ch == '.') toktype = TOK_COMMADOT; else ios_ungetc((char)ch, F); } else { if (!read_token(c, 0)) { if (buf[0]=='.' && buf[1]=='\0') { return (toktype=TOK_DOT); } else { if (read_numtok(buf, &tokval, 0)) return (toktype=TOK_NUM); } } toktype = TOK_SYM; tokval = symbol(buf); } return toktype; }
//------------------------------do_call---------------------------------------- // Handle your basic call. Inline if we can & want to, else just setup call. void Parse::do_call() { // It's likely we are going to add debug info soon. // Also, if we inline a guy who eventually needs debug info for this JVMS, // our contribution to it is cleaned up right here. kill_dead_locals(); // Set frequently used booleans bool is_virtual = bc() == Bytecodes::_invokevirtual; bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface; bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial; // Find target being called bool will_link; ciMethod* dest_method = iter().get_method(will_link); ciInstanceKlass* holder_klass = dest_method->holder(); ciKlass* holder = iter().get_declared_method_holder(); ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder); int nargs = dest_method->arg_size(); // See if the receiver (if any) is NULL, hence we always throw BEFORE // attempting to resolve the call or initialize the holder class. Doing so // out of order opens a window where we can endlessly deopt because the call // holder is not initialized, but the call never actually happens (forcing // class initialization) because we only see NULL receivers. CPData_Invoke *caller_cpdi = cpdata()->as_Invoke(bc()); debug_only( assert(caller_cpdi->is_Invoke(), "Not invoke!") ); if( is_virtual_or_interface && _gvn.type(stack(sp() - nargs))->higher_equal(TypePtr::NULL_PTR) ) { builtin_throw( Deoptimization::Reason_null_check, "null receiver", caller_cpdi, caller_cpdi->saw_null(), /*must_throw=*/true ); return; } // uncommon-trap when callee is unloaded, uninitialized or will not link // bailout when too many arguments for register representation if (!will_link || can_not_compile_call_site(dest_method, klass)) { return; } assert(FAM||holder_klass->is_loaded(),""); assert(dest_method->is_static() == !has_receiver, "must match bc"); // Note: this takes into account invokeinterface of methods declared in java/lang/Object, // which should be invokevirtuals but according to the VM spec may be invokeinterfaces assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc"); // Note: In the absence of miranda methods, an abstract class K can perform // an invokevirtual directly on an interface method I.m if K implements I. // --------------------- // Does Class Hierarchy Analysis reveal only a single target of a v-call? // Then we may inline or make a static call, but become dependent on there being only 1 target. // Does the call-site type profile reveal only one receiver? // Then we may introduce a run-time check and inline on the path where it succeeds. // The other path may uncommon_trap, check for another receiver, or do a v-call. // Choose call strategy. bool call_is_virtual = is_virtual_or_interface; int vtable_index = methodOopDesc::invalid_vtable_index; ciMethod* call_method = dest_method; // Try to get the most accurate receiver type if (is_virtual_or_interface) { Node* receiver_node = stack(sp() - nargs); const TypeInstPtr*inst_type=_gvn.type(receiver_node)->isa_instptr(); if( inst_type ) { ciInstanceKlass*ikl=inst_type->klass()->as_instance_klass(); // If the receiver is not yet linked then: (1) we never can make this // call because no objects can be created until linkage, and (2) CHA // reports incorrect answers... so do not bother with making the call // until after the klass gets linked. ciInstanceKlass *ikl2 = ikl->is_subtype_of(klass) ? ikl : klass; if(!ikl->is_linked()){ uncommon_trap(Deoptimization::Reason_uninitialized,klass,"call site where receiver is not linked",false); return; } } const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr(); ciMethod* optimized_virtual_method = optimize_inlining(method(), bci(), klass, dest_method, receiver_type); // Have the call been sufficiently improved such that it is no longer a virtual? if (optimized_virtual_method != NULL) { call_method = optimized_virtual_method; call_is_virtual = false; } else if (false) { // We can make a vtable call at this site vtable_index = call_method->resolve_vtable_index(method()->holder(), klass); } } // Note: It's OK to try to inline a virtual call. // The call generator will not attempt to inline a polymorphic call // unless it knows how to optimize the receiver dispatch. bool try_inline=(C->do_inlining()||InlineAccessors)&& (!C->method()->should_disable_inlining()) && (call_method->number_of_breakpoints() == 0); // Get profile data for the *callee*. First see if we have precise // CodeProfile for this exact inline because C1 inlined it already. CodeProfile *callee_cp; int callee_cp_inloff; if( caller_cpdi->inlined_method_oid() == call_method->objectId() ) { callee_cp = c1_cp(); // Use same CodeProfile as current callee_cp_inloff = caller_cpdi->cpd_offset(); // But use inlined portion } else { // If callee has a cp, clone it and use callee_cp = call_method->codeprofile(true); callee_cp_inloff = 0; if (callee_cp || FAM) { // The cloned cp needs to be freed later Compile* C = Compile::current(); C->record_cloned_cp(callee_cp); } else { // Had profile info at top level, but not for this call site? // callee_cp will hold the just created cp, or whatever cp allocated by // other thread which wins the race in set_codeprofile callee_cp = call_method->set_codeprofile(CodeProfile::make(call_method)); } } CPData_Invoke *c2_caller_cpdi = UseC1 ? c2cpdata()->as_Invoke(bc()) : NULL; // --------------------- inc_sp(- nargs); // Temporarily pop args for JVM state of call JVMState* jvms = sync_jvms(); // --------------------- // Decide call tactic. // This call checks with CHA, the interpreter profile, intrinsics table, etc. // It decides whether inlining is desirable or not. CallGenerator*cg=C->call_generator(call_method,vtable_index,call_is_virtual,jvms,try_inline,prof_factor(),callee_cp,callee_cp_inloff,c2_caller_cpdi,caller_cpdi); // --------------------- // Round double arguments before call round_double_arguments(dest_method); #ifndef PRODUCT // Record first part of parsing work for this call parse_histogram()->record_change(); #endif // not PRODUCT assert(jvms == this->jvms(), "still operating on the right JVMS"); assert(jvms_in_sync(), "jvms must carry full info into CG"); // save across call, for a subsequent cast_not_null. Node* receiver = has_receiver ? argument(0) : NULL; JVMState* new_jvms = cg->generate(jvms, caller_cpdi, is_private_copy()); if( new_jvms == NULL ) { // Did it work? // When inlining attempt fails (e.g., too many arguments), // it may contaminate the current compile state, making it // impossible to pull back and try again. Once we call // cg->generate(), we are committed. If it fails, the whole // compilation task is compromised. if (failing()) return; if (PrintOpto || PrintInlining || PrintC2Inlining) { // Only one fall-back, so if an intrinsic fails, ignore any bytecodes. if (cg->is_intrinsic() && call_method->code_size() > 0) { C2OUT->print("Bailed out of intrinsic, will not inline: "); call_method->print_name(C2OUT); C2OUT->cr(); } } // This can happen if a library intrinsic is available, but refuses // the call site, perhaps because it did not match a pattern the // intrinsic was expecting to optimize. The fallback position is // to call out-of-line. try_inline = false; // Inline tactic bailed out. cg=C->call_generator(call_method,vtable_index,call_is_virtual,jvms,try_inline,prof_factor(),c1_cp(),c1_cp_inloff(),c2_caller_cpdi,caller_cpdi); new_jvms=cg->generate(jvms,caller_cpdi,is_private_copy()); assert(new_jvms!=NULL,"call failed to generate: calls should work"); if (c2_caller_cpdi) c2_caller_cpdi->_inlining_failure_id = IF_GENERALFAILURE; } if (cg->is_inline()) { C->env()->notice_inlined_method(call_method); } // Reset parser state from [new_]jvms, which now carries results of the call. // Return value (if any) is already pushed on the stack by the cg. add_exception_states_from(new_jvms); if (new_jvms->map()->control() == top()) { stop_and_kill_map(); } else { assert(new_jvms->same_calls_as(jvms), "method/bci left unchanged"); set_jvms(new_jvms); } if (!stopped()) { // This was some sort of virtual call, which did a null check for us. // Now we can assert receiver-not-null, on the normal return path. if (receiver != NULL && cg->is_virtual()) { Node*cast=cast_not_null(receiver,true); // %%% assert(receiver == cast, "should already have cast the receiver"); } // Round double result after a call from strict to non-strict code round_double_result(dest_method); // If the return type of the method is not loaded, assert that the // value we got is a null. Otherwise, we need to recompile. if (!dest_method->return_type()->is_loaded()) { // If there is going to be a trap, put it at the next bytecode: set_bci(iter().next_bci()); do_null_assert(peek(), T_OBJECT); set_bci(iter().cur_bci()); // put it back } else { assert0( call_method->return_type()->is_loaded() ); BasicType result_type = dest_method->return_type()->basic_type(); if(result_type==T_OBJECT||result_type==T_ARRAY){ const Type *t = peek()->bottom_type(); assert0( t == TypePtr::NULL_PTR || t->is_oopptr()->klass()->is_loaded() ); } } } // Restart record of parsing work after possible inlining of call #ifndef PRODUCT parse_histogram()->set_initial_state(bc()); #endif }
// label is the backreference we'd like to fix up with this read static value_t do_read_sexpr(value_t label) { value_t v, sym, oldtokval, *head; value_t *pv; u_int32_t t; char c; t = peek(); take(); switch (t) { case TOK_CLOSE: lerror(ParseError, "read: unexpected ')'"); case TOK_CLOSEB: lerror(ParseError, "read: unexpected ']'"); case TOK_DOT: lerror(ParseError, "read: unexpected '.'"); case TOK_SYM: case TOK_NUM: return tokval; case TOK_COMMA: head = &COMMA; goto listwith; case TOK_COMMAAT: head = &COMMAAT; goto listwith; case TOK_COMMADOT: head = &COMMADOT; goto listwith; case TOK_BQ: head = &BACKQUOTE; goto listwith; case TOK_QUOTE: head = "E; listwith: #ifdef MEMDEBUG2 v = fl_list2(*head, NIL); #else v = cons_reserve(2); car_(v) = *head; cdr_(v) = tagptr(((cons_t*)ptr(v))+1, TAG_CONS); car_(cdr_(v)) = cdr_(cdr_(v)) = NIL; #endif PUSH(v); if (label != UNBOUND) ptrhash_put(&readstate->backrefs, (void*)label, (void*)v); v = do_read_sexpr(UNBOUND); car_(cdr_(Stack[SP-1])) = v; return POP(); case TOK_SHARPQUOTE: // femtoLisp doesn't need symbol-function, so #' does nothing return do_read_sexpr(label); case TOK_OPEN: PUSH(NIL); read_list(&Stack[SP-1], label); return POP(); case TOK_SHARPSYM: sym = tokval; if (sym == tsym || sym == Tsym) return FL_T; else if (sym == fsym || sym == Fsym) return FL_F; // constructor notation c = nextchar(); if (c != '(') { take(); lerrorf(ParseError, "read: expected argument list for %s", symbol_name(tokval)); } PUSH(NIL); read_list(&Stack[SP-1], UNBOUND); if (sym == vu8sym) { sym = arraysym; Stack[SP-1] = fl_cons(uint8sym, Stack[SP-1]); } else if (sym == fnsym) { sym = FUNCTION; } v = symbol_value(sym); if (v == UNBOUND) fl_raise(fl_list2(UnboundError, sym)); return fl_apply(v, POP()); case TOK_OPENB: return read_vector(label, TOK_CLOSEB); case TOK_SHARPOPEN: return read_vector(label, TOK_CLOSE); case TOK_SHARPDOT: // eval-when-read // evaluated expressions can refer to existing backreferences, but they // cannot see pending labels. in other words: // (... #2=#.#0# ... ) OK // (... #2=#.(#2#) ... ) DO NOT WANT sym = do_read_sexpr(UNBOUND); if (issymbol(sym)) { v = symbol_value(sym); if (v == UNBOUND) fl_raise(fl_list2(UnboundError, sym)); return v; } return fl_toplevel_eval(sym); case TOK_LABEL: // create backreference label if (ptrhash_has(&readstate->backrefs, (void*)tokval)) lerrorf(ParseError, "read: label %ld redefined", numval(tokval)); oldtokval = tokval; v = do_read_sexpr(tokval); ptrhash_put(&readstate->backrefs, (void*)oldtokval, (void*)v); return v; case TOK_BACKREF: // look up backreference v = (value_t)ptrhash_get(&readstate->backrefs, (void*)tokval); if (v == (value_t)HT_NOTFOUND) lerrorf(ParseError, "read: undefined label %ld", numval(tokval)); return v; case TOK_GENSYM: pv = (value_t*)ptrhash_bp(&readstate->gensyms, (void*)tokval); if (*pv == (value_t)HT_NOTFOUND) *pv = fl_gensym(NULL, 0); return *pv; case TOK_DOUBLEQUOTE: return read_string(); } return FL_UNSPECIFIED; }
// Copies ops out of the bgsync queue into the deque passed in as a parameter. // Returns true if the batch should be ended early. // Batch should end early if we encounter a command, or if // there are no further ops in the bgsync queue to read. // This function also blocks 1 second waiting for new ops to appear in the bgsync // queue. We can't block forever because there are maintenance things we need // to periodically check in the loop. bool SyncTail::tryPopAndWaitForMore(SyncTail::OpQueue* ops) { BSONObj op; // Check to see if there are ops waiting in the bgsync queue bool peek_success = peek(&op); if (!peek_success) { // if we don't have anything in the queue, wait a bit for something to appear if (ops->empty()) { // block up to 1 second _networkQueue->waitForMore(); return false; } // otherwise, apply what we have return true; } // check for commands if ((op["op"].valuestrsafe()[0] == 'c') || // Index builds are acheived through the use of an insert op, not a command op. // The following line is the same as what the insert code uses to detect an index build. (NamespaceString(op["ns"].valuestrsafe()).coll == "system.indexes")) { if (ops->empty()) { // apply commands one-at-a-time ops->push_back(op); _networkQueue->consume(); } // otherwise, apply what we have so far and come back for the command return true; } // check for oplog version change BSONElement elemVersion = op["v"]; int curVersion = 0; if (elemVersion.eoo()) // missing version means version 1 curVersion = 1; else curVersion = elemVersion.Int(); if (curVersion != oplogVersion) { // Version changes cause us to end a batch. // If we are starting a new batch, reset version number // and continue. if (ops->empty()) { oplogVersion = curVersion; } else { // End batch early return true; } } // Copy the op to the deque and remove it from the bgsync queue. ops->push_back(op); _networkQueue->consume(); // Go back for more ops return false; }
/** * Returns the last encountered non-NULL token */ Token* TokenStack::last() { if( latest == NULL ) { latest = peek(); } return latest; }
std::streamsize circular_char_buffer::peek(std::string &c, std::streamsize clen) const{ c.clear(); c.resize(clen); return peek(const_cast<char*>(c.c_str()), clen); }
const char* Buffer::findEOL() const { const void* eol = memchr(peek(), '\n', readableBytes()); return static_cast<const char*>(eol); }
/** * Look at the item at the front of this queue. This method may * not be invoked on an empty queue. * * @return the item value **/ const T &front() const { return peek(0); }
static int string(lexparam l, int delimiter) { int c = peek(l); joqe_lex_source *s = &l.builder->src; while(c >= 0) { if(c == delimiter) { consume(l); if(!(l.yylval->string = joqe_build_closestring(l.builder))) { l.yylval->integer = INVALID_OVERLONG; return INVALID_STRING; } return STRING; } if(c < 0x20) { l.yylval->integer = INVALID_CONTROL_CHARACTER; return INVALID_STRING; } if(c == '\\') { c = consume(l); switch(c) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'u': { uint32_t u = 0; int z = 0; do { if(z) { if(consume(l) != '\\') { l.yylval->integer = INVALID_UNICODE_SURROGATE; return INVALID_STRING; } else if(consume(l) != 'u') { l.yylval->integer = INVALID_UNICODE_SURROGATE; return INVALID_STRING; } } int32_t A = hex2dec(consume(l)); int32_t B = hex2dec(consume(l)); int32_t C = hex2dec(consume(l)); int32_t D = hex2dec(c = consume(l)); if((A|B|C|D) < 0 || !c) { l.yylval->integer = INVALID_UNICODE_ESCAPE; return INVALID_STRING; } z = joqe_utf16(A<<4|B, C<<4|D, z, &u); } while(z); c = joqe_lex_source_push(s, u); } break; default: if(c < 0x20) { l.yylval->integer = INVALID_UNICODE_ESCAPE; return INVALID_STRING; } break; } } joqe_build_appendstring(l.builder, c); c = consume(l); } l.yylval->integer = INVALID_END_OF_INPUT; return INVALID_STRING; }
/** * Look at the item at the back of this queue. This method may * not be invoked on an empty queue. * * @return the item value **/ const T &back() const { return peek(_used - 1); }
int string() { int c, n; char *s, *bp; static char *buf = 0; static int bufsz = 500; if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL) ERROR "out of space for strings" FATAL; for (bp = buf; (c = input()) != '"'; ) { if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, 0)) ERROR "out of space for string %.10s...", buf FATAL; switch (c) { case '\n': case '\r': case 0: ERROR "non-terminated string %.10s...", buf SYNTAX; lineno++; break; case '\\': c = input(); switch (c) { case '"': *bp++ = '"'; break; case 'n': *bp++ = '\n'; break; case 't': *bp++ = '\t'; break; case 'f': *bp++ = '\f'; break; case 'r': *bp++ = '\r'; break; case 'b': *bp++ = '\b'; break; case 'v': *bp++ = '\v'; break; case 'a': *bp++ = '\a'; break; case '\\': *bp++ = '\\'; break; case '0': case '1': case '2': /* octal: \d \dd \ddd */ case '3': case '4': case '5': case '6': case '7': n = c - '0'; if ((c = peek()) >= '0' && c < '8') { n = 8 * n + input() - '0'; if ((c = peek()) >= '0' && c < '8') n = 8 * n + input() - '0'; } *bp++ = n; break; case 'x': /* hex \x0-9a-fA-F + */ { char xbuf[100], *px; for (px = xbuf; (c = input()) != 0 && px-xbuf < 100-2; ) { if (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) *px++ = c; else break; } *px = 0; unput(c); sscanf(xbuf, "%x", &n); *bp++ = n; break; } default: *bp++ = c; break; } break; default: *bp++ = c; break; } } *bp = 0; s = tostring(buf); *bp++ = ' '; *bp++ = 0; yylval.cp = setsymtab(buf, s, 0.0, CON|STR|DONTFREE, symtab); RET(STRING); }
/** * Copy all items on this queue into the given queue while * retaining item order. The items will be inserted at the back of * the target queue. * * @param q the target queue **/ void copyInto(ArrayQueue<T> &q) const { for (uint32_t i = 0; i < _used; ++i) { q.emplace(peek(i)); } }
int_type underflow()/*C++0x_override/**/{return peek();}
int main() { Stack *s; int i, removed, returned, e=5; s = createStack(); initializeStack(s); for (i=0; i<50; i++) { if(push(s, 5+i+1) == 0) { printf("O valor %d foi inserido!\n", 5+i+1); } else { printf("O valor %d não pôde ser inserido.\n", 5+i+1); } } for (i=0; i<50; i++) { if (pop(s, &removed)==0) { printf("Topo removido com sucesso, o valor era: %d\n", removed); } else { printf("Não foi possível remover o topo\n"); } } if (peek(s, &returned) == 0) { printf("O valor do topo é: %d\n", returned); } else { printf("Não há nada no topo.\n"); } printStack(s); if (contains(s, &e) == 1) { printf("O valor 5 não está presente na pilha.\n"); } else { printf("O valor 5 está presente na pilha.\n"); } e++; if (contains(s, &e) == 1) { printf("O valor 6 não está presente na pilha.\n"); } else { printf("O valor 6 está presente na pilha.\n"); } printf("Tamanho da pilha: %d\n",sizeStack(s)); if (isEmptyStack(s) == 0) { printf("A pilha está vazia.\n"); } else { printf("A pilha não está vazia.\n"); } return(0); }
int main() { int t = 0, T = 0; scanf("%d",&T); while (t++ < T) { long int i=0,j=0,k=0; /*counter*/ stack *top; /*The topmost element of the stack*/ stacki *topi; top = NULL; /*the pointer to the topmost element is NULL*/ char infix[MAX]; /*Defining a string to store the infix*/ char postfix[MAX]; /*Defining a string to store the postfix*/ char a; scanf("%s",infix); /*Scanning the string*/ while( infix [ i ] != '\0') { if ( infix[i]=='(') push( & top , infix [i ++ ] ); else if (infix[i]==')') { while( peek ( &top ) != '(' ) { postfix [ j++ ] = pop( & top ); } pop( & top ); /*Discard the '(' */ i++; } else if ( isalpha ( infix [ i ] ) ) postfix [ j ++ ] = infix [ i ++ ]; else if (top != NULL) { if ( prcdnce ( infix [ i ]) > prcdnce ( peek ( &top ) ) ) push( & top , infix [ i ++ ] ); else { while ( prcdnce (infix [ i ]) <= prcdnce ( peek ( &top ) ) ) { postfix[ j ++ ] = pop ( & top ); if ( top == NULL) break; } push( & top , infix [ i ++ ] ); // postfix[j++] = infix[i++]; } } else if (top == NULL) push( & top , infix [ i ++ ] ); } while(top != NULL) { postfix[ j ++] = pop( & top ); } postfix[j]='\0'; printf ("%s\n",postfix); } return 0; /*successful termination*/ }
static struct buffer parse_table(struct buffer buff, struct invocation *invocation, const char **error) { unsigned i; size_t ident_len; struct argument args[MAX_ARGS]; const char *ident_name = NULL; unsigned argi = 0; buff = chomp(buff); buff = expect_char(buff, '{', error); if (*error) goto clean; buff = chomp(buff); while (!peek(buff, "}")) { if (argi >= MAX_ARGS) { raise_too_many_arguments(error); goto clean; } if (isalpha((int)buff.data[buff.offset])) { buff = get_ident(buff, &ident_name, &ident_len, error); if (!*error) { args[argi].a.value.type = RDT_STRING; args[argi].a.value.val.string.len = ident_len; args[argi].a.value.val.string.buff = (char*)calloc( ident_len + 1, sizeof(char) ); if (!args[argi].a.value.val.string.buff) goto clean; strncpy( args[argi].a.value.val.string.buff, ident_name, ident_len ); } } else buff = parse_string(buff, &args[argi].a.value, error); if (*error) goto clean; args[argi].type = AT_VALUE; buff = chomp(buff); argi++; buff = expect_char(buff, ':', error); if (*error) goto clean; buff = chomp(buff); if (argi >= MAX_ARGS) { raise_too_many_arguments(error); goto clean; } buff = parse_argument(buff, &args[argi], error); if (*error) goto clean; argi++; buff = chomp(buff); buff = expect_char(buff, ',', error); if (*error) { *error = NULL; break; } buff = chomp(buff); } buff = expect_char(buff, '}', error); if (*error) goto clean; invocation->func = all_map; invocation->argc = argi; invocation->argv = (struct argument*) malloc(sizeof(struct argument) * argi); if (!invocation->argv) { raise_enomem(error); goto clean; } memcpy(invocation->argv, args, sizeof(struct argument) * argi); goto success; clean: for (i = 0; i < argi; i++) argument_free(&args[i]); success: return buff; }