| 1 | ?RCS: $Id: d_vprintf.U,v 3.0 1993/08/18 12:07:59 ram Exp $ |
| 2 | ?RCS: |
| 3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi |
| 4 | ?RCS: |
| 5 | ?RCS: You may redistribute only under the terms of the Artistic License, |
| 6 | ?RCS: as specified in the README file that comes with the distribution. |
| 7 | ?RCS: You may reuse parts of this distribution only within the terms of |
| 8 | ?RCS: that same Artistic License; a copy of which may be found at the root |
| 9 | ?RCS: of the source tree for dist 3.0. |
| 10 | ?RCS: |
| 11 | ?RCS: $Log: d_vprintf.U,v $ |
| 12 | ?RCS: Revision 3.0 1993/08/18 12:07:59 ram |
| 13 | ?RCS: Baseline for dist 3.0 netwide release. |
| 14 | ?RCS: |
| 15 | ?MAKE:d_vprintf d_charvspr: Compile Guess cat Csym Setvar run rm_try \ |
| 16 | i_stdlib i_unistd i_stdarg i_varargs |
| 17 | ?MAKE: -pick add $@ %< |
| 18 | ?S:d_vprintf: |
| 19 | ?S: This variable conditionally defines the HAS_VPRINTF symbol, which |
| 20 | ?S: indicates to the C program that the vprintf() routine is available |
| 21 | ?S: to printf with a pointer to an argument list. |
| 22 | ?S:. |
| 23 | ?S:d_charvspr: |
| 24 | ?S: This variable conditionally defines CHARVSPRINTF if this system |
| 25 | ?S: has vsprintf returning type (char*). The trend seems to be to |
| 26 | ?S: declare it as "int vsprintf()". |
| 27 | ?S:. |
| 28 | ?C:HAS_VPRINTF (VPRINTF): |
| 29 | ?C: This symbol, if defined, indicates that the vprintf routine is available |
| 30 | ?C: to printf with a pointer to an argument list. If unavailable, you |
| 31 | ?C: may need to write your own, probably in terms of _doprnt(). |
| 32 | ?C:. |
| 33 | ?C:USE_CHAR_VSPRINTF (CHARVSPRINTF): |
| 34 | ?C: This symbol is defined if this system has vsprintf() returning type |
| 35 | ?C: (char*). The trend seems to be to declare it as "int vsprintf()". It |
| 36 | ?C: is up to the package author to declare vsprintf correctly based on the |
| 37 | ?C: symbol. |
| 38 | ?C:. |
| 39 | ?H:#$d_vprintf HAS_VPRINTF /**/ |
| 40 | ?H:#$d_charvspr USE_CHAR_VSPRINTF /**/ |
| 41 | ?H:. |
| 42 | ?T:val2 |
| 43 | ?F:!try |
| 44 | ?LINT:set d_vprintf d_charvspr |
| 45 | : see if vprintf exists |
| 46 | echo " " |
| 47 | if set vprintf val -f d_vprintf; eval $csym; $val; then |
| 48 | echo 'vprintf() found.' >&4 |
| 49 | val="$define" |
| 50 | $cat >try.c <<EOF |
| 51 | #$i_stdarg I_STDARG /* Only one of these can be defined by i_varhrd */ |
| 52 | #$i_varargs I_VARARGS |
| 53 | |
| 54 | #$i_stdlib I_STDLIB |
| 55 | #$i_unistd I_UNISTD |
| 56 | |
| 57 | #ifdef I_STDARG |
| 58 | # include <stdarg.h> |
| 59 | #else /* I_VARARGS */ |
| 60 | # include <varargs.h> |
| 61 | #endif |
| 62 | |
| 63 | #ifdef I_UNISTD |
| 64 | # include <unistd.h> |
| 65 | #endif |
| 66 | |
| 67 | #ifdef I_STDLIB |
| 68 | # include <stdlib.h> |
| 69 | #endif |
| 70 | |
| 71 | #include <stdio.h> /* vsprintf prototype */ |
| 72 | |
| 73 | #ifdef I_STDARG |
| 74 | void xxx(int n, ...) |
| 75 | { |
| 76 | va_list args; |
| 77 | char buf[10]; |
| 78 | va_start(args, n); |
| 79 | exit((unsigned long)vsprintf(buf,"%s",args) > 10L); |
| 80 | } |
| 81 | int main() { xxx(1, "foo"); } |
| 82 | |
| 83 | #else /* I_VARARGS */ |
| 84 | |
| 85 | xxx(va_alist) |
| 86 | va_dcl |
| 87 | { |
| 88 | va_list args; |
| 89 | char buf[10]; |
| 90 | va_start(args); |
| 91 | exit((unsigned long)vsprintf(buf,"%s",args) > 10L); |
| 92 | } |
| 93 | int main() { xxx("foo"); } |
| 94 | |
| 95 | #endif |
| 96 | |
| 97 | EOF |
| 98 | set try |
| 99 | if eval $compile_ok; then |
| 100 | if $run ./try; then |
| 101 | echo "Your vsprintf() returns (int)." >&4 |
| 102 | val2="$undef" |
| 103 | else |
| 104 | echo "Your vsprintf() returns (char*)." >&4 |
| 105 | val2="$define" |
| 106 | fi |
| 107 | else |
| 108 | echo 'I am unable to compile the vsprintf() test program.' >&4 |
| 109 | # We shouldn't get here. If we do, assume the standard signature, |
| 110 | # not the old BSD one. |
| 111 | echo 'Guessing that vsprintf() returns (int).' >&4 |
| 112 | val2="$undef" |
| 113 | fi |
| 114 | else |
| 115 | echo 'vprintf() NOT found.' >&4 |
| 116 | val="$undef" |
| 117 | val2="$undef" |
| 118 | fi |
| 119 | $rm_try |
| 120 | set d_vprintf |
| 121 | eval $setvar |
| 122 | val=$val2 |
| 123 | set d_charvspr |
| 124 | eval $setvar |
| 125 | |