use stdarg when compiling with ANSI C compiler

This commit is contained in:
ceriel 1995-08-18 07:26:18 +00:00
parent 1aa9149ff9
commit b9a67e72ca
5 changed files with 131 additions and 2 deletions

View file

@ -21,9 +21,14 @@
#include <errno.h>
#include <signal.h>
#include <varargs.h>
#include <stdio.h>
#include <em_path.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
/*
Version producing cc-compatible .o files in one pass.
@ -117,7 +122,11 @@ int c_flag = 0;
int v_flag = 0;
int O_flag = 0;
#if __STDC__
char *mkstr(char *, ...);
#else
char *mkstr();
#endif
char *malloc();
char *alloc();
char *extension();
@ -483,6 +492,32 @@ concat(al1, al2)
}
}
#if __STDC__
/*VARARGS*/
char *
mkstr(char *dst, ...)
{
va_list ap;
va_start(ap, dst);
{
register char *p;
register char *q;
q = dst;
p = va_arg(ap, char *);
while (p) {
while (*q++ = *p++);
q--;
p = va_arg(ap, char *);
}
}
va_end(ap);
return dst;
}
#else
/*VARARGS*/
char *
mkstr(va_alist)
@ -509,6 +544,7 @@ mkstr(va_alist)
return dst;
}
#endif
basename(str, dst)
char *str;

View file

@ -1,6 +1,11 @@
#include <ctype.h>
#include <system.h>
#if __STDC__
#include <stdarg.h>
extern out(char *, ...);
#else
#include <varargs.h>
#endif
#define CODE_EXPANDER
#include "em.h"
@ -99,6 +104,17 @@ int seg;
}
}
#if __STDC__
/*VARARGS*/
out(char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
doprnt( outfile, fmt, pvar);
va_end(pvar);
}
#else
/*VARARGS*/
out(va_alist)
va_dcl
@ -111,6 +127,7 @@ va_dcl
doprnt( outfile, fmt, pvar);
va_end(pvar);
}
#endif
char *suffix( str, suf)
char *str, *suf;

View file

@ -1,4 +1,10 @@
#include "varargs.h"
#if __STDC__
#include <stdarg.h>
extern out(char *, ...);
extern error(char *, ...);
#else
#include <varargs.h>
#endif
#include "decl.h"
/* All the functions in this file will be called by the parser.
@ -208,6 +214,32 @@ operand_clean()
n_ops = 0;
}
#if __STDC__
/*VARARGS*/
out(char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
doprnt( outfile, fmt, pvar);
va_end(pvar);
}
extern int nerrors;
/*VARARGS*/
error(char *fmt, ...)
{
va_list pvar;
nerrors++;
va_start(pvar, fmt);
fprint( STDERR, "!! ERROR : ");
doprnt( STDERR, fmt, pvar);
fprint( STDERR, " !!\n");
va_end(pvar);
}
#else
/*VARARGS*/
out(va_alist)
va_dcl
@ -238,6 +270,7 @@ va_dcl
fprint( STDERR, " !!\n");
va_end(pvar);
}
#endif
inc_ops()
{

View file

@ -1,7 +1,12 @@
#include <ctype.h>
#include <system.h>
#include <stdio.h>
#if __STDC__
#include <stdarg.h>
extern error(char *, ...);
#else
#include <varargs.h>
#endif
#include "as.h"
#include "const.h"
@ -224,6 +229,22 @@ char *mnem;
/*** Error ****************************************************************/
#if __STDC__
/*VARARGS*/
error(char *fmt, ...)
{
va_list args;
extern int yylineno;
extern int nerrors;
va_start(args, fmt);
fprint( STDERR, "ERROR in line %d : ", yylineno);
doprnt( STDERR, fmt, args);
fprint( STDERR, "\n");
va_end(args);
nerrors++;
}
#else
/*VARARGS*/
error(va_alist)
va_dcl
@ -241,3 +262,4 @@ error(va_alist)
va_end(args);
nerrors++;
}
#endif

View file

@ -4,7 +4,11 @@
#include "header.h"
#include "back.h"
#include "mach.h"
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
/* Mysprint() stores the string directly in the string_arae. This saves
* a copy action. It is assumed that the strings stored in the string-table
@ -13,6 +17,22 @@
#define MAXSTRLEN 1024
#if __STDC__
/*VARARGS*/
static int mysprint(char *fmt, ...)
{
va_list args;
int retval;
va_start(args, fmt);
while (string + MAXSTRLEN - string_area > size_string)
mem_string();
retval = _format(string, fmt, args);
string[retval] = '\0';
va_end(args);
return retval;
}
#else
/*VARARGS*/
static int mysprint(va_alist)
va_dcl
@ -30,6 +50,7 @@ static int mysprint(va_alist)
va_end(args);
return retval;
}
#endif
/* The extnd_*()s make a name unique. The resulting string is directly stored
* in the symbol_table (by mysprint()). Later additional fields in the