bcpp-20210108/0000755000175100001440000000000013776165640011433 5ustar tomusersbcpp-20210108/MANIFEST0000644000175100001440000000646013776150420012560 0ustar tomusersMANIFEST for bcpp-20210108, version t2021-01-08 -------------------------------------------------------------------------------- MANIFEST this file CHANGES change-log for BCPP COPYING copyright and license README top-level README for bcpp VERSION version of this package aclocal.m4 autoconf macros for BCPP bcpp.cfg default configuration for bcpp bcppall.bat run bcpp for a whole directory config.guess utility script config.sub utility script config_h.in template for config.h configure configure script for BCPP configure.in configure-script template for BCPP configure Configuration script for UNIX indent.bat script for format all C/C++/Java(Script) files indent.cfg alternate configuration (larger queue) install.sh install-script makefile.in top-level makefile templace for BCPP code subdirectory code/.vilerc vile settings code/anyobj.cpp the base class for all objects... code/anyobj.h interface of anyobj.cpp code/backup.cpp backup original file, restore if no change is made code/baseq.cpp objects which are descendents of ANYOBJECT code/baseq.h interface of baseq.cpp code/bcpp.cfg sample config-file for bcpp (used in testing also) code/bcpp.cpp main program (Beautify C++) code/bcpp.h common interface/defs for bcpp code/cb++ sample unix script, used for regression testing code/cmdline.cpp command-line options-parsing code/cmdline.h interface of cmdline.cpp code/config.cpp config-file reader code/config.h interface of config.cpp code/debug.cpp debug/trace functions for BCPP code/execsql.cpp module to indent embedded SQL statements code/hanging.cpp compute hanging-indent of multiline statements code/html.cpp test for HTML vs JavaScript code/makefile.blc makefile for Borland C code/makefile.in makefile template for BCPP program code/makefile.unx UNIX makefile (g++) code/makefile.wnt makefile for M$ Visual C++ code/run-test test-script code/stacklis.cpp container class that stores items in a linked list code/stacklis.h interface of stacklis.cpp code/strings.cpp simple string-utilities code/tabs.cpp tab expansion/conversion for BCPP code/verbose.cpp all output to stdout or stderr txtdocs subdirectory txtdocs/bcpp.1 manual, in UNIX manpage format txtdocs/hirachy.txt text-version of class-hierarchy txtdocs/manual.txt text-version of manual wpdocs subdirectory wpdocs/hirachy.doc document, in WP51 format wpdocs/manual.doc document, in WP51 format bcpp-20210108/configure.in0000644000175100001440000000073013776150543013740 0ustar tomusersdnl Process this file with 'autoconf' to produce a 'configure' script dnl $Id: configure.in,v 1.8 2021/01/08 21:40:51 tom Exp $ AC_PREREQ(2.52.20210105) AC_REVISION($Revision: 1.8 $) AC_INIT(code/bcpp.cpp) AC_CONFIG_HEADER(code/autoconf.h:config_h.in) CF_CHECK_CACHE AC_PROG_CXX AC_PROG_CXXCPP AC_PROG_INSTALL AC_LANG_CPLUSPLUS AC_EXEEXT AC_OBJEXT CF_DISABLE_ECHO CF_GXX_WARNINGS AC_STDC_HEADERS AC_CHECK_HEADERS( \ unistd.h \ ) AC_OUTPUT(makefile code/makefile,,,cat) bcpp-20210108/config.guess0000755000175100001440000013746213716375511013762 0ustar tomusers#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2020 Free Software Foundation, Inc. timestamp='2020-08-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. tmp= # shellcheck disable=SC2172 trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" # shellcheck disable=SC2039 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" for driver in cc gcc c89 c99 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$driver" break fi done if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac } # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu set_cc_for_build cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" # If ldd exists, use it to detect musl libc. if command -v ldd >/dev/null && \ ldd --version 2>&1 | grep -q ^musl then LIBC=musl fi ;; esac # Note: order is significant - the case branches are not exclusive. case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ "/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine="${arch}${endian}"-unknown ;; *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; *:OS108:*:*) echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Twizzler:*:*) echo "$UNAME_MACHINE"-unknown-twizzler exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ test "$TARGET_BINARY_INTERFACE"x = x then echo m88k-dg-dgux"$UNAME_RELEASE" else echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if test -x /usr/bin/lslpp ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if test "$HP_ARCH" = hppa2.0w then set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if test -x /usr/sbin/sysversion ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; arm:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` set_cc_for_build if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi else echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) case "$UNAME_MACHINE" in x86) echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; *:Minix:*:*) echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef mips #undef mipsel #undef mips64 #undef mips64el #if ${IS_GLIBC} && defined(_ABI64) LIBCABI=gnuabi64 #else #if ${IS_GLIBC} && defined(_ABIN32) LIBCABI=gnuabin32 #else LIBCABI=${LIBC} #endif #endif #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa64r6 #else #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa32r6 #else #if defined(__mips64) CPU=mips64 #else CPU=mips #endif #endif #endif #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) MIPS_ENDIAN= #else MIPS_ENDIAN= #endif #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) set_cc_for_build LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_X32 >/dev/null then LIBCABI="$LIBC"x32 fi fi echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if test -d /usr/nec; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; arm64:Darwin:*:*) echo aarch64-apple-darwin"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac if command -v xcode-select > /dev/null 2> /dev/null && \ ! xcode-select --print-path > /dev/null 2> /dev/null ; then # Avoid executing cc if there is no toolchain installed as # cc will be a stub that puts up a graphical alert # prompting the user to install developer tools. CC_FOR_BUILD=no_compiler_found else set_cc_for_build fi if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; NSV-*:NONSTOP_KERNEL:*:*) echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; *:Unleashed:*:*) echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" exit ;; esac # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" < #include #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #include #if defined(_SIZE_T_) || defined(SIGLOST) #include #endif #endif #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) #include #if defined (BSD) #if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); #else #if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); #else printf ("vax-dec-bsd\n"); exit (0); #endif #endif #else printf ("vax-dec-bsd\n"); exit (0); #endif #else #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname un; uname (&un); printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname *un; uname (&un); printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else printf ("mips-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF fi exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: bcpp-20210108/VERSION0000644000175100001440000000001413776150420012464 0ustar tomuserst2021-01-08 bcpp-20210108/makefile.in0000644000175100001440000000221513732506764013536 0ustar tomusers# $Id: makefile.in,v 1.8 2020/09/22 23:51:16 tom Exp $ # top-level makefile-template for 'bcpp' THIS = bcpp #### Start of system configuration section. #### srcdir = @srcdir@ VPATH = @srcdir@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ prefix = @prefix@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ bindir = @bindir@ mandir = @mandir@ BINDIR = $(DESTDIR)$(bindir) MANDIR = $(DESTDIR)$(mandir)/man1 manext = 1 #### End of system configuration section. #### SHELL = /bin/sh all: cd code && $(MAKE) $@ install: all installdirs cd code && $(MAKE) $@ DESTDIR=$(DESTDIR) $(INSTALL_DATA) $(srcdir)/txtdocs/$(THIS).1 $(MANDIR)/$(THIS).$(manext) installdirs: mkdir -p $(BINDIR) $(MANDIR) uninstall: rm -f $(BINDIR)/$(THIS) $(MANDIR)/$(THIS).$(manext) mostlyclean: cd code && $(MAKE) $@ rm -f *.o core *~ *.out *.BAK *.atac clean: mostlyclean cd code && $(MAKE) $@ rm -f $(THIS) distclean: clean cd code && $(MAKE) $@ rm -f makefile code/makefile code/autoconf.h rm -f config.log config.cache config.status realclean: distclean cd code && $(MAKE) $@ check: cd code && $(MAKE) $@ bcpp-20210108/configure0000755000175100001440000035777613776152053013365 0ustar tomusers#! /bin/sh # From configure.in Revision: 1.8 . # Guess values for system-dependent variables and create Makefiles. # Generated by Autoconf 2.52.20210105. # # Copyright 2003-2020,2021 Thomas E. Dickey # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Sed expression to map a string onto a valid variable name. as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Name of the executable. as_me=`echo "$0" |sed 's,.*[\\/],,'` if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset="unset" else as_unset="false" fi # NLS nuisances. $as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } $as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } $as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } $as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : "${ac_max_here_lines=38}" ac_unique_file="code/bcpp.cpp" # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${datarootdir}/info' mandir='${datarootdir}/man' # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo "$ac_feature" | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo "$ac_feature" | sed 's/-/_/g'` case "$ac_option" in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst \ | --runs | --run | --ru) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* \ | --runs=* | --run=* | --ru=*) runstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo "$ac_package" | sed 's/-/_/g'` case "$ac_option" in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo "$ac_package" | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export "$ac_envvar" ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option}" "${host_alias=$ac_option}" "${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo "$ac_prev" | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo "$ac_var"` case "$ac_val" in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo "$ac_var"` case "$ac_val" in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. build=$build_alias host=$host_alias target=$target_alias # FIXME: should be removed in autoconf 3.0. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CXX_set=${CXX+set} ac_env_CXX_value=$CXX ac_cv_env_CXX_set=${CXX+set} ac_cv_env_CXX_value=$CXX ac_env_CXXFLAGS_set=${CXXFLAGS+set} ac_env_CXXFLAGS_value=$CXXFLAGS ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} ac_cv_env_CXXFLAGS_value=$CXXFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CXXCPP_set=${CXXCPP+set} ac_env_CXXCPP_value=$CXXCPP ac_cv_env_CXXCPP_set=${CXXCPP+set} ac_cv_env_CXXCPP_value=$CXXCPP ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat < if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXXCPP C++ preprocessor CC C compiler command CFLAGS C compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. EOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue cd "$ac_subdir" # A "../" for each directory in /$ac_subdir. ac_dots=`echo "$ac_subdir" | sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'` case "$srcdir" in .) # No --srcdir option. We are building in place. ac_sub_srcdir="$srcdir" ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_sub_srcdir="$srcdir/$ac_subdir" ;; *) # Relative path. ac_sub_srcdir="$ac_dots$srcdir/$ac_subdir" ;; esac # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_sub_srcdir/configure.gnu"; then echo $SHELL "$ac_sub_srcdir/configure.gnu" --help=recursive elif test -f "$ac_sub_srcdir/configure"; then echo $SHELL "$ac_sub_srcdir/configure" --help=recursive elif test -f "$ac_sub_srcdir/configure.ac" || test -f "$ac_sub_srcdir/configure.in"; then echo "$ac_configure" --help else echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2 fi cd "$ac_popdir" done fi test -n "$ac_init_help" && exit 0 if "$ac_init_version"; then cat <<\EOF Copyright 2003-2020,2021 Thomas E. Dickey Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. EOF exit 0 fi exec 5>config.log cat >&5 </dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` PATH = $PATH _ASUNAME } >&5 cat >&5 <\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" ac_sep=" " ;; *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg" ac_sep=" " ;; esac # Get rid of the leading space. done # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. trap 'exit_status=$? # Save into config.log some information that might help in debugging. echo >&5 echo "## ----------------- ##" >&5 echo "## Cache variables. ##" >&5 echo "## ----------------- ##" >&5 echo >&5 # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } >&5 sed "/^$/d" confdefs.h >conftest.log if test -s conftest.log; then echo >&5 echo "## ------------ ##" >&5 echo "## confdefs.h. ##" >&5 echo "## ------------ ##" >&5 echo >&5 cat conftest.log >&5 fi (echo; echo) >&5 test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" >&5 echo "$as_me: exit $exit_status" >&5 rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' "$ac_signal" done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:868: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} cat "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:879: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:887: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case "$ac_old_set,$ac_new_set" in set,) { echo "$as_me:903: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:907: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:913: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:915: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:917: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. It doesn't matter if # we pass some twice (in addition to the command line arguments). if test "$ac_new_set" = set; then case "$ac_new_val" in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val" ;; esac fi done if "$ac_cache_corrupted"; then { echo "$as_me:936: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:938: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" case `echo "testing\c" 2>/dev/null; echo 1,2,3`,`echo -n testing 2>/dev/null; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C= # newlines do not sed ;-) only broken shells would use this case anyway ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac echo "#! $SHELL" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh if { (echo "$as_me:967: PATH=\".;.\"; conftest.sh") >&5 (PATH=".;."; conftest.sh) 2>&5 ac_status=$? echo "$as_me:970: \$? = $ac_status" >&5 (exit "$ac_status"); }; then ac_path_separator=';' else ac_path_separator=: fi PATH_SEPARATOR="$ac_path_separator" rm -f conftest.sh ac_config_headers="$ac_config_headers code/autoconf.h:config_h.in" ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:998: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:1008: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:1012: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:1021: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub "$ac_cv_build_alias"` || { { echo "$as_me:1025: error: $ac_config_sub $ac_cv_build_alias failed." >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:1030: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then echo "$as_me:1038: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub "$ac_cv_host_alias"` || { { echo "$as_me:1047: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:1052: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && cat >>confdefs.h <&6 else cf_cv_system_name="$system_name" fi test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && echo "$as_me:1078: result: Configuring for $cf_cv_system_name" >&5 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6 if test ".$system_name" != ".$cf_cv_system_name" ; then echo "$as_me:1082: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6 { { echo "$as_me:1084: error: \"Please remove config.cache and try again.\"" >&5 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;} { (exit 1); exit 1; }; } fi ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" if test -n "$ac_tool_prefix"; then for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:1100: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:1115: found $ac_dir/$ac_word" >&5 break done fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then echo "$as_me:1123: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6 else echo "$as_me:1126: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:1139: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:1154: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then echo "$as_me:1162: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6 else echo "$as_me:1165: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CXX" && break done test -n "$ac_ct_CXX" || ac_ct_CXX="g++" CXX=$ac_ct_CXX fi # Provide some information about the compiler. echo "$as_me:1177:" \ "checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:1180: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:1183: \$? = $ac_status" >&5 (exit "$ac_status"); } { (eval echo "$as_me:1185: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:1188: \$? = $ac_status" >&5 (exit "$ac_status"); } { (eval echo "$as_me:1190: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:1193: \$? = $ac_status" >&5 (exit "$ac_status"); } cat >"conftest.$ac_ext" <<_ACEOF #line 1197 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:1213: checking for C++ compiler default output" >&5 echo $ECHO_N "checking for C++ compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *"conftest[^"]*"//'` if { (eval echo "$as_me:1216: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:1219: \$? = $ac_status" >&5 (exit "$ac_status"); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. for ac_file in `ls a.exe conftest.exe 2>/dev/null; ls a.out conftest 2>/dev/null; ls a.* conftest.* 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; a.out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { { echo "$as_me:1242: error: C++ compiler cannot create executables" >&5 echo "$as_me: error: C++ compiler cannot create executables" >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:1248: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:1253: checking whether the C++ compiler works" >&5 echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:1259: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1262: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:1269: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'." >&5 echo "$as_me: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:1277: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe "conftest$ac_cv_exeext" ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:1284: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:1286: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:1289: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 if { (eval echo "$as_me:1291: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:1294: \$? = $ac_status" >&5 (exit "$ac_status"); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:1310: error: cannot compute EXEEXT: cannot compile and link" >&5 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} { (exit 1); exit 1; }; } fi rm -f "conftest$ac_cv_exeext" echo "$as_me:1316: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f "conftest.$ac_ext" EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:1322: checking for object suffix" >&5 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 1328 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:1340: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1343: \$? = $ac_status" >&5 (exit "$ac_status"); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { { echo "$as_me:1355: error: cannot compute OBJEXT: cannot compile" >&5 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} { (exit 1); exit 1; }; } fi rm -f "conftest.$ac_cv_objext" "conftest.$ac_ext" fi echo "$as_me:1362: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:1366: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 1372 "configure" #include "confdefs.h" int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1387: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1390: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1393: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1396: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_compiler_gnu=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:1408: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS CXXFLAGS="-g" echo "$as_me:1414: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 1420 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1432: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1435: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1438: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1441: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_prog_cxx_g=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:1451: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi for ac_declaration in \ ''\ '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >"conftest.$ac_ext" <<_ACEOF #line 1478 "configure" #include "confdefs.h" #include $ac_declaration int main (void) { exit (42); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1491: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1494: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1497: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1500: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 continue fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF #line 1510 "configure" #include "confdefs.h" $ac_declaration int main (void) { exit (42); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1522: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1525: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1528: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1531: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done rm -rf conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo "$ac_declaration" >>confdefs.h echo '#endif' >>confdefs.h fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" for ac_prog in ggrep grep do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:1558: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$GREP"; then ac_cv_prog_GREP="$GREP" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_GREP="$ac_prog" echo "$as_me:1573: found $ac_dir/$ac_word" >&5 break done fi fi GREP=$ac_cv_prog_GREP if test -n "$GREP"; then echo "$as_me:1581: result: $GREP" >&5 echo "${ECHO_T}$GREP" >&6 else echo "$as_me:1584: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$GREP" && break done test -n "$GREP" || GREP=": " echo "$as_me:1592: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else for ac_prog in gegrep egrep do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:1604: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_EGREP="$EGREP" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_EGREP="$ac_dir/$ac_word" echo "$as_me:1621: found $ac_dir/$ac_word" >&5 break fi done ;; esac fi EGREP=$ac_cv_path_EGREP if test -n "$EGREP"; then echo "$as_me:1632: result: $EGREP" >&5 echo "${ECHO_T}$EGREP" >&6 else echo "$as_me:1635: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$EGREP" && break done test -n "$EGREP" || EGREP=": " test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:1643: error: cannot find workable egrep" >&5 echo "$as_me: error: cannot find workable egrep" >&2;} { (exit 1); exit 1; }; } fi fi echo "$as_me:1648: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6 EGREP="$ac_cv_path_EGREP" ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" echo "$as_me:1658: checking how to run the C++ preprocessor" >&5 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >"conftest.$ac_ext" <<_ACEOF #line 1675 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:1680: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:1686: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Broken: fails on valid input. continue fi rm -f conftest.err "conftest.$ac_ext" # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >"conftest.$ac_ext" <<_ACEOF #line 1709 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:1713: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:1719: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err "conftest.$ac_ext" done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi echo "$as_me:1756: result: $CXXCPP" >&5 echo "${ECHO_T}$CXXCPP" >&6 ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >"conftest.$ac_ext" <<_ACEOF #line 1766 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:1771: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:1777: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Broken: fails on valid input. continue fi rm -f conftest.err "conftest.$ac_ext" # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >"conftest.$ac_ext" <<_ACEOF #line 1800 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:1804: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:1810: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err "conftest.$ac_ext" done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then : else { { echo "$as_me:1838: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5 echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:1862: checking for a BSD compatible install" >&5 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_IFS=$IFS; IFS=$ac_path_separator for ac_dir in $PATH; do IFS=$ac_save_IFS # Account for people who put trailing slashes in PATH elements. case $ac_dir/ in / | ./ | .// | /cC/* \ | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ | /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if $as_executable_p "$ac_dir/$ac_prog"; then if test $ac_prog = install && grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:1911: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" echo "$as_me:1929: checking if you want to see long compiling messages" >&5 echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6 # Check whether --enable-echo or --disable-echo was given. if test "${enable_echo+set}" = set; then enableval="$enable_echo" test "$enableval" != no && enableval=yes if test "$enableval" != "yes" ; then ECHO_LT='--silent' ECHO_LD='@echo linking $@;' RULE_CC='@echo compiling $<' SHOW_CC='@echo compiling $@' ECHO_CC='@' else ECHO_LT='' ECHO_LD='' RULE_CC='' SHOW_CC='' ECHO_CC='' fi else enableval=yes ECHO_LT='' ECHO_LD='' RULE_CC='' SHOW_CC='' ECHO_CC='' fi; echo "$as_me:1963: result: $enableval" >&5 echo "${ECHO_T}$enableval" >&6 ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:1975: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:1990: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1998: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:2001: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:2010: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:2025: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:2033: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:2036: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:2049: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:2064: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:2072: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:2075: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:2084: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="cc" echo "$as_me:2099: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:2107: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:2110: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:2123: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:2143: found $ac_dir/$ac_word" >&5 break done if test "$ac_prog_rejected" = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" ${1+"$@"} shift ac_cv_prog_CC="$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:2165: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:2168: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:2179: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:2194: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:2202: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:2205: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:2218: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:2233: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:2241: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:2244: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:2256: error: no acceptable cc found in \$PATH" >&5 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:2261:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo "$2"` { (eval echo "$as_me:2264: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:2267: \$? = $ac_status" >&5 (exit "$ac_status"); } { (eval echo "$as_me:2269: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:2272: \$? = $ac_status" >&5 (exit "$ac_status"); } { (eval echo "$as_me:2274: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:2277: \$? = $ac_status" >&5 (exit "$ac_status"); } echo "$as_me:2280: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 2286 "configure" #include "confdefs.h" int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2301: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2304: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2307: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2310: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_compiler_gnu=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:2322: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:2328: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 2334 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2346: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2349: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2352: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2355: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_prog_cc_g=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:2365: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >"conftest.$ac_ext" <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2392: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2395: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2398: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2401: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then for ac_declaration in \ ''\ '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >"conftest.$ac_ext" <<_ACEOF #line 2413 "configure" #include "confdefs.h" #include $ac_declaration int main (void) { exit (42); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2426: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2429: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2432: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2435: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 continue fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF #line 2445 "configure" #include "confdefs.h" $ac_declaration int main (void) { exit (42); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2457: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2460: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2463: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2466: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done rm -rf conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo "$ac_declaration" >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" echo "$as_me:2500: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >"conftest.$ac_ext" <<_ACEOF #line 2521 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:2526: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2532: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Broken: fails on valid input. continue fi rm -f conftest.err "conftest.$ac_ext" # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >"conftest.$ac_ext" <<_ACEOF #line 2555 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:2559: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2565: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err "conftest.$ac_ext" done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:2602: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >"conftest.$ac_ext" <<_ACEOF #line 2612 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:2617: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2623: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Broken: fails on valid input. continue fi rm -f conftest.err "conftest.$ac_ext" # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >"conftest.$ac_ext" <<_ACEOF #line 2646 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:2650: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2656: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err "conftest.$ac_ext" done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then : else { { echo "$as_me:2684: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" GXX_VERSION=none if test "$GXX" = yes; then echo "$as_me:2698: checking version of ${CXX:-g++}" >&5 echo $ECHO_N "checking version of ${CXX:-g++}... $ECHO_C" >&6 GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" if test -z "$GXX_VERSION" then GXX_VERSION=unknown GXX=no fi echo "$as_me:2706: result: $GXX_VERSION" >&5 echo "${ECHO_T}$GXX_VERSION" >&6 fi INTEL_CPLUSPLUS=no if test "$GCC" = yes ; then case "$host_os" in (linux*|gnu*) echo "$as_me:2715: checking if this is really Intel C++ compiler" >&5 echo $ECHO_N "checking if this is really Intel C++ compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -no-gcc" cat >"conftest.$ac_ext" <<_ACEOF #line 2720 "configure" #include "confdefs.h" int main (void) { #ifdef __INTEL_COMPILER #else make an error #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2737: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2740: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2743: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2746: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then INTEL_CPLUSPLUS=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CXXFLAGS="$cf_save_CFLAGS" echo "$as_me:2757: result: $INTEL_CPLUSPLUS" >&5 echo "${ECHO_T}$INTEL_CPLUSPLUS" >&6 ;; esac fi CLANG_CPLUSPLUS=no if test "$GCC" = yes ; then echo "$as_me:2766: checking if this is really Clang C++ compiler" >&5 echo $ECHO_N "checking if this is really Clang C++ compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CXXFLAGS" cat >"conftest.$ac_ext" <<_ACEOF #line 2770 "configure" #include "confdefs.h" int main (void) { #ifdef __clang__ #else make an error #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2787: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2790: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2793: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2796: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then CLANG_CPLUSPLUS=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CXXFLAGS="$cf_save_CFLAGS" echo "$as_me:2806: result: $CLANG_CPLUSPLUS" >&5 echo "${ECHO_T}$CLANG_CPLUSPLUS" >&6 fi CLANG_VERSION=none if test "x$CLANG_CPLUSPLUS" = "xyes" ; then case "$CC" in (c[1-9][0-9]|*/c[1-9][0-9]) { echo "$as_me:2815: WARNING: replacing broken compiler alias $CC" >&5 echo "$as_me: WARNING: replacing broken compiler alias $CC" >&2;} CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" CC=clang ;; esac echo "$as_me:2822: checking version of $CC" >&5 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$CLANG_VERSION" && CLANG_VERSION=unknown echo "$as_me:2826: result: $CLANG_VERSION" >&5 echo "${ECHO_T}$CLANG_VERSION" >&6 for cf_clang_opt in \ -Qunused-arguments \ -Wno-error=implicit-function-declaration do echo "$as_me:2833: checking if option $cf_clang_opt works" >&5 echo $ECHO_N "checking if option $cf_clang_opt works... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cf_clang_opt" cat >"conftest.$ac_ext" <<_ACEOF #line 2838 "configure" #include "confdefs.h" #include int main (void) { printf("hello!\\n"); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:2852: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:2855: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:2858: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2861: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_clang_optok=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_clang_optok=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" echo "$as_me:2872: result: $cf_clang_optok" >&5 echo "${ECHO_T}$cf_clang_optok" >&6 CFLAGS="$cf_save_CFLAGS" if test "$cf_clang_optok" = yes; then test -n "$verbose" && echo " adding option $cf_clang_opt" 1>&6 echo "${as_me:-configure}:2878: testing adding option $cf_clang_opt ..." 1>&5 test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_clang_opt" fi done fi ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" cat > conftest.$ac_ext <&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CXXFLAGS="$CXXFLAGS" EXTRA_CXXFLAGS="-Wall" for cf_opt in \ wd1419 \ wd1682 \ wd1683 \ wd1684 \ wd193 \ wd279 \ wd593 \ wd810 \ wd869 \ wd981 do CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt" if { (eval echo "$as_me:2930: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2933: \$? = $ac_status" >&5 (exit "$ac_status"); }; then test -n "$verbose" && echo "$as_me:2935: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt" fi done CXXFLAGS="$cf_save_CXXFLAGS" elif test "$GXX" = yes then { echo "$as_me:2944: checking for $CXX warning options..." >&5 echo "$as_me: checking for $CXX warning options..." >&6;} cf_save_CXXFLAGS="$CXXFLAGS" EXTRA_CXXFLAGS="-W -Wall" cf_gxx_extra_warnings="" test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings" case "$GXX_VERSION" in ([1-2].*) ;; (*) cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++" ;; esac for cf_opt in \ Wabi \ fabi-version=0 \ Wextra \ Wignored-qualifiers \ Wlogical-op \ Woverloaded-virtual \ Wsign-promo \ Wsynth \ Wold-style-cast \ Wcast-align \ Wcast-qual \ Wpointer-arith \ Wshadow \ Wundef $cf_gxx_extra_warnings do CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt" if { (eval echo "$as_me:2974: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2977: \$? = $ac_status" >&5 (exit "$ac_status"); }; then test -n "$verbose" && echo "$as_me:2979: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt" else test -n "$verbose" && echo "$as_me:2983: result: ... no -$cf_opt" >&5 echo "${ECHO_T}... no -$cf_opt" >&6 fi done CXXFLAGS="$cf_save_CXXFLAGS" fi rm -rf ./conftest* ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_main_return="return" echo "$as_me:2998: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 3004 "configure" #include "confdefs.h" #include #include #include #include _ACEOF if { (eval echo "$as_me:3012: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:3018: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_stdc=no fi rm -f conftest.err "conftest.$ac_ext" if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >"conftest.$ac_ext" <<_ACEOF #line 3040 "configure" #include "confdefs.h" #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -rf conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >"conftest.$ac_ext" <<_ACEOF #line 3058 "configure" #include "confdefs.h" #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -rf conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >"conftest.$ac_ext" <<_ACEOF #line 3079 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main (void) { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) $ac_main_return(2); $ac_main_return (0); } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:3105: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3108: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:3110: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3113: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_stdc=no fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi fi echo "$as_me:3126: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi for ac_header in \ unistd.h \ do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:3141: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 3147 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:3151: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:3157: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_Header=no" fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:3176: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then cat >>confdefs.h <confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overriden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if cmp -s $cache_file confcache; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H : "${CONFIG_STATUS=./config.status}" ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:3267: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >"$CONFIG_STATUS" <<_ACEOF #! $SHELL # Generated automatically by configure. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false SHELL=\${CONFIG_SHELL-$SHELL} ac_cs_invocation="\$0 \$@" CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS _ACEOF cat >>"$CONFIG_STATUS" <<\_ACEOF # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Name of the executable. as_me=`echo "$0" |sed 's,.*[\\/],,'` if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset="unset" else as_unset="false" fi # NLS nuisances. $as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } $as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } $as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } $as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } exec 6>&1 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>"$CONFIG_STATUS" fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>"$CONFIG_STATUS" fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>"$CONFIG_STATUS" fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>"$CONFIG_STATUS" fi cat >>"$CONFIG_STATUS" <<\EOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` shift set dummy "$ac_option" "$ac_optarg" ${1+"$@"} shift ;; -*);; *) # This is not an option, so the user has probably given explicit # arguments. ac_need_defaults=false;; esac case $1 in # Handling of the options. EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:3446: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) shift CONFIG_FILES="$CONFIG_FILES $1" ac_need_defaults=false;; --header | --heade | --head | --hea ) shift CONFIG_HEADERS="$CONFIG_HEADERS $1" ac_need_defaults=false;; # This is an error. -*) { { echo "$as_me:3465: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done exec 5>>config.log cat >&5 << _ACEOF ## ----------------------- ## ## Running config.status. ## ## ----------------------- ## This file was extended by $as_me 2.52.20210105, executed with CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS > "$ac_cs_invocation" on `(hostname || uname -n) 2>/dev/null | sed 1q` _ACEOF EOF cat >>"$CONFIG_STATUS" <<\EOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;; "code/makefile" ) CONFIG_FILES="$CONFIG_FILES code/makefile" ;; "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; "code/autoconf.h" ) CONFIG_HEADERS="$CONFIG_HEADERS code/autoconf.h:config_h.in" ;; *) { { echo "$as_me:3504: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if "$ac_need_defaults"; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. : ${TMPDIR=/tmp} { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/cs$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 { (exit 1); exit 1; } } EOF cat >>"$CONFIG_STATUS" <\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datarootdir@,$datarootdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@runstatedir@,$runstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@DEFS@,$DEFS,;t t s,@LIBS@,$LIBS,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@CXX@,$CXX,;t t s,@CXXFLAGS@,$CXXFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CXX@,$ac_ct_CXX,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CXXCPP@,$CXXCPP,;t t s,@GREP@,$GREP,;t t s,@EGREP@,$EGREP,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@ECHO_LT@,$ECHO_LT,;t t s,@ECHO_LD@,$ECHO_LD,;t t s,@RULE_CC@,$RULE_CC,;t t s,@SHOW_CC@,$SHOW_CC,;t t s,@ECHO_CC@,$ECHO_CC,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@CPP@,$CPP,;t t s,@EXTRA_CXXFLAGS@,$EXTRA_CXXFLAGS,;t t CEOF EOF cat >>"$CONFIG_STATUS" <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while "$ac_more_lines"; do if test "$ac_beg" -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed # It is possible to make a multiline substitution using escaped newlines. # Ensure that we do not split the substitution between script fragments. ac_BEG=$ac_end ac_END=`expr "$ac_end" + "$ac_max_sed_lines"` sed "1,${ac_BEG}d; ${ac_END}p; q" $tmp/subs.sed >$tmp/subs.next if test -s $tmp/subs.next; then grep '^s,@[^@,][^@,]*@,.*\\$' $tmp/subs.next >$tmp/subs.edit if test ! -s $tmp/subs.edit; then grep "^s,@[^@,][^@,]*@,.*,;t t$" $tmp/subs.next >$tmp/subs.edit if test ! -s $tmp/subs.edit; then if test "$ac_beg" -gt 1; then ac_end=`expr "$ac_end" - 1` continue fi fi fi fi if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr "$ac_sed_frag" + 1` ac_beg=$ac_end ac_end=`expr "$ac_end" + "$ac_max_sed_lines"` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" EOF cat >>"$CONFIG_STATUS" <<\EOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" ;; esac done; } ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'` else ac_dir_suffix= ac_dots= fi case "$srcdir" in .) ac_srcdir=. if test -z "$ac_dots"; then ac_top_srcdir=. else ac_top_srcdir=`echo "$ac_dots" | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) ac_srcdir="$srcdir$ac_dir_suffix"; ac_top_srcdir="$srcdir" ;; *) # Relative path. ac_srcdir="$ac_dots$srcdir$ac_dir_suffix" ac_top_srcdir="$ac_dots$srcdir" ;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_dots$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:3751: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated automatically by config.status. */ configure_input="Generated automatically from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:3769: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:3782: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } EOF cat >>"$CONFIG_STATUS" <<\EOF ac_warn_datarootdir=no if test x"$ac_file" != x-; then for ac_item in $ac_file_inputs do ac_seen=`grep '@\(datadir\|mandir\|infodir\)@' "$ac_item"` if test -n "$ac_seen"; then ac_used=`grep '@datarootdir@' "$ac_item"` if test -z "$ac_used"; then { echo "$as_me:3798: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&2;} ac_warn_datarootdir=yes fi fi ac_seen=`grep '${datarootdir}' "$ac_item"` if test -n "$ac_seen"; then { echo "$as_me:3807: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&2;} ac_warn_datarootdir=yes fi done fi if test "x$ac_warn_datarootdir" = xyes; then ac_sed_cmds="$ac_sed_cmds | sed -e 's,@datarootdir@,\${prefix}/share,g' -e 's,\${datarootdir},\${prefix}/share,g'" fi EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then cp "$tmp/out" "$ac_file" for ac_name in prefix exec_prefix datarootdir do ac_seen=`${FGREP-fgrep} -n '${'$ac_name'[:=].*}' "$ac_file"` if test -n "$ac_seen"; then ac_init=`${EGREP-egrep} '[ ]*'$ac_name'[ ]*=' "$ac_file"` if test -z "$ac_init"; then ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'` { echo "$as_me:3844: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&5 echo "$as_me: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&2;} fi fi done ${EGREP-egrep} -n '@[a-z_][a-z_0-9]+@' "$ac_file" >$tmp/out ${EGREP-egrep} -n '@[A-Z_][A-Z_0-9]+@' "$ac_file" >>$tmp/out if test -s $tmp/out; then ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out` { echo "$as_me:3855: WARNING: Some variables may not be substituted: $ac_seen" >&5 echo "$as_me: WARNING: Some variables may not be substituted: $ac_seen" >&2;} fi else cat $tmp/out fi rm -f $tmp/out done EOF cat >>"$CONFIG_STATUS" <<\EOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_i turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_iA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_iB='\([ ]\),\1#\2define\3' ac_iC=' ' ac_iD='\4,;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:3904: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:3915: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:3928: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in EOF # Transform confdefs.h into a list of #define's. We won't use it as a sed # script, but as data to insert where we see @DEFS@. We expect AC_SAVE_DEFS to # be either 'cat' or 'sort'. cat confdefs.h | uniq >conftest.vals # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail echo ' rm -f conftest.frag' >> "$CONFIG_STATUS" while grep . conftest.vals >/dev/null do # Write chunks of a limited-size here document to conftest.frag. echo ' cat >> conftest.frag <> "$CONFIG_STATUS" sed "${ac_max_here_lines}q" conftest.vals | sed -e 's/#ifdef.*/#if 0/' >> "$CONFIG_STATUS" echo 'CEOF' >> "$CONFIG_STATUS" sed "1,${ac_max_here_lines}d" conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals # Run sed to substitute the contents of conftest.frag into $tmp/in at the # marker @DEFS@. echo ' cat >> conftest.edit < $tmp/out rm -f $tmp/in mv $tmp/out $tmp/in rm -f conftest.edit conftest.frag ' >> "$CONFIG_STATUS" cat >>"$CONFIG_STATUS" <<\EOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated automatically by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated automatically by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s "$ac_file" "$tmp/config.h" 2>/dev/null; then { echo "$as_me:3986: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" ;; esac done; } fi rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" fi else cat $tmp/config.h rm -f $tmp/config.h fi done EOF cat >>"$CONFIG_STATUS" <<\EOF { (exit 0); exit 0; } EOF chmod +x "$CONFIG_STATUS" ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: exec 5>/dev/null $SHELL "$CONFIG_STATUS" || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. "$ac_cs_success" || { (exit 1); exit 1; } fi bcpp-20210108/bcppall.bat0000644000175100001440000000003506016174262013523 0ustar tomusers@for %f in (%1) do bcpp %f bcpp-20210108/wpdocs/0000755000175100001440000000000006271552430012717 5ustar tomusersbcpp-20210108/wpdocs/manual.doc0000644000175100001440000006005006271552430014664 0ustar tomusersÿWPC ûÿ2ÿÿBPÿÿZ¦ÿÿCourier 10cpi2|xËôx Œ @É“8Å;X@þþþþþþþÿþÿÿÿþÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿOkidata OkiLaser 400OKOKI400.PRSÛx Œ @ɇÏ,h,€03"¬¨X@ûÿ2¿ÿÿ2 ZB œ!ž2|xOkidata OkiLaser 400OKOKI400.PRSÛx Œ @ɇÏ,h,€03"¬¨X@ACourier 10cpiCourier 10cpi Boldûÿ2ßñX…ZÿÿF`ÐÐÓUSUKÓÐ ÷3Ø'3Ø'Standard3Ø'3Ø'StandardOKOKI400.PRSÛx Œ A°°°°÷ Ðtÿÿ–2xxx,‚Ìôx Œ @É“8Å;X@þþþþþþþÿþÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿðÿÿ‰?xxx,~•ôxÐ `ÉwÅ;X€þþþþþþþÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿ'î&ð&ñ& ø+÷+õ+ô*ô*õ)÷)ø(ø'÷&ô&û-û'ü&ý&þ'ÿÿÿÿú+ý+++&&&)++++'& & ' + 01-19-97 09:54p ÿÍ6ÿûÿ2ÐÐÔ*ìÔà ÃÃÃÓUKUSÓ Ô*ìÔ Ô*ìÔ Ô ÔC(++) Beautifier V1.9 ÔÈ ÔWritten By Steven De Toni December 1995 Ô@ ÔUpdated by Thomas Dickey January 1997 Ô*ìÔ Ô*ìÔÐÐÔ °ÔÄ ÄÄÄÔx0*0*0*°°Ô ÐÐÔ*ìÔ Ô –?È ÔÔ&ÐÔ ÃÃà ÃContentsÄÄ Ô*ìÔÐÐÔ °ÔÄ Ä×  ×› Page Ô –?… Ô 1 Á¸ ¸ Áà ÃIntroductionÄ Ä Ô –?" Ô 2 à ÃÁ¸ ¸ ÁDisclaimerÄ Ä Ô –?¿ Ô 3à à Á¸ ¸ ÁRequirementsÄ Ä Ô –?\ Ô 4 à ÃÁ¸ ¸ ÁHow To Use The ProgramÃÃÄÄÄ Ä Ô –?ù ÔÁÁÁ` ` Á11 à ÃÁ¸ ¸ ÁConfiguration File Error MessagesÄ Ä Ô –?– ÔÁÁÁ` ` Á12 à ÃÁ¸ ¸ ÁRun Time Errors During Input File Processing Ä Ä Ô –?3 Ô 13 à ÃÁ¸ ¸ ÁC(++) Beautifier LimitationsÄ Ä Ô –?Ð ÔÁÁÁ` ` Á15Á¸ ¸ Áà ÃContact AddressesÄ Ä Ôm0*0*0*°°Ô Ô ‰? ÔÐ ÈÈ ÐÐÐÔChÔà ÃPage >1<Ä Ä Ô ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔ$Ôà ÃÃÃIntroductionÄÄ Ô*ìÔÐÐÔ °ÔÄ Ä This program enables a user to reformat certain elements of a C, or C++ source code. This helps if one person's code is a little unreadable, or has been indented to a style that you dislike. Using this program will hopefully help in re-styling the code so that it closely meets your style. However, due to the many styles of C(++) that can be coded, there are limits to how well this program will handle the source code, and resulting re-formatted source. Ô ‰?ð Ôà ÃThe following are a list of features implemented:Ä Ä Ô –?€ ÔÂXÂÁ€°° Á-ÁÁà ÃReposition comments at certain locations.Ä ÄÆÐ Æ Ô –? ÔÂXÂÁ€°° Á-ÁÁà ÃRemove non-printable characters not contained within Ô ‰?ò Ôquotes.Ä ÄÆÐ Æ Ô –?‚ ÔÂXÂÁ€°° Á-ÁÁà ÃConvert non-printable characters within quotes to Ô ‰?W Ôoctal/character notation.Ä ÄÆÐ Æ Ô –?ç ÔÂXÂÁ€°° Á-ÁÁà ÃRe-space line spacing between functions.Ä ÄÆÐ Æ Ô –?„ ÔÂXÂÁ€°° Á-ÁÁà ÃTrim trailing spaces from all lines, as well as leading Ô ‰?Y Ôand trailing blank lines from the file.Ä ÄÆÐ Æ Ô –?é ÔÂXÂÁ€°° Á-ÁÁà ÃReposition opening braces to Kernighan/Ritchie style, Ô ‰?¾ Ôor to Pascal style.Ä ÄÆÐ Æ Ô –?N ÔÂXÂÁ€°° Á- ÁÁà ÃUse of tabs, or spaces in indenting.Ä ÄÆÐ Æ Ô –?ë ÔÂXÂÁ€°° Á-ÁÁà ÃIndention of single line code, according to certain C condition statements, including embedded SQL Ô ‰?ˆ Ôstatements.Ä ÄÆÐ Æ Ô0* ( (@@Ô Ô ‰? ÔÐÐÔChÔà ÃPage >2<Ä Ä Ô ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔ%”Ôà ÃÃÃDisclaimerÄ Ä Ô*ìÔÐÐÔ °ÔÄÄ The authors give no guarantees that this program will function to the specifications given via the configuration, or the program's reconstructed output of source code that have been processed. Any damage that might arise from the use of this program (be it software, or hardware) is the problem of user, and not the authors. Using this software binds you to this disclaimer. ÔÐ0* ( (@@Ô Ô ‰? ÔÐÐÔChÔà ÃPage >3<Ä ÄÔ ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔ$ÔÃÃà ÃRequirementsÄÄÄ Ä Ô*ìÔÐÐÔ °Ô This program will run under Microsoft DOS V3.3 and Unix platforms. It uses approximately 50 - 70k (or more, dependant upon internal queue size) of memory during execution. The program code has been written in such a way as to be compatible with existing C++ compilers, however the code is not ANSI standard and may require modification for your environment. The source code has been written with standard ANSI and Posix functions so that least amount of rewriting should be needed if recompiling on another computer platform. The current sources have been compiled using Turbo C++ V3.0, for Ô –2H ÔMS-DOS, GNU G++ 2.7.2 under Sun SPARCstation à ÃÄ Ärunning SunOS, Solaris as well as SGI workstations running IRIX. ÔØ0* ( (@@Ô Ô ‰? ÔÐ ÈÈ Ðà ÃÐÐÔChÔPage >4<Ä Ä Ô ‰?È ÔÔK(#ÔÐÐÔÄÔà ÃÃÃHow To Use The ProgramÄ ÄÄÄ Ô*ìÔÐÐÔ °Ô Operation of the program is via the command line (CLI), and with help from a configuration file you can define your format requirements. Basically each command directive starts with a dash Ô –?° Ô'Ã Ã©Ä Ä' followed my the command name. If another parameter is need for the command, the parameter is added after the command, and Ô –?M Ôseparated with a space (i.e. à Ãbcpp ©fi input.cppÄ Ä). Ô –?ê ÔN.B: Don't enter à Ãbcpp.exeÄ Ä on its own to find its command help, Ô –?¿ Ôuse à Ãbcpp ©?Ä Ä, orà à bcpp ©hÄ Ä. This is due to the input redirection from the O/S. Keeping to Unix CLI convention, a string that is read from the CLI and does not have a command directive is considered a input file. If there are two such occurrences on the command line, the precedence will be input file first, and output Ô –?´ Ôfile second (à Ãi.e., bcpp infile.cpp outfile.cpp ©lgÄ Ä), a third such occurrence will generate a error message. If no output file is presented, its assumed output is via the standard output. This automatically turns off program output. Parameters entered on the command line will override parameters that have been read from the configuration file. Example: Ô ‰?É ÔÁÁà Ãbcpp -fi input.cpp -f 2 -qb 5 -na -no -cc 60 > output.cpp Ä Ä Synopsis -fi input.cpp Input file = input.cpp -f 2 Function spacing = 2 -qb 2 Internal Queue Buffer = 5 -na Remove non-ascii chars -no Suppress program output -cc 60 Comments that appear on same line as code will be placed in column 60. > output.cpp Output of program is redirected to ÁÁÁ` ` ÁÁ¸ ¸ ÁÁÁ "output.cpp" Ô¹0*0*0*°°Ô Ô ‰? Ôà ÃÄ ÄÐÐÔChÔà ÃPage >5<Ä Ä ÔK(#Ô ÔK(#ÔÐÐÔ °ÔA configuration file can be used to specify most of the nonªchanging elements in reformatting of code. The configuration file consists of some fairly lengthy words that are used to explain the output style of the code. However setting these parameters is very easy, they basically consist of two types, Boolean, or Integer types. Using your favorite text editor, you can change the following within the configuration file ... The following parameters will be contained within the Ô –?˜ Ôconfiguration file (default is à Ãbcpp.cfgÄ Ä). The program will attempt to read the default configuration file at the program Ô –?5 Ôsource (i.e. which path bcpp was run). Using the à Ã-fncÄ Ä option you can define a custom configuration file name, and path from the CLI. Integer Type Ranges : 0 - 5000 Boolean Type Ranges : On, Yes, or Off, No à à Ô –?º ÔFunction_SpacingÄ Ä : Integer This parameter specifies how many lines separate two functions. e.g., function_spacing = 2 Ô –2w ÔÁÁCLIÁ` ` Á Ô ‰?? ÔÁÁÁ` ` Áà éf 2Ä Ä Ô –?Ï Ôà ÃUse_TabsÄ Ä: Boolean Specifies whether to use tabs in indenting code. e.g., use_tabs = no Ô –2Œ ÔÁÁCLI à ÃÁ` ` Á Ô –?T ÔÁÁÁ` ` Á©tÁ¸ ¸ ÁÄ Ä(This will turn tabs on, default uses spaces) Ô –?) ÔÁÁÁ` ` Áà ésÄ ÄÁ¸ ¸ Á(Use tabs for indenting)Ápp2Á Ô –?Ž Ôà ÃIndent_SpacingÄ Ä : Integer Specifies how many spaces to indent. This parameter also sets the Ô –?+! Ôwidth of tabs. à ÃBcppÄ Ä considers the width of a tab to be the same as the width of an indent. E.G. indent_spacing = 4 Ô –2è% ÔÁÁCLIÁ` ` Á Ô ‰?°& ÔÁÁÁ` ` Áà éi 4Á¸ ¸ ÁÄ ÄÔ°&0*0*0*°°Ô Ô ‰? ÔÐÐÔChÔà ÃPage >6< ÔK(#ÔÐÐÔ °ÔÐÐÔK(#ÔÐÐÔ °ÔÄ Ä Ô –? Ôà ÃComments_With_CodeÄ Ä : Integer Defines the column in which comments that appear after code on a line will be placed. e.g., comments_with_code = 50 Ô –2 ÔÁÁCLIÁ` ` Á Ô ‰?Ý ÔÁÁÁ` ` Áà écc 50Ä Ä Ã ÃÐÐÔK(#ÔÄ ÄÐÐÔ °Ô Ô –?5 Ôà ÃComments_With_Nocode Ä Ä: Integer Defines the column in which comments that appear in a line will be placed. e.g., comments_with_nocode = 0 ÁÁCLI Ô ‰?‚ ÔÁÁÁ` ` Áà énc 0Ä Ä Ô –? Ôà ÃIndent_PreprocessorÄ Ä: Boolean Ô –?ç ÔIf true, à ÃbcppÄ Äà ÃÄ Ä will indent preprocessor lines to the indention of the C(++) code. If false, preprocessor lines will be in the first column. Unrecognized (i.e., nonstandard) preprocessor lines are always put into the first column. Ô –?Ü Ôà ÃIndent_Exec_SqlÄ Ä: Boolean Ô –?± ÔIf true, à ÃbcppÄ Ä looks for embedded SQL statements (e.g., EXEC SQL), and formats them specially. Ô –? Ôà ÃLeave_Comments_NoCodeÄ Ä : Boolean This options overrides the "Comments_With_Nocode" option. Setting Ô –?³ Ôthis option à ÃOnÄ Ä will indent comments that do not occur on the same line as code to the same indention as code. ÁÁ ÁÁe.g., ÁÁÁ` ` Áleave_comments_nocode = on ÁÁCLI Ô –?8! ÔÁÁÁ` ` Áà énlcncÄ Ä (Turn off Leave_Comments_NoCode) Ô –? " ÔÁÁÁ` ` Áà éylcncÄ Ä (Turn on Leave_Comments_NoCode)Á  <Á Ôâ"0*0*0*°°Ô Ô ‰?È ÔÐÐÔChÔà ÃPage >7<Ä Ä ÔK(#ÔÐÐÔ °ÔÐÐÔK(#ÔÐÐÔ °Ô à ÃÄ Ä Ô –?  Ôà ÃNonAscii_Quotes_To_OctalÄ Ä : Boolean Use this option to change non-ASCII (non-printable) chars to octal notation if they lie within quotes. This parameter doesn't take effect unless either the Ascii_Chars_Only or Leave_Graphic_Chars parameters have been set. e.g., NonAscii_Quotes_to_Octal = no Ô –25 ÔÁÁCLIÁ` ` Á Ô –?ý ÔÁÁÁ` ` Áà énqÄ ÄÁ¸ ¸ Á(Turn off non©ascii chars in quotes to octal) Ô –?Ò ÔÁÁÁ` ` Áà éyqÄ ÄÁ¸ ¸ Á(Turn on non©ascii chars in quotes to octal) ÐÐÔK(#Ô ÔK(#Ô Ô –?7 ÔÔK(#ÔÐÐÔ °Ôà ÃLeave_Graphic_CharsÄ Ä : Boolean Setting this parameter to yes will strip non-printable characters from the source file, but leave any characters that are IBM graphics alone. Any non-printable characters that lie within quotes will be transformed into octal/character notation, if NonAscii_Quotes_To_Octal parameter is set to True. E.G. leave_graphic_chars = yes Ô –2 ÔÁÁCLIÁ` ` Á Ô ‰?Ü ÔÁÁÁ` ` Áà élgÄ Ä ÐÐÔK(#Ôà ÃÄ Ä ÔK(#ÔÐÐÔ °Ô Ô –?4 Ôà ÃAscii_Chars_OnlyÄ Ä : Boolean Setting this parameter to yes will strip any non-printable, non-ASCII characters from the input file. Any non-printable characters that lie within quotes will be transformed into octal/character notation if NonAscii_Quotes_To_Octal is set to True. Comment out this parameter if you are using Leave_Graphic_Chars parameter, as this parameter will override it. e.g., ascii_chars_only = yes Ô –2¡" ÔÁÁCLIÁ` ` Á Ô –?i# ÔÁÁÁ` ` Áà énaÄ ÄÁ¸ ¸ Á(Don't remove non©ASCII characters) Ô –?>$ ÔÁÁÁ` ` Áà éyaÄ ÄÁ¸ ¸ Á(Yes remove non©ASCII characters) à ÃÐÐÔK(#ÔÐÐÔ °ÔÔÛ% 0*0*0*°°Ô Ô ‰?È ÔÐÐÔChÔPage >8<Ä Ä ÔK(#ÔÐÐÔ °ÔÐÐÔK(#ÔÐÐÔ °Ô Ô –?X Ôà ÃPlace_Brace_On_New_LineÄ Ä : Boolean When set to 'on' bcpp will place opening braces on new lines ("Pascal" style C coding), when set to 'off' bcpp will use "K&R" style C coding. Pascal style C coding: if (condition) { statements; } K&R style C coding: if (condition) { statements; } e.g., place_brace_on_new_line = on Ô –2= ÔÁÁCLIÁ` ` Á Ô –? ÔÁÁÁ` ` Áà ébnlÄ Ä (on ) Ô –?Ú ÔÁÁÁ` ` Áà ébclÄ Ä (off) ÐÐ Ô –?? Ôà ÃProgram_OutputÄ Ä : Boolean This parameter will stop output from the program corrupting output that may exit from the program via the standard output. If this parameter is set to off/no then no output is generated from the program, unless an error is encountered. The standard error is used to display any errors encountered while processing. ÁÁE.G Ô –2Œ Ô ÁÁÁ` ` Áprogram_output = off ÁÁCLI Ô –?ä ÔÁÁÁ` ` Áà énoÄ Ä (default is generate output if possible, this will ÁÁÁ` ` Á force output off) Ô –? ÔÁÁÁ` ` Áà éyoÄ Ä (turn on program output if possible) ÔV 0*0*0*°°Ô Ã Ã Ô ‰?È ÔÐÐÔChÔPage >9<Ä Ä ÔK(#ÔÐÐÔ °ÔÐÐÔK(#ÔÐÐÔ °Ô Ô –?X Ôà ÃQueue_BufferÄ Ä : Integer Specifies what the internal memory requires will be in size of the line processing buffer. This is used for open brace relocation in Kernighan/Ritchie style. Extending this buffer to large amounts of memory will slow processing on small machines. ÁÁe.g., Ô –2Ý Ô ÁÁÁ` ` ÁQueue_Buffer = 2 Ô –2m ÔÁÁCLIÁ` ` Á Ô ‰?5 ÔÁÁÁ` ` Áà éqb 2Ä Ä Ô –?Å Ôà Ã; Ä Ä: Not Applicable Placing a semicolon in front of text makes everything after the semicolon a comment. Ô –?º Ôà ÃBackup_FileÄ Ä : Boolean This option will backup the input file to a file with the extension ".bac" and overwrite the input file with the reformatted version. à ÃÄ Ä ÁÁe.g., Ô –2w ÔÁÁÁ` ` Ábackup_file Áhh#ÁÁÀÀ(Á = yes Ô –2 ÔÁÁCLIÁ` ` Á Ô –?Ï ÔÁÁÁ` ` Áà éybÄ ÄÁ¸ ¸ Á(yes, backup input file if possible) Ô –?¤ ÔÁÁÁ` ` Áà énbÄ ÄÁ¸ ¸ Á(no, don't backup input file) Ôy 0*0*0*°°Ô Ô ‰? ÔÐÐÔBðÔà ÃPage >10<Ä Ä ÔK(#ÔÐÐÔ °Ô Ô –? Ôà ÃLoading Configuration FileÄ Ä : CLI only Ô –?e Ôà ÃBcppÄ Ä implements a configuration setting to allow custom file selection from a specific path/file defined by a user. ÁÁe.g., Ô –?’ ÔÁÁÁ` ` Ábcpp input.cppÁhh#Á©yb (read à Ãbcpp.cfgÄ Ä configuration file ÁÁÁ` ` ÁÁ¸ ¸ ÁÁÁÁhh#ÁÁÀÀ(Ábefore processing CLI options) Ô –2÷ ÔÁÁÁ` ` Ábcpp ©fnc /bin/bcpp.cfg (load configuration file atÁ(#(#KÁÁÁÁ` ` ÁÁ¸ ¸ ÁÁÁÁhh#ÁÁÀÀ(Á said location) Ô –2O ÔÁÁCLIÁ` ` Áà ÃÄ Ä Ô –? ÔÁÁÁ` ` Áà éfncÄ ÄÁ¸ ¸ Á(use user defined) Ô –?| Ôà ÃInput File NameÄ Ä : CLI only Ô –?Q ÔThis option directs à ÃbcppÄ Ä to read data at a given path, and file name. ÁÁE.G ÁÁÁ` ` Ábcpp ©fi input.cpp > output.cpp ÁÁCLI Ô ‰?Ö ÔÁÁÁ` ` Áà éfiÄ Ä Ô –?. Ôà ÃOutput File NameÄ Ä : CLI only This defines the output file name that data is to be written to. ÁÁe.g., ÁÁÁ` ` ÁHas to be like this, (in DOS, at least): ÁÁÁ` ` Ábcpp -fo output.cpp < input.cpp ÁÁClI Ô ‰?C ÔÁÁÁ` ` Áà éfoÄ Ä ÁÁÁ` ` Á Ô –?› Ôà ÃOnline HelpÄ Ä : CLI only Some online help which is brief but to the point exists within the program. The help lists all of the CLI commands available within the program. ÁÁE.G bcpp ©h ÁÁCLI bcpp ©? Ô –2è% ÔÁÁ bcpp ©hÁÁÁhh#Á à ÃÄ ÄÔx' 0*0*0*°°Ô Ô ‰? ÔÐÐÔBðÔà ÃPage >11<Ä Ä Ô ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔ0 Ôà ÃÃÃConfiguration File Error MessagesÄÄÄ Ä Ô*ìÔÐÐÔ °Ô If you enter a command/parameter incorrectly within the configuration file, upon the executable program reading it, the program will generate a error message along with its line number. The following is an explanation of error messages that may occur while reading parameters within the configuration file. Ô –?Ð ÔÂXÂ- à ÃSyntax Error After Key WordÄ Ä :ÆÐ Æ ÂXÂError occurs because the character/word after a parameter was incorrect, or expected another keyword (e.g =, Yes, No, On, Off)ÆÐ Æ Ô –?Å ÔÂXÂ- à ÃRange ErrorÄ Ä :ÆÐ Æ ÂXÂError occurs when integer parameters have a invalid numeric setting (i.e., A number is not within 0 - 5000).ÆÐ Æ Ô –?º ÔÂXÂ- à ÃExpected Numeric DataÄ Ä :ÆÐ Æ ÂXÂThis error occurs when alpha-numeric data is in place of numeric data for integer type parameters.ÆÐ Æ Ô –?ç ÔÂXÂ- à ÃCan't DecipherÄ Ä :ÆÐ Æ ÂXÂThe parameter at said line is not valid (i.e., not recognizable).ÆÐ Æ If any errors have occurred after reading the configuration file; the user is prompted with a [y/n] continuation prompt to either fix the configuration error(s) before processing, or continue with current set parameters. Ô4 0*0*0*°°Ô Ô ‰? ÔÐÐÔBðÔà ÃPage >12<Ä Ä Ô ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔœ Ôà ÃÃÃRun Time Errors During Input File ProcessingÄ ÄÄÄ Ô*ìÔÐÐÔ °Ô Ô –?  ÔÂX©à à Memory Allocation Failed Ä Ä: ÆÐ Æ ÂXÂThe program was unable to allocate memory to process data. This error will stop processing of data.ÆÐ Æ Ô –?M ÔÂX©à à Error In Line ConstructionÄ ÄÆÐ Æ Ô –?" ÔÂX© à ÃExpected Some Sort Of Code ! Data Type = ? Ä Ä:ÆÐ Æ ÂXÂThis error is generated within the line construction process. The decoded line from the input file may be too indecipherable for this program. Find the line in the input file, and see if it can be altered so that processing can continue.Æ(#Æ Ôß 0*0*0*°°Ô Ô ‰? Ôà ÃÐÐÔBðÔPage >13< Ô ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔ\ ÔÃÃC(++) Beautifier LimitationsÄ ÄÄÄ Ô*ìÔÐÐÔ °Ô Ô –?X ÔThis section highlights certain areas within code where à ÃbcppÄ Ä will fail to reconstruct the output code to the desired style (although it may still be able to compile). Ô –2… ÔÂXÂÁ€°° Á-ÁÁAll code that is fed through this program should be in a compilable state. This means that there should be Ô –? Ôclosing braces that cancel out opening braces. à ÃBcppÄ Ä does no syntax checking at all upon the code, but reformats it according to open, closing braces, and a handful of key words for single line indentation.ÆÐ Æ Ô –2 ÔÂXÂÁ€°° Á©ÁÁThere is also a limitation on how far the movement of open braces can be processed. This is due to the Ô –?š Ôcurrent design of the program (à Ãthis can fixed easily by Ô –?o Ôextending the internal queue buffer sizeÄ Ä), memory requirements, processing speed. Dynamic memory allocation is used extensively throughout the program, and may exceed current limits if certain conditions arise.ÆÐ Æ ÂXÂThe example shows that the movements of the brace from the new line to the above code line will not take place as it would be out of scope for the program if the internal queue buffer is limited to 2 lines in size.ÆÐ Æ ÔL0*0*0*°°Ô Ô ‰? ÔÐÐÔBðÔà ÃPage >13<Ä Ä ÔK(#ÔÐÐÔ °Ô ÂXÂExample of brace movement scope:ÆÐ Æ Ô ‰?  Ôà ÃÂXÂif (a == b)ÆÐ Æ ÂXÂ// Brace will not be re-positionedÆÐ Æ ÂXÂ{ÆÐ Æ ÂXÂÂX` ` Âb = c;Æx` Æ ÂXÂ}ÆÐ Æ ÂXÂif (a == b) // Brace will be re-positionedÆÐ Æ ÂXÂ{ÆÐ Æ ÂXÂÂX` ` Âb = c;Æx` Æ Ô ‰?( ÔÂXÂ}Ä ÄÆÐ Æ Ô ‰?¸ Ôà ÃÃÃÂXÂEnd ResultÄ ÄÄÄÆÐ Æ Ô ‰?H Ôà ÃÂXÂif (a == b)ÆÐ Æ ÂXÂ// Brace will not be re-positionedÆÐ Æ ÂXÂ{ÆÐ Æ ÂXÂÂX` ` Âb = c;Æx` Æ ÂXÂ}ÆÐ Æ ÂXÂif (a == b){ // Brace will be re-positionedÆÐ Æ ÂXÂÂX` ` Âb = c;Æx` Æ Ô ‰?ˆ ÔÂXÂ}Ä ÄÆÐ Æ Ô –2 ÔÂXÂÁ€°° Á-ÁÁThere is a constraint that a single line of code should only have one type of comment. If there are both C, and C++ existing on the same line then the line construction phase of the program will become confused, and generate a error message. The following line will produce a Line Construction Error message.ÆÐ Æ ÂXÂExample of multiple comments.ÆÐ Æ Ô ‰?  Ôà ÃÂXÂ/* C Comment */ a = b; // C++ CommentÄ ÄÆÐ Æ ÂXÂThe above line will generate an error. Remedy this by removing one type of comment, combine them, or place one on a new line.ÆÐ Æ Ô ‰? ÔÐÐÔBðÔà ÃPage >15<Ä Ä Ô ‰?È ÔÔK(#ÔÐÐÔ °ÔÐÐÔ"ðÔà ÃÃÃContact AddressesÄ ÄÄÄ Ô*ìÔÐÐÔ °Ô You can contact me via various online networks: ÁÁÁ` ` ÁInternet Address Ô ‰?° ÔÁÁÁ` ` ÁÁ¸ ¸ Áà Ãtge@midland.co.nzÄ Ä Ô ‰?x ÔÁÁÁ` ` ÁÁ¸ ¸ Áà Ãsteve@alpha.ocbbs.gen.nzÄ Ä ÁÁÁ` ` ÁNet Mail Via Fido©Net (Dog Net) Ô ‰?Ð ÔÁÁÁ` ` ÁÁ¸ ¸ Áà ÃSteven De Toni, ÁÁÁ` ` ÁÁ¸ ¸ Á"The Great Escape", ÁÁÁ` ` ÁÁ¸ ¸ ÁHamilton, Ô ‰?( ÔÁÁÁ` ` ÁÁ¸ ¸ ÁNew ZealandÄ Ä ÁÁÁ` ` ÁDemi©Monde New Zealand National Mail Net Work Ô ‰?€ ÔÁÁÁ` ` ÁÁ¸ ¸ Áà Ã(see Dog Net)Ä Ä All else fails, send me snail mail at: Ô ‰?  ÔÁÁÁ` ` Áà Ã17 Garden Heights Ave, Ô ‰?h ÔÁÁÁ` ` ÁMelville,ÁÁ ÁÁÁ` ` ÁHamilton, Ô ‰?ø ÔÁÁÁ` ` ÁNew ZealandÄ Ä Thomas Dickey can be reached at Ô ‰? ÔÁÁÁ` ` Áà Ãdickey@clark.netÄ Ä Ô –?¨ ÔSpecial thanks goes out toà à Glyn WebsterÄ Ä for proof reading my manual, and testing my program. Ô –?  ÔThanks toà à Justin SlootskyÄ Ä for his input, and changes for this version. All _grammatical_ errors within this document are there for your enjoyment. ;-)bcpp-20210108/wpdocs/hirachy.doc0000644000175100001440000000730705650466754015061 0ustar tomusersÿWPCè ûÿ2ÿÿBP Z¦Courier 10cpi3|x(/ôxþ6X@É“8Å;X@þþþþþþþÿÿÿÿÿþÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿHP LaserJet Series IIHPLASEII.PRSÛx Œ @ɇÏ,ðt0d¶„X@ÓUSUKÓÐ ÷3Ø'3Ø'StandardÐ6Â&A4Ð6Â&A4ÿÿrJet Series IIˆ¢E5´°°°°÷ Ðûÿ2´ 9!;X\ÿÿF`5´Courier 10cpiCourier 10cpi Boldðÿÿ‰?xxx,(/ôxþ6X@É“8Å;X@þþþþþþþÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿlÿÿ‰?xxx,üôxÐ `ÉwÅ;X€ÿÿÿþþþþÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿíÆïÆðÇõÿÿÆ÷ÆøÆùÆúÆyÇzÇ|Æ~ÆÇ«Ç€ÿÿÇÿÿÿÿDŽdžLj ÇŠXÇŒôǎǒǔǟǡǣǥǧǩûÿ2æÔ ‰? ÔÐÐÔÁ Ôà ÃÃÃObject Hierarchy DiagramÄ ÄÄÄ Ô)aÔÐÐÔ °Ô Ô ‰?  Ô Ã Ã Any ObjectÄ Ä ----+---- à ÃQueueList (generic queue object)Ä Ä | | Ô ‰?x Ô +---- à ÃStackList (generic stack object)Ä Ä | | Ô ‰?Ð Ô +---- à ÃInputStructÄ Ä | | Ô ‰?( Ô +---- à ÃOutputStructÄ Ä | | Ô ‰?€ Ô +---- à ÃIndentStructÄ Ä Notes of class usage: IndentStruct: Even though IndentStruct is defined as a class, it is basically a record structure. I have defined it as a class to help storage of the record data easier, and to automate some of the initialisation process. However, there are no methods (apart from the constructor), that handles any of the object's data. All data is altered directly within the class (i.e don't use methods to change data). InputStruct: This is basically like the IndentStruct, except it has no defined constructor. The class is used the same was as a normal structure. A destructor isn't implemented as existing data may belong to two, or more other objects. OutputStruct: This has more OO implementation than the previous two objects (i.e constructor, destructor), but data is accessed the same as any structure. Ôxp-p-p-°°Ô Ô ‰? Ôà ÃÃÃÐÐÔ ÔEntity RelationShip Diagram Ô)aÔÄ ÄÄÄ Ô)aÔÐÐÔ °Ô +-----------+ +-------------+ Ô ‰?è Ô | | à ÃhaveÄ Ä /| | Ô ‰?° Ô | à ÃQueueListÄ Ä |--------------| à ÃInputStructÄ Ä | | | \| | +-----------+ +-------------+ | | | +--------------+ Ô ‰?` Ô | à ÃhaveÄ Ä /| | Ô ‰?( Ô +--------------------|à à OutputStructÄ Ä | \| | +--------------+ +-----------+ +--------------+ Ô ‰?Ø Ô | | à ÃhaveÄ Ä /| | Ô ‰?  Ô | à ÃStackListÄ Ä |--------------| à ÃIndentStructÄ Ä | | | \| | +-----------+ +--------------+ bcpp-20210108/indent.bat0000644000175100001440000000017706644426760013410 0ustar tomusers@echo off if %1!==! %0 *.c *.cc *.cpp *.h *.java *.js for %%P in ( %1 %2 %3 %4 %5 %6 %7 %8 %9 ) do bcpp -fnc indent.cfg %%P bcpp-20210108/package/0000755000175100001440000000000013776151154013021 5ustar tomusersbcpp-20210108/package/bcpp.spec0000644000175100001440000000340613776150420014617 0ustar tomusersSummary: bcpp - C(++) beautifier %define AppProgram bcpp %define AppVersion 20210108 # $Id: bcpp.spec,v 1.7 2021/01/08 21:39:28 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: 1 License: MIT Group: Applications/Development URL: ftp://ftp.invisible-island.net/%{AppProgram} Source0: %{AppProgram}-%{AppVersion}.tgz Packager: Thomas Dickey %description bcpp indents C/C++ source programs, replacing tabs with spaces or the reverse. Unlike indent, it does (by design) not attempt to wrap long statements. This version improves the parsing algorithm by marking the state of all characters, recognizes a wider range of indention structures, and implements a simple algorithm for indenting embedded SQL. %prep # no need for debugging symbols... %define debug_package %{nil} %setup -q -n %{AppProgram}-%{AppVersion} %build CPPFLAGS="$CPPFLAGS -DBCPP_CONFIG_DIR=\"%{_sysconfdir}\"" \ INSTALL_PROGRAM='${INSTALL}' \ ./configure \ --program-prefix=b \ --target %{_target_platform} \ --prefix=%{_prefix} \ --bindir=%{_bindir} \ --datadir=%{_datadir} \ --sysconfdir=%{_sysconfdir} \ --libdir=%{_libdir} \ --mandir=%{_mandir} make %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{_sysconfdir} install code/bcpp.cfg $RPM_BUILD_ROOT%{_sysconfdir} strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram} %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %{_bindir}/%{AppProgram} %{_bindir}/cb++ %{_sysconfdir}/bcpp.cfg %{_mandir}/man1/%{AppProgram}.* %changelog # each patch should add its ChangeLog entries here * Sun Apr 01 2018 Thomas Dickey - update ftp url, suppress debug package * Sun Mar 18 2012 Thomas Dickey - initial version bcpp-20210108/package/debian/0000755000175100001440000000000013776151154014243 5ustar tomusersbcpp-20210108/package/debian/source/0000755000175100001440000000000013260234536015535 5ustar tomusersbcpp-20210108/package/debian/source/options0000644000175100001440000000027011443776574017170 0ustar tomusers# Bzip2 compression for debian.tar compression = "bzip2" compression-level = 7 # Do not generate diff for changes in config.(sub|guess) extend-diff-ignore = "(^|/)config.(sub|guess)$" bcpp-20210108/package/debian/source/format0000644000175100001440000000001513260234536016744 0ustar tomusers3.0 (native) bcpp-20210108/package/debian/control0000644000175100001440000000117411462654621015646 0ustar tomusersSource: bcpp Section: devel Priority: optional Maintainer: Miriam Ruiz Build-Depends: debhelper (>= 7), quilt, autotools-dev Standards-Version: 3.9.1 Package: bcpp Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: C(++) beautifier bcpp indents C/C++ source programs, replacing tabs with spaces or the reverse. Unlike indent, it does (by design) not attempt to wrap long statements. . This version improves the parsing algorithm by marking the state of all characters, recognizes a wider range of indention structures, and implements a simple algorithm for indenting embedded SQL. bcpp-20210108/package/debian/rules0000755000175100001440000000444511731377030015322 0ustar tomusers#!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif config.status: configure dh_testdir [ ! -d debian/patches ] || $(MAKE) -f /usr/share/quilt/quilt.make patch [ ! -d debian/pixmaps ] || { cd debian/pixmaps && for i in *.sng; do sng "$$i"; done; } ifneq "$(wildcard /usr/share/misc/config.sub)" "" cp -f /usr/share/misc/config.sub config.sub endif ifneq "$(wildcard /usr/share/misc/config.guess)" "" cp -f /usr/share/misc/config.guess config.guess endif CFLAGS="$(CFLAGS) -DBCPP_CONFIG_DIR=\"/etc/bcpp\" -Wl,-z,defs" \ ./configure \ --host=$(DEB_HOST_GNU_TYPE) \ --build=$(DEB_BUILD_GNU_TYPE) \ --prefix=/usr \ --mandir=\$${prefix}/share/man \ --infodir=\$${prefix}/share/info build: build-stamp build-stamp: config.status dh_testdir # Add here commands to compile the package. $(MAKE) #docbook-to-man debian/bcpp.sgml > bcpp.1 touch build-stamp clean: dh_testdir dh_testroot rm -fv build-stamp [ ! -d Makefile ] || $(MAKE) distclean rm -fv config.sub config.guess config.status config.log install rm -fv `find . -name "*.o"` rm -fv code/bcpp makefile code/makefile code/autoconf.h [ ! -d debian/patches ] || $(MAKE) -f /usr/share/quilt/quilt.make unpatch [ ! -d debian/pixmaps ] || rm -vf debian/pixmaps/*.png dh_clean install: build dh_testdir dh_testroot dh_prep dh_installdirs $(MAKE) install prefix=$(CURDIR)/debian/bcpp/usr dh_install code/bcpp.cfg etc/bcpp/ # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs CHANGES dh_installdocs dh_installexamples dh_installman dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install bcpp-20210108/package/debian/copyright0000644000175100001440000000310113776151154016171 0ustar tomusersThis package was debianized by Miriam Ruiz on Mon, 3 Oct 2005 15:43:14 +0200. It was downloaded from https://www.invisible-island.net/bcpp/ Copyright 2005-2020,2021 by Thomas E. Dickey Based on bcpp version 1.8, December 1995 by Steven De Toni License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, distribute with modifications, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. bcpp-20210108/package/debian/compat0000644000175100001440000000000313732506242015434 0ustar tomusers11 bcpp-20210108/package/debian/docs0000644000175100001440000000000711462653321015104 0ustar tomusersREADME bcpp-20210108/package/debian/changelog0000644000175100001440000000252713776150420016116 0ustar tomusersbcpp (20210108) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 08 Jan 2021 16:39:28 -0500 bcpp (20200922) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 22 Sep 2020 19:34:20 -0400 bcpp (20180401) unstable; urgency=low * update configure script -- Thomas E. Dickey Sun, 01 Apr 2018 15:43:38 -0400 bcpp (20150811) unstable; urgency=low * update configure script -- Thomas E. Dickey Tue, 11 Aug 2015 04:12:18 -0400 bcpp (20131209) unstable; urgency=low * update configure script -- Thomas E. Dickey Mon, 09 Dec 2013 07:30:32 -0500 bcpp (20120318) unstable; urgency=low * Add package scripts for testing -- Thomas E. Dickey Sun, 18 Mar 2012 10:37:27 -0400 bcpp (0.0.20050725-2) unstable; urgency=low * Upgraded Standards-Version from 3.6.2 to 3.9.1 * Moved to dpkg source v3 -- Miriam Ruiz Sat, 30 Oct 2010 01:21:04 +0200 bcpp (0.0.20050725-1) unstable; urgency=low * Initial release. Closes: #355488. * Modified FindConfigFile function in bcpp.cpp so that it gets config files from /etc/bcpp. -- Miriam Ruiz Mon, 3 Oct 2005 15:43:14 +0200 bcpp-20210108/package/debian/README.Debian0000644000175100001440000000205411462653321016276 0ustar tomusersbcpp for Debian ---------------- How to check the trustability of the beautifier program: 1) Compiling the code into binary: cp myprogram.cpp test.cpp g++ -c test.cpp -o test.orig.o bcpp myprogram.cpp > test.cpp g++ -c test.cpp -o test.bcpp.o diff test.orig.o test.bcpp.o *.cpp files before compilation should have the same name, or there would be differences in *.o objects. You can use cmp command instead of diff for comparing the binary files. 2) Comparing the assembler code generated: cp myprogram.cpp test.cpp g++ -S test.cpp -o test.orig.S bcpp myprogram.cpp > test.cpp g++ -S test.cpp -o test.bcpp.S diff test.orig.S test.bcpp.S If *.cpp file names are different, diff will find differences between the files, but they can be easily seen in the diff result. 3) You can check by hand the changes made, excluding whitespace changes: bcpp myprogram.cpp > myprogram.bcpp.cpp diff -wu myprogram.cpp myprogram.bcpp.cpp See also: http://yolinux.com/HOWTO/C-C++Beautifier-HOWTO.html -- Miriam Ruiz , Mon, 06 Mar 2006 15:46:01 +0100 bcpp-20210108/config.sub0000755000175100001440000010252313716375511013413 0ustar tomusers#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2020 Free Software Foundation, Inc. timestamp='2020-08-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Split fields of configuration type # shellcheck disable=SC2162 IFS="-" read field1 field2 field3 field4 <&2 exit 1 ;; *-*-*-*) basic_machine=$field1-$field2 basic_os=$field3-$field4 ;; *-*-*) # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two # parts maybe_os=$field2-$field3 case $maybe_os in nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ | storm-chaos* | os2-emx* | rtmk-nova*) basic_machine=$field1 basic_os=$maybe_os ;; android-linux) basic_machine=$field1-unknown basic_os=linux-android ;; *) basic_machine=$field1-$field2 basic_os=$field3 ;; esac ;; *-*) # A lone config we happen to match not fitting any pattern case $field1-$field2 in decstation-3100) basic_machine=mips-dec basic_os= ;; *-*) # Second component is usually, but not always the OS case $field2 in # Prevent following clause from handling this valid os sun*os*) basic_machine=$field1 basic_os=$field2 ;; # Manufacturers dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ | convergent* | ncr* | news | 32* | 3600* | 3100* \ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ | ultra | tti* | harris | dolphin | highlevel | gould \ | cbm | ns | masscomp | apple | axis | knuth | cray \ | microblaze* | sim | cisco \ | oki | wec | wrs | winbond) basic_machine=$field1-$field2 basic_os= ;; *) basic_machine=$field1 basic_os=$field2 ;; esac ;; esac ;; *) # Convert single-component short-hands not valid as part of # multi-component configurations. case $field1 in 386bsd) basic_machine=i386-pc basic_os=bsd ;; a29khif) basic_machine=a29k-amd basic_os=udi ;; adobe68k) basic_machine=m68010-adobe basic_os=scout ;; alliant) basic_machine=fx80-alliant basic_os= ;; altos | altos3068) basic_machine=m68k-altos basic_os= ;; am29k) basic_machine=a29k-none basic_os=bsd ;; amdahl) basic_machine=580-amdahl basic_os=sysv ;; amiga) basic_machine=m68k-unknown basic_os= ;; amigaos | amigados) basic_machine=m68k-unknown basic_os=amigaos ;; amigaunix | amix) basic_machine=m68k-unknown basic_os=sysv4 ;; apollo68) basic_machine=m68k-apollo basic_os=sysv ;; apollo68bsd) basic_machine=m68k-apollo basic_os=bsd ;; aros) basic_machine=i386-pc basic_os=aros ;; aux) basic_machine=m68k-apple basic_os=aux ;; balance) basic_machine=ns32k-sequent basic_os=dynix ;; blackfin) basic_machine=bfin-unknown basic_os=linux ;; cegcc) basic_machine=arm-unknown basic_os=cegcc ;; convex-c1) basic_machine=c1-convex basic_os=bsd ;; convex-c2) basic_machine=c2-convex basic_os=bsd ;; convex-c32) basic_machine=c32-convex basic_os=bsd ;; convex-c34) basic_machine=c34-convex basic_os=bsd ;; convex-c38) basic_machine=c38-convex basic_os=bsd ;; cray) basic_machine=j90-cray basic_os=unicos ;; crds | unos) basic_machine=m68k-crds basic_os= ;; da30) basic_machine=m68k-da30 basic_os= ;; decstation | pmax | pmin | dec3100 | decstatn) basic_machine=mips-dec basic_os= ;; delta88) basic_machine=m88k-motorola basic_os=sysv3 ;; dicos) basic_machine=i686-pc basic_os=dicos ;; djgpp) basic_machine=i586-pc basic_os=msdosdjgpp ;; ebmon29k) basic_machine=a29k-amd basic_os=ebmon ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson basic_os=ose ;; gmicro) basic_machine=tron-gmicro basic_os=sysv ;; go32) basic_machine=i386-pc basic_os=go32 ;; h8300hms) basic_machine=h8300-hitachi basic_os=hms ;; h8300xray) basic_machine=h8300-hitachi basic_os=xray ;; h8500hms) basic_machine=h8500-hitachi basic_os=hms ;; harris) basic_machine=m88k-harris basic_os=sysv3 ;; hp300 | hp300hpux) basic_machine=m68k-hp basic_os=hpux ;; hp300bsd) basic_machine=m68k-hp basic_os=bsd ;; hppaosf) basic_machine=hppa1.1-hp basic_os=osf ;; hppro) basic_machine=hppa1.1-hp basic_os=proelf ;; i386mach) basic_machine=i386-mach basic_os=mach ;; isi68 | isi) basic_machine=m68k-isi basic_os=sysv ;; m68knommu) basic_machine=m68k-unknown basic_os=linux ;; magnum | m3230) basic_machine=mips-mips basic_os=sysv ;; merlin) basic_machine=ns32k-utek basic_os=sysv ;; mingw64) basic_machine=x86_64-pc basic_os=mingw64 ;; mingw32) basic_machine=i686-pc basic_os=mingw32 ;; mingw32ce) basic_machine=arm-unknown basic_os=mingw32ce ;; monitor) basic_machine=m68k-rom68k basic_os=coff ;; morphos) basic_machine=powerpc-unknown basic_os=morphos ;; moxiebox) basic_machine=moxie-unknown basic_os=moxiebox ;; msdos) basic_machine=i386-pc basic_os=msdos ;; msys) basic_machine=i686-pc basic_os=msys ;; mvs) basic_machine=i370-ibm basic_os=mvs ;; nacl) basic_machine=le32-unknown basic_os=nacl ;; ncr3000) basic_machine=i486-ncr basic_os=sysv4 ;; netbsd386) basic_machine=i386-pc basic_os=netbsd ;; netwinder) basic_machine=armv4l-rebel basic_os=linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony basic_os=newsos ;; news1000) basic_machine=m68030-sony basic_os=newsos ;; necv70) basic_machine=v70-nec basic_os=sysv ;; nh3000) basic_machine=m68k-harris basic_os=cxux ;; nh[45]000) basic_machine=m88k-harris basic_os=cxux ;; nindy960) basic_machine=i960-intel basic_os=nindy ;; mon960) basic_machine=i960-intel basic_os=mon960 ;; nonstopux) basic_machine=mips-compaq basic_os=nonstopux ;; os400) basic_machine=powerpc-ibm basic_os=os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson basic_os=ose ;; os68k) basic_machine=m68k-none basic_os=os68k ;; paragon) basic_machine=i860-intel basic_os=osf ;; parisc) basic_machine=hppa-unknown basic_os=linux ;; psp) basic_machine=mipsallegrexel-sony basic_os=psp ;; pw32) basic_machine=i586-unknown basic_os=pw32 ;; rdos | rdos64) basic_machine=x86_64-pc basic_os=rdos ;; rdos32) basic_machine=i386-pc basic_os=rdos ;; rom68k) basic_machine=m68k-rom68k basic_os=coff ;; sa29200) basic_machine=a29k-amd basic_os=udi ;; sei) basic_machine=mips-sei basic_os=seiux ;; sequent) basic_machine=i386-sequent basic_os= ;; sps7) basic_machine=m68k-bull basic_os=sysv2 ;; st2000) basic_machine=m68k-tandem basic_os= ;; stratus) basic_machine=i860-stratus basic_os=sysv4 ;; sun2) basic_machine=m68000-sun basic_os= ;; sun2os3) basic_machine=m68000-sun basic_os=sunos3 ;; sun2os4) basic_machine=m68000-sun basic_os=sunos4 ;; sun3) basic_machine=m68k-sun basic_os= ;; sun3os3) basic_machine=m68k-sun basic_os=sunos3 ;; sun3os4) basic_machine=m68k-sun basic_os=sunos4 ;; sun4) basic_machine=sparc-sun basic_os= ;; sun4os3) basic_machine=sparc-sun basic_os=sunos3 ;; sun4os4) basic_machine=sparc-sun basic_os=sunos4 ;; sun4sol2) basic_machine=sparc-sun basic_os=solaris2 ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun basic_os= ;; sv1) basic_machine=sv1-cray basic_os=unicos ;; symmetry) basic_machine=i386-sequent basic_os=dynix ;; t3e) basic_machine=alphaev5-cray basic_os=unicos ;; t90) basic_machine=t90-cray basic_os=unicos ;; toad1) basic_machine=pdp10-xkl basic_os=tops20 ;; tpf) basic_machine=s390x-ibm basic_os=tpf ;; udi29k) basic_machine=a29k-amd basic_os=udi ;; ultra3) basic_machine=a29k-nyu basic_os=sym1 ;; v810 | necv810) basic_machine=v810-nec basic_os=none ;; vaxv) basic_machine=vax-dec basic_os=sysv ;; vms) basic_machine=vax-dec basic_os=vms ;; vsta) basic_machine=i386-pc basic_os=vsta ;; vxworks960) basic_machine=i960-wrs basic_os=vxworks ;; vxworks68) basic_machine=m68k-wrs basic_os=vxworks ;; vxworks29k) basic_machine=a29k-wrs basic_os=vxworks ;; xbox) basic_machine=i686-pc basic_os=mingw32 ;; ymp) basic_machine=ymp-cray basic_os=unicos ;; *) basic_machine=$1 basic_os= ;; esac ;; esac # Decode 1-component or ad-hoc basic machines case $basic_machine in # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) cpu=hppa1.1 vendor=winbond ;; op50n) cpu=hppa1.1 vendor=oki ;; op60c) cpu=hppa1.1 vendor=oki ;; ibm*) cpu=i370 vendor=ibm ;; orion105) cpu=clipper vendor=highlevel ;; mac | mpw | mac-mpw) cpu=m68k vendor=apple ;; pmac | pmac-mpw) cpu=powerpc vendor=apple ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) cpu=m68000 vendor=att ;; 3b*) cpu=we32k vendor=att ;; bluegene*) cpu=powerpc vendor=ibm basic_os=cnk ;; decsystem10* | dec10*) cpu=pdp10 vendor=dec basic_os=tops10 ;; decsystem20* | dec20*) cpu=pdp10 vendor=dec basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) cpu=m68k vendor=motorola ;; dpx2*) cpu=m68k vendor=bull basic_os=sysv3 ;; encore | umax | mmax) cpu=ns32k vendor=encore ;; elxsi) cpu=elxsi vendor=elxsi basic_os=${basic_os:-bsd} ;; fx2800) cpu=i860 vendor=alliant ;; genix) cpu=ns32k vendor=ns ;; h3050r* | hiux*) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) cpu=m68000 vendor=hp ;; hp9k3[2-9][0-9]) cpu=m68k vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) cpu=hppa1.1 vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp cpu=hppa1.1 vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp cpu=hppa1.1 vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) cpu=hppa1.1 vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; i*86v32) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv32 ;; i*86v4*) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv4 ;; i*86v) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv ;; i*86sol2) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=solaris2 ;; j90 | j90-cray) cpu=j90 vendor=cray basic_os=${basic_os:-unicos} ;; iris | iris4d) cpu=mips vendor=sgi case $basic_os in irix*) ;; *) basic_os=irix4 ;; esac ;; miniframe) cpu=m68000 vendor=convergent ;; *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) cpu=m68k vendor=atari basic_os=mint ;; news-3600 | risc-news) cpu=mips vendor=sony basic_os=newsos ;; next | m*-next) cpu=m68k vendor=next case $basic_os in openstep*) ;; nextstep*) ;; ns2*) basic_os=nextstep2 ;; *) basic_os=nextstep3 ;; esac ;; np1) cpu=np1 vendor=gould ;; op50n-* | op60c-*) cpu=hppa1.1 vendor=oki basic_os=proelf ;; pa-hitachi) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; pbd) cpu=sparc vendor=tti ;; pbb) cpu=m68k vendor=tti ;; pc532) cpu=ns32k vendor=pc532 ;; pn) cpu=pn vendor=gould ;; power) cpu=power vendor=ibm ;; ps2) cpu=i386 vendor=ibm ;; rm[46]00) cpu=mips vendor=siemens ;; rtpc | rtpc-*) cpu=romp vendor=ibm ;; sde) cpu=mipsisa32 vendor=sde basic_os=${basic_os:-elf} ;; simso-wrs) cpu=sparclite vendor=wrs basic_os=vxworks ;; tower | tower-32) cpu=m68k vendor=ncr ;; vpp*|vx|vx-*) cpu=f301 vendor=fujitsu ;; w65) cpu=w65 vendor=wdc ;; w89k-*) cpu=hppa1.1 vendor=winbond basic_os=proelf ;; none) cpu=none vendor=none ;; leon|leon[3-9]) cpu=sparc vendor=$basic_machine ;; leon-*|leon[3-9]-*) cpu=sparc vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; *-*) # shellcheck disable=SC2162 IFS="-" read cpu vendor <&2 exit 1 ;; esac ;; esac # Here we canonicalize certain aliases for manufacturers. case $vendor in digital*) vendor=dec ;; commodore*) vendor=cbm ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if test x$basic_os != x then # First recognize some ad-hoc caes, or perhaps split kernel-os, or else just # set os. case $basic_os in gnu/linux*) kernel=linux os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'` ;; nto-qnx*) kernel=nto os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'` ;; *-*) # shellcheck disable=SC2162 IFS="-" read kernel os <&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os in linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) ;; -dietlibc* | -newlib* | -musl* | -uclibc* ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 exit 1 ;; kfreebsd*-gnu* | kopensolaris*-gnu*) ;; nto-qnx*) ;; *-eabi* | *-gnueabi*) ;; -*) # Blank kernel with real OS is always fine. ;; *-*) echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 exit 1 ;; esac # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. case $vendor in unknown) case $cpu-$os in *-riscix*) vendor=acorn ;; *-sunos*) vendor=sun ;; *-cnk* | *-aix*) vendor=ibm ;; *-beos*) vendor=be ;; *-hpux*) vendor=hp ;; *-mpeix*) vendor=hp ;; *-hiux*) vendor=hitachi ;; *-unos*) vendor=crds ;; *-dgux*) vendor=dg ;; *-luna*) vendor=omron ;; *-genix*) vendor=ns ;; *-clix*) vendor=intergraph ;; *-mvs* | *-opened*) vendor=ibm ;; *-os400*) vendor=ibm ;; s390-* | s390x-*) vendor=ibm ;; *-ptx*) vendor=sequent ;; *-tpf*) vendor=ibm ;; *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; *-aux*) vendor=apple ;; *-hms*) vendor=hitachi ;; *-mpw* | *-macos*) vendor=apple ;; *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; *-vos*) vendor=stratus ;; esac ;; esac echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: bcpp-20210108/COPYING0000644000175100001440000000271513776151117012465 0ustar tomusers$Id: COPYING,v 1.7 2021/01/08 21:44:47 tom Exp $ BCPP - Beautify C++ Source Files -------------------------------------------------------------------------------- Copyright 2005-2020,2021 by Thomas E. Dickey Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, distribute with modifications, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. bcpp-20210108/config_h.in0000644000175100001440000000037105576717302013535 0ustar tomusers/* * $Id: config_h.in,v 1.1 1994/06/12 23:48:18 tom Exp $ * config_h.in is a template file used by configure to produce config.h. * config_h is then transformed (by config.status) into the header file * config.h -- Kevin Buettner. */ @DEFS@ bcpp-20210108/CHANGES0000644000175100001440000003644513776164776012453 0ustar tomusers-- $Id: CHANGES,v 1.51 2021/01/08 23:25:50 tom Exp $ -- Thomas E. Dickey 2021/01/08 ---------- + eliminate archaic "Boolean" enum + updated configure script macros + update config.guess, config.sub 2020/09/22 + remove obsolete makefile-rules + updated configure script macros + update config.guess, config.sub 2018/04/01 + updated configure script macros + update config.guess, config.sub 2015/08/11 + fix an off-by-one in limit-checking for command-line option values (patch by Miriam Ruiz). + updated configure script macros + update config.guess, config.sub 2013/12/09 + updated configure script macros + update config.guess, config.sub 2012/03/18 + add rpm script. + fixes for DESTDIR in makefiles + add cb++ script to install-rules + integrate patch from Debian package, to search for bcpp.cfg in user's home-directory and optionally a compile-time specific directory. + add dpkg script from Debian package, for testing. + updated configure script macros + drop mkdirs.sh, using "mkdir -p" + update config.guess, config.sub 2009/06/30 + updated configure scripts + improve exec-sql parser, detecting inline comments beginning with "--". + fix a case where multi-line indent was set during a #define, and not reset on completion of the #define, causing the following code to be indented. + check for braces or preprocessor-level before indenting comments which are on a line without code. + improve config-file parser, which used strstr... + add keep_code_with_comment option, to merge inline-comments with the code immediately following, rather than merging (for example) with trailing "}" (request by Daniel Lin). 2005/07/25 + add COPYING (request by Peter Hille). + fixes for Intel 9.0 compiler-warnings. + add AC_EXEEXT and AC_OBJEXT checks to configure properly with cygwin. 2005/05/16 + fixes to build with g++ 2.95.3 + add .SUFFIXES rule to build with Solaris make. 2005/04/10 + correct some regressions introduced by 2004/10/27: + check if a line began as part of a quoted string string before computing its indentation. + count indent-level for curly-braces within #define's. + improve configure check for g++ warnings (from ncurses). 2004/10/27 + correct logic that tracks state of preprocessor lines that continue from one line to the next. The additional lines were not marked as preprocessor lines (report by Edward Bishop). + updated configure script, fixes a check that added some gcc warning options which are not recognized by g++. 2003/11/03 + correct one of the valgrind fixes from 2003/04/23 which used delete[] in a special case where delete was correct (reports by Gert van de Kraats and John Whitley ). 2003/04/23 + fix several mismatches between new and delete (versus delete[]) reported by valgrind. + add place_top_brace_on_new_line to config, with corresponding command-line options -tbcl and tbnl to disable or enable it respectively. This is for the special case of the top-level brace, e.g., at the function-level, to better match K&R style braces (request by Daniel Lin). + modified run-test script to facilitate testing variations of bcpp.cfg 2002/11/24 + check in OutputToOutFile() for a trailing C-comment fragment which happened to precede code on the same line, e.g., */ a = b; and split the line to avoid constructing a = b; */ (reports by Andreas Werner and Yanir Lubetkin + add isFinalComment() check to ensure that embedded comments are not moved, e.g., void myFunct(int /*number*/, float* /*data*/); (report by Andreas Werner). 2002/11/23 + add a simple configure script. + rename UNIX makefile to makefile.unx, changing compiler definition from "gcc -x g++" to "g++", since that no longer works with gcc 3.2 (report by Don Park ). + remove obsolete 'unix' subdirectory. 2002/05/18 + add indent_both_braces config-file option and corresponding command-line -nbbi, -ybbi options to allow user to indent both leading/trailing braces of a block by one level (adapted from patch by Brad Mettee ). + add brace_indent config-file option and corresponding command-line -nbi, -ybi options to allow user to indent the trailing brace of a block to align with its content rather than the beginning of the block (detailed request by Edwin Robert Tisdale ) + correct isContinuation() by ignoring backslash characters within comments. This makes it handle comment blocks such as /*******\ * BUG * \*******/ (reported by Andreas Werner ). + add makefile.blc for Borland C (from Chris Elliott ). + remove references to obsolete email address + add CHANGES file, document the sets of changes I marked in RCS + add MANIFEST file. 1999/08/10 + makefile: do not link with -lg++ anymore + makefile: change $D to "./", to make vile follow the compiler warnings more easily + add __FILE__ to traceOutput() calls + fixes to compile on SunOS 4.x, which needs the stuff prototyped also, change interface of traceInput() and traceOutput() to add __FILE__ + fix a case Jeff Gilliat pointed out - an inline C comment fragment resulted in commenting out the code on that line. + mods in IndentNonBraces() which serve to distinguish "public:" which is a class scope from "public" which is a Java type. Otherwise we get odd indention for the latter case. + backup.cpp: had allocated one char too few for ".orig" suffix 1999/01/21 + rename the backup file to .orig, since "~" confuses WinNT's directory scanning, making it return the same file more than once. + open the output in binary mode, so we get ^J's rather than ^M^J's 1999/01/04 + kludge to ifdef for g++ versus M$ Visual C++ + kludge to compile in case we have the misfortune to use gcc 2.8.1 with Solaris's header files (some idiot decided to undef __STDC__ in g++ because they disapprove of using __STDC__ for ifdef'ing). + change defaults in bcpp.cfg to use_tabs=yes, and comments_with_code=33 (the original bpp.cfg is in top-level). + baseq.cpp: fix so we do not try to peek into a negative index + add top-level bcpp.cfg, indent.bat, indent.cfg as part of port to win32. + add txtdocs/manual.txt to distribution, updated wpdocs/manual.doc 1999/01/02 + mods to "work" with tisca.h, which contains a number of comments within long multi-line comments. This isn't quite right, since lines containing only a backslash are deleted, where they should be combined just like blank lines. + add run-test file (used with regression test-cases not part of the distribution). + implement html.cpp, to provide limited support for indenting JavaScript embedded in HTML files. + split-out backup.cpp to support renaming of the original file, preserving its modification-time, to allow recovery if the indent is not needed (makes no change), or otherwise should be discarded. + implement verbose.cpp, to support interactions such as stopping processing a set of files on an error. + change scattered printf's to call verbose(), and fprintf(stderr's to warning(). + rewrote ReadLine so it doesn't use fseek/ftell (which is a porting problem). + config.cpp: removed a lot of ugly/repetitious code + config.cpp: moved ShowConfig here from bcpp.cpp + debug.cpp: change trace() calls to not use stderr explicitly. 1997/04/04 + first draft of logic to reset indent-stack at the end of a multi-line preprocessor command. also, fixed (?) a bug in splitting continuation-line (but there's more) + allow unrecognized preprocessor-lines to be indented + refine a change to allow for things like "else return;" + replaced a couple of strcmp calls by CompareKeyword to allow for matching both "else" and "else if" statements. + fixes for places where we split a line that has continuation-marker on the end. while I was at it, trim redundant whitespace before the '\', to make it uniform. 1997/01/07 + tabs.cpp: fix a place where I trimmed trailing blanks from data w/o trimming state, causing bogus results with baseobj.hh, due to overrun in later logic. + lots of spelling corrections. + fixes for stricter gcc warnings 1996/12/24 + updated copyright notices. + refined adjustment of inline comments to work with hanging.cpp, which doesn't take that into account. + remove unused logic for adjustHangingComment, since I'm doing this in a different way. 1996/12/17 + execsql.cpp: refined hanging-indents to account for statements other than the two block-styles we use + make SqlStruct a class 1996/12/12 + shift-adjust dangling else{} block + makefile: record the debug-ifdefs + hanging.cpp: make HangStruct class to get rid of static variables + bcpp.h: made HangStruct class + change hang_state from an int to a class + made singleIndentLen obsolete via hanging.cpp 1996/12/06 + tabs.cpp: mods to allow tabs in OutputStruct.filler + fix a few leaks + ensure that hanging comments remain hanging when re-indenting. + use tabs for OutputStruct.filler 1996/12/05 + tabs.cpp: correct leading-whitespace conversion (space is printable ;-) + hanging.cpp: remove redundant reset of hang_state + debug.cpp: SunOS 4.x needs stdlib.h for size_t + add InputStruct.offset + add OutputStruct.splitElseIf + remove IndentStruct.firstPass, because hanging.cpp does it better + mods to preserve code-fragment's offset to use in shifting block-indented C-style comments + fixes for offset adjustment due to stripping whitespace from fragments in DecodeLine + first cut of logic to pass offset of code-fragments into InputStruct (to use for categorizing hanging comments) + revised logic for split else/if statement using flag 'splitElseIf'. this fixes the problem of indenting the code undef 'if'. + mods to make TestLineHasCode look at the parse-state (which is more reliable) + remove IndentStruct.firstPass logic, since hanging.cpp does it better + add pBFlag to OutputStruct to use in hanging.cpp 1996/11/15 + tabs.cpp: correct off-by-one in return from skipEscape() that ate trailing quote. + bcpp.h: rename OutputStruct.pState to OutputStruct.pCFlag + bcpp.h: add OutputStruct.pBFlag + use OutputStruct.indentHangs + split-out hanging.cpp + hanging.cpp: add 'do_aggreg' flag + hanging.cpp: use new member of OutputStruct, indentHangs to allow merge with info from execsql.cpp 1996/11/08 + move emptyString to bcpp.h + pass-in Config struct to IndentSQL, making it pass by ref everywhere + move some string-parsing to strings.cpp, to re-use in execsql.cpp + move debug/trace code to debug.cpp + move input/output/indent definitions to bcpp.h + align successive else/if + don't set interfunction-spacing for lines that happen to have R_CURL, if there's more on the line. + add indent_exec_sql to bcpp.cfg + execsql.cpp - quick hack to indent non-keyword stuff extra + move some functions to strings.cpp from bcpp.cpp, for use in execsql.cpp 1996/11/06 + restructured keyword-lookup to add 3rd type (blockLine). use this to fix case (successive lines) with "while", "switch" -- the curly-braces for "switch" weren't indented under "switch". + also, dropped special logic for singleIndentLen, making it the same as a standard indent (was too ugly). 1996/11/05 + propagate parse-state via InputStruct to OutputStruct. + correct potential indention of continued-string fragments. 1996/11/04 + moved string-table to config.cpp + fix uninitialized-memory-ref (Purify) + unused parameter. + add indent_preprocessor + simplify config.cpp a little using overloading + corrected some minor bugs affecting indention + add "#else" to typeOfPreP(), along with all other standard directives. + use enum rather than int for 'attrib' types. change name of one 'attrib' type to make it easier to maintain. fixes for TRACE. + first cut of indent_preprocessor option + modify so that both comma and semicolon are treated specially after '}', to make data lists work properly + correct a couple of special cases with multi-indent 1996/10/31 + fixes for memory leaks + corrections to tab computation + add special state for '#' pre-processor lines + makefile - move some symbols to accommodate non-g++ + add POUNDC + mods to track preprocessor-lines + reduce ConstructLine to a single-level switch, rather than the nested one that will get in the way of mods for execsql + refined logic in dontHangComment(), fixing a case I missed before. + correct a logical-reduction for matching against PreP types + suppress inter-function spacing before "#endif" + add pType to OutputStruct so I can tag them as PreP when needed + fix while-loop that was expressed as for-loop with break + undid unnecessary if-level in ConstructLine + restore leading tabs in comments if we're expanding tabs + moved the non-printing character conversion to tabs.cpp 1996/10/20 + moved delete for lineState into bcpp.cpp + make pString in/out for ExpandTabs + modify ExpandTabs to maintain a string of CharState values + corrected state: allow tab-expansion in // comments + add strings.cpp + make pString in/out for ExpandTabs + fixes for include-order (bcpp.h should be last) + reduce FindStartofComment and FindEndofComment to return index instead of pointers + revised FindPunctuation so it returns an index rather than a pointer, and uses the pLineState info so that we can easily discard quoted punctuation (which didn't work for a complicated string, e.g., "'\\0','\\0'}"). + changed allocation scheme of lineState + drop CComments param of DecodeLine, since pLineState contains proper info + fixes for blank-lines: ensure that we don't emit trailing blank-lines in a file, that except for inter-function blanks, we reduce runs of blank lines to a single blank, and that there's no lines (even comments) that come out with trailing whitespace. + simplify allocation/deallocation in DecodeLine by leaving pLineData alone. + a couple of Purify-fixes + modify ExpandTabs to maintain a string of CharState values; use this to retain parsing state so I can correct blank-trimming (so that continuation lines of a string aren't trimmed!). 1996/10/12 + split-out bcpp.h and tabs.cpp + moved tab-expansion (and tab-spacing) into separate file, first to fix an error in tab-expansion (wrong fill amount), then to allow rewrite to capture left/right CharState, to prevent quoted tabs from being expanded. Also, moved L_CURL, R_CURL, DQUOTE, SQUOTE into config.h, making capitalization consistent. + fixes for multi-line C comments + implement shiftToMatchSingleIndent, peekIndexOfBrace, chainedSingleIndent + better logic in resetSingleIndent(), to reset all pending single-indents + ifdef'd trace code so I don't have to uncomment it added clause in IndentNonBraceCode to (try to) reset singleIndentLen immediately after "{" -- works in one place but not another + eliminate single-char constant-strings to use strchr instead of strstr. use FindPunctuation to simplify some logic + new function CompareKeyword fixes parse ambiguity with strstr allow combination of tabs and spaces. bcpp-20210108/indent.cfg0000644000175100001440000001306406644240565013375 0ustar tomusers; This file contains configuration parameters that are used ; within the bcpp program. ; There are two types of parameter types : Boolean, and Integer. ; Boolean types can have only two valid values [On, Yes, or Off, No]. ; Integer types can have a valid range of 0 - 5000. ;------------------------------------------------------------------------ ; This parameter specifies how many lines separate between two ; functions. ;------------------------------------------------------------------------ function_spacing = 2 ; Integer ;------------------------------------------------------------------------ ; Specifies whether to use tabs in indenting code. ;------------------------------------------------------------------------ use_tabs = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies how many spaces to indent. This parameter is also used ; for tab indenting, as 1 tab may be worth 8 spaces if so desired. ; This parameter is used to position comments in TAB mode, and expanding ; of tabs within code! ;------------------------------------------------------------------------ indent_spacing = 4 ; Integer ;------------------------------------------------------------------------ ; Specifies whether to indent preprocessor controls to match the code ;------------------------------------------------------------------------ indent_preprocessor = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies whether to indent embedded SQL statements ;------------------------------------------------------------------------ indent_exec_sql = yes ; Boolean ;------------------------------------------------------------------------ ; Defines at what start position comments that have code on the ; same line to be placed. ;------------------------------------------------------------------------ comments_with_code = 33 ; Integer ;------------------------------------------------------------------------ ; Defines at what start position comments with no code start. ;------------------------------------------------------------------------ comments_with_nocode = 0 ; Integer ;------------------------------------------------------------------------ ; Set this option to ON turns off setting indentation position of parameter ; "comments_with_nocode". Indentation is then set according to code ; position. ;------------------------------------------------------------------------ leave_comments_nocode = yes ; Boolean ;------------------------------------------------------------------------ ; Use this option is used to change non-ascii (non-printable) chars to ; octal notation if they lie within quotes. Either ; Ascii_Chars_Only, XOR Leave_Graphic_Chars parameters need to be set ; as a True value for this parameter to take effect. ;------------------------------------------------------------------------ NonAscii_Quotes_to_Octal = yes ; Boolean ;------------------------------------------------------------------------ ; Setting this parameter to yes will strip non-printable characters ; from the source files, but leave any character that are IBM ; graphics alone. Any non-printable characters that lie within ; quotes will be transformed into octal/character notation, if ; NonAscii_Quotes_To_Octal parameter is set to True. ;------------------------------------------------------------------------ ; leave_graphic_chars = no ; Boolean ;------------------------------------------------------------------------ ; Setting this parameter to yes will strip any non-printable, ; non-ascii characters from the input file. Any non-printable ; octal/character notation if NonAscii_Quotes_To_Octal is set to ; True. Comment out this parameter if you are using ; Leave_Graphic_Chars parameter, as this parameter will override ; it. ;------------------------------------------------------------------------ ascii_chars_only = yes ; Boolean ;------------------------------------------------------------------------ ; This parameter will place open braces on a new line after it's ; associated code if set on/yes. Else the brace will be place on ; next above line if possible, with it's code. ;------------------------------------------------------------------------ place_brace_on_new_line = yes ; Boolean ;------------------------------------------------------------------------ ; This parameter will stop output from the program corrupting output ; that may exit from the program via the standard output. ; If this parameter is set to off/no then no output is generated from ; the program, unless an error is encountered ;------------------------------------------------------------------------ program_output = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies what the internal memory requirements will be in size of the ; line processing buffer. This essentially is used only for open brace ; relocation in kernighan/ritchie style. ;------------------------------------------------------------------------ Queue_Buffer = 1000 ; Integer ;------------------------------------------------------------------------ ; If this option is set to true then the input file will be backup into a ; another file with a ".bac" extension added to the end of the file ; name. ;------------------------------------------------------------------------ Backup_File = yes ; Boolean bcpp-20210108/code/0000755000175100001440000000000013776165640012345 5ustar tomusersbcpp-20210108/code/cb++0000755000175100001440000000073506644442444013006 0ustar tomusers#!/bin/sh # $Id: cb++,v 1.3 1999/01/05 17:00:20 tom Exp $ # Wrapper for 'bcpp', which does indention of C++ code (but doesn't trim # whitespace properly). OPTS="" TMP="$$" trap "rm -f $TMP" 0 1 2 5 15 for name in $* do case $name in -*) echo '...Ignored '$name ;; *.cpp|*.cc|*.hh|*.h|*.ppc|*.pc|*.ph|*.htm*) save=${name}.orig rm -f $save bcpp -fnc bcpp.cfg -yb $name test -f $save && echo '** Modified '$name ;; *) echo '...Skipping '$name ;; esac done bcpp-20210108/code/.vilerc0000644000175100001440000000027007567731036013630 0ustar tomusers; $Id: .vilerc,v 1.4 2002/11/23 16:51:42 tom Exp $ source ~/.vilerc ~with define-submode c notabinsert ts=4 sw=4 ~endwith ~with define-submode cpp notabinsert ts=4 sw=4 ~endwith bcpp-20210108/code/backup.cpp0000644000175100001440000000761413776165472014331 0ustar tomusers//****************************************************************************** // Copyright 1999-2002,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: backup.cpp,v 1.11 2021/01/08 23:31:06 tom Exp $ #include "bcpp.h" #include inline const char *endOf(const char *s) { return (s + strlen(s)); } inline char *endOf(char *s) { return (s + strlen(s)); } inline bool isPathDelim(char ch) { return ((ch == '\\') || (ch == '/')); } static char *FileSuffix(char *name) { char * suffix = endOf(name); while ( ((*suffix != '.') && (suffix > name)) && !isPathDelim(*suffix) ) suffix--; if ((suffix <= name) || isPathDelim(*suffix)) suffix = endOf(name); return suffix; } // Function creates a backup of oldFilename, by renaming it to either // a ".orig" or ".bac" extension. Thereafter, the program will read // from the backup file, and write to the orignal filename. // int BackupFile (char*& oldFilename, char*& newFilename) { const char* suffix = ".bac"; newFilename = oldFilename; oldFilename = new char[strlen(newFilename)+6]; if (oldFilename == NULL) return -1; strcpy(oldFilename, newFilename); char * pLook = FileSuffix(oldFilename); strcat(oldFilename, ".orig"); if (rename(newFilename, oldFilename) != 0) { FILE *fp = fopen(oldFilename, "r"); if (fp != 0) { warning("backup already exists: %s\n", oldFilename); fclose(fp); return -1; } strcpy (pLook, suffix); if (rename(newFilename, oldFilename) != 0) { warning("cannot rename %s\n", newFilename); return -1; } } return 0; } void RestoreIfUnchanged(char *oldFilename, char *newFilename) { FILE *newFp = fopen(newFilename, "r"); FILE *oldFp = fopen(oldFilename, "r"); bool changed = false; int newCh = EOF; int oldCh = EOF; if (newFp != 0 && oldFp != 0) { do { newCh = fgetc(newFp); oldCh = fgetc(oldFp); if (newCh != oldCh) break; } while (newCh != EOF && oldCh != EOF); changed = (newCh != oldCh); } if (newFp != 0) fclose(newFp); if (oldFp != 0) fclose(oldFp); if (!changed) { if (remove(newFilename) != 0) warning("cannot remove %s\n", newFilename); else if (rename(oldFilename, newFilename) != 0) warning("cannot rename %s\n", oldFilename); } } bcpp-20210108/code/tabs.cpp0000644000175100001440000004163213776165625014013 0ustar tomusers//****************************************************************************** // Copyright 1996-2005,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: tabs.cpp,v 1.26 2021/01/08 23:32:37 tom Exp $ // Tab conversion & first-pass scanning #include #include // strlen(), strstr(), strchr(), strcpy(), strcmp() #include "bcpp.h" // ---------------------------------------------------------------------------- // Function takes a unsigned char and converts it to a C type string that // contains the char's value, but in octal (i.e "\000" = null char). // // Parameters: // value : The value that wishes to be converted // // Return Values: // char* : Returns a pointer to the string that was converted. // Memory is allocated via the new command, and once string has been used, // memory should be returned to the system. // static char* ConvertCharToOctal (unsigned char value) { const char octalVals[] = "01234567"; char* pOctalValue = new char[5]; // \000 digits plus null terminator if (pOctalValue != NULL) { int last = 1; switch (value) { case '\a': pOctalValue[1] = 'a'; break; case '\b': pOctalValue[1] = 'b'; break; case '\f': pOctalValue[1] = 'f'; break; case '\n': pOctalValue[1] = 'n'; break; case '\r': pOctalValue[1] = 'r'; break; case '\t': pOctalValue[1] = 't'; break; default: last = 3; for (int pos = last; pos >= 1; pos--) { pOctalValue[pos] = octalVals[(value & 7)]; value >>= 3; // left shift to next three bits } } pOctalValue[0] = ESCAPE; pOctalValue[last+1] = NULLC; } return pOctalValue; } // ---------------------------------------------------------------------------- // Compute the number of characters in an escape static int skipEscape(char *String) { int it = 1; int n = 1; if (isdigit(String[n])) { while (n <= 3) { if (isdigit(String[n++])) it = n-1; else break; } } else if (String[n] == 'x') { while (n <= 3) { if (isxdigit(String[++n])) it = n-1; else break; } } return it; } // ---------------------------------------------------------------------------- #ifdef DEBUG static const char *showCharState(CharState theState) { const char *it; switch (theState) { default: case Blank: it = "Blank"; break; case PreProc: it = "PreProc"; break; case Normal: it = "Normal"; break; case Comment: it = "Comment"; break; case Ignore: it = "Ignore"; break; case DQuoted: it = "DQuoted"; break; case SQuoted: it = "SQuoted"; break; } return it; } #endif // ---------------------------------------------------------------------------- // Compute the state after this character is processed static void nextCharState(char * &String, CharState &theState, int &skip) { if (skip-- <= 0) { skip = 0; if (theState == Blank) { if (!isspace(String[0])) theState = Normal; } if (theState == Normal) { switch (String[0]) { case ESCAPE: skip = skipEscape(String); break; case DQUOTE: theState = DQuoted; break; case SQUOTE: theState = SQuoted; break; case '/': switch (String[1]) { case '*': theState = Comment; skip = 1; break; case '/': theState = Ignore; break; default: break; } break; case SPACE: case TAB: theState = Blank; break; default: break; } } else if (theState == Comment) { if (String[0] == '*' && String[1] == '/') { theState = Normal; skip = 1; } } else if (theState == SQuoted) { switch (String[0]) { case SQUOTE: theState = Normal; break; case ESCAPE: skip = skipEscape(String); break; default: break; } } else if (theState == DQuoted) { switch (String[0]) { case DQUOTE: theState = Normal; break; case ESCAPE: skip = skipEscape(String); break; default: break; } } } } // ---------------------------------------------------------------------------- // Check for non-printable characters, which we'll either quote or remove, // depending on whether they're in strings or not. static int NonPrintable(char c, int mode) { int it = false; unsigned char check = static_cast(c); // remove chars below a space, but not if char is a TAB. if (check < SPACE && check != TAB) { it = true; } else if (mode == 1) { it = (check >= 127); /* non 7-bit ASCII? */ } else if (mode == 3) { it = (check >= 127) && (check < 160); /* ISO C1 character? */ } return it; } // ---------------------------------------------------------------------------- // Function expands tabs to spaces; the number of spaces to expand to is // dependent upon the tabSpaceSize parameter within user settings, and // tab column positions. // // Parameters: // pString : Pointer to the string to process ! // tabLen : How much a tab is worth in spaces. // deleteChars : mode to select non-printing characters for removal/quoting // quoteChars : quote non-printing characters // curState : character-state at beginning (end) of string // lineState : character-states within string // // curState and lineState are set as side-effects // void ExpandTabs (char* &pString, int tabLen, int deleteChars, bool quoteChars, CharState &curState, char * &lineState, bool &codeOnLine) { int col = 0; int skip = 0; size_t last = 0; char* pSTab = pString; bool expand = true; bool my_pString = false; bool had_print = false; CharState oldState = curState; lineState = new char[strlen (pString) + 1]; if (lineState == 0) return; lineState[0] = NullC; //TRACE((" ExpandTabs(%s)%s\n", pString, codeOnLine ? " code" : "")) while (*pSTab != NULLC) { col++; if (isgraph(*pSTab)) had_print = true; if (skip || !isspace(*pSTab)) last = col + skip; if (*pSTab == TAB // calculate tab positions ! && expand && skip == 0 && !(had_print && (curState == Ignore || curState == Comment)) && curState != SQuoted && curState != DQuoted) { int tabAmount = 0; // tab is first character !!!! if (col == 1) tabAmount = tabLen; else tabAmount = ((((col+tabLen-1) / tabLen)) * tabLen) - col + 1; //TRACE(("amount:%d, col:%d, state:%s (%d)\n", tabAmount, col, showCharState(curState), had_print)) if (tabAmount > 0) { // create newString, remove tab ! char* pNewString = new char[strlen (pString) + tabAmount + 1]; char* pNewStates = new char[strlen (pString) + tabAmount + 1]; if (pNewString == NULL || pNewStates == NULL) { if (my_pString) { delete[] pString; pString = 0; } delete[] lineState; return; } my_pString = true; strcpy (pNewStates, lineState); delete[] lineState; lineState = pNewStates; // copy first part strcpy (pNewString, pString); // add spaces char *pAddSpc = pNewString + col - 1; while (tabAmount-- > 0) *pAddSpc++ = SPACE; // add original trailing spaces strcpy (pAddSpc, pSTab+1); delete[] pString; // remove old string from memory pString = pNewString; pSTab = pString + col - 1; // point to the first blank //TRACE(("...%d:%s\n", col, pString)) } else *pSTab = SPACE; } // SCCS ID contains a tab that we don't want to touch else if (*pSTab == '@' && !strncmp(pSTab+1, "(#)", 3)) { expand = false; } else if (NonPrintable(*pSTab, deleteChars)) { if (quoteChars && (curState == SQuoted || curState == DQuoted)) { char* pOctal = ConvertCharToOctal(*pSTab); char* pTemp = new char[strlen(pString)+strlen(pOctal)+1]; if (pOctal == 0 || pTemp == 0) { delete[] pOctal; delete[] pTemp; return; } *pSTab = NULLC; strcpy(pTemp, pString); strcat(pTemp, pOctal); strcat(pTemp, pSTab+1); pSTab = pTemp + (pSTab - pString); delete[] pString; pString = pTemp; pTemp = new char[strlen(pString)+strlen(pOctal)+1]; if (pTemp == 0) { delete[] pOctal; delete[] pTemp; delete[] pString; pString = NULL; return; } strcpy(pTemp, lineState); delete[] lineState; lineState = pTemp; delete[] pOctal; } else // simply remove the character { int n = 0; while ((pSTab[n] = pSTab[n+1]) != NULLC) n++; } col--; //TRACE(("re-interpret col %d\n", col)) continue; // re-interpret character } if (skip == 0) oldState = curState; nextCharState(pSTab, curState, skip); // Set the saved-state based on whether we're transitioning from // something that's got quotes (which are part of it): lineState[col-1] = (curState == Normal) && ((oldState == DQuoted) || (oldState == SQuoted) || (oldState == Comment)) ? oldState : curState; // Override the first '#' on a non-continued line to mark a // preprocessor-control. if (*pSTab == POUNDC && !codeOnLine && ispunct(curState)) { lineState[col-1] = PreProc; } else if (ispunct(lineState[col-1])) { codeOnLine = true; } lineState[col] = NullC; pSTab++; } // Set up for the next time through this procedure if (curState == Ignore) curState = Normal; if (col == 0 || pString[col-1] != ESCAPE) { codeOnLine = false; } if (skip == 0 && (curState == DQuoted || curState == SQuoted)) curState = Normal; // recover from syntax error if (last < strlen(pString)) { pString[last] = NULLC; // trim trailing blanks lineState[last] = NullC; } TRACE((" Expanded (%s)\n", pString)); TRACE((" lineState (%s)\n", lineState)); TRACE(("%s %d/%d %s\n", last > strlen(pString)+1 ? "FIXME" : "", last, strlen(pString), showCharState(curState))); } // ---------------------------------------------------------------------------- // This function is used to allocate memory for indentation within function // OutputToOutFile(). Once the memory needed is allocated, it fills the memory // with spaces, or tabs depending upon the fill mode. // // Parameters: // Mode : Defines the fill mode of the memory that it allocate // 1 = tabs only // 2 = spaces only // 3 = both // len : Number of bytes needed to be allocated // spaceIndent:Number of memory locations a tab character take up // // Return Values: // char* : Returns a pointer to the memory/string that was allocated // char* TabSpacing (int mode, int col, int len, int spaceIndent) { char* pOutTab = NULL; char* pOutSpc = NULL; if ((mode & 1) == 1) { int numOfTabs = 0; // bypass exception error if (spaceIndent > 0) { numOfTabs = ((len+col) / spaceIndent) - (col / spaceIndent); if (len != 0) len = (len + col) % spaceIndent; } pOutTab = new char[numOfTabs + 1]; if (pOutTab != NULL) { for (int fillTabs = 0; fillTabs < numOfTabs; fillTabs++) pOutTab[fillTabs] = TAB; pOutTab[numOfTabs] = NULLC; } else return NULL; // memory allocation failed // If not in both tab, and space concatenation. if ((mode & 2) == 0) return pOutTab; }//bit 0 set ! if ((mode & 2) == 2) { if (pOutTab == NULL) //##### normal space allocation ! { pOutSpc = new char[len+1]; if (pOutSpc != NULL) { for (int fillSpcs = 0; fillSpcs < len; fillSpcs++) pOutSpc[fillSpcs] = SPACE; pOutSpc[len] = NULLC; return pOutSpc; //##### return end product } else return NULL; // memory allocation failed } else // else a mix of spaces & tabs { int numOfSpcs = 0; if (spaceIndent > 0) numOfSpcs = len % spaceIndent; pOutSpc = new char[numOfSpcs+1]; if (pOutSpc != NULL) { for (int fillSpcs = 0; fillSpcs < numOfSpcs; fillSpcs++) pOutSpc[fillSpcs] = SPACE; pOutSpc[numOfSpcs] = NULLC; } else return NULL; // memory allocation failed } }// bit 1 set //##### Concatenate tabs & spaces if ( ((mode & 1) == 1) && ((mode & 2) == 2) ) { char* pConCat = new char[(strlen (pOutTab) + strlen (pOutSpc) + 1)]; // #### Check memory allocation if (pConCat == NULL) { delete[] pOutTab; delete[] pOutSpc; return NULL; } strcpy (pConCat, pOutTab); strcpy (pConCat + strlen (pConCat), pOutSpc); delete[] pOutTab; delete[] pOutSpc; return pConCat; } return NULL; //##### illegal mode passed ! } bcpp-20210108/code/anyobj.cpp0000644000175100001440000000062710271250557014325 0ustar tomusers#ifndef _ANYOBJECT_CODE #define _ANYOBJECT_CODE // Program code written by Steven De Toni ACBC 11 #include "anyobj.h" // ############################################################################### // #### ANYOBJECT Destructor #### // ############################## // Set to virtual so that objects can call there own destructors // without becoming confused. ANYOBJECT::~ANYOBJECT (void) {} #endif bcpp-20210108/code/makefile.in0000644000175100001440000000322411731400623014431 0ustar tomusers# $Id: makefile.in,v 1.12 2012/03/18 15:38:59 tom Exp $ # Makefile-template for 'bcpp' THIS = bcpp #### Start of system configuration section. #### srcdir = @srcdir@ VPATH = @srcdir@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ LINK = $(CXX) LIBS = @LIBS@ LDFLAGS = @LDFLAGS@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ BINDIR = $(DESTDIR)$(bindir) x = @EXEEXT@ o = .@OBJEXT@ #### End of system configuration section. #### SHELL = /bin/sh OBJS = \ bcpp$o \ anyobj$o \ backup$o \ baseq$o \ cmdline$o \ config$o \ debug$o \ execsql$o \ hanging$o \ html$o \ stacklis$o \ strings$o \ tabs$o \ verbose$o CPPFLAGS = -I. -I$(srcdir) \ -DVERSION=\"`cat $(srcdir)/../VERSION`\" \ -DHAVE_CONFIG_H # -DDEBUG -DDEBUG2 PROG = $(THIS)$x .SUFFIXES: .cpp $o .cpp$o: @RULE_CC@ @ECHO_CC@$(CXX) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(CPPFLAGS) -c $< -o $@ all: $(PROG) $(PROG): $(OBJS) @ECHO_LD@$(LINK) $(LDFLAGS) -o $(PROG) $(OBJS) $(LIBS) install: all installdirs $(INSTALL_PROGRAM) $(PROG) $(BINDIR)/$(PROG) $(INSTALL_SCRIPT) cb++ $(BINDIR)/cb++ installdirs: mkdir -p $(BINDIR) uninstall: rm -f $(BINDIR)/$(PROG) rm -f $(BINDIR)/cb++ mostlyclean: rm -f *$o core *~ *.out *.BAK *.atac clean: mostlyclean rm -f $(PROG) distclean: clean rm -f makefile config.log config.cache config.status autoconf.h realclean: distclean rm -f tags TAGS # don't remove configure! check: $(PROG) $(SHELL) ./run-test tags: ctags *.cpp *.h TAGS: etags *.cpp *.h $(OBJS): autoconf.h bcpp.h bcpp-20210108/code/debug.cpp0000644000175100001440000001001311221663452014115 0ustar tomusers//****************************************************************************** // Copyright 1996-2005,2009 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: debug.cpp,v 1.18 2009/06/28 12:50:50 tom Exp $ // Debug/trace functions for BCPP #include #include #include "bcpp.h" void trace(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); } #if defined(DEBUG) || defined(DEBUG2) static const char *traceDataType(DataTypes theType) { const char *it; switch (theType) { case CCom: it = "CCom"; break; case CppCom: it = "CppCom"; break; case Code: it = "Code"; break; case OBrace: it = "OBrace"; break; case CBrace: it = "CBrace"; break; case PreP: it = "PreP"; break; default: case ELine: it = "ELine"; break; } return it; } static const char *traceIndentAttr(IndentAttr theType) { const char *it; switch (theType) { case oneLine: it = "oneLine"; break; case multiLine: it = "multiLine"; break; case blockLine: it = "blockLine"; break; default: it = "noIndent"; break; } return it; } void traceInput(const char *file, int line, InputStruct *pIn) { if (pIn != 0) { TRACE(("%s@%d, %s%s (col:%d)\n", file, line, traceDataType(pIn->dataType), pIn->comWcode ? " comWcode" : "", pIn->offset)); if (pIn->pData != 0) TRACE(("---- data:%s\n", pIn->pData)); if (pIn->pState != 0) TRACE(("---- flag:%s\n", pIn->pState)); } } void traceIndent(const char *file, int line, IndentStruct *pIn) { if (pIn != 0) { TRACE(("%s@%d, Indent %s (pos:%d)\n", file, line, traceIndentAttr(pIn->attrib), pIn->pos)); } } void traceOutput(const char *file, int line, OutputStruct *pOut) { if (pOut != 0) { TRACE(("%s@%d, indent %d(%d:%d), fill %d, OUT #%d:%s:%s:%s:\n", file, line, pOut->bracesLevel, pOut->indentSpace, pOut->indentHangs, pOut->filler, pOut->thisToken, pOut->pCode ? "code" : "", pOut->pBrace ? "brace" : "", pOut->pComment ? "comment" : "")); if (pOut->pCode) TRACE(("----- code:%s\n", pOut->pCode)); if (pOut->pCFlag) TRACE(("---- state:%s\n", pOut->pCFlag)); if (pOut->pBrace) TRACE(("---- brace:%s\n", pOut->pBrace)); if (pOut->pBFlag) TRACE(("---- state:%s\n", pOut->pBFlag)); if (pOut->pComment) TRACE(("-- comment:%s\n", pOut->pComment)); } } #endif bcpp-20210108/code/makefile.blc0000644000175100001440000000114407366323772014604 0ustar tomusers# Make file supplied by Chris Elliott D=..\code .SUFFIXES: .exe .cpp .obj SOURCE= $(D)\bcpp.obj\ $(D)\anyobj.obj\ $(D)\backup.obj\ $(D)\baseq.obj\ $(D)\cmdline.obj\ $(D)\config.obj\ $(D)\debug.obj\ $(D)\execsql.obj\ $(D)\hanging.obj\ $(D)\html.obj\ $(D)\stacklis.obj\ $(D)\strings.obj\ $(D)\tabs.obj\ $(D)\verbose.obj bcpp.exe: $(SOURCE) bcc32 $(SOURCE) clean: erase $(D)\*.obj erase $(D)\*.exe erase $(D)\*.tds .cpp.obj: bcc32 -c -n$(D) $< bcpp-20210108/code/run-test0000755000175100001440000000232307650611367014050 0ustar tomusers#!/bin/sh # $Id: run-test,v 1.7 2003/04/20 21:36:55 tom Exp $ if (make) ; then if test $# != 0 ; then PATH=.:$PATH export PATH BCPP_OPT="-yb" DIFF_OPT="-u" rm -rf result mkdir result test -f output/.vilerc && cp output/.vilerc result/ # top-level directory "input" contains test-files. # subdirectories of "input" contain test-configs. for n in $* do N=`basename $n` if test -f input/$N ; then output=output/$N result=result/$N cp input/$N ${result} echo "** ${result}" ./bcpp -fnc bcpp.cfg $BCPP_OPT ${result} rm -f ${result}.orig diff $DIFF_OPT $output $result elif test -f input/$N/.bcpp ; then OUTPUT="output/$N" RESULT="result/$N" if test -d $RESULT ; then echo "? already exists: $RESULT" else mkdir $RESULT test -f output/.vilerc && cp output/.vilerc $RESULT/ for NN in input/* do if test -f $NN ; then output=$OUTPUT/`basename $NN` result=$RESULT/`basename $NN` cp $NN ${result} echo "** ${result}" ./bcpp -fnc input/$N/.bcpp $BCPP_OPT ${result} rm -f ${result}.orig diff $DIFF_OPT $output $result fi done fi fi done else eval $0 input/* fi fi bcpp-20210108/code/execsql.cpp0000644000175100001440000002303013776165535014516 0ustar tomusers//****************************************************************************** // Copyright 1996-2009,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: execsql.cpp,v 1.22 2021/01/08 23:31:41 tom Exp $ // EXEC SQL parsing & indention #include #include #include "bcpp.h" #include "cmdline.h" // StrUpr() // skip to the beginning of the next word, inclusive of the starting position. int SqlStruct::NextWord(int start, OutputStruct *pOut) { int n = start; bool reset = false; TRACE(("esql next:%s\n", pOut -> pCode+start)); while (pOut -> pCode[n] != NULLC && (pOut -> pCFlag[n] != Normal || !isName(pOut -> pCode[n]))) { if (pOut -> pCFlag[n] == Normal && pOut -> pCode[n] == '-' && pOut -> pCode[n + 1] == '-') { TRACE(("esql found comment:%s\n", pOut->pCode + n)); while (pOut -> pCode[n] != NULLC) { pOut -> pCFlag[n++] = Ignore; } break; } if ((pOut -> pCFlag[n] == Normal && !isName(pOut -> pCode[n])) || pOut -> pCFlag[n] == DQuoted || pOut -> pCFlag[n] == DQuoted) reset = true; n++; } // Maintain the level-counter as the maximum number of words we could // have matched. Punctuation resets it, since the SQL-keywords don't // bypass normal C/C++ syntax. if (reset) { matched[level = 0] = NULLC; if (state == MoreSQL && pOut -> pCFlag[n - 1] == Normal && pOut -> pCode[n - 1] == SEMICOLON) { TRACE(("esql NextWord reset:%.*s^%s\n", n - 1, pOut->pCode, pOut->pCode + n - 1)); state = NotSQL; } } return n; } int SqlStruct::SkipWord(int start, OutputStruct *pOut) { int n = start; TRACE(("esql skip:%s\n", pOut -> pCode+start)); // skip the current word while (pOut -> pCode[n] != NULLC && (ispunct(pOut -> pCFlag[n]) && isName(pOut -> pCode[n]))) n++; return n; } // return true if we've found a keyword which shouldn't be indented bool SqlStruct::SqlVerb(const char *code) { if (!emptyString(code)) { const char *table[] = { "ADD", "AND", "APPEND", "AS", "BEGIN", "BETWEEN", "BODY", "BY", "CANCEL", "CHANGE", "CLOSE", "COMMIT", "CONNECT", "CONTAIN", "CONTAINS", "COUNT", "CREATE", "CURRENT", "CURRVAL", "CURSOR", "DECLARE", "DELETE", "DISABLE", "DO", "DROP", "ELSE", "ELSIF", "ENABLE", "END", "ERASE", "EXCEPTION", "EXECUTE", "EXISTS", "FETCH", "FOR", "FROM", "FUNCTION", "GRANT", "GROUP", "HAVING", "IF", "IN", "INCLUDING", "INCREMENT", "INDEX", "INSERT", "INTO", "IS", "LAST", "LIKE", "MAX", "MIN", "MOD", "MODIFY", "NEW", "NEXT", "NEXTVAL", "NOT", "NULL", "NUMBER", "OF", "ON", "ONLY", "OPEN", "OR", "POSITION", "RAISE", "RANGE", "RAW", "READ", "RECOVER", "REM", "RENAME", "REPLACE", "RESUME", "RETURN", "REVERSE", "REVOKE", "ROLLBACK", "ROW", "ROWID", "SELECT", "SEQUENCE", "SET", "SORT", "SQL", "START", "STOP", "TABLE", "THEN", "THIS", "TO", "TRIGGER", "TRUE", "UNDER", "UNION", "UNIQUE", "UNTIL", "UPDATE", "USE", "USING", "VALIDATE", "VALUES", "VIEW", "WHEN", "WHENEVER", "WHERE", "WHILE", "WITH", }; for (size_t n = 0; n < TABLESIZE(table); n++) { if (CompareKeyword(code, table[n])) { return true; } } } return false; } void SqlStruct::IndentSQL(OutputStruct *pOut) { // (Yes, lex/yacc would be more powerful ;-) const struct { const char *name; int code; } state_keys[] = { { "EXEC", '+' }, { "SQL", 'S' }, { "EXECUTE", 'x' }, { "BEGIN", 'b' }, { "END-EXEC", 'E' }, // match this before "END" { "END", 'e' }, { "DECLARE", 'd' }, { "SECTION", 's' }, }; const struct { const char *text; SqlState code; } state_strings[] = { { "+Sbds", DeclSQL }, // begin declaration { "+Seds", NotSQL }, // end declaration { "+Sxb", BeginSQL }, // begin statement { "E", NotSQL }, // end statement }; SqlState old_state = state; char* pUprString = NULL; // First, look for SQL keywords to see when we've entered a block or // a statement. Ignore preprocessor-lines. if (pOut -> pType == Code && pOut -> pCode != NULL && pOut -> pCFlag != NULL) { pUprString = new char[strlen (pOut -> pCode) + 1]; if (pUprString == NULL) return; StrUpr (strcpy(pUprString, pOut->pCode)); TRACE(("esql HERE:%s\n", pUprString)); TRACE(("esql FLAG:%s\n", pOut->pCFlag)); for (int n = NextWord(0, pOut); pOut -> pCode[n] != NULLC; n = NextWord(n, pOut)) { bool found = false; for (size_t m = 0; m < TABLESIZE(state_keys); m++) { if (CompareKeyword(pUprString+n, state_keys[m].name)) { found = true; matched[level++] = state_keys[m].code; matched[level] = NULLC; n += strlen(state_keys[m].name); // fix for END-EXEC for (size_t j = 0; j < TABLESIZE(state_strings); j++) { if (!strcmp(state_strings[j].text, matched)) { state = state_strings[j].code; matched[level = 0] = NULLC; break; } } break; } } if (!found) { if (state == NotSQL && level >= 2 && !strncmp(matched, "+S", 2)) { state = MoreSQL; TRACE(("esql transition to MoreSQL:%s\n", pOut->pCode + n)); } matched[level = 0] = NULLC; } TRACE(("esql TEST:%s\n", pUprString + n)); TRACE(("->state:%d, level %d, matched:%s\n", state, level, matched)); n = SkipWord(n, pOut); if (pOut -> pCode[n] == NULLC) { break; } } } if (pOut -> pType != PreP) { if (state != NotSQL && old_state != 0) { pOut -> indentHangs = 1; if ((state == BeginSQL || state == MoreSQL) && !SqlVerb(pUprString)) pOut -> indentHangs = 2; TRACE(("esql FIXME-HANG:%d\n", pOut -> indentHangs)); } else if (state == NotSQL && old_state == MoreSQL) { pOut -> indentHangs = 1; if (!SqlVerb(pUprString)) pOut -> indentHangs = 2; TRACE(("esql FIXME-HANG2:%d\n", pOut -> indentHangs)); } } delete[] pUprString; } bcpp-20210108/code/anyobj.h0000644000175100001440000000120106264572725013772 0ustar tomusers#ifndef _ANYOBJECT_HEADER #define _ANYOBJECT_HEADER // Program code written by Steven De Toni ACBC 11 // This header contains a base class definition with a virtual destructor // so that existing objects that inherit from it use their proper destructor // no matter what type they are when being deleted. // ############################################################################### // #### ANYOBJECT Class #### // ######################### // Class used within container (TWOWAYLL) to store objects. // This is the base class for every other object to use. class ANYOBJECT { public: virtual ~ANYOBJECT (void); }; #endif bcpp-20210108/code/cmdline.cpp0000644000175100001440000001774513776164462014503 0ustar tomusers#ifndef _CMDLINE_CODE #define _CMDLINE_CODE // $Id: cmdline.cpp,v 1.26 2021/01/08 23:22:26 tom Exp $ // Program C(++) Beautifier Written By Steven De Toni ACBC 11 12/94 // Revised 1999 - Thomas Dickey // // This module contains methods to parse the command line. #include // atoi() #include #include // strcmp() #include "bcpp.h" #include "cmdline.h" // prototypes // Function converts a lower case string into upper case, any special // characters remain the same (i.e "$", "%" ...) void StrUpr (char* pUpCase) { while (*pUpCase != '\0') { if (isalpha(*pUpCase) && islower(*pUpCase)) *pUpCase = toupper(*pUpCase); pUpCase++; } } // This function displays brief command line help to the user. // Parameters: // char* argv[] : Pointer to command line parameter pointer array // void PrintProgramHelp (void) { static const char *help[] = { "C(++) Beautifier " VERSION, "", "Program Was Written By Steven De Toni, December 1995", "Modified/revised by Thomas E. Dickey 1996-2003,2004", "All Parts Of This Program Are Freely Distributable.", "", "Usage: bcpp [Parameters] [Input File Name] [Output File Name]", "", "Options:", "", "[-bcl] [-bnl] [-cc ] [-f ] [-fi ] [-fnc ]", "[-fo ] [-h] [-i ] [-lg]", "[-na] [-nb] [-nbbi] [-nbi] [-nc] [-nkcwc] [-nlcnc] [-no] [-nq]", "[-qb] [-s] [-t]", "[-ya] [-yb] [-ybbi] [-ybi] [-ykcwc] [-ylcnc] [-yo] [-yq]", "[] []", "", "[] = Optional <> = Parameter Requirement", "", "* Support For I/O Redirection Is Provided *", }; unsigned n; for (n = 0; n < TABLESIZE(help); n++) verbose("%s\n", help[n]); if (prompt("More Detail")) { static const char *details[] = { "-bcl : Open braces on code line", "-bnl : Open braces on new line", "-cc : Column to align comments with code", "-f : Function line spacing", "-fi : Input file name", "-fnc : Load custom configuration file", "-fo : Output file name", "-h or -? : This help message", "-i : Indent space length", "-lg : Leave graphic chars", "-nc : Column to align comments with no code", "-qb : Define internal queue buffer size", "-s : Use spaces in indenting", "-t : Use tabs in indenting", "-tbcl : Top-level open braces on code line", "-tbnl : Top-level open braces on new line", "", "Options beginning with -n or -y disable/enable functions:", " a : Remove non-ASCII chars", " b : Backup input file with .bac extension", " bbi : Indent both braces of a block", " bi : Indent trailing brace of block", " kcwc : Keep comments with Code", " lcnc : Leave comments with NoCode", " o : Program output", " q : Change non-ASCII chars in quotes to octal", }; for (n = 0; n < TABLESIZE(details); n++) verbose("%s\n", details[n]); } } // integer assignment static void intOption (int& cmdCount, int argc, char* argv[], int &result ) { if (++cmdCount <= (argc-1)) { result = atoi (argv[cmdCount]); } else { warning ("Expected Another Integer Parameter For Command Directive %s\n", argv[cmdCount]); PrintProgramHelp (); } } // string assignment static void strOption (int& cmdCount, int argc, char* argv[], char * &result) { if (++cmdCount <= (argc-1)) { result = argv[cmdCount]; } else { warning ("Expected Another String Parameter For Command Directive %s\n", argv[cmdCount]); PrintProgramHelp (); } } #define DecodeFlg(option, flag, value) \ if (strcmp (option, cmdRead) == 0) \ { \ flag = value; \ continue; \ } #define DecodeInt(option, flag) \ if (strcmp (option, cmdRead) == 0) \ { \ intOption (cmdCount, argc, argv, flag); \ continue; \ } #define DecodeStr(option, flag) \ if (strcmp (option, cmdRead) == 0) \ { \ strOption (cmdCount, argc, argv, flag); \ continue; \ } // Function processes command line parameters int ProcessCommandLine (int argc, char* argv[], Config& settings, char*& pInFile, char*& pOutFile, char*& pConfig) { int cmdCount = 0; char* cmdRead; while (cmdCount < argc-1) { // command line error if (cmdCount < 0) return cmdCount; // next command to process! cmdCount++; cmdRead = argv[cmdCount]; // this is a command directive if (cmdRead[0] == '-') { // upcase the command parameter StrUpr (cmdRead); cmdRead++; // miscellaneous flags, "sort +1" DecodeFlg ("BCL", settings.braceLoc, false); DecodeFlg ("BNL", settings.braceLoc, true); DecodeInt ("CC", settings.posOfCommentsWC); DecodeInt ("F", settings.numOfLineFunc); DecodeStr ("FI", pInFile); DecodeStr ("FNC", pConfig); DecodeStr ("FO", pOutFile); DecodeInt ("I", settings.tabSpaceSize); DecodeFlg ("LG", settings.deleteHighChars, 3); DecodeInt ("NC", settings.posOfCommentsNC); DecodeInt ("QB", settings.queueBuffer); DecodeFlg ("S", settings.useTabs, false); DecodeFlg ("T", settings.useTabs, true); DecodeFlg ("TBCL", settings.topBraceLoc, false); DecodeFlg ("TBNL", settings.topBraceLoc, true); // "No" flags DecodeFlg ("NA", settings.deleteHighChars, 0); DecodeFlg ("NB", settings.backUp, false); DecodeFlg ("NBBI", settings.braceIndent2, false); DecodeFlg ("NBI", settings.braceIndent, false); DecodeFlg ("NLCNC", settings.leaveCommentsNC, false); DecodeFlg ("NO", settings.output, false); DecodeFlg ("NQ", settings.quoteChars, false); // "Yes" flags DecodeFlg ("YA", settings.deleteHighChars, 1); DecodeFlg ("YB", settings.backUp, true); DecodeFlg ("YBBI", settings.braceIndent2, true); DecodeFlg ("YBI", settings.braceIndent, true); DecodeFlg ("YLCNC", settings.leaveCommentsNC, true); DecodeFlg ("YO", settings.output, true); DecodeFlg ("YQ", settings.quoteChars, true); // ### display help ### if( (strcmp ("?", cmdRead) == 0) || (strcmp ("H", cmdRead) == 0) ) { verbose ("*** Displaying Brief Help ***\n"); PrintProgramHelp (); return -1; } warning ("Unknown Command Directive %s \n", cmdRead); PrintProgramHelp (); return -1; } else if (pInFile == NULL) pInFile = argv [cmdCount]; else if (pOutFile == NULL) pOutFile = argv [cmdCount]; else { warning ("Command Line Error : Expected Command Directive, Not %s\n", argv[cmdCount]); PrintProgramHelp (); return -1; } } if (settings.queueBuffer < 2) settings.queueBuffer = 2; return 0; } #endif //_CMDLINE_CODE bcpp-20210108/code/stacklis.cpp0000644000175100001440000001040710226270406014650 0ustar tomusers// $Id: stacklis.cpp,v 1.3 2005/04/10 18:31:34 tom Exp $ #ifndef _STACK_LIST_CODE #define _STACK_LIST_CODE // Code written by Steven De Toni ACBC 11 // This file contains the methods that were defined in stacklist.h // header file (i.e container class that stores items in a linked list, // in stack form) #include "stacklis.h" #include // NULL Constant // ############################################################################ // #### StackList Class #### // ######################### // ############################## Public Methods ############################## // ############################### Constructors ############################### #define MY_DEFAULT \ pCurrentPos(NULL), \ itemCount(0), \ spaceAvailable(0) // Initialise internal variables. // StackList::StackList (void) : MY_DEFAULT { } // Initalise variables, and place item passed in a new list // // Parameters: // pItem : Pointer to the object that is will to be stored. // Item must be of descendant ANYOBJECT. // StackList::StackList (ANYOBJECT* pItem) : MY_DEFAULT { push (pItem); } // Places a new item in the list (i.e on the stack). // // Parameters: // pItem : Pointer to the object that is will to be stored. // Item must be of descendant ANYOBJECT. // // Return Values: // int : Returns a error code value to indicate whether operation // was successful or not. // Value: // 0 = No Worries, item stacked. // -1 = Item not stacked, memory allocation failure // int StackList::push (ANYOBJECT* pItem) { ListLink* newItem = new ListLink; if (newItem) // not NULL { // update contents of structure newItem->pItem = pItem; newItem->pLinkedItem = NULL; if (pCurrentPos) // not NULL newItem->pLinkedItem = pCurrentPos; // update start of stack pointer pCurrentPos = newItem; itemCount++; return spaceAvailable; } else { spaceAvailable = -1; return spaceAvailable; } } // Removes a item from the list and returns the value contained within it // back to the user. A NULL value is returns if there are no more items // within the list. // // Return Values: // ANYOBJECT* : Pointer to the object last object that was placed // on the stack. Returns NULL pointer if operation // failed. // ANYOBJECT* StackList::pop (void) { ListLink* pBackUp = pCurrentPos; if (pCurrentPos) // not NULL { ANYOBJECT* pTemp = pCurrentPos->pItem; pCurrentPos = pCurrentPos->pLinkedItem; delete pBackUp; itemCount--; return pTemp; } else return NULL; } // Peeks at items within the linked list without removing // them from the list. // // Parameters: // int item : item number in list. // // Return Values: // ANYOBJECT* : Returns NULL if operation failed, else // pointer to the object contained at list // number selected! // ANYOBJECT* StackList::peek (int item) { ListLink* pPeekPos = pCurrentPos; // invalid range ! if ( ((item < 1) || (item > itemCount)) || (pPeekPos == NULL) ) return NULL; while (item > 1) { pPeekPos = pPeekPos -> pLinkedItem; item--; } return pPeekPos -> pItem; } // Method returns whether last operation failed due to memory allocation // failure. // // Return Values: // int : Returns 1 of two values ... // Values: // 0 = memory available // -1 = Last memory allocation failed. // int StackList::space (void) { return spaceAvailable; } // Returns the number of items current being stacked. // // Returns Values: // int : Num of items within queue. // int StackList::status (void) { return itemCount; } // ############################### Destructor ############################### // Method will remove all list items from memory if they still exist, // no garbage collection provided, or used. // StackList::~StackList (void) { ANYOBJECT* pTest = pop(); while (pTest != NULL) { delete pTest; pTest = pop(); } } #endif bcpp-20210108/code/hanging.cpp0000644000175100001440000001635513776165551014477 0ustar tomusers//****************************************************************************** // Copyright 1996-2005,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: hanging.cpp,v 1.21 2021/01/08 23:31:53 tom Exp $ // Compute hanging-indent for most multiline statements. #include #include #include #include "bcpp.h" static int endOfKeyword(const char *name, int first) { int next = first; while (isName(name[next + 1])) ++next; return next; } static char* parseKeyword(const char *name, int &next) { int first = next; next = endOfKeyword(name, next); unsigned len = next + 1 - first; char* string = new char[len + 1]; strncpy(string, name + first, len)[len] = 0; return string; } // Determine if the current OutputStruct should be indented for hanging // indent of a multi-line statement. Generally, we indent all lines after // the first for a statement, except when other conditions prevail: // // a. we encounter curly-braces (which have their own rules) // b. we encounter a keyword that has its own indention rules void HangStruct::ScanState(const char *code, const char *state) { if (code != 0) { for (int n = 0; code[n] != NULLC; n++) { if (state[n] == Normal) { int c = code[n]; if (isName(c) && (n == 0 || !isName(code[n-1]))) { char *name = parseKeyword(code, n); int findWord = LookupKeyword(name); TRACE(("lookup '%s' ->%d\n", name, findWord)); do_aggreg = false; if (findWord >= 0) { indent = 0; until_parn = 1; if (pIndentWords[findWord].code == oneLine) stmt_level++; else stmt_level = 0; } else { if (!strcmp(name, "enum")) until_curl = 1; if (parn_level == 0) until_parn = 0; indent = 1; } delete[] name; } else if (!isspace(code[n])) { if (do_aggreg && code[n] != L_CURL) do_aggreg = false; switch (code[n]) { case '=': if (parn_level == 0) do_aggreg = true; break; case L_CURL: curl_level++; indent = 0; stmt_level = 0; until_parn = 0; if (do_aggreg) in_aggreg = curl_level; break; case R_CURL: curl_level--; indent = 0; stmt_level = 0; until_curl = 0; break; case ':': // "::" means something different entirely if (code[n+1] == ':') { n++; } else { indent = 0; stmt_level = 0; until_parn = 0; } break; case SEMICOLON: if (parn_level == 0) { indent = 0; stmt_level = 0; until_parn = 0; until_curl = 0; if (in_aggreg > curl_level) in_aggreg = 0; } break; case L_PAREN: parn_level++; indent = 1; break; case R_PAREN: parn_level--; if (until_parn && !parn_level) indent = 0; else indent = 1; break; case ESCAPE: break; default: indent = 1; break; } } } } } } void HangStruct::IndentHanging(OutputStruct *pOut) { #ifdef DEBUG TRACE(("--------------------------------------------------------------\n")); TRACE_OUTPUT(pOut); TRACE(("state:%d/%d, parn:%d/%d, curl:%d, agg:%d/%d\n", indent, stmt_level, until_parn, parn_level, curl_level, do_aggreg, in_aggreg)); #endif if (indent != 0 && curl_level != 0 && (until_parn == 0 || parn_level != 0) && until_curl == 0 && in_aggreg < curl_level && !emptyString(pOut -> pCode) && !emptyString(pOut -> pCFlag) && (pOut -> pCFlag[0] == Normal || !ContinuedQuote(pOut))) { pOut -> indentHangs = indent; if (stmt_level && !until_parn) pOut -> indentHangs += stmt_level; TRACE(("HANG:%d\n", pOut -> indentHangs)); } if (pOut -> pType != PreP) { ScanState(pOut -> pCode, pOut -> pCFlag); ScanState(pOut -> pBrace, pOut -> pBFlag); } } bcpp-20210108/code/makefile.wnt0000644000175100001440000000206406644223332014643 0ustar tomusersINTDIR = . OUTDIR = . LINK32=link.exe CPP_PROJ=/nologo /ML /W3 /GX /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\ /Fp"$(INTDIR)/bcpp.pch" /YX /Fo"$(INTDIR)/" /c LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ odbccp32.lib /nologo /subsystem:console /incremental:no\ /pdb:"$(OUTDIR)/bcpp.pdb" /machine:I386 /out:"$(OUTDIR)/bcpp.exe" CXX =gcc CXXFLAGS =-I$(D) -O2 -Wall .SUFFIXES: .cpp .obj .cpp{$(CPP_OBJS)}.obj: $(CPP) $(CPP_PROJ) $< EXE = bcpp.exe OBJS = \ bcpp.obj \ anyobj.obj \ backup.obj \ baseq.obj \ cmdline.obj \ config.obj \ debug.obj \ execsql.obj \ hanging.obj \ html.obj \ stacklis.obj \ strings.obj \ tabs.obj \ verbose.obj $(EXE) : $(DEF_FILE) $(OBJS) $(LINK32) @<< $(LINK32_FLAGS) $(OBJS) << clean:: - erase *.exe - erase *.obj $(OBJS) : config.h bcpp.obj \ tabs.obj : bcpp.h bcpp-20210108/code/strings.cpp0000644000175100001440000000501513776165607014546 0ustar tomusers//****************************************************************************** // Copyright 1996-2009,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: strings.cpp,v 1.15 2021/01/08 23:32:23 tom Exp $ // strings.cpp #include #include #include #include "bcpp.h" bool isName(char c) { return isalnum(c) || (c == '_') || (c == '$'); } bool CompareKeyword(const char *tst, const char *ref) { bool result = true; int n; for (n = 0; ref[n] != NULLC; n++) { if (tst[n] != ref[n]) { result = false; break; } } if (result) { result = !isName(tst[n]); } if (result) { TRACE(("Match (\"%s\",\"%s\")\n", tst, ref)); } return result; } char *NewString (const char *src) { char* dst = new char[strlen (src)+1]; if (dst != 0) strcpy(dst, src); return dst; } char *NewSubstring (const char *src, size_t len) { char* dst = new char[len + 1]; if (dst != 0) { strncpy(dst, src, len); dst[len] = NULLC; } return dst; } const char *SkipBlanks(const char *s) { while (isspace(*s)) s++; return s; } bcpp-20210108/code/stacklis.h0000644000175100001440000000750610226270362014324 0ustar tomusers// $Id: stacklis.h,v 1.3 2005/04/10 18:31:14 tom Exp $ #ifndef _STACK_LIST_HEADER #define _STACK_LIST_HEADER // Code written by Steven De Toni ACBC 11 // This header definition contains information of the construction, // operation of a container class that holds data in linked list // in stack form. #include // NULL Constant #include "anyobj.h" // use Base class definition // Structure definition used to link the items in the stack struct ListLink { ListLink* pLinkedItem; // linker (pointer to next item in the list) ANYOBJECT* pItem; // variable used to contain the data }; class StackList : public ANYOBJECT { protected: ListLink* pCurrentPos; // pointer to the end of the list int itemCount; // number of items in list int spaceAvailable; // used to test if memory // is still available public: //#### Constructors // Initialise internal variables. // StackList (void); // Initialise variables, and place item passed in a new list // // Parameters: // pItem : Pointer to the object that is will to be stored. // Item must be of descendant ANYOBJECT. // StackList (ANYOBJECT* pItem); // use the defaults here: StackList(const StackList&); StackList& operator=(const StackList&); //#### Access Methods // Places a new item in the list (i.e on the stack). // // Parameters: // pItem : Pointer to the object that is will to be stored. // Item must be of descendant ANYOBJECT. // // Return Values: // int : Returns a error code value to indicate whether operation // was successful or not. // Value: // 0 = No Worries, item stacked. // -1 = Item not stacked, memory allocation failure // int push (ANYOBJECT* pItem); // Removes a item from the list and returns the value contained within it // back to the user. A NULL value is returns if there are no more items // within the list. // // Return Values: // ANYOBJECT* : Pointer to the object last object that was placed // on the stack. Returns NULL pointer if operation // failed. // ANYOBJECT* pop (void); // Peeks at items within the linked list without removing // them from the list. // // Parameters: // int item : item number in list. // // Return Values: // ANYOBJECT* : Returns NULL if operation failed, else // pointer to the object contained at list // number selected! // ANYOBJECT* peek (int item); // Returns the number of items current being stacked. // // Returns Values: // int : Num of items within queue. // int status (void); // Method returns whether last operation failed due to memory allocation // failure. // // Return Values: // int : Returns 1 of two values ... // Values: // 0 = memory available // -1 = Last memory allocation failed. // int space (void); //#### Destructor // Method will remove all list items from memory if they still exist, // no garbage collection provided, or used. // ~StackList (void); }; #endif bcpp-20210108/code/bcpp.cfg0000644000175100001440000001574611221417146013747 0ustar tomusers; $Id: bcpp.cfg,v 1.14 2009/06/27 13:28:06 tom Exp $ ; vile: confmode ; ; This file contains configuration parameters that are used ; within the bcpp program. ; There are two types of parameter types : Boolean, and Integer. ; Boolean types can have only two valid values [On, Yes, or Off, No]. ; Integer types can have a valid range of 0 - 5000. ;------------------------------------------------------------------------ ; This parameter specifies how many lines separate between two ; functions. ;------------------------------------------------------------------------ function_spacing = 2 ; Integer ;------------------------------------------------------------------------ ; Specifies whether to use tabs in indenting code. ;------------------------------------------------------------------------ use_tabs = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies how many spaces to indent. This parameter is also used ; for tab indenting, as 1 tab may be worth 8 spaces if so desired. ; This parameter is used to position comments in TAB mode, and expanding ; of tabs within code! ;------------------------------------------------------------------------ indent_spacing = 4 ; Integer ;------------------------------------------------------------------------ ; Specifies whether to indent preprocessor controls to match the code ;------------------------------------------------------------------------ indent_preprocessor = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies whether to indent embedded SQL statements ;------------------------------------------------------------------------ indent_exec_sql = yes ; Boolean ;------------------------------------------------------------------------ ; If set, overrides comments_with_code setting, forcing inline comments ; to be appended to the code they are adjacent to. ;------------------------------------------------------------------------ keep_comments_with_code = no ; Boolean ;------------------------------------------------------------------------ ; Defines at what start position comments that have code on the ; same line to be placed. ;------------------------------------------------------------------------ comments_with_code = 33 ; Integer ;------------------------------------------------------------------------ ; Defines at what start position comments with no code start. ;------------------------------------------------------------------------ comments_with_nocode = 0 ; Integer ;------------------------------------------------------------------------ ; Set this option to ON turns off setting indentation position of parameter ; "comments_with_nocode". Indentation is then set according to code ; position. ;------------------------------------------------------------------------ leave_comments_nocode = yes ; Boolean ;------------------------------------------------------------------------ ; Use this option is used to change non-ASCII (non-printable) chars to ; octal notation if they lie within quotes. Either ; Ascii_Chars_Only, XOR Leave_Graphic_Chars parameters need to be set ; as a True value for this parameter to take effect. ;------------------------------------------------------------------------ NonAscii_Quotes_to_Octal = yes ; Boolean ;------------------------------------------------------------------------ ; Setting this parameter to yes will strip non-printable characters ; from the source files, but leave any character that are IBM ; graphics alone. Any non-printable characters that lie within ; quotes will be transformed into octal/character notation, if ; NonAscii_Quotes_To_Octal parameter is set to True. ;------------------------------------------------------------------------ ; leave_graphic_chars = no ; Boolean ;------------------------------------------------------------------------ ; Setting this parameter to yes will strip any non-printable, ; non-ASCII characters from the input file. Any non-printable ; octal/character notation if NonAscii_Quotes_To_Octal is set to ; True. Comment out this parameter if you are using ; Leave_Graphic_Chars parameter, as this parameter will override ; it. ;------------------------------------------------------------------------ ascii_chars_only = yes ; Boolean ;------------------------------------------------------------------------ ; This parameter will place top-level open braces on a new line after its ; associated code if set on/yes. Else the brace will be placed on ; next above line if possible, with its code. ;------------------------------------------------------------------------ place_top_brace_on_new_line = yes ; Boolean ;------------------------------------------------------------------------ ; This parameter will place open braces on a new line after its ; associated code if set on/yes. Else the brace will be placed on ; next above line if possible, with its code. ;------------------------------------------------------------------------ place_brace_on_new_line = yes ; Boolean ;------------------------------------------------------------------------ ; This parameter will indent a trailing brace to align with the code ; which is enclosed, rather than with the "if" or similar statement which ; begins the compound statement. ;------------------------------------------------------------------------ brace_indent = no ; Boolean ;------------------------------------------------------------------------ ; This parameter will shift both leading/trailing braces to the right by ; one indent-level. ;------------------------------------------------------------------------ indent_both_braces = no ; Boolean ;------------------------------------------------------------------------ ; This parameter will stop output from the program corrupting output ; that may exit from the program via the standard output. ; If this parameter is set to off/no then no output is generated from ; the program, unless an error is encountered ;------------------------------------------------------------------------ program_output = no ; Boolean ;------------------------------------------------------------------------ ; Specifies what the internal memory requirements will be in size of the ; line processing buffer. This essentially is used only for open brace ; relocation in Kernighan/Ritchie style. ;------------------------------------------------------------------------ Queue_Buffer = 1000 ; Integer ;------------------------------------------------------------------------ ; If this option is set to true then the input file will be backup into a ; another file with a ".bac" extension added to the end of the file ; name. ;------------------------------------------------------------------------ Backup_File = no ; Boolean bcpp-20210108/code/verbose.cpp0000644000175100001440000000517013776165640014521 0ustar tomusers//****************************************************************************** // Copyright 1999-2020,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: verbose.cpp,v 1.10 2021/01/08 23:32:48 tom Exp $ // verbose.cpp #include "bcpp.h" #include #if HAVE_UNISTD_H #include #else #include #endif #undef verbose // in case we defined it to 'printf' static int my_level = 1; void verbose(const char *format, ...) { if (my_level > 0) { va_list ap; va_start(ap, format); vprintf(format, ap); va_end(ap); } } void warning(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); } bool prompt(const char *format, ...) { int code; if (isatty(fileno(stdin)) && isatty(fileno(stdout))) { va_list ap; for(;;) { fprintf(stderr, "\n"); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); fprintf(stderr, " [y/n] ? "); fflush(stderr); code = getc(stdin); if (code == 'y' || code == 'Y') return true; if (code == 'n' || code == 'N') break; } } return false; } bcpp-20210108/code/makefile.unx0000644000175100001440000000125507567703226014660 0ustar tomusers# $Id: makefile.unx,v 1.3 2002/11/23 13:45:58 tom Exp $ # Make file supplied by Piercarlo Grandi # This works on UNIX. D =./ CXX =g++ CXXFLAGS =-I$(D) -O2 -Wall #-DDEBUG -DDEBUG2 .SUFFIXES: .cpp .o .cpp.o: $(CXX) $(CXXFLAGS) -c $< -o $@ BCPP.o = \ $(D)bcpp.o \ $(D)anyobj.o \ $(D)backup.o \ $(D)baseq.o \ $(D)cmdline.o \ $(D)config.o \ $(D)debug.o \ $(D)execsql.o \ $(D)hanging.o \ $(D)html.o \ $(D)stacklis.o \ $(D)strings.o \ $(D)tabs.o \ $(D)verbose.o bcpp: $(BCPP.o) $(CXX) $(BCPP.o) -o $@ clean:: rm -f *.o bcpp *~ *# *.bak $(BCPP.o) : config.h $(D)bcpp.o \ $(D)debug.o \ $(D)execsql.o \ $(D)hanging.o \ $(D)tabs.o : bcpp.h bcpp-20210108/code/bcpp.cpp0000644000175100001440000037430113776164644014010 0ustar tomusers// C(++) Beautifier V1.61 Unix/MS-DOS update ! // ----------------------------------------- // $Id: bcpp.cpp,v 1.135 2021/01/08 23:24:20 tom Exp $ // // Program was written by Steven De Toni 1994 (CBC, ACBC). // Modified/revised by Thomas E. Dickey 1996-2015,2018. // // Steven's original notes follow: // ---------------------------------------------------------------------------- // This program attempts to alter C, C++ code so that it fits to a // format that the user wants. // This program is the result of a project that needed to be written // for a module that I was doing at the Waikato Polytech. // Course : Advanced Certificate In Business Computing (ACBC) // Module : PR-300. // Assignment : Project 1, approx 60 hours. // // The program reads a configuration file that has the user's settings. // Input, and output files are via the command line. // // If compiling under DOS, use Large memory model, any other // type of system (i.e., Unix, Amiga), use default. // I have tried to use all standard Unix functions for I/O to keep // the Unix programmers happy. // // NOTE: // This code has never been tested under any other system other than MS-DOS. // All program code is public domain, you can use any part of this // code on the condition that my name be placed somewhere within documentation, // or program. However, all rights are reserved as to the program logic, that // is to say, you can change it, give it to people, but my name must still // exist within the credits of the old, or newly altered program (Programmers Ethics). // // ################################################################################### // // Program Update : 14/11/94 V1.5 // // Removed a couple more bugs, optimized code (not that you notice it), // added the following features: // - Able to decode lines fully (uses recursion) // - Able to handle unlimited depth handling for single indent code. // - Added command line parameter processing (able use i/o redirection) // - Added variable internal buffer length (used for repositioning of braces) // // ################################################################################### // // Program Update : 21/11/94 V1.55 // // Compiling done using GNU G++, brilliant compiler ... // Dos debugger (debug32) sucked totally compared to Borlands programming // environment, ended up using a series of printf statements in debugging ! // // Program functions perfectly under Sun SPARC station running SunOs V??, // compiled using GNU G++ V2.6.?. Version 1.05 of the GNU running under // DOS functions brilliantly, except for input redirection fails. I think this // could be due to fseek() failing to move back, and forward within the input // stream. Under Unix, this isn't a problem as pipes/redirections are handled // properly ! // // Removed/fixed segmentation violations picked up by G++ within code! // // - Removed non-existing enum constant out of fseek() (I didn't know) // - Wrote my own string upper case routine as standard string.h // didn't have it (again I didn't know). // - Fix a couple of string constants, and few other odds and ends. // // ################################################################################### // // Program Update : 24/11/94 V1.6 // // Final version update of this program. // // - Added a time feature to show long processing of the input // data stream took ... just because I could. // // - Fixed tab space size so that code lines are calculated at correct // lengths according to indent spacing. // // - Implemented a backup feature for the input file, and changed the // selection of input/output file to the Unix standard. // // - fix the following decode problems // if (strcmp (pAString, "A String") == 0) // test for "A String" // ^ // | // Not recognized as a comment because of the quotes chars! // // - struct a { int b, c, d; } as; // The above now gets decoded properly. // // - able to indent multiple depthed switch like structures properly. // // ################################################################################### // // Program Update : 9/1/95 V1.61 // // - Able to set indentation of comments with no code the same as normal code, // this results in the comments lining up with the code. // // This option was brought to you by a Canadian user Justin Slootsky. // // ################################################################################### // // Program Update : 19/2/95 V1.62 // // Fixed error that was caused when C style comment was placed in the wrong // placed which caused program output to be wrong // // if (someCode) /* C Style Comment // // // // /* C Style Comment // if (someCode) // // Fixed output error is multi-if statements were nested together, and have // have code within braces after them. // // if (someCode) { someCode; } // if (someCode) { someCode; } // // // // if (someCode) { someCode; } // if (someCode) { someCode; } // // ################################################################################### // // Program Update : 10/3/95 V1.629 // // Fixed problems with preprocessor statements. All preprocessor statements // are place at column 1. // // ################################################################################### // // Program Update : 4/5/95 V1.7 // // Fixed removing of spaces in c style multiline comments // Remove bug with c style comment that has code before it (uses recursion as a fix) // Added location of program to use bcpp.cfg configuration without specifying // it with options (i.e. uses PATH variable to locate). // ################################################################################### // // Program Update : 27/11/95 V1.75 // // Fixed the indenting of single statements so they don't become corrupt, and // line up with previous code. // Also some simple logic errors where found by users and fixed. // // ################################################################################### // // Program Update : 06/12/95 V1.8 (Bug was created when ported to Unix and // trying to prevent segmentation errors, this has been fixed. The problem // caused incorrect indenting of code if a 'if' statement was within a case // structure. #include // getenv() #include // time() #include // strlen(), strstr(), strchr(), strcpy(), strcmp() #include // character-types #include "cmdline.h" // ProcessCommandLine() #include "bcpp.h" // ---------------------------------------------------------------------------- static int LookupLastKeyword(OutputStruct* pCodeLine); static const char *cppc_begin = "//"; static const char *ccom_begin = "/*"; static const char *ccom_end = "*/"; const IndentwordStruct pIndentWords[] = { { "if", oneLine }, { "while", oneLine }, { "for", oneLine }, { "else", oneLine }, { "case", multiLine }, { "default", multiLine }, { "public", multiLine }, { "protected", multiLine }, { "private", multiLine }, { "do", blockLine }, { "switch", blockLine }, { "while", blockLine }, }; #if defined(DEBUG) || defined(DEBUG2) int totalTokens; // token count, for debugging #endif // ---------------------------------------------------------------------------- static inline const char *endOf(const char *s) { return (s + strlen(s)); } static inline char *endOf(char *s) { return (s + strlen(s)); } static inline char lastChar(const char *s) { return ((s != NULL) && (*s != NULLC)) ? *(endOf(s)-1) : static_cast(NULLC); } static bool IsStartOfComment(char *pLineData, char *pLineState) { if (pLineState[0] == Comment) { if (!strncmp(pLineData, ccom_begin, 2)) return true; } return false; } static bool IsEndOfComment(char *pLineData, char *pLineState) { while (*pLineState++ == Comment) { if (!strncmp(pLineData++, ccom_end, 2)) return true; } return false; } static bool IsLeadingCommentFragment(char *pLineData, char *pLineState) { if (IsStartOfComment(pLineData, pLineState) && !IsEndOfComment(pLineData+2, pLineState+2)) return true; return false; } // Check if we've just extracted a comment fragment, i.e., a C comment // beginning on the current line that doesn't end there. We'll have to defer // the comment til after the code is flushed out, otherwise we end up // commenting it out. static bool ExtractedCCmtFragment(char *pLineData, InputStruct* pItem) { if (*SkipBlanks(pLineData) && IsLeadingCommentFragment(pItem->pData, pItem->pState)) { pItem->comWcode = false; pItem->offset = 0; return true; } return false; } static inline void ShiftLeft(char *s, int len) { if (len > 0) { char *t = s + len; while ((*s = *t) != '\0') { ++s; ++t; } } } int LookupKeyword(const char *tst) { size_t n; if (!emptyString(tst)) { for (n = 0; n < TABLESIZE(pIndentWords); n++) if (CompareKeyword(tst, pIndentWords[n].name)) return n; } return -1; } // Return true if the given data is a blockLine. static bool beginBlockLine(OutputStruct* pItem) { bool result = false; int findWord = LookupKeyword(pItem -> pCode); if (findWord >= 0) { if (pIndentWords[findWord].code == blockLine) { TRACE(("beginBlockLine -- ")); TRACE_OUTPUT(pItem); result = true; } } return result; } // Return true if the given data is a multiLine. static bool beginMultiLine(OutputStruct* pItem) { bool result = false; int findWord = LookupKeyword(pItem -> pCode); if (findWord >= 0) { if (pIndentWords[findWord].code == multiLine) { TRACE(("beginMultiLine -- ")); TRACE_OUTPUT(pItem); result = true; } } return result; } // Return true if the current line is a blockLine preceding L_CURL. static bool beginBlockLine(QueueList* pLines) { return beginBlockLine(reinterpret_cast(pLines -> peek(1))); } // ---------------------------------------------------------------------------- // Function removes leading, trailing, both leading/trailing characters // that are less than or equal to a space character (includes spaces, tabs etc) // // Parameters: // pLineData : Pointer to the start location of the string that's going to be processed // mode : Bit values that define the removal of characters from the string... // 1 = remove spaces from left // 2 = remove spaces from right // 3 = remove spaces from left, and right // // Returns: the number of spaces removed from the left. // static int StripSpacingLeftRight (char* pLineData, char* pLineState, int mode = 3) { int n; int result = 0; if (mode & 1) { for (n = -1; pLineState[n+1] == Blank; n++) ; if (n >= 0) { ShiftLeft(pLineData, n+1); ShiftLeft(pLineState, n+1); result = n+1; } } if (mode & 2) { for (n = strlen(pLineData); n > 0 && pLineState[n-1] == Blank; n--) { pLineData[n-1] = NULLC; pLineState[n-1] = NullC; } } return result; } // ---------------------------------------------------------------------------- // Function returns a Boolean value that shows where code is contained within // a string, given its parse-state. // // Parameters: // pLineState : Pointer to a string to process. // // Return Values: // Boolean : false = line has no code // true = line has some sort of code // static bool TestLineHasCode (char* pLineState) { if (pLineState != NULL) { while (*pLineState != NullC) { if (ispunct(*pLineState)) return true; pLineState++; } } return false; } static inline void TerminateLine(char *pData, char *pState, size_t n) { pData[n] = NULLC; pState[n] = NullC; } /* * Check if the indicated comment is the last item on the line. If it is not, * it is not safe to move to the end of the line, or to a different line, since * we are not sure of the context. */ static bool isFinalComment(int first, int last, char *pData, char *pState) { if (pState[first] == Ignore) { return true; } last += 2; // count the "*/" int limit = strlen(pState); if (last >= limit) { return true; } while (last < limit) { if (pData[last] != ESCAPE && pData[last] != SPACE) return false; ++last; } return true; } static bool isContinuation(size_t &len, char *pData, char *pState) { if (pData != 0 && pState != 0) { len = strlen(pState); if (len != 0 && pData[--len] == ESCAPE && pState[len] != Comment && pState[len] != Ignore) return true; } return false; } static bool isContinuation(InputStruct *pItem) { size_t len; return isContinuation(len, pItem->pData, pItem->pState); } static bool isContinuation(OutputStruct *pItem) { size_t len; return isContinuation(len, pItem->pCode, pItem->pCFlag); } static void TrimContinuation(char *pData, char *pState) { size_t len; if (isContinuation(len, pData, pState)) { while (len > 1 && isspace(pState[len-1]) && isspace(pState[len-2])) { len--; pData[len-1] = SPACE; pData[len] = ESCAPE; pData[len+1] = NULLC; pState[len] = Normal; pState[len+1] = NullC; } if (len > 0 && isspace(pState[len-1])) { pData[len-1] = SPACE; } } } // check if the given data is a preprocessor-line static inline bool isPreproLine(OutputStruct* pOut) { return ((pOut != 0) && (pOut->pCode != 0) && (pOut->pType == PreP)); } // check if the given data begins with a right curly-brace static inline bool BeginsCurly(OutputStruct* pOut) { bool result = false; for (int n = 0; pOut->pCode[n] != NULLC; ++n) { if (pOut->pCFlag[n] != Blank) { if (pOut->pCFlag[n] == Normal && pOut->pCode[n] == R_CURL) result = true; break; } } return result; } // ---------------------------------------------------------------------------- // This function is used within function DecodeLine(), it creates a new // InputStructure and stores what is contained in pLineData string in // the newly created structure. // // Parameters: // offset : offset within original line's text of this component // pLineData : Pointer to the string to store within the InputStructure. // dataType : Type of data that is to be stored within the InputStructure // see DataTypes enum. // removeSpace : true when we're to remove leading/trailing blanks // // Return Values: // InputStruct* : Returns a pointer to the newly constructed InputStructure, // returns a NULL value if unable to allocate memory. // static InputStruct* ExtractCode (int offset, char* pLineData, char* pLineState, DataTypes dataType = Code, bool removeSpace = true) { char* pNewCode = 0; char* pNewState = 0; InputStruct* pItem = 0; if ((pNewCode = NewString(pLineData)) != 0) { if ((pNewState = NewString(pLineState)) != 0) { // strip spacing in new string before storing if (removeSpace != false) { offset += StripSpacingLeftRight (pNewCode, pNewState); if (dataType == Code || dataType == PreP) TrimContinuation(pNewCode, pNewState); } if ((pItem = new InputStruct(dataType, offset)) != 0) { pItem -> pData = pNewCode; pItem -> pState = pNewState; return pItem; } delete pNewState; } delete pNewCode; } return 0; } // ---------------------------------------------------------------------------- // Extracting comments from the input line is a little more complicated than // the code fragments, since we'll strip the comments out of the input line // after extracting them. // static InputStruct* ExtractCCmt (int& offset, int start, int end, char* pLineData, char* pLineState, DataTypes dataType = CCom) { InputStruct* pItem = 0; char endData = NULLC; char endState = NULLC; size_t len = (end >= 0) ? static_cast(end - start + 2) : strlen(pLineData); size_t last = start + len; if (end >= 0) { endData = pLineData[last]; endState = pLineState[last]; TerminateLine(pLineData, pLineState, last); } pItem = ExtractCode( offset + start, pLineData + start, pLineState + start, dataType, false); if (end >= 0) { pLineData[last] = endData; pLineState[last] = endState; ShiftLeft (pLineData +start, len); ShiftLeft (pLineState+start, len); } else { TerminateLine(pLineData, pLineState, start); } if (pItem != 0) { pItem -> comWcode = TestLineHasCode (pLineState); // Comment without code ? } offset += len; TRACE(("Updated offset to %d\n", offset)); return pItem; } // ---------------------------------------------------------------------------- // This Function is used to de-allocate memory in a InputStructure. // A destructor wasn't used because other objects may also own the // same memory. // // Parameters: // pDelStruct : Pointer to a dynamically allocated InputStructure within // string data allocated. // static inline void CleanInputStruct (InputStruct* pDelStruct) { if (pDelStruct != NULL) { delete[] pDelStruct -> pState; delete[] pDelStruct -> pData; delete pDelStruct; } } // ---------------------------------------------------------------------------- // Function is used within function DecodeLine() to de-allocate memory // that it is currently using. This function is called upon a memory // allocation failure. // // Parameters: // PDelQueue : Pointer to a QueueList object which in general will contain // InputStructures. // static int DecodeLineCleanUp (QueueList* pDelQueue) { // Don't implement destructor as other objects may be using the same // memory when using structure in output line processing (simple garbage collection) while (pDelQueue->status() > 0) CleanInputStruct ( reinterpret_cast(pDelQueue -> takeNext()) ); return -1; } static int FindStartofComment(char *pLineState, CharState code = Comment) { int it = -1; int n; for (n = 0; pLineState[n] != NullC; n++) { if (pLineState[n] == code) { it = n; break; } } return it; } static int FindEndofComment(char *pLineState) { int it = -1; int n; for (n = 0; pLineState[n] == Comment; n++) { if (pLineState[n+1] == Comment && pLineState[n+2] != Comment) { it = n; break; } } return it; } // find punctuation delimiting code, e.g., curly braces or semicolon static int FindPunctuation(char *pLineData, char *pLineState, char punct) { int it = -1; int n; for (n = 0; pLineData[n] != NULLC; n++) { if (pLineState[n] == Normal && pLineData[n] == punct) { it = n; break; } } return it; } // ---------------------------------------------------------------------------- // When splitting a line (e.g., to move an open brace), check to see if the // right fragment has a backslash escaping the newline. If so, append one to // the left fragment. // // pItem : pointer to structure that we may append continuation to. // pLineData : Pointer to a line of a users input file (string). // pLineState : Pointer to a state of a users input line (string). // static void splitContinuation(InputStruct *pItem, char *pLineData, char *pLineState, bool force) { size_t len; if (force && !strcmp(pLineData, pItem->pData)) force = false; if ((force || isContinuation(len, pLineData, pLineState)) && !isContinuation(len, pItem->pData, pItem->pState)) { char *s = new char[len + 4]; strcpy(s, pItem->pData); strcat(s, " \\"); delete[] pItem->pData; pItem->pData = s; s = new char[len + 4]; strcpy(s, pItem->pState); s[++len] = Blank; s[++len] = Normal; s[++len] = NullC; delete[] pItem->pState; pItem->pState = s; } } // ---------------------------------------------------------------------------- // This function is a single pass decoder for a line of input code that // is read from the user's input file. The function stores each part of a line, // be it a comment (with its attributes), code, open brace, close brace, or // blank line as a InputStructure, each InputStructure is stored within // a Queue Object. // // Parameters: // offset : offset within original line's text of this component // pLineData : Pointer to a line of a users input file (string). // pLineState : Pointer to a state of a users input line (string). // QueueList* : Pointer to a QueueList object will contains all of // a lines basic elements. If this object doesn't contain // any elements, then it suggests there was a processing // problem. // // Return Values: // int : returns a error code. // -1 : Memory allocation failure // 0 : No Worries // static int DecodeLine (bool afterSlash, int offset, char* pLineData, char *pLineState, QueueList* pInputQueue) { int SChar = -1; int EChar = -1; size_t commentLen = 0; // @@@@@@ C Comment processing, if over multiple lines @@@@@@ if (*pLineState == Comment && !IsStartOfComment(pLineData, pLineState)) { //#### Test to see if end terminating C comment has arrived ! EChar = FindEndofComment(pLineState); if (EChar >= 0) { InputStruct* pItem = ExtractCCmt(offset, 0, EChar, pLineData, pLineState, CCom); if (pItem == NULL) return DecodeLineCleanUp (pInputQueue); TRACE_INPUT(pItem) pInputQueue->putLast (pItem); } else //##### Place output as comment without code (C comment terminator not found) { InputStruct* pTemp = ExtractCode (offset, pLineData, pLineState, CCom, false); // don't remove spaces ! //#### Test if memory allocated if (pTemp == NULL) return DecodeLineCleanUp (pInputQueue); TRACE_INPUT(pTemp) pInputQueue->putLast (pTemp); return 0; } }// if multi-line C style comments // N.B Place this function here as to sure not to corrupt relative pointer // settings that may be used within pLinedata, and become altered through // using this routine. offset += StripSpacingLeftRight (pLineData, pLineState); //@@@@@@ Extract /* comment */ C type comments on one line SChar = FindStartofComment (pLineState); // find start of C Comment if (SChar >= 0) { //##### Check if there is a ending C terminator comment string EChar = FindEndofComment(pLineState+SChar) + SChar; //##### If negative then comments are on multiple lines ! if (EChar < 0) { InputStruct* pItem = ExtractCCmt(offset, SChar, -1, pLineData, pLineState, CCom); if (pItem == NULL) return DecodeLineCleanUp (pInputQueue); // make multi-line C style comments totally separate // from code to avoid some likely errors occurring if they // are shifted due to being over written by code. // apply recursion so that comment is last item placed // in queue ! if (DecodeLine (afterSlash, offset, pLineData, pLineState, pInputQueue) != 0) { // problems ! delete[] pItem -> pData; delete pItem; return -1; } TRACE_INPUT(pItem) pInputQueue->putLast (pItem); return 0; // no need to continue processing } else if (!isFinalComment(SChar, EChar, pLineData, pLineState)) { InputStruct* pItem = ExtractCode(offset, pLineData, pLineState); TRACE_INPUT(pItem) pInputQueue->putLast (pItem); return 0; // no need to continue processing } else if (!isContinuation(commentLen, pLineData, pLineState)) { InputStruct* pItem = ExtractCCmt(offset, SChar, EChar, pLineData, pLineState, CCom); if (pItem == NULL) return DecodeLineCleanUp (pInputQueue); if (ExtractedCCmtFragment(pLineData, pItem)) { if (DecodeLine (afterSlash, offset, pLineData, pLineState, pInputQueue) != 0) return DecodeLineCleanUp(pInputQueue); TRACE_INPUT(pItem) pInputQueue->putLast (pItem); return 0; } else { TRACE_INPUT(pItem) pInputQueue->putLast (pItem); } } //##### else }//##### If "/*" C comments present //##### Remove blank spacing from left & right of string offset += StripSpacingLeftRight (pLineData, pLineState); //@@@@@@ C++ Comment Processing ! SChar = FindStartofComment (pLineState, Ignore); if (SChar >= 0) { int myoff = offset; InputStruct* pItem = ExtractCCmt(myoff, SChar, -1, pLineData, pLineState, CppCom); if (pItem == NULL) return DecodeLineCleanUp (pInputQueue); if (ExtractedCCmtFragment(pLineData, pItem)) { if (DecodeLine (afterSlash, offset, pLineData, pLineState, pInputQueue) != 0) return DecodeLineCleanUp(pInputQueue); TRACE_INPUT(pItem) pInputQueue->putLast (pItem); return 0; } else { TRACE_INPUT(pItem) pInputQueue->putLast (pItem); } } //##### Remove blank spacing from left & right of string offset += StripSpacingLeftRight (pLineData, pLineState); //@@@@@@ #define (preprocessor extraction) if (pLineState[0] == POUNDC) { //#### create new queue structure ! InputStruct* pItem = ExtractCode(offset, pLineData, pLineState, PreP); //#### Test if memory allocated if (pItem == NULL) return DecodeLineCleanUp (pInputQueue); TRACE_INPUT(pItem) pInputQueue->putLast (pItem); return 0; // no worries ! } //################# Actual Code Extraction ################# offset += StripSpacingLeftRight (pLineData, pLineState); //@@@@@@ Test what's left in line for L_CURL, and R_CURL braces SChar = FindPunctuation(pLineData, pLineState, L_CURL); EChar = FindPunctuation(pLineData, pLineState, R_CURL); bool testEnumType = false; if ( ((SChar >= 0) && (EChar >= 0)) && (SChar < EChar)) { // test to see if there are multiple open/ close braces in enum // selective range // i.e. { if ( a == b ) { b = c } else { d = e } } int OBrace2 = FindPunctuation(pLineData+SChar+1, pLineState+SChar+1, L_CURL); if ( (OBrace2 < 0) || ((OBrace2 > EChar) && (OBrace2 >= 0)) ) testEnumType = true; } //##### If condition correct, then make rest of line just code ! (e.g enum) // if no items in input queue, and no multiple open, close braces in // line then .... extract as enum. if ( (testEnumType != false) && (pInputQueue -> status () <= 0) ) { //store code as enum type if follow-up condition is true EChar++; switch (pLineData[EChar]) // advance another char? { case SEMICOLON: case ',': EChar++; break; default: break; } char saveData = pLineData[EChar]; pLineData[EChar] = NULLC; char saveState = pLineState[EChar]; pLineState[EChar] = NULLC; InputStruct* pTemp = ExtractCode(offset, pLineData, pLineState); if (pTemp == NULL) return DecodeLineCleanUp (pInputQueue); pLineData[EChar] = saveData; pLineState[EChar] = saveState; splitContinuation(pTemp, pLineData, pLineState, afterSlash); TRACE_INPUT(pTemp) pInputQueue->putLast (pTemp); offset += EChar; ShiftLeft (pLineData, EChar); ShiftLeft (pLineState, EChar); // restart decoding line ! return DecodeLine (afterSlash, offset, pLineData, pLineState, pInputQueue); // end of recursive call ! } // if L_CURL and R_CURL exist on same line //##### Determine extraction precedence ! if ((SChar >= 0) && (EChar >= 0)) { if (SChar > EChar) SChar = -1; else EChar = -1; } //##### Place whatever is before the open brace L_CURL, or R_CURL as code if ((SChar >= 0) || (EChar >= 0)) { char saveCode; char saveFlag; int toSave = SChar >= 0 ? SChar : EChar; saveCode = pLineData[toSave]; pLineData[toSave] = NULLC; saveFlag = pLineState[toSave]; pLineState[toSave] = NULLC; //#### Store leading code if any if (TestLineHasCode (pLineState) != false) { char* pTemp = NewString(pLineData); if (pTemp == NULL) return DecodeLineCleanUp (pInputQueue); //#### strip spacing is handled within extractCode routine. This //#### means that pointers that are calculated before stripSpacing //#### function remain valid. InputStruct* pLeadCode = ExtractCode (offset, pTemp, pLineState); if (pLeadCode == NULL) return DecodeLineCleanUp (pInputQueue); pLineData[toSave] = saveCode; pLineState[toSave] = saveFlag; splitContinuation(pLeadCode, pLineData+toSave+1, pLineState+toSave+1, afterSlash); TRACE_INPUT(pLeadCode) pInputQueue->putLast (pLeadCode); delete[] pTemp; } //##### Update main string offset += toSave; pLineData[toSave] = saveCode; ShiftLeft (pLineData, toSave); pLineState[toSave] = saveFlag; ShiftLeft (pLineState, toSave); TrimContinuation(pLineData, pLineState); // extract open/closing brace from code, and place brace as separate // line from code. And create new structure for code InputStruct* pTemp = 0; int extractMode; if (pLineData[0] == L_CURL) extractMode = 1; // remove open brace else extractMode = 2; // remove close brace do { switch (extractMode) { case (1): // remove open brace { saveCode = pLineData[1]; pLineData[1] = NULLC; saveFlag = pLineState[1]; pLineState[1] = NULLC; pTemp = ExtractCode (offset, pLineData, pLineState, OBrace);//##### Define data type before storing offset += 1; pLineData[1] = saveCode; ShiftLeft (pLineData, 1); pLineState[1] = saveFlag; ShiftLeft (pLineState, 1); splitContinuation(pTemp, pLineData, pLineState, afterSlash); extractMode = 3; // apply recursive extraction break; } case (2): // remove close brace { // test the type of close brace extraction ! // check for following code ... // struct { int a, b, } aStructure; //@@@@@@ Test what's left in line for L_CURL, and R_CURL braces // start one after first char ! SChar = FindPunctuation(pLineData+1, pLineState+1, L_CURL); EChar = FindPunctuation(pLineData+1, pLineState+1, R_CURL); if ((SChar >= 0) || (EChar >= 0)) { int mark; if (pLineData[1] == SEMICOLON) // if true, extract after char mark = 2; else mark = 1; saveCode = pLineData[mark]; pLineData[mark] = NULLC; saveFlag = pLineState[mark]; pLineState[mark] = NULLC; pTemp = ExtractCode (offset, pLineData, pLineState, CBrace); offset += mark; pLineData[mark] = saveCode; ShiftLeft (pLineData, mark); pLineState[mark] = saveFlag; ShiftLeft (pLineState, mark); splitContinuation(pTemp, pLineData, pLineState, afterSlash); extractMode = 3; // apply recursive extraction } else // rest of data is considered as code ! { pTemp = ExtractCode (offset, pLineData, pLineState, CBrace); splitContinuation(pTemp, pLineData, pLineState, afterSlash); pLineState = NULL; // leave processing ! } break; } case (3): // remove what is left on line as code. { return DecodeLine (afterSlash, offset, pLineData, pLineState, pInputQueue); // end of recursive call ! } }// switch; //#### Test if memory allocated if (pTemp == NULL) return DecodeLineCleanUp (pInputQueue); TRACE_INPUT(pTemp) pInputQueue->putLast (pTemp); // store Item } while ((TestLineHasCode (pLineState) != false) && (pTemp != NULL)); } else //##### Line contains either code, or spacing { //##### If nothing in string, and nothing stored in queue, then blank line if ((pLineData[0] == NULLC) && ((pInputQueue->status()) <= 0)) { //##### implement blank space InputStruct* pTemp = ExtractCode (offset, pLineData, pLineState, ELine); if (pTemp == NULL) return DecodeLineCleanUp (pInputQueue); TRACE_INPUT(pTemp) pInputQueue->putLast (pTemp); } //##### If line has more than spacing/tabs then code else if (TestLineHasCode (pLineState) != false && strcmp(pLineData, "\\") != 0) { // implement blank space InputStruct* pTemp = ExtractCode (offset, pLineData, pLineState); if (pTemp == NULL) return DecodeLineCleanUp (pInputQueue); TRACE_INPUT(pTemp) pInputQueue->putLast (pTemp); } } return 0; // no worries } // If the comment (fragment) doesn't begin a comment, we may be continuing // a multi-line comment. Adjust its indention to line up with the beginning // to avoid a hanging-indent appearance. static void dontHangComment(InputStruct *pIn, OutputStruct *pOut, QueueList* pLines) { if (pIn -> dataType == CCom && strncmp(pOut -> pComment, ccom_begin, 2) != 0) { const char *text = SkipBlanks(pOut -> pComment); int count = pLines -> status(); int length = text - pOut -> pComment; // If the comment text begins with an '*', increase the indention by // one unless it follows a comment-line that didn't begin with '*'. if (count > 0) { bool star = (*text == '*'); while (count > 0) { OutputStruct *pTemp = reinterpret_cast(pLines -> peek(count--)); if (pTemp == 0 || pTemp -> pComment == 0) continue; text = SkipBlanks(pTemp -> pComment); if (!strncmp(text, ccom_begin, 2)) { if (!star) { if (length > pTemp -> offset) length = pTemp -> offset; } break; } if (*text != '*') star = false; } ShiftLeft(pOut -> pComment, length); if (star) pOut -> indentSpace += 1; } } } // if nothing in queue, or next item isn't code then some sort of error static bool inputIsCode(InputStruct *pItem) { if (pItem != NULL) { switch (pItem -> dataType) { case Code: case OBrace: case CBrace: case PreP: return true; case CCom: case CppCom: case ELine: case NoType: break; } } warning ("\n#### ERROR ! Error In Line Construction !"); warning ("\nExpected Some Sort Of Code ! Data Type Found = "); if (pItem == NULL) warning ("NULL"); else warning ("%d", pItem -> dataType); return false; // ##### incorrect dataType expected! } // ---------------------------------------------------------------------------- // Determine the type of preprocessor-control: // 0 = unknown (leave it alone!) // 1 = if-nesting // 2 = if-unnesting // 3 = nest/unnest // 4 = other static int typeOfPreP(InputStruct *pItem) { static const struct { const char *keyword; int code; } table[] = { { "define", 4 }, { "elif", 3 }, { "else", 3 }, { "endif", 2 }, { "error", 4 }, { "if", 1 }, { "ifdef", 1 }, { "ifndef", 1 }, { "include", 4 }, { "line", 4 }, { "pragma", 4 }, { "undef", 4 } }; const char *s = pItem -> pData; // FIXME: we should be using the "state", just in case there's quotes if (*s == POUNDC) { s = SkipBlanks(s+1); for (size_t i = 0; i < TABLESIZE(table); i++) { if (CompareKeyword(s, table[i].keyword)) return table[i].code; } } return 0; } // Returns the combination of brace-indent and preprocessor-indent static int combinedIndent(int indentStack, int prepStack, Config userS) { if (prepStack > userS.tabSpaceSize) return indentStack + prepStack - userS.tabSpaceSize; return indentStack; } // ---------------------------------------------------------------------------- // Analyze an OutputStruct to see if it began as a continued quoted-string. bool ContinuedQuote(OutputStruct *pOut) { if (pOut -> pCode != 0 && pOut -> pCFlag != 0) { if (pOut -> pCFlag[0] == SQuoted || pOut -> pCFlag[0] == DQuoted) { return (pOut -> pCFlag[0] != pOut -> pCode[0]); } } return false; } // ---------------------------------------------------------------------------- // Check if the given fragment ends a statement (i.e., there's a semicolon that // isn't quoted, and not within parentheses static bool EndsStatement(OutputStruct *pOut) { int nested = 0; for (int n = 0; pOut -> pCode[n] != NULLC; n++) { if (pOut -> pCFlag[n] == Normal) { if (pOut -> pCode[n] == L_PAREN) nested++; else if (pOut -> pCode[n] == R_PAREN) nested--; else if (nested == 0 && pOut -> pCode[n] == SEMICOLON) return true; } } return false; } // ---------------------------------------------------------------------------- // Check for an "else" or "else if" that doesn't finish the statement on the // given fragment. static bool BeginsElseClause(OutputStruct *pOut) { if (CompareKeyword(pOut -> pCode, "else")) { return !EndsStatement(pOut); } return false; } // ---------------------------------------------------------------------------- // Compute next curly-brace level after the given line static void computeBraces(OutputStruct *pOut, int& level) { TRACE_OUTPUT(pOut); if (pOut->pCode != 0 && pOut->pCFlag != 0) { for (int n = 0; pOut->pCFlag[n] != NullC; ++n) { if (pOut->pCFlag[n] == Normal) { if (pOut->pCode[n] == L_CURL) ++level; else if (pOut->pCode[n] == R_CURL) --level; } } } else if (pOut->pBrace != 0 && pOut->pBFlag != 0) { for (int n = 0; pOut->pBFlag[n] != NullC; ++n) { if (pOut->pBFlag[n] == Normal) { if (pOut->pBrace[n] == L_CURL) ++level; else if (pOut->pBrace[n] == R_CURL) --level; } } } // this could happen in a syntax-bending macro if (level < 0) level = 0; } // Check if the given output line was a preprocessor line that ended with // a backslash. static bool outputWasContinuedPreP (OutputStruct * pOut) { if (pOut != 0 && pOut -> pType == PreP && isContinuation(pOut)) { return true; } return false; } // ---------------------------------------------------------------------------- // Function takes a QueueList object that contains InputStructure items, and // uses these items to reconstruct a compressed version of a output line of // code, comment, or both. // // Parameters: // indentStack : Variable used to show how many spaces/tabs to indent when // creating a new OutputStructure. // pInputQueue : Pointer to the InputStructure queue object. // pOutputQueue: Pointer to the OutputStructure queue object. // userS : Structure that contains the users config settings. // // Return Values: // int : Return values of ... // 0 = No problems // -1 = Memory allocation failure // -2 = Line construction error, unexpected type found. static int ConstructLine ( bool &indentPreP, int &prepStack, // level of preprocessor-stack int& bracesLevel, // curly-brace level for normal line int& preproLevel, // curly-brace level for preprocesor line int& indentStack, bool& pendingElse, HangStruct& hang_state, SqlStruct& sql_state, QueueList* pInputQueue, QueueList* pOutputQueue, const Config& userS) { InputStruct* pTestType = NULL; char *pendingComment = NULL; TRACE(("ConstructLine indentStack=%d\n", indentStack)); while ( pInputQueue->status() > 0 ) { int tokenIndent = indentStack; pTestType = reinterpret_cast(pInputQueue -> takeNext()); OutputStruct* pOut = new OutputStruct(pTestType); if (pOut == NULL) return -1; // Special logic to make controls for MCCONFIG look "correct" if (pTestType -> dataType == CppCom) { const char *tst = SkipBlanks(pTestType -> pData + 2); static const char *keys[] = { "MCCONFIG{{", "MCCONFIG}}" }; if (CompareKeyword(tst, keys[0])) indentPreP = true; if (CompareKeyword(tst, keys[1])) indentPreP = false; } int theType = pTestType -> dataType; for (int p = pOutputQueue -> status(); p > 0; --p) { OutputStruct *pq = reinterpret_cast(pOutputQueue -> peek(p)); if (pq != 0 && pq -> pCFlag != 0) { if (outputWasContinuedPreP (pq)) { theType = PreP; } break; } } switch (theType) { //@@@@@@@ Processing of C type comments /* comment */ case (CCom): //@@@@@@@ Processing of C++ type comments // comment case (CppCom): { if (pTestType -> comWcode == true) //##### If true then comment has code { InputStruct *pNextItem = reinterpret_cast(pInputQueue -> peek(1)); if (pNextItem == 0) { // comment after nothing? pOut -> pComment = pTestType -> pData; dontHangComment(pTestType, pOut, pOutputQueue); break; } if (!inputIsCode(pNextItem)) return -2; // ##### incorrect dataType expected! // if pData length overwrites comments then place comments on new line if (!userS.keepCommentsWC && (indentStack + static_cast(strlen (pNextItem -> pData))) > (userS.posOfCommentsWC) ) { /* * Check if this is a comment or fragment which we will * delay after the code on the current line. If so, * indent it to align with code. */ if ((pTestType->dataType == CCom && !strncmp(pTestType->pData, ccom_begin, 2)) || (pTestType->dataType == CppCom)) { pOut -> filler = userS.posOfCommentsWC; } else { pOut -> filler = indentStack + 1; } pOut -> pComment = pTestType -> pData; TRACE(("@%d, Split Comment = %s:%d\n", __LINE__, pOut->pComment, pOut->thisToken)); } else { pendingComment = pTestType -> pData; TRACE(("@%d, Pending Comment = %s:%d\n", __LINE__, pendingComment, pOut->thisToken)); delete[] pTestType -> pState; delete pTestType; delete pOut; continue; } } else { if (userS.leaveCommentsNC != false) { pOut -> indentSpace = combinedIndent(indentStack, prepStack, userS); if ((pOut -> offset >= userS.posOfCommentsWC) && (pOut -> indentSpace < userS.posOfCommentsWC)) { pOut -> indentSpace = 0; pOut -> filler = userS.posOfCommentsWC; } } else pOut -> indentSpace = userS.posOfCommentsNC; pOut -> pComment = pTestType -> pData; dontHangComment(pTestType, pOut, pOutputQueue); TRACE(("@%d, Set Comment = %s:%d indent %d\n", __LINE__, pOut->pComment, pOut->thisToken, pOut->indentSpace)); }// else a comment without code ! break; }// case // @@@@@@ Processing of code (i.e k = 1; enum show {one, two};) case (Code): { pOut -> pCode = pTestType -> pData; pOut -> pCFlag = pTestType -> pState; if (!ContinuedQuote(pOut)) { pOut -> indentSpace = combinedIndent(indentStack, prepStack, userS); // Special case: align "else" and "if" if they're on successive lines if (pendingElse && CompareKeyword(pOut -> pCode, "if")) pOut -> splitElseIf = true; pendingElse = BeginsElseClause(pOut); } TRACE(("@%d, Set Code = %s:%d indent %d\n", __LINE__, pOut->pCode, pOut->thisToken, pOut->indentSpace)); break; } // @@@@@@ Processing of open brackets "{ k = 1;" case (OBrace): // @@@@@@ Processing of closed brackets "} k = 1;" case (CBrace): { pendingElse = false; // indent back before adding brace, some error checking if ((pTestType -> dataType == CBrace) && !userS.braceIndent) { indentStack -= userS.tabSpaceSize; if (indentStack < 0) indentStack = 0; tokenIndent = indentStack; } pOut -> indentSpace = combinedIndent(indentStack, prepStack, userS); pOut -> pBrace = pTestType -> pData; pOut -> pBFlag = pTestType -> pState; TRACE(("@%d, Set pBrace = %s:%d indent %d\n", __LINE__, pOut->pBrace, pOut->thisToken, pOut->indentSpace)); // ##### advance to the right ! if (pTestType -> dataType == OBrace) indentStack += userS.tabSpaceSize; // indent back before adding brace, some error checking if ((pTestType -> dataType == CBrace) && userS.braceIndent) { indentStack -= userS.tabSpaceSize; if (indentStack < 0) indentStack = 0; tokenIndent = indentStack; } break; } // @@@@@@ Blank Line spacing case (ELine): { delete[] pTestType -> pData; break; } // @@@@@@ Preprocessor Line ! case (PreP): { pOut -> pType = PreP; pOut -> pCode = pTestType -> pData; pOut -> pCFlag = pTestType -> pState; if (userS.indentPreP) { int resetPreproLevel = 0; switch (typeOfPreP(pTestType)) { case 0: pOut -> indentSpace = indentStack + prepStack; resetPreproLevel = preproLevel; break; case 1: pOut -> indentSpace = indentStack + prepStack; if (indentPreP != false) prepStack += userS.tabSpaceSize; break; case 2: if (indentPreP != false) { prepStack -= userS.tabSpaceSize; if (prepStack < 0) prepStack = 0; } pOut -> indentSpace = indentStack + prepStack; break; case 3: pOut -> indentSpace = indentStack + prepStack; if (prepStack >= userS.tabSpaceSize) pOut -> indentSpace -= userS.tabSpaceSize; break; case 4: pOut -> indentSpace = indentStack + prepStack; break; } // If this was a "#" line and not a continuation, reset // the curly-brace level seen for indenting. preproLevel = resetPreproLevel; } else pOut -> indentSpace = 0; break; } } // switch if (pOut -> pCode == 0 && pOut -> pBrace == 0) { delete[] pTestType -> pState; } else if (pendingComment != NULL) { TRACE(("@%d, Use Pending Comment = %s:%d\n", __LINE__, pendingComment, pOut->thisToken)); pOut -> pComment = pendingComment; pOut -> filler = (userS.posOfCommentsWC - (tokenIndent + strlen (pTestType -> pData))); pendingComment = NULL; } pOut->bracesLevel = bracesLevel; pOut->preproLevel = preproLevel; hang_state.IndentHanging(pOut); if (userS.indent_sql) sql_state.IndentSQL(pOut); // set the braces level from a previous call to this function pOut->bracesLevel = bracesLevel; pOut->preproLevel = preproLevel; // compute the braces-level for the next line if (isPreproLine(pOut)) { computeBraces(pOut, preproLevel); if (beginMultiLine(pOut)) preproLevel += 1; } else { computeBraces(pOut, bracesLevel); preproLevel = 0; } pOutputQueue -> putLast (pOut); delete pTestType; // ##### Remove structure from memory, not its data // ##### (i.e., char* pData), this is stored // ##### in the output queue. if (indentStack < 0) indentStack = 0; } // while there are items to construct ! return 0; } // no extra indent immediately after any brace static void resetSingleIndent(StackList* pIMode) { int n = 1; IndentStruct* pIndentItem; while ((pIndentItem = reinterpret_cast(pIMode -> peek(n++))) != 0) { TRACE(("...reset single-indent (%d)\n", pIndentItem->singleIndentLen)); pIndentItem->singleIndentLen = 0; pIndentItem->attrib = noIndent; } } // returns index to the next OutputStruct iff it's an open brace (skipping // comments), or zero. static int peekIndexOBrace(QueueList* pLines, int first) { OutputStruct* pTemp; while ((pTemp = reinterpret_cast(pLines -> peek (first))) != 0) { if (pTemp -> pCode != 0) break; if ((pTemp -> pBrace != 0) && *(pTemp -> pBrace) == L_CURL) return first; first++; } return 0; } // Check for a chain of single-indents static bool chainedSingleIndent(StackList* pIMode) { bool result = true; int count; for (count = 1; count <= 2; count++) { IndentStruct* pIndentItem = reinterpret_cast(pIMode -> peek(count)); if (pIndentItem == 0 || pIndentItem -> attrib != oneLine || pIndentItem -> singleIndentLen == 0) { result = false; break; } } TRACE(("...chainedSingleIndent %d\n", result)); return result; } // If we've had a chain of single indents before a L_CURL, we have to shift // the block to match the indent of the last indented code, because the // preceding logic was indenting solely on the basis of curly braces. static void shiftToMatchSingleIndent(QueueList* pLines, int indention, int first) { int baseIn = (reinterpret_cast(pLines -> peek (first))) -> indentSpace; int adjust = indention - baseIn; int state = 0; if (adjust > 0) { TRACE(("shiftToMatchSingleIndent, base %d adj %d\n", baseIn, adjust)); for (int i = first; i <= pLines -> status() ; i++) { OutputStruct* pAlterLine = reinterpret_cast(pLines -> peek (i)); if (pAlterLine == 0) break; // If there's an "else" immediately after the block-else, shift // it also. if (state == 1) { if (pAlterLine -> pCode == 0 || !BeginsElseClause(pAlterLine)) break; state = 2; } else if (pAlterLine -> pCode != 0) { if (pAlterLine -> pType == PreP) continue; } else if (pAlterLine -> pBrace == 0) { continue; } if (pAlterLine -> indentSpace < baseIn) break; TRACE(("...shift %2d %2d :%s\n", pAlterLine -> indentSpace, pAlterLine -> indentSpace + adjust, pAlterLine -> pCode ? pAlterLine -> pCode : pAlterLine -> pBrace)); pAlterLine -> indentSpace += adjust; if (pAlterLine -> indentSpace <= baseIn + adjust && pAlterLine -> pBrace != 0 && pAlterLine -> pBrace[0] == R_CURL) { if (state == 0) state = 1; else break; } } } } // check if an output-struct contains code, so we can distinguish it from // blank lines or comments static inline bool OutputContainsCode(OutputStruct *pOut) { return (pOut -> pCode != NULL || pOut -> pBrace != NULL); } // ---------------------------------------------------------------------------- // Function is used to indent single indented code such is found in if, while, // else statements. Also handles case like statements within switches'. // // Parameters: // pLines : Pointer to the output queue. // pIMode : Pointer to indent type stack. // userS : User configuration (i.e indent spacing, position of comments) // // Return Values: // QueueList* : Pointer to the output queue (may have been reconstructed), // returns NULL if failed to allocate memory // static QueueList* IndentNonBraceCode (QueueList* pLines, StackList* pIMode, const Config& userS, bool top) { TRACE(("IndentNonBraceCode\n")); // if there are items to check ! if ((pLines != NULL) && (pLines -> status () <= 0)) return pLines; // If there are indent items to process ! if (pIMode -> status() <= 0) return pLines; OutputStruct* pAlterLine = reinterpret_cast(pLines -> peek (1)); if (pAlterLine -> pType == PreP) return pLines; IndentStruct* pIndentItem = reinterpret_cast(pIMode -> pop()); if ( ((pAlterLine -> pCode != NULL) || ((pAlterLine -> pBrace != NULL) && (pIndentItem -> attrib == multiLine)) ) || ((userS.leaveCommentsNC != false) && ((pAlterLine -> pCode == NULL) && (pAlterLine -> pComment != NULL))) ) { bool adjusted = false; TRACE_OUTPUT(pAlterLine); TRACE_INDENT(pIndentItem); switch (pIndentItem -> attrib) { case (blockLine): case (noIndent): break; // single indent case (oneLine): { int indentAmount; // Test for continued statements, suppressing indent until // it's complete. if (ContinuedQuote(pAlterLine)) indentAmount = 0; else if (pAlterLine -> indentHangs != 0) indentAmount = 0; else indentAmount = userS.tabSpaceSize; // Single line indentation calculation pAlterLine -> indentSpace += indentAmount; TRACE(("@%d, total indent %d (%d)\n", __LINE__, pAlterLine->indentSpace, indentAmount)); break; } // indent of a case statement case (multiLine): { // determine how many case-like items are stored within // list to determine how much to indent int pTest; pAlterLine -> indentSpace += (userS.tabSpaceSize * (pIMode -> status())); // test if not another case, or default, if so, don't indent pTest = LookupKeyword(pAlterLine -> pCode); if (pTest >= 0 && pIndentWords[pTest].code != multiLine) { pTest = -1; } // check for closing braces to end case indention if ((pTest < 0) && (pAlterLine -> pBrace != NULL)) { if ((*(pAlterLine -> pBrace) == R_CURL) && (pAlterLine -> indentSpace == pIndentItem -> pos)) { delete pIndentItem; pIndentItem = NULL; } } // indent as per normal if ((pIndentItem != NULL) && (pTest < 0)) { pIMode -> push (pIndentItem); // ok to indent next item if (OutputContainsCode(pAlterLine)) // FIXME2 { pAlterLine -> indentSpace += userS.tabSpaceSize; adjusted = true; } else if (pAlterLine -> pComment != NULL) { if (pAlterLine -> filler == 0 && (pAlterLine -> bracesLevel || pAlterLine -> preproLevel )) { pAlterLine -> indentSpace += userS.tabSpaceSize; } } TRACE_OUTPUT(pAlterLine) } else if (pIndentItem != NULL) { // if end single indent keyword found, check to see // whether it is the correct one before removing it if ((pTest >= 0) && (pIndentItem -> pos+userS.tabSpaceSize < pAlterLine -> indentSpace)) { pIMode -> push (pIndentItem); // ok to indent next item ! if (OutputContainsCode(pAlterLine)) { pAlterLine -> indentSpace += userS.tabSpaceSize; adjusted = true; } TRACE_OUTPUT(pAlterLine) } else { delete pIndentItem; pIndentItem = NULL; } } break; } }// switch // test if code has started to overwrite comments, and // not a case, or default statement ... if so, adjust queue ! if ( ((pAlterLine -> pComment != NULL) && (pIndentItem != NULL)) && ((pAlterLine -> pCode != NULL) || (pAlterLine -> pBrace != NULL)) ) { // alter filler size for comment spacing ! pAlterLine -> filler -= userS.tabSpaceSize; // if less than 0, then code is overwriting comments ! if (pAlterLine -> filler < 0) { // reconstruct queue ! QueueList* pNewQueue = new QueueList(); OutputStruct* pNewItem = new OutputStruct(pAlterLine); pAlterLine = reinterpret_cast(pLines -> takeNext()); if (pNewItem == NULL) { delete pNewQueue; delete pIMode; delete pLines; return NULL;// out of memory } // load new structure pNewItem -> filler = userS.posOfCommentsWC; pNewItem -> pComment = pAlterLine -> pComment; pAlterLine -> filler = 0; // set this to zero as not to create filler // spaces at line output time. if (adjusted) // we'll add this back later pAlterLine -> indentSpace -= userS.tabSpaceSize; pAlterLine -> pComment = NULL; // reconstruct queue ! pNewQueue -> putLast (pNewItem); pNewQueue -> putLast (pAlterLine); // copy existing lines from old queue, into the newly created queue ! while (pLines -> status () > 0) pNewQueue -> putLast ( pLines -> takeNext() ); delete pLines; pLines = pNewQueue; // reassign new queue object } // if overwriting comments }// if comments exist on same line as code // Remove single line indentation from memory, if current line // does contain a if, else, while ... type keyword if (pIndentItem == NULL) ; else if (pIndentItem -> attrib == oneLine) { int block = 0; // recursive function call ! if (pIMode -> status() > 0) pLines = IndentNonBraceCode (pLines, pIMode, userS, false); TRACE(("#%d, brace=%p: %d\n", pAlterLine->thisToken, pAlterLine->pBrace, pIndentItem->attrib)); TRACE(("@%d, push indent %d\n", __LINE__, pIndentItem -> singleIndentLen)); pIMode -> push (pIndentItem); pIndentItem = NULL; if (top && (chainedSingleIndent(pIMode) || beginBlockLine(pLines)) && (block = peekIndexOBrace(pLines, 2)) != 0) { shiftToMatchSingleIndent(pLines, pAlterLine->indentSpace, block); } } //FIXME (leak): delete pIndentItem; } // if code to process else if (pIndentItem != NULL) { TRACE(("#%d, brace=%p: %d\n", pAlterLine->thisToken, pAlterLine->pBrace, pIndentItem->attrib)); // no indentation yet, maybe only blank line, or comment in case pIMode -> push (pIndentItem); // no extra indent immediately after any brace if (pAlterLine->pBrace != 0) resetSingleIndent(pIMode); } return pLines; } // ---------------------------------------------------------------------------- // Function allocates indent structures used to indent code that don't lie // within braces, but should still be indented. // // Parameters: // pIMode : Pointer to a indent stack. Contains indent structures used to // indent code without braces // pLines : Pointer to output queue, stores semi-finished output code. // userS : User settings. // // Return Values: // QueueList* : Pointer to the output queue (may have been reconstructed), // returns NULL if failed to allocate memory // static QueueList* IndentNonBraces (StackList* pIMode, QueueList* pLines, const Config& userS) { const int minLimit = 2; // used in searching output queue // for open braces TRACE(("IndentNonBraces: %d\n", pIMode -> status() )); // indent Items contained ! if (pIMode -> status () > 0) { char* pBraceOnNewLn = (reinterpret_cast(pLines -> peek (1))) -> pBrace; char* pBraceOnCurLn = (reinterpret_cast(pLines -> peek (1))) -> pCode; IndentStruct* pTestBrace = reinterpret_cast(pIMode -> pop()); if ( (pBraceOnNewLn != NULL) && ((pBraceOnNewLn[0] == L_CURL) && (pTestBrace -> attrib == oneLine)) ) { delete pTestBrace; } else if (lastChar(pBraceOnCurLn) == L_CURL && (pTestBrace -> attrib == oneLine)) { delete pTestBrace; } else pIMode -> push (pTestBrace); } //#### Indent code if code available, in a case statement TRACE(("...IndentNonBraces: %d\n", pIMode -> status() )); if (pIMode -> status () > 0) pLines = IndentNonBraceCode (pLines, pIMode, userS, true); if (pLines -> status () < minLimit) return pLines; OutputStruct *pOut = reinterpret_cast(pLines -> peek (1)); // Cancel the indent applied by "else" to "if", and abandon the indent // that would be computed in this function for the code under "if". if (pOut -> splitElseIf) { pOut -> indentSpace -= userS.tabSpaceSize; return pLines; } // determine if current line has a single line keyword (if, else, while, for, do) const char* pTestCode = pOut -> pCode; if (pTestCode != NULL) { int findWord = LookupKeyword(pTestCode); if (findWord < 0) { findWord = LookupLastKeyword(pOut); // if (findWord >= 0) TRACE(("GOTCHA!\n")); #if 0 if (findWord >= 0) { if (strcmp(pIndentWords[findWord].name, "else")) findWord = -1; } #endif } // if keyword found, check if next line not a brace or, comment // Test if code not NULL, and No Hidden Open Braces // FIXME: punctuation need not be at end of line if (findWord >= 0) { if (pIndentWords[findWord].code == multiLine) { const char *pTmp = SkipBlanks(pTestCode + strlen(pIndentWords[findWord].name)); if (*pTmp != '\0' && *pTmp != ':' && lastChar(pTestCode) != ':') findWord = -1; } switch (lastChar(pTestCode)) { case L_CURL: case SEMICOLON: case R_CURL: findWord = -1; break; default: break; } } // Test if open brace not located on next line if (findWord >= 0) { pTestCode = (reinterpret_cast(pLines -> peek (minLimit))) -> pBrace; if ((pTestCode != NULL) && (pTestCode[0] == L_CURL)) findWord = -1; // Don't process line as a single indentation ! } if (findWord >= 0) // create new structure ! { IndentStruct* pIndent = new IndentStruct(); // #### memory allocation error if (pIndent == NULL) { delete pLines; delete pIMode; return NULL; } // do indent mode for (if, while, for, else) if (pIndentWords[findWord].code == oneLine) { pIndent -> attrib = oneLine; // single indent ! // determine how much to indent the next line of code ! pIndent -> singleIndentLen = userS.tabSpaceSize; TRACE_INDENT(pIndent); TRACE(("#%d: set single-indent to %d\n", (reinterpret_cast(pLines->peek(1)))->thisToken, pIndent->singleIndentLen)); TRACE_OUTPUT(reinterpret_cast(pLines->peek(1))); TRACE_OUTPUT(reinterpret_cast(pLines->peek(2))); } else // it's a case or other block-statement ! { pIndent -> attrib = pIndentWords[findWord].code; pIndent -> pos = ((reinterpret_cast(pLines -> peek (1))) -> indentSpace) - userS.tabSpaceSize; TRACE_INDENT(pIndent); TRACE(("#%d: set multi-indent %d, pos = %d\n", (reinterpret_cast(pLines->peek(1)))->thisToken, pIndent->attrib, pIndent->pos)); } // place item on stack ! pIMode -> push (pIndent); } else { // update pIMode indent queue, throw out single indents if // not needed (i.e multi line single if conditions) IndentStruct* pThrowOut = NULL; // Test code for single indentation, if semi-colon exists // within code, remove item from indent stack! pTestCode = (reinterpret_cast(pLines -> peek (1))) -> pCode ; while (pIMode -> status () > 0) { pThrowOut = reinterpret_cast(pIMode -> pop()); if (pThrowOut -> attrib == multiLine) { pIMode -> push (pThrowOut); break; } // Test single code indents for a semicolon ! else if (lastChar(pTestCode) == SEMICOLON) delete pThrowOut; // throw out the single indent item else { pIMode -> push (pThrowOut); // Place item back on stack! break; // Leave loop! } } } } return pLines; } // ---------------------------------------------------------------------------- static bool isPreProc (OutputStruct *test) { bool result = false; if (test->pCFlag != 0) { for (int n = 0; test->pCFlag[n] != '\0'; ++n) { char state = test->pCFlag[n]; if (state == PreProc) { result = true; break; } else if (state == Normal) { break; } } } return result; } #ifdef TEST_BCPP // ---------------------------------------------------------------------------- // Check for a keyword which can follow a right curly-brace. static bool KeyAfterBrace (const char *word, int length) { switch (length) { case 4: return (strncmp(word, "else", length)) ? false : true; #if 0 // only if we have more info... case 5: return (strncmp(word, "while", length)) ? false : true; #endif } return false; } #endif // ---------------------------------------------------------------------------- // Check for a keyword which can precede a left curly-brace. static bool KeyBeforeBrace (const char *word, int length) { switch (length) { case 2: return (strncmp(word, "do", length)) ? false : true; case 4: return (strncmp(word, "else", length) && strncmp(word, "enum", length)) ? false : true; case 5: return (strncmp(word, "while", length)) ? false : true; } return false; } // ---------------------------------------------------------------------------- #ifdef TEST_BCPP static bool LineContainsBraces(QueueList* pLines, int item) { OutputStruct *pItem = reinterpret_cast(pLines->peek (item)); bool result = false; if (pItem->pBrace != NULL) result = true; else if (pItem->pCode != NULL && pItem->pCFlag != 0) { for (int n = 0; pItem->pCFlag[n] != 0; ++n) { if (pItem->pCFlag[n] == Normal && (pItem->pCode[n] == L_CURL || pItem->pCode[n] == R_CURL)) { result = true; break; } } } return result; } #endif // ---------------------------------------------------------------------------- static OutputStruct* findBraceLine(QueueList* pLines, int &first, int last, char brace, int step) { OutputStruct *result = NULL; OutputStruct *pBraceLine = NULL; // Can't process less than two items (i.e. move brace from one line to next line to make one line) while (first >= 0 && first <= last) { pBraceLine = reinterpret_cast(pLines->peek (first)); if ((pBraceLine->pBrace != NULL) && (pBraceLine->pBrace[0] == brace)) { result = pBraceLine; TRACE_OUTPUT(result); break; } first += step; } TRACE(("...%s brace\n", result ? "found" : "NOT found")); return result; } static OutputStruct* findBraceLine(QueueList* pLines, int &first, int last, char brace) { return findBraceLine(pLines, first, last, brace, 1); } // ---------------------------------------------------------------------------- static OutputStruct* findCodeLine(QueueList* pLines, int &first, int last, int step) { OutputStruct *result = NULL; OutputStruct *pCodeLine = NULL; // Can't process less than two items (i.e. move brace from one line to next line to make one line) while (first >= 0 && first <= last) { pCodeLine = reinterpret_cast(pLines->peek (first)); if (pCodeLine == NULL || isPreProc(pCodeLine)) { break; } if (pCodeLine->pCode != NULL) { result = pCodeLine; TRACE_OUTPUT(result); break; } first += step; } TRACE(("...%s code\n", result ? "found" : "NOT found")); return result; } #ifdef TEST_BCPP static OutputStruct* findCodeLine(QueueList* pLines, int &first, int last) { return findCodeLine(pLines, first, last, 1); } #endif // ---------------------------------------------------------------------------- // Find the index for the last word on the code line, or the last character // if the line does not end with a word. Returns true if we found something. static bool parseLastCode(OutputStruct* pCodeLine, char &lastchar, int &lastword, int &wordsize) { bool result = false; lastword = -1; wordsize = 0; lastchar = NullC; if (pCodeLine->pCode != 0 && pCodeLine->pCFlag != 0) { for (int n = 0; pCodeLine->pCode[n] != NullC; ++n) { if (pCodeLine->pCFlag[n] == PreProc) { lastchar = NullC; lastword = -1; break; } else if (pCodeLine->pCFlag[n] == Normal) { if (!isName(pCodeLine->pCode[n])) { lastchar = pCodeLine->pCode[n]; lastword = -1; wordsize = 0; } else if (lastword < 0) { lastchar = NullC; lastword = n; wordsize = 0; } if (lastword >= 0) ++wordsize; } else { lastchar = NullC; lastword = -1; wordsize = 0; } } result = lastchar != NullC || lastword != -1 || wordsize > 0; } return result; } static int LookupLastKeyword(OutputStruct* pCodeLine) { char lastchar; int lastword; int wordsize; int result = -1; if (parseLastCode(pCodeLine, lastchar, lastword, wordsize) && wordsize > 0) { lastchar = pCodeLine->pCode[lastword + wordsize]; pCodeLine->pCode[lastword + wordsize] = 0; result = LookupKeyword(pCodeLine->pCode + lastword); pCodeLine->pCode[lastword + wordsize] = lastchar; } return result; } // ---------------------------------------------------------------------------- // Find the index for the first word on the code line, or the first character // if the line does not begin with a word. Returns true if we found something. #ifdef TEST_BCPP static bool parseFirstCode(OutputStruct* pCodeLine, char &firstchar, int &firstword, int &wordsize) { bool result = false; firstword = -1; wordsize = 0; firstchar = NullC; if (pCodeLine->pCode != 0 && pCodeLine->pCFlag != 0) { for (int n = 0; pCodeLine->pCode[n] != NullC; ++n) { if (pCodeLine->pCFlag[n] == PreProc) { firstchar = NullC; firstword = -1; break; } else if (pCodeLine->pCFlag[n] == Normal) { if ((n > 0 && !isName(pCodeLine->pCode[n-1])) || !isName(pCodeLine->pCode[n])) { firstchar = pCodeLine->pCode[n]; firstword = -1; wordsize = 0; break; } else if (firstword < 0) { firstchar = NullC; firstword = n; wordsize = 0; } if (firstword >= 0) ++wordsize; } else if (pCodeLine->pCFlag[n] == DQuoted || pCodeLine->pCFlag[n] == SQuoted) { firstchar = NullC; firstword = -1; wordsize = 0; break; } else if (wordsize) { break; } } result = firstchar != NullC || firstword != -1 || wordsize > 0; } return result; } #endif #ifdef TEST_BCPP static void copyLinesUntil(QueueList* dst, QueueList* src, OutputStruct *last) { OutputStruct *temp = reinterpret_cast(src->takeNext()); while (temp != last) { TRACE(("COPYING ... ")); TRACE_OUTPUT(temp); dst -> putLast (temp); temp = reinterpret_cast(src->takeNext()); } } #endif // ---------------------------------------------------------------------------- // Function reformats open braces (left-curly) to be on the same lines as the // code that it's assigned (if possible). // // Parameters: // pLines : Pointer to a OutputStructure queue object // userS : Users configuration settings. // // Return Values: // QueueList* : Returns a pointer to a newly constructed OutputStructure // queue, or the value of pLines if no work is needed. // The input pLines is freed unless it is the return-value. // static QueueList* ReformatLCurly (QueueList* pLines, int first, const Config& userS) { int queueNum = pLines -> status (); // get queue number TRACE(("ReformatLCurly(%d:%d)\n", first, queueNum)); // Can't process less than two items (i.e. move brace from one line to next line to make one line ) if (queueNum < 2 || first > queueNum) { return pLines; } OutputStruct* pBraceLine = NULL; OutputStruct* pCodeLine = NULL; int findBrace; // position in queue where first brace line is located int findCode ; // position in queue where next code line is located // search forward through queue to find the first appearance of a brace findBrace = first; pBraceLine = findBraceLine(pLines, findBrace, queueNum, L_CURL); if (pBraceLine == NULL) return pLines; // find out if there is a place to place the brace in the code that // is currently stored findCode = findBrace - 1; // position in queue where first brace line is located pCodeLine = findCodeLine(pLines, findCode, queueNum, -1); if (pCodeLine == NULL) return pLines; if (findCode >= first) // o.k found a line that has code ! { OutputStruct* pNewItem = NULL; // we're here to join braces, but must check if this instance must // remain split: bool splitBraces = false; if (pBraceLine->bracesLevel == 0 && userS.topBraceLoc != false) { splitBraces = true; } else { int lastword; int wordsize; char lastchar; if (parseLastCode(pCodeLine, lastchar, lastword, wordsize)) { // we can join a left-curly after a right-paren, equals, or "else" if (lastchar != R_PAREN && lastchar != '=' && (lastword < 0 || KeyBeforeBrace(pCodeLine->pCode + lastword, wordsize) == false)) splitBraces = true; } } // place top-level open braces on same line as code if (splitBraces || userS.braceLoc == true) { TRACE(("...leave brace, restart (%d,%d)\n", splitBraces, userS.braceLoc)); return pLines; } QueueList* pNewLines = new QueueList(); if (pNewLines == NULL) { return NULL; // out of memory } // load newQueue with lines up to code line found ! for (int loadNew = 1; loadNew < findCode; loadNew++) pNewLines -> putLast (pLines -> takeNext()); // take code line that is going to be altered ! pCodeLine = reinterpret_cast(pLines -> takeNext ()); // if code has comments, then it's placed on a new line ! if (pCodeLine -> pComment != NULL) { // len of indent + code + space + brace int overWrite = pCodeLine -> indentSpace + strlen (pCodeLine -> pCode) + 1 + strlen (pBraceLine -> pBrace); if (overWrite >= userS.posOfCommentsWC) // if true then place comment on new line ! { pNewItem = new OutputStruct(pCodeLine); if (pNewItem == NULL) return NULL; pNewItem -> filler = userS.posOfCommentsWC; pNewItem -> pComment = pCodeLine -> pComment; pCodeLine -> pComment = NULL;// make this NULL as not to be delete when // object destructor is called. pNewLines -> putLast (pNewItem); } } // place brace code onto new output structure ! pNewItem = new OutputStruct(pCodeLine); // code + space + brace + nullc int newLen = (strlen (pCodeLine->pCode) + strlen (pBraceLine->pBrace) + 1 + 1); char *pNewCode = new char [newLen]; char *pNewState = new char [newLen]; if ((pNewItem == NULL) || (pNewCode == NULL)) { delete pCodeLine; delete pBraceLine; delete pLines; delete pNewLines; return NULL; // out of memory } // concatenate code + space + brace // ### CHECK IT sprintf (pNewCode, "%s %s", pCodeLine->pCode, pBraceLine->pBrace); sprintf (pNewState, "%s %s", pCodeLine->pCFlag, pBraceLine->pBFlag); // place attributes into queue pNewItem -> bracesLevel = pCodeLine -> bracesLevel; pNewItem -> indentSpace = pCodeLine -> indentSpace; pNewItem -> pCode = pNewCode; pNewItem -> pCFlag = pNewState; // Add comments to new code line if they exist if (pCodeLine -> pComment != NULL) { pNewItem -> pComment = pCodeLine -> pComment; pCodeLine -> pComment = NULL;// make this NULL as not to be delete when // object destructor is called. // calculate filler spacing! pNewItem -> filler = userS.posOfCommentsWC - (pCodeLine -> indentSpace + strlen (pNewItem -> pCode)); } TRACE(("...merged code+brace\n")); TRACE_OUTPUT(pNewItem); // store newly constructed output structure pNewLines -> putLast (pNewItem); // process brace Line !, create new output structure for brace comment if (pBraceLine -> pComment != NULL) { pNewItem = new OutputStruct(pBraceLine); if (pNewItem == NULL) { delete pCodeLine; delete pBraceLine; delete pLines; delete pNewLines; return NULL;// out of memory } // load comment pNewItem -> pComment = pBraceLine -> pComment; pBraceLine -> pComment = NULL; // positioning comment, use filler - not indentSpace - as this // will become screw when using tabs ... fillers use spaces! pNewItem -> filler = userS.posOfCommentsWC; pNewLines -> putLast (pNewItem); } delete pCodeLine; // copy existing lines from old queue, into the newly created queue ! // copy all objects from pLines up to pBraceLine pCodeLine = reinterpret_cast(pLines -> takeNext()); // read ahead rule while (pCodeLine != pBraceLine) { pNewLines -> putLast (pCodeLine); pCodeLine = reinterpret_cast(pLines -> takeNext()); } delete pCodeLine; // remove brace lines (in disguise) // code what's left in pLines queue to pNewLines ! while ((pLines -> status ()) > 0 ) { pNewLines -> putLast (pLines -> takeNext ()); } // remove old queue object from memory, return newly constructed one delete pLines; pLines = pNewLines; } return pLines; } // ---------------------------------------------------------------------------- // Function reformats closing braces (right-curly) to be on the same lines as // the code that it's assigned (if possible). // // Parameters: // pLines : Pointer to a OutputStructure queue object // userS : Users configuration settings. // // Return Values: // QueueList* : Returns a pointer to a newly constructed OutputStructure // queue, or the value of pLines if no work is needed. // The input pLines is freed unless it is the return-value. // #ifdef TEST_BCPP static QueueList* ReformatRCurly (QueueList* pLines, int first, const Config& userS) { int queueNum = pLines -> status (); // get queue number TRACE(("ReformatRCurly(%d:%d)\n", first, queueNum)); // Can't process less than two items (i.e. move brace from one line to next line to make one line ) if (queueNum < 2 || first > queueNum) { return pLines; } // search forward through queue to find the first appearance of a brace int findBrace = first; // position in queue where first brace line is located OutputStruct* pBraceLine = findBraceLine(pLines, findBrace, queueNum, R_CURL); if (pBraceLine == NULL) return pLines; int findCode = findBrace + 1; // position in queue where first brace line is located OutputStruct* pCodeLine = findCodeLine(pLines, findCode, queueNum); if (pCodeLine == NULL) return pLines; for (int n = findBrace + 1; n < findCode; ++n) { if (LineContainsBraces(pLines, n)) { TRACE(("...extra brace conflicts\n")); return pLines; } } if (findCode >= first) // o.k found a line that has code ! { OutputStruct* pNewItem = NULL; // we're here to join braces, but must check if this instance must // remain split: bool splitBraces = false; if (pBraceLine->bracesLevel == 0 && userS.topBraceLoc != false) { splitBraces = true; } else { int lastword = -1; int wordsize = 0; char lastchar = NullC; if (parseFirstCode(pCodeLine, lastchar, lastword, wordsize)) { TRACE(("lastchar %#x, lastword %d, wordsize %d\n", lastchar, lastword, wordsize)); // we can join a right-curly before "else" if (lastchar != NullC || KeyAfterBrace(pCodeLine->pCode + lastword, wordsize) == false) splitBraces = true; } } // place top-level close braces on same line as code if (splitBraces || userS.braceLoc == true) { TRACE(("...leave brace, restart (%d,%d)\n", splitBraces, userS.braceLoc)); return pLines; } QueueList* pNewLines = new QueueList(); if (pNewLines == NULL) { return NULL; // out of memory } // load newQueue with lines up to first line found for (int loadNew = 1; loadNew < findBrace; loadNew++) pNewLines -> putLast (pLines->takeNext()); // take the first line that is going to be altered pLines->takeNext (); // if code has comments, then it's placed on a new line if (pCodeLine -> pComment != NULL) { // len of indent + code + space + brace int overWrite = pCodeLine -> indentSpace + strlen (pCodeLine -> pCode) + 1 + strlen (pBraceLine -> pBrace); if (overWrite >= userS.posOfCommentsWC) // if true then place comment on new line ! { pNewItem = new OutputStruct(pCodeLine); if (pNewItem == NULL) return NULL; pNewItem -> filler = userS.posOfCommentsWC; pNewItem -> pComment = pCodeLine -> pComment; pCodeLine -> pComment = NULL;// make this NULL as not to be delete when // object destructor is called. pNewLines -> putLast (pNewItem); } } // place brace code onto new output structure ! pNewItem = new OutputStruct(pCodeLine); // code + space + brace + nullc int newLen = (strlen (pCodeLine->pCode) + strlen (pBraceLine->pBrace) + 1 + 1); char *pNewCode = new char [newLen]; char *pNewState = new char [newLen]; if ((pNewItem == NULL) || (pNewCode == NULL)) { delete pCodeLine; delete pBraceLine; delete pLines; delete pNewLines; return NULL; // out of memory } // concatenate code + space + brace // ### CHECK IT sprintf (pNewCode, "%s %s", pBraceLine->pBrace, pCodeLine->pCode); sprintf (pNewState, "%s %s", pBraceLine->pBFlag, pCodeLine->pCFlag); // place attributes into queue pNewItem = pBraceLine; pNewItem->pCode = pNewCode; pNewItem->pCFlag = pNewState; pNewItem->pBrace = NULL; pNewItem->pBFlag = NULL; pNewItem->pComment = NULL; // Add comments to new code line if they exist if (pCodeLine -> pComment != NULL) { pNewItem -> pComment = pCodeLine -> pComment; pCodeLine -> pComment = NULL;// make this NULL as not to be delete when // object destructor is called. // calculate filler spacing! pNewItem -> filler = userS.posOfCommentsWC - (pCodeLine -> indentSpace + strlen (pNewItem -> pCode)); } TRACE(("...merged brace+code\n")); TRACE_OUTPUT(pNewItem); // store newly constructed output structure pNewLines -> putLast (pNewItem); // process brace Line !, create new output structure for brace comment if (pBraceLine -> pComment != NULL) { pNewItem = new OutputStruct(pBraceLine); if (pNewItem == NULL) { delete pCodeLine; delete pBraceLine; delete pLines; delete pNewLines; return NULL;// out of memory } // load comment pNewItem -> pComment = pBraceLine -> pComment; pBraceLine -> pComment = NULL; // positioning comment, use filler - not indentSpace - as this // will become screw when using tabs ... fillers use spaces! pNewItem -> filler = userS.posOfCommentsWC; pNewLines -> putLast (pNewItem); } delete pCodeLine; // copy existing lines from old queue, into the newly created queue ! copyLinesUntil(pNewLines, pLines, pCodeLine); // FIXME delete pCodeLine; // remove last line // code what's left in pLines queue to pNewLines ! while ((pLines -> status ()) > 0 ) { pNewLines -> putLast (pLines -> takeNext ()); } // remove old queue object from memory, return newly constructed one delete pLines; pLines = pNewLines; } return pLines; } #endif // ---------------------------------------------------------------------------- // Function reformats the spacing between functions, structures, unions, classes. // // Parameters: // pOutFile : Pointer to the output FILE structure. // pLines : Pointer to the OutputStructure queue object. // userS : Users configuration settings. // FuncVar : Defines what type of mode the function is operating in. // inBraces : Set to true if we're within curly-braces. // pendingBlank : is used to control consecutive blank lines // // Return Values: // QueueList* : Pointer to the OutputStructure (sometimes altered) // FuncVar : Defines what mode function is currently in // 0 = don't delete blank lines // 1 = output blank lines // 2 = delete blank OutputStructures in queue until code is reached. // static void FunctionSpacing (QueueList* pLines, const Config& userS, int& FuncVar, int &pendingBlank, bool& inBraces ) { inBraces = false; if (pLines -> status () > 0) // if there are items in the queue ! { OutputStruct* pTestLine = reinterpret_cast(pLines -> peek (1)); inBraces = (pTestLine -> indentSpace > 0) ? true : false; // check if end of function, structure, class has been reached ! if ( ((FuncVar == 0) && (inBraces == false)) && (pTestLine -> pBrace != NULL) ) { if (pTestLine -> pBrace[0] == R_CURL && pTestLine -> pBrace[1] == NULLC) { FuncVar = 1; // add function spacing ! return; } } if (FuncVar == 1) { // go into blank line output mode between functions! pendingBlank = userS.numOfLineFunc; FuncVar = 2; } if ( (FuncVar == 2) && (((pTestLine -> pCode != NULL ) || (pTestLine -> pBrace != NULL)) || (pTestLine -> pComment != NULL)) ) FuncVar = 0; else if (FuncVar == 2) { OutputStruct* dump = reinterpret_cast(pLines -> takeNext()); // dump line from queue! delete dump; } } } // ---------------------------------------------------------------------------- // Putting an inter-function space before "#endif" looks ugly. This is used // to test for that condition. static bool PreProcessorEndif(OutputStruct *pOut) { if (pOut -> pType == PreP) { return CompareKeyword(SkipBlanks(pOut -> pCode + 1), "endif"); } return false; } // ---------------------------------------------------------------------------- // Check if the first statement on the input-queue begins a preprocessor // command, is a continuation of one, or is neither. static int beginningPrePro (QueueList *pInputQueue, int Current) { int n; int result = 0; InputStruct *pNextItem; if ((n = pInputQueue -> status()) != 0) { pNextItem = reinterpret_cast(pInputQueue -> peek(n)); switch (pNextItem -> dataType) { case PreP: result = isContinuation(pNextItem) ? 1 : 0; break; case Code: case CBrace: case OBrace: result = Current ? (isContinuation(pNextItem) ? Current+1 : 0) : 0; break; default: result = 0; break; } if (Current && !result) { TRACE(("PEEK(%d)%s\n", Current, isContinuation(pNextItem) ? " CONT" : "")); TRACE_INPUT(pNextItem) } } return result; } // We may convert leading whitespace in a comment back to tabs static bool adjustLeadingSpaces(int fillMode, char *¬es, int &leading) { if ((fillMode & 1) != 0 && notes != NULL && *notes == SPACE) { while (*notes == SPACE) { notes++; leading++; } return true; } return false; } // ---------------------------------------------------------------------------- // Function is used to expand OutputStructures contained within a queue to the // user's output file. Function also reformats braces, function spacing, // braces indenting. // // Parameters: // pOutFile : Pointer to the users output FILE structure/handle // pLines : Pointer to the OutputStructures queue object // FuncVar : See FunctionSpacing() // userS : Users configuration settings. // stopLimit : Defines how many OutputStructures remain within the Queue not // processed. // pendingBlank : is used to control consecutive blank lines // // Return Values: // FuncVar : See FunctionSpacing() // QueueList*: Pointer to the Output queue object (sometimes modified!) // // returns NULL if memory allocation failed // static QueueList* OutputToOutFile (FILE* pOutFile, QueueList* pLines, StackList* pIMode, int& FuncVar, const Config& userS, int stopLimit, int &pendingBlank) { OutputStruct* pOut = NULL; char* pIndentation = NULL; char* pFiller = NULL; int fillMode = 2; // we can always use spaces bool inBraces; // determine fill mode if (userS.useTabs == true) fillMode |= 1; // set bit 0, tabs while (pLines -> status() > stopLimit) // stopLimit is used to search backward for L_CURL { // process function spacing !!!!! int testProcessing = pLines -> status(); FunctionSpacing (pLines, userS, FuncVar, pendingBlank, inBraces ); if (pLines -> status () < testProcessing) // line removed, test next line in buffer continue; // check indentation on case statements etc pLines = IndentNonBraces (pIMode, pLines, userS); if (pLines == NULL) return NULL; //#### Memory Allocation Failure // reformat open braces if user option set if (userS.topBraceLoc == false // place open braces on same line as code || userS.braceLoc == false) // place open braces on same line as code { pLines = ReformatLCurly (pLines, 1, userS); if (pLines == NULL) return NULL; } #ifdef TEST_BCPP if (userS.braceLoc == false) // place closing braces on same line as code { pLines = ReformatRCurly (pLines, 1, userS); if (pLines == NULL) return NULL; } #endif pOut = reinterpret_cast(pLines -> takeNext()); TRACE_OUTPUT(pOut); // expand pOut structure to print to the output file if (!emptyString(pOut -> pCode) || !emptyString(pOut -> pBrace) || !emptyString(pOut -> pComment)) { int mark; int in_code = ((pOut -> pCode != 0) ? strlen(pOut -> pCode) : 0) + ((pOut -> pBrace != 0) ? strlen(pOut -> pBrace) : 0); int leading = pOut -> indentSpace + (pOut -> indentHangs * userS.tabSpaceSize); // FIXME: indentHangs should use separate param char *notes = pOut -> pComment; if (emptyString(notes)) notes = NULL; // Check for a trailing C-comment fragment. That must go before // any code! if (notes != NULL && (!emptyString(pOut -> pCode) || !emptyString(pOut -> pBrace)) && strncmp(notes, ccom_begin, 2) && strncmp(notes, cppc_begin, 2)) { adjustLeadingSpaces(fillMode, notes, leading); pIndentation = TabSpacing (fillMode, 0, leading, userS.tabSpaceSize); fprintf (pOutFile, "%s", pIndentation); delete[] pIndentation; fprintf (pOutFile, "%s\n", notes); notes = NULL; } // Just in case we only had a comment fragment, check again... if (!emptyString(pOut -> pCode) || !emptyString(pOut -> pBrace) || !emptyString(notes)) { if (!adjustLeadingSpaces(fillMode, notes, leading) && (in_code == 0) && !emptyString(notes)) { if (pOut -> filler > leading) leading = 0; } // compute the end-column of the code before filler, to use in // adjusting tab conversion. mark = leading + in_code; if (notes != 0) if (pOut -> filler > userS.posOfCommentsWC - mark) pOut -> filler = userS.posOfCommentsWC - mark; if (pOut -> filler < 0) pOut -> filler = 0; // 2-9-2 BTM - re-adjust location of braces & any comments that might follow them if ( pOut -> pBrace && userS.braceIndent2) { leading += userS.tabSpaceSize; if ( pOut->filler > userS.tabSpaceSize ) { pOut->filler -= userS.tabSpaceSize; } } if (ContinuedQuote(pOut)) pIndentation = NULL; else { if (isPreproLine(pOut)) { int next = pOut->preproLevel; if (next > 0 && BeginsCurly(pOut)) --next; leading += next * userS.tabSpaceSize; } pIndentation = TabSpacing (fillMode, 0, leading, userS.tabSpaceSize); } pFiller = TabSpacing (fillMode, mark, pOut -> filler, userS.tabSpaceSize); if (pendingBlank != 0) { if (PreProcessorEndif(pOut)) { pendingBlank = 0; FuncVar = 0; } else { while (pendingBlank > 0) { fputc (LF, pOutFile); // output line feed! pendingBlank--; } } } // Output data if (pIndentation != NULL) { fprintf (pOutFile, "%s", pIndentation); delete[] pIndentation; } if (pOut -> pCode != NULL) fprintf (pOutFile, "%s", pOut -> pCode); if (pOut -> pBrace != NULL) fprintf (pOutFile, "%s", pOut -> pBrace); if (pFiller != NULL) { fprintf (pOutFile, "%s", pFiller); delete[] pFiller; } if (notes != NULL) { size_t len = strlen(notes); fprintf (pOutFile, "%s", notes); if (len > 0 && notes[len-1] == ESCAPE) fprintf (pOutFile, " "); } fputc (LF, pOutFile); // output line feed! } } else pendingBlank = 1; // free memory delete pOut; } return pLines; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Function will backspace the desired characters length according to // numeric size. static void backSpaceIt (unsigned long int num) { unsigned long int size = 1; while (num >= size) { printf ("\b"); size = size * 10; } printf ("\b"); // remove the trail zero, or space ! } // Parameters: // mode : 1 = set new time, 2 = compare current time with now time static unsigned long int GetStartEndTime (int mode) { static time_t newTime; switch (mode) { case (1): newTime = time (NULL); return 0; case (2): return (time (NULL) - newTime); } return 0; } // ---------------------------------------------------------------------------- // Function is used to bundle all of the input, and output line processing // functions together to create a final output file. // // Parameters: // pInFile : Pointer to the user's input FILE structure/handle. // pOutFile : Pointer to the user's output FILE structure/handle. // userS : User's configuration settings. // // Return Values: // int : Returns a value indicating whether there were any problems // in processing the input/output files. // 0 = no worries. // -1 = memory allocation failure, or line construction failure // static int ProcessFile (FILE* pInFile, FILE* pOutFile, const Config& userS) { const char* errorMsg = "\n\n#### ERROR ! Memory Allocation Failed\n"; const unsigned long lineStep = 10; // line number update period (show every 10 lines) unsigned long int lineNo = 0; int EndOfFile = 0; // Var used by readline() to show eof has been reached char* pData = 0; int pendingBlank = 0; // var used to control blank lines int indentStack = 0; // var used for brace spacing int indentStack2 = 0; // save/restore "indentStack" for preprocessor lines QueueList* pOutputQueue = new QueueList(); StackList* pIMode = new StackList(); QueueList* pInputQueue = new QueueList(); int FuncVar = 0; // variable used in processing function spacing ! CharState curState = Blank; char* lineState = NULL; bool codeOnLine = false; bool indentPreP = false; bool pendingElse = false; int prepStack = 0; int bracesLevel = 0; int preproLevel = 0; int in_prepro = 0; HangStruct hang_state; HtmlStruct html_state; SqlStruct sql_state; size_t beforeSize; bool beforeSlash = false; bool afterSlash; // Check memory allocated ! if (((pOutputQueue == NULL) || (pIMode == NULL)) || (pInputQueue == NULL)) { delete pOutputQueue; delete pInputQueue; delete pIMode; warning ("%s", errorMsg); return -1; } if (userS.output != false) { verbose ("\nFeed Me, Feed Me Code ...\n"); verbose ("Number Of Lines Processed : "); } GetStartEndTime (1); // lets time the operation ! while (! EndOfFile) { if (pData != 0) delete[] pData; pData = ReadLine (pInFile, EndOfFile); if (lineState != 0) { delete[] lineState; lineState = NULL; } if (pData != NULL) { lineNo++; if ( (lineNo % lineStep == 0) && (userS.output != false) ) { if (lineNo > 0) backSpaceIt (lineNo - lineStep); // reposition cursor ! Don't used gotoxy() for Unix compatibility printf ("%lu ", lineNo); } if (html_state.Active(pData)) { if (EndOfFile) break; // flush queue ... pOutputQueue = OutputToOutFile ( pOutFile, pOutputQueue, pIMode, FuncVar, userS, 0, pendingBlank); fprintf(pOutFile, "%s\n", pData); continue; } ExpandTabs (pData, userS.tabSpaceSize, userS.deleteHighChars, userS.quoteChars, curState, lineState, codeOnLine); if (pData == NULL) { warning ("%s", errorMsg); delete pIMode; delete pInputQueue; delete pOutputQueue; return -1; } afterSlash = beforeSlash; beforeSlash = isContinuation(beforeSize, pData, lineState); if (DecodeLine (afterSlash, 0, pData, lineState, pInputQueue) == 0) // if there are input items to process { int old_prepro = in_prepro; bool restoreit = false; if ((in_prepro = beginningPrePro(pInputQueue, in_prepro)) != 0) { if (in_prepro == 1) { TRACE(("save indentStack: %d (%d)\n", in_prepro, indentStack)); indentStack2 = indentStack; } else if (in_prepro == 2) { TRACE(("increase indentStack\n")); indentStack += userS.tabSpaceSize; } } else if (old_prepro) { restoreit = true; if (old_prepro == 1) indentStack += userS.tabSpaceSize; } int errorCode = ConstructLine ( indentPreP, prepStack, bracesLevel, preproLevel, indentStack, pendingElse, hang_state, sql_state, pInputQueue, pOutputQueue, userS); switch (errorCode) { case (0) : break; case (-1) : { warning ("%s", errorMsg); delete pIMode; delete pInputQueue; delete pOutputQueue; return errorCode; } case (-2): // Construct line failed ! { // output final line position warning ("\nLast Line Read %ld", lineNo); delete pIMode; delete pInputQueue; delete pOutputQueue; return errorCode; } default: { warning ("\nSomething Weird %d\n", errorCode); return errorCode; } } pOutputQueue = OutputToOutFile ( pOutFile, pOutputQueue, pIMode, FuncVar, userS, restoreit ? 0 : userS.queueBuffer, pendingBlank ); if (pOutputQueue == NULL) { warning ("%s", errorMsg); delete pIMode; delete pInputQueue; return -1; // memory allocation error ! } if (restoreit) { TRACE(("restore indentStack (%d) to %d\n", indentStack, indentStack2)); if (indentStack != 0) { pIMode -> pop(); } indentStack = indentStack2; } } } // if there's data available }// while data // flush queue ... pOutputQueue = OutputToOutFile ( pOutFile, pOutputQueue, pIMode, FuncVar, userS, 0, pendingBlank); // output final line position if (userS.output != false) { if ((lineNo > 0) && (lineNo > lineStep)) backSpaceIt (lineNo - (lineNo % lineStep)); // reposition cursor printf ("%lu ", lineNo); } delete pIMode; delete pOutputQueue; delete pInputQueue; delete[] pData; delete[] lineState; if (userS.output != false) { unsigned long int t = GetStartEndTime (2); int hours = (t / 60) / 60, mins = (t / 60), secs = (t % 60); verbose ("(In %d Hours %d Minutes %d Seconds)", hours, mins, secs); } return 0; } // ---------------------------------------------------------------------------- // locates programs configuration file via the PATH command. // Should work for MS-DOS, and Unix environments. Amiga dos // may fail because PATH is not the name of their path variable. // pCfgName = Name of configuration file // pCfgFile = reference to FILE structure pointer. static void FindConfigFile (const char* pCfgName, FILE*& pCfgFile) { // test to see if file is in current directory first: ./bcpp.cfg if ((pCfgFile = fopen(pCfgName, "r")) != NULL) return; // search in user's $HOME directory: $HOME/.bcpp.cfg char* pSHome = getenv ("HOME"); if (pSHome) { char* pNameMem = NULL; if ((pNameMem = new char[strlen (pSHome) + strlen (pCfgName) + 3]) == NULL) return; strcpy (pNameMem, pSHome); strcat (pNameMem, "/."); strcat (pNameMem, pCfgName); if ((pCfgFile = fopen(pNameMem, "r")) != NULL) { fprintf(stderr, "Using configuration file at \"%s\"\n", pNameMem); delete[] pNameMem; return; } delete[] pNameMem; } // If we have a compile-time definition of the directory where the // configuration file is, use that. #ifdef BCPP_CONFIG_DIR // search in /etc/bcpp/ directory: /etc/bcpp/bcpp.cfg char* pNameMem = NULL; if ((pNameMem = new char[strlen (BCPP_CONFIG_DIR) + strlen (pCfgName) + 1]) == NULL) return; strcpy (pNameMem, BCPP_CONFIG_DIR); strcat (pNameMem, pCfgName); if ((pCfgFile = fopen(pNameMem, "r")) != NULL) { fprintf(stderr, "Using configuration file at \"%s\"\n", pNameMem); delete[] pNameMem; return; } #else // Otherwise, search in the user's PATH variable const char* sepCharList = ";,:"; // dos, amigaDos, unix char* pSPath = getenv ("PATH"); char* pEPath = NULL; char* pNameMem = NULL; char sepChar = NULLC; const char* pathSepChar; char backUp; int count = 0; // environment variable not found... if (pSPath == NULL) return; if ((pNameMem = new char[strlen (pSPath) + strlen (pCfgName)+2]) == NULL) return; // best guess in separating parameters ! while (sepCharList[count] != NULLC) { pEPath = endOf(pSPath); while ((*pEPath != sepCharList[count]) && (pEPath > pSPath)) pEPath--; if (*pEPath == sepCharList[count]) { sepChar = sepCharList[count]; break; // leave loop } count++; } pEPath = pSPath; do { while ((*pEPath != sepChar) && (*pEPath != NULLC)) pEPath++; backUp = *pEPath; *pEPath = NULLC; strcpy (pNameMem, pSPath); if (sepChar == SEMICOLON) pathSepChar = "\\"; // dumb dos's backwards path system ! else pathSepChar = "/"; // everyone else uses this method // try to prevent segmentation errors ! if (strlen (pNameMem) > 0) if (lastChar(pNameMem) != pathSepChar[0]) strcpy (endOf(pNameMem), pathSepChar); strcpy (endOf(pNameMem), pCfgName); *pEPath = backUp; if (*pEPath != NULLC) { pEPath++; pSPath = pEPath; } pCfgFile = fopen(pNameMem, "r"); } while ((*pEPath != NULLC) && (pCfgFile == NULL)); #endif delete[] pNameMem; pCfgFile = NULL; } // ---------------------------------------------------------------------------- // Front-end to the program, it reads in the configuration file, checks if there // were any errors, and starts processing of the files. // // Parameters: // argc : command line parameter count // argv[] : array of pointers to command line parameters // // Return Values: // int : A non zero value indicates processing problem. // static int LoadnRun (int argc, char* argv[]) { const char* pNoFile = "Couldn't Open, or Create File"; bool renamed = false; char* pConfig = NULL; char* pInFile = NULL; char* pOutFile = NULL; FILE* pInputFile = NULL; FILE* pOutputFile = NULL; FILE* pConfigFile = NULL; int errorNum = 0; int errorCode = 0; Config settings = {2, // numOfLineFunc 4, // tabSpaceSize false, // useTabs 50, // posOfCommentsWC 0, // posOfCommentsNC false, // keepCommentsWC false, // leaveCommentsNC false, // quoteChars 3, // deleteHighChars true, // topBraceLoc true, // braceLoc true, // output 10, // queueBuffer false, // backUp false, // indentPreP false, // indent_sql false, // braceIndent false}; // braceIndent2 /* ************************************************************************************ // set defaults settings.numOfLineFunc = 2; // number of lines between functions settings.tabSpaceSize = 4; // number of spaces a tab takes up settings.useTabs = false;// use tabs to indents rather than spaces settings.posOfCommentsWC = 50; // position of comments on line with code settings.posOfCommentsNC = 0; // position of comments on line settings.leaveCommentsNC = false;// true = don't change the indentation of comments with code. settings.quoteChars = false;// use tabs to indents rather than spaces settings.deleteHighChars = 3; // 0 = no check , 1 = delete high chars, // 3 = delete high chars, but not graphics settings.topBraceLoc = true; // Start top-level open braces on new line settings.braceLoc = true; // Start open braces on new line settings.output = true; // Set this true for normal program output settings.queueBuffer = 10; // Set the number if lines to store in memory at a time ! settings.backUp = false;// backup the original file, have output file become input file name ! ************************************************************************************ */ // Function processes command line parameters // FIRST read of the command line will search for the -fnc option to // read the configuration file, default is bcpp.cfg at current directory if (ProcessCommandLine (argc, argv, settings, pInFile, pOutFile, pConfig) != 0) return -1; // problems // ********************************************************************* // Find default path and default configuration file name if (pConfig == NULL) FindConfigFile ("bcpp.cfg", pConfigFile); else pConfigFile = fopen(pConfig, "r"); if (pConfigFile == NULL) { warning ("\nCouldn't Open Config File: %s\n", pConfig); warning ("Read Docs For Configuration Settings\n"); } else { // LOAD CONFIG FILE ! errorNum = SetConfig (pConfigFile, settings); // If output is via stdout, then turn out program output if it's // set within config file ! if (pOutputFile == stdout) settings.output = false; if (settings.output != false) warning ("\n%d Error(s) In Config File.\n\n", errorNum); } // ********************************************************************* // SECOND read of the command line will overwrite settings that may have // been changed by the previous command. Lots of processing to overcome // this process, but hey it's a easy solution ! pInFile = pOutFile = NULL; // reset these so they can re-assigned again ! if (ProcessCommandLine (argc, argv, settings, pInFile, pOutFile, pConfig) != 0) return -1; // problems // ********************************************************************* // backup original filename! if ( ((settings.backUp != false) && (pInFile != NULL)) && (pOutFile == NULL)) // Test if user wants an output file ! { if (BackupFile (pInFile, pOutFile) != 0) return -1; renamed = true; } // ************************************************************** // assign I/O streams if (pInFile == NULL) pInputFile = stdin; else pInputFile = fopen(pInFile, "r"); if (pOutFile == NULL) { pOutputFile = stdout; settings.output = false; // if using standard out, don't corrupt output } else pOutputFile = fopen(pOutFile, "wb"); // Check user defined I/O streams if (pInputFile == NULL) { warning ("%s %s\n", pNoFile, pInFile); errorCode = -1; } if (pOutputFile == NULL) { warning ("%s %s\n", pNoFile, pOutFile); errorCode = -1; } if ((settings.output != false) && (errorCode == 0)) errorNum = ShowConfig(settings); if (pConfigFile != NULL) fclose (pConfigFile); // #### Lets do some code crunching ! if ((errorNum == 0) && (errorCode == 0)) errorCode = ProcessFile (pInputFile, pOutputFile, settings); if (settings.output != false) verbose ("\nCleaning Up Dinner ... "); if (pInputFile != NULL) fclose (pInputFile); if (pOutputFile != NULL) fclose (pOutputFile); if (renamed) { RestoreIfUnchanged(pInFile, pOutFile); delete[] pInFile; } if (settings.output != false) verbose ("Done !\n"); return errorCode; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ int main (int argc, char* argv[]) { return LoadnRun (argc, argv); } // The End :-). bcpp-20210108/code/baseq.cpp0000644000175100001440000001407710226270172014135 0ustar tomusers#ifndef _QUEUE_LIST_CODE #define _QUEUE_LIST_CODE // $Id: baseq.cpp,v 1.5 2005/04/10 18:29:14 tom Exp $ // Code written by Steven De Toni ACBC 11 // These class methods used to implement a object that holds other objects // that are descendant of ANYOBJECT (i.e universal container). #include "baseq.h" #include // NULL CONSTANT // ############################################################################ // #### QueueList Class #### // ######################### // ############################ Protected Methods ############################# // Create new list item and place programmer's data within it, // make new links with previous item if wished. // returns a pointer to the new item, NULL if operation failed. // // Parameters: // pItem : Pointer to the object to be stored. // LinkItem : Pointer to end of list where item to be added. // // Return Values: // LinkItem : returns pointer to newly added item in list, // NULL if operation failed. However items within list // before hand still exist. LinkItem* QueueList::newItem (ANYOBJECT* pItem, LinkItem* pEndList) { LinkItem* pNewStruct = new LinkItem; if (pNewStruct != NULL) { pNewStruct->pLinkedItem = pEndList; pNewStruct->pStoredItem = pItem; } return pNewStruct; } // ############################## Public Methods ############################## // ############################### Constructors ############################### #define MY_DEFAULT \ itemCount(0), \ pEndPos(NULL), \ spaceAvailable(0) QueueList::QueueList (void) : MY_DEFAULT { } // Parameters: // pItem : Pointer to a object to be stored, must be descendant of // base class ANYOBJECT. QueueList::QueueList (ANYOBJECT* pItem) : MY_DEFAULT { putLast(pItem); } #undef MY_DEFAULT // ########################### User Methods ################################### // Place programmers object into list // // Parameters: // pItem : Pointer to a object to be stored, must be descendant of // base class ANYOBJECT. // // Return Values: // int : Returns a error code indicating whether operation was // successful. // Values: // 0 = No Worries // -1 = Arrgh ... No memory // int QueueList::putLast (ANYOBJECT* pItem) { LinkItem* pNewItem = newItem (pItem, pEndPos); if (pNewItem != NULL) { pEndPos = pNewItem; itemCount++; return 0; } spaceAvailable = -1; return -1; // could not add item to list! } // Take first item placed in Queue, out and return it. // Type casting is required to return object back to its original // state. // // Return Values: // ANYOBJECT* : Pointer to the object that was stored within queue. // ANYOBJECT* QueueList::takeNext (void) { if (pEndPos != NULL) { LinkItem* pUpDateList = pEndPos; LinkItem* pStartPos = pEndPos; // move down list until start has been reached while (pStartPos->pLinkedItem != NULL) pStartPos = pStartPos->pLinkedItem; if (pStartPos != pUpDateList) // if not the last item in list { // retrieve data and delete item from list while (pUpDateList->pLinkedItem != pStartPos) pUpDateList = pUpDateList->pLinkedItem; } else { pEndPos = NULL; // start new list after all items gone } ANYOBJECT* pTemp = pStartPos->pStoredItem; // copy value to user pUpDateList->pLinkedItem = NULL; // make new start of list delete pStartPos; // delete object itemCount--; // one less if (spaceAvailable) // if no memory available before... spaceAvailable = 0; // there is now! return pTemp; } else return NULL; } // Returns the number of items contained within the queue. // // Returns Values: // int : Num of items within queue. // int QueueList::status (void) // return number of item in Queue { return itemCount; } // Method returns whether last operation failed due to memory allocation // failure. // // Return Values: // int : Returns 1 of two values ... // Values: // 0 = memory available // -1 = Last memory allocation failed. // int QueueList::space (void) // return Queue space left { return spaceAvailable; // return -1 if no space available } // Methods is used to peek within the queue at objects, and return their // pointer without taking them out of the queue. // // Parameters: // NumFromNext : The object number to look at from the start of the // queue. The start of the queue is 1, not 0. // // Return Values: // ANYOBJECT* : Pointer to the object that is stored within queue, // at said position. Returns NULL if operation failed. // ANYOBJECT* QueueList::peek (int numFromNext) { if (pEndPos != NULL) { //if (numFromNext > itemCount) //error checking ! // return NULL; int count = itemCount - numFromNext; LinkItem* pStartPos = pEndPos; if (count >= 0) { // move down list until start has been reached while (count > 0) { pStartPos = pStartPos->pLinkedItem; count--; } if (pStartPos != NULL) return pStartPos->pStoredItem; } } return NULL; } // ############################### Destructor ############################### // Method will remove all list items from memory if they still exist, // no garbage collection provided, or used. // QueueList::~QueueList (void) { LinkItem* pTemp = pEndPos; while (pEndPos != NULL) { pEndPos = pEndPos->pLinkedItem; // advance to next item delete pTemp ->pStoredItem; // kill data contained delete pTemp; // kill item pTemp = pEndPos; } } #endif bcpp-20210108/code/baseq.h0000644000175100001440000000767710226270301013604 0ustar tomusers// $Id: baseq.h,v 1.3 2005/04/10 18:30:25 tom Exp $ #ifndef _QUEUE_LIST_HEADER #define _QUEUE_LIST_HEADER // Code written by Steven De Toni ACBC 11 // this header definition contains a container class that stores data // in a queued linked list. #include "anyobj.h" // include base class struct LinkItem { LinkItem* pLinkedItem; // linker (pointer to the next item in the list) ANYOBJECT* pStoredItem; // data that is store within a list item }; class QueueList { protected: int itemCount; LinkItem* pEndPos; int spaceAvailable; // set to 0 for space available, // -1 if no space available; // Create new list item and place programmer's data within it, // make new links with previous item if wished. // returns a pointer to the new item, NULL if operation failed. // // Parameters: // pItem : Pointer to the object to be stored. // LinkItem : Pointer to end of list where item to be added. // // Return Values: // LinkItem : returns pointer to newly added item in list, // NULL if operation failed. However items within list // before hand still exist. LinkItem* newItem (ANYOBJECT* pItem, LinkItem* pEndList); public: // constructors QueueList (void); // Parameters: // pItem : Pointer to a object to be stored, must be descendant of // base class ANYOBJECT. QueueList (ANYOBJECT* pItem); // use the defaults here QueueList(const QueueList&); QueueList& operator=(const QueueList&); // Place programmers object into list // // Parameters: // pItem : Pointer to a object to be stored, must be descendant of // base class ANYOBJECT. // // Return Values: // int : Returns a error code indicating whether operation was // successful. // Values: // 0 = No Worries // -1 = Arrgh ... No memory // int putLast (ANYOBJECT* pItem); // Take first item placed in Queue, out and return it. // Type casting is required to return object back to it's original // state. // // Return Values: // ANYOBJECT* : Pointer to the object that was stored within queue. // ANYOBJECT* takeNext (void); // Returns the number of items contained within the queue. // // Returns Values: // int : Num of items within queue. // int status (void); // Method returns whether last operation failed due to memory allocation // failure. // // Return Values: // int : Returns 1 of two values ... // Values: // 0 = memory available // -1 = Last memory allocation failed. // int space (void); // return Queue space left // Methods is used to peek within the queue at objects, and return there // pointer without taking them out of the queue. // // Parameters: // NumFromNext : The object number to look at from the start of the // queue. The start of the queue is 1, not 0. // // Return Values: // ANYOBJECT* : Pointer to the object that is stored within queue, // at said position. Returns NULL if operation failed. // ANYOBJECT* peek (int numFromNext); // Method will remove all list items from memory if they still exist, // no garbage collection provided, or used. // ~QueueList (void); }; #endif bcpp-20210108/code/html.cpp0000644000175100001440000000627613776165570014032 0ustar tomusers//****************************************************************************** // Copyright 1999-2003,2021 by Thomas E. Dickey * // All Rights Reserved. * // * // Permission to use, copy, modify, and distribute this software and its * // documentation for any purpose and without fee is hereby granted, provided * // that the above copyright notice appear in all copies and that both that * // copyright notice and this permission notice appear in supporting * // documentation, and that the name of the above listed copyright holder(s) * // not be used in advertising or publicity pertaining to distribution of the * // software without specific, written prior permission. THE ABOVE LISTED * // COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * // EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, * // INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * // PERFORMANCE OF THIS SOFTWARE. * //****************************************************************************** // $Id: html.cpp,v 1.7 2021/01/08 23:32:08 tom Exp $ #include "bcpp.h" #include "cmdline.h" #include #include static char * UpperCase(const char *text) { while (isspace(*text)) text++; char *temp = new char[strlen(text)+1]; strcpy(temp, text); for (int n = strlen(temp); n > 0; n--) if (isspace(temp[n-1])) temp[--n] = 0; StrUpr(temp); return temp; } static bool BeginScript(const char *text) { char *temp = UpperCase (text); bool code = !strcmp("", temp) || !strcmp("", temp); delete[] temp; return code; } bool HtmlStruct::Active(const char *pLineData) { bool match = false; int n; switch (state) { case 0: for (n = 0; pLineData[n] != 0; n++) { if (!isspace(pLineData[n])) { if (pLineData[n] == '<') { state = 1; } else { state = -1; } break; } } // FALLTHRU case 1: if (BeginScript(pLineData)) { state = 2; match = true; } break; case 2: if (EndScript(pLineData)) { state = 1; match = true; } break; default: // We've decided it is not HTML + JavaScript break; } return ((state == 1) || match); } bcpp-20210108/code/config.h0000644000175100001440000001006313776164715013765 0ustar tomusers#ifndef _CONFIG_HEADER #define _CONFIG_HEADER // $Id: config.h,v 1.16 2021/01/08 23:25:01 tom Exp $ // Program C(++) beautifier Written By Steven De Toni ACBC 11 10/94 // // This file contains prototypes, constants, enum declarations for the // source file config?.cpp. Prototypes declared can read data from a // text file a line at a time, and able to read parameters from a // configuration file. #include // FILE Structure // Commonly-used characters that are awkward to represent const char NULLC = '\0'; const char TAB = '\t'; const char LF = '\n'; const char CR = '\r'; const char SPACE = ' '; const char SEMICOLON = ';'; const char POUNDC = '#'; const char L_CURL = '{'; const char R_CURL = '}'; const char L_PAREN = '('; const char R_PAREN = ')'; const char DQUOTE = '"'; const char SQUOTE = '\''; const char ESCAPE = '\\'; // This structure is used to store the users settings that are read from a // configuration file. struct Config { int numOfLineFunc ; // number of lines between functions int tabSpaceSize ; // number of spaces a tab takes up {4} bool useTabs ; // true = use tabs in indenting, false = use spaces int posOfCommentsWC; // position of comments on line with code int posOfCommentsNC; // position of comments on line bool keepCommentsWC ; // true = keep comments inline with code bool leaveCommentsNC; // true = don't change the indentation of comments with code. bool quoteChars ; // change non-ASCII chars in quotes to octal notation int deleteHighChars; // 0 = no check , 1 = delete high chars, // 2 = don't delete graphics chars bool topBraceLoc ; // true = place on new line, false = at end of code bool braceLoc ; // true = place on new line, false = at end of code bool output ; // Set this true for normal program output int queueBuffer ; // Set the number if lines to store in memory at a time ! bool backUp ; // backup the original file, have output file become input file name ! bool indentPreP ; // indent preprocessor controls to match code bool indent_sql ; // indent embedded SQL statements bool braceIndent ; // true = indent trailing brace, false = don't bool braceIndent2 ; // true = indent both braces, false = don't }; // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Allocates memory for line in file, and places that the data in it. // pInFile = the file handle to use when reading the file ! // EndOfFile variable is used to test if the end of the file has been reached. // When this is true, the variable is changed to -1 // // A string is returned with the contents the current line in the file, // memory is allocated via the ReadLine routine, and should be deleted // when not needed ! char* ReadLine (FILE *pInFile, int& EndOfFile); // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // This function is used to load the users configuration from a file. // // Parameters: // pConfigFile : Pointer to a FILE structure/handle that contains the // configuration data. // userSettings : Config structure that will contain the user settings. // // Return Values: // int : Returns the number of errors encountered when reading the // configuration file. // userSettings : This variable is altered to the user settings read from the // config file. // extern int SetConfig (FILE* pConfigFile, Config& userSettings); // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // This function is used to show the users configuration // // Parameters: // userSettings : Config structure that contains the user settings. // // Return Values: // int : Returns the number of errors encountered when reading the // configuration file. // extern int ShowConfig(Config& userSettings); #endif bcpp-20210108/code/config.cpp0000644000175100001440000004113513776164667014332 0ustar tomusers// $Id: config.cpp,v 1.27 2021/01/08 23:24:39 tom Exp $ // Program C(++) beautifier Written By Steven De Toni ACBC 11 11/94 // // This program module contains routines to read data from a text file a // line at a time, and able to read parameters from a configuration file. #include // atol(), #include // strlen(), strstr(), strcpy(), strcmp(), strpbrk() #include // NULL constant, printf(), FILE, ftell(), fseek(), fprintf(), stderr #include #include "bcpp.h" #include "cmdline.h" // StrUpr() enum ConfigWords {ANYT = 0, FSPC, UTAB, ISPC, IPRO, ISQL, NAQTOOCT, COMWC, COMNC, KCWC, LCNC, LGRAPHC, ASCIIO, BI, BI2, PTBNLINE, PBNLINE, PROGO, QBUF, BUF, EQUAL, YES, ON, NO, OFF}; static const struct { ConfigWords code; const char *name; } ConfigData[] = { { ANYT, ";" }, { FSPC, "FUNCTION_SPACING" }, { UTAB, "USE_TABS" }, { ISPC, "INDENT_SPACING" }, { IPRO, "INDENT_PREPROCESSOR" }, { ISQL, "INDENT_EXEC_SQL" }, { NAQTOOCT, "NONASCII_QUOTES_TO_OCTAL" }, { COMWC, "COMMENTS_WITH_CODE" }, { COMNC, "COMMENTS_WITH_NOCODE" }, { KCWC, "KEEP_COMMENTS_WITH_CODE" }, { LCNC, "LEAVE_COMMENTS_NOCODE" }, { LGRAPHC, "LEAVE_GRAPHIC_CHARS" }, { ASCIIO, "ASCII_CHARS_ONLY" }, { BI, "BRACE_INDENT" }, { BI2, "INDENT_BOTH_BRACES" }, { PTBNLINE, "PLACE_TOP_BRACE_ON_NEW_LINE" }, { PBNLINE, "PLACE_BRACE_ON_NEW_LINE" }, { PROGO, "PROGRAM_OUTPUT" }, { QBUF, "QUEUE_BUFFER" }, { BUF, "BACKUP_FILE" }, { EQUAL, "=" }, { YES, "YES" }, { ON, "ON" }, { NO, "NO" }, { OFF, "OFF" } }; static const size_t SizeofData = TABLESIZE(ConfigData); // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Allocates memory for line in file, and places that the data in it. // pInFile = the file handle to use when reading the file. // EndOfFile variable is used to test if the end of the file has been reached. // When this is true, the variable is changed to -1 // // A string is returned with the contents the current line in the file, // memory is allocated via the ReadLine routine, and should be deleted // when not needed. char* ReadLine (FILE *pInFile, int& EndOfFile) { const int nominal = 80; int used = nominal; int need = 0; int ch; char* pLineBuffer = new char [used]; for(;;) { ch = fgetc(pInFile); if (ch < 0) { EndOfFile = ch; break; } else if (ch == LF) { break; } if (need + 2 > used) { used = ((need + 2) * 3) / 2; char *temp = new char [used]; for (int n = 0; n < need; n++) temp[n] = pLineBuffer[n]; delete[] pLineBuffer; pLineBuffer = temp; } pLineBuffer[need++] = ch; } pLineBuffer[need] = 0; return pLineBuffer; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Lookup keyword in ConfigData[] static const char *ConfigWordOf(ConfigWords code) { for (size_t i = 0; i < SizeofData; i++) if (ConfigData[i].code == code) return ConfigData[i].name; return 0; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // This function is used to generate a generic error message. // // Parameters: // LineNo : Line number where the error occurred // errorCode : Error type to output to the user // errorCount : This variable is increment when this function is used // pMessage : Use by programmer to add additional information about the error // // // Return Values: // errorCount : This variable is used to show how many errors have occurred. // static void ErrorMessage (int lineNo, int errorCode, int& errorCount, const char* pMessage = NULL) { switch (errorCode) { case (1): { warning ("Syntax Error After Key Word "); break; } case (2): { warning ("Range Error !"); break; } case (3): { warning ("Expected Numeric Data !"); break; } case (4): { warning ("Can't Decipher"); break; } } if (pMessage != NULL) warning ("%s", pMessage); warning (" At Line %d\n", lineNo); errorCount++; } static void trimConfigLine(char *data) { if (data != NULL) { char* pWordLoc = strstr (data, ConfigWordOf(ANYT)); if (pWordLoc != NULL) *pWordLoc = NULLC; size_t len = strlen(data); while (len != 0 && isspace(data[len - 1])) data[--len] = NULLC; } } static void skipBlanks(const char *& string) { while (isspace(*string)) ++string; } static void skipKeyword(const char *& string) { if (*string == '=') { ++string; // yes, "=" is a keyword } else { while (isalnum(*string) || *string == '_') ++string; } } // find the next keyword in the data, setting its length as a side-effect. static const char *parseKeyword(const char *& from, size_t& len) { const char *result; skipBlanks(from); result = from; skipKeyword(from); len = from - result; return result; } // compare a desired keyword 'want' against the actual data 'have'. static bool matchKeyword(const char *want, const char *have, size_t haveLen) { bool result = false; size_t wantLen = strlen(want); if (haveLen == wantLen && !strncmp(want, have, wantLen)) { result = true; } return result; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Function finds keywords within a line of data. // // Parameters: // Type : // The parameter is used to define the type of keyword to find within // a configuration line. // // See ConfigWords enum for values, Use ANYT, or a value of 0 to search // for any valid keywords within the line. // // pConfigLine : // This parameter is a pointer to a string that contains the data that // is going to be searched. // // Return Values: // // Type : Returns the keyword value expected, or keyword value found if // searching for any. // // Char*: Returns a pointer in the string to the next starting location // AFTER the keyword found. Or returns NULL if no keyword found. // static const char* FindConfigWords (const char* pConfigLine, ConfigWords& type) { size_t len; const char* pToMatch = parseKeyword(pConfigLine, len); if (len != 0) { if (type > ANYT) { if (matchKeyword(ConfigWordOf(type), pToMatch, len)) { return pToMatch + len; } } for (size_t typeCount = 1; typeCount < SizeofData; typeCount++) { if (matchKeyword(ConfigData[typeCount].name, pToMatch, len)) { type = ConfigData[typeCount].code; return pToMatch + len; } } } type = ANYT; // not a keyword return NULL; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // ConfigAssignment function is used to assigned Boolean, or unsigned integer // values from 0 - 5000 to variables that are passed to it. // // Parameters: // errorCount : Variable used to define how many errors have occurred. If any errors // encountered within the function, then this var will be incremented. // PosInLine : Defines a pointer to the starting location to read in data for // assignment from config data line (string). // variable : This defines the variables that's going to be altered, be boolean, or // integer. // // Return Values: // errorCount : If any error occur within variable assignment, the a error // message is displayed, and this variable is incremented. // variable : If no errors have occurred, then this variable will contain the value // that was set by the user. // static void ConfigAssignment (int& errorCount, int& configError, const char* pPosInLine, int& variable) { // convert what's left in the string to an INTEGER. if (strpbrk(pPosInLine, "0123456789") != NULL) variable = atoi (pPosInLine); else ErrorMessage (errorCount, 3, configError); // check range of lines numbers between functions. if ( (variable < 0) || (variable > 5000) ) ErrorMessage (errorCount, 2, configError, " Valid Range = 0 - 5000"); } static void ConfigAssignment (int& errorCount, int& configError, const char* pPosInLine, bool& variable) { ConfigWords type = ANYT; // check if key words are there pPosInLine = FindConfigWords (pPosInLine, type); switch (type) { case (YES): // YES case (ON) : // ON variable = true; break; case (NO) : // NO case (OFF): // OFF variable = false; break; default: ErrorMessage (errorCount, 1, configError, ConfigWordOf(EQUAL)); } // switch } #define DecodeIt(value) \ { \ ConfigWords tesType = EQUAL; \ pPosInLine = FindConfigWords (pPosInLine, tesType); \ \ if (tesType != EQUAL) { \ ErrorMessage (lineCount, 1, configError, ConfigWordOf(type)); \ break; \ } else \ ConfigAssignment (lineCount, configError, pPosInLine, value); \ } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // This function is used to load the users configuration from a file. // // Parameters: 2 // pConfigFile : Pointer to a FILE structure/handle that contains the // configuration data. // userSettings : Config structure that will contain the user settings. // // Return Values: // int : Returns the number of errors encountered when reading the // configuration file. // userSettings : This variable is altered to the user settings read from the // config file. // int SetConfig (FILE* pConfigFile, Config& userSettings) { int noMoreConfig = 0 ; char* pLineOfConfig = NULL; const char* pPosInLine = NULL; ConfigWords type ; int lineCount = 0 ; int configError = 0 ; bool test; while (! noMoreConfig) { pLineOfConfig = ReadLine (pConfigFile, noMoreConfig); lineCount++; // upcase all characters in string. StrUpr (pLineOfConfig); if (pLineOfConfig != 0) trimConfigLine(pLineOfConfig); type = ANYT; pPosInLine = FindConfigWords (pLineOfConfig, type); switch (type) { case (FSPC): // FUNCTION_SPACING = (%d) DecodeIt (userSettings.numOfLineFunc); break; case (UTAB): // USE_TABS = {on, off, yes, no} DecodeIt (userSettings.useTabs); break; case (ISPC): // INDENT_SPACING = (%d) DecodeIt (userSettings.tabSpaceSize); break; case (IPRO): // INDENT_PREPROCESSOR = {on, off, yes, no} DecodeIt (userSettings.indentPreP); break; case (ISQL): // INDENT_EXEC_SQL = {on, off, yes, no} DecodeIt (userSettings.indent_sql); break; case (NAQTOOCT): // NONASCII_QUOTES_TO_OCTAL = {on, off, yes, no} DecodeIt (userSettings.quoteChars); break; case (COMWC): // COMMENTS_WITH_CODE = (%d) DecodeIt (userSettings.posOfCommentsWC); break; case (COMNC): // COMMENTS_WITH_NOCODE = (%d) DecodeIt (userSettings.posOfCommentsNC); break; case (KCWC): // KEEP_COMMENTS_WITH_CODE = {on, off, yes, no} DecodeIt (userSettings.keepCommentsWC); break; case (LCNC): // LEAVE_COMMENTS_NOCODE = {on, off, yes, no} DecodeIt (userSettings.leaveCommentsNC); break; case (LGRAPHC): // LEAVE_GRAPHIC_CHARS = {on, off, yes, no} test = false; DecodeIt (test); if (test == true) userSettings.deleteHighChars = 3; // set bit 0, 1 else userSettings.deleteHighChars = 0; // unset bit 0, 1 break; case (ASCIIO): // ASCII_CHARS_ONLY = {on, off, yes, no} test = false; DecodeIt (test); if (test == true) userSettings.deleteHighChars = 1; // set bit 0 else userSettings.deleteHighChars = 0; // unset bit 0 break; case (BI): // BRACE_INDENT = {on, off, yes, no} DecodeIt (userSettings.braceIndent); break; case (BI2): // INDENT_BOTH_BRACES = {on, off, yes, no} DecodeIt (userSettings.braceIndent2); break; case (PTBNLINE): // PLACE_TOP_BRACE_ON_NEW_LINE = {on, off, yes, no} DecodeIt (userSettings.topBraceLoc); break; case (PBNLINE): // PLACE_BRACE_ON_NEW_LINE = {on, off, yes, no} DecodeIt (userSettings.braceLoc); break; case (PROGO): // PROGRAM_OUTPUT = {on, off, yes, no} DecodeIt (userSettings.output); break; case (QBUF): // queue_buffer = (%d) DecodeIt (userSettings.queueBuffer); if (userSettings.queueBuffer < 2) userSettings.queueBuffer = 2; break; case (BUF): // backup_file = {on, off, yes, no} DecodeIt (userSettings.backUp); break; case (ANYT): break; default: warning("Text:%s\n", pLineOfConfig); ErrorMessage (lineCount, 4, configError); break; }// switch delete[] pLineOfConfig; }// while return configError; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // This function is used to show the users configuration. // // Parameters: // userSettings : Config structure that contains the user settings. // // Return Values: // int : Returns the number of errors encountered when reading the // configuration file. // int ShowConfig (Config& userSettings) { const char* choices[2] = {"Yes", "No"}; int errorNum = 0; verbose ("Function Line Spacing : %d\n", userSettings.numOfLineFunc); verbose ("Use Tabs In Indenting : %s\n", choices[userSettings.useTabs+1]); verbose ("Indent Spacing Length : %d\n", userSettings.tabSpaceSize); verbose ("Comments With Code : %d\n", userSettings.posOfCommentsWC); if (userSettings.leaveCommentsNC != false) verbose ("Comments With No Code : Indented According To Code\n"); else verbose ("Comments With No Code : %d\n", userSettings.posOfCommentsNC); verbose ("Remove Non-ASCII Chars : "); switch (userSettings.deleteHighChars) { case (0): verbose ("No\n"); break; case (1): verbose ("Yes\n"); break; case (3): verbose ("Yes But Not Graphic Chars\n"); break; default: warning ("#### ERROR : Unexpected Value %d", userSettings.deleteHighChars); errorNum++; } verbose ("Non-ASCII Chars In Quotes To Octal : %s\n", choices[userSettings.quoteChars+1]); verbose ("Top-level Open Braces On New Line : %s\n", choices[userSettings.topBraceLoc+1]); verbose ("Open Braces On New Line : %s\n", choices[userSettings.braceLoc+1]); verbose ("Program Output : %s\n", choices[userSettings.output+1]); verbose ("Internal Queue Buffer Size : %d\n", userSettings.queueBuffer); if (errorNum > 0 && prompt("Do You Wish To Continue To Process Files ")) errorNum = 0; return errorNum; } bcpp-20210108/code/bcpp.h0000644000175100001440000003111613776165514013444 0ustar tomusers/****************************************************************************** * Copyright 1996-2009,2021 by Thomas E. Dickey * * All Rights Reserved. * * * * Permission to use, copy, modify, and distribute this software and its * * documentation for any purpose and without fee is hereby granted, provided * * that the above copyright notice appear in all copies and that both that * * copyright notice and this permission notice appear in supporting * * documentation, and that the name of the above listed copyright holder(s) * * not be used in advertising or publicity pertaining to distribution of the * * software without specific, written prior permission. THE ABOVE LISTED * * COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * * EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * ******************************************************************************/ // $Id: bcpp.h,v 1.49 2021/01/08 23:31:24 tom Exp $ #ifndef _BCPP_HEADER #define _BCPP_HEADER #include #include #ifdef HAVE_CONFIG_H #include "autoconf.h" #endif #include "config.h" #include "anyobj.h" // Use ANYOBJECT base class #include "baseq.h" // QueueList class to store Output structures #include "stacklis.h" // StackList class to store indentStruct // Common/miscellaneous definitions for BCPP #define TABLESIZE(n) (sizeof(n)/sizeof(n[0])) #ifndef VERSION #define VERSION "" #endif #ifdef DEBUG #define TRACE(p) trace p #else #define TRACE(p) /*nothing*/ #endif #if defined(sun) && !defined(__SVR4) // SunOS extern "C" { extern char *strcat(char *, const char *); extern char *strncpy(const char *, const char *, size_t); extern char *strstr(const char *, const char *); extern int strncmp(const char *, const char *, size_t); }; #endif #ifdef __GNUC__ #define HAVE_UNISTD_H 1 #else #define bool int // FIXME #endif //----------------------------------------------------------------------------- // Character-state, chosen to allow storing as a null-terminated char-string enum CharState { NullC = 0, Blank = ' ', // whitespace not in other categories PreProc = '#', // preprocessor (first chunk, with '#') Normal = '.', // code DQuoted = '"', // "string" SQuoted = '\'', // 'c' Comment = 'c', // C comment Ignore = 'C' // C++ comment }; // ---------------------------------------------------------------------------- enum DataTypes { NoType = 0, CCom = 1, CppCom = 2, Code = 3, OBrace = 4, CBrace = 5, PreP = 6, ELine = 7 }; // ---------------------------------------------------------------------------- enum IndentAttr { noIndent=0, oneLine=1, multiLine=2, blockLine=3 }; // ---------------------------------------------------------------------------- typedef struct { const char *name; IndentAttr code; } IndentwordStruct; extern const IndentwordStruct pIndentWords[]; // ---------------------------------------------------------------------------- // This structure is used to store line data that is de-constructed from the // user's input file. #define MY_DEFAULT \ dataType(NoType), \ comWcode(false), \ offset(0), \ pData(), \ pState() class InputStruct : public ANYOBJECT { public: DataTypes dataType; // i.e "/*" or "*/" (CCom) // "//" (CppCom) // Code (a = 5; , if (a == b) .. (Code) // "{" (OBrace) // "}" (CBrace) // #define (PreP) // SPACES (nothing, blank line) (ELine) bool comWcode; // -1 : true, comment with code (for comment dataType) // 0 : false, comment with no Code int offset; // offset within original line's text char* pData; // pointer to queue data ! char* pState; // pointer to corresponding parse-state inline InputStruct (DataTypes theType, int theOffset) : MY_DEFAULT { dataType = theType; offset = theOffset; comWcode = false; pState = 0; // only non-null for code } // use defaults here: InputStruct(const InputStruct&); InputStruct& operator=(const InputStruct&); }; #undef MY_DEFAULT #if defined(DEBUG) || defined(DEBUG2) extern int totalTokens; // token count, for debugging #endif // ---------------------------------------------------------------------------- // The output structure is used to hold an entire output line. The structure is // expanded with its real tabs/spaces within the output function of the program. #if defined(DEBUG) || defined(DEBUG2) #define DBG_DEFAULT , thisToken(totalTokens++) #else #define DBG_DEFAULT #endif #define MY_DEFAULT \ pType(ELine), \ offset(0), \ bracesLevel(0), \ preproLevel(0), \ indentSpace(0), \ indentHangs(0), \ splitElseIf(false), \ pCode(NULL), \ pCFlag(NULL), \ pBrace(NULL), \ pBFlag(NULL), \ filler(0), \ pComment(NULL) DBG_DEFAULT class OutputStruct : public ANYOBJECT { public: DataTypes pType; int offset; // offset within original line's text int bracesLevel; // curly-brace level at beginning of line int preproLevel; // curly-brace level for preprocessor lines int indentSpace; // num of spaces int indentHangs; // num of indents for continuation bool splitElseIf; // special case for aligning else/if char* pCode; char* pCFlag; // state-flags for pCode char* pBrace; // "}" or "{", with possible code-fragment char* pBFlag; // state-flags for pBrace int filler; // num of spaces char* pComment; #if defined(DEBUG) || defined(DEBUG2) int thisToken; // current token number #endif public: // Constructor // Automate initalisation inline OutputStruct (DataTypes theType) : MY_DEFAULT { pType = theType; } inline OutputStruct (InputStruct* theIn) : MY_DEFAULT { pType = theIn -> dataType; offset = theIn -> offset; } inline OutputStruct (OutputStruct* theIn) : MY_DEFAULT { pType = theIn -> pType; offset = theIn -> offset; } // use defaults here OutputStruct(const OutputStruct &); OutputStruct& operator=(const OutputStruct&); // Destructor // Automate destruction inline ~OutputStruct (void) { delete[] pCode; delete[] pCFlag; delete[] pBrace; delete[] pBFlag; delete[] pComment; } }; #undef MY_DEFAULT #undef DBG_DEFAULT // ---------------------------------------------------------------------------- #define MY_DEFAULT \ stmt_level(0), \ until_parn(0), \ parn_level(0), \ until_curl(0), \ curl_level(0), \ in_aggreg(0), \ do_aggreg(false), \ indent(0) class HangStruct : public ANYOBJECT { private: int stmt_level; // statement-level (from oneLine=0) int until_parn; // suppress hang until right-parenthesis int parn_level; // parentheses-level int until_curl; // suppress hang until R_CURL int curl_level; // curly-brace-level int in_aggreg; // in aggregate, curly-brace-level bool do_aggreg; public: int indent; HangStruct() : MY_DEFAULT { } void IndentHanging (OutputStruct *pOut); private: void ScanState(const char *code, const char *state); }; #undef MY_DEFAULT // ---------------------------------------------------------------------------- class HtmlStruct : public ANYOBJECT { int state; public: HtmlStruct(void) : state(0) { } bool Active(const char *pLineData); }; // ---------------------------------------------------------------------------- #define MY_DEFAULT \ state(NotSQL), \ level(0), \ matched() enum SqlState { NotSQL = 0, DeclSQL = 1, BeginSQL = 2, MoreSQL = 3 }; class SqlStruct : public ANYOBJECT { SqlState state; int level; char matched[80]; public: SqlStruct(void) : MY_DEFAULT { matched[0] = 0; } void IndentSQL(OutputStruct *pOut); private: int NextWord(int start, OutputStruct *pOut); int SkipWord(int start, OutputStruct *pOut); bool SqlVerb(const char *code); }; #undef MY_DEFAULT // ---------------------------------------------------------------------------- // This structure is used to hold indent data on non-brace code. // This includes case statements, single line if's, while's, for statements... #define MY_DEFAULT \ attrib(noIndent), \ pos(), \ singleIndentLen() class IndentStruct : public ANYOBJECT { public: // attribute values ... // value 1 = indent code one position, until a ';' is found ! // 2 = end on close brace, and at a position "pos" IndentAttr attrib; int pos; // Indent double the amount for multiline single if, while ... // statements. int singleIndentLen; // constructor IndentStruct (void) : MY_DEFAULT { attrib = noIndent; pos = 0; singleIndentLen = 0; // number of spaces to indent ! } }; #undef MY_DEFAULT //----------------------------------------------------------------------------- // debug.cpp extern void trace (const char *format, ...); #ifdef DEBUG extern void traceInput(const char *file, int line, InputStruct *pIn); extern void traceIndent(const char *file, int line, IndentStruct *pIndent); extern void traceOutput(const char *file, int line, OutputStruct *pOut); #define TRACE_INPUT(pOut) traceInput(__FILE__, __LINE__, pOut); #define TRACE_INDENT(pOut) traceIndent(__FILE__, __LINE__, pOut); #define TRACE_OUTPUT(pOut) traceOutput(__FILE__, __LINE__, pOut); #else #define TRACE_INPUT(pOut) /* nothing */ #define TRACE_INDENT(pOut) /* nothing */ #define TRACE_OUTPUT(pOut) /* nothing */ #endif inline bool emptyString(const char *s) { return s == 0 || *s == 0; } //----------------------------------------------------------------------------- // backup.cpp extern int BackupFile (char*& oldFilename, char*& newFilename); extern void RestoreIfUnchanged(char *oldFilename, char *newFilename); // exec_sql.cpp extern void IndentSQL (OutputStruct *pOut, int& state); // hanging.cpp extern void IndentHanging (OutputStruct *pOut, HangStruct& state); // FIXME extern int LookupKeyword(const char *tst); extern bool ContinuedQuote(OutputStruct *pOut); // strings.cpp extern bool isName(char c); extern bool CompareKeyword(const char *tst, const char *ref); extern char *NewString (const char *src); extern char *NewSubstring (const char *src, size_t len); extern const char *SkipBlanks(const char *s); // tabs.cpp extern void ExpandTabs (char* &pString, int tabLen, int deleteChars, bool quoteChars, CharState &curState, char * &lineState, bool &codeOnLine); extern char* TabSpacing (int mode, int col, int len, int spaceIndent); // verbose.cpp extern bool prompt (const char *format, ...); extern void verbose (const char *format, ...); extern void warning (const char *format, ...); #endif // _BCPP_HEADER bcpp-20210108/code/cmdline.h0000644000175100001440000000156307651627253014134 0ustar tomusers#ifndef _CMDLINE_HEADER #define _CMDLINE_HEADER // $Id: cmdline.h,v 1.2 2003/04/24 00:24:11 tom Exp $ #include "config.h" // Config structure // ******* Define Prototypes ******** // Function converts a lower case string into upper case, any special // characters remain the same (i.e "$", "%" ...) void StrUpr (char* pUpCase); // This function displays brief command line help to the user. // Parameters: // char* argv[] : Pointer to command line parameter pointer array // void PrintProgramHelp (void); // integer assignment int intAssign (int& cmdCount, int argc, char* argv[] ); // string assignment char* strAssign (int& cmdCount, int argc, char* argv[]); // Function processes command line parameters int ProcessCommandLine (int argc, char* argv[], Config& settings, char*& pInFile, char*& pOutFile, char*& pConfig); #endif bcpp-20210108/bcpp.cfg0000644000175100001440000001306506644240721013033 0ustar tomusers; This file contains configuration parameters that are used ; within the bcpp program. ; There are two types of parameter types : Boolean, and Integer. ; Boolean types can have only two valid values [On, Yes, or Off, No]. ; Integer types can have a valid range of 0 - 5000. ;------------------------------------------------------------------------ ; This parameter specifies how many lines separate between two ; functions. ;------------------------------------------------------------------------ function_spacing = 2 ; Integer ;------------------------------------------------------------------------ ; Specifies whether to use tabs in indenting code. ;------------------------------------------------------------------------ use_tabs = no ; Boolean ;------------------------------------------------------------------------ ; Specifies how many spaces to indent. This parameter is also used ; for tab indenting, as 1 tab may be worth 8 spaces if so desired. ; This parameter is used to position comments in TAB mode, and expanding ; of tabs within code! ;------------------------------------------------------------------------ indent_spacing = 4 ; Integer ;------------------------------------------------------------------------ ; Specifies whether to indent preprocessor controls to match the code ;------------------------------------------------------------------------ indent_preprocessor = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies whether to indent embedded SQL statements ;------------------------------------------------------------------------ indent_exec_sql = yes ; Boolean ;------------------------------------------------------------------------ ; Defines at what start position comments that have code on the ; same line to be placed. ;------------------------------------------------------------------------ comments_with_code = 50 ; Integer ;------------------------------------------------------------------------ ; Defines at what start position comments with no code start. ;------------------------------------------------------------------------ comments_with_nocode = 0 ; Integer ;------------------------------------------------------------------------ ; Set this option to ON turns off setting indentation position of parameter ; "comments_with_nocode". Indentation is then set according to code ; position. ;------------------------------------------------------------------------ leave_comments_nocode = yes ; Boolean ;------------------------------------------------------------------------ ; Use this option is used to change non-ascii (non-printable) chars to ; octal notation if they lie within quotes. Either ; Ascii_Chars_Only, XOR Leave_Graphic_Chars parameters need to be set ; as a True value for this parameter to take effect. ;------------------------------------------------------------------------ NonAscii_Quotes_to_Octal = yes ; Boolean ;------------------------------------------------------------------------ ; Setting this parameter to yes will strip non-printable characters ; from the source files, but leave any character that are IBM ; graphics alone. Any non-printable characters that lie within ; quotes will be transformed into octal/character notation, if ; NonAscii_Quotes_To_Octal parameter is set to True. ;------------------------------------------------------------------------ ; leave_graphic_chars = yes ; Boolean ;------------------------------------------------------------------------ ; Setting this parameter to yes will strip any non-printable, ; non-ascii characters from the input file. Any non-printable ; octal/character notation if NonAscii_Quotes_To_Octal is set to ; True. Comment out this parameter if you are using ; Leave_Graphic_Chars parameter, as this parameter will override ; it. ;------------------------------------------------------------------------ ascii_chars_only = no ; Boolean ;------------------------------------------------------------------------ ; This parameter will place open braces on a new line after it's ; associated code if set on/yes. Else the brace will be place on ; next above line if possible, with it's code. ;------------------------------------------------------------------------ place_brace_on_new_line = yes ; Boolean ;------------------------------------------------------------------------ ; This parameter will stop output from the program corrupting output ; that may exit from the program via the standard output. ; If this parameter is set to off/no then no output is generated from ; the program, unless an error is encountered ;------------------------------------------------------------------------ program_output = yes ; Boolean ;------------------------------------------------------------------------ ; Specifies what the internal memory requirements will be in size of the ; line processing buffer. This essentially is used only for open brace ; relocation in kernighan/ritchie style. ;------------------------------------------------------------------------ Queue_Buffer = 10 ; Integer ;------------------------------------------------------------------------ ; If this option is set to true then the input file will be backup into a ; another file with a ".bac" extension added to the end of the file ; name. ;------------------------------------------------------------------------ Backup_File = yes ; Boolean bcpp-20210108/txtdocs/0000755000175100001440000000000011221744705013107 5ustar tomusersbcpp-20210108/txtdocs/hirachy.txt0000644000175100001440000000570605672503204015307 0ustar tomusers Object Hierarchy Diagram Any Object ----+---- QueueList (generic queue object) | | +---- StackList (generic stack object) | | +---- InputStruct | | +---- OutputStruct | | +---- IndentStruct Notes of class usage: IndentStruct: Even though IndentStruct is defined as a class, it is basically a record structure. I have defined it as a class to help storage of the record data easier, and to automate some of the initialisation process. However, there are no methods (apart from the constructor), that handles any of the object's data. All data is altered directly within the class (i.e don't use methods to change data). InputStruct: This is basically like the IndentStruct, except it has no defined constructor. The class is used the same was as a normal structure. A destructor isn't implemented as existing data may belong to two, or more other objects. OutputStruct: This has more OO implementation than the previous two objects (i.e constructor, destructor), but data is accessed the same as any structure. Entity RelationShip Diagram +-----------+ +-------------+ | | have /| | | QueueList |--------------| InputStruct | | | \| | +-----------+ +-------------+ | | | +--------------+ | have /| | +--------------------| OutputStruct | \| | +--------------+ +-----------+ +--------------+ | | have /| | | StackList |--------------| IndentStruct | | | \| | +-----------+ +--------------+ bcpp-20210108/txtdocs/bcpp.10000644000175100001440000003572111221744705014125 0ustar tomusers.\" $Id: bcpp.1,v 1.2 2009/06/28 19:51:33 tom Exp $ .TH "C++ Beautifier" .SH NAME \fBbcpp\fP \- make C++ beautifier .SH OVERVIEW This program enables a user to reformat certain elements of a C, or C++ source code. This helps if one person's code is a little unreadable, or has been indented to a style that you dislike. Using this program will hopefully help in re-styling the code so that it closely meets your style. However, due to the many styles of C(++) that can be coded, there are limits to how well this program will handle the source code, and resulting re-formatted source. .PP The following are a list of features implemented: .RS 5 .TP 3 - Reposition comments at certain locations. .TP - Remove non-printable characters not contained within quotes. .TP - Convert non-printable characters within quotes to octal/character notation. .TP - Re-space line spacing between functions. .TP - Trim trailing spaces from all lines, as well as leading and trailing blank lines from the file. .TP - Reposition opening braces to Kernighan/Ritchie style, or to Pascal style. .TP - Use of tabs, or spaces in indenting. .TP - Indention of single line code, according to certain C condition statements, including embedded SQL statements. .RE .SH Requirements This program will run under Microsoft DOS V3.3 and Unix platforms. .PP It uses approximately 50 - 70k (or more, dependant upon internal queue size) of memory during execution. .PP The program code has been written in such a way as to be compatible with existing C++ compilers, however the code is not ANSI standard and may require modification for your environment. The source code has been written with standard ANSI and Posix functions so that least amount of rewriting should be needed if recompiling on another computer platform. .PP The current sources have been compiled using Turbo C++ V3.0, for MS-DOS, GNU G++ 2.7.2 under Sun SPARCstation running SunOS, Solaris as well as SGI workstations running IRIX. .SH OPERATION Operation of the program is via the command line (CLI), and with help from a configuration file you can define your format requirements. Basically each command directive starts with a dash "\-" followed my the command name. If another parameter is need for the command, the parameter is added after the command, and separated with a space (i.e. bcpp -fi input.cpp). .PP N.B: Do not enter bcpp.exe on its own to find its command help, use bcpp -?, or bcpp -h. This is due to the input redirection from the O/S. Keeping to Unix CLI convention, a string that is read from the CLI and does not have a command directive is considered a input file. If there are two such occurrences on the command line, the precedence will be input file first, and output file second (i.e., bcpp infile.cpp outfile.cpp -lg), a third such occurrence will generate a error message. .PP If no output file is presented, its assumed output is via the standard output. This automatically turns off program output. Parameters entered on the command line will override parameters that have been read from the configuration file. .PP Example: .nf bcpp -fi input.cpp -f 2 -qb 5 -na -no -cc 60 > output.cpp .fi .PP Synopsis .PP -fi input.cpp Input file = input.cpp -f 2 Function spacing = 2 -qb 2 Internal Queue Buffer = 5 -na Remove non-ascii chars -no Suppress program output -cc 60 Comments that appear on same line as code will be placed in column 60. > output.cpp Output of program is redirected to "output.cpp" .PP A configuration file can be used to specify most of the non- changing elements in reformatting of code. The configuration file consists of some fairly lengthy words that are used to explain the output style of the code. However setting these parameters is very easy, they basically consist of two types, Boolean, or Integer types. Using your favorite text editor, you can change the following within the configuration file ... .PP The following parameters will be contained within the configuration file (default is bcpp.cfg). The program will attempt to read the default configuration file at the program source (i.e. which path bcpp was run). Using the -fnc option you can define a custom configuration file name, and path from the CLI. .PP Integer Type Ranges : 0 - 5000 Boolean Type Ranges : On, Yes, or Off, No .RS 5 .TP 5 Function_Spacing : Integer This parameter specifies how many lines separate two functions. e.g., function_spacing = 2 CLI -f 2 .TP Use_Tabs: Boolean Specifies whether to use tabs in indenting code. e.g., use_tabs = no CLI -t (Turn tabs on, default uses spaces) -s (Use tabs for indenting) .TP Indent_Spacing : Integer Specifies how many spaces to indent. This parameter also sets the width of tabs. Bcpp considers the width of a tab to be the same as the width of an indent. E.G. indent_spacing = 4 CLI -i 4 .TP Comments_With_Code : Integer Defines the column in which comments that appear after code on a line will be placed. e.g., comments_with_code = 50 CLI -cc 50 .TP Comments_With_Nocode : Integer Defines the column in which comments that appear in a line will be placed. e.g., comments_with_nocode = 0 CLI -nc 0 .TP Indent_Preprocessor: Boolean If true, bcpp will indent preprocessor lines to the indention of the C(++) code. If false, preprocessor lines will be in the first column. Unrecognized (i.e., nonstandard) preprocessor lines are always put into the first column. .TP Indent_Exec_Sql: Boolean If true, bcpp looks for embedded SQL statements (e.g., EXEC SQL), and formats them specially. .TP Keep_Comments_With_Code : Boolean This option overrides the "Comments_With_Code" option. Setting this option On will make comments which do not fit as inline comments append to the code anyway. .TP Leave_Comments_NoCode : Boolean This option overrides the "Comments_With_Nocode" option. Setting this option On will indent comments that do not occur on the same line as code to the same indention as code. e.g., leave_comments_nocode = on CLI -nlcnc (Turn off Leave_Comments_NoCode) -ylcnc (Turn on Leave_Comments_NoCode) .TP NonAscii_Quotes_To_Octal : Boolean Use this option to change non-ASCII (non-printable) chars to octal notation if they lie within quotes. This parameter does not take effect unless either the Ascii_Chars_Only or Leave_Graphic_Chars parameters have been set. e.g., NonAscii_Quotes_to_Octal = no CLI -nq (Turn off non-ascii chars in quotes to octal) -yq (Turn on non-ascii chars in quotes to octal) .TP Leave_Graphic_Chars : Boolean Setting this parameter to yes will strip non-printable characters from the source file, but leave any characters that are IBM graphics alone. Any non-printable characters that lie within quotes will be transformed into octal/character notation, if NonAscii_Quotes_To_Octal parameter is set to True. E.G. leave_graphic_chars = yes CLI -lg .TP Ascii_Chars_Only : Boolean Setting this parameter to yes will strip any non-printable, non-ASCII characters from the input file. Any non-printable characters that lie within quotes will be transformed into octal/character notation if NonAscii_Quotes_To_Octal is set to True. Comment out this parameter if you are using Leave_Graphic_Chars parameter, as this parameter will override it. e.g., ascii_chars_only = yes CLI -na (Do not remove non-ASCII characters) -ya (Yes remove non-ASCII characters) .TP Place_Brace_On_New_Line : Boolean When set to 'on' bcpp will place opening braces on new lines ("Pascal" style C coding), when set to 'off' bcpp will use "K&R" style C coding. Pascal style C coding: if (condition) { statements; } K&R style C coding: if (condition) { statements; } e.g., place_brace_on_new_line = on CLI -bnl (on ) -bcl (off) .TP Program_Output : Boolean This parameter will stop output from the program corrupting output that may exit from the program via the standard output. If this parameter is set to off/no then no output is generated from the program, unless an error is encountered. The standard error is used to display any errors encountered while processing. E.G program_output = off CLI -no (default is generate output if possible, this will force output off) -yo (turn on program output if possible) .TP Queue_Buffer : Integer Specifies what the internal memory requires will be in size of the line processing buffer. This is used for open brace relocation in Kernighan/Ritchie style. Extending this buffer to large amounts of memory will slow processing on small machines. e.g., Queue_Buffer = 2 CLI -qb 2 .TP ; : Not Applicable Placing a semicolon in front of text makes everything after the semicolon a comment. .TP Backup_File : Boolean This option will backup the input file to a file with the extension ".bac" and overwrite the input file with the reformatted version. e.g., backup_file = yes CLI -yb (yes, backup input file if possible) -nb (no, do not backup input file) .RE .SH Loading Configuration File : CLI only Bcpp implements a configuration setting to allow custom file selection from a specific path/file defined by a user. e.g., bcpp input.cpp -yb (read bcpp.cfg configuration file before processing CLI options) bcpp -fnc /bin/bcpp.cfg (load configuration file at said location) CLI -fnc (use user defined) .TP Input File Name : CLI only This option directs bcpp to read data at a given path, and file name. E.G bcpp -fi input.cpp > output.cpp CLI -fi .TP Output File Name : CLI only This defines the output file name that data is to be written to. e.g., Has to be like this, (in DOS, at least): bcpp -fo output.cpp < input.cpp ClI -fo .TP Online Help : CLI only Some online help which is brief but to the point exists within the program. The help lists all of the CLI commands available within the program. E.G bcpp -h CLI bcpp -? bcpp -h .SH Configuration File Error Messages If you enter a command/parameter incorrectly within the configuration file, upon the executable program reading it, the program will generate a error message along with its line number. The following is an explanation of error messages that may occur while reading parameters within the configuration file. .RS 5 .TP 3 Syntax Error After Key Word : Error occurs because the character/word after a parameter was incorrect, or expected another keyword (e.g =, Yes, No, On, Off) .TP Range Error : Error occurs when integer parameters have a invalid numeric setting (i.e., A number is not within 0 - 5000). .TP Expected Numeric Data : This error occurs when alpha-numeric data is in place of numeric data for integer type parameters. .TP Cannot Decipher : The parameter at said line is not valid (i.e., not recognizable). .RE .PP If any errors have occurred after reading the configuration file; the user is prompted with a [y/n] continuation prompt to either fix the configuration error(s) before processing, or continue with current set parameters. .SH Run Time Errors During Input File Processing .RS 5 .TP 3 Memory Allocation Failed : The program was unable to allocate memory to process data. This error will stop processing of data. .TP Error In Line Construction .TP Expected Some Sort Of Code ! Data Type = ? : This error is generated within the line construction process. The decoded line from the input file may be too indecipherable for this program. Find the line in the input file, and see if it can be altered so that processing can continue. .RE .SH C(++) Beautifier Limitations This section highlights certain areas within code where bcpp will fail to reconstruct the output code to the desired style (although it may still be able to compile). .RS 5 .TP 3 - All code that is fed through this program should be in a compilable state. This means that there should be closing braces that cancel out opening braces. Bcpp does no syntax checking at all upon the code, but reformats it according to open, closing braces, and a handful of key words for single line indentation. .TP - There is also a limitation on how far the movement of open braces can be processed. This is due to the current design of the program (this can fixed easily by extending the internal queue buffer size), memory requirements, processing speed. Dynamic memory allocation is used extensively throughout the program, and may exceed current limits if certain conditions arise. The example shows that the movements of the brace from the new line to the above code line will not take place as it would be out of scope for the program if the internal queue buffer is limited to 2 lines in size. Example of brace movement scope: if (a == b) // Brace will not be re-positioned { b = c; } if (a == b) // Brace will be re-positioned { b = c; } End Result if (a == b) // Brace will not be re-positioned { b = c; } if (a == b){ // Brace will be re-positioned b = c; } .TP - There is a constraint that a single line of code should only have one type of comment. If there are both C, and C++ existing on the same line then the line construction phase of the program will become confused, and generate a error message. The following line will produce a Line Construction Error message. Example of multiple comments. /* C Comment */ a = b; // C++ Comment The above line will generate an error. Remedy this by removing one type of comment, combine them, or place one on a new line. .RE .SH AUTHORS Written By Steven De Toni December 1995 .br Updated by Thomas Dickey January 1997-2002 .PP You can contact Steven De Toni via various online networks: Internet Address tge@midland.co.nz steve@alpha.ocbbs.gen.nz Net Mail Via Fido-Net (Dog Net) Steven De Toni, "The Great Escape", Hamilton, New Zealand Demi-Monde New Zealand National Mail Net Work (see Dog Net) .PP If all else fails, send snail mail to: .PP 17 Garden Heights Ave, Melville, Hamilton, New Zealand .PP Thomas Dickey can be reached at dickey@invisible-island.net .PP Special thanks goes out to Glyn Webster for proof reading my manual, and testing my program. .PP Thanks to Justin Slootsky for his input, and changes for this version. .PP All \fBgrammatical\fR errors within this document are there for your enjoyment. ;-) .SH DISCLAIMER The authors give no guarantees that this program will function to the specifications given via the configuration, or the program's reconstructed output of source code that have been processed. Any damage that might arise from the use of this program (be it software, or hardware) is the problem of user, and not the authors. Using this software binds you to this disclaimer.bcpp-20210108/txtdocs/manual.txt0000644000175100001440000003742707471511734015150 0ustar tomusers C(++) Beautifier V1.9 Written By Steven De Toni December 1995 Updated by Thomas Dickey January 1997 Contents Page 1 Introduction 2 Disclaimer 3 Requirements 4 How To Use The Program 11 Configuration File Error Messages 12 Run Time Errors During Input File Processing 13 C(++) Beautifier Limitations 15 Contact Addresses Page >1< Introduction This program enables a user to reformat certain elements of a C, or C++ source code. This helps if one person's code is a little unreadable, or has been indented to a style that you dislike. Using this program will hopefully help in re-styling the code so that it closely meets your style. However, due to the many styles of C(++) that can be coded, there are limits to how well this program will handle the source code, and resulting re-formatted source. The following are a list of features implemented: - Reposition comments at certain locations. - Remove non-printable characters not contained within quotes. - Convert non-printable characters within quotes to octal/character notation. - Re-space line spacing between functions. - Trim trailing spaces from all lines, as well as leading and trailing blank lines from the file. - Reposition opening braces to Kernighan/Ritchie style, or to Pascal style. - Use of tabs, or spaces in indenting. - Indention of single line code, according to certain C condition statements, including embedded SQL statements. Page >2< Disclaimer The authors give no guarantees that this program will function to the specifications given via the configuration, or the program's reconstructed output of source code that have been processed. Any damage that might arise from the use of this program (be it software, or hardware) is the problem of user, and not the authors. Using this software binds you to this disclaimer. Page >3< Requirements This program will run under Microsoft DOS V3.3 and Unix platforms. It uses approximately 50 - 70k (or more, dependant upon internal queue size) of memory during execution. The program code has been written in such a way as to be compatible with existing C++ compilers, however the code is not ANSI standard and may require modification for your environment. The source code has been written with standard ANSI and Posix functions so that least amount of rewriting should be needed if recompiling on another computer platform. The current sources have been compiled using Turbo C++ V3.0, for MS-DOS, GNU G++ 2.7.2 under Sun SPARCstation running SunOS, Solaris as well as SGI workstations running IRIX. Page >4< How To Use The Program Operation of the program is via the command line (CLI), and with help from a configuration file you can define your format requirements. Basically each command directive starts with a dash '-' followed my the command name. If another parameter is need for the command, the parameter is added after the command, and separated with a space (i.e. bcpp -fi input.cpp). N.B: Don't enter bcpp.exe on its own to find its command help, use bcpp -?, or bcpp -h. This is due to the input redirection from the O/S. Keeping to Unix CLI convention, a string that is read from the CLI and does not have a command directive is considered a input file. If there are two such occurrences on the command line, the precedence will be input file first, and output file second (i.e., bcpp infile.cpp outfile.cpp -lg), a third such occurrence will generate a error message. If no output file is presented, its assumed output is via the standard output. This automatically turns off program output. Parameters entered on the command line will override parameters that have been read from the configuration file. Example: bcpp -fi input.cpp -f 2 -qb 5 -na -no -cc 60 > output.cpp Synopsis -fi input.cpp Input file = input.cpp -f 2 Function spacing = 2 -qb 2 Internal Queue Buffer = 5 -na Remove non-ascii chars -no Suppress program output -cc 60 Comments that appear on same line as code will be placed in column 60. > output.cpp Output of program is redirected to "output.cpp" Page >5< A configuration file can be used to specify most of the non- changing elements in reformatting of code. The configuration file consists of some fairly lengthy words that are used to explain the output style of the code. However setting these parameters is very easy, they basically consist of two types, Boolean, or Integer types. Using your favorite text editor, you can change the following within the configuration file ... The following parameters will be contained within the configuration file (default is bcpp.cfg). The program will attempt to read the default configuration file at the program source (i.e. which path bcpp was run). Using the -fnc option you can define a custom configuration file name, and path from the CLI. Integer Type Ranges : 0 - 5000 Boolean Type Ranges : On, Yes, or Off, No Function_Spacing : Integer This parameter specifies how many lines separate two functions. e.g., function_spacing = 2 CLI -f 2 Use_Tabs: Boolean Specifies whether to use tabs in indenting code. e.g., use_tabs = no CLI -t (This will turn tabs on, default uses spaces) -s (Use tabs for indenting) Indent_Spacing : Integer Specifies how many spaces to indent. This parameter also sets the width of tabs. Bcpp considers the width of a tab to be the same as the width of an indent. E.G. indent_spacing = 4 CLI -i 4 Page >6< Comments_With_Code : Integer Defines the column in which comments that appear after code on a line will be placed. e.g., comments_with_code = 50 CLI -cc 50 Comments_With_Nocode : Integer Defines the column in which comments that appear in a line will be placed. e.g., comments_with_nocode = 0 CLI -nc 0 Indent_Preprocessor: Boolean If true, bcpp will indent preprocessor lines to the indention of the C(++) code. If false, preprocessor lines will be in the first column. Unrecognized (i.e., nonstandard) preprocessor lines are always put into the first column. Indent_Exec_Sql: Boolean If true, bcpp looks for embedded SQL statements (e.g., EXEC SQL), and formats them specially. Leave_Comments_NoCode : Boolean This options overrides the "Comments_With_Nocode" option. Setting this option On will indent comments that do not occur on the same line as code to the same indention as code. e.g., leave_comments_nocode = on CLI -nlcnc (Turn off Leave_Comments_NoCode) -ylcnc (Turn on Leave_Comments_NoCode) Page >7< NonAscii_Quotes_To_Octal : Boolean Use this option to change non-ASCII (non-printable) chars to octal notation if they lie within quotes. This parameter doesn't take effect unless either the Ascii_Chars_Only or Leave_Graphic_Chars parameters have been set. e.g., NonAscii_Quotes_to_Octal = no CLI -nq (Turn off non-ascii chars in quotes to octal) -yq (Turn on non-ascii chars in quotes to octal) Leave_Graphic_Chars : Boolean Setting this parameter to yes will strip non-printable characters from the source file, but leave any characters that are IBM graphics alone. Any non-printable characters that lie within quotes will be transformed into octal/character notation, if NonAscii_Quotes_To_Octal parameter is set to True. E.G. leave_graphic_chars = yes CLI -lg Ascii_Chars_Only : Boolean Setting this parameter to yes will strip any non-printable, non-ASCII characters from the input file. Any non-printable characters that lie within quotes will be transformed into octal/character notation if NonAscii_Quotes_To_Octal is set to True. Comment out this parameter if you are using Leave_Graphic_Chars parameter, as this parameter will override it. e.g., ascii_chars_only = yes CLI -na (Don't remove non-ASCII characters) -ya (Yes remove non-ASCII characters) Page >8< Place_Brace_On_New_Line : Boolean When set to 'on' bcpp will place opening braces on new lines ("Pascal" style C coding), when set to 'off' bcpp will use "K&R" style C coding. Pascal style C coding: if (condition) { statements; } K&R style C coding: if (condition) { statements; } e.g., place_brace_on_new_line = on CLI -bnl (on ) -bcl (off) Program_Output : Boolean This parameter will stop output from the program corrupting output that may exit from the program via the standard output. If this parameter is set to off/no then no output is generated from the program, unless an error is encountered. The standard error is used to display any errors encountered while processing. E.G program_output = off CLI -no (default is generate output if possible, this will force output off) -yo (turn on program output if possible) Page >9< Queue_Buffer : Integer Specifies what the internal memory requires will be in size of the line processing buffer. This is used for open brace relocation in Kernighan/Ritchie style. Extending this buffer to large amounts of memory will slow processing on small machines. e.g., Queue_Buffer = 2 CLI -qb 2 ; : Not Applicable Placing a semicolon in front of text makes everything after the semicolon a comment. Backup_File : Boolean This option will backup the input file to a file with the extension ".bac" and overwrite the input file with the reformatted version. e.g., backup_file = yes CLI -yb (yes, backup input file if possible) -nb (no, don't backup input file) Page >10< Loading Configuration File : CLI only Bcpp implements a configuration setting to allow custom file selection from a specific path/file defined by a user. e.g., bcpp input.cpp -yb (read bcpp.cfg configuration file before processing CLI options) bcpp -fnc /bin/bcpp.cfg (load configuration file at said location) CLI -fnc (use user defined) Input File Name : CLI only This option directs bcpp to read data at a given path, and file name. E.G bcpp -fi input.cpp > output.cpp CLI -fi Output File Name : CLI only This defines the output file name that data is to be written to. e.g., Has to be like this, (in DOS, at least): bcpp -fo output.cpp < input.cpp ClI -fo Online Help : CLI only Some online help which is brief but to the point exists within the program. The help lists all of the CLI commands available within the program. E.G bcpp -h CLI bcpp -? bcpp -h Page >11< Configuration File Error Messages If you enter a command/parameter incorrectly within the configuration file, upon the executable program reading it, the program will generate a error message along with its line number. The following is an explanation of error messages that may occur while reading parameters within the configuration file. - Syntax Error After Key Word : Error occurs because the character/word after a parameter was incorrect, or expected another keyword (e.g =, Yes, No, On, Off) - Range Error : Error occurs when integer parameters have a invalid numeric setting (i.e., A number is not within 0 - 5000). - Expected Numeric Data : This error occurs when alpha-numeric data is in place of numeric data for integer type parameters. - Can't Decipher : The parameter at said line is not valid (i.e., not recognizable). If any errors have occurred after reading the configuration file; the user is prompted with a [y/n] continuation prompt to either fix the configuration error(s) before processing, or continue with current set parameters. Page >12< Run Time Errors During Input File Processing - Memory Allocation Failed : The program was unable to allocate memory to process data. This error will stop processing of data. - Error In Line Construction - Expected Some Sort Of Code ! Data Type = ? : This error is generated within the line construction process. The decoded line from the input file may be too indecipherable for this program. Find the line in the input file, and see if it can be altered so that processing can continue. Page >13< C(++) Beautifier Limitations This section highlights certain areas within code where bcpp will fail to reconstruct the output code to the desired style (although it may still be able to compile). - All code that is fed through this program should be in a compilable state. This means that there should be closing braces that cancel out opening braces. Bcpp does no syntax checking at all upon the code, but reformats it according to open, closing braces, and a handful of key words for single line indentation. - There is also a limitation on how far the movement of open braces can be processed. This is due to the current design of the program (this can fixed easily by extending the internal queue buffer size), memory requirements, processing speed. Dynamic memory allocation is used extensively throughout the program, and may exceed current limits if certain conditions arise. The example shows that the movements of the brace from the new line to the above code line will not take place as it would be out of scope for the program if the internal queue buffer is limited to 2 lines in size. Page >13< Example of brace movement scope: if (a == b) // Brace will not be re-positioned { b = c; } if (a == b) // Brace will be re-positioned { b = c; } End Result if (a == b) // Brace will not be re-positioned { b = c; } if (a == b){ // Brace will be re-positioned b = c; } - There is a constraint that a single line of code should only have one type of comment. If there are both C, and C++ existing on the same line then the line construction phase of the program will become confused, and generate a error message. The following line will produce a Line Construction Error message. Example of multiple comments. /* C Comment */ a = b; // C++ Comment The above line will generate an error. Remedy this by removing one type of comment, combine them, or place one on a new line. Page >15< Contact Addresses You can contact me via various online networks: Internet Address tge@midland.co.nz steve@alpha.ocbbs.gen.nz Net Mail Via Fido-Net (Dog Net) Steven De Toni, "The Great Escape", Hamilton, New Zealand Demi-Monde New Zealand National Mail Net Work (see Dog Net) All else fails, send me snail mail at: 17 Garden Heights Ave, Melville, Hamilton, New Zealand Thomas Dickey can be reached at dickey@invisible-island.net Special thanks goes out to Glyn Webster for proof reading my manual, and testing my program. Thanks to Justin Slootsky for his input, and changes for this version. All _grammatical_ errors within this document are there for your enjoyment. ;-)bcpp-20210108/aclocal.m40000644000175100001440000003245113776152030013265 0ustar tomusersdnl $Id: aclocal.m4,v 1.19 2021/01/08 21:52:24 tom Exp $ dnl --------------------------------------------------------------------------- dnl Copyright 2002-2020,2021 -- Thomas E. Dickey dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the dnl "Software"), to deal in the Software without restriction, including dnl without limitation the rights to use, copy, modify, merge, publish, dnl distribute, distribute with modifications, sublicense, and/or sell dnl copies of the Software, and to permit persons to whom the Software is dnl furnished to do so, subject to the following conditions: dnl dnl The above copyright notice and this permission notice shall be included dnl in all copies or portions of the Software. dnl dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. dnl dnl Except as contained in this notice, the name(s) of the above copyright dnl holders shall not be used in advertising or otherwise to promote the dnl sale, use or other dealings in this Software without prior written dnl authorization. dnl dnl see dnl https://invisible-island.net/autoconf/ dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55 dnl -------------- dnl use this macro for appending text without introducing an extra blank at dnl the beginning define([CF_APPEND_TEXT], [ test -n "[$]$1" && $1="[$]$1 " $1="[$]{$1}$2" ])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31 dnl -------------- dnl Allow user to disable a normally-on option. AC_DEFUN([CF_ARG_DISABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14 dnl ------------- dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus dnl values. dnl dnl Parameters: dnl $1 = option name dnl $2 = help-string dnl $3 = action to perform if option is not default dnl $4 = action if perform if option is default dnl $5 = default option value (either 'yes' or 'no') AC_DEFUN([CF_ARG_OPTION], [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes) if test "$enableval" != "$5" ; then ifelse([$3],,[ :]dnl ,[ $3]) ifelse([$4],,,[ else $4]) fi],[enableval=$5 ifelse([$4],,,[ $4 ])dnl ])])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15 dnl -------------- dnl Check if we're accidentally using a cache from a different machine. dnl Derive the system name, as a check for reusing the autoconf cache. dnl dnl If we've packaged config.guess and config.sub, run that (since it does a dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM dnl which is useful in cross-compiles. dnl dnl Note: we would use $ac_config_sub, but that is one of the places where dnl autoconf 2.5x broke compatibility with autoconf 2.13 AC_DEFUN([CF_CHECK_CACHE], [ if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then ifelse([$1],,[AC_CANONICAL_HOST],[$1]) system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.]) AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name) if test ".$system_name" != ".$cf_cv_system_name" ; then AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) AC_MSG_ERROR("Please remove config.cache and try again.") fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04 dnl ----------------- dnl Check if the given compiler is really clang. clang's C driver defines dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does dnl not ignore some gcc options. dnl dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from dnl the wrappers for gcc and g++ warnings. dnl dnl $1 = GCC (default) or GXX dnl $2 = CLANG_COMPILER (default) dnl $3 = CFLAGS (default) or CXXFLAGS AC_DEFUN([CF_CLANG_COMPILER],[ ifelse([$2],,CLANG_COMPILER,[$2])=no if test "$ifelse([$1],,[$1],GCC)" = yes ; then AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler) cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" AC_TRY_COMPILE([],[ #ifdef __clang__ #else make an error #endif ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes ],[]) ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2])) fi CLANG_VERSION=none if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then case "$CC" in (c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]]) AC_MSG_WARN(replacing broken compiler alias $CC) CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" CC=clang ;; esac AC_MSG_CHECKING(version of $CC) CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" test -z "$CLANG_VERSION" && CLANG_VERSION=unknown AC_MSG_RESULT($CLANG_VERSION) for cf_clang_opt in \ -Qunused-arguments \ -Wno-error=implicit-function-declaration do AC_MSG_CHECKING(if option $cf_clang_opt works) cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cf_clang_opt" AC_TRY_LINK([ #include ],[ printf("hello!\\n");],[ cf_clang_optok=yes],[ cf_clang_optok=no]) AC_MSG_RESULT($cf_clang_optok) CFLAGS="$cf_save_CFLAGS" if test "$cf_clang_optok" = yes; then CF_VERBOSE(adding option $cf_clang_opt) CF_APPEND_TEXT(CFLAGS,$cf_clang_opt) fi done fi ]) dnl --------------------------------------------------------------------------- dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57 dnl --------------- dnl You can always use "make -n" to see the actual options, but it's hard to dnl pick out/analyze warning messages when the compile-line is long. dnl dnl Sets: dnl ECHO_LT - symbol to control if libtool is verbose dnl ECHO_LD - symbol to prefix "cc -o" lines dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) dnl SHOW_CC - symbol to put before explicit "cc -c" lines dnl ECHO_CC - symbol to put before any "cc" line dnl AC_DEFUN([CF_DISABLE_ECHO],[ AC_MSG_CHECKING(if you want to see long compiling messages) CF_ARG_DISABLE(echo, [ --disable-echo do not display "compiling" commands], [ ECHO_LT='--silent' ECHO_LD='@echo linking [$]@;' RULE_CC='@echo compiling [$]<' SHOW_CC='@echo compiling [$]@' ECHO_CC='@' ],[ ECHO_LT='' ECHO_LD='' RULE_CC='' SHOW_CC='' ECHO_CC='' ]) AC_MSG_RESULT($enableval) AC_SUBST(ECHO_LT) AC_SUBST(ECHO_LD) AC_SUBST(RULE_CC) AC_SUBST(SHOW_CC) AC_SUBST(ECHO_CC) ])dnl dnl --------------------------------------------------------------------------- dnl CF_GXX_VERSION version: 8 updated: 2017/02/11 14:48:57 dnl -------------- dnl Check for version of g++ AC_DEFUN([CF_GXX_VERSION],[ AC_REQUIRE([AC_PROG_CPP]) GXX_VERSION=none if test "$GXX" = yes; then AC_MSG_CHECKING(version of ${CXX:-g++}) GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" if test -z "$GXX_VERSION" then GXX_VERSION=unknown GXX=no fi AC_MSG_RESULT($GXX_VERSION) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_GXX_WARNINGS version: 11 updated: 2021/01/08 16:50:55 dnl --------------- dnl Check if the compiler supports useful warning options. dnl dnl Most of gcc's options apply to g++, except: dnl -Wbad-function-cast dnl -Wmissing-declarations dnl -Wnested-externs dnl dnl Omit a few (for now): dnl -Winline dnl dnl Parameter: dnl $1 is an optional list of g++ warning flags that a particular dnl application might want to use, e.g., "no-unused" for dnl -Wno-unused dnl Special: dnl If $with_ext_const is "yes", add a check for -Wwrite-strings dnl AC_DEFUN([CF_GXX_WARNINGS], [ CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS) CF_CLANG_COMPILER(GXX,CLANG_CPLUSPLUS,CXXFLAGS) AC_REQUIRE([CF_GXX_VERSION]) AC_LANG_SAVE AC_LANG_CPLUSPLUS cat > conftest.$ac_ext <&AC_FD_CC ])dnl dnl --------------------------------------------------------------------------- dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12 dnl ---------- dnl Use AC_VERBOSE w/o the warnings AC_DEFUN([CF_VERBOSE], [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG CF_MSG_LOG([$1]) ])dnl bcpp-20210108/install-sh0000755000175100001440000001572307762207755013451 0ustar tomusers#! /bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd=$cpprog shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "$0: no input file specified" >&2 exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d "$dst" ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "$0: $src does not exist" >&2 exit 1 fi if [ x"$dst" = x ] then echo "$0: no destination specified" >&2 exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d "$dst" ] then dst=$dst/`basename "$src"` else : fi fi ## this sed command emulates the dirname command dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` IFS=$oIFS pathcomp='' while [ $# -ne 0 ] ; do pathcomp=$pathcomp$1 shift if [ ! -d "$pathcomp" ] ; then $mkdirprog "$pathcomp" else : fi pathcomp=$pathcomp/ done fi if [ x"$dir_arg" != x ] then $doit $instcmd "$dst" && if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename "$dst"` else dstfile=`basename "$dst" $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename "$dst"` else : fi # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/#inst.$$# rmtmp=$dstdir/#rm.$$# # Trap to clean up temp files at exit. trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 # Move or copy the file name to the temp name $doit $instcmd "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && # Now remove or move aside any old file at destination location. We try this # two ways since rm can't unlink itself on some systems and the destination # file might be busy for other reasons. In this case, the final cleanup # might fail but the new file should still install successfully. { if [ -f "$dstdir/$dstfile" ] then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" fi && # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit } bcpp-20210108/README0000644000175100001440000001300107567703741012307 0ustar tomusers-- $Id: README,v 1.2 2002/11/23 13:51:29 tom Exp $ -- This is the original README - see CHANGES for a current history -TD ------------------------------------------------------------------------------- History ------- Version 0.9 ----------- Heaps of bugs, should never been released. Version 1.0 ----------- Heaps of bug fixes, have tested the program heaps, and tried to extract 98% of the errors, any bugs found while using this program are to be considered as undocumented features. Future Versions will include most of the limitations of version 1 fixed. I haven't fixed these yet as I'd rather have a program that works happily instead of one that is giving me eternal hassles (plus project dead lines). The next updated version will be released within early December. Version 1.5 ----------- - Couple more bug fixes, and some code optimisation. - Unlimited (ram limited) amount of line decoding so even the most tangled code can be decoded (uses recursion). - Unlimited amount of single code indenting is provided (fixed from last version (uses recursion)) - Options for program can entered via command line, or configuration file. - Operating system I/O redirection is fully support within the program. - User definable line buffer size. I have tried to test this program rigorously to see that I have no rouge pointers lying within ... (fingers crossed). Anyways it ran fine under Qemm, and Windows (i.e. no exception errors due to incorrect memory access). Using Qemm V7.0, the program uses DPMI memory allocation so you the program allocate memory exceeding 640 k in MS-DOS memory model. This is done by processing large files (i.e. 1 meg+), and using a very large buffer (i.e. 10000). Large buffers above 10 are not really require and will slow processing because of extensive searching (plus my Queue object isn't the fastest of designs ever). Version 1.55 ------------ - The only real update is working the code so that it functions/compiles under Unix. - Removed all segmentation violations. - Fixed a couple of little things ... I forget. - Input redirection under DOS fails, but works under Unix. Version 1.6 (Final) ------------------- This will be the final release from me of this software. This version fixes a few more bugs, some small, some large, but I think this time the program is about as stable as I'm going to get it. The code will still be able to compile under both Unix, and MS-DOS. - Added a backup file feature. - Added a time feature just for the hell of it. - Fixed a decoding problem with quotes - Fixed a decoding/construction problem with tabs. The current method will expand all tabs to spaces that are ready via the input data stream. Version 1.61 (User Update) -------------------------- A Canadian programmer (Justin Slootsky) introduced a new feature into this program that allows code that has no accompanied code to be indented as per normal code. Although just a few lines of code, this new feature is very effective. Version 1.629 (Bug Update) --------------------------- Fixed a couple of minor bugs that would cause a little havock. Added preprocessor handling, so that any preprocessor commands are always place at position 1; Version 1.7 (Bug Update) ------------------------ Fixed C comment process bugs. fixed locating configuration file (i.e uses argv[0] now) unless -fnc switch is used. Version 1.75 (Bug Update) ------------------------- Fixed single statement formating over multiple lines (i.e. if, while type statements) Fixed a couple of simple errors that Manuel T. Petit pointed out in my code. Version 1.8 (Bug Of A Bug Update) ---------------------------------- This bug was created becuase of Unix's perdantic checking of memory (i.e. MNU). I haven't checked all the conditions of a certain section of code, this caused an 'if' statement within case structure to prematurely be trashed. The result of which is the indent structure is removed and the code output doesn't align correctly. Util ---- Text Conversion: I've provided a program than when compiled will convert MS-DOS text input UNIX text using standard output, or Unix text to MS-DOS text (OS dependant). Use this program to convert my source so that it can be compiled without worries of carriage returns. Compiling --------- The only OS type system that this program has been fully tested on is MS-DOS, so I give no guarantees that this program will function under any other OS other then DOS. It's up to you to fix any possible conflicts between compilers/operating systems. This software is provided on the "As Is Where Is" bases. Compiled using the following compilers ... Borland Turbo C V1.0 Borland Turbo C V3.0 GNU G++ V1.05 (DOS) GNU G++ V2.62 (UNIX) Feed Back --------- Thanks to the few people that sent me mail pointing out my deliberate mistakes :-) within my code/documentation. If people use this program for other projects, I wouldn't mind hearing about it, see DOCs for addresses. Notices ------- Thanks to: Pink Floyd (some of the best music ever written to program to) Black Jack, 8forty8, Knight Shade, Cold Shock ... (Some of the best heavy rock/metal bands in Hamilton/N.Z) GNU (For producing a brilliant compiler) Borland (Brilliant programming environment)