Beispiel #1
0
int printexpr(struct expr *e, char **s, int ssize)
{
    if (e->subexpr) {
	if (ssize > 0) {
	    ssize--;
	    *(*s)++ = '(';
	}
	ssize = printexpr(e->subexpr->a, s, ssize);
	if (ssize > 0) {
	    ssize--;
	    *(*s)++ = printop(e->subexpr->op);
	}
	ssize = printexpr(e->subexpr->b, s, ssize);
	if (ssize > 0) {
	    ssize--;
	    *(*s)++ = ')';
	}
	*(*s) = '\0';
	return(ssize);
    } else {
	char buf[40];
	int len;
	sprintf(buf, "%d", e->val);
	len = strlen(buf);
	if (len >= ssize)
	    return(0);
	strcpy(*s, buf);
	*s += len;
	return(ssize - len);
    }
}
Beispiel #2
0
void
sp_print_document(Gtk::Window& parentWindow, SPDocument *doc)
{
    doc->ensureUpToDate();

    // Build arena
    SPItem      *base = doc->getRoot();

    // Run print dialog
    Inkscape::UI::Dialog::Print printop(doc,base);
    Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow);
    (void)res; // TODO handle this
}
Beispiel #3
0
void
sp_print_document(Gtk::Window& parentWindow, SPDocument *doc)
{
    sp_document_ensure_up_to_date(doc);

    // Build arena
    SPItem      *base = SP_ITEM(sp_document_root(doc));
    NRArena    *arena = NRArena::create();
    unsigned int dkey = sp_item_display_key_new(1);
    NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);

    // Run print dialog
    Inkscape::UI::Dialog::Print printop(doc,base);
    Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow);
    (void)res; // TODO handle this

    // Release arena
    sp_item_invoke_hide(base, dkey);
    nr_object_unref((NRObject *) arena);
}
Beispiel #4
0
/* Reverse Polish calculator */
main()
{
	int type;
	double op2;
	char s[MAXOP];
	
	while((type=getop(s))!=EOF){
			switch(type){
					case NUMBER:
							push(atof(s));
							break;
					case IDENTIFIER:
							dealWithName(s);
					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();
							if(op2)
									push(fmod(pop(),op2));
							else
									printf("error:zero divisor\n");
							break;
					case '\n':
							printf("\t%.8g\n",pop());
							break;
					/* print the top element and not push */
					case 'p':
							printop();
							break;
					/* copy the top element and print it */
					case 'c':
							copy();
							break;
					/* print the stack */
					case 'P':
							printstack();
							break;
					/* swap the top two element */
					case 's':
							swap();
							break;
					case 'C':
							clear();
							break;
					default:
							printf("error:unknown command %s\n",s);
							break;
			
			}
	}
	return 0;
}