hamilton (09/14/82)
#R:sri-unix:-298900:uicsovax:5500025:000:604 uicsovax!hamilton Sep 14 14:06:00 1982 i used to use %r printf format too, but after several system changes, with attendant re-implementations of %r, and accidental recompilations using the standard library, i have settled on using _doprnt() directly. the example given by sri-unix!wales: oops (args) char *args; { fprintf (stderr, "ERROR: %r", &args); exit (1); } becomes: oops (fmt, args) char *args; { fprintf (stderr, "ERROR: "); _doprnt (fmt, &args, stderr); exit (1); } with a minimum of extra work, you can stay portable... wayne hamilton ({decvax,ucbvax,harpo}!pur-ee!uiucdcs!uicsovax!hamilton)
nrh (09/18/82)
#R:sri-unix:-298900:esquire:900002:000:534 esquire!nrh Sep 17 23:11:00 1982 ***** esquire:net.unix-wizar / uicsovax!hamilton / 4:43 am Sep 17, 1982 Just a note about the philosophy of using _doprnt instead of "%r" for portability: I think you're being hard on the authors of future standard I/O libraries in using _doprnt, a function that is nowhere documented, and which, by its name, seems meant to be used by routines internal to standard I/O only. I've no better solution, unless you count an ongoing battle with successive implementations of printf(), but feel that _doprnt should be out of sight.
trt (09/18/82)
Due to the lack of a clearly portable way to provide routines like: warn("Cannot open %s", filename); Steve Daniel (duke!mcnc!swd) used the following for "A news": char bfr[BIGENOUGH]; /* handy global buffer */ ... sprintf(bfr, "Cannot open %s", filename); warn(bfr); This way of handling variable numbers of arguments is portable, fairly easy to use, and can be used to invoke *any* routine, not just those written to handle printf-style format: sprintf(bfr, "%s/%s", dir, name); fp = fopen(bfr, "r"); If sprintf(III) returned a pointer to the result string (which alas is not true of some versions) one could just type: fp = fopen(sprintf(bfr, "%s/%s", dir, name), "r"); Tom Truscott (duke!trt)