home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume28 / diffstat / part01 next >
Encoding:
Text File  |  1994-06-16  |  45.8 KB  |  1,727 lines

  1. Newsgroups: comp.sources.unix
  2. From: dickey@clark.net (T.E.Dickey)
  3. Subject: v28i064: diffstat - compute histograms of diff output, Part01/01
  4. Message-id: <1.771829971.3595@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: dickey@clark.net (T.E.Dickey)
  9. Posting-Number: Volume 28, Issue 64
  10. Archive-Name: diffstat/part01
  11.  
  12. This program is a simple filter that reads the output of the 'diff' program,
  13. and produces a histogram of the total number of lines that were changed.  It
  14. is useful for scanning a patch file to see which files were changed.
  15.  
  16. #!/bin/sh
  17. # This is diffstat, a shell archive (produced by shar 3.50)
  18. # To extract the files from this archive, save it to a file, remove
  19. # everything above the "!/bin/sh" line above, and type "sh file_name".
  20. #
  21. # made 06/15/1994 00:31 UTC by tom@dickey_ppp
  22. # Source directory /home/tom/src/misc/diffstat
  23. #
  24. # existing files will NOT be overwritten unless -c is specified
  25. #
  26. #                                                                          
  27. #                                                                          
  28. #
  29. # This shar contains:
  30. # length  mode       name
  31. # ------ ---------- ------------------------------------------
  32. #  24898 -rwxr-xr-x configure
  33. #    299 -r--r--r-- README
  34. #   8620 -r--r--r-- diffstat.c
  35. #   2467 -r--r--r-- diffstat.1
  36. #    249 -r--r--r-- config_h.in
  37. #    649 -r-xr-xr-x mkdirs.sh
  38. #   2152 -r--r--r-- makefile.in
  39. #    753 -r--r--r-- configure.in
  40. #
  41. TOUCH=true
  42. rm -f 1231235999
  43. if touch -am 1231235999 1231235970
  44. then
  45.  if test -f 1231235970 -a ! -f 1231235999
  46.   then TOUCH=touch
  47.  fi
  48. fi
  49. rm -f 1231235999 1231235970
  50. if test -r _shar_seq_.tmp; then
  51.     echo 'Must unpack archives in sequence!'
  52.     echo Please unpack part `cat _shar_seq_.tmp` next
  53.     exit 1
  54. fi
  55. # ============= configure ==============
  56. if test -f 'configure' -a X"$1" != X"-c"; then
  57.     echo 'x - skipping configure (File already exists)'
  58.     rm -f _shar_wnt_.tmp
  59. else
  60. > _shar_wnt_.tmp
  61. echo 'x - extracting configure (Text)'
  62. sed 's/^X//' << 'SHAR_EOF' > 'configure' &&
  63. #!/bin/sh
  64. # From configure.in Revision: 1.3 
  65. X
  66. #!/bin/sh
  67. # Guess values for system-dependent variables and create Makefiles.
  68. # Generated automatically using autoconf version 1.11 
  69. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  70. X
  71. # This configure script is free software; you can redistribute it and/or
  72. # modify it under the terms of the GNU General Public License as published
  73. # by the Free Software Foundation; either version 2, or (at your option)
  74. # any later version.
  75. X
  76. # This script is distributed in the hope that it will be useful, but
  77. # WITHOUT ANY WARRANTY; without even the implied warranty of
  78. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
  79. # Public License for more details.
  80. X
  81. # You should have received a copy of the GNU General Public License
  82. # along with this program; if not, write to the Free Software
  83. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  84. X
  85. # Save the original args to write them into config.status later.
  86. configure_args="$*"
  87. X
  88. # Only options that might do something get documented.
  89. ac_usage="Usage: configure [options] [host]
  90. Options: [defaults in brackets after descriptions]
  91. --build=BUILD        configure for building on BUILD [BUILD=HOST]
  92. --disable-FEATURE    do not include FEATURE (same as --enable-FEATURE=no)
  93. --enable-FEATURE[=ARG]    include FEATURE [ARG=yes]
  94. --exec-prefix=PREFIX    install host dependent files in PREFIX [/usr/local]
  95. --help            print this message
  96. --host=HOST        configure for HOST [guessed]
  97. --prefix=PREFIX        install host independent files in PREFIX [/usr/local]
  98. --quiet, --silent    do not print \`checking for...' messages
  99. --srcdir=DIR        find the sources in DIR [configure dir or ..]
  100. --target=TARGET        configure for TARGET [TARGET=HOST]
  101. --verbose        print results of checks
  102. --version        print the version of autoconf that created configure
  103. --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  104. --without-PACKAGE    do not use PACKAGE (same as --with-PACKAGE=no)
  105. --x-includes=DIR    X include files are in DIR
  106. --x-libraries=DIR    X library files are in DIR"
  107. X
  108. # Initialize some variables set by options.
  109. # The variables have the same names as the options, with
  110. # dashes changed to underlines.
  111. build=NONE
  112. exec_prefix=
  113. host=NONE
  114. no_create=
  115. nonopt=NONE
  116. norecursion=
  117. prefix=
  118. program_prefix=
  119. program_suffix=
  120. program_transform_name=
  121. silent=
  122. srcdir=
  123. target=NONE
  124. verbose=
  125. x_includes=
  126. x_libraries=
  127. X
  128. ac_prev=
  129. for ac_option
  130. do
  131. X
  132. X  # If the previous option needs an argument, assign it.
  133. X  if test -n "$ac_prev"; then
  134. X    eval "$ac_prev=\$ac_option"
  135. X    ac_prev=
  136. X    continue
  137. X  fi
  138. X
  139. X  # Accept (but ignore some of) the important Cygnus configure
  140. X  # options, so we can diagnose typos.
  141. X
  142. X  case "$ac_option" in
  143. X  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  144. X  *) ac_optarg= ;;
  145. X  esac
  146. X
  147. X  case "$ac_option" in
  148. X
  149. X  -build | --build | --buil | --bui | --bu | --b)
  150. X    ac_prev=build ;;
  151. X  -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*)
  152. X    build="$ac_optarg" ;;
  153. X
  154. X  -disable-* | --disable-*)
  155. X    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
  156. X    # Reject names that aren't valid shell variable names.
  157. X    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
  158. X      echo "configure: $ac_feature: invalid feature name" >&2; exit 1
  159. X    fi
  160. X    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
  161. X    eval "enable_${ac_feature}=no" ;;
  162. X
  163. X  -enable-* | --enable-*)
  164. X    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
  165. X    # Reject names that aren't valid shell variable names.
  166. X    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
  167. X      echo "configure: $ac_feature: invalid feature name" >&2; exit 1
  168. X    fi
  169. X    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
  170. X    case "$ac_option" in
  171. X      *=*) ;;
  172. X      *) ac_optarg=yes ;;
  173. X    esac
  174. X    eval "enable_${ac_feature}='$ac_optarg'" ;;
  175. X
  176. X  # For backward compatibility, recognize -exec-prefix and --exec_prefix.
  177. X  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  178. X  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  179. X  | --exec | --exe | --ex)
  180. X    ac_prev=exec_prefix ;;
  181. X  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  182. X  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  183. X  | --exec=* | --exe=* | --ex=*)
  184. X    exec_prefix="$ac_optarg" ;;
  185. X
  186. X  -gas | --gas | --ga | --g)
  187. X    with_gas=yes ;; # Obsolete; use --with-gas.
  188. X
  189. X  -help | --help | --hel | --he)
  190. X    cat << EOF
  191. $ac_usage
  192. EOF
  193. X    exit 0 ;;
  194. X
  195. X  -host | --host | --hos | --ho)
  196. X    ac_prev=host ;;
  197. X  -host=* | --host=* | --hos=* | --ho=*)
  198. X    host="$ac_optarg" ;;
  199. X
  200. X  -nfp | --nfp | --nf)
  201. X    with_fp=no ;; # Obsolete; use --without-fp.
  202. X
  203. X  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  204. X  | --no-cr | --no-c)
  205. X    no_create=yes ;;
  206. X
  207. X  -norecursion | --norecursion | --norecursio | --norecursi \
  208. X  | --norecurs | --norecur | --norecu | --norec | --nore | --nor)
  209. X    norecursion=yes ;;
  210. X
  211. X  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  212. X    ac_prev=prefix ;;
  213. X  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  214. X    prefix="$ac_optarg" ;;
  215. X
  216. X  -program-prefix | --program-prefix | --program-prefi | --program-pref \
  217. X  | --program-pre | --program-pr | --program-p)
  218. X    ac_prev=program_prefix ;;
  219. X  -program-prefix=* | --program-prefix=* | --program-prefi=* \
  220. X  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
  221. X    program_prefix="$ac_optarg" ;;
  222. X
  223. X  -program-suffix | --program-suffix | --program-suffi | --program-suff \
  224. X  | --program-suf | --program-su | --program-s)
  225. X    ac_prev=program_suffix ;;
  226. X  -program-suffix=* | --program-suffix=* | --program-suffi=* \
  227. X  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
  228. X    program_suffix="$ac_optarg" ;;
  229. X
  230. X  -program-transform-name | --program-transform-name \
  231. X  | --program-transform-nam | --program-transform-na \
  232. X  | --program-transform-n | --program-transform- \
  233. X  | --program-transform | --program-transfor \
  234. X  | --program-transfo | --program-transf \
  235. X  | --program-trans | --program-tran \
  236. X  | --progr-tra | --program-tr | --program-t)
  237. X    ac_prev=program_transform_name ;;
  238. X  -program-transform-name=* | --program-transform-name=* \
  239. X  | --program-transform-nam=* | --program-transform-na=* \
  240. X  | --program-transform-n=* | --program-transform-=* \
  241. X  | --program-transform=* | --program-transfor=* \
  242. X  | --program-transfo=* | --program-transf=* \
  243. X  | --program-trans=* | --program-tran=* \
  244. X  | --progr-tra=* | --program-tr=* | --program-t=*)
  245. X    program_transform_name="$ac_optarg" ;;
  246. X
  247. X  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  248. X  | -silent | --silent | --silen | --sile | --sil)
  249. X    silent=yes ;;
  250. X
  251. X  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  252. X    ac_prev=srcdir ;;
  253. X  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  254. X    srcdir="$ac_optarg" ;;
  255. X
  256. X  -target | --target | --targe | --targ | --tar | --ta | --t)
  257. X    ac_prev=target ;;
  258. X  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
  259. X    target="$ac_optarg" ;;
  260. X
  261. X  -v | -verbose | --verbose | --verbos | --verbo | --verb)
  262. X    verbose=yes ;;
  263. X
  264. X  -version | --version | --versio | --versi | --vers)
  265. X    echo "configure generated by autoconf version 1.11"
  266. X    exit 0 ;;
  267. X
  268. X  -with-* | --with-*)
  269. X    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
  270. X    # Reject names that aren't valid shell variable names.
  271. X    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
  272. X      echo "configure: $ac_package: invalid package name" >&2; exit 1
  273. X    fi
  274. X    ac_package=`echo $ac_package| sed 's/-/_/g'`
  275. X    case "$ac_option" in
  276. X      *=*) ;;
  277. X      *) ac_optarg=yes ;;
  278. X    esac
  279. X    eval "with_${ac_package}='$ac_optarg'" ;;
  280. X
  281. X  -without-* | --without-*)
  282. X    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
  283. X    # Reject names that aren't valid shell variable names.
  284. X    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
  285. X      echo "configure: $ac_package: invalid package name" >&2; exit 1
  286. X    fi
  287. X    ac_package=`echo $ac_package| sed 's/-/_/g'`
  288. X    eval "with_${ac_package}=no" ;;
  289. X
  290. X  --x) with_x=yes ;; # Obsolete; use --with-x.
  291. X
  292. X  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
  293. X  | --x-incl | --x-inc | --x-in | --x-i)
  294. X    ac_prev=x_includes ;;
  295. X  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
  296. X  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
  297. X    x_includes="$ac_optarg" ;;
  298. X
  299. X  -x-libraries | --x-libraries | --x-librarie | --x-librari \
  300. X  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
  301. X    ac_prev=x_libraries ;;
  302. X  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
  303. X  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
  304. X    x_libraries="$ac_optarg" ;;
  305. X
  306. X  -*) echo "configure: $ac_option: invalid option; use --help to show usage" >&2; exit 1
  307. X    ;;
  308. X
  309. X  *) 
  310. X    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
  311. X      echo "configure: warning: $ac_option: invalid host type" >&2
  312. X    fi
  313. X    if test "x$nonopt" != xNONE; then
  314. X      echo "configure: can only configure for one host and one target at a time" >&2; exit 1
  315. X    fi
  316. X    nonopt="$ac_option"
  317. X    ;;
  318. X
  319. X  esac
  320. done
  321. X
  322. if test -n "$ac_prev"; then
  323. X  echo "configure: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" >&2; exit 1
  324. fi
  325. X
  326. trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15
  327. trap 'rm -fr confdefs* $ac_clean_files' 0
  328. X
  329. # Save the original args if we used an alternate arg parser.
  330. ac_configure_temp="${configure_args-$*}"
  331. # Strip out --no-create and --norecursion so they don't pile up.
  332. configure_args=
  333. for ac_arg in $ac_configure_temp; do
  334. X  case "$ac_arg" in
  335. X  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  336. X  | --no-cr | --no-c) ;;
  337. X  -norecursion | --norecursion | --norecursio | --norecursi \
  338. X  | --norecurs | --norecur | --norecu | --norec | --nore | --nor) ;;
  339. X  *) configure_args="$configure_args $ac_arg" ;;
  340. X  esac
  341. done
  342. X
  343. # NLS nuisances.
  344. # These must not be set unconditionally because not all systems understand
  345. # e.g. LANG=C (notably SCO).
  346. if test "${LC_ALL+set}" = 'set'; then LC_ALL=C; export LC_ALL; fi
  347. if test "${LANG+set}"   = 'set'; then LANG=C;   export LANG;   fi
  348. X
  349. # confdefs.h avoids OS command line length limits that DEFS can exceed.
  350. rm -rf conftest* confdefs.h
  351. # AIX cpp loses on an empty file, so make sure it contains at least a newline.
  352. echo > confdefs.h
  353. X
  354. # A filename unique to this package, relative to the directory that
  355. # configure is in, which we can look for to find out if srcdir is correct.
  356. ac_unique_file=diffstat.c
  357. X
  358. # Find the source files, if location was not specified.
  359. if test -z "$srcdir"; then
  360. X  ac_srcdir_defaulted=yes
  361. X  # Try the directory containing this script, then `..'.
  362. X  ac_prog=$0
  363. X  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
  364. X  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
  365. X  srcdir=$ac_confdir
  366. X  if test ! -r $srcdir/$ac_unique_file; then
  367. X    srcdir=..
  368. X  fi
  369. fi
  370. if test ! -r $srcdir/$ac_unique_file; then
  371. X  if test x$ac_srcdir_defaulted = xyes; then
  372. X    echo "configure: can not find sources in ${ac_confdir} or .." >&2; exit 1
  373. X  else
  374. X    echo "configure: can not find sources in ${srcdir}" >&2; exit 1
  375. X  fi
  376. fi
  377. ac_ext=c
  378. # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
  379. ac_cpp='${CPP}'
  380. ac_compile='${CC-cc} $CFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS >/dev/null 2>&1'
  381. X
  382. X
  383. if test -z "$CC"; then
  384. X  # Extract the first word of `gcc', so it can be a program name with args.
  385. X  set ac_dummy gcc; ac_word=$2
  386. X  test -n "$silent" || echo "checking for $ac_word"
  387. X  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  388. X  for ac_dir in $PATH; do
  389. X    test -z "$ac_dir" && ac_dir=.
  390. X    if test -f $ac_dir/$ac_word; then
  391. X      CC="gcc"
  392. X      break
  393. X    fi
  394. X  done
  395. X  IFS="$ac_save_ifs"
  396. fi
  397. test -z "$CC" && CC="cc"
  398. test -n "$CC" && test -n "$verbose" && echo "    setting CC to $CC"
  399. X
  400. # Find out if we are using GNU C, under whatever name.
  401. cat > conftest.c <<EOF
  402. #ifdef __GNUC__
  403. X  yes
  404. #endif
  405. EOF
  406. ${CC-cc} -E conftest.c > conftest.out 2>&1
  407. if egrep yes conftest.out >/dev/null 2>&1; then
  408. X  GCC=1 # For later tests.
  409. fi
  410. rm -f conftest*
  411. X
  412. # Make sure to not get the incompatible SysV /etc/install and
  413. # /usr/sbin/install, which might be in PATH before a BSD-like install,
  414. # or the SunOS /usr/etc/install directory, or the AIX /bin/install,
  415. # or the AFS install, which mishandles nonexistent args, or
  416. # /usr/ucb/install on SVR4, which tries to use the nonexistent group
  417. # `staff', or /sbin/install on IRIX which has incompatible command-line
  418. # syntax.  Sigh.
  419. #
  420. #     On most BSDish systems install is in /usr/bin, not /usr/ucb
  421. #     anyway.
  422. # This turns out not to be true, so the mere pathname isn't an indication
  423. # of whether the program works.  What we really need is a set of tests for
  424. # the install program to see if it actually works in all the required ways.
  425. #
  426. # Avoid using ./install, which might have been erroneously created
  427. # by make from ./install.sh.
  428. if test -z "${INSTALL}"; then
  429. X  test -n "$silent" || echo "checking for a BSD compatible install"
  430. X  IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  431. X  for ac_dir in $PATH; do
  432. X    case "$ac_dir" in
  433. X    ''|.|/etc|/sbin|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
  434. X    *)
  435. X      # OSF1 and SCO ODT 3.0 have their own names for install.
  436. X      for ac_prog in installbsd scoinst install; do
  437. X        if test -f $ac_dir/$ac_prog; then
  438. X      if test $ac_prog = install &&
  439. X            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  440. X        # AIX install.  It has an incompatible calling convention.
  441. X        # OSF/1 installbsd also uses dspmsg, but is usable.
  442. X        :
  443. X      else
  444. X        INSTALL="$ac_dir/$ac_prog -c"
  445. X        break 2
  446. X      fi
  447. X    fi
  448. X      done
  449. X      ;;
  450. X    esac
  451. X  done
  452. X  IFS="$ac_save_ifs"
  453. fi
  454. X
  455. if test -z "$INSTALL"; then
  456. X  # As a last resort, use the slow shell script.
  457. X  for ac_dir in ${srcdir} ${srcdir}/.. ${srcdir}/../..; do
  458. X    if test -f $ac_dir/install.sh; then
  459. X      INSTALL="$ac_dir/install.sh -c"; break
  460. X    fi
  461. X  done
  462. fi
  463. if test -z "$INSTALL"; then
  464. X  echo "configure: can not find install.sh in ${srcdir} or ${srcdir}/.. or ${srcdir}/../.." >&2; exit 1
  465. fi
  466. test -n "$verbose" && echo "    setting INSTALL to $INSTALL"
  467. X
  468. # Use test -z because SunOS4 sh mishandles ${INSTALL_PROGRAM-'${INSTALL}'}.
  469. # It thinks the first close brace ends the variable substitution.
  470. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  471. test -n "$verbose" && echo "    setting INSTALL_PROGRAM to $INSTALL_PROGRAM"
  472. X
  473. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  474. test -n "$verbose" && echo "    setting INSTALL_DATA to $INSTALL_DATA"
  475. X
  476. test -n "$silent" || echo "checking how to run the C preprocessor"
  477. if test -z "$CPP"; then
  478. X  # This must be in double quotes, not single quotes, because CPP may get
  479. X  # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  480. X  # make.  It must be expanded now.
  481. X  CPP="${CC-cc} -E"
  482. X  cat > conftest.${ac_ext} <<EOF
  483. #include "confdefs.h"
  484. #include <stdio.h>
  485. Syntax Error
  486. EOF
  487. # Some shells (Coherent) do redirections in the wrong order, so need
  488. # the parens.
  489. ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  490. if test -z "$ac_err"; then
  491. X  :
  492. else
  493. X  rm -rf conftest*
  494. X  CPP="${CC-cc} -E -traditional-cpp"
  495. X  cat > conftest.${ac_ext} <<EOF
  496. #include "confdefs.h"
  497. #include <stdio.h>
  498. Syntax Error
  499. EOF
  500. # Some shells (Coherent) do redirections in the wrong order, so need
  501. # the parens.
  502. ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  503. if test -z "$ac_err"; then
  504. X  :
  505. else
  506. X  rm -rf conftest*
  507. X  CPP=/lib/cpp
  508. fi
  509. rm -f conftest*
  510. fi
  511. rm -f conftest*
  512. fi
  513. test -n "$verbose" && echo "    setting CPP to $CPP"
  514. X
  515. if test -n "$GCC"; then
  516. X  test -n "$silent" || echo "checking whether -traditional is needed"
  517. X  ac_pattern="Autoconf.*'x'"
  518. X  ac_prog='#include <sgtty.h>
  519. Autoconf TIOCGETP'
  520. X  cat > conftest.${ac_ext} <<EOF
  521. #include "confdefs.h"
  522. $ac_prog
  523. EOF
  524. eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1"
  525. if egrep "$ac_pattern" conftest.out >/dev/null 2>&1; then
  526. X  rm -rf conftest*
  527. X  ac_need_trad=1
  528. X
  529. fi
  530. rm -f conftest*
  531. X
  532. X
  533. X  if test -z "$ac_need_trad"; then
  534. X    ac_prog='#include <termio.h>
  535. Autoconf TCGETA'
  536. X    cat > conftest.${ac_ext} <<EOF
  537. #include "confdefs.h"
  538. $ac_prog
  539. EOF
  540. eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1"
  541. if egrep "$ac_pattern" conftest.out >/dev/null 2>&1; then
  542. X  rm -rf conftest*
  543. X  ac_need_trad=1
  544. X
  545. fi
  546. rm -f conftest*
  547. X
  548. X  fi
  549. X  test -n "$ac_need_trad" && CC="$CC -traditional"
  550. fi
  551. X
  552. X
  553. if test -n "$GCC"
  554. then
  555. CFLAGS='-O -Wall -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes'
  556. fi
  557. X
  558. X
  559. X
  560. ac_prog='/* Ultrix mips cc rejects this.  */
  561. typedef int charset[2]; const charset x;
  562. /* SunOS 4.1.1 cc rejects this.  */
  563. char const *const *ccp;
  564. char **p;
  565. /* AIX XL C 1.02.0.0 rejects this.
  566. X   It does not let you subtract one const X* pointer from another in an arm
  567. X   of an if-expression whose if-part is not a constant expression */
  568. const char *g = "string";
  569. ccp = &g + (g ? g-g : 0);
  570. /* HPUX 7.0 cc rejects these. */
  571. ++ccp;
  572. p = (char**) ccp;
  573. ccp = (char const *const *) p;
  574. { /* SCO 3.2v4 cc rejects this.  */
  575. X  char *t;
  576. X  char const *s = 0 ? (char *) 0 : (char const *) 0;
  577. X
  578. X  *t++ = 0;
  579. }
  580. { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  581. X  int x[] = {25,17};
  582. X  const int *foo = &x[0];
  583. X  ++foo;
  584. }
  585. { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  586. X  typedef const int *iptr;
  587. X  iptr p = 0;
  588. X  ++p;
  589. }
  590. { /* AIX XL C 1.02.0.0 rejects this saying
  591. X     "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  592. X  struct s { int j; const int *ap[3]; };
  593. X  struct s *b; b->j = 5;
  594. }
  595. { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  596. X  const int foo = 10;
  597. }'
  598. test -n "$silent" || echo "checking for lack of working const"
  599. cat > conftest.${ac_ext} <<EOF
  600. #include "confdefs.h"
  601. X
  602. int main() { return 0; }
  603. int t() { $ac_prog; return 0; }
  604. EOF
  605. if eval $ac_compile; then
  606. X  :
  607. else
  608. X  rm -rf conftest*
  609. X  
  610. {
  611. test -n "$verbose" && \
  612. echo "    defining" const to be empty
  613. echo "#define" const "" >> confdefs.h
  614. DEFS="$DEFS -Dconst="
  615. }
  616. X
  617. fi
  618. rm -f conftest*
  619. X
  620. test -n "$silent" || echo "checking for ANSI C header files"
  621. cat > conftest.${ac_ext} <<EOF
  622. #include "confdefs.h"
  623. #include <stdlib.h>
  624. #include <stdarg.h>
  625. #include <string.h>
  626. #include <float.h>
  627. EOF
  628. # Some shells (Coherent) do redirections in the wrong order, so need
  629. # the parens.
  630. ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  631. if test -z "$ac_err"; then
  632. X  rm -rf conftest*
  633. X  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  634. echo '#include "confdefs.h"
  635. #include <string.h>' > conftest.${ac_ext}
  636. eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1"
  637. if egrep "memchr" conftest.out >/dev/null 2>&1; then
  638. X  rm -rf conftest*
  639. X  # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  640. cat > conftest.${ac_ext} <<EOF
  641. #include "confdefs.h"
  642. #include <ctype.h>
  643. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  644. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  645. #define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
  646. int main () { int i; for (i = 0; i < 256; i++)
  647. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  648. exit (0); }
  649. X
  650. EOF
  651. eval $ac_compile
  652. if test -s conftest && (./conftest; exit) 2>/dev/null; then
  653. X  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  654. echo '#include "confdefs.h"
  655. #include <stdlib.h>' > conftest.${ac_ext}
  656. eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1"
  657. if egrep "free" conftest.out >/dev/null 2>&1; then
  658. X  rm -rf conftest*
  659. X  
  660. {
  661. test -n "$verbose" && \
  662. echo "    defining STDC_HEADERS"
  663. echo "#define" STDC_HEADERS "1" >> confdefs.h
  664. DEFS="$DEFS -DSTDC_HEADERS=1"
  665. }
  666. X
  667. X
  668. fi
  669. rm -f conftest*
  670. X
  671. X
  672. fi
  673. rm -fr conftest*
  674. X
  675. fi
  676. rm -f conftest*
  677. X
  678. X
  679. fi
  680. rm -f conftest*
  681. X
  682. for ac_hdr in stdlib.h unistd.h
  683. do
  684. ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
  685. test -n "$silent" || echo "checking for ${ac_hdr}"
  686. cat > conftest.${ac_ext} <<EOF
  687. #include "confdefs.h"
  688. #include <${ac_hdr}>
  689. EOF
  690. # Some shells (Coherent) do redirections in the wrong order, so need
  691. # the parens.
  692. ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  693. if test -z "$ac_err"; then
  694. X  rm -rf conftest*
  695. X  
  696. {
  697. test -n "$verbose" && \
  698. echo "    defining ${ac_tr_hdr}"
  699. echo "#define" ${ac_tr_hdr} "1" >> confdefs.h
  700. DEFS="$DEFS -D${ac_tr_hdr}=1"
  701. }
  702. X
  703. X
  704. fi
  705. rm -f conftest*
  706. done
  707. X
  708. for ac_hdr in getopt.h string.h malloc.h
  709. do
  710. ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
  711. test -n "$silent" || echo "checking for ${ac_hdr}"
  712. cat > conftest.${ac_ext} <<EOF
  713. #include "confdefs.h"
  714. #include <${ac_hdr}>
  715. EOF
  716. # Some shells (Coherent) do redirections in the wrong order, so need
  717. # the parens.
  718. ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  719. if test -z "$ac_err"; then
  720. X  rm -rf conftest*
  721. X  
  722. {
  723. test -n "$verbose" && \
  724. echo "    defining ${ac_tr_hdr}"
  725. echo "#define" ${ac_tr_hdr} "1" >> confdefs.h
  726. DEFS="$DEFS -D${ac_tr_hdr}=1"
  727. }
  728. X
  729. X
  730. fi
  731. rm -f conftest*
  732. done
  733. X
  734. X
  735. ###    output makefile and config.h
  736. X
  737. # The preferred way to propogate these variables is regular @ substitutions.
  738. if test -n "$prefix"; then
  739. X  ac_prsub="s%^prefix\\([     ]*\\)=\\([     ]*\\).*$%prefix\\1=\\2$prefix%"
  740. else
  741. X  prefix=/usr/local
  742. fi
  743. if test -n "$exec_prefix"; then
  744. X  ac_prsub="$ac_prsub
  745. s%^exec_prefix\\([     ]*\\)=\\([     ]*\\).*$%exec_prefix\\1=\\2$exec_prefix%"
  746. else
  747. X  exec_prefix='${prefix}' # Let make expand it.
  748. fi
  749. X
  750. # Any assignment to VPATH causes Sun make to only execute
  751. # the first set of double-colon rules, so remove it if not needed.
  752. # If there is a colon in the path, we need to keep it.
  753. if test "x$srcdir" = x.; then
  754. X  ac_vpsub='/^[     ]*VPATH[     ]*=[^:]*$/d'
  755. fi
  756. X
  757. # Quote sed substitution magic chars in DEFS.
  758. cat >conftest.def <<EOF
  759. $DEFS
  760. EOF
  761. ac_escape_ampersand_and_backslash='s%[&\\]%\\&%g'
  762. DEFS=`sed "$ac_escape_ampersand_and_backslash" <conftest.def`
  763. rm -f conftest.def
  764. # Substitute for predefined variables.
  765. X
  766. trap 'rm -f config.status; exit 1' 1 2 15
  767. echo creating config.status
  768. rm -f config.status
  769. cat > config.status <<EOF
  770. #!/bin/sh
  771. # Generated automatically by configure.
  772. # Run this file to recreate the current configuration.
  773. # This directory was configured as follows,
  774. # on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
  775. #
  776. # $0 $configure_args
  777. X
  778. ac_cs_usage="Usage: config.status [--recheck] [--version] [--help]"
  779. for ac_option
  780. do
  781. X  case "\$ac_option" in
  782. X  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
  783. X    echo running \${CONFIG_SHELL-/bin/sh} $0 $configure_args --no-create
  784. X    exec \${CONFIG_SHELL-/bin/sh} $0 $configure_args --no-create ;;
  785. X  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
  786. X    echo "config.status generated by autoconf version 1.11"
  787. X    exit 0 ;;
  788. X  -help | --help | --hel | --he | --h)
  789. X    echo "\$ac_cs_usage"; exit 0 ;;
  790. X  *) echo "\$ac_cs_usage"; exit 1 ;;
  791. X  esac
  792. done
  793. X
  794. trap 'rm -f makefile config_h; exit 1' 1 2 15
  795. CC='$CC'
  796. INSTALL='$INSTALL'
  797. INSTALL_PROGRAM='$INSTALL_PROGRAM'
  798. INSTALL_DATA='$INSTALL_DATA'
  799. CPP='$CPP'
  800. CFLAGS='$CFLAGS'
  801. LIBS='$LIBS'
  802. srcdir='$srcdir'
  803. top_srcdir='$top_srcdir'
  804. prefix='$prefix'
  805. exec_prefix='$exec_prefix'
  806. DEFS='$DEFS'
  807. ac_prsub='$ac_prsub'
  808. ac_vpsub='$ac_vpsub'
  809. extrasub='$extrasub'
  810. EOF
  811. cat >> config.status <<\EOF
  812. X
  813. ac_given_srcdir=$srcdir
  814. X
  815. CONFIG_FILES=${CONFIG_FILES-"makefile config_h"}
  816. for ac_file in .. ${CONFIG_FILES}; do if test "x$ac_file" != x..; then
  817. X  # Remove last slash and all that follows it.  Not all systems have dirname.
  818. X  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
  819. X  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
  820. X    # The file is in a subdirectory.
  821. X    test ! -d "$ac_dir" && mkdir "$ac_dir"
  822. X    ac_dir_suffix="/$ac_dir"
  823. X  else
  824. X    ac_dir_suffix=
  825. X  fi
  826. X
  827. X  # A "../" for each directory in $ac_dir_suffix.
  828. X  ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
  829. X  case "$ac_given_srcdir" in
  830. X  .)  srcdir=.
  831. X      if test -z "$ac_dir_suffix"; then top_srcdir=.
  832. X      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
  833. X  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
  834. X  *) # Relative path.
  835. X    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
  836. X    top_srcdir="$ac_dots$ac_given_srcdir" ;;
  837. X  esac
  838. X
  839. X  echo creating "$ac_file"
  840. X  rm -f "$ac_file"
  841. X  comment_str="Generated automatically from `echo $ac_file|sed 's|.*/||'`.in by configure."
  842. X  case "$ac_file" in
  843. X    *.c | *.h | *.C | *.cc | *.m )  echo "/* $comment_str */" > "$ac_file" ;;
  844. X    * )          echo "# $comment_str"     > "$ac_file" ;;
  845. X  esac
  846. X  sed -e "
  847. $ac_prsub
  848. $ac_vpsub
  849. $extrasub
  850. s%@CC@%$CC%g
  851. s%@INSTALL@%$INSTALL%g
  852. s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
  853. s%@INSTALL_DATA@%$INSTALL_DATA%g
  854. s%@CPP@%$CPP%g
  855. s%@CFLAGS@%$CFLAGS%g
  856. s%@LIBS@%$LIBS%g
  857. s%@srcdir@%$srcdir%g
  858. s%@top_srcdir@%$top_srcdir%g
  859. s%@prefix@%$prefix%g
  860. s%@exec_prefix@%$exec_prefix%g
  861. s%@DEFS@%$DEFS%
  862. " $ac_given_srcdir/${ac_file}.in >> $ac_file
  863. fi; done
  864. X
  865. X
  866. echo creating config.h
  867. sed    -e '/^# /d' \
  868. X    -e 's/ -D/\
  869. #define /g' \
  870. X    -e 's/\(#define [A-Za-z_][A-Za-z0-9_]*\)=/\1    /g' \
  871. X    config_h >config.h
  872. X
  873. echo removing config_h
  874. rm config_h
  875. X
  876. Xexit 0
  877. EOF
  878. chmod +x config.status
  879. # Some shells look in PATH for config.status without the "./".
  880. test -n "$no_create" || ${CONFIG_SHELL-/bin/sh} ./config.status
  881. X
  882. SHAR_EOF
  883. $TOUCH -am 0613210094 'configure' &&
  884. chmod 0755 configure ||
  885. echo 'restore of configure failed'
  886. Wc_c="`wc -c < 'configure'`"
  887. test 24898 -eq "$Wc_c" ||
  888.     echo 'configure: original size 24898, current size' "$Wc_c"
  889. rm -f _shar_wnt_.tmp
  890. fi
  891. # ============= README ==============
  892. if test -f 'README' -a X"$1" != X"-c"; then
  893.     echo 'x - skipping README (File already exists)'
  894.     rm -f _shar_wnt_.tmp
  895. else
  896. > _shar_wnt_.tmp
  897. echo 'x - extracting README (Text)'
  898. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  899. $Id: README,v 1.2 1994/06/13 23:43:17 tom Exp $
  900. X
  901. Readme file for DiffStat.
  902. X
  903. This program is a simple filter that reads the output of the 'diff' program,
  904. and produces a histogram of the total number of lines that were changed.  It is
  905. useful for scanning a patch file to see which files were changed.
  906. SHAR_EOF
  907. $TOUCH -am 0613194394 'README' &&
  908. chmod 0444 README ||
  909. echo 'restore of README failed'
  910. Wc_c="`wc -c < 'README'`"
  911. test 299 -eq "$Wc_c" ||
  912.     echo 'README: original size 299, current size' "$Wc_c"
  913. rm -f _shar_wnt_.tmp
  914. fi
  915. # ============= diffstat.c ==============
  916. if test -f 'diffstat.c' -a X"$1" != X"-c"; then
  917.     echo 'x - skipping diffstat.c (File already exists)'
  918.     rm -f _shar_wnt_.tmp
  919. else
  920. > _shar_wnt_.tmp
  921. echo 'x - extracting diffstat.c (Text)'
  922. sed 's/^X//' << 'SHAR_EOF' > 'diffstat.c' &&
  923. /******************************************************************************
  924. X * Copyright (c) 1994 by Thomas E. Dickey.  All Rights Reserved.              *
  925. X *                                                                            *
  926. X * You may freely copy or redistribute this software, so long as there is no  *
  927. X * profit made from its use, sale trade or reproduction. You may not change   *
  928. X * this copyright notice, and it must be included in any copy made.           *
  929. X ******************************************************************************/
  930. #if    !defined(NO_IDENT)
  931. static    char    *Id = "$Id: diffstat.c,v 1.12 1994/06/13 00:43:20 tom Exp $";
  932. #endif
  933. X
  934. /*
  935. X * Title:    diffstat.c
  936. X * Author:    T.E.Dickey
  937. X * Created:    02 Feb 1992
  938. X * Modified:
  939. X *        12 Jun 1994, recognize unified diff, and output of makepatch.
  940. X *        04 Oct 1993, merge multiple diff-files, busy message when the
  941. X *                 output is piped to a file.
  942. X *
  943. X * Function:    this program reads the output of 'diff' and displays a histogram
  944. X *        of the insertions/deletions/modifications per-file.
  945. X */
  946. X
  947. #if    defined(HAVE_CONFIG_H)
  948. #include "config.h"
  949. #endif
  950. X
  951. #include <stdio.h>
  952. #include <string.h>
  953. #include <ctype.h>
  954. X
  955. #if HAVE_STDLIB_H
  956. #include <stdlib.h>
  957. #else
  958. extern    int    atoi();
  959. #endif
  960. X
  961. #if HAVE_UNISTD_H
  962. #include <unistd.h>
  963. #else
  964. extern int    isatty();
  965. #endif
  966. X
  967. #if HAVE_MALLOC_H
  968. #include <malloc.h>
  969. #else
  970. extern    char    *malloc();
  971. #endif
  972. X
  973. #if HAVE_GETOPT_H
  974. #include <getopt.h>
  975. #else
  976. extern    int    getopt();
  977. extern    char    *optarg;
  978. extern    int    optind;
  979. #endif
  980. X
  981. #if !defined(TRUE) || (TRUE != 1)
  982. #undef  TRUE
  983. #undef  FALSE
  984. #define    TRUE        1
  985. #define    FALSE        0
  986. #endif
  987. X
  988. #if !defined(EXIT_SUCCESS)
  989. #define EXIT_SUCCESS 0
  990. #define EXIT_FAILURE 1
  991. #endif
  992. X
  993. /******************************************************************************/
  994. X
  995. #define PATHSEP '/'
  996. #define EOS     '\0'
  997. #define BLANK   ' '
  998. X
  999. typedef    enum comment { Normal, Only, Binary } Comment;
  1000. X
  1001. typedef    struct    _data    {
  1002. X    struct    _data    *link;
  1003. X    char        *name;
  1004. X    Comment        cmt;
  1005. X    long        ins,    /* "+" count inserted lines */
  1006. X            del,    /* "-" count deleted lines */
  1007. X            mod;    /* "!" count modified lines */
  1008. X    } DATA;
  1009. X
  1010. static    DATA    *all_data;
  1011. static    int    piped_output;
  1012. static    int    max_width;    /* the specified width-limit */
  1013. static    int    name_wide;    /* the amount reserved for filenames */
  1014. static    int    plot_width;    /* the amount left over for histogram */
  1015. X
  1016. /******************************************************************************/
  1017. #if    __STDC__
  1018. static    void    failed (char *s);
  1019. static    void    blip (int c);
  1020. static    char *    new_string(char *s);
  1021. static    DATA *    new_data(char *name);
  1022. static    int    match(char *s, char *p);
  1023. static    void    do_file(FILE *fp);
  1024. static    void    plot(long num, long max, int c);
  1025. static    void    summarize(void);
  1026. static    void    usage(void);
  1027. X    int    main(int argc, char *argv[]);
  1028. #endif
  1029. /******************************************************************************/
  1030. X
  1031. static
  1032. void    failed(s)
  1033. X    char    *s;
  1034. {
  1035. X    perror(s);
  1036. X    exit(EXIT_FAILURE);
  1037. }
  1038. X
  1039. static
  1040. void    blip(c)
  1041. X    int    c;
  1042. {
  1043. X    if (piped_output) {
  1044. X        (void)fputc(c, stderr);
  1045. X        (void)fflush(stderr);
  1046. X    }
  1047. }
  1048. X
  1049. static
  1050. char *    new_string(s)
  1051. X    char    *s;
  1052. {
  1053. X    return strcpy(malloc((unsigned)(strlen(s)+1)), s);
  1054. }
  1055. X
  1056. static
  1057. DATA *    new_data(name)
  1058. X    char    *name;
  1059. {
  1060. X    register DATA *p, *q, *r;
  1061. X
  1062. X    /* insert into sorted list */
  1063. X    for (p = all_data, q = 0; p != 0; q = p, p = p->link) {
  1064. X        int    cmp = strcmp(p->name, name);
  1065. X        if (cmp == 0)
  1066. X            return p;
  1067. X        if (cmp > 0) {
  1068. X            break;
  1069. X        }
  1070. X    }
  1071. X    r = (DATA *)malloc(sizeof(DATA));
  1072. X    if (q != 0)
  1073. X        q->link = r;
  1074. X    else
  1075. X        all_data = r;
  1076. X
  1077. X    r->link = p;
  1078. X    r->name = new_string(name);
  1079. X    r->cmt = Normal;
  1080. X    r->ins =
  1081. X    r->del =
  1082. X    r->mod = 0;
  1083. X
  1084. X    return r;
  1085. }
  1086. X
  1087. /* like strncmp, but without the 3rd argument */
  1088. static
  1089. int    match(s, p)
  1090. X    char    *s;
  1091. X    char    *p;
  1092. {
  1093. X    while (*s != EOS) {
  1094. X        if (*p == EOS)
  1095. X            break;
  1096. X        if (*s++ != *p++)
  1097. X            return FALSE;
  1098. X    }
  1099. X    return TRUE;
  1100. }
  1101. X
  1102. static
  1103. void    do_file(fp)
  1104. X    FILE    *fp;
  1105. {
  1106. X    DATA    dummy, *this = &dummy;
  1107. X    char    buffer[BUFSIZ];
  1108. X    int    ok = FALSE;
  1109. X    register char *s;
  1110. X
  1111. X    while (fgets(buffer, sizeof(buffer), fp)) {
  1112. X        for (s = buffer + strlen(buffer); s > buffer; s--) {
  1113. X            if (isspace(s[-1]))
  1114. X                s[-1] = EOS;
  1115. X            else
  1116. X                break;
  1117. X        }
  1118. X
  1119. X        /*
  1120. X         * The markers for unified diff are a little different from the
  1121. X         * normal context-diff:
  1122. X         */
  1123. X        if (match(buffer, "+++ ")
  1124. X         || match(buffer, "--- "))
  1125. X             (void)strncpy(buffer, "***", 3);
  1126. X
  1127. X        /*
  1128. X         * Use the first character of the input line to determine its
  1129. X         * type:
  1130. X         */
  1131. X        switch (*buffer) {
  1132. X        case 'O':    /* Only */
  1133. X            if (match(buffer, "Only in ")) {
  1134. X                char *path = buffer + 8;
  1135. X                int found = FALSE;
  1136. X                for (s = path; *s != EOS; s++) {
  1137. X                    if (match(s, ": ")) {
  1138. X                        found = TRUE;
  1139. X                        *s++ = PATHSEP;
  1140. X                        while ((s[0] = s[1]) != EOS)
  1141. X                            s++;
  1142. X                        break;
  1143. X                    }
  1144. X                }
  1145. X                if (found) {
  1146. X                    blip('.');
  1147. X                    this = new_data(path);
  1148. X                    this->cmt = Only;
  1149. X                    ok = TRUE;
  1150. X                }
  1151. X            }
  1152. X            break;
  1153. X
  1154. X        case 'I':    /* Index (e.g., from makepatch) */
  1155. X            if (!match(buffer, "Index: "))
  1156. X                break;
  1157. X            if ((s = strrchr(buffer, BLANK)) != 0) {
  1158. X                blip('.');
  1159. X                this = new_data(s+1);
  1160. X                ok = TRUE;
  1161. X            }
  1162. X            break;
  1163. X
  1164. X        case 'd':    /* diff command trace */
  1165. X            if (!match(buffer, "diff "))
  1166. X                break;
  1167. X            if ((s = strrchr(buffer, BLANK)) != 0) {
  1168. X                blip('.');
  1169. X                this = new_data(s+1);
  1170. X                ok = TRUE;
  1171. X            }
  1172. X            break;
  1173. X
  1174. X        case '*':
  1175. X            if (ok <= 0) {
  1176. X                char    fname[BUFSIZ];
  1177. X                char    wday[BUFSIZ], mmm[BUFSIZ];
  1178. X                int    ddd, hour, minute, second, year;
  1179. X
  1180. X                if (sscanf(buffer,
  1181. X                    "*** %[^\t]\t%[^ ] %[^ ] %d %d:%d:%d %d",
  1182. X                    fname,
  1183. X                    wday, mmm, &ddd,
  1184. X                    &hour, &minute, &second, &year) == 8) {
  1185. X                    ok = -TRUE;
  1186. X                    if (!(s = strrchr(fname, PATHSEP)))
  1187. X                        s = fname;
  1188. X                    else
  1189. X                        s++;
  1190. X                    this = new_data(s);
  1191. X                }
  1192. X            }
  1193. X            break;
  1194. X
  1195. X        case '+':
  1196. X            /* fall-thru */
  1197. X        case '>':
  1198. X            if (!ok)
  1199. X                break;
  1200. X            this->ins += 1;
  1201. X            break;
  1202. X
  1203. X        case '-':
  1204. X            if (!ok)
  1205. X                break;
  1206. X            if (buffer[1] == '-')
  1207. X                break;
  1208. X            /* fall-thru */
  1209. X        case '<':
  1210. X            if (!ok)
  1211. X                break;
  1212. X            this->del += 1;
  1213. X            break;
  1214. X
  1215. X        case '!':
  1216. X            if (!ok)
  1217. X                break;
  1218. X            this->mod += 1;
  1219. X            break;
  1220. X
  1221. X        case 'B':    /* Binary */
  1222. X            /* fall-thru */
  1223. X        case 'b':    /* binary */
  1224. X            if (match(buffer+1, "inary files "))
  1225. X                this->cmt = Binary;
  1226. X            break;
  1227. X        }
  1228. X    }
  1229. X    blip('\n');
  1230. }
  1231. X
  1232. static
  1233. void    plot(num, max, c)
  1234. X    long    num;
  1235. X    long    max;
  1236. X    int    c;
  1237. {
  1238. X    num = (((plot_width * num) + (plot_width/2)) / max);
  1239. X    while (--num >= 0)
  1240. X        (void)putchar(c);
  1241. }
  1242. X
  1243. static
  1244. void    summarize()
  1245. {
  1246. X    register DATA *p;
  1247. X    long    scale = 0,
  1248. X        total_ins = 0,
  1249. X        total_del = 0,
  1250. X        total_mod = 0,
  1251. X        temp;
  1252. X    int    num_files = 0;
  1253. X
  1254. X    for (p = all_data; p; p = p->link) {
  1255. X        int    len = strlen(p->name);
  1256. X        if (len > name_wide)
  1257. X            name_wide = len;
  1258. X        num_files++;
  1259. X        total_ins += p->ins;
  1260. X        total_del += p->del;
  1261. X        total_mod += p->mod;
  1262. X        temp = p->ins + p->del + p->mod;
  1263. X        if (temp > scale)
  1264. X            scale = temp;
  1265. X    }
  1266. X
  1267. X    name_wide++;    /* make sure it's nonzero */
  1268. X    plot_width = (max_width - name_wide - 8);
  1269. X    if (plot_width < 10)
  1270. X        plot_width = 10;
  1271. X
  1272. X    for (p = all_data; p; p = p->link) {
  1273. X        printf(" %-*.*s|", name_wide, name_wide, p->name);
  1274. X        if (p->cmt == Normal) {
  1275. X            printf("%5ld ", p->ins + p->del + p->mod);
  1276. X            plot(p->ins, scale, '+');
  1277. X            plot(p->del, scale, '-');
  1278. X            plot(p->mod, scale, '!');
  1279. X        } else if (p->cmt == Binary) {
  1280. X            printf("binary");
  1281. X        } else if (p->cmt == Only) {
  1282. X            printf("only");
  1283. X        }
  1284. X        printf("\n");
  1285. X    }
  1286. X
  1287. X    printf(" %d files changed", num_files);
  1288. X    if (total_ins) printf(", %ld insertions", total_ins);
  1289. X    if (total_del) printf(", %ld deletions", total_del);
  1290. X    if (total_mod) printf(", %ld modifications", total_mod);
  1291. X    printf("\n");
  1292. }
  1293. X
  1294. static
  1295. void    usage()
  1296. {
  1297. X    static    char    *msg[] = {
  1298. X    "Usage: diffstat [options] [files]",
  1299. X    "",
  1300. X    "Reads from one or more input files which contain output from 'diff',",
  1301. X    "producing a histgram of total lines changed for each file referenced.",
  1302. X    "If no filename is given on the command line, reads from stdin.",
  1303. X    "",
  1304. X    "Options:",
  1305. X    "  -w NUM  specify maximum width of the output (default: 80)"
  1306. X    };
  1307. X    register int j;
  1308. X    for (j = 0; j < sizeof(msg)/sizeof(msg[0]); j++)
  1309. X        fprintf(stderr, "%s\n", msg[j]);
  1310. X    exit (EXIT_FAILURE);
  1311. }
  1312. X
  1313. int    main(argc, argv)
  1314. X    int    argc;
  1315. X    char    *argv[];
  1316. {
  1317. X    register int    j;
  1318. X
  1319. X    max_width = 80;
  1320. X    piped_output = !isatty(fileno(stdout))
  1321. X             && isatty(fileno(stderr));
  1322. X
  1323. X    while ((j = getopt(argc, argv, "w:")) != EOF) {
  1324. X        switch (j) {
  1325. X        case 'w':
  1326. X            max_width = atoi(optarg);
  1327. X            break;
  1328. X        default:
  1329. X            usage();
  1330. X            /*NOTREACHED*/
  1331. X        }
  1332. X    }
  1333. X
  1334. X    if (optind < argc) {
  1335. X        while (optind < argc) {
  1336. X            FILE *fp;
  1337. X            char *name = argv[optind++];
  1338. X            if ((fp = fopen(name, "r")) != 0) {
  1339. X                if (piped_output) {
  1340. X                    (void)fprintf(stderr, "%s\n", name);
  1341. X                    (void)fflush(stderr);
  1342. X                }
  1343. X                do_file(fp);
  1344. X            } else {
  1345. X                failed(name);
  1346. X            }
  1347. X        }
  1348. X    } else {
  1349. X        do_file(stdin);
  1350. X    }
  1351. X    summarize();
  1352. X    exit(EXIT_SUCCESS);
  1353. X    /*NOTREACHED*/
  1354. X    return (EXIT_SUCCESS);
  1355. }
  1356. SHAR_EOF
  1357. $TOUCH -am 0612204394 'diffstat.c' &&
  1358. chmod 0444 diffstat.c ||
  1359. echo 'restore of diffstat.c failed'
  1360. Wc_c="`wc -c < 'diffstat.c'`"
  1361. test 8620 -eq "$Wc_c" ||
  1362.     echo 'diffstat.c: original size 8620, current size' "$Wc_c"
  1363. rm -f _shar_wnt_.tmp
  1364. fi
  1365. # ============= diffstat.1 ==============
  1366. if test -f 'diffstat.1' -a X"$1" != X"-c"; then
  1367.     echo 'x - skipping diffstat.1 (File already exists)'
  1368.     rm -f _shar_wnt_.tmp
  1369. else
  1370. > _shar_wnt_.tmp
  1371. echo 'x - extracting diffstat.1 (Text)'
  1372. sed 's/^X//' << 'SHAR_EOF' > 'diffstat.1' &&
  1373. .\"*****************************************************************************
  1374. .\" Copyright (c) 1994 by Thomas E. Dickey.  All Rights Reserved.              *
  1375. .\"                                                                            *
  1376. .\" You may freely copy or redistribute this software, so long as there is no  *
  1377. .\" profit made from its use, sale trade or reproduction. You may not change   *
  1378. .\" this copyright notice, and it must be included in any copy made.           *
  1379. .\"*****************************************************************************
  1380. .\" $Id: diffstat.1,v 1.2 1994/06/13 23:38:35 tom Exp $
  1381. .de DS
  1382. .RS
  1383. .nf
  1384. .sp
  1385. ..
  1386. .de DE
  1387. .fi
  1388. .RE
  1389. .sp .5
  1390. ..
  1391. .TH DIFFSTAT 1
  1392. .
  1393. .SH NAME
  1394. \fBdiffstat\fR \- make histogram from diff-output
  1395. .
  1396. .SH USAGE
  1397. \fBdiffstat\fI [options] [file-specifications]
  1398. .
  1399. .SH SYNOPSIS
  1400. This program reads the output of \fBdiff\fR and displays a histogram
  1401. of the insertions, deletions, and modifications per-file.
  1402. .
  1403. .SH DESCRIPTION
  1404. Diffstat is a program that is useful for reviewing large, complex patch files.
  1405. It reads from one or more input files which contain output from \fBdiff\fR,
  1406. producing a histogram of the total lines changed for each file referenced.
  1407. .
  1408. .PP
  1409. Diffstat recognizes the most popular types of output from diff:
  1410. .
  1411. .RS
  1412. .TP
  1413. unified
  1414. preferred by the \fBpatch\fR utility.
  1415. .
  1416. .TP
  1417. context
  1418. best for readability, but not very compact.
  1419. .
  1420. .TP
  1421. default
  1422. not good for much, but simple to generate.
  1423. .RE
  1424. .
  1425. .PP
  1426. \fBDiffstat\fR detects the lines that are output by \fBdiff\fR to
  1427. tell which files are compared, and then counts the markers in the
  1428. first column that denote the type of change (insertion, deletion
  1429. or modification).
  1430. These are shown in the histogram as "+", "-" and "!" characters.
  1431. .
  1432. .PP
  1433. If no filename is given on the command line,
  1434. \fBdiffstat\fR reads the differences from the standard input.
  1435. .
  1436. .SH OPTIONS
  1437. .TP
  1438. .BI \-w " number"
  1439. specify the maximum width of the histogram.
  1440. The plot will never be shorter than 10 columns, just in case
  1441. the filenames get too large.
  1442. .
  1443. .SH ENVIRONMENT
  1444. .PP
  1445. \fBDiffstat\fR runs in a portable UNIX\*R environment.
  1446. .SH FILES
  1447. .PP
  1448. \fBDiffstat\fR is a single binary module, which uses no auxiliary files.
  1449. .
  1450. .SH BUGS
  1451. .PP
  1452. \fBDiffstat\fR makes a lot of assumptions about the format of a \fBdiff\fR file.
  1453. .PP
  1454. There's no easy way to determine the degree of overlap between the
  1455. "before" and "after" displays of modified lines.
  1456. .
  1457. .SH SEE ALSO
  1458. .PP
  1459. diff (1).
  1460. .SH AUTHOR
  1461. .PP
  1462. Thomas Dickey (dickey@clark.net).
  1463. SHAR_EOF
  1464. $TOUCH -am 0613193894 'diffstat.1' &&
  1465. chmod 0444 diffstat.1 ||
  1466. echo 'restore of diffstat.1 failed'
  1467. Wc_c="`wc -c < 'diffstat.1'`"
  1468. test 2467 -eq "$Wc_c" ||
  1469.     echo 'diffstat.1: original size 2467, current size' "$Wc_c"
  1470. rm -f _shar_wnt_.tmp
  1471. fi
  1472. # ============= config_h.in ==============
  1473. if test -f 'config_h.in' -a X"$1" != X"-c"; then
  1474.     echo 'x - skipping config_h.in (File already exists)'
  1475.     rm -f _shar_wnt_.tmp
  1476. else
  1477. > _shar_wnt_.tmp
  1478. echo 'x - extracting config_h.in (Text)'
  1479. sed 's/^X//' << 'SHAR_EOF' > 'config_h.in' &&
  1480. /* 
  1481. X * $Id: config_h.in,v 1.1 1994/06/12 23:48:18 tom Exp $
  1482. X * config_h.in is a template file used by configure to produce config.h.
  1483. X * config_h is then transformed (by config.status) into the header file 
  1484. X * config.h -- Kevin Buettner.
  1485. X */
  1486. X
  1487. @DEFS@
  1488. SHAR_EOF
  1489. $TOUCH -am 0612194894 'config_h.in' &&
  1490. chmod 0444 config_h.in ||
  1491. echo 'restore of config_h.in failed'
  1492. Wc_c="`wc -c < 'config_h.in'`"
  1493. test 249 -eq "$Wc_c" ||
  1494.     echo 'config_h.in: original size 249, current size' "$Wc_c"
  1495. rm -f _shar_wnt_.tmp
  1496. fi
  1497. # ============= mkdirs.sh ==============
  1498. if test -f 'mkdirs.sh' -a X"$1" != X"-c"; then
  1499.     echo 'x - skipping mkdirs.sh (File already exists)'
  1500.     rm -f _shar_wnt_.tmp
  1501. else
  1502. > _shar_wnt_.tmp
  1503. echo 'x - extracting mkdirs.sh (Text)'
  1504. sed 's/^X//' << 'SHAR_EOF' > 'mkdirs.sh' &&
  1505. #!/bin/sh
  1506. # mkinstalldirs --- make directory hierarchy
  1507. # Author: Noah Friedman <friedman@prep.ai.mit.edu>
  1508. # Created: 1993-05-16
  1509. # Last modified: 1994-03-25
  1510. # Public domain
  1511. X
  1512. errstatus=0
  1513. X
  1514. for file in ${1+"$@"} ; do 
  1515. X   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
  1516. X   shift
  1517. X
  1518. X   pathcomp=
  1519. X   for d in ${1+"$@"} ; do
  1520. X     pathcomp="$pathcomp$d"
  1521. X     case "$pathcomp" in
  1522. X       -* ) pathcomp=./$pathcomp ;;
  1523. X     esac
  1524. X
  1525. X     if test ! -d "$pathcomp"; then
  1526. X        echo "mkdir $pathcomp" 1>&2
  1527. X        mkdir "$pathcomp" || errstatus=$?
  1528. X     fi
  1529. X
  1530. X     pathcomp="$pathcomp/"
  1531. X   done
  1532. done
  1533. X
  1534. exit $errstatus
  1535. X
  1536. # mkinstalldirs ends here
  1537. SHAR_EOF
  1538. $TOUCH -am 0521140894 'mkdirs.sh' &&
  1539. chmod 0555 mkdirs.sh ||
  1540. echo 'restore of mkdirs.sh failed'
  1541. Wc_c="`wc -c < 'mkdirs.sh'`"
  1542. test 649 -eq "$Wc_c" ||
  1543.     echo 'mkdirs.sh: original size 649, current size' "$Wc_c"
  1544. rm -f _shar_wnt_.tmp
  1545. fi
  1546. # ============= makefile.in ==============
  1547. if test -f 'makefile.in' -a X"$1" != X"-c"; then
  1548.     echo 'x - skipping makefile.in (File already exists)'
  1549.     rm -f _shar_wnt_.tmp
  1550. else
  1551. > _shar_wnt_.tmp
  1552. echo 'x - extracting makefile.in (Text)'
  1553. sed 's/^X//' << 'SHAR_EOF' > 'makefile.in' &&
  1554. # $Id: makefile.in,v 1.7 1994/06/14 00:55:55 tom Exp $
  1555. # Makefile-template for 'diffstat'
  1556. X
  1557. THIS = diffstat
  1558. X
  1559. #### Start of system configuration section. ####
  1560. X
  1561. srcdir = @srcdir@
  1562. VPATH  = @srcdir@
  1563. X
  1564. CC        = @CC@
  1565. LINK        = $(CC)
  1566. INSTALL        = @INSTALL@
  1567. INSTALL_PROGRAM    = @INSTALL_PROGRAM@
  1568. INSTALL_DATA    = @INSTALL_DATA@
  1569. X
  1570. LIBS        = @LIBS@
  1571. CFLAGS        = @CFLAGS@
  1572. X
  1573. prefix        = /usr/local
  1574. exec_prefix    = $(prefix)
  1575. X
  1576. bindir        = $(exec_prefix)/bin
  1577. libdir        = $(exec_prefix)/lib
  1578. mandir        = $(prefix)/man/man1
  1579. manext        = 1
  1580. X
  1581. #### End of system configuration section. ####
  1582. X
  1583. SHELL        = /bin/sh
  1584. X
  1585. CPPFLAGS    = -I. -I$(srcdir) -DHAVE_CONFIG_H
  1586. X
  1587. LDFLAGS        = 
  1588. X
  1589. .c.o:
  1590. X    $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
  1591. X
  1592. SRC = README $(THIS).c $(THIS).1 config_h.in mkdirs.sh makefile.in configure.in
  1593. X
  1594. OBJ = $(THIS).o
  1595. X
  1596. DISTFILES = configure $(SRC)
  1597. X
  1598. all:    $(THIS)
  1599. X
  1600. $(THIS): $(OBJ)
  1601. X    -mv $(THIS) o$(THIS)
  1602. X    $(LINK) $(LDFLAGS) -o $(THIS) $(OBJ) $(LIBS)
  1603. X
  1604. install: all installdirs
  1605. X    $(INSTALL_PROGRAM) $(THIS) $(bindir)/$(THIS)
  1606. X    $(INSTALL_DATA) $(srcdir)/$(THIS).1 $(mandir)/$(THIS).$(manext)
  1607. X
  1608. installdirs:
  1609. X    $(SHELL) ${srcdir}/mkdirs.sh $(bindir) $(libdir) $(mandir)
  1610. X
  1611. uninstall:
  1612. X    rm -f $(bindir)/$(THIS) $(mandir)/$(THIS).$(manext)
  1613. X
  1614. makefile: makefile.in config.status
  1615. X    ./config.status
  1616. X
  1617. config.h: configure
  1618. X    ./configure
  1619. X
  1620. config.status: configure
  1621. X    ./config.status --recheck
  1622. X
  1623. mostlyclean:
  1624. X    rm -f *.o o$(THIS) core *~ *.BAK
  1625. X
  1626. clean: mostlyclean
  1627. X    rm -f $(THIS)
  1628. X
  1629. distclean: clean
  1630. X    rm -f makefile config.status config.h
  1631. X
  1632. realclean: distclean
  1633. X    rm -f tags TAGS # don't remove configure!
  1634. X
  1635. lint:
  1636. X    lint $(THIS).c
  1637. X
  1638. tags:
  1639. X    ctags $(THIS).c $(HDRS)
  1640. X
  1641. TAGS:
  1642. X    etags $(THIS).c $(HDRS)
  1643. X
  1644. dist:    makefile $(DISTFILES)
  1645. X    echo $(THIS)-`sed \
  1646. X        -e '/"$$[A-Za-z]*: $(THIS)\.c.*$$"/!d' \
  1647. X        -e 's/^.*$(THIS)[^ ]*[ ]*//' \
  1648. X        -e 's/[ ].*$$//' \
  1649. X        -e q $(srcdir)/$(THIS).c` > .fname
  1650. X    rm -rf `cat .fname`
  1651. X    mkdir `cat .fname`
  1652. X    for file in $(DISTFILES); do \
  1653. X      ln $(srcdir)/$$file `cat .fname` \
  1654. X        || { echo copying $$file instead; cp -p $$file `cat .fname`; }; \
  1655. X    done
  1656. X    tar -cf - `cat .fname` | gzip >`cat .fname`.tgz
  1657. X    rm -rf `cat .fname` .fname
  1658. X
  1659. shar:    $(DISTFILES)
  1660. X    shar -a -m -M -L50 -n$(THIS) -oPart $(DISTFILES)
  1661. X
  1662. $(THIS).o:    config.h
  1663. X
  1664. $(SRC):    ; checkout $@
  1665. SHAR_EOF
  1666. $TOUCH -am 0613205594 'makefile.in' &&
  1667. chmod 0444 makefile.in ||
  1668. echo 'restore of makefile.in failed'
  1669. Wc_c="`wc -c < 'makefile.in'`"
  1670. test 2152 -eq "$Wc_c" ||
  1671.     echo 'makefile.in: original size 2152, current size' "$Wc_c"
  1672. rm -f _shar_wnt_.tmp
  1673. fi
  1674. # ============= configure.in ==============
  1675. if test -f 'configure.in' -a X"$1" != X"-c"; then
  1676.     echo 'x - skipping configure.in (File already exists)'
  1677.     rm -f _shar_wnt_.tmp
  1678. else
  1679. > _shar_wnt_.tmp
  1680. echo 'x - extracting configure.in (Text)'
  1681. sed 's/^X//' << 'SHAR_EOF' > 'configure.in' &&
  1682. dnl Process this file with 'autoconf' to produce a 'configure' script
  1683. dnl $Id: configure.in,v 1.3 1994/06/14 00:06:44 tom Exp $
  1684. AC_REVISION($Revision: 1.3 $)
  1685. AC_INIT(diffstat.c)
  1686. AC_PROG_CC
  1687. AC_PROG_INSTALL
  1688. AC_GCC_TRADITIONAL
  1689. X
  1690. if test -n "$GCC"
  1691. then
  1692. CFLAGS='-O -Wall -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes'
  1693. fi
  1694. AC_SUBST(CFLAGS)
  1695. AC_SUBST(LIBS)
  1696. X
  1697. AC_CONST
  1698. AC_STDC_HEADERS
  1699. AC_HAVE_HEADERS(stdlib.h unistd.h)
  1700. AC_HAVE_HEADERS(getopt.h string.h malloc.h)
  1701. X
  1702. ###    output makefile and config.h
  1703. changequote({,})dnl
  1704. AC_OUTPUT(makefile config_h,
  1705. {
  1706. echo creating config.h
  1707. sed    -e '/^# /d' \
  1708. X    -e 's/ -D/\
  1709. #define /g' \
  1710. X    -e 's/\(#define [A-Za-z_][A-Za-z0-9_]*\)=/\1    /g' \
  1711. X    config_h >config.h
  1712. }
  1713. echo removing config_h
  1714. rm config_h
  1715. )
  1716. changequote([,])dnl
  1717. SHAR_EOF
  1718. $TOUCH -am 0613200694 'configure.in' &&
  1719. chmod 0444 configure.in ||
  1720. echo 'restore of configure.in failed'
  1721. Wc_c="`wc -c < 'configure.in'`"
  1722. test 753 -eq "$Wc_c" ||
  1723.     echo 'configure.in: original size 753, current size' "$Wc_c"
  1724. rm -f _shar_wnt_.tmp
  1725. fi
  1726. exit 0
  1727.