BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / ex / printf.c
index f9cc8d6..85da93d 100644 (file)
@@ -1,8 +1,17 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)printf.c    7.4 (Berkeley) 3/9/87";
 /* The pwb version this is based on */
 static char *printf_id = "@(#) printf.c:2.2 6/5/79";
 /* The pwb version this is based on */
 static char *printf_id = "@(#) printf.c:2.2 6/5/79";
-/* The local sccs version within ex */
-static char *sccsid = "@(#)printf.c    4.3 %G%";
-#include "varargs.h"
+#endif not lint
+
+#include <varargs.h>
 /*
  * This version of printf is compatible with the Version 7 C
  * printf. The differences are only minor except that this
 /*
  * This version of printf is compatible with the Version 7 C
  * printf. The differences are only minor except that this
@@ -10,7 +19,6 @@ static char *sccsid = "@(#)printf.c   4.3 %G%";
  * printf is more general (and is much larger) and includes
  * provisions for floating point.
  */
  * printf is more general (and is much larger) and includes
  * provisions for floating point.
  */
 
 #define MAXOCT 11      /* Maximum octal digits in a long */
 #define MAXINT 32767   /* largest normal length positive integer */
 
 #define MAXOCT 11      /* Maximum octal digits in a long */
 #define MAXINT 32767   /* largest normal length positive integer */
@@ -21,7 +29,8 @@ static int width, sign, fill;
 
 char *_p_dconv();
 
 
 char *_p_dconv();
 
-printf(va_alist)
+/* VARARGS */
+ex_printf(va_alist)
        va_dcl
 {
        va_list ap;
        va_dcl
 {
        va_list ap;
@@ -42,7 +51,7 @@ printf(va_alist)
                        /* ordinary (non-%) character */
                        if (fcode=='\0')
                                return;
                        /* ordinary (non-%) character */
                        if (fcode=='\0')
                                return;
-                       putchar(fcode);
+                       ex_putchar(fcode);
                }
                /* length modifier: -1 for h, 1 for l, 0 for none */
                length = 0;
                }
                /* length modifier: -1 for h, 1 for l, 0 for none */
                length = 0;
@@ -172,8 +181,8 @@ printf(va_alist)
                                }
                                else
                                        if (!sign && fill <= 0) {
                                }
                                else
                                        if (!sign && fill <= 0) {
-                                               putchar('0');
-                                               putchar(fcode);
+                                               ex_putchar('0');
+                                               ex_putchar(fcode);
                                                width -= 2;
                                        }
                                        else {
                                                width -= 2;
                                        }
                                        else {
@@ -321,7 +330,7 @@ _p_emit(s, send)
        
        /* we may want to print a leading '-' before anything */
        if (*s == '-' && fill < 0) {
        
        /* we may want to print a leading '-' before anything */
        if (*s == '-' && fill < 0) {
-               putchar(*s++);
+               ex_putchar(*s++);
                alen--;
                width--;
        }
                alen--;
                width--;
        }
@@ -330,14 +339,14 @@ _p_emit(s, send)
        /* emit any leading pad characters */
        if (!sign)
                while (--npad >= 0)
        /* emit any leading pad characters */
        if (!sign)
                while (--npad >= 0)
-                       putchar(cfill);
+                       ex_putchar(cfill);
                        
        /* emit the string itself */
        while (--alen >= 0)
                        
        /* emit the string itself */
        while (--alen >= 0)
-               putchar(*s++);
+               ex_putchar(*s++);
                
        /* emit trailing pad characters */
        if (sign)
                while (--npad >= 0)
                
        /* emit trailing pad characters */
        if (sign)
                while (--npad >= 0)
-                       putchar(cfill);
+                       ex_putchar(cfill);
 }
 }