Split vfprintf.c into 2 via #ifdefs, so that ORCA/C can create two

different object files.

Added "%b" printf specifier for as per the ORCA/C implementation,
but disable it for now pending an ORCA/C bug.
This commit is contained in:
gdr 1997-10-30 04:52:45 +00:00
parent 88223ca717
commit 68e30dd46a
2 changed files with 74 additions and 20 deletions

View File

@ -3,7 +3,7 @@
#
# Devin Reade, 1997
#
# $Id: Makefile,v 1.6 1997/10/03 04:44:25 gdr Exp $
# $Id: Makefile,v 1.7 1997/10/30 04:52:44 gdr Exp $
#
.INCLUDE: ../../../paths.mk
@ -16,8 +16,9 @@ OBJS = clrerr.o fclose.o fdopen.o feof.o ferror.o fflush.o fgetc.o \
getc.o getchar.o gets.o getw.o makebuf.o mktemp.o perror.o printf.o \
putc.o putchar.o puts.o putw.o refill.o remove.o rewind.o rget.o \
scanf.o setbuf.o setbuffer.o setvbuf.o snprintf.o sprintf.o sscanf.o \
stdio.o tempnam.o tmpfile.o tmpnam.o ungetc.o vfprintf.o vfscanf.o \
vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o wbuf.o wsetup.o
stdio.o tempnam.o tmpfile.o tmpnam.o ungetc.o vfscanf.o \
vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o wbuf.o wsetup.o \
vfprintf1.o vfprintf2.o
CFLAGS += -O78
@ -31,11 +32,17 @@ obj: $(OBJS)
# We can avoid the problem by preprocessing this file with a stand-alone
# cpp(1). This problem has been reported to Byte Works.
#
junk.c: vfprintf.c
cpp -I/src/gno/include -I/lang/orca/include -D__ORCAC__ -D__appleiigs__ -D__GNO__ $< > $@
JINCL = -I/src/gno/include -I/lang/orca/include
JDEFS = -D__ORCAC__ -D__appleiigs__ -D__GNO__ -DSPLIT_FILE_2
vfprintf.o: junk.c
$(CC) -c -o $@ $(CFLAGS) $<
junk.c: vfprintf.c
cpp $(JINCL) $(JDEFS) $< > $@
vfprintf1.o: vfprintf.c
$(CC) -c -o $@ $(CFLAGS) -DSPLIT_FILE_1 $<
vfprintf2.o: junk.c
$(CC) -c -o $@ $(CFLAGS) -DSPLIT_FILE_2 $<
.INCLUDE: ../rules.mk
@ -69,6 +76,8 @@ sscanf.o:: local.h
stdio.o:: local.h
ungetc.o:: local.h
vfprintf.o:: local.h fvwrite.h floatio.h
vfprintf1.o:: local.h fvwrite.h floatio.h
vfprintf2.o:: local.h fvwrite.h floatio.h
vfscanf.o:: local.h floatio.h
wbuf.o:: local.h
wsetup.o:: local.h

View File

@ -38,6 +38,9 @@
segment "libc_stdio";
#pragma optimize 78 /* bits 3 and 6, minimum */
#pragma debug 0
#define PRIVATE
#else
#define PRIVATE static
#endif
#if defined(LIBC_SCCS) && !defined(lint)
@ -69,11 +72,16 @@ static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
/* Define FLOATING_POINT to get floating point. */
#define FLOATING_POINT
PRIVATE int __sbprintf(register FILE *fp, const char *fmt, va_list ap);
PRIVATE int __sprint(FILE *fp, register struct __suio *uio);
#ifdef SPLIT_FILE_1
/*
* Flush out all the vectors defined by the given uio,
* then reset it so that it can be reused.
*/
static int
PRIVATE int
__sprint(FILE *fp, register struct __suio *uio)
{
register int err;
@ -94,7 +102,7 @@ __sprint(FILE *fp, register struct __suio *uio)
* worries about ungetc buffers and so forth.
*/
static int
PRIVATE int
__sbprintf(register FILE *fp, const char *fmt, va_list ap)
{
int ret;
@ -134,6 +142,8 @@ __sbprintf(register FILE *fp, const char *fmt, va_list ap)
return (ret);
}
#endif /* SPLIT_FILE_1 */
/*
* Macros for converting digits to letters and vice versa
*/
@ -141,13 +151,18 @@ __sbprintf(register FILE *fp, const char *fmt, va_list ap)
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
#define to_char(n) ((n) + '0')
PRIVATE char *
__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs);
#ifdef SPLIT_FILE_1
/*
* Convert an unsigned long to ASCII for printf purposes, returning
* a pointer to the first character of the string representation.
* Octal numbers can be forced to have a leading zero; hex numbers
* use the given digits.
*/
static char *
PRIVATE char *
__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
{
register char *cp = endp;
@ -204,7 +219,7 @@ __ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
#ifdef HAS_QUAD_T
/* Identical to __ultoa, but for quads. */
static char *
PRIVATE char *
__uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs)
{
register char *cp = endp;
@ -253,6 +268,7 @@ __uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs)
return (cp);
}
#endif /* HAS_QUAD_T */
#endif /* SPLIT_FILE_1 */
#ifdef FLOATING_POINT
#include <math.h>
@ -269,8 +285,8 @@ typedef double double_spec_t;
typedef long double ldouble_spec_t;
#endif
static char *cvt __P((double_spec_t, int, int, char *, int *, int, int *));
static int exponent __P((char *, int, int));
PRIVATE char *__cvt __P((double_spec_t, int, int, char *, int *, int, int *));
PRIVATE int __exponent __P((char *, int, int));
#else /* no FLOATING_POINT */
@ -293,6 +309,8 @@ static int exponent __P((char *, int, int));
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
#define FPT 0x100 /* Floating point number */
#ifdef SPLIT_FILE_2
#ifdef __ORCAC__
typedef struct vfprintfData_t {
char *fmt; /* format string */
@ -646,7 +664,7 @@ fp_begin: if (prec == -1)
break;
}
flags |= FPT;
cp = cvt(_double, prec, flags, &softsign,
cp = __cvt(_double, prec, flags, &softsign,
&expt, ch, &ndig);
if (ch == 'g' || ch == 'G') {
if (expt <= -4 || expt > prec)
@ -656,7 +674,7 @@ fp_begin: if (prec == -1)
}
if (ch <= 'e') { /* 'e' or 'E' fmt */
--expt;
expsize = exponent(expstr, expt, ch);
expsize = __exponent(expstr, expt, ch);
size = expsize + ndig;
if (ndig > 1 || flags & ALT)
++size;
@ -743,6 +761,28 @@ fp_begin: if (prec == -1)
size = strlen(cp);
sign = '\0';
break;
/*
* ORCA/C (maybe makelib?) has a problem with this right now. If
* This code is included, then the resulting file cannot be successfully
* placed into a library file.
*/
#if 0
#ifdef __GNO__
case 'b':
cp = va_arg(ap, char *);
if (cp == NULL) {
cp = "(null)";
size = 6;
} else {
size = *cp++;
if ((prec >= 0) && (size > prec)) {
size = prec;
}
}
sign = '\0';
break;
#endif
#endif /* 0 */
case 'U':
flags |= LONGINT;
/*FALLTHROUGH*/
@ -960,13 +1000,17 @@ error:
#undef ox
#endif /* __ORCAC__ */
#endif /* SPLIT_FILE_2 */
#ifdef SPLIT_FILE_1
#ifdef FLOATING_POINT
extern char *__dtoa __P((double, int, int, int *, int *, char **));
static char *
cvt(double_spec_t value, int ndigits, int flags, char *sign, int *decpt, int ch,
int *length)
PRIVATE char *
__cvt(double_spec_t value, int ndigits, int flags, char *sign, int *decpt,
int ch, int *length)
{
int mode, dsgn;
char *digits, *bp, *rve;
@ -1006,8 +1050,8 @@ cvt(double_spec_t value, int ndigits, int flags, char *sign, int *decpt, int ch,
return (digits);
}
static int
exponent(char *p0, int exp, int fmtch)
PRIVATE int
__exponent(char *p0, int exp, int fmtch)
{
register char *p, *t;
#ifdef __ORCAC__
@ -1038,3 +1082,4 @@ exponent(char *p0, int exp, int fmtch)
return (p - p0);
}
#endif /* FLOATING_POINT */
#endif /* SPLIT_FILE_1 */