home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / misc / hwgrcs / src / rcs.rcsfiles / conf.sh,v < prev    next >
Encoding:
Text File  |  1995-06-25  |  56.3 KB  |  2,605 lines

  1. head    5.14;
  2. branch    5.14.1;
  3. access;
  4. symbols
  5.     HWGRCSP12F:5.14.1.2
  6.     HWGRCSP11F:5.14.1.2
  7.     HWGRCSP10F:5.14.1.2
  8.     HWGRCSP9:5.14.1.2
  9.     HWGRCSP8F:5.14.1.2
  10.     HWGRCSP7F:5.14.1.2
  11.     HWGRCSP6F:5.14.1.2
  12.     HWGRCSP5F:5.14.1.1
  13.     HWGRCSp4:5.14.1.1
  14.     HWGRCSp3:5.14.1
  15.     HWGRCS_Fish:5.14.1
  16.     HWGRCS:5.14.1;
  17. locks; strict;
  18. comment    @# @;
  19.  
  20.  
  21. 5.14
  22. date    91.11.20.18.21.10;    author eggert;    state Exp;
  23. branches
  24.     5.14.1.1;
  25. next    ;
  26.  
  27. 5.14.1.1
  28. date    93.01.18.14.39.42;    author heinz;    state Exp;
  29. branches;
  30. next    5.14.1.2;
  31.  
  32. 5.14.1.2
  33. date    93.12.20.18.48.30;    author heinz;    state Exp;
  34. branches;
  35. next    ;
  36.  
  37.  
  38. desc
  39. @Checked in with -k 16.jan.93 HWG
  40. @
  41.  
  42.  
  43. 5.14
  44. log
  45. @checked in with -k by heinz at 1993/01/17 01:55:16
  46. @
  47. text
  48. @#!/bin/sh
  49. # Output RCS compile-time configuration.
  50. Id='$Id: conf.sh,v 5.14 1991/11/20 18:21:10 eggert Exp $'
  51. #    Copyright 1990, 1991 by Paul Eggert
  52. #    Distributed under license by the Free Software Foundation, Inc.
  53.  
  54. # This file is part of RCS.
  55. #
  56. # RCS is free software; you can redistribute it and/or modify
  57. # it under the terms of the GNU General Public License as published by
  58. # the Free Software Foundation; either version 2, or (at your option)
  59. # any later version.
  60. #
  61. # RCS is distributed in the hope that it will be useful,
  62. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  63. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  64. # GNU General Public License for more details.
  65. #
  66. # You should have received a copy of the GNU General Public License
  67. # along with RCS; see the file COPYING.  If not, write to
  68. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  69. #
  70. # Report problems and direct all questions to:
  71. #
  72. #     rcs-bugs@@cs.purdue.edu
  73.  
  74.  
  75. # Standard output should already be directed to "a.h";
  76. # later parts of this procedure need it.
  77. # Standard error can be ignored if a.h is OK,
  78. # and can be inspected for clues otherwise.
  79.  
  80. # The Makefile overrides the following defaults.
  81. : ${CC=cc}
  82. : ${CFLAGS=-O}
  83. : ${COMPAT2=0}
  84. : ${DIFF3=${RCSPREFIX}diff3}
  85. : ${DIFF3_BIN=1}
  86. : ${DIFF=${RCSPREFIX}diff}
  87. : ${DIFF_FLAGS=-an}
  88. : ${DIFF_L=1}
  89. : ${DIFF_SUCCESS=0} ${DIFF_FAILURE=1} ${DIFF_TROUBLE=2}
  90. : ${ED=/bin/ed}
  91. : ${RCSPREFIX=/usr/local/bin/}
  92. : ${SENDMAIL='"/usr/lib/sendmail"'}
  93. # : ${LDFLAGS=} ${LDLIBS=} tickles old shell bug
  94.  
  95. C="$CC $CFLAGS"
  96. CL="$CC $CFLAGS $LDFLAGS"
  97. L=$LDLIBS
  98. RM='rm -f a.out'
  99.  
  100. cat <<EOF
  101. /* RCS compile-time configuration */
  102.  
  103.     /* $Id */
  104.  
  105. /*
  106.  * This file is generated automatically.
  107.  * If you edit it by hand your changes may be lost.
  108.  * Instead, please try to fix conf.sh,
  109.  * and send your fixes to rcs-bugs@@cs.purdue.edu.
  110.  */
  111.  
  112. EOF
  113.  
  114. : exitmain
  115. cat >a.c <<EOF
  116. #include "a.h"
  117. int main(argc,argv) int argc; char **argv; { return argc-1; }
  118. EOF
  119. $RM && $CL a.c $L >&2 || exit
  120. e='exit(n), 3 /* lint fodder */'
  121. if ./a.out -
  122. then :
  123. elif ./a.out
  124. then e=n
  125. fi
  126. echo "#define exitmain(n) return $e /* how to exit from main() */"
  127.  
  128. : _POSIX_SOURCE
  129. cat >a.c <<'EOF'
  130. #include "a.h"
  131. #include <stdio.h>
  132. int main() { exitmain(fileno(stdout) < 0); }
  133. EOF
  134. a='/* ' z='*/ '
  135. $RM || exit
  136. if ($CL a.c $L && ./a.out) >&2
  137. then :
  138. elif $RM || exit; ($CL -D_POSIX_SOURCE a.c $L && ./a.out) >&2
  139. then a= z=
  140. fi
  141. cat <<EOF
  142. $a#define _POSIX_SOURCE $z/* Define this if Posix + strict Standard C.  */
  143.  
  144. #include <errno.h>
  145. #include <stdio.h>
  146. #include <time.h>
  147. EOF
  148.  
  149. cat <<'EOF'
  150.  
  151. /* Comment out #include lines below that do not work.  */
  152. EOF
  153.  
  154. # Run `$CS a.c $LS' instead of `$CL a.c $L' for compile-time checking only.
  155. # This speeds up the configuration process.
  156. if $C -S a.c >&2
  157. then CS="$C -S" LS=    # Generate assembly language output.
  158. elif $C -c a.c >&2
  159. then CS="$C -c" LS=    # Generate object code.
  160. else CS=$CL LS=$L    # Generate an executable.
  161. fi
  162.  
  163. # standard include files
  164. # sys/types.h and sys/stat.h must come first because others depend on them.
  165. has_signal=1
  166. for h in \
  167.     sys/types sys/stat \
  168.     dirent fcntl limits pwd signal stdlib string sys/mman sys/wait unistd utime vfork
  169. do
  170.     i="#include <$h.h>"
  171.     : $i
  172.     cat >a.c <<EOF
  173. #include "a.h"
  174. $i
  175. int main(){ exitmain(0); }
  176. EOF
  177.     $RM || exit
  178.     ($CL a.c $L && ./a.out) >&2 || {
  179.         case $h in
  180.         string)
  181.             i='#include <strings.h>';;
  182.         *)
  183.             i="/* $i */"
  184.         esac
  185.         case $h in
  186.         signal) has_signal=0
  187.         esac
  188.     }
  189.     echo "$i"
  190. done
  191.  
  192. cat <<'EOF'
  193.  
  194. /* Define the following symbols to be 1 or 0.  */
  195. EOF
  196.  
  197. # has_sys_*_h
  198. for H in dir param
  199. do
  200.     : has_sys_${H}_h
  201.     cat >a.c <<EOF
  202. #include "a.h"
  203. #include <sys/$H.h>
  204. int main() { exitmain(0); }
  205. EOF
  206.     $RM || exit
  207.     if ($CL a.c $L && ./a.out) >&2
  208.     then h=1
  209.     else h=0
  210.     fi
  211.     echo "#define has_sys_${H}_h $h /* Does #include <sys/$H.h> work?  */"
  212. done
  213.  
  214.  
  215. # We must do NAME_MAX and has_readlink next, because they might generate
  216. # #include directives that affect later definitions.
  217.  
  218. : NAME_MAX
  219. cat >a.c <<'EOF'
  220. #include "a.h"
  221. char b[NAME_MAX + 2];
  222. main()
  223. {
  224. #if !defined(NAME_MAX)
  225.     exitmain(1);
  226. #else
  227.     int i;
  228.     b[0] = 'a'; b[1] = '.';
  229.     for (i = 2;  i < NAME_MAX;  i++)
  230.         b[i] = 'a';
  231.     b[i] = 'b';
  232.     exitmain(creat(b, 0) < 0);
  233. #endif
  234. }
  235. EOF
  236. $RM a.*ab || exit
  237. if $CL a.c $L >&2 && ./a.out && test -f a.*ab
  238. then a= z=
  239. else a='/* ' z='*/ '
  240. fi
  241. rm -f a.*ab || exit
  242.  
  243. : has_readlink
  244. cat >a.c <<'EOF'
  245. #include "a.h"
  246. char b[7];
  247. int main()
  248. {
  249.     exitmain(readlink("a.sym2",b,7) != 6  ||  strcmp(b, "a.sym1") != 0);
  250. }
  251. EOF
  252. $RM a.sym* || exit
  253. if (ln -s a.sym1 a.sym2 && $CL a.c $L && ./a.out) >&2
  254. then h=1
  255. else h=0
  256. fi
  257. cat <<EOF
  258. #define has_readlink $h /* Does readlink() work?  */
  259.  
  260. $a#undef NAME_MAX $z/* Uncomment this if NAME_MAX is broken.  */
  261.  
  262. #if !defined(NAME_MAX) && !defined(_POSIX_NAME_MAX)
  263. #    if has_sys_dir_h
  264. #        include <sys/dir.h>
  265. #    endif
  266. #    ifndef NAME_MAX
  267. #        ifndef MAXNAMLEN
  268. #            define MAXNAMLEN 14
  269. #        endif
  270. #        define NAME_MAX MAXNAMLEN
  271. #    endif
  272. #endif
  273. #if !defined(PATH_MAX) && !defined(_POSIX_PATH_MAX)
  274. #    if has_sys_param_h
  275. #        include <sys/param.h>
  276. #        define included_sys_param_h 1
  277. #    endif
  278. #    ifndef PATH_MAX
  279. #        ifndef MAXPATHLEN
  280. #            define MAXPATHLEN 1024
  281. #        endif
  282. #        define PATH_MAX (MAXPATHLEN-1)
  283. #    endif
  284. #endif
  285. #if has_readlink && !defined(MAXSYMLINKS)
  286. #    if has_sys_param_h && !included_sys_param_h
  287. #        include <sys/param.h>
  288. #    endif
  289. #    ifndef MAXSYMLINKS
  290. #        define MAXSYMLINKS 20 /* BSD; not standard yet */
  291. #    endif
  292. #endif
  293. EOF
  294.  
  295. cat <<'EOF'
  296.  
  297. /* Comment out the keyword definitions below if the keywords work.  */
  298. EOF
  299.  
  300. : const, volatile
  301. for i in const volatile
  302. do
  303.     cat >a.c <<EOF
  304. #    include "a.h"
  305.     enum Boolean { false, true };
  306.     static enum Boolean $i zero;
  307.     static enum Boolean $i * $i azero = &zero;
  308.     static enum Boolean $i * $i * $i aazero = &azero;
  309.     int main() { exitmain(!!**aazero); }
  310. EOF
  311.     a= z=
  312.     if $CS a.c $LS >&2
  313.     then
  314.         cat >a.c <<EOF
  315.             typedef unsigned char $i *Iptr_type;
  316.             struct { Iptr_type lim; } s, *f = &s;
  317.             int main() {
  318.                 Iptr_type lim;
  319.                 lim = f->lim;
  320.                 return !!lim;
  321.             }
  322. EOF
  323.         if $CS a.c $LS >&2
  324.         then a='/* ' z=' */'
  325.         fi
  326.     fi
  327.     echo "$a#define $i$z"
  328. done
  329.  
  330. # *_t
  331. cat <<'EOF'
  332.  
  333. /* Comment out the typedefs below if the types are already declared.  */
  334. /* Fix any uncommented typedefs that are wrong.  */
  335. EOF
  336. cat >a.c <<'EOF'
  337. #include "a.h"
  338. t x;
  339. int main() { exitmain(0); }
  340. EOF
  341. for t in mode_t pid_t sig_atomic_t size_t ssize_t time_t uid_t
  342. do
  343.     : $t
  344.     case $t in
  345.     size_t) i=unsigned;;
  346.     time_t) i=long;;
  347.     *) i=int;;
  348.     esac
  349.     if $CS -Dt=$t a.c $LS >&2
  350.     then a='/* ' z=' */'
  351.     else a= z=
  352.     fi
  353.     echo "${a}typedef $i $t;$z"
  354. done
  355.  
  356. : has_prototypes, has_stdarg, has_varargs, va_start_args
  357. cat >a.ha <<'EOF'
  358. #if has_prototypes
  359. #    define P(params) params
  360. #else
  361. #    define P(params) ()
  362. #endif
  363. #if has_stdarg
  364. #    include <stdarg.h>
  365. #else
  366. #    if has_varargs
  367. #        include <varargs.h>
  368. #    else
  369.         typedef char *va_list;
  370. #        define va_dcl int va_alist;
  371. #        define va_start(ap) ((ap) = (va_list)&va_alist)
  372. #        define va_arg(ap,t) (((t*) ((ap)+=sizeof(t)))  [-1])
  373. #        define va_end(ap)
  374. #    endif
  375. #endif
  376. #if va_start_args == 2
  377. #    define vararg_start va_start
  378. #else
  379. #    define vararg_start(ap,p) va_start(ap)
  380. #endif
  381. EOF
  382. cat >a.c <<'EOF'
  383. #include "a.h"
  384. #include "a.ha"
  385. #if has_prototypes
  386. char *f(char **p, ...)
  387. #else
  388. char *f(p, va_alist) char **p; va_dcl
  389. #endif
  390. {
  391.     char *s;
  392.     va_list v;
  393.     vararg_start(v,p);
  394.     s = p[va_arg(v,int)];
  395.     va_end(v);
  396.     return s;
  397. }
  398. int main P((int, char**));
  399. int main(argc, argv) int argc; char **argv; {
  400.     exitmain(f(argv,0) != argv[0]  ||  f(argv,1) != argv[1]);
  401. }
  402. EOF
  403. for has_prototypes in 1 0
  404. do
  405.     for has_stdarg in 1 v 0
  406.     do
  407.         case $has_stdarg in
  408.         v) has_varargs=1 has_stdarg=0;;
  409.         *) has_varargs=0
  410.         esac
  411.         case $has_stdarg in
  412.         0) as='1 2';;
  413.         1) as='2 1'
  414.         esac
  415.         for va_start_args in $as
  416.         do
  417.             $RM || exit
  418.             $CL \
  419.                 -Dhas_prototypes=$has_prototypes \
  420.                 -Dhas_stdarg=$has_stdarg \
  421.                 -Dhas_varargs=$has_varargs \
  422.                 -Dva_start_args=$va_start_args \
  423.                 a.c $L >&2 && ./a.out && break
  424.         done && break
  425.     done && break
  426. done || {
  427.     echo >&2 "cannot deduce has_prototypes, has_stdarg, va_start_args"
  428.     exit 1
  429. }
  430. cat - a.ha <<EOF
  431.  
  432. /* Define the following symbols to be 1 or 0.  */
  433. #define has_prototypes $has_prototypes /* Do function prototypes work?  */
  434. #define has_stdarg $has_stdarg /* Does <stdarg.h> work?  */
  435. #define has_varargs $has_varargs /* Does <varargs.h> work?  */
  436. #define va_start_args $va_start_args /* How many args does va_start() take?  */
  437. EOF
  438.  
  439. : text_equals_binary_stdio, FOPEN_...
  440. cat >a.c <<'EOF'
  441. #include "a.h"
  442.     int
  443. copyto(filename, mode)
  444.     char const *filename, *mode;
  445. {
  446.     int c;
  447.     FILE *f, *g;
  448.     if (!(f = fopen("a.out", "rb")) || !(g = fopen(filename, mode)))
  449.         return 1;
  450.     while (c=getc(f), !feof(f))
  451.         if (ferror(f)  ||  putc(c,g)<0 && ferror(g))
  452.             return 1;
  453.     return fclose(f)!=0 || fclose(g)!=0;
  454. }
  455. int main() { exitmain(copyto("a.d", "w+b") || copyto("a.e", "w+")); }
  456. EOF
  457. e=1
  458. $RM a.d a.e || exit
  459. $CL a.c $L >&2 && ./a.out && cmp a.out a.d && {
  460.     cmp a.out a.e || e=0
  461. }
  462. cat <<EOF
  463.  
  464. #define text_equals_binary_stdio $e /* Does stdio treat text like binary?  */
  465. #define text_work_stdio 0 /* Text i/o for working file, binary for RCS file?  */
  466. #if text_equals_binary_stdio
  467.     /* Text and binary i/o behave the same, or binary i/o does not work.  */
  468. #    define FOPEN_R "r"
  469. #    define FOPEN_W "w"
  470. #    define FOPEN_WPLUS "w+"
  471. #else
  472.     /* Text and binary i/o behave differently.  */
  473.     /* This is incompatible with Posix and Unix.  */
  474. #    define FOPEN_R "rb"
  475. #    define FOPEN_W "wb"
  476. #    define FOPEN_WPLUS "w+b"
  477. #endif
  478. #if text_work_stdio
  479. #    define FOPEN_R_WORK "r"
  480. #    define FOPEN_W_WORK "w"
  481. #    define FOPEN_WPLUS_WORK "w+"
  482. #else
  483. #    define FOPEN_R_WORK FOPEN_R
  484. #    define FOPEN_W_WORK FOPEN_W
  485. #    define FOPEN_WPLUS_WORK FOPEN_WPLUS
  486. #endif
  487.  
  488. /* Define or comment out the following symbols as needed.  */
  489. EOF
  490.  
  491. : bad_fopen_wplus
  492. cat >a.c <<'EOF'
  493. #include "a.h"
  494. int main() { exitmain(!fopen("a.d",FOPEN_WPLUS)); }
  495. EOF
  496. $RM || exit
  497. if echo nonempty >a.d && $CL a.c $L >&2 && ./a.out && test ! -s a.d
  498. then b=0
  499. else b=1
  500. fi
  501. echo "#define bad_fopen_wplus $b /* Does fopen(f,FOPEN_WPLUS) fail to truncate f?  */"
  502.  
  503. : getlogin_is_secure
  504. echo "#define getlogin_is_secure 0 /* Is getlogin() secure?  Usually it's not.  */"
  505.  
  506. : has_dirent
  507. cat >a.c <<'EOF'
  508. #include "a.h"
  509. int main() {
  510.     DIR *d = opendir(".");
  511.     struct dirent *e;
  512.     while ((e = readdir(d)))
  513.         if (strcmp(e->d_name, "a.c") == 0  &&  closedir(d) == 0)
  514.             exitmain(0);
  515.     exitmain(1);
  516. }
  517. EOF
  518. $RM || exit
  519. if $CL a.c $L >&2 && ./a.out
  520. then h=1
  521. else h=0
  522. fi
  523. echo "#define has_dirent $h /* Do opendir(), readdir(), closedir() work?  */"
  524.  
  525. : has_fchmod
  526. cat >a.c <<'EOF'
  527. #include "a.h"
  528. int main() { exitmain(fchmod(fileno(stdin),0) != 0); }
  529. EOF
  530. $RM || exit
  531. if $CL a.c $L >&2 && ./a.out <a.c && test ! -r a.c
  532. then h=1
  533. else h=0
  534. fi
  535. echo "#define has_fchmod $h /* Does fchmod() work?  */"
  536. rm -f a.c || exit
  537.  
  538. : has_fputs
  539. cat >a.c <<'EOF'
  540. #include "a.h"
  541. int main() { exitmain(fputs("Hello\"\nworld", stdout) != 12); }
  542. EOF
  543. Hello='Hello"
  544. world'
  545. $RM || exit
  546. if $CL a.c $L >&2 && ./a.out >/dev/null && x=`./a.out` && test " $x" = " $Hello"
  547. then h=1
  548. else h=0
  549. fi
  550. echo "#define has_fputs $h /* Does fputs() work?  */"
  551.  
  552. : has_ftruncate
  553. cat >a.c <<'EOF'
  554. #include "a.h"
  555. int main(argc, argv) int argc; char **argv; {
  556.     int f = creat(argv[1], 0);
  557.     if (f<0 || write(f,"abc",3)!=3 || ftruncate(f,(off_t)0)!=0 || close(f)!=0)
  558.             exitmain(1);
  559.     exitmain(0);
  560. }
  561. EOF
  562. $RM || exit
  563. if $CL a.c $L >&2
  564. then
  565.     h=1
  566.     # Check out /tmp too; it's buggy on some hosts.
  567.     for d in . /tmp
  568.     do
  569.         if test -d $d
  570.         then
  571.             f=$d/a.d
  572.             rm -f $f || exit
  573.             ./a.out $f && test ! -s $f && test -f $f  ||  h=0
  574.             rm -f $f || exit
  575.         fi
  576.     done
  577. else h=0
  578. fi
  579. echo "#define has_ftruncate $h /* Does ftruncate() work?  */"
  580.  
  581. : has_getuid
  582. cat >a.c <<'EOF'
  583. #include "a.h"
  584. #ifndef getuid
  585.     uid_t getuid();
  586. #endif
  587. int main() { exitmain(getuid()!=getuid()); }
  588. EOF
  589. $RM || exit
  590. if ($CL a.c $L && ./a.out) >&2
  591. then has_getuid=1
  592. else has_getuid=0
  593. fi
  594. echo "#define has_getuid $has_getuid /* Does getuid() work?  */"
  595.  
  596. : has_getpwuid
  597. case $has_getuid in
  598. 0)
  599.     a='/* ' z='*/ ' h=?;;
  600. *)
  601.     a= z=
  602.     cat >a.c <<'EOF'
  603. #include "a.h"
  604. int main() { exitmain(!getpwuid(0)); }
  605. EOF
  606.     $RM || exit
  607.     if ($CL a.c $L && ./a.out) >&2
  608.     then h=1
  609.     else h=0
  610.     fi
  611. esac
  612. echo "$a#define has_getpwuid $h $z/* Does getpwuid() work?  */"
  613.  
  614. : has_link
  615. cat >a.c <<'EOF'
  616. #include "a.h"
  617. int main() { exitmain(link("a.c","a.d") != 0); }
  618. EOF
  619. $RM a.d || exit
  620. if ($CL a.c $L && ./a.out && cmp a.c a.d) >&2
  621. then h=1
  622. else h=0
  623. fi
  624. rm -f a.d || exit
  625. echo "#define has_link $h /* Does link() work?  */"
  626.  
  627. : has_memcmp
  628. cat >a.c <<'EOF'
  629. #include "a.h"
  630. int main() { exitmain(memcmp("beautiful","beautiful",10) != 0); }
  631. EOF
  632. $RM || exit
  633. if ($CL a.c $L && ./a.out) >&2
  634. then h=1
  635. else h=0
  636. fi
  637. echo "#define has_memcmp $h /* Does memcmp() work?  */"
  638.  
  639. : has_memcpy
  640. cat >a.c <<'EOF'
  641. #include "a.h"
  642. char a[3];
  643. int main() {
  644.     memcpy(a,"xy",3);
  645.     exitmain(strcmp(a,"xy")!=0);
  646. }
  647. EOF
  648. $RM || exit
  649. if ($CL a.c $L && ./a.out) >&2
  650. then h=1
  651. else h=0
  652. fi
  653. echo "#define has_memcpy $h /* Does memcpy() work?  */"
  654.  
  655. : has_memmove
  656. cat >a.c <<'EOF'
  657. #include "a.h"
  658. char a[4];
  659. int main() {
  660.     strcpy(a, "xy");
  661.     memmove(a+1, a, 3);
  662.     exitmain(strcmp(a,"xxy")!=0);
  663. }
  664. EOF
  665. $RM || exit
  666. if ($CL a.c $L && ./a.out) >&2
  667. then h=1
  668. else h=0
  669. fi
  670. echo "#define has_memmove $h /* Does memmove() work?  */"
  671.  
  672. : has_mmap, has_madvise
  673. cat >a.c <<'EOF'
  674. #define CHAR1 '#' /* the first character in this file */
  675. #include "a.h"
  676. #ifndef mmap
  677.     caddr_t mmap();
  678. #endif
  679. caddr_t a;
  680. struct stat b;
  681. #ifndef MADVISE_OK
  682. #    define MADVISE_OK (madvise(a,b.st_size,MADV_SEQUENTIAL)==0 && madvise(a,b.st_size,MADV_NORMAL)==0)
  683. #endif
  684. int main()
  685. {
  686.     if (fstat(fileno(stdin), &b) != 0)
  687.         exitmain(1);
  688.     a = mmap(
  689.         (caddr_t)0, b.st_size, PROT_READ, MAP_SHARED,
  690.         fileno(stdin), (off_t)0
  691.     );
  692.     exitmain(
  693.         a == (caddr_t)-1  ||
  694.         !MADVISE_OK ||
  695.         *a != CHAR1  ||
  696.         munmap(a, b.st_size)  !=  0
  697.     );
  698. }
  699. EOF
  700. a=0 has_mmap=0
  701. $RM || exit
  702. if ($CL -DMADVISE_OK=1 a.c $L && ./a.out <a.c) >&2
  703. then
  704.     has_mmap=1
  705.     $RM || exit
  706.     ($CL a.c $L && ./a.out <a.c) >&2 && a=1
  707. fi
  708. echo "#define has_madvise $a /* Does madvise() work?  */"
  709. echo "#define has_mmap $has_mmap /* Does mmap() work on regular files?  */"
  710.  
  711. : has_rename, bad_a_rename, bad_b_rename
  712. cat >a.c <<'EOF'
  713. #include "a.h"
  714. int main() { exitmain(rename("a.a","a.b") != 0); }
  715. EOF
  716. echo a >a.a && $RM a.b || exit
  717. if ($CL a.c $L && ./a.out && test -f a.b) >&2
  718. then
  719.     h=1
  720.     rm -f a.a a.b &&
  721.     echo a >a.a && chmod -w a.a || exit
  722.     if ./a.out && test ! -f a.a && test -f a.b
  723.     then a=0
  724.     else a=1
  725.     fi
  726.     rm -f a.a a.b &&
  727.     echo a >a.a && echo b >a.b && chmod -w a.b || exit
  728.     if ./a.out && test ! -f a.a && test -f a.b
  729.     then b=0
  730.     else b=1
  731.     fi
  732.     rm -f a.a a.b || exit
  733. else h=0 a=0 b=0
  734. fi
  735. echo "#define has_rename $h /* Does rename() work?  */"
  736. echo "#define bad_a_rename $a /* Does rename(A,B) fail if A is unwritable?  */"
  737. echo "#define bad_b_rename $b /* Does rename(A,B) fail if B is unwritable?  */"
  738.  
  739. : void, VOID
  740. cat >a.c <<'EOF'
  741. #include "a.h"
  742. void f() {}
  743. int main() {f(); exitmain(0);}
  744. EOF
  745. if $CS a.c $LS >&2
  746. then
  747.     v='(void) '
  748. else
  749.     v=
  750.     echo 'typedef int void;'
  751. fi
  752. echo "#define VOID $v/* 'VOID e;' discards the value of an expression 'e'.  */"
  753.  
  754. : has_seteuid
  755. case $has_getuid in
  756. 0)
  757.     a='/* ' z='*/ ' has_seteuid=?;;
  758. *)
  759.     a= z=
  760.     cat >a.c <<'EOF'
  761. #include "a.h"
  762. #ifndef geteuid
  763.     uid_t geteuid();
  764. #endif
  765. int main() {
  766. /* Guess, don't test.  Ugh.  Testing would require running conf.sh setuid.  */
  767. /* seteuid() isn't standardized yet, so the guess below may well be wrong.  */
  768. #if !_POSIX_VERSION || _POSIX_VERSION<=199009L&&!defined(sgi)&&!defined(__sgi__)&&!defined(sun)&&!defined(__sun__)
  769.     exitmain(1);
  770. #else
  771.     exitmain(seteuid(geteuid()) != 0);
  772. #endif
  773. }
  774. EOF
  775.     $RM || exit
  776.     if ($CL a.c $L && ./a.out) >&2
  777.     then has_seteuid=1
  778.     else has_seteuid=0
  779.     fi
  780. esac
  781. echo "$a#define has_seteuid $has_seteuid $z/* Does seteuid() work?  See README.  */"
  782.  
  783. : has_setuid
  784. h=$has_seteuid
  785. case $h in
  786. 0)
  787.     cat >a.c <<'EOF'
  788. #include "a.h"
  789. #ifndef getuid
  790.     uid_t getuid();
  791. #endif
  792. int main() { exitmain(setuid(getuid()) != 0); }
  793. EOF
  794.     $RM || exit
  795.     ($CL a.c $L && ./a.out) >&2 && h=1
  796. esac
  797. echo "$a#define has_setuid $h $z/* Does setuid() exist?  */"
  798.  
  799. : has_signal, signal_args, signal_type, sig_zaps_handler
  800. cat >a.c <<'EOF'
  801. #include "a.h"
  802. #ifndef getpid
  803.     pid_t getpid();
  804. #endif
  805. #if !defined(signal) && declare_signal
  806.     signal_type (*signal P((int,signal_type(*)signal_args)))signal_args;
  807. #endif
  808. signal_type nothing(i) int i; {}
  809. int main(argc, argv) int argc; char **argv;
  810. {
  811.     signal(SIGINT, nothing);
  812.     while (--argc)
  813.         kill(getpid(), SIGINT);
  814.     exitmain(0);
  815. }
  816. EOF
  817. for declare_signal in 1 0
  818. do
  819.     for signal_type in void int
  820.     do
  821.         for signal_args in 'P((int))' '()'
  822.         do
  823.             $RM || exit
  824.             ($CL \
  825.                 -Ddeclare_signal=$declare_signal \
  826.                 -Dsignal_args="$signal_args" \
  827.                 -Dsignal_type=$signal_type \
  828.                     a.c $L && ./a.out 1) >&2 && break
  829.         done && break
  830.     done && break
  831. done || {
  832.     echo >&2 "cannot deduce signal_args, signal_type"
  833.     exit 1
  834. }
  835. if ./a.out 1 2 >&2
  836. then z=0
  837. else z=1
  838. fi
  839. cat <<EOF
  840. #define has_signal $has_signal /* Does signal() work?  */
  841. #define signal_args $signal_args /* arguments of signal handlers */
  842. #define signal_type $signal_type /* type returned by signal handlers */
  843. #define sig_zaps_handler $z /* Must a signal handler reinvoke signal()?  */
  844. EOF
  845.  
  846. : has_sigaction
  847. cat >a.c <<'EOF'
  848. #include "a.h"
  849. #ifndef getpid
  850.     pid_t getpid();
  851. #endif
  852. static sig_atomic_t volatile gotsig;
  853. static void getsig(i) int i; { gotsig = 1; }
  854. int main(argc, argv) int argc; char **argv;
  855. {
  856.     struct sigaction s;
  857.     sigset_t t;
  858.     if (sigemptyset(&t) != 0  ||  sigaddset(&t, SIGINT) != 0)
  859.         exitmain(1);
  860.     if (sigaction(SIGINT, (struct sigaction const*)0, &s) != 0)
  861.         exitmain(1);
  862.     s.sa_handler = getsig;
  863.     s.sa_mask = t;
  864.     if (sigaction(SIGINT, &s, (struct sigaction*)0) != 0)
  865.         exitmain(1);
  866.     kill(getpid(), SIGINT);
  867.     exitmain(gotsig != 1);
  868. }
  869. EOF
  870. $RM || exit
  871. if ($CL a.c $L && ./a.out) >&2
  872. then has_sigaction=1
  873. else has_sigaction=0
  874. fi
  875. echo "#define has_sigaction $has_sigaction /* Does struct sigaction work?  */"
  876.  
  877. : has_sigblock, sigmask
  878. a='/* ' z='*/ '
  879. b='/* ' y='*/ '
  880. case $has_sigaction in
  881. 1)
  882.     h=? n=?;;
  883. *)
  884.     a= z=
  885.     cat >a.c <<'EOF'
  886. #include "a.h"
  887. #include <signal.h>
  888. #if define_sigmask
  889. #    define sigmask(s) (1 << ((s)-1))
  890. #endif
  891. int main()
  892. {
  893.     sigblock(sigmask(SIGHUP));
  894.     exitmain(kill(getpid(), SIGHUP) != 0);
  895. }
  896. EOF
  897.     if $RM || exit; ($CL a.c $L && ./a.out) >&2
  898.     then h=1
  899.     elif $RM || exit; ($CL -Ddefine_sigmask=1 a.c $L && ./a.out) >&2
  900.     then h=1 b= y=
  901.     else h=0
  902.     fi
  903. esac
  904. echo "$a#define has_sigblock $h $z/* Does sigblock() work?  */"
  905. echo "$b#define sigmask(s) (1 << ((s)-1)) $y/* Yield mask for signal number.  */"
  906.  
  907. : has_sys_siglist
  908. cat >a.c <<'EOF'
  909. #include "a.h"
  910. #ifndef sys_siglist
  911.     extern char const *sys_siglist[];
  912. #endif
  913. int main() { exitmain(!sys_siglist[1][0]); }
  914. EOF
  915. $RM || exit
  916. if ($CL a.c $L && ./a.out) >&2
  917. then h=1
  918. else h=0
  919. fi
  920. echo "#define has_sys_siglist $h /* Does sys_siglist[] work?  */"
  921.  
  922. : fread_type, Fread, Fwrite
  923. cat >a.c <<'EOF'
  924. #define CHAR1 '#' /* the first character in this file */
  925. #include "a.h"
  926. #if !defined(fread) && declare_fread
  927.     fread_type fread P((void*,freadarg_type,freadarg_type,FILE*));
  928. #endif
  929. int main()
  930. {
  931.     char b;
  932.     exitmain(!(
  933.         fread(&b, (freadarg_type)1, (freadarg_type)1, stdin) == 1  &&
  934.         b==CHAR1
  935.     ));
  936. }
  937. EOF
  938. for declare_fread in 1 0
  939. do
  940.     for fread_type in ssize_t size_t int unsigned
  941.     do
  942.         for freadarg_type in size_t ssize_t unsigned int
  943.         do
  944.             $RM || exit
  945.             (
  946.                 $CL \
  947.                     -Ddeclare_fread=$declare_fread \
  948.                     -Dfreadarg_type=$freadarg_type \
  949.                     -Dfread_type=$fread_type \
  950.                     a.c $L &&
  951.                 ./a.out <a.c
  952.             ) >&2 && break
  953.         done && break
  954.     done && break
  955. done || {
  956.     echo >&2 "cannot deduce fread types"
  957.     exit 1
  958. }
  959. cat <<EOF
  960. typedef $fread_type fread_type; /* type returned by fread() and fwrite() */
  961. typedef $freadarg_type freadarg_type; /* type of their size arguments */
  962. EOF
  963.  
  964. : malloc_type
  965. cat >a.c <<'EOF'
  966. #include "a.h"
  967. typedef void *malloc_type;
  968. #ifndef malloc
  969.     malloc_type malloc();
  970. #endif
  971. int main() { exitmain(!malloc(1)); }
  972. EOF
  973. if $CS a.c $LS >&2
  974. then t=void
  975. else t=char
  976. fi
  977. echo "typedef $t *malloc_type; /* type returned by malloc() */"
  978.  
  979. : has_getcwd
  980. cat >a.c <<'EOF'
  981. #include "a.h"
  982. #ifndef getcwd
  983.     char *getcwd();
  984. #endif
  985. char buf[10000];
  986. int main() { exitmain(!getcwd(buf,10000)); }
  987. EOF
  988. $RM || exit
  989. if ($CL a.c $L && ./a.out) >&2
  990. then has_getcwd=1
  991. else has_getcwd=0
  992. fi
  993. echo "#define has_getcwd $has_getcwd /* Does getcwd() work?  */"
  994.  
  995. : has_getwd
  996. case $has_getcwd in
  997. 1)
  998.     a='/* ' z='*/ ' h=?;;
  999. *)
  1000.     a= z=
  1001.     cat >a.c <<'EOF'
  1002. #include "a.h"
  1003. #include <sys/param.h>
  1004. #ifndef getwd
  1005.     char *getwd();
  1006. #endif
  1007. char buf[MAXPATHLEN];
  1008. int main() { exitmain(!getwd(buf)); }
  1009. EOF
  1010.     $RM || exit
  1011.     if ($CL a.c $L && ./a.out) >&2
  1012.     then h=1
  1013.     else h=0
  1014.     fi
  1015. esac
  1016. echo "$a#define has_getwd $h $z/* Does getwd() work?  */"
  1017.  
  1018. : has_mktemp
  1019. cat >a.c <<'EOF'
  1020. #include "a.h"
  1021. #ifndef mktemp
  1022.     char *mktemp();
  1023. #endif
  1024. int main()
  1025. {
  1026.     char b[9];
  1027.     strcpy(b, "a.XXXXXX");
  1028.     exitmain(!mktemp(b));
  1029. }
  1030. EOF
  1031. $RM || exit
  1032. if ($CL a.c $L && ./a.out) >&2
  1033. then h=1
  1034. else h=0
  1035. fi
  1036. echo "#define has_mktemp $h /* Does mktemp() work?  */"
  1037.  
  1038. : has_NFS
  1039. echo "#define has_NFS 1 /* Might NFS be used?  */"
  1040.  
  1041. : strchr
  1042. cat >a.c <<'EOF'
  1043. #include "a.h"
  1044. #ifndef strchr
  1045.     char *strchr();
  1046. #endif
  1047. int main() {exitmain(!strchr("abc", 'c'));}
  1048. EOF
  1049. $RM || exit
  1050. if ($CL a.c $L && ./a.out) >&2
  1051. then a='/* ' z='*/ '
  1052. else a= z=
  1053. fi
  1054. echo "$a#define strchr index $z/* Use old-fashioned name for strchr()?  */"
  1055.  
  1056. : strrchr
  1057. cat >a.c <<'EOF'
  1058. #include "a.h"
  1059. #ifndef strrchr
  1060.     char *strrchr();
  1061. #endif
  1062. int main() {exitmain(!strrchr("abc", 'c'));}
  1063. EOF
  1064. $RM || exit
  1065. if ($CL a.c $L && ./a.out) >&2
  1066. then a='/* ' z='*/ '
  1067. else a= z=
  1068. fi
  1069. echo "$a#define strrchr rindex $z/* Use old-fashioned name for strrchr()?  */"
  1070.  
  1071. : bad_unlink
  1072. cat >a.c <<'EOF'
  1073. #include "a.h"
  1074. int main() { exitmain(unlink("a.c") != 0); }
  1075. EOF
  1076. $RM && chmod -w a.c || exit
  1077. if $CL a.c $L >&2 && ./a.out >/dev/null && test ! -f a.c
  1078. then b=0
  1079. else b=1
  1080. fi
  1081. rm -f a.c || exit
  1082. echo "#define bad_unlink $b /* Does unlink() fail on unwritable files?  */"
  1083.  
  1084. : has_vfork, has_fork, has_spawn, has_wait, has_waitpid, RCS_SHELL
  1085. cat >a.c <<'EOF'
  1086. #include "a.h"
  1087. #ifndef getpid
  1088.     pid_t getpid();
  1089. #endif
  1090. #if TRY_VFORK
  1091. #    ifndef vfork
  1092.         pid_t vfork();
  1093. #    endif
  1094. #else
  1095. #    ifndef fork
  1096.         pid_t fork();
  1097. #    endif
  1098. #    undef vfork
  1099. #    define vfork fork
  1100. #endif
  1101. #if TRY_WAITPID
  1102. #    ifndef waitpid
  1103.         pid_t waitpid();
  1104. #    endif
  1105. #else
  1106. #    ifndef wait
  1107.         pid_t wait();
  1108. #    endif
  1109. #endif
  1110. pid_t child;
  1111. int status;
  1112. struct stat st;
  1113. int main()
  1114. {
  1115.     pid_t parent = getpid();
  1116.     if (!(child = vfork())) {
  1117.         /* Tickle vfork/compiler bug (e.g. sparc gcc -O (1.37.1).  */
  1118.         pid_t i = getpid(), j = getpid();
  1119.         if (i!=getpid() || j!=getpid())
  1120.             _exit(!i);
  1121.         /* Tickle file descriptor bug (e.g. IRIX 3.3).  */
  1122.         _exit(close(1) != 0);
  1123.     } else {
  1124. #        if TRY_WAITPID
  1125.             if (waitpid(child, &status, 0) != child)
  1126.                 exitmain(1);
  1127. #        else
  1128.             while (wait(&status) != child)
  1129.                 ;
  1130. #        endif
  1131.         /* Test for presence of bugs.  */
  1132.         exitmain(status  ||  parent != getpid()  ||  fstat(1,&st) != 0);
  1133.     }
  1134. }
  1135. EOF
  1136. $RM || exit
  1137. if ($CL -DTRY_VFORK=1 a.c $L && ./a.out) >&2
  1138. then has_vfork=1
  1139. else has_vfork=0
  1140. fi
  1141. echo "#define has_vfork $has_vfork /* Does vfork() work?  */"
  1142. h=$has_vfork
  1143. case $h in
  1144. 0)
  1145.     $RM || exit
  1146.     ($CL a.c $L && ./a.out) >&2 && h=1
  1147. esac
  1148. echo "#define has_fork $h /* Does fork() work?  */"
  1149. $RM || exit
  1150. if ($CL -DTRY_VFORK=$has_vfork -DTRY_WAITPID=1 a.c $L && ./a.out) >&2
  1151. then h=1
  1152. else h=0
  1153. fi
  1154. echo "#define has_spawn 0 /* Does spawn*() work?  */"
  1155. echo "#define has_wait 1 /* Does wait() work?  */"
  1156. echo "#define has_waitpid $h /* Does waitpid() work?  */"
  1157. echo '#define RCS_SHELL "/bin/sh" /* shell to run RCS subprograms */'
  1158.  
  1159. : has_vfprintf
  1160. cat >a.c <<'EOF'
  1161. #include "a.h"
  1162. #if has_prototypes
  1163. int p(char const*format,...)
  1164. #else
  1165. /*VARARGS1*/ int p(format, va_alist) char *format; va_dcl
  1166. #endif
  1167. {
  1168.     int r;
  1169.     va_list args;
  1170.     vararg_start(args, format);
  1171.     r = vfprintf(stderr, format, args);
  1172.     va_end(args);
  1173.     return r;
  1174. }
  1175. int main() { exitmain(p("") != 0); }
  1176. EOF
  1177. $RM || exit
  1178. if ($CL a.c $L && ./a.out) >&2
  1179. then h=1
  1180. else h=0
  1181. fi
  1182. echo "#define has_vfprintf $h /* Does vfprintf() work?  */"
  1183.  
  1184. : has__doprintf, has__doprnt
  1185. case $h in
  1186. 1)
  1187.     h=? a='/* ' z='*/ ';;
  1188. *)
  1189.     a= z=
  1190.     cat >a.c <<'EOF'
  1191. #include "a.h"
  1192. #if has_prototypes
  1193. int p(char const*format,...)
  1194. #else
  1195. /*VARARGS1*/ int p(format, va_alist) char *format; va_dcl
  1196. #endif
  1197. {
  1198.     va_list args;
  1199.     vararg_start(args, format);
  1200. #    if TRY__DOPRINTF
  1201.         _doprintf(stderr, format, args);
  1202. #    else
  1203.         _doprnt(format, args, stderr);
  1204. #    endif
  1205.     va_end(args);
  1206. }
  1207. int main() { p(""); exitmain(ferror(stderr) != 0); }
  1208. EOF
  1209.     $RM || exit
  1210.     if ($CL -DTRY__DOPRINTF=1 a.c $L && ./a.out) >&2
  1211.     then h=1
  1212.     else h=0
  1213.     fi
  1214. esac
  1215. echo "$a#define has__doprintf $h $z/* Does _doprintf() work?  */"
  1216. case $h in
  1217. 0)
  1218.     $RM || exit
  1219.     if ($CL a.c $L && ./a.out) >&2
  1220.     then h=1
  1221.     else h=0
  1222.     fi
  1223.     a= z=;;
  1224. *)
  1225.     h=? a='/* ' z='*/ '
  1226. esac
  1227. echo "$a#define has__doprnt $h $z/* Does _doprnt() work?  */"
  1228.  
  1229. : EXIT_FAILURE
  1230. cat >a.c <<'EOF'
  1231. #include "a.h"
  1232. int main() { exitmain(EXIT_FAILURE); }
  1233. EOF
  1234. $RM || exit
  1235. if $CL a.c $L >&2 && ./a.out
  1236. then a= z=
  1237. else a='/* ' z='*/ '
  1238. fi
  1239. echo "$a#undef EXIT_FAILURE $z/* Uncomment this if EXIT_FAILURE is broken.  */"
  1240.  
  1241. : large_memory
  1242. echo "#define large_memory $has_mmap /* Can main memory hold entire RCS files?  */"
  1243.  
  1244. : ULONG_MAX
  1245. cat >a.c <<'EOF'
  1246. #include "a.h"
  1247. #ifdef ULONG_MAX
  1248.     /*
  1249.      * "#if ULONG_MAX/10 <= 0" does not always work,
  1250.      * because some buggy implementations put casts in ULONG_MAX.
  1251.      */
  1252.     int main() { exitmain(ULONG_MAX/10 <= 0); }
  1253. #else
  1254.     int main() { exitmain(1); }
  1255. #endif
  1256. EOF
  1257. $RM || exit
  1258. if $CL a.c $L >&2 && ./a.out
  1259. then a='/* ' z='*/ '
  1260. else a= z=
  1261. fi
  1262. echo "$a#undef ULONG_MAX $z/* Uncomment this if ULONG_MAX is broken (e.g. < 0).  */"
  1263.  
  1264. : struct utimbuf
  1265. cat >a.c <<'EOF'
  1266. #include "a.h"
  1267. struct utimbuf s;
  1268. int main() { s.actime = s.modtime = 1; exitmain(utime("a.c", &s) != 0); }
  1269. EOF
  1270. $RM || exit
  1271. if ($CL a.c $L && ./a.out) >&2
  1272. then a='/* ' z=' */'
  1273. else a= z=
  1274. fi
  1275. echo "${a}struct utimbuf { time_t actime, modtime; };$z /* Uncomment this if needed.  */"
  1276.  
  1277. : CO
  1278. echo "#define CO \"${RCSPREFIX}co\" /* name of 'co' program */"
  1279.  
  1280. : COMPAT2
  1281. echo "#define COMPAT2 $COMPAT2 /* Are version 2 files supported?  */"
  1282.  
  1283. : DATEFORM
  1284. cat >a.c <<'EOF'
  1285. #include "a.h"
  1286. int main() { printf("%.2d", 1); exitmain(0); }
  1287. EOF
  1288. $RM && $CL a.c $L >&2 && r=`./a.out` || exit
  1289. case $r in
  1290. 01)    f=%.2d;;
  1291. *)    f=%02d
  1292. esac
  1293. echo "#define DATEFORM \"$f.$f.$f.$f.$f.${f}\" /* e.g. 01.01.01.01.01.01 */"
  1294.  
  1295. : DIFF
  1296. echo "#define DIFF \"${DIFF}\" /* name of 'diff' program */"
  1297.  
  1298. : DIFF3
  1299. echo "#define DIFF3 \"${DIFF3}\" /* name of 'diff3' program */"
  1300.  
  1301. echo "#define DIFF3_BIN $DIFF3_BIN /* Is diff3 user-visible (not the /usr/lib auxiliary)?  */"
  1302.  
  1303. : DIFF_FLAGS
  1304. dfs=
  1305. for df in $DIFF_FLAGS
  1306. do dfs="$dfs, \"${df}\""
  1307. done
  1308. echo "#define DIFF_FLAGS $dfs /* Make diff output suitable for RCS.  */"
  1309.  
  1310. : DIFF_L
  1311. echo "#define DIFF_L $DIFF_L /* Does diff -L work? */"
  1312.  
  1313. : DIFF_SUCCESS, DIFF_FAILURE, DIFF_TROUBLE
  1314. cat <<EOF
  1315. #define DIFF_SUCCESS $DIFF_SUCCESS /* DIFF status if no differences are found */
  1316. #define DIFF_FAILURE $DIFF_FAILURE /* DIFF status if differences are found */
  1317. #define DIFF_TROUBLE $DIFF_TROUBLE /* DIFF status if trouble */
  1318. EOF
  1319.  
  1320. : ED
  1321. echo "#define ED \"${ED}\" /* name of 'ed' program (used only if !DIFF3_BIN) */"
  1322.  
  1323. : MERGE
  1324. echo "#define MERGE \"${RCSPREFIX}merge\" /* name of 'merge' program */"
  1325.  
  1326. : '*SLASH*', ROOTPATH, TMPDIR, X_DEFAULT
  1327. case ${PWD-`pwd`} in
  1328. /*) # Posix
  1329.     SLASH=/
  1330.     qSLASH="'/'"
  1331.     SLASHes=$qSLASH
  1332.     isSLASH='#define isSLASH(c) ((c) == SLASH)'
  1333.     ROOTPATH='isSLASH((p)[0])'
  1334.     X_DEFAULT=",v$SLASH";;
  1335. ?:[/\\]*) # MS-DOS
  1336.     SLASH='\'
  1337.     qSLASH="'\\\\'"
  1338.     SLASHes="$qSLASH: case '/': case ':'"
  1339.     isSLASH='int isSLASH P((int));'
  1340.     ROOTPATH='((p)[0] && (p)[1]==':' && isSLASH((p)[2]))'
  1341.     X_DEFAULT="$SLASH,v";;
  1342. *)
  1343.     echo >&2 "cannot deduce SLASH"; exit 1
  1344. esac
  1345. cat <<EOF
  1346. #define TMPDIR "${SLASH}tmp" /* default directory for temporary files */
  1347. #define SLASH $qSLASH /* principal pathname separator */
  1348. #define SLASHes $SLASHes /* \`case SLASHes:' labels all pathname separators */
  1349. $isSLASH /* Is arg a pathname separator?  */
  1350. #define ROOTPATH(p) $ROOTPATH /* Is p an absolute pathname?  */
  1351. #define X_DEFAULT "$X_DEFAULT" /* default value for -x option */
  1352. EOF
  1353.  
  1354. : DIFF_ABSOLUTE
  1355. case $DIFF in
  1356. "$SLASH"*) a=1;;
  1357. *) a=0
  1358. esac
  1359. echo "#define DIFF_ABSOLUTE $a /* Is ROOTPATH(DIFF) true?  */"
  1360.  
  1361. : ALL_ABSOLUTE
  1362. a=1
  1363. for i in "$DIFF" "$DIFF3" "$ED" "$RCSPREFIX" "$SENDMAIL"/
  1364. do
  1365.     case $i in
  1366.     "$SLASH"* | "\"$SLASH"*) ;;
  1367.     *) a=0 break
  1368.     esac
  1369. done
  1370. echo "#define ALL_ABSOLUTE $a /* Are all subprograms absolute pathnames?  */"
  1371.  
  1372. : SENDMAIL
  1373. case $SENDMAIL in
  1374. '') a='/* ' z='*/ ';;
  1375. *) a= z=
  1376. esac
  1377. echo "$a#define SENDMAIL $SENDMAIL $z/* how to send mail */"
  1378.  
  1379. : TZ_must_be_set
  1380. echo "#define TZ_must_be_set 0 /* Must TZ be set for gmtime() to work?  */"
  1381.  
  1382.  
  1383. : standard function declarations
  1384.  
  1385. cat <<'EOF'
  1386.  
  1387.  
  1388.  
  1389. /* Adjust the following declarations as needed.  */
  1390.  
  1391.  
  1392. #if __GNUC__ && !__STRICT_ANSI__
  1393. #    define exiting volatile /* GCC extension: function cannot return */
  1394. #else
  1395. #    define exiting
  1396. #endif
  1397. EOF
  1398.  
  1399. cat >a.ha <<EOF
  1400.  
  1401. #if has_ftruncate
  1402.     int ftruncate P((int,off_t));
  1403. #endif
  1404.  
  1405. /* <sys/mman.h> */
  1406. #if has_madvise
  1407.     int madvise P((caddr_t,size_t,int));
  1408. #endif
  1409. #if has_mmap
  1410.     caddr_t mmap P((caddr_t,size_t,int,int,int,off_t));
  1411.     int munmap P((caddr_t,size_t));
  1412. #endif
  1413.  
  1414.  
  1415. /* Posix (ISO/IEC 9945-1: 1990 / IEEE Std 1003.1-1990) */
  1416. /* These definitions are for the benefit of non-Posix hosts, and */
  1417. /* Posix hosts that have Standard C compilers but traditional include files.  */
  1418. /* Unfortunately, mixed-up hosts are all too common.  */
  1419.  
  1420. /* <fcntl.h> */
  1421. #ifdef F_DUPFD
  1422.     int fcntl P((int,int,...));
  1423. #else
  1424.     int dup2 P((int,int));
  1425. #endif
  1426. #ifndef O_BINARY /* some non-Posix hosts need O_BINARY */
  1427. #    define O_BINARY 0 /* no effect on Posix */
  1428. #endif
  1429. #ifdef O_CREAT
  1430. #    define open_can_creat 1
  1431. #else
  1432. #    define open_can_creat 0
  1433. #    define O_RDONLY 0
  1434. #    define O_WRONLY 1
  1435. #    define O_RDWR 2
  1436. #    define O_CREAT 01000
  1437. #    define O_TRUNC 02000
  1438.     int creat P((char const*,mode_t));
  1439. #endif
  1440. #ifndef O_EXCL
  1441. #    define O_EXCL 0
  1442. #endif
  1443.  
  1444. /* <pwd.h> */
  1445. #if has_getpwuid
  1446.     struct passwd *getpwuid P((uid_t));
  1447. #endif
  1448.  
  1449. /* <signal.h> */
  1450. #if has_sigaction
  1451.     int sigaction P((int,struct sigaction const*,struct sigaction*));
  1452.     int sigaddset P((sigset_t*,int));
  1453.     int sigemptyset P((sigset_t*));
  1454. #else
  1455. #if has_sigblock
  1456.     /* BSD */
  1457.     int sigblock P((int));
  1458.     int sigmask P((int));
  1459.     int sigsetmask P((int));
  1460. #endif
  1461. #endif
  1462.  
  1463. /* <stdio.h> */
  1464. FILE *fdopen P((int,char const*));
  1465. int fileno P((FILE*));
  1466.  
  1467. /* <sys/stat.h> */
  1468. int chmod P((char const*,mode_t));
  1469. int fstat P((int,struct stat*));
  1470. int stat P((char const*,struct stat*));
  1471. mode_t umask P((mode_t));
  1472. #if has_fchmod
  1473.     int fchmod P((int,mode_t));
  1474. #endif
  1475. #ifndef S_IRUSR
  1476. #    ifdef S_IREAD
  1477. #        define S_IRUSR S_IREAD
  1478. #    else
  1479. #        define S_IRUSR 0400
  1480. #    endif
  1481. #    ifdef S_IWRITE
  1482. #        define S_IWUSR S_IWRITE
  1483. #    else
  1484. #        define S_IWUSR (S_IRUSR/2)
  1485. #    endif
  1486. #endif
  1487. #ifndef S_IRGRP
  1488. #    if has_getuid
  1489. #        define S_IRGRP (S_IRUSR / 0010)
  1490. #        define S_IWGRP (S_IWUSR / 0010)
  1491. #        define S_IROTH (S_IRUSR / 0100)
  1492. #        define S_IWOTH (S_IWUSR / 0100)
  1493. #    else
  1494.         /* single user OS -- not Posix or Unix */
  1495. #        define S_IRGRP 0
  1496. #        define S_IWGRP 0
  1497. #        define S_IROTH 0
  1498. #        define S_IWOTH 0
  1499. #    endif
  1500. #endif
  1501. #ifndef S_ISREG
  1502. #    define S_ISREG(n) (((n) & S_IFMT) == S_IFREG)
  1503. #endif
  1504.  
  1505. /* <sys/wait.h> */
  1506. #if has_wait
  1507.     pid_t wait P((int*));
  1508. #endif
  1509. #ifndef WEXITSTATUS
  1510. #    define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  1511. #    undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix.  */
  1512. #endif
  1513. #ifndef WIFEXITED
  1514. #    define WIFEXITED(stat_val) (!((stat_val) & 255))
  1515. #endif
  1516.  
  1517. /* <unistd.h> */
  1518. char *getlogin P((void));
  1519. int close P((int));
  1520. int isatty P((int));
  1521. int link P((char const*,char const*));
  1522. int open P((char const*,int,...));
  1523. int unlink P((char const*));
  1524. int _filbuf P((FILE*)); /* keeps lint quiet in traditional C */
  1525. int _flsbuf P((int,FILE*)); /* keeps lint quiet in traditional C */
  1526. long pathconf P((char const*,int));
  1527. ssize_t write P((int,void const*,size_t));
  1528. #ifndef STDIN_FILENO
  1529. #    define STDIN_FILENO 0
  1530. #    define STDOUT_FILENO 1
  1531. #    define STDERR_FILENO 2
  1532. #endif
  1533. #if has_fork
  1534. #    if !has_vfork
  1535. #        undef vfork
  1536. #        define vfork fork
  1537. #    endif
  1538.     pid_t vfork P((void)); /* vfork is nonstandard but faster */
  1539. #endif
  1540. #if has_getcwd || !has_getwd
  1541.     char *getcwd P((char*,size_t));
  1542. #else
  1543.     char *getwd P((char*));
  1544. #endif
  1545. #if has_getuid
  1546.     uid_t getuid P((void));
  1547. #endif
  1548. #if has_readlink
  1549.     ssize_t readlink P((char const*,char*,size_t)); /* BSD; not standard yet */
  1550. #endif
  1551. #if has_setuid
  1552. #    if !has_seteuid
  1553. #        undef seteuid
  1554. #        define seteuid setuid
  1555. #    endif
  1556.     int seteuid P((uid_t));
  1557.     uid_t geteuid P((void));
  1558. #endif
  1559. #if has_spawn
  1560.     int spawnv P((int,char const*,char*const*));
  1561. #    if ALL_ABSOLUTE
  1562. #        define spawn_RCS spawnv
  1563. #    else
  1564. #        define spawn_RCS spawnvp
  1565.         int spawnvp P((int,char const*,char*const*));
  1566. #    endif
  1567. #else
  1568.     int execv P((char const*,char*const*));
  1569. #    if ALL_ABSOLUTE
  1570. #        define exec_RCS execv
  1571. #    else
  1572. #        define exec_RCS execvp
  1573.         int execvp P((char const*,char*const*));
  1574. #    endif
  1575. #endif
  1576.  
  1577. /* utime.h */
  1578. int utime P((char const*,struct utimbuf const*));
  1579.  
  1580.  
  1581. /* Standard C library */
  1582. /* These definitions are for the benefit of hosts that have */
  1583. /* traditional C include files, possibly with Standard C compilers.  */
  1584. /* Unfortunately, mixed-up hosts are all too common.  */
  1585.  
  1586. /* <errno.h> */
  1587. extern int errno;
  1588.  
  1589. /* <limits.h> */
  1590. #ifndef ULONG_MAX
  1591.     /* This does not work in #ifs, but it's good enough for us.  */
  1592. #    define ULONG_MAX ((unsigned long)-1)
  1593. #endif
  1594.  
  1595. /* <signal.h> */
  1596. #if has_signal
  1597.     signal_type (*signal P((int,signal_type(*)signal_args)))signal_args;
  1598. #endif
  1599.  
  1600. /* <stdio.h> */
  1601. FILE *fopen P((char const*,char const*));
  1602. fread_type fread P((void*,freadarg_type,freadarg_type,FILE*));
  1603. fread_type fwrite P((void const*,freadarg_type,freadarg_type,FILE*));
  1604. int fclose P((FILE*));
  1605. int feof P((FILE*));
  1606. int ferror P((FILE*));
  1607. int fflush P((FILE*));
  1608. int fprintf P((FILE*,char const*,...));
  1609. int fputs P((char const*,FILE*));
  1610. int fseek P((FILE*,long,int));
  1611. int printf P((char const*,...));
  1612. int rename P((char const*,char const*));
  1613. int sprintf P((char*,char const*,...));
  1614. long ftell P((FILE*));
  1615. void clearerr P((FILE*));
  1616. void perror P((char const*));
  1617. #ifndef L_tmpnam
  1618. #    define L_tmpnam 32 /* power of 2 > sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */
  1619. #endif
  1620. #ifndef SEEK_SET
  1621. #    define SEEK_SET 0
  1622. #endif
  1623. #if has_mktemp
  1624.     char *mktemp P((char*)); /* traditional */
  1625. #else
  1626.     char *tmpnam P((char*));
  1627. #endif
  1628. #if has_vfprintf
  1629.     int vfprintf P((FILE*,char const*,va_list));
  1630. #else
  1631. #if has__doprintf
  1632.     void _doprintf P((FILE*,char const*,va_list)); /* Minix */
  1633. #else
  1634.     void _doprnt P((char const*,va_list,FILE*)); /* BSD */
  1635. #endif
  1636. #endif
  1637.  
  1638. /* <stdlib.h> */
  1639. char *getenv P((char const*));
  1640. exiting void _exit P((int));
  1641. exiting void exit P((int));
  1642. malloc_type malloc P((size_t));
  1643. malloc_type realloc P((malloc_type,size_t));
  1644. void free P((malloc_type));
  1645. #ifndef EXIT_FAILURE
  1646. #    define EXIT_FAILURE 1
  1647. #endif
  1648. #ifndef EXIT_SUCCESS
  1649. #    define EXIT_SUCCESS 0
  1650. #endif
  1651. #if !has_fork && !has_spawn
  1652.     int system P((char const*));
  1653. #endif
  1654.  
  1655. /* <string.h> */
  1656. char *strcpy P((char*,char const*));
  1657. char *strchr P((char const*,int));
  1658. char *strrchr P((char const*,int));
  1659. int memcmp P((void const*,void const*,size_t));
  1660. int strcmp P((char const*,char const*));
  1661. size_t strlen P((char const*));
  1662. void *memcpy P((void*,void const*,size_t));
  1663. #if has_memmove
  1664.     void *memmove P((void*,void const*,size_t));
  1665. #endif
  1666.  
  1667. /* <time.h> */
  1668. time_t time P((time_t*));
  1669. EOF
  1670.  
  1671. cat >a.c <<'EOF'
  1672. #include "a.h"
  1673. #define a 0
  1674. #define b 1
  1675. #if h==a
  1676. #    include "a.ha"
  1677. #else
  1678. #    include "a.hb"
  1679. #endif
  1680. int main() { exitmain(0); }
  1681. EOF
  1682.  
  1683. # Comment out lines in a.ha that the compiler rejects.
  1684. # a.ha may not contain comments that cross line boundaries.
  1685. # Leave the result in a.h$h.
  1686. h=a l=1
  1687. U=`wc -l <a.ha | sed 's| ||g'`
  1688. commentOut='s|^[^#/][^/]*|/* & */|'
  1689.  
  1690. until  test $U -lt $l  ||  $CS -Dh=$h a.c $LS >&2
  1691. do
  1692.     case $h in
  1693.     a) i=b;;
  1694.     *) i=a
  1695.     esac
  1696.  
  1697.     # The compiler rejects some line in l..U.
  1698.     # Use binary search to set l to be the index of the first bad line in l..U.
  1699.     u=$U
  1700.     while test $l -lt $u
  1701.     do
  1702.         M=`expr '(' $l + $u ')' / 2`
  1703.         M1=`expr $M + 1`
  1704.         sed "$M1,\$$commentOut" a.h$h >a.h$i || exit
  1705.         if $CS -Dh=$i a.c $LS >&2
  1706.         then l=$M1
  1707.         else u=$M
  1708.         fi
  1709.     done
  1710.  
  1711.     # Comment out the bad line.
  1712.     sed "$l$commentOut" a.h$h >a.h$i || exit
  1713.  
  1714.     h=$i
  1715.     l=`expr $l + 1`
  1716. done
  1717.  
  1718. cat a.h$h
  1719. @
  1720.  
  1721.  
  1722. 5.14.1.1
  1723. log
  1724. @Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
  1725. @
  1726. text
  1727. @@
  1728.  
  1729.  
  1730. 5.14.1.2
  1731. log
  1732. @RCS 5.6.0.1 changes added.
  1733. @
  1734. text
  1735. @d3 3
  1736. a5 3
  1737. Id='$Id: conf.sh,v 5.14.1.1 1993/01/18 14:39:42 heinz Exp heinz $'
  1738. #       Copyright 1990, 1991 by Paul Eggert
  1739. #       Distributed under license by the Free Software Foundation, Inc.
  1740. a37 1
  1741. : ${DIFF3_A=1}
  1742. d56 1
  1743. a56 1
  1744.         /* $Id */
  1745. d110 1
  1746. a110 1
  1747. then CS="$C -S" LS=     # Generate assembly language output.
  1748. d112 2
  1749. a113 2
  1750. then CS="$C -c" LS=     # Generate object code.
  1751. else CS=$CL LS=$L       # Generate an executable.
  1752. d120 2
  1753. a121 2
  1754.         sys/types sys/stat \
  1755.         dirent fcntl limits pwd signal stdlib string sys/mman sys/wait unistd utime vfork
  1756. d123 3
  1757. a125 3
  1758.         i="#include <$h.h>"
  1759.         : $i
  1760.         cat >a.c <<EOF
  1761. d130 13
  1762. a142 13
  1763.         $RM || exit
  1764.         ($CL a.c $L && ./a.out) >&2 || {
  1765.                 case $h in
  1766.                 string)
  1767.                         i='#include <strings.h>';;
  1768.                 *)
  1769.                         i="/* $i */"
  1770.                 esac
  1771.                 case $h in
  1772.                 signal) has_signal=0
  1773.                 esac
  1774.         }
  1775.         echo "$i"
  1776. d153 2
  1777. a154 2
  1778.         : has_sys_${H}_h
  1779.         cat >a.c <<EOF
  1780. d159 6
  1781. a164 6
  1782.         $RM || exit
  1783.         if ($CL a.c $L && ./a.out) >&2
  1784.         then h=1
  1785.         else h=0
  1786.         fi
  1787.         echo "#define has_sys_${H}_h $h /* Does #include <sys/$H.h> work?  */"
  1788. d178 1
  1789. a178 1
  1790.         exitmain(1);
  1791. d180 6
  1792. a185 6
  1793.         int i;
  1794.         b[0] = 'a'; b[1] = '.';
  1795.         for (i = 2;  i < NAME_MAX;  i++)
  1796.                 b[i] = 'a';
  1797.         b[i] = 'b';
  1798.         exitmain(creat(b, 0) < 0);
  1799. d202 1
  1800. a202 1
  1801.         exitmain(readlink("a.sym2",b,7) != 6  ||  strcmp(b, "a.sym1") != 0);
  1802. d216 9
  1803. a224 9
  1804. #       if has_sys_dir_h
  1805. #               include <sys/dir.h>
  1806. #       endif
  1807. #       ifndef NAME_MAX
  1808. #               ifndef MAXNAMLEN
  1809. #                       define MAXNAMLEN 14
  1810. #               endif
  1811. #               define NAME_MAX MAXNAMLEN
  1812. #       endif
  1813. d227 10
  1814. a236 10
  1815. #       if has_sys_param_h
  1816. #               include <sys/param.h>
  1817. #               define included_sys_param_h 1
  1818. #       endif
  1819. #       ifndef PATH_MAX
  1820. #               ifndef MAXPATHLEN
  1821. #                       define MAXPATHLEN 1024
  1822. #               endif
  1823. #               define PATH_MAX (MAXPATHLEN-1)
  1824. #       endif
  1825. d239 6
  1826. a244 6
  1827. #       if has_sys_param_h && !included_sys_param_h
  1828. #               include <sys/param.h>
  1829. #       endif
  1830. #       ifndef MAXSYMLINKS
  1831. #               define MAXSYMLINKS 20 /* BSD; not standard yet */
  1832. #       endif
  1833. d256 25
  1834. a280 25
  1835.         cat >a.c <<EOF
  1836. #       include "a.h"
  1837.         enum Boolean { false, true };
  1838.         static enum Boolean $i zero;
  1839.         static enum Boolean $i * $i azero = &zero;
  1840.         static enum Boolean $i * $i * $i aazero = &azero;
  1841.         int main() { exitmain(!!**aazero); }
  1842. EOF
  1843.         a= z=
  1844.         if $CS a.c $LS >&2
  1845.         then
  1846.                 cat >a.c <<EOF
  1847.                         typedef unsigned char $i *Iptr_type;
  1848.                         struct { Iptr_type lim; } s, *f = &s;
  1849.                         int main() {
  1850.                                 Iptr_type lim;
  1851.                                 lim = f->lim;
  1852.                                 return !!lim;
  1853.                         }
  1854. EOF
  1855.                 if $CS a.c $LS >&2
  1856.                 then a='/* ' z=' */'
  1857.                 fi
  1858.         fi
  1859.         echo "$a#define $i$z"
  1860. d296 11
  1861. a306 11
  1862.         : $t
  1863.         case $t in
  1864.         size_t) i=unsigned;;
  1865.         time_t) i=long;;
  1866.         *) i=int;;
  1867.         esac
  1868.         if $CS -Dt=$t a.c $LS >&2
  1869.         then a='/* ' z=' */'
  1870.         else a= z=
  1871.         fi
  1872.         echo "${a}typedef $i $t;$z"
  1873. d312 1
  1874. a312 1
  1875. #       define P(params) params
  1876. d314 1
  1877. a314 1
  1878. #       define P(params) ()
  1879. d317 1
  1880. a317 1
  1881. #       include <stdarg.h>
  1882. d319 9
  1883. a327 9
  1884. #       if has_varargs
  1885. #               include <varargs.h>
  1886. #       else
  1887.                 typedef char *va_list;
  1888. #               define va_dcl int va_alist;
  1889. #               define va_start(ap) ((ap) = (va_list)&va_alist)
  1890. #               define va_arg(ap,t) (((t*) ((ap)+=sizeof(t)))  [-1])
  1891. #               define va_end(ap)
  1892. #       endif
  1893. d330 1
  1894. a330 1
  1895. #       define vararg_start va_start
  1896. d332 1
  1897. a332 1
  1898. #       define vararg_start(ap,p) va_start(ap)
  1899. d344 6
  1900. a349 6
  1901.         char *s;
  1902.         va_list v;
  1903.         vararg_start(v,p);
  1904.         s = p[va_arg(v,int)];
  1905.         va_end(v);
  1906.         return s;
  1907. d353 1
  1908. a353 1
  1909.         exitmain(f(argv,0) != argv[0]  ||  f(argv,1) != argv[1]);
  1910. d358 21
  1911. a378 21
  1912.         for has_stdarg in 1 v 0
  1913.         do
  1914.                 case $has_stdarg in
  1915.                 v) has_varargs=1 has_stdarg=0;;
  1916.                 *) has_varargs=0
  1917.                 esac
  1918.                 case $has_stdarg in
  1919.                 0) as='1 2';;
  1920.                 1) as='2 1'
  1921.                 esac
  1922.                 for va_start_args in $as
  1923.                 do
  1924.                         $RM || exit
  1925.                         $CL \
  1926.                                 -Dhas_prototypes=$has_prototypes \
  1927.                                 -Dhas_stdarg=$has_stdarg \
  1928.                                 -Dhas_varargs=$has_varargs \
  1929.                                 -Dva_start_args=$va_start_args \
  1930.                                 a.c $L >&2 && ./a.out && break
  1931.                 done && break
  1932.         done && break
  1933. d380 2
  1934. a381 2
  1935.         echo >&2 "cannot deduce has_prototypes, has_stdarg, va_start_args"
  1936.         exit 1
  1937. d395 1
  1938. a395 1
  1939.         int
  1940. d397 1
  1941. a397 1
  1942.         char const *filename, *mode;
  1943. d399 8
  1944. a406 8
  1945.         int c;
  1946.         FILE *f, *g;
  1947.         if (!(f = fopen("a.out", "rb")) || !(g = fopen(filename, mode)))
  1948.                 return 1;
  1949.         while (c=getc(f), !feof(f))
  1950.                 if (ferror(f)  ||  putc(c,g)<0 && ferror(g))
  1951.                         return 1;
  1952.         return fclose(f)!=0 || fclose(g)!=0;
  1953. d413 1
  1954. a413 1
  1955.         cmp a.out a.e || e=0
  1956. d420 10
  1957. a429 10
  1958.         /* Text and binary i/o behave the same, or binary i/o does not work.  */
  1959. #       define FOPEN_R "r"
  1960. #       define FOPEN_W "w"
  1961. #       define FOPEN_WPLUS "w+"
  1962. #else
  1963.         /* Text and binary i/o behave differently.  */
  1964.         /* This is incompatible with Posix and Unix.  */
  1965. #       define FOPEN_R "rb"
  1966. #       define FOPEN_W "wb"
  1967. #       define FOPEN_WPLUS "w+b"
  1968. d432 7
  1969. a438 7
  1970. #       define FOPEN_R_WORK "r"
  1971. #       define FOPEN_W_WORK "w"
  1972. #       define FOPEN_WPLUS_WORK "w+"
  1973. #else
  1974. #       define FOPEN_R_WORK FOPEN_R
  1975. #       define FOPEN_W_WORK FOPEN_W
  1976. #       define FOPEN_WPLUS_WORK FOPEN_WPLUS
  1977. d463 6
  1978. a468 6
  1979.         DIR *d = opendir(".");
  1980.         struct dirent *e;
  1981.         while ((e = readdir(d)))
  1982.                 if (strcmp(e->d_name, "a.c") == 0  &&  closedir(d) == 0)
  1983.                         exitmain(0);
  1984.         exitmain(1);
  1985. d509 4
  1986. a512 4
  1987.         int f = creat(argv[1], 0);
  1988.         if (f<0 || write(f,"abc",3)!=3 || ftruncate(f,(off_t)0)!=0 || close(f)!=0)
  1989.                         exitmain(1);
  1990.         exitmain(0);
  1991. d518 12
  1992. a529 12
  1993.         h=1
  1994.         # Check out /tmp too; it's buggy on some hosts.
  1995.         for d in . /tmp
  1996.         do
  1997.                 if test -d $d
  1998.                 then
  1999.                         f=$d/a.d
  2000.                         rm -f $f || exit
  2001.                         ./a.out $f && test ! -s $f && test -f $f  ||  h=0
  2002.                         rm -f $f || exit
  2003.                 fi
  2004.         done
  2005. d538 1
  2006. a538 1
  2007.         uid_t getuid();
  2008. d552 1
  2009. a552 1
  2010.         a='/* ' z='*/ ' h=?;;
  2011. d554 2
  2012. a555 2
  2013.         a= z=
  2014.         cat >a.c <<'EOF'
  2015. d559 5
  2016. a563 5
  2017.         $RM || exit
  2018.         if ($CL a.c $L && ./a.out) >&2
  2019.         then h=1
  2020.         else h=0
  2021.         fi
  2022. d597 2
  2023. a598 2
  2024.         memcpy(a,"xy",3);
  2025.         exitmain(strcmp(a,"xy")!=0);
  2026. d613 3
  2027. a615 3
  2028.         strcpy(a, "xy");
  2029.         memmove(a+1, a, 3);
  2030.         exitmain(strcmp(a,"xxy")!=0);
  2031. d630 1
  2032. a630 1
  2033.         caddr_t mmap();
  2034. d635 1
  2035. a635 1
  2036. #       define MADVISE_OK (madvise(a,b.st_size,MADV_SEQUENTIAL)==0 && madvise(a,b.st_size,MADV_NORMAL)==0)
  2037. d639 12
  2038. a650 12
  2039.         if (fstat(fileno(stdin), &b) != 0)
  2040.                 exitmain(1);
  2041.         a = mmap(
  2042.                 (caddr_t)0, b.st_size, PROT_READ, MAP_SHARED,
  2043.                 fileno(stdin), (off_t)0
  2044.         );
  2045.         exitmain(
  2046.                 a == (caddr_t)-1  ||
  2047.                 !MADVISE_OK ||
  2048.                 *a != CHAR1  ||
  2049.                 munmap(a, b.st_size)  !=  0
  2050.         );
  2051. d657 3
  2052. a659 3
  2053.         has_mmap=1
  2054.         $RM || exit
  2055.         ($CL a.c $L && ./a.out <a.c) >&2 && a=1
  2056. d672 14
  2057. a685 14
  2058.         h=1
  2059.         rm -f a.a a.b &&
  2060.         echo a >a.a && chmod -w a.a || exit
  2061.         if ./a.out && test ! -f a.a && test -f a.b
  2062.         then a=0
  2063.         else a=1
  2064.         fi
  2065.         rm -f a.a a.b &&
  2066.         echo a >a.a && echo b >a.b && chmod -w a.b || exit
  2067.         if ./a.out && test ! -f a.a && test -f a.b
  2068.         then b=0
  2069.         else b=1
  2070.         fi
  2071.         rm -f a.a a.b || exit
  2072. d700 1
  2073. a700 1
  2074.         v='(void) '
  2075. d702 2
  2076. a703 2
  2077.         v=
  2078.         echo 'typedef int void;'
  2079. d710 1
  2080. a710 1
  2081.         a='/* ' z='*/ ' has_seteuid=?;;
  2082. d712 2
  2083. a713 2
  2084.         a= z=
  2085.         cat >a.c <<'EOF'
  2086. d716 1
  2087. a716 1
  2088.         uid_t geteuid();
  2089. d722 1
  2090. a722 1
  2091.         exitmain(1);
  2092. d724 1
  2093. a724 1
  2094.         exitmain(seteuid(geteuid()) != 0);
  2095. d728 5
  2096. a732 5
  2097.         $RM || exit
  2098.         if ($CL a.c $L && ./a.out) >&2
  2099.         then has_seteuid=1
  2100.         else has_seteuid=0
  2101.         fi
  2102. d740 1
  2103. a740 1
  2104.         cat >a.c <<'EOF'
  2105. d743 1
  2106. a743 1
  2107.         uid_t getuid();
  2108. d747 2
  2109. a748 2
  2110.         $RM || exit
  2111.         ($CL a.c $L && ./a.out) >&2 && h=1
  2112. d756 1
  2113. a756 1
  2114.         pid_t getpid();
  2115. d759 1
  2116. a759 1
  2117.         signal_type (*signal P((int,signal_type(*)signal_args)))signal_args;
  2118. d764 4
  2119. a767 4
  2120.         signal(SIGINT, nothing);
  2121.         while (--argc)
  2122.                 kill(getpid(), SIGINT);
  2123.         exitmain(0);
  2124. d772 12
  2125. a783 12
  2126.         for signal_type in void int
  2127.         do
  2128.                 for signal_args in 'P((int))' '()'
  2129.                 do
  2130.                         $RM || exit
  2131.                         ($CL \
  2132.                                 -Ddeclare_signal=$declare_signal \
  2133.                                 -Dsignal_args="$signal_args" \
  2134.                                 -Dsignal_type=$signal_type \
  2135.                                         a.c $L && ./a.out 1) >&2 && break
  2136.                 done && break
  2137.         done && break
  2138. d785 2
  2139. a786 2
  2140.         echo >&2 "cannot deduce signal_args, signal_type"
  2141.         exit 1
  2142. d803 1
  2143. a803 1
  2144.         pid_t getpid();
  2145. d809 12
  2146. a820 12
  2147.         struct sigaction s;
  2148.         sigset_t t;
  2149.         if (sigemptyset(&t) != 0  ||  sigaddset(&t, SIGINT) != 0)
  2150.                 exitmain(1);
  2151.         if (sigaction(SIGINT, (struct sigaction const*)0, &s) != 0)
  2152.                 exitmain(1);
  2153.         s.sa_handler = getsig;
  2154.         s.sa_mask = t;
  2155.         if (sigaction(SIGINT, &s, (struct sigaction*)0) != 0)
  2156.                 exitmain(1);
  2157.         kill(getpid(), SIGINT);
  2158.         exitmain(gotsig != 1);
  2159. d835 1
  2160. a835 1
  2161.         h=? n=?;;
  2162. d837 2
  2163. a838 2
  2164.         a= z=
  2165.         cat >a.c <<'EOF'
  2166. d842 1
  2167. a842 1
  2168. #       define sigmask(s) (1 << ((s)-1))
  2169. d846 2
  2170. a847 2
  2171.         sigblock(sigmask(SIGHUP));
  2172.         exitmain(kill(getpid(), SIGHUP) != 0);
  2173. d850 6
  2174. a855 6
  2175.         if $RM || exit; ($CL a.c $L && ./a.out) >&2
  2176.         then h=1
  2177.         elif $RM || exit; ($CL -Ddefine_sigmask=1 a.c $L && ./a.out) >&2
  2178.         then h=1 b= y=
  2179.         else h=0
  2180.         fi
  2181. d864 1
  2182. a864 1
  2183.         extern char const *sys_siglist[];
  2184. d880 1
  2185. a880 1
  2186.         fread_type fread P((void*,freadarg_type,freadarg_type,FILE*));
  2187. d884 5
  2188. a888 5
  2189.         char b;
  2190.         exitmain(!(
  2191.                 fread(&b, (freadarg_type)1, (freadarg_type)1, stdin) == 1  &&
  2192.                 b==CHAR1
  2193.         ));
  2194. d893 15
  2195. a907 15
  2196.         for fread_type in ssize_t size_t int unsigned
  2197.         do
  2198.                 for freadarg_type in size_t ssize_t unsigned int
  2199.                 do
  2200.                         $RM || exit
  2201.                         (
  2202.                                 $CL \
  2203.                                         -Ddeclare_fread=$declare_fread \
  2204.                                         -Dfreadarg_type=$freadarg_type \
  2205.                                         -Dfread_type=$fread_type \
  2206.                                         a.c $L &&
  2207.                                 ./a.out <a.c
  2208.                         ) >&2 && break
  2209.                 done && break
  2210.         done && break
  2211. d909 2
  2212. a910 2
  2213.         echo >&2 "cannot deduce fread types"
  2214.         exit 1
  2215. d922 1
  2216. a922 1
  2217.         malloc_type malloc();
  2218. d936 1
  2219. a936 1
  2220.         char *getcwd();
  2221. d951 1
  2222. a951 1
  2223.         a='/* ' z='*/ ' h=?;;
  2224. d953 2
  2225. a954 2
  2226.         a= z=
  2227.         cat >a.c <<'EOF'
  2228. d958 1
  2229. a958 1
  2230.         char *getwd();
  2231. d963 5
  2232. a967 5
  2233.         $RM || exit
  2234.         if ($CL a.c $L && ./a.out) >&2
  2235.         then h=1
  2236.         else h=0
  2237.         fi
  2238. d975 1
  2239. a975 1
  2240.         char *mktemp();
  2241. d979 3
  2242. a981 3
  2243.         char b[9];
  2244.         strcpy(b, "a.XXXXXX");
  2245.         exitmain(!mktemp(b));
  2246. d998 1
  2247. a998 1
  2248.         char *strchr();
  2249. d1013 1
  2250. a1013 1
  2251.         char *strrchr();
  2252. d1041 1
  2253. a1041 1
  2254.         pid_t getpid();
  2255. d1044 9
  2256. a1052 9
  2257. #       ifndef vfork
  2258.                 pid_t vfork();
  2259. #       endif
  2260. #else
  2261. #       ifndef fork
  2262.                 pid_t fork();
  2263. #       endif
  2264. #       undef vfork
  2265. #       define vfork fork
  2266. d1055 7
  2267. a1061 7
  2268. #       ifndef waitpid
  2269.                 pid_t waitpid();
  2270. #       endif
  2271. #else
  2272. #       ifndef wait
  2273.                 pid_t wait();
  2274. #       endif
  2275. d1068 19
  2276. a1086 19
  2277.         pid_t parent = getpid();
  2278.         if (!(child = vfork())) {
  2279.                 /* Tickle vfork/compiler bug (e.g. sparc gcc -O (1.37.1).  */
  2280.                 pid_t i = getpid(), j = getpid();
  2281.                 if (i!=getpid() || j!=getpid())
  2282.                         _exit(!i);
  2283.                 /* Tickle file descriptor bug (e.g. IRIX 3.3).  */
  2284.                 _exit(close(1) != 0);
  2285.         } else {
  2286. #               if TRY_WAITPID
  2287.                         if (waitpid(child, &status, 0) != child)
  2288.                                 exitmain(1);
  2289. #               else
  2290.                         while (wait(&status) != child)
  2291.                                 ;
  2292. #               endif
  2293.                 /* Test for presence of bugs.  */
  2294.                 exitmain(status  ||  parent != getpid()  ||  fstat(1,&st) != 0);
  2295.         }
  2296. d1098 2
  2297. a1099 2
  2298.         $RM || exit
  2299.         ($CL a.c $L && ./a.out) >&2 && h=1
  2300. d1121 6
  2301. a1126 6
  2302.         int r;
  2303.         va_list args;
  2304.         vararg_start(args, format);
  2305.         r = vfprintf(stderr, format, args);
  2306.         va_end(args);
  2307.         return r;
  2308. d1140 1
  2309. a1140 1
  2310.         h=? a='/* ' z='*/ ';;
  2311. d1142 2
  2312. a1143 2
  2313.         a= z=
  2314.         cat >a.c <<'EOF'
  2315. d1151 8
  2316. a1158 8
  2317.         va_list args;
  2318.         vararg_start(args, format);
  2319. #       if TRY__DOPRINTF
  2320.                 _doprintf(stderr, format, args);
  2321. #       else
  2322.                 _doprnt(format, args, stderr);
  2323. #       endif
  2324.         va_end(args);
  2325. d1162 5
  2326. a1166 5
  2327.         $RM || exit
  2328.         if ($CL -DTRY__DOPRINTF=1 a.c $L && ./a.out) >&2
  2329.         then h=1
  2330.         else h=0
  2331.         fi
  2332. d1171 6
  2333. a1176 6
  2334.         $RM || exit
  2335.         if ($CL a.c $L && ./a.out) >&2
  2336.         then h=1
  2337.         else h=0
  2338.         fi
  2339.         a= z=;;
  2340. d1178 1
  2341. a1178 1
  2342.         h=? a='/* ' z='*/ '
  2343. d1201 5
  2344. a1205 5
  2345.         /*
  2346.          * "#if ULONG_MAX/10 <= 0" does not always work,
  2347.          * because some buggy implementations put casts in ULONG_MAX.
  2348.          */
  2349.         int main() { exitmain(ULONG_MAX/10 <= 0); }
  2350. d1207 1
  2351. a1207 1
  2352.         int main() { exitmain(1); }
  2353. d1243 2
  2354. a1244 2
  2355. 01)     f=%.2d;;
  2356. *)      f=%02d
  2357. a1253 2
  2358. echo "#define DIFF3_A $DIFF3_A /* Does diff3 have an -A option?  */"
  2359.  
  2360. d1282 6
  2361. a1287 6
  2362.         SLASH=/
  2363.         qSLASH="'/'"
  2364.         SLASHes=$qSLASH
  2365.         isSLASH='#define isSLASH(c) ((c) == SLASH)'
  2366.         ROOTPATH='isSLASH((p)[0])'
  2367.         X_DEFAULT=",v$SLASH";;
  2368. d1289 6
  2369. a1294 6
  2370.         SLASH='\'
  2371.         qSLASH="'\\\\'"
  2372.         SLASHes="$qSLASH: case '/': case ':'"
  2373.         isSLASH='int isSLASH P((int));'
  2374.         ROOTPATH='((p)[0] && (p)[1]==':' && isSLASH((p)[2]))'
  2375.         X_DEFAULT="$SLASH,v";;
  2376. d1296 1
  2377. a1296 1
  2378.         echo >&2 "cannot deduce SLASH"; exit 1
  2379. d1318 4
  2380. a1321 4
  2381.         case $i in
  2382.         "$SLASH"* | "\"$SLASH"*) ;;
  2383.         *) a=0 break
  2384.         esac
  2385. d1346 1
  2386. a1346 1
  2387. #       define exiting volatile /* GCC extension: function cannot return */
  2388. d1348 1
  2389. a1348 1
  2390. #       define exiting
  2391. d1355 1
  2392. a1355 1
  2393.         int ftruncate P((int,off_t));
  2394. d1360 1
  2395. a1360 1
  2396.         int madvise P((caddr_t,size_t,int));
  2397. d1363 2
  2398. a1364 2
  2399.         caddr_t mmap P((caddr_t,size_t,int,int,int,off_t));
  2400.         int munmap P((caddr_t,size_t));
  2401. d1375 1
  2402. a1375 1
  2403.         int fcntl P((int,int,...));
  2404. d1377 1
  2405. a1377 1
  2406.         int dup2 P((int,int));
  2407. d1380 1
  2408. a1380 1
  2409. #       define O_BINARY 0 /* no effect on Posix */
  2410. d1383 1
  2411. a1383 1
  2412. #       define open_can_creat 1
  2413. d1385 7
  2414. a1391 7
  2415. #       define open_can_creat 0
  2416. #       define O_RDONLY 0
  2417. #       define O_WRONLY 1
  2418. #       define O_RDWR 2
  2419. #       define O_CREAT 01000
  2420. #       define O_TRUNC 02000
  2421.         int creat P((char const*,mode_t));
  2422. d1394 1
  2423. a1394 1
  2424. #       define O_EXCL 0
  2425. d1399 1
  2426. a1399 1
  2427.         struct passwd *getpwuid P((uid_t));
  2428. d1404 3
  2429. a1406 3
  2430.         int sigaction P((int,struct sigaction const*,struct sigaction*));
  2431.         int sigaddset P((sigset_t*,int));
  2432.         int sigemptyset P((sigset_t*));
  2433. d1409 4
  2434. a1412 4
  2435.         /* BSD */
  2436.         int sigblock P((int));
  2437.         int sigmask P((int));
  2438.         int sigsetmask P((int));
  2439. d1426 1
  2440. a1426 1
  2441.         int fchmod P((int,mode_t));
  2442. d1429 10
  2443. a1438 10
  2444. #       ifdef S_IREAD
  2445. #               define S_IRUSR S_IREAD
  2446. #       else
  2447. #               define S_IRUSR 0400
  2448. #       endif
  2449. #       ifdef S_IWRITE
  2450. #               define S_IWUSR S_IWRITE
  2451. #       else
  2452. #               define S_IWUSR (S_IRUSR/2)
  2453. #       endif
  2454. d1441 12
  2455. a1452 12
  2456. #       if has_getuid
  2457. #               define S_IRGRP (S_IRUSR / 0010)
  2458. #               define S_IWGRP (S_IWUSR / 0010)
  2459. #               define S_IROTH (S_IRUSR / 0100)
  2460. #               define S_IWOTH (S_IWUSR / 0100)
  2461. #       else
  2462.                 /* single user OS -- not Posix or Unix */
  2463. #               define S_IRGRP 0
  2464. #               define S_IWGRP 0
  2465. #               define S_IROTH 0
  2466. #               define S_IWOTH 0
  2467. #       endif
  2468. d1455 1
  2469. a1455 1
  2470. #       define S_ISREG(n) (((n) & S_IFMT) == S_IFREG)
  2471. d1460 1
  2472. a1460 1
  2473.         pid_t wait P((int*));
  2474. d1463 2
  2475. a1464 2
  2476. #       define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  2477. #       undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix.  */
  2478. d1467 1
  2479. a1467 1
  2480. #       define WIFEXITED(stat_val) (!((stat_val) & 255))
  2481. d1482 3
  2482. a1484 3
  2483. #       define STDIN_FILENO 0
  2484. #       define STDOUT_FILENO 1
  2485. #       define STDERR_FILENO 2
  2486. d1487 5
  2487. a1491 5
  2488. #       if !has_vfork
  2489. #               undef vfork
  2490. #               define vfork fork
  2491. #       endif
  2492.         pid_t vfork P((void)); /* vfork is nonstandard but faster */
  2493. d1494 1
  2494. a1494 1
  2495.         char *getcwd P((char*,size_t));
  2496. d1496 1
  2497. a1496 1
  2498.         char *getwd P((char*));
  2499. d1499 1
  2500. a1499 1
  2501.         uid_t getuid P((void));
  2502. d1502 1
  2503. a1502 1
  2504.         ssize_t readlink P((char const*,char*,size_t)); /* BSD; not standard yet */
  2505. d1505 6
  2506. a1510 6
  2507. #       if !has_seteuid
  2508. #               undef seteuid
  2509. #               define seteuid setuid
  2510. #       endif
  2511.         int seteuid P((uid_t));
  2512.         uid_t geteuid P((void));
  2513. d1513 15
  2514. a1527 15
  2515.         int spawnv P((int,char const*,char*const*));
  2516. #       if ALL_ABSOLUTE
  2517. #               define spawn_RCS spawnv
  2518. #       else
  2519. #               define spawn_RCS spawnvp
  2520.                 int spawnvp P((int,char const*,char*const*));
  2521. #       endif
  2522. #else
  2523.         int execv P((char const*,char*const*));
  2524. #       if ALL_ABSOLUTE
  2525. #               define exec_RCS execv
  2526. #       else
  2527. #               define exec_RCS execvp
  2528.                 int execvp P((char const*,char*const*));
  2529. #       endif
  2530. d1544 2
  2531. a1545 2
  2532.         /* This does not work in #ifs, but it's good enough for us.  */
  2533. #       define ULONG_MAX ((unsigned long)-1)
  2534. d1550 1
  2535. a1550 1
  2536.         signal_type (*signal P((int,signal_type(*)signal_args)))signal_args;
  2537. d1571 1
  2538. a1571 1
  2539. #       define L_tmpnam 32 /* power of 2 > sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */
  2540. d1574 1
  2541. a1574 1
  2542. #       define SEEK_SET 0
  2543. d1577 1
  2544. a1577 1
  2545.         char *mktemp P((char*)); /* traditional */
  2546. d1579 1
  2547. a1579 1
  2548.         char *tmpnam P((char*));
  2549. d1582 1
  2550. a1582 1
  2551.         int vfprintf P((FILE*,char const*,va_list));
  2552. d1585 1
  2553. a1585 1
  2554.         void _doprintf P((FILE*,char const*,va_list)); /* Minix */
  2555. d1587 1
  2556. a1587 1
  2557.         void _doprnt P((char const*,va_list,FILE*)); /* BSD */
  2558. d1599 1
  2559. a1599 1
  2560. #       define EXIT_FAILURE 1
  2561. d1602 1
  2562. a1602 1
  2563. #       define EXIT_SUCCESS 0
  2564. d1605 1
  2565. a1605 1
  2566.         int system P((char const*));
  2567. d1617 1
  2568. a1617 1
  2569.         void *memmove P((void*,void const*,size_t));
  2570. d1629 1
  2571. a1629 1
  2572. #       include "a.ha"
  2573. d1631 1
  2574. a1631 1
  2575. #       include "a.hb"
  2576. d1645 18
  2577. a1662 18
  2578.         case $h in
  2579.         a) i=b;;
  2580.         *) i=a
  2581.         esac
  2582.  
  2583.         # The compiler rejects some line in l..U.
  2584.         # Use binary search to set l to be the index of the first bad line in l..U.
  2585.         u=$U
  2586.         while test $l -lt $u
  2587.         do
  2588.                 M=`expr '(' $l + $u ')' / 2`
  2589.                 M1=`expr $M + 1`
  2590.                 sed "$M1,\$$commentOut" a.h$h >a.h$i || exit
  2591.                 if $CS -Dh=$i a.c $LS >&2
  2592.                 then l=$M1
  2593.                 else u=$M
  2594.                 fi
  2595.         done
  2596. d1664 2
  2597. a1665 2
  2598.         # Comment out the bad line.
  2599.         sed "$l$commentOut" a.h$h >a.h$i || exit
  2600. d1667 2
  2601. a1668 2
  2602.         h=$i
  2603.         l=`expr $l + 1`
  2604. @
  2605.