Exemplo n.º 1
0
/* writewbmp
 * ---------
 * Write a wbmp to a file descriptor
 *
 * Why not just giving a filedescriptor to this function?
 * Well, the incentive to write this function was the complete
 * integration in gd library from www.libgd.org. They use
 * their own io functions, so the passing of a function seemed to be 
 * a logic(?) decision ...
 */
int writewbmp(Wbmp *wbmp, void (*putout)(int c, void *out), void *out)
{
	int row, col;
	int bitpos, octet;

	/* Generate the header */
	putout(0, out); /* WBMP Type 0: B/W, Uncompressed bitmap */
	putout(0, out); /* FixHeaderField */

	/* Size of the image */
	putmbi(wbmp->width, putout, out);	/* width */
	putmbi(wbmp->height, putout, out);	/* height */


	/* Image data */
	for(row = 0; row < wbmp->height; row++) {
		bitpos = 8;
		octet = 0;

		for(col = 0; col < wbmp->width; col++) {
			octet |= ((wbmp->bitmap[row * wbmp->width + col] == 1) ? WBMP_WHITE : WBMP_BLACK) << --bitpos;
			if(bitpos == 0) {
				bitpos = 8;
				putout(octet, out);
				octet = 0;
			}
		}

		if(bitpos != 8) {
			putout(octet, out);
		}
	}

	return 0;
}
Exemplo n.º 2
0
int main(int argc,char **argv)
{
    char path[256];
    char title[256];
    time_t now;
    int before;

    if (argc > 1)
        before = atoi(argv[1]);
    else
        before = 0;

    chdir(BBSHOME);
    bzero(&x[0], sizeof(x));

    if (init_all()) {
        printf("init data fail\n");
        return -1;
    }

    mysql_init(&s);

    if (! my_connect_mysql(&s)) {
        printf("Mysql connect error: %s\n",mysql_error(&s));
        return 0;
    }

    now=time(0) - 86400 - 86400*before;
    localtime_r(&now, &t);

    fillboard();

    mysql_close(&s);

    qsort(x, n, sizeof(x[0]), online_cmp);
    /* generate boards usage result in xml format */
    gen_board_rank_xml();

    sprintf(path,"tmp/brdlog.%d.out",getpid());
    putout(path);

    sprintf(title, "%d年%2d月%2d日版面统计数据(在线排序)", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday);
    post_file(NULL, "", path, "SysTrace", title, 0, 1, getSession());
    unlink(path);

    qsort(x, n, sizeof(x[0]), id_cmp);

    sprintf(path,"tmp/brdlog.%d.out",getpid());
    putout(path);

    sprintf(title, "%d年%2d月%2d日版面统计数据(文章数排序)", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday);
    post_file(NULL, "", path, "SysTrace", title, 0, 1, getSession());
    unlink(path);

    return 0;
}
Exemplo n.º 3
0
static void
execute(           /* process a file */
char  *file
)
{
	int  conditional = vardefined("cond");
	long  nrecs = 0;
	long  nout = 0;
	FILE  *fp;
	
	if (file == NULL)
		fp = stdin;
	else if ((fp = fopen(file, "r")) == NULL) {
		eputs(file);
		eputs(": cannot open\n");
		quit(1);
	}
	if (inpfmt != NULL)
		initinp(fp);
	
	while (getinputrec(fp)) {
		varset("recno", '=', (double)++nrecs);
		varset("outno", '=', (double)(nout+1));
		colflg = 0;
		eclock++;
		if (!conditional || varvalue("cond") > 0.0) {
			putout();
			++nout;
		}
	}
	fclose(fp);
}
Exemplo n.º 4
0
void setup()
{
   int i,j;
   
   for(i=0;i<20;i++)
	   for(j=0;j<30;j++)
	   {
	       window[i][j]=' '; 
	   }

		putout();
}
Exemplo n.º 5
0
/* putmbi
 * ------
 * Put a multibyte intgerer in some kind of output stream
 * I work here with a function pointer, to make it as generic
 * as possible. Look at this function as an iterator on the
 * mbi integers it spits out.
 *
 */
void putmbi(int i, void (*putout)(int c, void *out), void *out)
{
	int cnt, l, accu;

	/* Get number of septets */
	accu = cnt = 0;
	while(accu != i) {
		accu += i & 0x7f << 7 * cnt++;
	}

	/* Produce the multibyte output */
	for(l = cnt - 1; l > 0; l--) {
		putout(0x80 | (i & 0x7f << 7 * l) >> 7 * l, out);
	}

	putout(i & 0x7f, out);
}
Exemplo n.º 6
0
static void put_seq(
    char *  begin,                  /* Sequence already in buffer   */
    char *  seq                     /* Sequence to be read          */
)
/*
 * Put out the failed sequence as it is.
 */
{
    FILEINFO *  file = infile;
    int     c;

    cerror( "Operand of _Pragma() is not a string literal"  /* _E_  */
            , NULL, 0L, NULL);
    while (c = get_ch(), file == infile)
        *seq++ = c;
    unget_ch();
    out_ptr = seq;
    putout( begin);
}
Exemplo n.º 7
0
static void do_pragma_op( void)
/*
 * Execute the _Pragma() operator contained in an expanded macro.
 * Note: _Pragma() operator is also implemented as a special macro.  Therefore
 *      it is always searched as a macro.
 * There might be more than one _Pragma() in a expanded macro and those may be
 *      surrounded by other token sequences.
 * Since all the macros have been expanded completely, any name identical to
 *      macro should not be re-expanded.
 * However, a macro in the string argument of _Pragma() may be expanded by
 *      do_pragma() after de_stringize(), if EXPAND_PRAGMA == TRUE.
 */
{
    FILEINFO *  file;
    DEFBUF *    defp;
    int     prev = output < out_ptr;        /* There is a previous sequence */
    int     token_type;
    char *  cp1, * cp2;
    int     c;

    file = unget_string( out_ptr, NULL);
    while (c = get_ch(), file == infile) {
        if (char_type[ c] & HSP) {
            *out_ptr++ = c;
            continue;
        }
        if (scan_token( c, (cp1 = out_ptr, &cp1), out_wend)
                    == NAM && (defp = is_macro( &cp1)) != NULL
                && defp->nargs == DEF_PRAGMA) {     /* _Pragma() operator   */
            if (prev) {
                putout( output);    /* Putout the previous sequence */
                cp1 = stpcpy( output, "pragma ");   /* From top of buffer   */
            }
            /* is_macro() already read over possible spaces after _Pragma   */
            *cp1++ = get_ch();                              /* '('  */
            while (char_type[ c = get_ch()] & HSP)
                *cp1++ = c;
            if (((token_type = scan_token( c, (cp2 = cp1, &cp1), out_wend))
                    != STR && token_type != WSTR)) {
                /* Not a string literal */
                put_seq( output, cp1);
                return;
            }
            workp = de_stringize( cp2, work_buf);
            while (char_type[ c = get_ch()] & HSP)
                *cp1++ = c;
            if (c != ')') {         /* More than a string literal   */
                unget_ch();
                put_seq( output, cp1);
                return;
            }
            strcpy( workp, "\n");       /* Terminate with <newline> */
            unget_string( work_buf, NULL);
            do_pragma();                /* Do the #pragma "line"    */
            infile->bptr += strlen( infile->bptr);      /* Clear sequence   */
            cp1 = out_ptr = output;     /* From the top of buffer   */
            prev = FALSE;
        } else {                        /* Not pragma sequence      */
            out_ptr = cp1;
            prev = TRUE;
        }
    }
    unget_ch();
    if (prev)
        putout( output);
}
Exemplo n.º 8
0
static void mcpp_main( void)
/*
 * Main process for mcpp -- copies tokens from the current input stream
 * (main file or included file) to the output file.
 */
{
    int     c;                      /* Current character            */
    char *  wp;                     /* Temporary pointer            */
    DEFBUF *    defp;               /* Macro definition             */
    int     line_top;       /* Is in the line top, possibly spaces  */
    LINE_COL    line_col;   /* Location of macro call in source     */

    keep_comments = option_flags.c && !no_output;
    keep_spaces = option_flags.k;       /* Will be turned off if !compiling */
    line_col.col = line_col.line = 0L;

    /*
     * This loop is started "from the top" at the beginning of each line.
     * 'wrong_line' is set TRUE in many places if it is necessary to write
     * a #line record.  (But we don't write them when expanding macros.)
     *
     * 'newlines' variable counts the number of blank lines that have been
     * skipped over.  These are then either output via #line records or
     * by outputting explicit blank lines.
     * 'newlines' will be cleared on end of an included file by get_ch().
     */
    while (1) {                             /* For the whole input  */
        newlines = 0;                       /* Count empty lines    */

        while (1) {                         /* For each line, ...   */
            out_ptr = output;               /* Top of the line buf  */
            c = get_ch();
            if (src_col)
                break;  /* There is a residual tokens on the line   */
            while (char_type[ c] & HSP) {   /* ' ' or '\t'          */
                if (c != COM_SEP)
                    *out_ptr++ = c; /* Retain line top white spaces */
                                    /* Else skip 0-length comment   */
                c = get_ch();
            }
            if (c == '#') {                 /* Is 1st non-space '#' */
                directive();                /* Do a #directive      */
            } else if (mcpp_mode == STD && option_flags.dig && c == '%') {
                    /* In POST_STD digraphs are already converted   */
                if (get_ch() == ':') {      /* '%:' i.e. '#'        */
                    directive();            /* Do a #directive      */
                } else {
                    unget_ch();
                    if (! compiling) {
                        skip_nl();
                        newlines++;
                    } else {
                        break;
                    }
                }
            } else if (c == CHAR_EOF) {     /* End of input         */
                break;
            } else if (! compiling) {       /* #ifdef false?        */
                skip_nl();                  /* Skip to newline      */
                newlines++;                 /* Count it, too.       */
            } else if (in_asm && ! no_output) { /* In #asm block    */
                put_asm();                  /* Put out as it is     */
            } else if (c == '\n') {         /* Blank line           */
                if (keep_comments)
                    mcpp_fputc( '\n', OUT); /* May flush comments   */
                else
                    newlines++;             /* Wait for a token     */
            } else {
                break;                      /* Actual token         */
            }
        }

        if (c == CHAR_EOF)                  /* Exit process at      */
            break;                          /*   end of input       */

        /*
         * If the loop didn't terminate because of end of file, we
         * know there is a token to compile.  First, clean up after
         * absorbing newlines.  newlines has the number we skipped.
         */
        if (no_output) {
            wrong_line = FALSE;
        } else {
            if (wrong_line || newlines > 10) {
                sharp( NULL, 0);            /* Output # line number */
                if (keep_spaces && src_col) {
                    while (src_col--)       /* Adjust columns       */
                        mcpp_fputc( ' ', OUT);
                    src_col = 0;
                }
            } else {                        /* If just a few, stuff */
                while (newlines-- > 0)      /* them out ourselves   */
                    mcpp_fputc('\n', OUT);
            }
        }

        /*
         * Process each token on this line.
         */
        line_top = TRUE;
        while (c != '\n' && c != CHAR_EOF) {    /* For the whole line   */
            /*
             * has_pragma is set to TRUE so as to execute _Pragma() operator
             * when the psuedo macro _Pragma() is found.
             */
            int     has_pragma;

            if ((mcpp_debug & MACRO_CALL) && ! in_directive) {
                line_col.line = src_line;       /* Location in source   */
                line_col.col = infile->bptr - infile->buffer - 1;
            }
            if (scan_token( c, (wp = out_ptr, &wp), out_wend) == NAM
                    && (defp = is_macro( &wp)) != NULL) {   /* A macro  */
                wp = expand_macro( defp, out_ptr, out_wend, line_col
                        , & has_pragma);    /* Expand it completely */
                if (line_top) {     /* The first token is a macro   */
                    char *  tp = out_ptr;
                    while (char_type[ *tp & UCHARMAX] & HSP)
                        tp++;           /* Remove excessive spaces  */
                    memmove( out_ptr, tp, strlen( tp) + 1);
                    wp -= (tp - out_ptr);
                }
                if (has_pragma) {           /* Found _Pramga()      */
                    do_pragma_op();         /* Do _Pragma() operator*/
                    out_ptr = output;       /* Do the rest of line  */
                    wrong_line = TRUE;      /* Line-num out of sync */
                } else {
                    out_ptr = wp;
                }
                if (keep_spaces && wrong_line && infile
                        && *(infile->bptr) != '\n' && *(infile->bptr) != EOS) {
                    src_col = infile->bptr - infile->buffer;
                    /* Remember the current colums  */
                    break;                  /* Do sharp() now       */
                }
            } else {                        /* Not a macro call     */
                out_ptr = wp;               /* Advance the place    */
                if (wrong_line)             /* is_macro() swallowed */
                    break;                  /*      the newline     */
            }
            while (char_type[ c = get_ch()] & HSP) {    /* Horizontal space */
                if (c != COM_SEP)           /* Skip 0-length comment*/
                    *out_ptr++ = c;
            }
            line_top = FALSE;               /* Read over some token */
        }                                   /* Loop for line        */

        putout( output);                    /* Output the line      */
    }                                       /* Continue until EOF   */
}
Exemplo n.º 9
0
Arquivo: eqn.c Projeto: Requaos/harvey
int
yyparse(void)
{
	struct
	{
		YYSTYPE	yyv;
		int	yys;
	} yys[YYMAXDEPTH], *yyp, *yypt;
	short *yyxi;
	int yyj, yym, yystate, yyn, yyg;
	YYSTYPE save1, save2;
	int save3, save4;
	long yychar;

	save1 = yylval;
	save2 = yyval;
	save3 = yynerrs;
	save4 = yyerrflag;

	yystate = 0;
	yychar = -1;
	yynerrs = 0;
	yyerrflag = 0;
	yyp = &yys[-1];
	goto yystack;

ret0:
	yyn = 0;
	goto ret;

ret1:
	yyn = 1;
	goto ret;

ret:
	yylval = save1;
	yyval = save2;
	yynerrs = save3;
	yyerrflag = save4;
	return yyn;

yystack:
	/* put a state and value onto the stack */
	if(yydebug >= 4)
		printf("char %s in %s", yytokname(yychar), yystatname(yystate));

	yyp++;
	if(yyp >= &yys[YYMAXDEPTH]) {
		yyerror("yacc stack overflow");
		goto ret1;
	}
	yyp->yys = yystate;
	yyp->yyv = yyval;

yynewstate:
	yyn = yypact[yystate];
	if(yyn <= YYFLAG)
		goto yydefault; /* simple state */
	if(yychar < 0)
		yychar = yylex1();
	yyn += yychar;
	if(yyn < 0 || yyn >= YYLAST)
		goto yydefault;
	yyn = yyact[yyn];
	if(yychk[yyn] == yychar) { /* valid shift */
		yychar = -1;
		yyval = yylval;
		yystate = yyn;
		if(yyerrflag > 0)
			yyerrflag--;
		goto yystack;
	}

yydefault:
	/* default state action */
	yyn = yydef[yystate];
	if(yyn == -2) {
		if(yychar < 0)
			yychar = yylex1();

		/* look through exception table */
		for(yyxi=yyexca;; yyxi+=2)
			if(yyxi[0] == -1 && yyxi[1] == yystate)
				break;
		for(yyxi += 2;; yyxi += 2) {
			yyn = yyxi[0];
			if(yyn < 0 || yyn == yychar)
				break;
		}
		yyn = yyxi[1];
		if(yyn < 0)
			goto ret0;
	}
	if(yyn == 0) {
		/* error ... attempt to resume parsing */
		switch(yyerrflag) {
		case 0:   /* brand new error */
			yyerror("syntax error");
			if(yydebug >= 1) {
				printf("%s", yystatname(yystate));
				printf("saw %s\n", yytokname(yychar));
			}
yyerrlab:
			yynerrs++;

		case 1:
		case 2: /* incompletely recovered error ... try again */
			yyerrflag = 3;

			/* find a state where "error" is a legal shift action */
			while(yyp >= yys) {
				yyn = yypact[yyp->yys] + YYERRCODE;
				if(yyn >= 0 && yyn < YYLAST) {
					yystate = yyact[yyn];  /* simulate a shift of "error" */
					if(yychk[yystate] == YYERRCODE)
						goto yystack;
				}

				/* the current yyp has no shift onn "error", pop stack */
				if(yydebug >= 2)
					printf("error recovery pops state %d, uncovers %d\n",
						yyp->yys, (yyp-1)->yys );
				yyp--;
			}
			/* there is no state on the stack with an error shift ... abort */
			goto ret1;

		case 3:  /* no shift yet; clobber input char */
			if(yydebug >= YYEOFCODE)
				printf("error recovery discards %s\n", yytokname(yychar));
			if(yychar == YYEOFCODE)
				goto ret1;
			yychar = -1;
			goto yynewstate;   /* try again in the same state */
		}
	}

	/* reduction by production yyn */
	if(yydebug >= 2)
		printf("reduce %d in:\n\t%s", yyn, yystatname(yystate));

	yypt = yyp;
	yyp -= yyr2[yyn];
	yyval = (yyp+1)->yyv;
	yym = yyn;

	/* consult goto table to find next state */
	yyn = yyr1[yyn];
	yyg = yypgo[yyn];
	yyj = yyg + yyp->yys + 1;

	if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
		yystate = yyact[yyg];
	switch(yym) {
		
case 1:
#line	24	"/sys/src/cmd/eqn/eqn.y"
{ putout(yypt[-0].yyv); } break;
case 2:
#line	25	"/sys/src/cmd/eqn/eqn.y"
{ ERROR "syntax error" WARNING; } break;
case 3:
#line	26	"/sys/src/cmd/eqn/eqn.y"
{ eqnreg = 0; } break;
case 5:
#line	30	"/sys/src/cmd/eqn/eqn.y"
{ eqnbox(yypt[-1].yyv, yypt[-0].yyv, 0); } break;
case 6:
#line	31	"/sys/src/cmd/eqn/eqn.y"
{ eqnbox(yypt[-1].yyv, yypt[-0].yyv, 1); } break;
case 7:
#line	32	"/sys/src/cmd/eqn/eqn.y"
{ lineup(0); } break;
case 8:
#line	35	"/sys/src/cmd/eqn/eqn.y"
{ yyval = yypt[-0].yyv; lineup(1); } break;
case 9:
#line	38	"/sys/src/cmd/eqn/eqn.y"
{ yyval = yypt[-0].yyv; } break;
case 10:
#line	39	"/sys/src/cmd/eqn/eqn.y"
{ yyval = 0; } break;
case 11:
#line	42	"/sys/src/cmd/eqn/eqn.y"
{ yyval = yypt[-0].yyv; } break;
case 12:
#line	43	"/sys/src/cmd/eqn/eqn.y"
{ yyval = 0; } break;
case 13:
#line	46	"/sys/src/cmd/eqn/eqn.y"
{ yyval = yypt[-1].yyv; } break;
case 14:
#line	47	"/sys/src/cmd/eqn/eqn.y"
{ text(QTEXT, (char *) yypt[-0].yyv); } break;
case 15:
#line	48	"/sys/src/cmd/eqn/eqn.y"
{ text(CONTIG, (char *) yypt[-0].yyv); } break;
case 16:
#line	49	"/sys/src/cmd/eqn/eqn.y"
{ text(SPACE, (char *) 0); } break;
case 17:
#line	50	"/sys/src/cmd/eqn/eqn.y"
{ text(THIN, (char *) 0); } break;
case 18:
#line	51	"/sys/src/cmd/eqn/eqn.y"
{ text(TAB, (char *) 0); } break;
case 19:
#line	52	"/sys/src/cmd/eqn/eqn.y"
{ funny(SUM); } break;
case 20:
#line	53	"/sys/src/cmd/eqn/eqn.y"
{ funny(PROD); } break;
case 21:
#line	54	"/sys/src/cmd/eqn/eqn.y"
{ funny(UNION); } break;
case 22:
#line	55	"/sys/src/cmd/eqn/eqn.y"
{ funny(INTER); } break;
case 23:
#line	56	"/sys/src/cmd/eqn/eqn.y"
{ boverb(yypt[-2].yyv, yypt[-0].yyv); } break;
case 24:
#line	57	"/sys/src/cmd/eqn/eqn.y"
{ mark(yypt[-0].yyv); } break;
case 25:
#line	58	"/sys/src/cmd/eqn/eqn.y"
{ size(yypt[-1].yyv, yypt[-0].yyv); } break;
case 26:
#line	59	"/sys/src/cmd/eqn/eqn.y"
{ font(yypt[-1].yyv, yypt[-0].yyv); } break;
case 27:
#line	60	"/sys/src/cmd/eqn/eqn.y"
{ fatbox(yypt[-0].yyv); } break;
case 28:
#line	61	"/sys/src/cmd/eqn/eqn.y"
{ sqrt(yypt[-0].yyv); } break;
case 29:
#line	62	"/sys/src/cmd/eqn/eqn.y"
{ps -= deltaps;} break;
case 30:
#line	62	"/sys/src/cmd/eqn/eqn.y"
{ subsup(yypt[-4].yyv, yypt[-1].yyv, yypt[-0].yyv); } break;
case 31:
#line	63	"/sys/src/cmd/eqn/eqn.y"
{ps -= deltaps;} break;
case 32:
#line	63	"/sys/src/cmd/eqn/eqn.y"
{ subsup(yypt[-3].yyv, 0, yypt[-0].yyv); } break;
case 33:
#line	64	"/sys/src/cmd/eqn/eqn.y"
{ps -= deltaps;} break;
case 34:
#line	64	"/sys/src/cmd/eqn/eqn.y"
{ integral(yypt[-4].yyv, yypt[-1].yyv, yypt[-0].yyv); } break;
case 35:
#line	65	"/sys/src/cmd/eqn/eqn.y"
{ps -= deltaps;} break;
case 36:
#line	65	"/sys/src/cmd/eqn/eqn.y"
{ integral(yypt[-3].yyv, 0, yypt[-0].yyv); } break;
case 37:
#line	66	"/sys/src/cmd/eqn/eqn.y"
{ integral(yypt[-0].yyv, 0, 0); } break;
case 38:
#line	67	"/sys/src/cmd/eqn/eqn.y"
{ps -= deltaps;} break;
case 39:
#line	67	"/sys/src/cmd/eqn/eqn.y"
{ fromto(yypt[-4].yyv, yypt[-1].yyv, yypt[-0].yyv); } break;
case 40:
#line	68	"/sys/src/cmd/eqn/eqn.y"
{ps -= deltaps;} break;
case 41:
#line	68	"/sys/src/cmd/eqn/eqn.y"
{ fromto(yypt[-3].yyv, 0, yypt[-0].yyv); } break;
case 42:
#line	69	"/sys/src/cmd/eqn/eqn.y"
{ paren(yypt[-2].yyv, yypt[-1].yyv, yypt[-0].yyv); } break;
case 43:
#line	70	"/sys/src/cmd/eqn/eqn.y"
{ paren(yypt[-1].yyv, yypt[-0].yyv, 0); } break;
case 44:
#line	71	"/sys/src/cmd/eqn/eqn.y"
{ diacrit(yypt[-1].yyv, yypt[-0].yyv); } break;
case 45:
#line	72	"/sys/src/cmd/eqn/eqn.y"
{ move(FWD, yypt[-1].yyv, yypt[-0].yyv); } break;
case 46:
#line	73	"/sys/src/cmd/eqn/eqn.y"
{ move(UP, yypt[-1].yyv, yypt[-0].yyv); } break;
case 47:
#line	74	"/sys/src/cmd/eqn/eqn.y"
{ move(BACK, yypt[-1].yyv, yypt[-0].yyv); } break;
case 48:
#line	75	"/sys/src/cmd/eqn/eqn.y"
{ move(DOWN, yypt[-1].yyv, yypt[-0].yyv); } break;
case 49:
#line	76	"/sys/src/cmd/eqn/eqn.y"
{ pile(yypt[-0].yyv); ct = yypt[-0].yyv; } break;
case 50:
#line	77	"/sys/src/cmd/eqn/eqn.y"
{yyval=ct;} break;
case 51:
#line	77	"/sys/src/cmd/eqn/eqn.y"
{ matrix(yypt[-3].yyv); ct = yypt[-3].yyv; } break;
case 52:
#line	80	"/sys/src/cmd/eqn/eqn.y"
{ setintegral(); } break;
case 53:
#line	83	"/sys/src/cmd/eqn/eqn.y"
{ yyval = atoi((char *) yypt[-1].yyv); } break;
case 54:
#line	84	"/sys/src/cmd/eqn/eqn.y"
{ yyval = atoi((char *) yypt[-1].yyv); } break;
case 55:
#line	85	"/sys/src/cmd/eqn/eqn.y"
{ yyval = atoi((char *) yypt[-1].yyv); } break;
case 56:
#line	86	"/sys/src/cmd/eqn/eqn.y"
{ yyval = atoi((char *) yypt[-1].yyv); } break;
case 57:
#line	88	"/sys/src/cmd/eqn/eqn.y"
{ yyval = HAT; } break;
case 58:
#line	89	"/sys/src/cmd/eqn/eqn.y"
{ yyval = VEC; } break;
case 59:
#line	90	"/sys/src/cmd/eqn/eqn.y"
{ yyval = DYAD; } break;
case 60:
#line	91	"/sys/src/cmd/eqn/eqn.y"
{ yyval = BAR; } break;
case 61:
#line	92	"/sys/src/cmd/eqn/eqn.y"
{ yyval = LOWBAR; } break;
case 62:
#line	93	"/sys/src/cmd/eqn/eqn.y"
{ yyval = HIGHBAR; } break;
case 63:
#line	94	"/sys/src/cmd/eqn/eqn.y"
{ yyval = UNDER; } break;
case 64:
#line	95	"/sys/src/cmd/eqn/eqn.y"
{ yyval = DOT; } break;
case 65:
#line	96	"/sys/src/cmd/eqn/eqn.y"
{ yyval = TILDE; } break;
case 66:
#line	97	"/sys/src/cmd/eqn/eqn.y"
{ yyval = UTILDE; } break;
case 67:
#line	98	"/sys/src/cmd/eqn/eqn.y"
{ yyval = DOTDOT; } break;
case 68:
#line	101	"/sys/src/cmd/eqn/eqn.y"
{ yyval = ((char *)yypt[-0].yyv)[0]; } break;
case 69:
#line	102	"/sys/src/cmd/eqn/eqn.y"
{ yyval = '{'; } break;
case 70:
#line	105	"/sys/src/cmd/eqn/eqn.y"
{ yyval = ((char *)yypt[-0].yyv)[0]; } break;
case 71:
#line	106	"/sys/src/cmd/eqn/eqn.y"
{ yyval = '}'; } break;
case 74:
#line	113	"/sys/src/cmd/eqn/eqn.y"
{ column(yypt[-3].yyv, DEFGAP); } break;
case 75:
#line	114	"/sys/src/cmd/eqn/eqn.y"
{yyval=atoi((char*)yypt[-0].yyv);} break;
case 76:
#line	114	"/sys/src/cmd/eqn/eqn.y"
{ column(yypt[-5].yyv, yypt[-3].yyv); } break;
case 77:
#line	117	"/sys/src/cmd/eqn/eqn.y"
{ yyval = startcol(LCOL); } break;
case 78:
#line	118	"/sys/src/cmd/eqn/eqn.y"
{ yyval = startcol(CCOL); } break;
case 79:
#line	119	"/sys/src/cmd/eqn/eqn.y"
{ yyval = startcol(RCOL); } break;
case 80:
#line	120	"/sys/src/cmd/eqn/eqn.y"
{ yyval = startcol(COL); } break;
case 81:
#line	123	"/sys/src/cmd/eqn/eqn.y"
{ lp[ct++] = yypt[-0].yyv; } break;
case 82:
#line	124	"/sys/src/cmd/eqn/eqn.y"
{ lp[ct++] = yypt[-0].yyv; } break;
case 83:
#line	127	"/sys/src/cmd/eqn/eqn.y"
{ yyval = ps; setsize((char *) yypt[-0].yyv); } break;
case 84:
#line	130	"/sys/src/cmd/eqn/eqn.y"
{ static char R[]="R"; setfont(R); } break;
case 85:
#line	131	"/sys/src/cmd/eqn/eqn.y"
{ static char I[]="I"; setfont(I); } break;
case 86:
#line	132	"/sys/src/cmd/eqn/eqn.y"
{ static char B[]="B"; setfont(B); } break;
case 87:
#line	133	"/sys/src/cmd/eqn/eqn.y"
{ setfont((char *)yypt[-0].yyv); } break;
	}
	goto yystack;  /* stack new state and value */
}
Exemplo n.º 10
0
void enter()
{
    int i,j,c,step=1;
	//界面
	window[8][10]='G';
	window[8][11]='a';
	window[8][12]='m';
	window[8][13]='e';
	window[9][6]='R';
	window[9][7]='u';
	window[9][8]='n';
	window[9][9]=' ';
	window[9][10]='a';
	window[9][11]='n';
	window[9][12]='d';
	window[9][13]=' ';
	window[9][14]='T';
	window[9][15]='u';
	window[9][16]='r';
	window[9][17]='n';
	window[11][9]=16;
	window[11][10]='S';
	window[11][11]='t';
	window[11][12]='a';
	window[11][13]='r';
	window[11][14]='t';
    window[13][10]='H';
	window[13][11]='e';
	window[13][12]='l';
	window[13][13]='p';
	window[16][10]='P';
	window[16][11]='r';
	window[16][12]='e';
	window[16][13]='s';
	window[16][14]='s';
	window[16][15]=' ';
	window[16][16]='d';




	putout();
	while(c=getch())
	{
	    switch(c)
		{
		case'w': case's':
			 {
			   if(step==1)
			   {
			      window[11][9]=' ';
				  window[13][9]=16;
			      step=2;
				  system("cls");
				  putout();
				  break;
			   }
			   
			 
                if(step==2)
				{
				window[13][9]=' ';
					window[11][9]=16;
					step=1;
					 system("cls");
				  putout();
				  }
				break;
			}
		case'd':
			{
				if(step==1)
			goto finish;
				if(step==2)
				{
				  system("cls");
					printf("\n\t\t游戏规则\n");
				  printf("  在Run and turn的游戏中你将会是一只被诅咒的小虫子\n");
				  printf("  邪恶的诅咒使你必须不断前进(速度是不稳定的!)\n  通过不断吸收爱心来维持生命\n");
				  printf("  但拐弯需要消耗大量能量,在没吃到爱心时,仅有三次拐弯的体力\n");
				  printf("  吃到爱心后重新获得三次拐弯的体力,注意哦\n ");
				  printf("  别错过拐弯的机会哦!比比看谁爱心吃的多!\n");
				  printf("  拐弯由'w','a','s','d'控制,按两下w退出介绍");

					 getch();
				  break;
				
				
				}
			}
		}
	
	
	
	
	}

finish:;



}
Exemplo n.º 11
0
void move()
{
    int m=18,n=10,x,y,step=0,num=0;
	int c,compare;
	FILE *fp1,*fp2;
    srand((int)time(NULL));
	window[m][n]=15;

	system("cls");
	putout();
	x=rand()%19+1;
	y=rand()%28+1;
	window[x][y]=3;
while(c=getch())
{    
    
		switch(c)
	   {
		
	   case 'w' :
		   {
	num=num+1;
       while(!kbhit())
	   {
          window[m][n]=' ';
		   m=m-1;
           window[m][n]=15;
           system("cls");
		   putout();
		   		if(m==x&&n==y)
	{
	  window[m][n]=15;
	 system("cls");
	 step=1;
	  putout();
	  num=0;
	  count=count+1;
		}
		if(step==1)
		{
		step=0;
		x=rand()%19+1;
  	  y=rand()%28+1;
	  window[x][y]=3;
	  system("cls");
	  putout();
		}

}
	   if(num==3)
		   goto finish;
		 break;
		   }
	   case 'd':
		{
			num=num+1;
	      while(!kbhit())
{
           window[m][n]=' ';
		   n=n+1;
           window[m][n]=15;
           system("cls");
		   putout();
		   		if(m==x&&n==y)
	{
	  window[m][n]=15;
	 system("cls");
	 step=1;
	  putout();
	  num=0;
	   count=count+1;
		}
		if(step==1)
		{
		step=0;
		x=rand()%19+1;
  	  y=rand()%28+1;
	  window[x][y]=3;
	  system("cls");
	  putout();
		}

}
		  if(num==3)
		   goto finish;
		      break;
		}
	   case 's':
		   {
			   num=num+1;
	      while(!kbhit())
{
           window[m][n]=' ';
		   m=m+1;
           window[m][n]=15;
           system("cls");
		   putout();
		   		if(m==x&&n==y)
	{
	  window[m][n]=15;
	 system("cls");
	 step=1;
	  putout();
	  num=0;
	   count=count+1;
		}
		if(step==1)
		{
		step=0;
		x=rand()%19+1;
  	  y=rand()%28+1;
	  window[x][y]=3;
	  system("cls");
	  putout();
		}

}
		  if(num==3)
		   goto finish;
		      break;
		   }
	   case 'a' :
		   {
			   num=num+1;
while(!kbhit())
{
           window[m][n]=' ';
		    n=n-1;
           window[m][n]=15;
           system("cls");
		   putout();
		if(m==x&&n==y)
	{
	  window[m][n]=15;
	 system("cls");
	 step=1;
	  putout();
	  num=0;
	   count=count+1;
		}
		if(step==1)
		{
		step=0;
		x=rand()%19+1;
  	  y=rand()%28+1;
	  window[x][y]=3;
	  system("cls");
	  putout();
		}
}
      if(num==3)
		   goto finish;
		      break;
	   }	
	}
}
finish: {
		   window[m][n]=' ';
		   window[x][y]=' ';
		   window[10][5]='Y';
		   window[10][6]='O';
		   window[10][7]='U';
		   window[10][8]='R';
		   window[10][9]=' ';
		   window[10][10]='S';
		   window[10][11]='C';
		   window[10][12]='O';
		   window[10][13]='R';
		   window[10][14]='E';
		   window[10][15]=':';
		   window[10][16]=3;
		   window[10][17]='*';
		   window[10][18]=count;
           window[8][10]='Y';
		   window[8][11]='O';
		   window[8][12]='U';
		   window[8][13]=' ';
		   window[8][14]='L';
		   window[8][15]='O';
		   window[8][16]='S';
		   window[8][17]='E';
		   window[8][18]='!';
		   window[12][3]='P';
		   window[12][4]='r';
		   window[12][5]='e';
		   window[12][6]='s';
		   window[12][7]='s';
		   window[12][8]=' ';
		   window[12][9]='a';
		   window[12][10]='n';
		   window[12][11]='y';
		   window[12][12]=' ';
		   window[12][13]='k';
		   window[12][14]='e';
		   window[12][15]='y';
		   window[12][16]=' ';
		   window[12][17]='t';
		   window[12][18]='o';
		   window[12][19]=' ';
		   window[12][20]='r';
		   window[12][21]='e';
		   window[12][22]='t';
		   window[12][23]='r';
		   window[12][24]='y';
		   window[14][3]='P';
		   window[14][4]='r';
		   window[14][5]='e';
		   window[14][6]='s';
		   window[14][7]='s';
		   window[14][8]=' ';
		   window[14][9]='q';
		   window[14][10]=' ';
		   window[14][11]='t';
		   window[14][12]='o';
		    window[14][13]=' ';
			 window[14][14]='Q';
			  window[14][15]='u';
			   window[14][16]='i';
			    window[14][17]='t';
				fp1=fopen("record.txt","rb");
		
				fscanf(fp1,"%d",&compare);
				if(count>compare)
				{
				     system("cls");
					 printf("\n\n\n\n\n\n\n\tBreak the Record!");
					 Sleep(2000);
					 fclose(fp1);
					 fp2=fopen("record.txt","w+");
					 fprintf(fp2,"%d",count);
					 fclose(fp2);
				
				
				
				}
		  
		}
		system("cls");
		putout2( );
	
}
Exemplo n.º 12
0
int
main(
int  argc,
char  *argv[]
)
{
	int  i;

	esupport |= E_VARIABLE|E_FUNCTION|E_INCHAN|E_OUTCHAN|E_RCONST;
	esupport &= ~(E_REDEFW);

#ifdef  BIGGERLIB
	biggerlib();
#endif
	varset("PI", ':', 3.14159265358979323846);
	funset("in", 1, '=', &l_in);

	for (i = 1; i < argc && argv[i][0] == '-'; i++)
		switch (argv[i][1]) {
		case 'b':
			blnkeq = !blnkeq;
			break;
		case 'l':
			igneol = !igneol;
			break;
		case 'p':
			passive = !passive;
			break;
		case 't':
			sepchar = argv[i][2];
			break;
		case 's':
			svpreset(argv[++i]);
			break;
		case 'f':
			fcompile(argv[++i]);
			break;
		case 'e':
			scompile(argv[++i], NULL, 0);
			break;
		case 'n':
			noinput = 1;
			break;
		case 'i':
			switch (argv[i][2]) {
			case '\0':
				itype = 'a';
				nbicols = 0;
				readfmt(argv[++i], 0);
				break;
			case 'a':
				itype = 'a';
				nbicols = 0;
				break;
			case 'd':
			case 'D':
				itype = argv[i][2];
				if (isdigit(argv[i][3]))
					nbicols = atoi(argv[i]+3);
				else
					nbicols = 1;
				if (nbicols*sizeof(double) > INBSIZ) {
					eputs(argv[0]);
					eputs(": too many input columns\n");
					quit(1);
				}
				break;
			case 'f':
			case 'F':
				itype = argv[i][2];
				if (isdigit(argv[i][3]))
					nbicols = atoi(argv[i]+3);
				else
					nbicols = 1;
				if (nbicols*sizeof(float) > INBSIZ) {
					eputs(argv[0]);
					eputs(": too many input columns\n");
					quit(1);
				}
				break;
			default:
				goto userr;
			}
			break;
		case 'o':
			switch (argv[i][2]) {
			case '\0':
				otype = 'a';
				readfmt(argv[++i], 1);
				break;
			case 'a':
				otype = 'a';
				break;
			case 'd':
			case 'D':
			case 'f':
			case 'F':
				otype = argv[i][2];
				break;
			default:
				goto userr;
			}
			break;
		case 'w':
			nowarn = !nowarn;
			break;
		case 'u':
			unbuff = !unbuff;
			break;
		default:;
		userr:
			eputs("Usage: ");
			eputs(argv[0]);
eputs(" [-b][-l][-n][-p][-w][-u][-tS][-s svar=sval][-e expr][-f source][-i infmt][-o outfmt] [file]\n");
			quit(1);
		}
	if (otype != 'a')
		SET_FILE_BINARY(stdout);
	if (noinput) {          /* produce a single output record */
		if (i < argc) {
			eputs(argv[0]);
			eputs(": file argument(s) incompatible with -n\n");
			quit(1);
		}
		eclock++;
		putout();
		quit(0);
	}
	if (itype != 'a')
		SET_FILE_BINARY(stdin);

	if (blnkeq)             /* for efficiency */
		nbsynch();

	if (i == argc)          /* from stdin */
		execute(NULL);
	else                    /* from one or more files */
		for ( ; i < argc; i++)
			execute(argv[i]);
	
	quit(0);
	return 0; /* pro forma return */
}