Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site washu.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!clyde!ihnp4!mtplx1!washu!eric From: eric@washu.UUCP (Eric Kiebler) Newsgroups: net.lang.c Subject: Re: %r, and why it disappeared (a theory) Message-ID: <169@washu.UUCP> Date: Sun, 16-Oct-83 23:26:05 EDT Article-I.D.: washu.169 Posted: Sun Oct 16 23:26:05 1983 Date-Received: Tue, 18-Oct-83 03:51:43 EDT References: <267@abnjh.UUCP> Organization: Washington U. CSL, St. Louis Lines: 94 BEWARE the _doprnt code, my son! The bits that twitch; the types that clash! Use the portable varargs stuff, Avoid the _doprnt's teeth that gnash! As Mark Horton pointed out, the _doprnt() routine is *not* portable and should not be used for that reason. Yes, of course, the code will *never* leave your machine, but... Just for you "my code stays at home and watches TV" folks out there, here is a little collection of error functions which I used in code that wasn't supposed to leave my machine either... /* Error Handling Functions Wash. U. Computer Systems Lab E. Kiebler Sept, 1982 Distribution allowed if and only if this entire comment is included */ #include #include #include extern char *ProgramName; extern int DebugFlag; extern FILE *stdlog; warning(fmt,args) char *fmt; { fprintf(stderr,"%s: (warning) ",ProgramName); _doprnt(fmt, &args, stderr); /* magic */ return(ferror(stderr)? EOF : 0); } error(fmt,args) char *fmt; { fprintf(stderr,"%s: (error) ",ProgramName); _doprnt(fmt, &args, stderr); /* voodoo */ return(ferror(stderr)? EOF : 0); } fatal(fmt,args) char *fmt; { fprintf(stderr,"%s: (fatal) ",ProgramName); _doprnt(fmt, &args, stderr); /* read the manuals */ exit(0); } debug(fmt,args) char *fmt; { if(DebugFlag){ fprintf(stderr,"%s: (debug) ",ProgramName); _doprnt(fmt, &args, stderr); /* wonderful! */ fprintf(stderr,"\n"); } } log(fmt,args) char *fmt; { struct tm *tp; extern struct tm *localtime(); time_t clock; time(&clock); tp = localtime(&clock); fprintf(stdlog, "(%d/%d-%d:%d) ", tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min); _doprnt(fmt,&args,stdlog); fprintf(stdlog,"\n"); } This code was written by myself and, as far as I know, does not use any proprietary (sp?) code (unless telling people that _doprnt() exists is proprietary, in which case eat the code and call your lawyer). C A V E A T E M P T O R ========================== -- eric ..!ihnp4!washu!eric