use stdarg when compiling with ANSI C compiler

This commit is contained in:
ceriel 1995-08-17 14:36:05 +00:00
parent acdb874527
commit c3855160fb
6 changed files with 145 additions and 3 deletions

View file

@ -31,9 +31,13 @@ Something wrong here! Only one of FM2, FPC, or FCC must be defined
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <varargs.h>
#include <stdio.h> #include <stdio.h>
#include <em_path.h> #include <em_path.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
/* /*
Version producing ACK .o files in one pass. Version producing ACK .o files in one pass.
@ -178,7 +182,11 @@ int v_flag = 0;
int O_flag = 0; int O_flag = 0;
int ansi_c = 0; int ansi_c = 0;
#if __STDC__
char *mkstr(char *, ...);
#else
char *mkstr(); char *mkstr();
#endif
char *malloc(); char *malloc();
char *alloc(); char *alloc();
char *extension(); char *extension();
@ -669,7 +677,32 @@ concat(al1, al2)
*p++ = *q++; *p++ = *q++;
} }
} }
#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*/ /*VARARGS*/
char * char *
mkstr(va_alist) mkstr(va_alist)
@ -696,7 +729,7 @@ mkstr(va_alist)
return dst; return dst;
} }
#endif
basename(str, dst) basename(str, dst)
char *str; char *str;
register char *dst; register char *dst;

View file

@ -1,8 +1,26 @@
#include <system.h> #include <system.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h> #include <varargs.h>
#endif
extern int nerrors; extern int nerrors;
#if __STDC__
/*VARARGS*/
error(char *fmt, ...)
{
va_list pvar;
va_start(pvar, fmt);
fprint( STDERR, "!! ERROR : ");
doprnt( STDERR, fmt, pvar);
fprint( STDERR, " !!\n");
va_end(pvar);
nerrors++;
}
#else
/*VARARGS*/ /*VARARGS*/
error(va_alist) error(va_alist)
va_dcl va_dcl
@ -18,3 +36,4 @@ va_dcl
va_end(pvar); va_end(pvar);
nerrors++; nerrors++;
} }
#endif

View file

@ -1,10 +1,14 @@
/* $Id$ */ /* $Id$ */
#include <stdio.h> #include <stdio.h>
#include <varargs.h>
#include <assert.h> #include <assert.h>
#include <alloc.h> #include <alloc.h>
#include <out.h> #include <out.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "operator.h" #include "operator.h"
#include "position.h" #include "position.h"
@ -24,6 +28,20 @@ t_lineno listline;
extern char *strrindex(); extern char *strrindex();
extern int interrupted; extern int interrupted;
#if __STDC__
/*VARARGS1*/
p_tree
mknode(int op, ...)
{
va_list ap;
register p_tree p = new_tree();
va_start(ap, op);
{
register int i, na;
p->t_oper = op;
#else
/*VARARGS1*/ /*VARARGS1*/
p_tree p_tree
mknode(va_alist) mknode(va_alist)
@ -37,6 +55,7 @@ mknode(va_alist)
register int i, na; register int i, na;
p->t_oper = va_arg(ap, int); p->t_oper = va_arg(ap, int);
#endif
switch(p->t_oper) { switch(p->t_oper) {
case OP_NAME: case OP_NAME:
case OP_HELP: case OP_HELP:

View file

@ -30,4 +30,8 @@ typedef struct tree {
/* ALLOCDEF "tree" 100 */ /* ALLOCDEF "tree" 100 */
#if __STDC__
extern p_tree mknode(int, ...);
#else
extern p_tree mknode(); extern p_tree mknode();
#endif

View file

@ -5,7 +5,12 @@
/* $Id$ */ /* $Id$ */
#include <stdio.h> #include <stdio.h>
#if __STDC__
#include <stdarg.h>
extern fatal(char *, ...);
#else
#include <varargs.h> #include <varargs.h>
#endif
#include "logging.h" #include "logging.h"
#include "global.h" #include "global.h"
@ -105,6 +110,34 @@ init_ofiles(firsttime)
#endif /* LOGGING */ #endif /* LOGGING */
} }
#if __STDC__
/*VARARGS0*/
fatal(char *fmt, ...)
{
va_list ap;
fprintf(stderr, "%s: ", prog_name);
va_start(ap, fmt);
{
do_fatal(stderr, fmt, ap);
}
va_end(ap);
if (mess_fp) {
va_start(ap, fmt);
{
do_fatal(mess_fp, fmt, ap);
}
va_end(ap);
}
if (running)
core_dump();
close_down(1);
}
#else
/*VARARGS0*/ /*VARARGS0*/
fatal(va_alist) fatal(va_alist)
va_dcl va_dcl
@ -134,6 +167,7 @@ fatal(va_alist)
close_down(1); close_down(1);
} }
#endif
close_down(rc) close_down(rc)
int rc; int rc;
@ -163,6 +197,23 @@ PRIVATE do_fatal(fp, fmt, ap)
fputc('\n', fp); fputc('\n', fp);
} }
#if __STDC__
/*VARARGS0*/
message(char *fmt, ...)
{
va_list ap;
fprintf(mess_fp, "(Message): ");
va_start(ap, fmt);
{
vfprintf(mess_fp, fmt, ap);
}
va_end(ap);
fprintf(mess_fp, " at %s\n", position());
}
#else
/*VARARGS0*/ /*VARARGS0*/
message(va_alist) message(va_alist)
va_dcl va_dcl
@ -180,6 +231,7 @@ message(va_alist)
fprintf(mess_fp, " at %s\n", position()); fprintf(mess_fp, " at %s\n", position());
} }
#endif
char *position() /* transient */ char *position() /* transient */
{ {

View file

@ -5,7 +5,11 @@
/* $Id$ */ /* $Id$ */
#include <stdio.h> #include <stdio.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h> #include <varargs.h>
#endif
#include "logging.h" #include "logging.h"
#include "global.h" #include "global.h"
@ -239,6 +243,16 @@ int check_log(mark)
return ((mark[2] - '0') <= log_level[mark[1]]); return ((mark[2] - '0') <= log_level[mark[1]]);
} }
#if __STDC__
/*VARARGS*/
do_log(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
{
#else
/*VARARGS*/ /*VARARGS*/
do_log(va_alist) do_log(va_alist)
va_dcl va_dcl
@ -249,6 +263,7 @@ do_log(va_alist)
{ {
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
#endif
if (!check_log(fmt)) if (!check_log(fmt))
return; return;