Added prototyping stuff

This commit is contained in:
ceriel
1993-11-10 12:09:49 +00:00
parent 62f978c40f
commit 103cbb4319
37 changed files with 205 additions and 94 deletions

View File

@@ -5,7 +5,7 @@
/* $Header$ */
#include <system.h>
#include <varargs.h>
#include "print.h"
#include "param.h"
/*FORMAT1 $
@@ -15,7 +15,7 @@
%[uxbo] = unsigned int
%d = int
$ */
/*VARARGS2*/
void
doprnt(fp, fmt, argp)
File *fp;
char *fmt;

View File

@@ -4,7 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
extern char *long2str();
@@ -33,7 +34,6 @@ integral(c)
%[uxbo] = unsigned int
%d = int
$ */
/*VARARGS2*/
int
_format(buf, fmt, argp)
char *buf, *fmt;

View File

@@ -4,8 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
#include "param.h"
/*FORMAT1v $
@@ -16,18 +16,28 @@
%d = int
$ */
/*VARARGS*/
fprint(va_alist)
void
fprint
#if __STDC__
(File *fp, char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
File *fp;
char *fmt;
#endif
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
fp = va_arg(args, File *);
fmt = va_arg(args, char *);
#endif
sys_write(fp, buf, _format(buf, fmt, args));
va_end(args);
}

View File

@@ -5,19 +5,19 @@ print, fprint, sprint, doprnt -- very simple formatted-output routines
.SH SYNOPSIS
.nf
.B #include <system.h>
.B #include <varargs.h>
.B #include <print.h>
.PP
.B print(format [, arg] ... )
.B void print(format [, arg] ... )
.B char *format;
.PP
.B fprint(filep, format [, arg] ... )
.B void fprint(filep, format [, arg] ... )
.B File *filep;
.B char *format;
.PP
.B char *sprint(s, format [, arg] ... )
.B char *s, *format;
.PP
.B doprnt(filep, format, args)
.B void doprnt(filep, format, args)
.B File *filep;
.B char *format;
.B va_list args;
@@ -106,29 +106,6 @@ length of the string.
takes
.I args
as the address of the arguments of the format string.
This allows routines, e.g.
.IR print ,
to be defined as follows:
.br
.RS
.nf
#include <varargs.h>
#include <system.h>
/*VARARGS*/
print(va_alist)
va_dcl
{
char *fmt;
va_list args;
va_start(args);
fmt = va_arg(args, char *);
doprnt(STDOUT, fmt, args);
va_end(args);
}
.fi
.RE
.SH FILES
.nf
~em/modules/lib/libprint.a

View File

@@ -4,8 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
#include "param.h"
/*FORMAT0v $
@@ -16,15 +16,26 @@
%d = int
$ */
/*VARARGS*/
print(va_alist)
void
print
#if __STDC__
(char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
char *fmt;
#endif
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
fmt = va_arg(args, char *);
#endif
sys_write(STDOUT, buf, _format(buf, fmt, args));
va_end(args);
}

View File

@@ -4,12 +4,20 @@
*/
/* $Header$ */
#define stdin STDIN
#define stdout STDOUT
#define stderr STDERR
#ifndef __PRINT_INCLUDED__
#define __PRINT_INCLUDED__
#define printf print
#define sprintf sprint
#define fprintf fprint
#include <ansi.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#define FILE File
_PROTOTYPE(void print, (char *fmt, ...));
_PROTOTYPE(void fprint, (File *f, char *fmt, ...));
_PROTOTYPE(void doprnt, (File *f, char *fmt, va_list ap));
_PROTOTYPE(int _format, (char *buf, char *fmt, va_list ap));
_PROTOTYPE(char *sprint, (char *buf, char *fmt, ...));
#endif /* __PRINT_INCLUDED__ */

View File

@@ -21,16 +21,18 @@ $(LIBPRINT): $(OBJ)
$(RANLIB) $(LIBPRINT)
install: all
-mkdir $(MOD_DIR)/lib
-mkdir $(MOD_DIR)/h
cp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT)
$(RANLIB) $(MOD_DIR)/lib/$(LIBPRINT)
cp $(SRC_DIR)/print.3 $(MOD_DIR)/man/print.3
cp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h
if [ $(DO_MACHINE_INDEP) = y ] ; \
then mk_manpage $(SRC_DIR)/print.3 $(TARGET_HOME) ; \
fi
cmp: all
-cmp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT)
-cmp $(SRC_DIR)/print.3 $(MOD_DIR)/man/print.3
-cmp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h
pr:
@pr $(SRC_DIR)/proto.make $(SRC)

View File

@@ -4,8 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
#include "param.h"
/*FORMAT1v $
@@ -17,15 +17,25 @@
$ */
/*VARARGS*/
char *
sprint(va_alist)
sprint
#if __STDC__
(char *buf, char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
char *buf, *fmt;
#endif
va_list args;
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
buf = va_arg(args, char *);
fmt = va_arg(args, char *);
#endif
buf[_format(buf, fmt, args)] = '\0';
va_end(args);
return buf;