File: print.c

package info (click to toggle)
icmake 6.30-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,360 kB
  • ctags: 1,415
  • sloc: ansic: 7,727; makefile: 1,465; sh: 244; asm: 126; cpp: 39
file content (33 lines) | stat: -rw-r--r-- 674 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
\funcref{fun\_print}{void fun\_print ()}
    {}
    {}
    {print(), xrealloc()}
    {fun\_exec()}
    {funprint.c}
    {

        This function prints the arguments to a {\em printf()} statement,
        pushed onto the stack previously. The number of arguments to printf is
        the last pushed value.

    }

*/

#include "builtin.ih"

void fun_printf ()
{
    size_t i;
    int newelement;
    size_t nargs = intValue(top());

    for (i = 1; i <= nargs; i += newelement)
    {
        char *string = getarg(i, &newelement);
        printf("%s%s", string, 
                       typeValue(top() - i) & e_list && *string ? " " : "");
        free(string);
    }
}