|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1183 (0x49f)
Types: TextFile
Notes: UNIX file
Names: »printf.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »unimenu/src/menu/printf.c«
/*
* "@(#)printf.c 1.1 15:35:19 4/6/85"
*
* let's see if this can't replace some of the stdio stuff
*/
/*
* printf - menu only uses %s and %d
*/
static char obuf[128] = {0};
static char *outp = 0;
static int ocnt = 0;
/* VARAGRS */
printf(fmt)
char *fmt;
{
char **argv;
char *p;
long *lp;
outp = &obuf[0];
ocnt = 0;
for (argv = &fmt; *fmt; fmt++ )
{
if ( *fmt == '%' )
{
fmt++;
if ( *fmt == 'd' )
bpnum((int) *(++argv));
else if ( *fmt == 'D' )
{
lp = (long *) (++argv);
argv++;
bplng(lp);
}
else if ( *fmt == 's' )
{
p = *(++argv);
while ( *p )
bwrch(*p++);
}
else if ( *fmt == 'c' )
bwrch(*(++argv));
else
bwrch(*fmt);
}
else
bwrch(*fmt);
}
if ( ocnt )
write(1, obuf, ocnt);
}
static bwrch(c)
char c;
{
*outp++ = c;
if ( ++ocnt >= 128 )
{
write(1, obuf, ocnt);
ocnt = 0;
}
}
static char nums[] = "0123456789abcdef";
static bpnum(n)
int n;
{
if ( n < 0 )
{
bwrch('-');
n = -n;
}
if ( n >= 10 )
bpnum(n/10);
bwrch(nums[n%10]);
}
static bplng(n)
long n;
{
if ( n < 0L )
{
bwrch('-');
n = -n;
}
if ( n >= 10L )
bplng(n/10L);
bwrch(nums[(int) n % 10]);
}