mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-11-16 06:08:20 +00:00
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:
parent
88223ca717
commit
68e30dd46a
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Devin Reade, 1997
|
# 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
|
.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 \
|
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 \
|
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 \
|
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 \
|
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
|
vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o wbuf.o wsetup.o \
|
||||||
|
vfprintf1.o vfprintf2.o
|
||||||
|
|
||||||
CFLAGS += -O78
|
CFLAGS += -O78
|
||||||
|
|
||||||
@ -31,11 +32,17 @@ obj: $(OBJS)
|
|||||||
# We can avoid the problem by preprocessing this file with a stand-alone
|
# We can avoid the problem by preprocessing this file with a stand-alone
|
||||||
# cpp(1). This problem has been reported to Byte Works.
|
# cpp(1). This problem has been reported to Byte Works.
|
||||||
#
|
#
|
||||||
junk.c: vfprintf.c
|
JINCL = -I/src/gno/include -I/lang/orca/include
|
||||||
cpp -I/src/gno/include -I/lang/orca/include -D__ORCAC__ -D__appleiigs__ -D__GNO__ $< > $@
|
JDEFS = -D__ORCAC__ -D__appleiigs__ -D__GNO__ -DSPLIT_FILE_2
|
||||||
|
|
||||||
vfprintf.o: junk.c
|
junk.c: vfprintf.c
|
||||||
$(CC) -c -o $@ $(CFLAGS) $<
|
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
|
.INCLUDE: ../rules.mk
|
||||||
|
|
||||||
@ -69,6 +76,8 @@ sscanf.o:: local.h
|
|||||||
stdio.o:: local.h
|
stdio.o:: local.h
|
||||||
ungetc.o:: local.h
|
ungetc.o:: local.h
|
||||||
vfprintf.o:: local.h fvwrite.h floatio.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
|
vfscanf.o:: local.h floatio.h
|
||||||
wbuf.o:: local.h
|
wbuf.o:: local.h
|
||||||
wsetup.o:: local.h
|
wsetup.o:: local.h
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
segment "libc_stdio";
|
segment "libc_stdio";
|
||||||
#pragma optimize 78 /* bits 3 and 6, minimum */
|
#pragma optimize 78 /* bits 3 and 6, minimum */
|
||||||
#pragma debug 0
|
#pragma debug 0
|
||||||
|
#define PRIVATE
|
||||||
|
#else
|
||||||
|
#define PRIVATE static
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#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 to get floating point. */
|
||||||
#define 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,
|
* Flush out all the vectors defined by the given uio,
|
||||||
* then reset it so that it can be reused.
|
* then reset it so that it can be reused.
|
||||||
*/
|
*/
|
||||||
static int
|
PRIVATE int
|
||||||
__sprint(FILE *fp, register struct __suio *uio)
|
__sprint(FILE *fp, register struct __suio *uio)
|
||||||
{
|
{
|
||||||
register int err;
|
register int err;
|
||||||
@ -94,7 +102,7 @@ __sprint(FILE *fp, register struct __suio *uio)
|
|||||||
* worries about ungetc buffers and so forth.
|
* worries about ungetc buffers and so forth.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
PRIVATE int
|
||||||
__sbprintf(register FILE *fp, const char *fmt, va_list ap)
|
__sbprintf(register FILE *fp, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -134,6 +142,8 @@ __sbprintf(register FILE *fp, const char *fmt, va_list ap)
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* SPLIT_FILE_1 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros for converting digits to letters and vice versa
|
* 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 is_digit(c) ((unsigned)to_digit(c) <= 9)
|
||||||
#define to_char(n) ((n) + '0')
|
#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
|
* Convert an unsigned long to ASCII for printf purposes, returning
|
||||||
* a pointer to the first character of the string representation.
|
* a pointer to the first character of the string representation.
|
||||||
* Octal numbers can be forced to have a leading zero; hex numbers
|
* Octal numbers can be forced to have a leading zero; hex numbers
|
||||||
* use the given digits.
|
* use the given digits.
|
||||||
*/
|
*/
|
||||||
static char *
|
PRIVATE char *
|
||||||
__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
|
__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
|
||||||
{
|
{
|
||||||
register char *cp = endp;
|
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
|
#ifdef HAS_QUAD_T
|
||||||
/* Identical to __ultoa, but for quads. */
|
/* Identical to __ultoa, but for quads. */
|
||||||
static char *
|
PRIVATE char *
|
||||||
__uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs)
|
__uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs)
|
||||||
{
|
{
|
||||||
register char *cp = endp;
|
register char *cp = endp;
|
||||||
@ -253,6 +268,7 @@ __uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs)
|
|||||||
return (cp);
|
return (cp);
|
||||||
}
|
}
|
||||||
#endif /* HAS_QUAD_T */
|
#endif /* HAS_QUAD_T */
|
||||||
|
#endif /* SPLIT_FILE_1 */
|
||||||
|
|
||||||
#ifdef FLOATING_POINT
|
#ifdef FLOATING_POINT
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -269,8 +285,8 @@ typedef double double_spec_t;
|
|||||||
typedef long double ldouble_spec_t;
|
typedef long double ldouble_spec_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *cvt __P((double_spec_t, int, int, char *, int *, int, int *));
|
PRIVATE char *__cvt __P((double_spec_t, int, int, char *, int *, int, int *));
|
||||||
static int exponent __P((char *, int, int));
|
PRIVATE int __exponent __P((char *, int, int));
|
||||||
|
|
||||||
#else /* no FLOATING_POINT */
|
#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 ZEROPAD 0x080 /* zero (as opposed to blank) pad */
|
||||||
#define FPT 0x100 /* Floating point number */
|
#define FPT 0x100 /* Floating point number */
|
||||||
|
|
||||||
|
#ifdef SPLIT_FILE_2
|
||||||
|
|
||||||
#ifdef __ORCAC__
|
#ifdef __ORCAC__
|
||||||
typedef struct vfprintfData_t {
|
typedef struct vfprintfData_t {
|
||||||
char *fmt; /* format string */
|
char *fmt; /* format string */
|
||||||
@ -646,7 +664,7 @@ fp_begin: if (prec == -1)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
flags |= FPT;
|
flags |= FPT;
|
||||||
cp = cvt(_double, prec, flags, &softsign,
|
cp = __cvt(_double, prec, flags, &softsign,
|
||||||
&expt, ch, &ndig);
|
&expt, ch, &ndig);
|
||||||
if (ch == 'g' || ch == 'G') {
|
if (ch == 'g' || ch == 'G') {
|
||||||
if (expt <= -4 || expt > prec)
|
if (expt <= -4 || expt > prec)
|
||||||
@ -656,7 +674,7 @@ fp_begin: if (prec == -1)
|
|||||||
}
|
}
|
||||||
if (ch <= 'e') { /* 'e' or 'E' fmt */
|
if (ch <= 'e') { /* 'e' or 'E' fmt */
|
||||||
--expt;
|
--expt;
|
||||||
expsize = exponent(expstr, expt, ch);
|
expsize = __exponent(expstr, expt, ch);
|
||||||
size = expsize + ndig;
|
size = expsize + ndig;
|
||||||
if (ndig > 1 || flags & ALT)
|
if (ndig > 1 || flags & ALT)
|
||||||
++size;
|
++size;
|
||||||
@ -743,6 +761,28 @@ fp_begin: if (prec == -1)
|
|||||||
size = strlen(cp);
|
size = strlen(cp);
|
||||||
sign = '\0';
|
sign = '\0';
|
||||||
break;
|
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':
|
case 'U':
|
||||||
flags |= LONGINT;
|
flags |= LONGINT;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
@ -960,13 +1000,17 @@ error:
|
|||||||
#undef ox
|
#undef ox
|
||||||
#endif /* __ORCAC__ */
|
#endif /* __ORCAC__ */
|
||||||
|
|
||||||
|
#endif /* SPLIT_FILE_2 */
|
||||||
|
|
||||||
|
#ifdef SPLIT_FILE_1
|
||||||
|
|
||||||
#ifdef FLOATING_POINT
|
#ifdef FLOATING_POINT
|
||||||
|
|
||||||
extern char *__dtoa __P((double, int, int, int *, int *, char **));
|
extern char *__dtoa __P((double, int, int, int *, int *, char **));
|
||||||
|
|
||||||
static char *
|
PRIVATE char *
|
||||||
cvt(double_spec_t value, int ndigits, int flags, char *sign, int *decpt, int ch,
|
__cvt(double_spec_t value, int ndigits, int flags, char *sign, int *decpt,
|
||||||
int *length)
|
int ch, int *length)
|
||||||
{
|
{
|
||||||
int mode, dsgn;
|
int mode, dsgn;
|
||||||
char *digits, *bp, *rve;
|
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);
|
return (digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
PRIVATE int
|
||||||
exponent(char *p0, int exp, int fmtch)
|
__exponent(char *p0, int exp, int fmtch)
|
||||||
{
|
{
|
||||||
register char *p, *t;
|
register char *p, *t;
|
||||||
#ifdef __ORCAC__
|
#ifdef __ORCAC__
|
||||||
@ -1038,3 +1082,4 @@ exponent(char *p0, int exp, int fmtch)
|
|||||||
return (p - p0);
|
return (p - p0);
|
||||||
}
|
}
|
||||||
#endif /* FLOATING_POINT */
|
#endif /* FLOATING_POINT */
|
||||||
|
#endif /* SPLIT_FILE_1 */
|
||||||
|
Loading…
Reference in New Issue
Block a user