xref: /original-bsd/usr.bin/ex/ovprintf.c (revision bdd86a84)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char *sccsid = "@(#)ovprintf.c	1.3 (Berkeley) 06/07/85";
9 #endif not lint
10 
11 /*
12  * This version of printf calls doprnt, and as such is not portable,
13  * since doprnt is written in pdp-11 assembly language.  (There is a
14  * vax doprnt which has the first 2 arguments reversed.  We don't use it.)
15  * This version is used because it is about 900 bytes smaller than the
16  * portable version, which is also included in case it is needed.
17  */
18 #ifdef TRACE
19 #include	<stdio.h>
20 #undef putchar
21 #endif
22 
23 printf(fmt, args)
24 char *fmt;
25 {
26 	_doprnt(fmt, &args, 0);
27 }
28 
29 _strout(string, count, adjust, file, fillch)
30 register char *string;
31 register count;
32 int adjust;
33 register struct _iobuf *file;
34 {
35 	while (adjust < 0) {
36 		if (*string=='-' && fillch=='0') {
37 			putchar(*string++);
38 			count--;
39 		}
40 		putchar(fillch);
41 		adjust++;
42 	}
43 	while (--count>=0)
44 		putchar(*string++);
45 	while (adjust) {
46 		putchar(fillch);
47 		adjust--;
48 	}
49 }
50