diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile index 84fe2f2f3b8..113e7d693b4 100644 --- a/gnu/usr.bin/Makefile +++ b/gnu/usr.bin/Makefile @@ -2,7 +2,7 @@ .include SUBDIR.${MK_DIALOG}+= dialog -SUBDIR.${MK_GNU_DIFF}+= diff3 +SUBDIR.${MK_GNU_DIFF}+= diff SUBDIR.${MK_TESTS}+= tests SUBDIR_PARALLEL= diff --git a/gnu/usr.bin/binutils/Makefile b/gnu/usr.bin/binutils/Makefile deleted file mode 100644 index 191a8ad3d5c..00000000000 --- a/gnu/usr.bin/binutils/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -.include - -SUBDIR= doc\ - libiberty \ - libbfd \ - libopcodes \ - libbinutils \ - as \ - objdump - -# When we use ld.lld as /usr/bin/ld, do not install the non-ifunc-capable -# GNU binutils 2.17.50 ld. -.if ${MK_LLD_IS_LD} == "no" -SUBDIR+=ld -.endif - -SUBDIR_DEPEND_libbinutils=libbfd # for bfdver.h -SUBDIR_DEPEND_as=libbfd libiberty libopcodes -SUBDIR_DEPEND_ld=libbfd libiberty -SUBDIR_DEPEND_objdump=libbfd libiberty libbinutils libopcodes - -.if !make(install) -SUBDIR_PARALLEL= -.endif - -.include diff --git a/gnu/usr.bin/binutils/Makefile.inc b/gnu/usr.bin/binutils/Makefile.inc deleted file mode 100644 index a2971a4a9f6..00000000000 --- a/gnu/usr.bin/binutils/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/Makefile.inc 298107 2016-04-16 07:45:30Z gjb $ - -WARNS?= 3 -PACKAGE= binutils - -.include "../Makefile.inc" diff --git a/gnu/usr.bin/binutils/Makefile.inc0 b/gnu/usr.bin/binutils/Makefile.inc0 deleted file mode 100644 index c2149202580..00000000000 --- a/gnu/usr.bin/binutils/Makefile.inc0 +++ /dev/null @@ -1,52 +0,0 @@ -# $FreeBSD: stable/10/gnu/usr.bin/binutils/Makefile.inc0 239272 2012-08-15 03:21:56Z gonzo $ -# -# This is included explicitly at the top of each sub-Makefile. We can't -# use the normal "Makefile.inc" mechanism, because we need some of these -# definitions before the sub-Makefile is processed. - -VERSION= "2.17.50 [MidnightBSD] 2007-07-03" - -.if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} -.else -TARGET_CPUARCH=${MACHINE_CPUARCH} -.endif -TARGET_ARCH?= ${MACHINE_ARCH} -TARGET_VENDOR?= midnightbsd -TARGET_OS?= freebsd -BINUTILS_ARCH=${TARGET_ARCH:C/amd64/x86_64/} -TARGET_TUPLE?= ${BINUTILS_ARCH}-${TARGET_VENDOR}-${TARGET_OS} -.if ${TARGET_ARCH:Marm*eb} != "" || \ - (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el*} == "") -TARGET_BIG_ENDIAN=t -.endif - -# GNURELTOP is the relative path to this point in the source or object -# tree, from any subdirectory of same. It gets extra "../" prefixes -# added to it as we descend into subdirectories. -GNURELTOP:= .. - -RELSRC= ${GNURELTOP}/../../../contrib/binutils -SRCDIR= ${.CURDIR}/${RELSRC} - -.if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "i386" || \ - ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "powerpcspe" || \ - (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips64*} == "") -CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=32 -.else -CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=64 -.endif - -CFLAGS+= -I. -CFLAGS+= -I${.CURDIR} -CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbfd -CFLAGS+= -I${.OBJDIR}/${GNURELTOP}/libbfd -CFLAGS+= -I${SRCDIR}/include - -ARCHS= ${TARGET_CPUARCH} - -.if exists(${.CURDIR}/Makefile.${TARGET_ARCH}) -.include "${.CURDIR}/Makefile.${TARGET_ARCH}" -.elif exists(${.CURDIR}/Makefile.${TARGET_CPUARCH}) -.include "${.CURDIR}/Makefile.${TARGET_CPUARCH}" -.endif diff --git a/gnu/usr.bin/binutils/as/Makefile b/gnu/usr.bin/binutils/as/Makefile deleted file mode 100644 index 46446b5f477..00000000000 --- a/gnu/usr.bin/binutils/as/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# $FreeBSD$ - - -# BINDIR -.include "${.CURDIR}/../../Makefile.inc" -.include "${.CURDIR}/../Makefile.inc0" -.include - -.PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config - -.if ${TARGET_ARCH:Marm*} || ${TARGET_ARCH} == "powerpc64" -NO_WERROR.clang= -.endif - -PROG= as -SRCS+= app.c \ - as.c \ - atof-generic.c \ - atof-ieee.c \ - cond.c \ - depend.c \ - dw2gencfi.c \ - dwarf2dbg.c \ - ecoff.c \ - ehopt.c \ - expr.c \ - flonum-copy.c \ - flonum-konst.c \ - flonum-mult.c \ - frags.c \ - hash.c \ - input-file.c \ - input-scrub.c \ - listing.c \ - literal.c \ - macro.c \ - messages.c \ - obj-elf.c \ - output-file.c \ - read.c \ - sb.c \ - stabs.c \ - subsegs.c \ - symbols.c \ - write.c -# DEO: why not used? -#SRCS+= itbl-ops.c - -.if ${TARGET_ARCH:Marmv6*} != "" -CFLAGS+= -DCPU_DEFAULT=ARM_ARCH_V6K -.endif -.if ${TARGET_ARCH:Marmv7*} != "" -CFLAGS+= -DCPU_DEFAULT=ARM_ARCH_V7A -.endif - -.if ${TARGET_CPUARCH} == "mips" -SRCS+= itbl-ops.c itbl-parse.y itbl-lex.l -.if ${TARGET_ARCH:Mmips64*} != "" -CFLAGS+= -DMIPS_DEFAULT_ABI=N64_ABI -DMIPS_DEFAULT_64BIT=1 -.elif ${TARGET_ARCH:Mmipsn32*} != "" -CFLAGS+= -DMIPS_DEFAULT_ABI=N32_ABI -.else -MIPS_ABI_DEFAULT=ABI_32 -.endif -.endif - -.if ${TARGET_ARCH} == "amd64" -SRCS+= tc-i386.c -.elif ${TARGET_CPUARCH} == "powerpc" -SRCS+= tc-ppc.c -.elif ${TARGET_ARCH} == "sparc64" -SRCS+= tc-sparc.c -.else -SRCS+= tc-${TARGET_CPUARCH}.c -.endif - -.if ${TARGET_ARCH} == "sparc64" -CFLAGS+= -DDEFAULT_ARCH=\"v9-64\" -.else -CFLAGS+= -DDEFAULT_ARCH=\"${BINUTILS_ARCH}\" -.endif -.if defined(TARGET_BIG_ENDIAN) -CFLAGS+= -DTARGET_BYTES_BIG_ENDIAN=1 -.endif -CFLAGS+= -DTARGET_CPU=\"${BINUTILS_ARCH}\" -CFLAGS+= -DTARGET_OS=\"${TARGET_OS}\" -CFLAGS+= -DTARGET_CANONICAL=\"${TARGET_TUPLE}\" -CFLAGS+= -DTARGET_ALIAS=\"${TARGET_TUPLE}\" -CFLAGS+= -DVERSION=\"${VERSION}\" -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${SRCDIR}/gas -I${SRCDIR}/bfd -I${SRCDIR}/gas/config -I${SRCDIR} -CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${TARGET_CPUARCH}-freebsd - -.if ${MK_SHARED_TOOLCHAIN} == "no" -NO_SHARED?= yes -.endif - -DPADD= ${GNURELTOP}/libbfd/libbfd${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libiberty/libiberty${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libopcodes/libopcodes${PIE_SUFFIX}.a -LDADD= ${DPADD} - -.include diff --git a/gnu/usr.bin/binutils/as/Makefile.depend b/gnu/usr.bin/binutils/as/Makefile.depend deleted file mode 100644 index 1480a25f260..00000000000 --- a/gnu/usr.bin/binutils/as/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libiberty \ - gnu/usr.bin/binutils/libopcodes \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/as/alpha-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/alpha-freebsd/targ-cpu.h deleted file mode 100644 index 273884893eb..00000000000 --- a/gnu/usr.bin/binutils/as/alpha-freebsd/targ-cpu.h +++ /dev/null @@ -1 +0,0 @@ -#include "tc-alpha.h" diff --git a/gnu/usr.bin/binutils/as/amd64-freebsd/itbl-cpu.h b/gnu/usr.bin/binutils/as/amd64-freebsd/itbl-cpu.h deleted file mode 100644 index a0fe73b3c8d..00000000000 --- a/gnu/usr.bin/binutils/as/amd64-freebsd/itbl-cpu.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $FreeBSD$ */ - -#include "itbl-i386.h" diff --git a/gnu/usr.bin/binutils/as/amd64-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/amd64-freebsd/targ-cpu.h deleted file mode 100644 index 34219a5293f..00000000000 --- a/gnu/usr.bin/binutils/as/amd64-freebsd/targ-cpu.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $FreeBSD$*/ - -#include "tc-i386.h" diff --git a/gnu/usr.bin/binutils/as/arm-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/arm-freebsd/targ-cpu.h deleted file mode 100644 index ac410744deb..00000000000 --- a/gnu/usr.bin/binutils/as/arm-freebsd/targ-cpu.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $FreeBSD$ */ - -#include "tc-arm.h" diff --git a/gnu/usr.bin/binutils/as/as.1 b/gnu/usr.bin/binutils/as/as.1 deleted file mode 100644 index eba331791d3..00000000000 --- a/gnu/usr.bin/binutils/as/as.1 +++ /dev/null @@ -1,1138 +0,0 @@ -.\" $FreeBSD$ -.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "AS 1" -.TH AS 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -AS \- the portable GNU assembler. -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -as [\fB\-a\fR[\fBcdhlns\fR][=\fIfile\fR]] [\fB\-\-alternate\fR] [\fB\-D\fR] - [\fB\-\-defsym\fR \fIsym\fR=\fIval\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-\-gstabs\fR] - [\fB\-\-gstabs+\fR] [\fB\-\-gdwarf\-2\fR] [\fB\-\-help\fR] [\fB\-I\fR \fIdir\fR] [\fB\-J\fR] - [\fB\-K\fR] [\fB\-L\fR] [\fB\-\-listing\-lhs\-width\fR=\fI\s-1NUM\s0\fR] - [\fB\-\-listing\-lhs\-width2\fR=\fI\s-1NUM\s0\fR] [\fB\-\-listing\-rhs\-width\fR=\fI\s-1NUM\s0\fR] - [\fB\-\-listing\-cont\-lines\fR=\fI\s-1NUM\s0\fR] [\fB\-\-keep\-locals\fR] [\fB\-o\fR - \fIobjfile\fR] [\fB\-R\fR] [\fB\-\-reduce\-memory\-overheads\fR] [\fB\-\-statistics\fR] - [\fB\-v\fR] [\fB\-version\fR] [\fB\-\-version\fR] [\fB\-W\fR] [\fB\-\-warn\fR] - [\fB\-\-fatal\-warnings\fR] [\fB\-w\fR] [\fB\-x\fR] [\fB\-Z\fR] [\fB@\fR\fI\s-1FILE\s0\fR] - [\fB\-\-target\-help\fR] [\fItarget-options\fR] - [\fB\-\-\fR|\fIfiles\fR ...] -.PP -\&\fITarget Alpha options:\fR - [\fB\-m\fR\fIcpu\fR] - [\fB\-mdebug\fR | \fB\-no\-mdebug\fR] - [\fB\-relax\fR] [\fB\-g\fR] [\fB\-G\fR\fIsize\fR] - [\fB\-F\fR] [\fB\-32addr\fR] -.PP -\&\fITarget \s-1ARC\s0 options:\fR - [\fB\-marc[5|6|7|8]\fR] - [\fB\-EB\fR|\fB\-EL\fR] -.PP -\&\fITarget \s-1ARM\s0 options:\fR - [\fB\-mcpu\fR=\fIprocessor\fR[+\fIextension\fR...]] - [\fB\-march\fR=\fIarchitecture\fR[+\fIextension\fR...]] - [\fB\-mfpu\fR=\fIfloating-point-format\fR] - [\fB\-mfloat\-abi\fR=\fIabi\fR] - [\fB\-meabi\fR=\fIver\fR] - [\fB\-mthumb\fR] - [\fB\-EB\fR|\fB\-EL\fR] - [\fB\-mapcs\-32\fR|\fB\-mapcs\-26\fR|\fB\-mapcs\-float\fR| - \fB\-mapcs\-reentrant\fR] - [\fB\-mthumb\-interwork\fR] [\fB\-k\fR] -.PP -\&\fITarget \s-1CRIS\s0 options:\fR - [\fB\-\-underscore\fR | \fB\-\-no\-underscore\fR] - [\fB\-\-pic\fR] [\fB\-N\fR] - [\fB\-\-emulation=criself\fR | \fB\-\-emulation=crisaout\fR] - [\fB\-\-march=v0_v10\fR | \fB\-\-march=v10\fR | \fB\-\-march=v32\fR | \fB\-\-march=common_v10_v32\fR] -.PP -\&\fITarget D10V options:\fR - [\fB\-O\fR] -.PP -\&\fITarget D30V options:\fR - [\fB\-O\fR|\fB\-n\fR|\fB\-N\fR] -.PP -\&\fITarget i386 options:\fR - [\fB\-\-32\fR|\fB\-\-64\fR] [\fB\-n\fR] - [\fB\-march\fR=\fI\s-1CPU\s0\fR] [\fB\-mtune\fR=\fI\s-1CPU\s0\fR] -.PP -\&\fITarget i960 options:\fR - [\fB\-ACA\fR|\fB\-ACA_A\fR|\fB\-ACB\fR|\fB\-ACC\fR|\fB\-AKA\fR|\fB\-AKB\fR| - \fB\-AKC\fR|\fB\-AMC\fR] - [\fB\-b\fR] [\fB\-no\-relax\fR] -.PP -\&\fITarget \s-1IA\-64\s0 options:\fR - [\fB\-mconstant\-gp\fR|\fB\-mauto\-pic\fR] - [\fB\-milp32\fR|\fB\-milp64\fR|\fB\-mlp64\fR|\fB\-mp64\fR] - [\fB\-mle\fR|\fBmbe\fR] - [\fB\-mtune=itanium1\fR|\fB\-mtune=itanium2\fR] - [\fB\-munwind\-check=warning\fR|\fB\-munwind\-check=error\fR] - [\fB\-mhint.b=ok\fR|\fB\-mhint.b=warning\fR|\fB\-mhint.b=error\fR] - [\fB\-x\fR|\fB\-xexplicit\fR] [\fB\-xauto\fR] [\fB\-xdebug\fR] -.PP -\&\fITarget \s-1IP2K\s0 options:\fR - [\fB\-mip2022\fR|\fB\-mip2022ext\fR] -.PP -\&\fITarget M32C options:\fR - [\fB\-m32c\fR|\fB\-m16c\fR] -.PP -\&\fITarget M32R options:\fR - [\fB\-\-m32rx\fR|\fB\-\-[no\-]warn\-explicit\-parallel\-conflicts\fR| - \fB\-\-W[n]p\fR] -.PP -\&\fITarget M680X0 options:\fR - [\fB\-l\fR] [\fB\-m68000\fR|\fB\-m68010\fR|\fB\-m68020\fR|...] -.PP -\&\fITarget M68HC11 options:\fR - [\fB\-m68hc11\fR|\fB\-m68hc12\fR|\fB\-m68hcs12\fR] - [\fB\-mshort\fR|\fB\-mlong\fR] - [\fB\-mshort\-double\fR|\fB\-mlong\-double\fR] - [\fB\-\-force\-long\-branches\fR] [\fB\-\-short\-branches\fR] - [\fB\-\-strict\-direct\-mode\fR] [\fB\-\-print\-insn\-syntax\fR] - [\fB\-\-print\-opcodes\fR] [\fB\-\-generate\-example\fR] -.PP -\&\fITarget \s-1MCORE\s0 options:\fR - [\fB\-jsri2bsr\fR] [\fB\-sifilter\fR] [\fB\-relax\fR] - [\fB\-mcpu=[210|340]\fR] -.PP -\&\fITarget \s-1MIPS\s0 options:\fR - [\fB\-nocpp\fR] [\fB\-EL\fR] [\fB\-EB\fR] [\fB\-O\fR[\fIoptimization level\fR]] - [\fB\-g\fR[\fIdebug level\fR]] [\fB\-G\fR \fInum\fR] [\fB\-KPIC\fR] [\fB\-call_shared\fR] - [\fB\-non_shared\fR] [\fB\-xgot\fR [\fB\-mvxworks\-pic\fR] - [\fB\-mabi\fR=\fI\s-1ABI\s0\fR] [\fB\-32\fR] [\fB\-n32\fR] [\fB\-64\fR] [\fB\-mfp32\fR] [\fB\-mgp32\fR] - [\fB\-march\fR=\fI\s-1CPU\s0\fR] [\fB\-mtune\fR=\fI\s-1CPU\s0\fR] [\fB\-mips1\fR] [\fB\-mips2\fR] - [\fB\-mips3\fR] [\fB\-mips4\fR] [\fB\-mips5\fR] [\fB\-mips32\fR] [\fB\-mips32r2\fR] - [\fB\-mips64\fR] [\fB\-mips64r2\fR] - [\fB\-construct\-floats\fR] [\fB\-no\-construct\-floats\fR] - [\fB\-trap\fR] [\fB\-no\-break\fR] [\fB\-break\fR] [\fB\-no\-trap\fR] - [\fB\-mfix7000\fR] [\fB\-mno\-fix7000\fR] - [\fB\-mips16\fR] [\fB\-no\-mips16\fR] - [\fB\-msmartmips\fR] [\fB\-mno\-smartmips\fR] - [\fB\-mips3d\fR] [\fB\-no\-mips3d\fR] - [\fB\-mdmx\fR] [\fB\-no\-mdmx\fR] - [\fB\-mdsp\fR] [\fB\-mno\-dsp\fR] - [\fB\-mdspr2\fR] [\fB\-mno\-dspr2\fR] - [\fB\-mmt\fR] [\fB\-mno\-mt\fR] - [\fB\-mdebug\fR] [\fB\-no\-mdebug\fR] - [\fB\-mpdr\fR] [\fB\-mno\-pdr\fR] -.PP -\&\fITarget \s-1MMIX\s0 options:\fR - [\fB\-\-fixed\-special\-register\-names\fR] [\fB\-\-globalize\-symbols\fR] - [\fB\-\-gnu\-syntax\fR] [\fB\-\-relax\fR] [\fB\-\-no\-predefined\-symbols\fR] - [\fB\-\-no\-expand\fR] [\fB\-\-no\-merge\-gregs\fR] [\fB\-x\fR] - [\fB\-\-linker\-allocated\-gregs\fR] -.PP -\&\fITarget \s-1PDP11\s0 options:\fR - [\fB\-mpic\fR|\fB\-mno\-pic\fR] [\fB\-mall\fR] [\fB\-mno\-extensions\fR] - [\fB\-m\fR\fIextension\fR|\fB\-mno\-\fR\fIextension\fR] - [\fB\-m\fR\fIcpu\fR] [\fB\-m\fR\fImachine\fR] -.PP -\&\fITarget picoJava options:\fR - [\fB\-mb\fR|\fB\-me\fR] -.PP -\&\fITarget PowerPC options:\fR - [\fB\-mpwrx\fR|\fB\-mpwr2\fR|\fB\-mpwr\fR|\fB\-m601\fR|\fB\-mppc\fR|\fB\-mppc32\fR|\fB\-m603\fR|\fB\-m604\fR| - \fB\-m403\fR|\fB\-m405\fR|\fB\-mppc64\fR|\fB\-m620\fR|\fB\-mppc64bridge\fR|\fB\-mbooke\fR| - \fB\-mbooke32\fR|\fB\-mbooke64\fR] - [\fB\-mcom\fR|\fB\-many\fR|\fB\-maltivec\fR] [\fB\-memb\fR] - [\fB\-mregnames\fR|\fB\-mno\-regnames\fR] - [\fB\-mrelocatable\fR|\fB\-mrelocatable\-lib\fR] - [\fB\-mlittle\fR|\fB\-mlittle\-endian\fR|\fB\-mbig\fR|\fB\-mbig\-endian\fR] - [\fB\-msolaris\fR|\fB\-mno\-solaris\fR] -.PP -\&\fITarget \s-1SPARC\s0 options:\fR - [\fB\-Av6\fR|\fB\-Av7\fR|\fB\-Av8\fR|\fB\-Asparclet\fR|\fB\-Asparclite\fR - \fB\-Av8plus\fR|\fB\-Av8plusa\fR|\fB\-Av9\fR|\fB\-Av9a\fR] - [\fB\-xarch=v8plus\fR|\fB\-xarch=v8plusa\fR] [\fB\-bump\fR] - [\fB\-32\fR|\fB\-64\fR] -.PP -\&\fITarget \s-1TIC54X\s0 options:\fR - [\fB\-mcpu=54[123589]\fR|\fB\-mcpu=54[56]lp\fR] [\fB\-mfar\-mode\fR|\fB\-mf\fR] - [\fB\-merrors\-to\-file\fR \fI\fR|\fB\-me\fR \fI\fR] -.PP -\&\fITarget Z80 options:\fR - [\fB\-z80\fR] [\fB\-r800\fR] - [ \fB\-ignore\-undocumented\-instructions\fR] [\fB\-Wnud\fR] - [ \fB\-ignore\-unportable\-instructions\fR] [\fB\-Wnup\fR] - [ \fB\-warn\-undocumented\-instructions\fR] [\fB\-Wud\fR] - [ \fB\-warn\-unportable\-instructions\fR] [\fB\-Wup\fR] - [ \fB\-forbid\-undocumented\-instructions\fR] [\fB\-Fud\fR] - [ \fB\-forbid\-unportable\-instructions\fR] [\fB\-Fup\fR] -.PP -\&\fITarget Xtensa options:\fR - [\fB\-\-[no\-]text\-section\-literals\fR] [\fB\-\-[no\-]absolute\-literals\fR] - [\fB\-\-[no\-]target\-align\fR] [\fB\-\-[no\-]longcalls\fR] - [\fB\-\-[no\-]transform\fR] - [\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR] -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -\&\s-1GNU\s0 \fBas\fR will be removed from a future version of the -FreeBSD base system. Users who require -\&\s-1GNU\s0 \fBas\fR are advised to install the binutils port or package. -.PP -\&\s-1GNU\s0 \fBas\fR is really a family of assemblers. -If you use (or have used) the \s-1GNU\s0 assembler on one architecture, you -should find a fairly similar environment when you use it on another -architecture. Each version has much in common with the others, -including object file formats, most assembler directives (often called -\&\fIpseudo-ops\fR) and assembler syntax. -.PP -\&\fBas\fR is primarily intended to assemble the output of the -\&\s-1GNU\s0 C compiler \f(CW\*(C`gcc\*(C'\fR for use by the linker -\&\f(CW\*(C`ld\*(C'\fR. Nevertheless, we've tried to make \fBas\fR -assemble correctly everything that other assemblers for the same -machine would assemble. -Any exceptions are documented explicitly. -This doesn't mean \fBas\fR always uses the same syntax as another -assembler for the same architecture; for example, we know of several -incompatible versions of 680x0 assembly language syntax. -.PP -Each time you run \fBas\fR it assembles exactly one source -program. The source program is made up of one or more files. -(The standard input is also a file.) -.PP -You give \fBas\fR a command line that has zero or more input file -names. The input files are read (from left file name to right). A -command line argument (in any position) that has no special meaning -is taken to be an input file name. -.PP -If you give \fBas\fR no file names it attempts to read one input file -from the \fBas\fR standard input, which is normally your terminal. You -may have to type \fBctl-D\fR to tell \fBas\fR there is no more program -to assemble. -.PP -Use \fB\-\-\fR if you need to explicitly name the standard input file -in your command line. -.PP -If the source is empty, \fBas\fR produces a small, empty object -file. -.PP -\&\fBas\fR may write warnings and error messages to the standard error -file (usually your terminal). This should not happen when a compiler -runs \fBas\fR automatically. Warnings report an assumption made so -that \fBas\fR could keep assembling a flawed program; errors report a -grave problem that stops the assembly. -.PP -If you are invoking \fBas\fR via the \s-1GNU\s0 C compiler, -you can use the \fB\-Wa\fR option to pass arguments through to the assembler. -The assembler arguments must be separated from each other (and the \fB\-Wa\fR) -by commas. For example: -.PP -.Vb 1 -\& gcc \-c \-g \-O \-Wa,\-alh,\-L file.c -.Ve -.PP -This passes two options to the assembler: \fB\-alh\fR (emit a listing to -standard output with high-level and assembly source) and \fB\-L\fR (retain -local symbols in the symbol table). -.PP -Usually you do not need to use this \fB\-Wa\fR mechanism, since many compiler -command-line options are automatically passed to the assembler by the compiler. -(You can call the \s-1GNU\s0 compiler driver with the \fB\-v\fR option to see -precisely what options it passes to each compilation pass, including the -assembler.) -.SH "OPTIONS" -.IX Header "OPTIONS" -.IP "\fB@\fR\fIfile\fR" 4 -.IX Item "@file" -Read command-line options from \fIfile\fR. The options read are -inserted in place of the original @\fIfile\fR option. If \fIfile\fR -does not exist, or cannot be read, then the option will be treated -literally, and not removed. -.Sp -Options in \fIfile\fR are separated by whitespace. A whitespace -character may be included in an option by surrounding the entire -option in either single or double quotes. Any character (including a -backslash) may be included by prefixing the character to be included -with a backslash. The \fIfile\fR may itself contain additional -@\fIfile\fR options; any such options will be processed recursively. -.IP "\fB\-a[cdhlmns]\fR" 4 -.IX Item "-a[cdhlmns]" -Turn on listings, in any of a variety of ways: -.RS 4 -.IP "\fB\-ac\fR" 4 -.IX Item "-ac" -omit false conditionals -.IP "\fB\-ad\fR" 4 -.IX Item "-ad" -omit debugging directives -.IP "\fB\-ah\fR" 4 -.IX Item "-ah" -include high-level source -.IP "\fB\-al\fR" 4 -.IX Item "-al" -include assembly -.IP "\fB\-am\fR" 4 -.IX Item "-am" -include macro expansions -.IP "\fB\-an\fR" 4 -.IX Item "-an" -omit forms processing -.IP "\fB\-as\fR" 4 -.IX Item "-as" -include symbols -.IP "\fB=file\fR" 4 -.IX Item "=file" -set the name of the listing file -.RE -.RS 4 -.Sp -You may combine these options; for example, use \fB\-aln\fR for assembly -listing without forms processing. The \fB=file\fR option, if used, must be -the last one. By itself, \fB\-a\fR defaults to \fB\-ahls\fR. -.RE -.IP "\fB\-\-alternate\fR" 4 -.IX Item "--alternate" -Begin in alternate macro mode. -.IP "\fB\-D\fR" 4 -.IX Item "-D" -Ignored. This option is accepted for script compatibility with calls to -other assemblers. -.IP "\fB\-\-defsym\fR \fIsym\fR\fB=\fR\fIvalue\fR" 4 -.IX Item "--defsym sym=value" -Define the symbol \fIsym\fR to be \fIvalue\fR before assembling the input file. -\&\fIvalue\fR must be an integer constant. As in C, a leading \fB0x\fR -indicates a hexadecimal value, and a leading \fB0\fR indicates an octal -value. The value of the symbol can be overridden inside a source file via the -use of a \f(CW\*(C`.set\*(C'\fR pseudo-op. -.IP "\fB\-f\fR" 4 -.IX Item "-f" -\&\*(L"fast\*(R"\-\-\-skip whitespace and comment preprocessing (assume source is -compiler output). -.IP "\fB\-g\fR" 4 -.IX Item "-g" -.PD 0 -.IP "\fB\-\-gen\-debug\fR" 4 -.IX Item "--gen-debug" -.PD -Generate debugging information for each assembler source line using whichever -debug format is preferred by the target. This currently means either \s-1STABS\s0, -\&\s-1ECOFF\s0 or \s-1DWARF2\s0. -.IP "\fB\-\-gstabs\fR" 4 -.IX Item "--gstabs" -Generate stabs debugging information for each assembler line. This -may help debugging assembler code, if the debugger can handle it. -.IP "\fB\-\-gstabs+\fR" 4 -.IX Item "--gstabs+" -Generate stabs debugging information for each assembler line, with \s-1GNU\s0 -extensions that probably only gdb can handle, and that could make other -debuggers crash or refuse to read your program. This -may help debugging assembler code. Currently the only \s-1GNU\s0 extension is -the location of the current working directory at assembling time. -.IP "\fB\-\-gdwarf\-2\fR" 4 -.IX Item "--gdwarf-2" -Generate \s-1DWARF2\s0 debugging information for each assembler line. This -may help debugging assembler code, if the debugger can handle it. Note\-\-\-this -option is only supported by some targets, not all of them. -.IP "\fB\-\-help\fR" 4 -.IX Item "--help" -Print a summary of the command line options and exit. -.IP "\fB\-\-target\-help\fR" 4 -.IX Item "--target-help" -Print a summary of all target specific options and exit. -.IP "\fB\-I\fR \fIdir\fR" 4 -.IX Item "-I dir" -Add directory \fIdir\fR to the search list for \f(CW\*(C`.include\*(C'\fR directives. -.IP "\fB\-J\fR" 4 -.IX Item "-J" -Don't warn about signed overflow. -.IP "\fB\-K\fR" 4 -.IX Item "-K" -Issue warnings when difference tables altered for long displacements. -.IP "\fB\-L\fR" 4 -.IX Item "-L" -.PD 0 -.IP "\fB\-\-keep\-locals\fR" 4 -.IX Item "--keep-locals" -.PD -Keep (in the symbol table) local symbols. These symbols start with -system-specific local label prefixes, typically \fB.L\fR for \s-1ELF\s0 systems -or \fBL\fR for traditional a.out systems. -.IP "\fB\-\-listing\-lhs\-width=\fR\fInumber\fR" 4 -.IX Item "--listing-lhs-width=number" -Set the maximum width, in words, of the output data column for an assembler -listing to \fInumber\fR. -.IP "\fB\-\-listing\-lhs\-width2=\fR\fInumber\fR" 4 -.IX Item "--listing-lhs-width2=number" -Set the maximum width, in words, of the output data column for continuation -lines in an assembler listing to \fInumber\fR. -.IP "\fB\-\-listing\-rhs\-width=\fR\fInumber\fR" 4 -.IX Item "--listing-rhs-width=number" -Set the maximum width of an input source line, as displayed in a listing, to -\&\fInumber\fR bytes. -.IP "\fB\-\-listing\-cont\-lines=\fR\fInumber\fR" 4 -.IX Item "--listing-cont-lines=number" -Set the maximum number of lines printed in a listing for a single line of input -to \fInumber\fR + 1. -.IP "\fB\-o\fR \fIobjfile\fR" 4 -.IX Item "-o objfile" -Name the object-file output from \fBas\fR \fIobjfile\fR. -.IP "\fB\-R\fR" 4 -.IX Item "-R" -Fold the data section into the text section. -.Sp -Set the default size of \s-1GAS\s0's hash tables to a prime number close to -\&\fInumber\fR. Increasing this value can reduce the length of time it takes the -assembler to perform its tasks, at the expense of increasing the assembler's -memory requirements. Similarly reducing this value can reduce the memory -requirements at the expense of speed. -.IP "\fB\-\-reduce\-memory\-overheads\fR" 4 -.IX Item "--reduce-memory-overheads" -This option reduces \s-1GAS\s0's memory requirements, at the expense of making the -assembly processes slower. Currently this switch is a synonym for -\&\fB\-\-hash\-size=4051\fR, but in the future it may have other effects as well. -.IP "\fB\-\-statistics\fR" 4 -.IX Item "--statistics" -Print the maximum space (in bytes) and total time (in seconds) used by -assembly. -.IP "\fB\-\-strip\-local\-absolute\fR" 4 -.IX Item "--strip-local-absolute" -Remove local absolute symbols from the outgoing symbol table. -.IP "\fB\-v\fR" 4 -.IX Item "-v" -.PD 0 -.IP "\fB\-version\fR" 4 -.IX Item "-version" -.PD -Print the \fBas\fR version. -.IP "\fB\-\-version\fR" 4 -.IX Item "--version" -Print the \fBas\fR version and exit. -.IP "\fB\-W\fR" 4 -.IX Item "-W" -.PD 0 -.IP "\fB\-\-no\-warn\fR" 4 -.IX Item "--no-warn" -.PD -Suppress warning messages. -.IP "\fB\-\-fatal\-warnings\fR" 4 -.IX Item "--fatal-warnings" -Treat warnings as errors. -.IP "\fB\-\-warn\fR" 4 -.IX Item "--warn" -Don't suppress warning messages or treat them as errors. -.IP "\fB\-w\fR" 4 -.IX Item "-w" -Ignored. -.IP "\fB\-x\fR" 4 -.IX Item "-x" -Ignored. -.IP "\fB\-Z\fR" 4 -.IX Item "-Z" -Generate an object file even after errors. -.IP "\fB\-\- |\fR \fIfiles\fR \fB...\fR" 4 -.IX Item "-- | files ..." -Standard input, or source files to assemble. -.PP -The following options are available when as is configured for -an \s-1ARC\s0 processor. -.IP "\fB\-marc[5|6|7|8]\fR" 4 -.IX Item "-marc[5|6|7|8]" -This option selects the core processor variant. -.IP "\fB\-EB | \-EL\fR" 4 -.IX Item "-EB | -EL" -Select either big-endian (\-EB) or little-endian (\-EL) output. -.PP -The following options are available when as is configured for the \s-1ARM\s0 -processor family. -.IP "\fB\-mcpu=\fR\fIprocessor\fR\fB[+\fR\fIextension\fR\fB...]\fR" 4 -.IX Item "-mcpu=processor[+extension...]" -Specify which \s-1ARM\s0 processor variant is the target. -.IP "\fB\-march=\fR\fIarchitecture\fR\fB[+\fR\fIextension\fR\fB...]\fR" 4 -.IX Item "-march=architecture[+extension...]" -Specify which \s-1ARM\s0 architecture variant is used by the target. -.IP "\fB\-mfpu=\fR\fIfloating-point-format\fR" 4 -.IX Item "-mfpu=floating-point-format" -Select which Floating Point architecture is the target. -.IP "\fB\-mfloat\-abi=\fR\fIabi\fR" 4 -.IX Item "-mfloat-abi=abi" -Select which floating point \s-1ABI\s0 is in use. -.IP "\fB\-mthumb\fR" 4 -.IX Item "-mthumb" -Enable Thumb only instruction decoding. -.IP "\fB\-mapcs\-32 | \-mapcs\-26 | \-mapcs\-float | \-mapcs\-reentrant\fR" 4 -.IX Item "-mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant" -Select which procedure calling convention is in use. -.IP "\fB\-EB | \-EL\fR" 4 -.IX Item "-EB | -EL" -Select either big-endian (\-EB) or little-endian (\-EL) output. -.IP "\fB\-mthumb\-interwork\fR" 4 -.IX Item "-mthumb-interwork" -Specify that the code has been generated with interworking between Thumb and -\&\s-1ARM\s0 code in mind. -.IP "\fB\-k\fR" 4 -.IX Item "-k" -Specify that \s-1PIC\s0 code has been generated. -.PP -See the info pages for documentation of the CRIS-specific options. -.PP -The following options are available when as is configured for -a D10V processor. -.IP "\fB\-O\fR" 4 -.IX Item "-O" -Optimize output by parallelizing instructions. -.PP -The following options are available when as is configured for a D30V -processor. -.IP "\fB\-O\fR" 4 -.IX Item "-O" -Optimize output by parallelizing instructions. -.IP "\fB\-n\fR" 4 -.IX Item "-n" -Warn when nops are generated. -.IP "\fB\-N\fR" 4 -.IX Item "-N" -Warn when a nop after a 32\-bit multiply instruction is generated. -.PP -The following options are available when as is configured for the -Intel 80960 processor. -.IP "\fB\-ACA | \-ACA_A | \-ACB | \-ACC | \-AKA | \-AKB | \-AKC | \-AMC\fR" 4 -.IX Item "-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC" -Specify which variant of the 960 architecture is the target. -.IP "\fB\-b\fR" 4 -.IX Item "-b" -Add code to collect statistics about branches taken. -.IP "\fB\-no\-relax\fR" 4 -.IX Item "-no-relax" -Do not alter compare-and-branch instructions for long displacements; -error if necessary. -.PP -The following options are available when as is configured for the -Ubicom \s-1IP2K\s0 series. -.IP "\fB\-mip2022ext\fR" 4 -.IX Item "-mip2022ext" -Specifies that the extended \s-1IP2022\s0 instructions are allowed. -.IP "\fB\-mip2022\fR" 4 -.IX Item "-mip2022" -Restores the default behaviour, which restricts the permitted instructions to -just the basic \s-1IP2022\s0 ones. -.PP -The following options are available when as is configured for the -Renesas M32C and M16C processors. -.IP "\fB\-m32c\fR" 4 -.IX Item "-m32c" -Assemble M32C instructions. -.IP "\fB\-m16c\fR" 4 -.IX Item "-m16c" -Assemble M16C instructions (the default). -.PP -The following options are available when as is configured for the -Renesas M32R (formerly Mitsubishi M32R) series. -.IP "\fB\-\-m32rx\fR" 4 -.IX Item "--m32rx" -Specify which processor in the M32R family is the target. The default -is normally the M32R, but this option changes it to the M32RX. -.IP "\fB\-\-warn\-explicit\-parallel\-conflicts or \-\-Wp\fR" 4 -.IX Item "--warn-explicit-parallel-conflicts or --Wp" -Produce warning messages when questionable parallel constructs are -encountered. -.IP "\fB\-\-no\-warn\-explicit\-parallel\-conflicts or \-\-Wnp\fR" 4 -.IX Item "--no-warn-explicit-parallel-conflicts or --Wnp" -Do not produce warning messages when questionable parallel constructs are -encountered. -.PP -The following options are available when as is configured for the -Motorola 68000 series. -.IP "\fB\-l\fR" 4 -.IX Item "-l" -Shorten references to undefined symbols, to one word instead of two. -.IP "\fB\-m68000 | \-m68008 | \-m68010 | \-m68020 | \-m68030\fR" 4 -.IX Item "-m68000 | -m68008 | -m68010 | -m68020 | -m68030" -.PD 0 -.IP "\fB| \-m68040 | \-m68060 | \-m68302 | \-m68331 | \-m68332\fR" 4 -.IX Item "| -m68040 | -m68060 | -m68302 | -m68331 | -m68332" -.IP "\fB| \-m68333 | \-m68340 | \-mcpu32 | \-m5200\fR" 4 -.IX Item "| -m68333 | -m68340 | -mcpu32 | -m5200" -.PD -Specify what processor in the 68000 family is the target. The default -is normally the 68020, but this can be changed at configuration time. -.IP "\fB\-m68881 | \-m68882 | \-mno\-68881 | \-mno\-68882\fR" 4 -.IX Item "-m68881 | -m68882 | -mno-68881 | -mno-68882" -The target machine does (or does not) have a floating-point coprocessor. -The default is to assume a coprocessor for 68020, 68030, and cpu32. Although -the basic 68000 is not compatible with the 68881, a combination of the -two can be specified, since it's possible to do emulation of the -coprocessor instructions with the main processor. -.IP "\fB\-m68851 | \-mno\-68851\fR" 4 -.IX Item "-m68851 | -mno-68851" -The target machine does (or does not) have a memory-management -unit coprocessor. The default is to assume an \s-1MMU\s0 for 68020 and up. -.PP -For details about the \s-1PDP\-11\s0 machine dependent features options, -see \fBPDP\-11\-Options\fR. -.IP "\fB\-mpic | \-mno\-pic\fR" 4 -.IX Item "-mpic | -mno-pic" -Generate position-independent (or position-dependent) code. The -default is \fB\-mpic\fR. -.IP "\fB\-mall\fR" 4 -.IX Item "-mall" -.PD 0 -.IP "\fB\-mall\-extensions\fR" 4 -.IX Item "-mall-extensions" -.PD -Enable all instruction set extensions. This is the default. -.IP "\fB\-mno\-extensions\fR" 4 -.IX Item "-mno-extensions" -Disable all instruction set extensions. -.IP "\fB\-m\fR\fIextension\fR \fB| \-mno\-\fR\fIextension\fR" 4 -.IX Item "-mextension | -mno-extension" -Enable (or disable) a particular instruction set extension. -.IP "\fB\-m\fR\fIcpu\fR" 4 -.IX Item "-mcpu" -Enable the instruction set extensions supported by a particular \s-1CPU\s0, and -disable all other extensions. -.IP "\fB\-m\fR\fImachine\fR" 4 -.IX Item "-mmachine" -Enable the instruction set extensions supported by a particular machine -model, and disable all other extensions. -.PP -The following options are available when as is configured for -a picoJava processor. -.IP "\fB\-mb\fR" 4 -.IX Item "-mb" -Generate \*(L"big endian\*(R" format output. -.IP "\fB\-ml\fR" 4 -.IX Item "-ml" -Generate \*(L"little endian\*(R" format output. -.PP -The following options are available when as is configured for the -Motorola 68HC11 or 68HC12 series. -.IP "\fB\-m68hc11 | \-m68hc12 | \-m68hcs12\fR" 4 -.IX Item "-m68hc11 | -m68hc12 | -m68hcs12" -Specify what processor is the target. The default is -defined by the configuration option when building the assembler. -.IP "\fB\-mshort\fR" 4 -.IX Item "-mshort" -Specify to use the 16\-bit integer \s-1ABI\s0. -.IP "\fB\-mlong\fR" 4 -.IX Item "-mlong" -Specify to use the 32\-bit integer \s-1ABI\s0. -.IP "\fB\-mshort\-double\fR" 4 -.IX Item "-mshort-double" -Specify to use the 32\-bit double \s-1ABI\s0. -.IP "\fB\-mlong\-double\fR" 4 -.IX Item "-mlong-double" -Specify to use the 64\-bit double \s-1ABI\s0. -.IP "\fB\-\-force\-long\-branches\fR" 4 -.IX Item "--force-long-branches" -Relative branches are turned into absolute ones. This concerns -conditional branches, unconditional branches and branches to a -sub routine. -.IP "\fB\-S | \-\-short\-branches\fR" 4 -.IX Item "-S | --short-branches" -Do not turn relative branches into absolute ones -when the offset is out of range. -.IP "\fB\-\-strict\-direct\-mode\fR" 4 -.IX Item "--strict-direct-mode" -Do not turn the direct addressing mode into extended addressing mode -when the instruction does not support direct addressing mode. -.IP "\fB\-\-print\-insn\-syntax\fR" 4 -.IX Item "--print-insn-syntax" -Print the syntax of instruction in case of error. -.IP "\fB\-\-print\-opcodes\fR" 4 -.IX Item "--print-opcodes" -print the list of instructions with syntax and then exit. -.IP "\fB\-\-generate\-example\fR" 4 -.IX Item "--generate-example" -print an example of instruction for each possible instruction and then exit. -This option is only useful for testing \fBas\fR. -.PP -The following options are available when \fBas\fR is configured -for the \s-1SPARC\s0 architecture: -.IP "\fB\-Av6 | \-Av7 | \-Av8 | \-Asparclet | \-Asparclite\fR" 4 -.IX Item "-Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite" -.PD 0 -.IP "\fB\-Av8plus | \-Av8plusa | \-Av9 | \-Av9a\fR" 4 -.IX Item "-Av8plus | -Av8plusa | -Av9 | -Av9a" -.PD -Explicitly select a variant of the \s-1SPARC\s0 architecture. -.Sp -\&\fB\-Av8plus\fR and \fB\-Av8plusa\fR select a 32 bit environment. -\&\fB\-Av9\fR and \fB\-Av9a\fR select a 64 bit environment. -.Sp -\&\fB\-Av8plusa\fR and \fB\-Av9a\fR enable the \s-1SPARC\s0 V9 instruction set with -UltraSPARC extensions. -.IP "\fB\-xarch=v8plus | \-xarch=v8plusa\fR" 4 -.IX Item "-xarch=v8plus | -xarch=v8plusa" -For compatibility with the Solaris v9 assembler. These options are -equivalent to \-Av8plus and \-Av8plusa, respectively. -.IP "\fB\-bump\fR" 4 -.IX Item "-bump" -Warn when the assembler switches to another architecture. -.PP -The following options are available when as is configured for the 'c54x -architecture. -.IP "\fB\-mfar\-mode\fR" 4 -.IX Item "-mfar-mode" -Enable extended addressing mode. All addresses and relocations will assume -extended addressing (usually 23 bits). -.IP "\fB\-mcpu=\fR\fI\s-1CPU_VERSION\s0\fR" 4 -.IX Item "-mcpu=CPU_VERSION" -Sets the \s-1CPU\s0 version being compiled for. -.IP "\fB\-merrors\-to\-file\fR \fI\s-1FILENAME\s0\fR" 4 -.IX Item "-merrors-to-file FILENAME" -Redirect error output to a file, for broken systems which don't support such -behaviour in the shell. -.PP -The following options are available when as is configured for -a \s-1MIPS\s0 processor. -.IP "\fB\-G\fR \fInum\fR" 4 -.IX Item "-G num" -This option sets the largest size of an object that can be referenced -implicitly with the \f(CW\*(C`gp\*(C'\fR register. It is only accepted for targets that -use \s-1ECOFF\s0 format, such as a DECstation running Ultrix. The default value is 8. -.IP "\fB\-EB\fR" 4 -.IX Item "-EB" -Generate \*(L"big endian\*(R" format output. -.IP "\fB\-EL\fR" 4 -.IX Item "-EL" -Generate \*(L"little endian\*(R" format output. -.IP "\fB\-mips1\fR" 4 -.IX Item "-mips1" -.PD 0 -.IP "\fB\-mips2\fR" 4 -.IX Item "-mips2" -.IP "\fB\-mips3\fR" 4 -.IX Item "-mips3" -.IP "\fB\-mips4\fR" 4 -.IX Item "-mips4" -.IP "\fB\-mips5\fR" 4 -.IX Item "-mips5" -.IP "\fB\-mips32\fR" 4 -.IX Item "-mips32" -.IP "\fB\-mips32r2\fR" 4 -.IX Item "-mips32r2" -.IP "\fB\-mips64\fR" 4 -.IX Item "-mips64" -.IP "\fB\-mips64r2\fR" 4 -.IX Item "-mips64r2" -.PD -Generate code for a particular \s-1MIPS\s0 Instruction Set Architecture level. -\&\fB\-mips1\fR is an alias for \fB\-march=r3000\fR, \fB\-mips2\fR is an -alias for \fB\-march=r6000\fR, \fB\-mips3\fR is an alias for -\&\fB\-march=r4000\fR and \fB\-mips4\fR is an alias for \fB\-march=r8000\fR. -\&\fB\-mips5\fR, \fB\-mips32\fR, \fB\-mips32r2\fR, \fB\-mips64\fR, and -\&\fB\-mips64r2\fR -correspond to generic -\&\fB\s-1MIPS\s0 V\fR, \fB\s-1MIPS32\s0\fR, \fB\s-1MIPS32\s0 Release 2\fR, \fB\s-1MIPS64\s0\fR, -and \fB\s-1MIPS64\s0 Release 2\fR -\&\s-1ISA\s0 processors, respectively. -.IP "\fB\-march=\fR\fI\s-1CPU\s0\fR" 4 -.IX Item "-march=CPU" -Generate code for a particular \s-1MIPS\s0 cpu. -.IP "\fB\-mtune=\fR\fIcpu\fR" 4 -.IX Item "-mtune=cpu" -Schedule and tune for a particular \s-1MIPS\s0 cpu. -.IP "\fB\-mfix7000\fR" 4 -.IX Item "-mfix7000" -.PD 0 -.IP "\fB\-mno\-fix7000\fR" 4 -.IX Item "-mno-fix7000" -.PD -Cause nops to be inserted if the read of the destination register -of an mfhi or mflo instruction occurs in the following two instructions. -.IP "\fB\-mdebug\fR" 4 -.IX Item "-mdebug" -.PD 0 -.IP "\fB\-no\-mdebug\fR" 4 -.IX Item "-no-mdebug" -.PD -Cause stabs-style debugging output to go into an ECOFF-style .mdebug -section instead of the standard \s-1ELF\s0 .stabs sections. -.IP "\fB\-mpdr\fR" 4 -.IX Item "-mpdr" -.PD 0 -.IP "\fB\-mno\-pdr\fR" 4 -.IX Item "-mno-pdr" -.PD -Control generation of \f(CW\*(C`.pdr\*(C'\fR sections. -.IP "\fB\-mgp32\fR" 4 -.IX Item "-mgp32" -.PD 0 -.IP "\fB\-mfp32\fR" 4 -.IX Item "-mfp32" -.PD -The register sizes are normally inferred from the \s-1ISA\s0 and \s-1ABI\s0, but these -flags force a certain group of registers to be treated as 32 bits wide at -all times. \fB\-mgp32\fR controls the size of general-purpose registers -and \fB\-mfp32\fR controls the size of floating-point registers. -.IP "\fB\-mips16\fR" 4 -.IX Item "-mips16" -.PD 0 -.IP "\fB\-no\-mips16\fR" 4 -.IX Item "-no-mips16" -.PD -Generate code for the \s-1MIPS\s0 16 processor. This is equivalent to putting -\&\f(CW\*(C`.set mips16\*(C'\fR at the start of the assembly file. \fB\-no\-mips16\fR -turns off this option. -.IP "\fB\-msmartmips\fR" 4 -.IX Item "-msmartmips" -.PD 0 -.IP "\fB\-mno\-smartmips\fR" 4 -.IX Item "-mno-smartmips" -.PD -Enables the SmartMIPS extension to the \s-1MIPS32\s0 instruction set. This is -equivalent to putting \f(CW\*(C`.set smartmips\*(C'\fR at the start of the assembly file. -\&\fB\-mno\-smartmips\fR turns off this option. -.IP "\fB\-mips3d\fR" 4 -.IX Item "-mips3d" -.PD 0 -.IP "\fB\-no\-mips3d\fR" 4 -.IX Item "-no-mips3d" -.PD -Generate code for the \s-1MIPS\-3D\s0 Application Specific Extension. -This tells the assembler to accept \s-1MIPS\-3D\s0 instructions. -\&\fB\-no\-mips3d\fR turns off this option. -.IP "\fB\-mdmx\fR" 4 -.IX Item "-mdmx" -.PD 0 -.IP "\fB\-no\-mdmx\fR" 4 -.IX Item "-no-mdmx" -.PD -Generate code for the \s-1MDMX\s0 Application Specific Extension. -This tells the assembler to accept \s-1MDMX\s0 instructions. -\&\fB\-no\-mdmx\fR turns off this option. -.IP "\fB\-mdsp\fR" 4 -.IX Item "-mdsp" -.PD 0 -.IP "\fB\-mno\-dsp\fR" 4 -.IX Item "-mno-dsp" -.PD -Generate code for the \s-1DSP\s0 Release 1 Application Specific Extension. -This tells the assembler to accept \s-1DSP\s0 Release 1 instructions. -\&\fB\-mno\-dsp\fR turns off this option. -.IP "\fB\-mdspr2\fR" 4 -.IX Item "-mdspr2" -.PD 0 -.IP "\fB\-mno\-dspr2\fR" 4 -.IX Item "-mno-dspr2" -.PD -Generate code for the \s-1DSP\s0 Release 2 Application Specific Extension. -This option implies \-mdsp. -This tells the assembler to accept \s-1DSP\s0 Release 2 instructions. -\&\fB\-mno\-dspr2\fR turns off this option. -.IP "\fB\-mmt\fR" 4 -.IX Item "-mmt" -.PD 0 -.IP "\fB\-mno\-mt\fR" 4 -.IX Item "-mno-mt" -.PD -Generate code for the \s-1MT\s0 Application Specific Extension. -This tells the assembler to accept \s-1MT\s0 instructions. -\&\fB\-mno\-mt\fR turns off this option. -.IP "\fB\-\-construct\-floats\fR" 4 -.IX Item "--construct-floats" -.PD 0 -.IP "\fB\-\-no\-construct\-floats\fR" 4 -.IX Item "--no-construct-floats" -.PD -The \fB\-\-no\-construct\-floats\fR option disables the construction of -double width floating point constants by loading the two halves of the -value into the two single width floating point registers that make up -the double width register. By default \fB\-\-construct\-floats\fR is -selected, allowing construction of these floating point constants. -.IP "\fB\-\-emulation=\fR\fIname\fR" 4 -.IX Item "--emulation=name" -This option causes \fBas\fR to emulate \fBas\fR configured -for some other target, in all respects, including output format (choosing -between \s-1ELF\s0 and \s-1ECOFF\s0 only), handling of pseudo-opcodes which may generate -debugging information or store symbol table information, and default -endianness. The available configuration names are: \fBmipsecoff\fR, -\&\fBmipself\fR, \fBmipslecoff\fR, \fBmipsbecoff\fR, \fBmipslelf\fR, -\&\fBmipsbelf\fR. The first two do not alter the default endianness from that -of the primary target for which the assembler was configured; the others change -the default to little\- or big-endian as indicated by the \fBb\fR or \fBl\fR -in the name. Using \fB\-EB\fR or \fB\-EL\fR will override the endianness -selection in any case. -.Sp -This option is currently supported only when the primary target -\&\fBas\fR is configured for is a \s-1MIPS\s0 \s-1ELF\s0 or \s-1ECOFF\s0 target. -Furthermore, the primary target or others specified with -\&\fB\-\-enable\-targets=...\fR at configuration time must include support for -the other format, if both are to be available. For example, the Irix 5 -configuration includes support for both. -.Sp -Eventually, this option will support more configurations, with more -fine-grained control over the assembler's behavior, and will be supported for -more processors. -.IP "\fB\-nocpp\fR" 4 -.IX Item "-nocpp" -\&\fBas\fR ignores this option. It is accepted for compatibility with -the native tools. -.IP "\fB\-\-trap\fR" 4 -.IX Item "--trap" -.PD 0 -.IP "\fB\-\-no\-trap\fR" 4 -.IX Item "--no-trap" -.IP "\fB\-\-break\fR" 4 -.IX Item "--break" -.IP "\fB\-\-no\-break\fR" 4 -.IX Item "--no-break" -.PD -Control how to deal with multiplication overflow and division by zero. -\&\fB\-\-trap\fR or \fB\-\-no\-break\fR (which are synonyms) take a trap exception -(and only work for Instruction Set Architecture level 2 and higher); -\&\fB\-\-break\fR or \fB\-\-no\-trap\fR (also synonyms, and the default) take a -break exception. -.IP "\fB\-n\fR" 4 -.IX Item "-n" -When this option is used, \fBas\fR will issue a warning every -time it generates a nop instruction from a macro. -.PP -The following options are available when as is configured for -an MCore processor. -.IP "\fB\-jsri2bsr\fR" 4 -.IX Item "-jsri2bsr" -.PD 0 -.IP "\fB\-nojsri2bsr\fR" 4 -.IX Item "-nojsri2bsr" -.PD -Enable or disable the \s-1JSRI\s0 to \s-1BSR\s0 transformation. By default this is enabled. -The command line option \fB\-nojsri2bsr\fR can be used to disable it. -.IP "\fB\-sifilter\fR" 4 -.IX Item "-sifilter" -.PD 0 -.IP "\fB\-nosifilter\fR" 4 -.IX Item "-nosifilter" -.PD -Enable or disable the silicon filter behaviour. By default this is disabled. -The default can be overridden by the \fB\-sifilter\fR command line option. -.IP "\fB\-relax\fR" 4 -.IX Item "-relax" -Alter jump instructions for long displacements. -.IP "\fB\-mcpu=[210|340]\fR" 4 -.IX Item "-mcpu=[210|340]" -Select the cpu type on the target hardware. This controls which instructions -can be assembled. -.IP "\fB\-EB\fR" 4 -.IX Item "-EB" -Assemble for a big endian target. -.IP "\fB\-EL\fR" 4 -.IX Item "-EL" -Assemble for a little endian target. -.PP -See the info pages for documentation of the MMIX-specific options. -.PP -The following options are available when as is configured for -an Xtensa processor. -.IP "\fB\-\-text\-section\-literals | \-\-no\-text\-section\-literals\fR" 4 -.IX Item "--text-section-literals | --no-text-section-literals" -With \fB\-\-text\-section\-literals\fR, literal pools are interspersed -in the text section. The default is -\&\fB\-\-no\-text\-section\-literals\fR, which places literals in a -separate section in the output file. These options only affect literals -referenced via PC-relative \f(CW\*(C`L32R\*(C'\fR instructions; literals for -absolute mode \f(CW\*(C`L32R\*(C'\fR instructions are handled separately. -.IP "\fB\-\-absolute\-literals | \-\-no\-absolute\-literals\fR" 4 -.IX Item "--absolute-literals | --no-absolute-literals" -Indicate to the assembler whether \f(CW\*(C`L32R\*(C'\fR instructions use absolute -or PC-relative addressing. The default is to assume absolute addressing -if the Xtensa processor includes the absolute \f(CW\*(C`L32R\*(C'\fR addressing -option. Otherwise, only the PC-relative \f(CW\*(C`L32R\*(C'\fR mode can be used. -.IP "\fB\-\-target\-align | \-\-no\-target\-align\fR" 4 -.IX Item "--target-align | --no-target-align" -Enable or disable automatic alignment to reduce branch penalties at the -expense of some code density. The default is \fB\-\-target\-align\fR. -.IP "\fB\-\-longcalls | \-\-no\-longcalls\fR" 4 -.IX Item "--longcalls | --no-longcalls" -Enable or disable transformation of call instructions to allow calls -across a greater range of addresses. The default is -\&\fB\-\-no\-longcalls\fR. -.IP "\fB\-\-transform | \-\-no\-transform\fR" 4 -.IX Item "--transform | --no-transform" -Enable or disable all assembler transformations of Xtensa instructions. -The default is \fB\-\-transform\fR; -\&\fB\-\-no\-transform\fR should be used only in the rare cases when the -instructions must be exactly as specified in the assembly source. -.PP -The following options are available when as is configured for -a Z80 family processor. -.IP "\fB\-z80\fR" 4 -.IX Item "-z80" -Assemble for Z80 processor. -.IP "\fB\-r800\fR" 4 -.IX Item "-r800" -Assemble for R800 processor. -.IP "\fB\-ignore\-undocumented\-instructions\fR" 4 -.IX Item "-ignore-undocumented-instructions" -.PD 0 -.IP "\fB\-Wnud\fR" 4 -.IX Item "-Wnud" -.PD -Assemble undocumented Z80 instructions that also work on R800 without warning. -.IP "\fB\-ignore\-unportable\-instructions\fR" 4 -.IX Item "-ignore-unportable-instructions" -.PD 0 -.IP "\fB\-Wnup\fR" 4 -.IX Item "-Wnup" -.PD -Assemble all undocumented Z80 instructions without warning. -.IP "\fB\-warn\-undocumented\-instructions\fR" 4 -.IX Item "-warn-undocumented-instructions" -.PD 0 -.IP "\fB\-Wud\fR" 4 -.IX Item "-Wud" -.PD -Issue a warning for undocumented Z80 instructions that also work on R800. -.IP "\fB\-warn\-unportable\-instructions\fR" 4 -.IX Item "-warn-unportable-instructions" -.PD 0 -.IP "\fB\-Wup\fR" 4 -.IX Item "-Wup" -.PD -Issue a warning for undocumented Z80 instructions that do not work on R800. -.IP "\fB\-forbid\-undocumented\-instructions\fR" 4 -.IX Item "-forbid-undocumented-instructions" -.PD 0 -.IP "\fB\-Fud\fR" 4 -.IX Item "-Fud" -.PD -Treat all undocumented instructions as errors. -.IP "\fB\-forbid\-unportable\-instructions\fR" 4 -.IX Item "-forbid-unportable-instructions" -.PD 0 -.IP "\fB\-Fup\fR" 4 -.IX Item "-Fup" -.PD -Treat undocumented Z80 instructions that do not work on R800 as errors. -.SH "SEE ALSO" -.IX Header "SEE ALSO" -\&\fIgcc\fR\|(1), \fIld\fR\|(1), and the Info entries for \fIbinutils\fR and \fIld\fR. -.SH "COPYRIGHT" -.IX Header "COPYRIGHT" -Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, -2006, 2007 Free Software Foundation, Inc. -.PP -Permission is granted to copy, distribute and/or modify this document -under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 -or any later version published by the Free Software Foundation; -with no Invariant Sections, with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the -section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/as/config.h b/gnu/usr.bin/binutils/as/config.h deleted file mode 100644 index 84cd51590e5..00000000000 --- a/gnu/usr.bin/binutils/as/config.h +++ /dev/null @@ -1,254 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.in by autoheader. */ - -/* Define if using AIX 5.2 value for C_WEAKEXT. */ -/* #undef AIX_WEAK_SUPPORT */ - -/* assert broken? */ -/* #undef BROKEN_ASSERT */ - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Compiling cross-assembler? */ -/* #undef CROSS_COMPILE */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Default architecture. */ -/* #define DEFAULT_ARCH "i386" */ - -/* Default CRIS architecture. */ -/* #undef DEFAULT_CRIS_ARCH */ - -/* Default emulation. */ -/* #define DEFAULT_EMULATION "i386elf" */ - -/* Supported emulations. */ -/* #define EMULATIONS &i386elf, */ - -/* Define if you want run-time sanity checks. */ -/* #undef ENABLE_CHECKING */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -/* #undef HAVE_ALLOCA_H */ - -/* Is the prototype for getopt in in the expected format? */ -#define HAVE_DECL_GETOPT 1 - -/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VSNPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `remove' function. */ -/* #undef HAVE_REMOVE */ - -/* Define to 1 if you have the `sbrk' function. */ -/* #undef HAVE_SBRK */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `unlink' function. */ -#define HAVE_UNLINK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VARARGS_H */ - -/* Using i386 COFF? */ -/* #undef I386COFF */ - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Using m68k COFF? */ -/* #undef M68KCOFF */ - -/* Using m88k COFF? */ -/* #undef M88KCOFF */ - -/* Default CPU for MIPS targets. */ -/* #undef MIPS_CPU_STRING_DEFAULT */ - -/* Generate 64-bit code by default on MIPS targets. */ -/* #undef MIPS_DEFAULT_64BIT */ - -/* Choose a default ABI for MIPS targets. */ -/* #undef MIPS_DEFAULT_ABI */ - -/* Define if environ is not declared in system header files. */ -#define NEED_DECLARATION_ENVIRON 1 - -/* Define if errno is not declared in system header files. */ -/* #undef NEED_DECLARATION_ERRNO */ - -/* Define if ffs is not declared in system header files. */ -/* #undef NEED_DECLARATION_FFS */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if sbrk is not declared in system header files. */ -/* #undef NEED_DECLARATION_SBRK */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* a.out support? */ -/* #undef OBJ_MAYBE_AOUT */ - -/* b.out support? */ -/* #undef OBJ_MAYBE_BOUT */ - -/* COFF support? */ -/* #undef OBJ_MAYBE_COFF */ - -/* ECOFF support? */ -/* #undef OBJ_MAYBE_ECOFF */ - -/* ELF support? */ -/* #undef OBJ_MAYBE_ELF */ - -/* generic support? */ -/* #undef OBJ_MAYBE_GENERIC */ - -/* SOM support? */ -/* #undef OBJ_MAYBE_SOM */ - -/* Name of package */ -#define PACKAGE "gas" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define if defaulting to ELF on SCO 5. */ -/* #undef SCO_ELF */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Using strict COFF? */ -/* #undef STRICTCOFF */ - -/* Target alias. */ -/* #define TARGET_ALIAS "i386-unknown-freebsd9.0" */ - -/* Define as 1 if big endian. */ -/* #undef TARGET_BYTES_BIG_ENDIAN */ - -/* Canonical target. */ -/* #define TARGET_CANONICAL "i386-unknown-freebsd9.0" */ - -/* Target CPU. */ -/* #define TARGET_CPU "i386" */ - -/* Target OS. */ -/* #define TARGET_OS "freebsd9.0" */ - -/* Define if default target is PowerPC Solaris. */ -/* #undef TARGET_SOLARIS_COMMENT */ - -/* Define if target is Symbian OS. */ -/* #undef TARGET_SYMBIAN */ - -/* Target vendor. */ -/* #define TARGET_VENDOR "unknown" */ - -/* Use b modifier when opening binary files? */ -/* #undef USE_BINARY_FOPEN */ - -/* Use emulation support? */ -/* #undef USE_EMULATIONS */ - -/* Allow use of E_MIPS_ABI_O32 on MIPS targets. */ -/* #undef USE_E_MIPS_ABI_O32 */ - -/* Using cgen code? */ -/* #undef USING_CGEN */ - -/* Version number of package */ -/* #define VERSION "2.17.50" */ - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#define YYTEXT_POINTER 1 - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif diff --git a/gnu/usr.bin/binutils/as/i386-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/i386-freebsd/targ-cpu.h deleted file mode 100644 index f4be0e50bd8..00000000000 --- a/gnu/usr.bin/binutils/as/i386-freebsd/targ-cpu.h +++ /dev/null @@ -1 +0,0 @@ -#include "tc-i386.h" diff --git a/gnu/usr.bin/binutils/as/mips-freebsd/itbl-cpu.h b/gnu/usr.bin/binutils/as/mips-freebsd/itbl-cpu.h deleted file mode 100644 index 5e007d18e35..00000000000 --- a/gnu/usr.bin/binutils/as/mips-freebsd/itbl-cpu.h +++ /dev/null @@ -1,22 +0,0 @@ -/* $FreeBSD$ */ - -#include "itbl-mips.h" - -/* Choose a default ABI for MIPS targets. */ -#ifndef MIPS_DEFAULT_ABI -#define MIPS_DEFAULT_ABI NO_ABI -#endif - -/* Default CPU for MIPS targets. */ -#define MIPS_CPU_STRING_DEFAULT "from-abi" - -/* Generate 64-bit code by default on MIPS targets. */ -#ifndef MIPS_DEFAULT_64BIT -#define MIPS_DEFAULT_64BIT 0 -#endif - -/* Allow use of E_MIPS_ABI_O32 on MIPS targets. */ -#define USE_E_MIPS_ABI_O32 1 - -/* Use traditional mips */ -#define TE_TMIPS 1 diff --git a/gnu/usr.bin/binutils/as/mips-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/mips-freebsd/targ-cpu.h deleted file mode 100644 index 72fa131944e..00000000000 --- a/gnu/usr.bin/binutils/as/mips-freebsd/targ-cpu.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $FreeBSD$ */ -#define TE_TMIPS 1 - -#include "tc-mips.h" diff --git a/gnu/usr.bin/binutils/as/obj-format.h b/gnu/usr.bin/binutils/as/obj-format.h deleted file mode 100644 index 02a3030e1ad..00000000000 --- a/gnu/usr.bin/binutils/as/obj-format.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $FreeBSD$ */ - -#include "obj-elf.h" diff --git a/gnu/usr.bin/binutils/as/powerpc-freebsd/itbl-cpu.h b/gnu/usr.bin/binutils/as/powerpc-freebsd/itbl-cpu.h deleted file mode 100644 index b55da9afd1a..00000000000 --- a/gnu/usr.bin/binutils/as/powerpc-freebsd/itbl-cpu.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ - -/* Values for processors will be from 0 to NUMBER_OF_PROCESSORS-1 */ -#define NUMBER_OF_PROCESSORS 1 - -#include "itbl-ppc.h" diff --git a/gnu/usr.bin/binutils/as/powerpc-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/powerpc-freebsd/targ-cpu.h deleted file mode 100644 index 891bd6cabaf..00000000000 --- a/gnu/usr.bin/binutils/as/powerpc-freebsd/targ-cpu.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $FreeBSD$ */ - -#include "tc-ppc.h" diff --git a/gnu/usr.bin/binutils/as/sparc64-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/sparc64-freebsd/targ-cpu.h deleted file mode 100644 index 46e43130fc1..00000000000 --- a/gnu/usr.bin/binutils/as/sparc64-freebsd/targ-cpu.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $FreeBSD$ */ - -#include "tc-sparc.h" diff --git a/gnu/usr.bin/binutils/as/targ-env.h b/gnu/usr.bin/binutils/as/targ-env.h deleted file mode 100644 index 213374dabac..00000000000 --- a/gnu/usr.bin/binutils/as/targ-env.h +++ /dev/null @@ -1,2 +0,0 @@ - -#include "te-freebsd.h" diff --git a/gnu/usr.bin/binutils/doc/Makefile b/gnu/usr.bin/binutils/doc/Makefile deleted file mode 100644 index 4d1f059daee..00000000000 --- a/gnu/usr.bin/binutils/doc/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/doc/Makefile 279529 2015-03-02 17:24:04Z bapt $ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/gas/doc \ - ${SRCDIR}/ld \ - ${SRCDIR}/binutils/doc - -MAN= ld.7 ldint.7 as.7 binutils.7 - -.include diff --git a/gnu/usr.bin/binutils/doc/Makefile.depend b/gnu/usr.bin/binutils/doc/Makefile.depend deleted file mode 100644 index e1d4f07ca0d..00000000000 --- a/gnu/usr.bin/binutils/doc/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/doc/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/ld/Makefile b/gnu/usr.bin/binutils/ld/Makefile deleted file mode 100644 index b2ce9eececc..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# $FreeBSD$ - -ELF_SCR_EXT= x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw -.include "../Makefile.inc0" -.include - -.PATH: ${SRCDIR}/ld - -PROG= ld.bfd -.if (!defined(TOOLS_PREFIX) && ${MK_LLD_IS_LD} == "no") || \ - (defined(TOOLS_PREFIX) && ${MK_LLD_BOOTSTRAP} == "no") -MAN= ld.1 -LINKS= ${BINDIR}/ld.bfd ${BINDIR}/ld -.else -MAN= ld.bfd.1 -CLEANFILES+= ld.bfd.1 -ld.bfd.1: ld.1 - ${CP} ${.ALLSRC} ${.TARGET} -.endif - -SCRIPTDIR= /usr/libdata/ldscripts -SRCS+= ldcref.c \ - ldctor.c \ - ldemul-list.h \ - ldemul.c \ - ldexp.c \ - ldfile.c \ - ldgram.y \ - ldlang.c \ - ldlex.l \ - ldmain.c \ - ldmisc.c \ - ldver.c \ - ldwrite.c \ - lexsup.c \ - mri.c - -CFLAGS+= -DTARGET=\"${TARGET_TUPLE}\" -CFLAGS+= -DDEFAULT_EMULATION=\"${NATIVE_EMULATION}\" -CFLAGS+= -DSCRIPTDIR=\"${TOOLS_PREFIX}/usr/libdata\" -CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" -CFLAGS+= -DBINDIR=\"${BINDIR}\" -.if defined(TOOLS_PREFIX) -CFLAGS+= -DTARGET_SYSTEM_ROOT=\"${TOOLS_PREFIX}\" -.else -CFLAGS+= -DTARGET_SYSTEM_ROOT=\"/\" -.endif -CFLAGS+= -DTOOLBINDIR=\"${TOOLS_PREFIX}/${BINDIR}/libexec\" -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd -.if ${MK_SHARED_TOOLCHAIN} == "no" -NO_SHARED?= yes -.endif -DPADD= ${GNURELTOP}/libbfd/libbfd${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libiberty/libiberty${PIE_SUFFIX}.a -LDADD= ${DPADD} -CLEANDIRS+= ldscripts -CLEANFILES+= ldemul-list.h stringify.sed - -FILES= ${LDSCRIPTS:S|^|ldscripts/|} -FILESDIR= ${SCRIPTDIR} - -HOST= ${TARGET_TUPLE} -LIBSEARCHPATH= \"=/lib\":\"=/usr/lib\" -.for ext in ${ELF_SCR_EXT} -LDSCRIPTS+= ${NATIVE_EMULATION}.${ext} -ldscripts/${NATIVE_EMULATION}.${ext}: e${NATIVE_EMULATION}.c -.endfor - -EMXFR= -EMLST= -.for _e in ${NATIVE_EMULATION} ${EMS} -EMXFR+= extern ld_emulation_xfer_type ld_${_e}_emulation; -EMLST+= &ld_${_e}_emulation, -.endfor - -ldemul-list.h: - echo "${EMXFR}" > ${.TARGET} - echo "#define EMULATION_LIST ${EMLST} 0" >> ${.TARGET} - -stringify.sed: ${SRCDIR}/ld/emultempl/astring.sed .NOMETA - ln -sf ${.ALLSRC} ${.TARGET} - -GENDIRDEPS_FILTER.host+= Nusr.bin/yacc - -.include diff --git a/gnu/usr.bin/binutils/ld/Makefile.amd64 b/gnu/usr.bin/binutils/ld/Makefile.amd64 deleted file mode 100644 index c396d1fd79d..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.amd64 +++ /dev/null @@ -1,29 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/ld/Makefile.amd64 288233 2015-09-25 20:31:04Z bdrewery $ - -NATIVE_EMULATION= elf_x86_64_fbsd - -SRCS+= e${NATIVE_EMULATION}.c -CLEANFILES+= e${NATIVE_EMULATION}.c -e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} - -X86_EMULATION= elf_i386_fbsd -_i386_path= \"${TOOLS_PREFIX}/usr/lib32\" -EMS+= ${X86_EMULATION} -.for ext in ${ELF_SCR_EXT} -LDSCRIPTS+= ${X86_EMULATION}.${ext} -ldscripts/${X86_EMULATION}.${ext}: e${X86_EMULATION}.c -.endfor - -SRCS+= e${X86_EMULATION}.c -CLEANFILES+= e${X86_EMULATION}.c -e${X86_EMULATION}.c: emulparams/${X86_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${_i386_path} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${X86_EMULATION} "" no ${X86_EMULATION} ${TARGET_TUPLE} diff --git a/gnu/usr.bin/binutils/ld/Makefile.arm b/gnu/usr.bin/binutils/ld/Makefile.arm deleted file mode 100644 index 9fe573cad21..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.arm +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -.if ${TARGET_ARCH:Marm*eb} != "" -NATIVE_EMULATION= armelfb_fbsd -.else -NATIVE_EMULATION= armelf_fbsd -.endif - -SRCS+= e${NATIVE_EMULATION}.c -CLEANFILES+= e${NATIVE_EMULATION}.c -e${NATIVE_EMULATION}.c: ${.CURDIR}/${NATIVE_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} \ - ${.CURDIR}/${NATIVE_EMULATION}.sh diff --git a/gnu/usr.bin/binutils/ld/Makefile.depend b/gnu/usr.bin/binutils/ld/Makefile.depend deleted file mode 100644 index ace486b47b1..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.bin/yacc.host \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/ld/Makefile.depend.host b/gnu/usr.bin/binutils/ld/Makefile.depend.host deleted file mode 100644 index fea8e8e26bf..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.depend.host +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libiberty \ - usr.bin/yacc \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/ld/Makefile.i386 b/gnu/usr.bin/binutils/ld/Makefile.i386 deleted file mode 100644 index 216bfa8a4fd..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.i386 +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -NATIVE_EMULATION= elf_i386_fbsd - -SRCS+= e${NATIVE_EMULATION}.c -CLEANFILES+= e${NATIVE_EMULATION}.c -e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} diff --git a/gnu/usr.bin/binutils/ld/Makefile.powerpc b/gnu/usr.bin/binutils/ld/Makefile.powerpc deleted file mode 100644 index fed52341c08..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.powerpc +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -NATIVE_EMULATION= elf32ppc_fbsd - -SRCS+= e${NATIVE_EMULATION}.c -CLEANFILES+= e${NATIVE_EMULATION}.c -e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed ldemul-list.h - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} diff --git a/gnu/usr.bin/binutils/ld/Makefile.powerpc64 b/gnu/usr.bin/binutils/ld/Makefile.powerpc64 deleted file mode 100644 index 9e18cb4a60a..00000000000 --- a/gnu/usr.bin/binutils/ld/Makefile.powerpc64 +++ /dev/null @@ -1,30 +0,0 @@ -# $FreeBSD$ - -NATIVE_EMULATION= elf64ppc_fbsd - -SRCS+= e${NATIVE_EMULATION}.c -CLEANFILES+= e${NATIVE_EMULATION}.c -e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed ldemul-list.h - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} - -PPC32_EMULATION= elf32ppc_fbsd -_ppc32_path= \"${TOOLS_PREFIX}/usr/lib32\" -EMS+= ${PPC32_EMULATION} -.for ext in ${ELF_SCR_EXT} -LDSCRIPTS+= ${PPC32_EMULATION}.${ext} -ldscripts/${PPC32_EMULATION}.${ext}: e${PPC32_EMULATION}.c -.endfor - -SRCS+= e${PPC32_EMULATION}.c -CLEANFILES+= e${PPC32_EMULATION}.c -e${PPC32_EMULATION}.c: emulparams/${PPC32_EMULATION}.sh emultempl/elf32.em \ - scripttempl/elf.sc genscripts.sh stringify.sed ldemul-list.h - sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${_ppc32_path} \ - ${TOOLS_PREFIX}/usr \ - ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ - ${PPC32_EMULATION} "" no ${PPC32_EMULATION} ${TARGET_TUPLE} - diff --git a/gnu/usr.bin/binutils/ld/armelf_fbsd.sh b/gnu/usr.bin/binutils/ld/armelf_fbsd.sh deleted file mode 100644 index 2340a0ec2c7..00000000000 --- a/gnu/usr.bin/binutils/ld/armelf_fbsd.sh +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/ld/armelf_fbsd.sh 245101 2013-01-06 07:14:04Z andrew $ -. ${srcdir}/emulparams/armelf.sh -. ${srcdir}/emulparams/elf_fbsd.sh -TARGET2_TYPE=got-rel -MAXPAGESIZE=0x8000 -GENERATE_PIE_SCRIPT=yes - -unset STACK_ADDR -unset EMBEDDED diff --git a/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh b/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh deleted file mode 100644 index 39364efe31a..00000000000 --- a/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ -#XXX: This should be used once those bits are merged back in the FSF repo. -#. ${srcdir}/emulparams/armelf_fbsd.sh -# -#OUTPUT_FORMAT="elf32-bigarm" -. ${srcdir}/emulparams/armelf.sh -. ${srcdir}/emulparams/elf_fbsd.sh -TARGET2_TYPE=got-rel -MAXPAGESIZE=0x8000 -GENERATE_PIE_SCRIPT=yes - -unset STACK_ADDR -unset EMBEDDED -OUTPUT_FORMAT="elf32-bigarm" diff --git a/gnu/usr.bin/binutils/ld/config.h b/gnu/usr.bin/binutils/ld/config.h deleted file mode 100644 index ac9a78d729d..00000000000 --- a/gnu/usr.bin/binutils/ld/config.h +++ /dev/null @@ -1,141 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* Additional extension a shared object might have. */ -/* #undef EXTRA_SHLIB_EXTENSION */ - -/* Define to 1 if you have the declaration of `environ', and to 0 if you - don't. */ -#define HAVE_DECL_ENVIRON 0 - -/* Define to 1 if you have the declaration of `free', and to 0 if you don't. - */ -#define HAVE_DECL_FREE 1 - -/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. - */ -#define HAVE_DECL_GETENV 1 - -/* Is the prototype for getopt in in the expected format? */ -#define HAVE_DECL_GETOPT 1 - -/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. - */ -#define HAVE_DECL_SBRK 1 - -/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't. - */ -#define HAVE_DECL_STRSTR 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ELF_HINTS_H 1 - -/* Define to 1 if you have the `glob' function. */ -#define HAVE_GLOB 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkstemp' function. */ -#define HAVE_MKSTEMP 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the `realpath' function. */ -#define HAVE_REALPATH 1 - -/* Define to 1 if you have the `sbrk' function. */ -/* #undef HAVE_SBRK */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `waitpid' function. */ -#define HAVE_WAITPID 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "ld" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* The size of a `long', as computed by sizeof. */ -/* #undef SIZEOF_LONG */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Use b modifier when opening binary files? */ -/* #undef USE_BINARY_FOPEN */ - -/* Version number of package */ -/* #define VERSION "2.17.50" */ - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#define YYTEXT_POINTER 1 diff --git a/gnu/usr.bin/binutils/ld/elf32btsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32btsmip_fbsd.sh deleted file mode 100755 index ef5afbcdf4a..00000000000 --- a/gnu/usr.bin/binutils/ld/elf32btsmip_fbsd.sh +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ -. ${srcdir}/emulparams/elf32btsmip.sh -. ${srcdir}/emulparams/elf_fbsd.sh -GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/elf32btsmipn32_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32btsmipn32_fbsd.sh deleted file mode 100755 index 2e33346efd9..00000000000 --- a/gnu/usr.bin/binutils/ld/elf32btsmipn32_fbsd.sh +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ -. ${srcdir}/emulparams/elf32btsmipn32.sh -. ${srcdir}/emulparams/elf_fbsd.sh -GENERATE_PIE_SCRIPT=yes -ALIGNMENT=8 diff --git a/gnu/usr.bin/binutils/ld/elf32ltsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32ltsmip_fbsd.sh deleted file mode 100755 index 89c13d8bd05..00000000000 --- a/gnu/usr.bin/binutils/ld/elf32ltsmip_fbsd.sh +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ -. ${srcdir}/emulparams/elf32ltsmip.sh -. ${srcdir}/emulparams/elf_fbsd.sh -GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/elf32ltsmipn32_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32ltsmipn32_fbsd.sh deleted file mode 100755 index 50242102329..00000000000 --- a/gnu/usr.bin/binutils/ld/elf32ltsmipn32_fbsd.sh +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ -. ${srcdir}/emulparams/elf32ltsmipn32.sh -. ${srcdir}/emulparams/elf_fbsd.sh -GENERATE_PIE_SCRIPT=yes -ALIGNMENT=8 diff --git a/gnu/usr.bin/binutils/ld/elf64btsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf64btsmip_fbsd.sh deleted file mode 100755 index e6ca55abf11..00000000000 --- a/gnu/usr.bin/binutils/ld/elf64btsmip_fbsd.sh +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ -. ${srcdir}/emulparams/elf64btsmip.sh -. ${srcdir}/emulparams/elf_fbsd.sh -GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/elf64ltsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf64ltsmip_fbsd.sh deleted file mode 100755 index 932600164a2..00000000000 --- a/gnu/usr.bin/binutils/ld/elf64ltsmip_fbsd.sh +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ -. ${srcdir}/emulparams/elf64ltsmip.sh -. ${srcdir}/emulparams/elf_fbsd.sh -GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/genscripts.sh b/gnu/usr.bin/binutils/ld/genscripts.sh deleted file mode 100755 index 238263eb75a..00000000000 --- a/gnu/usr.bin/binutils/ld/genscripts.sh +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/sh -# genscripts.sh - generate the ld-emulation-target specific files -# -# Usage: genscripts.sh srcdir libdir host target target_alias \ -# default_emulation native_lib_dirs this_emulation -# -# Sample usage: -# genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 \ -# sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun4 "" sun3 sparc-sun-sunos4.1.3 -# produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c -# -# $FreeBSD$ -# -# This is a cut-down version of the GNU script. Instead of jumping through -# hoops for all possible combinations of paths, just use the libdir -# argument in place of LIB_PATH. -# -# The exec_prefix, target_alias, use_sysroot, NATIVE_LIB_DIRS, TOOL_LIB, CUSTOMIZER_SCRIPT -# arguments are not used in this version. -# - -srcdir=$1 -libdir=$2 -exec_prefix=$3 -host=$4 -target=$5 -target_alias=$6 -EMULATION_LIBPATH=$7 -NATIVE_LIB_DIRS=$8 -use_sysroot=$9 -shift 9 -EMULATION_NAME=$1 -TOOL_LIB=$2 -CUSTOMIZER_SCRIPT=$3 - -# Create the 'CUSTOMIZER_SCRIPT' knob to better sync this script with -# FSF BU ver 2.15 which allows for a more generic emulparams processing. -# To reduce the diff, I also include the ${EMULATION_NAME} parameter in uses -# of 'CUSTOMIZER_SCRIPT'. - -# XXX: arm hack : until those file are merged back into the FSF repo, just -# use the version in this directory. -if !(test -f ${CUSTOMIZER_SCRIPT}"";) then -CUSTOMIZER_SCRIPT="${srcdir}/emulparams/${EMULATION_NAME}.sh" -fi - -# Include the emulation-specific parameters: -. ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - -if test -d ldscripts; then - true -else - mkdir -p ldscripts -fi - -# Set some flags for the emultempl scripts. USE_LIBPATH will -# be set for any libpath-using emulation; NATIVE will be set for a -# emulation to enable 'LD_LIBRARY_PATH=/foo:/bar ld -lfooz' - if [ "x${host}" = "x${target}" ] ; then - NATIVE=yes - fi - USE_LIBPATH=yes - -# Set the library search path, for libraries named by -lfoo. -# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used. -# Otherwise, the default is set here. -# -# The format is the usual list of colon-separated directories. -# To force a logically empty LIB_PATH, do LIBPATH=":". - -LIB_SEARCH_DIRS=`echo ${libdir} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'` - -# Generate 5 or 6 script files from a master script template in -# ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6 -# script files is actually used depends on command line options given -# to ld. (SCRIPT_NAME was set in the emulparams_file.) -# -# A .x script file is the default script. -# A .xr script is for linking without relocation (-r flag). -# A .xu script is like .xr, but *do* create constructors (-Ur flag). -# A .xn script is for linking with -n flag (mix text and data on same page). -# A .xbn script is for linking with -N flag (mix text and data on same page). -# A .xs script is for generating a shared library with the --shared -# flag; it is only generated if $GENERATE_SHLIB_SCRIPT is set by the -# emulation parameters. -# A .xc script is for linking with -z combreloc; it is only generated if -# $GENERATE_COMBRELOC_SCRIPT is set by the emulation parameters or -# $SCRIPT_NAME is "elf". -# A .xsc script is for linking with --shared -z combreloc; it is generated -# if $GENERATE_COMBRELOC_SCRIPT is set by the emulation parameters or -# $SCRIPT_NAME is "elf" and $GENERATE_SHLIB_SCRIPT is set by the emulation -# parameters too. - -if [ "x$SCRIPT_NAME" = "xelf" ]; then - GENERATE_COMBRELOC_SCRIPT=yes -fi - -SEGMENT_SIZE=${SEGMENT_SIZE-${MAXPAGESIZE-${TARGET_PAGE_SIZE}}} - -# Determine DATA_ALIGNMENT for the 5 variants, using -# values specified in the emulparams/.sh file or default. - -DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}" -DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}" -DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}" -DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}" -DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}" - -LD_FLAG=r -DATA_ALIGNMENT=${DATA_ALIGNMENT_r} -DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" -( echo "/* Script for ld -r: link without relocation */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc -) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xr - -LD_FLAG=u -DATA_ALIGNMENT=${DATA_ALIGNMENT_u} -CONSTRUCTING=" " -( echo "/* Script for ld -Ur: link w/out relocation, do create constructors */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc -) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu - -LD_FLAG= -DATA_ALIGNMENT=${DATA_ALIGNMENT_} -RELOCATING=" " -( echo "/* Default linker script, for normal executables */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc -) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.x - -LD_FLAG=n -DATA_ALIGNMENT=${DATA_ALIGNMENT_n} -TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}} -( echo "/* Script for -n: mix text and data on same page */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc -) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xn - -LD_FLAG=N -DATA_ALIGNMENT=${DATA_ALIGNMENT_N} -( echo "/* Script for -N: mix text and data on same page; don't align data */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc -) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xbn - -if test -n "$GENERATE_COMBRELOC_SCRIPT"; then - DATA_ALIGNMENT=${DATA_ALIGNMENT_c-${DATA_ALIGNMENT_}} - LD_FLAG=c - COMBRELOC=ldscripts/${EMULATION_NAME}.xc.tmp - ( echo "/* Script for -z combreloc: combine and sort reloc sections */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xc - rm -f ${COMBRELOC} - LD_FLAG=w - RELRO_NOW=" " - COMBRELOC=ldscripts/${EMULATION_NAME}.xw.tmp - ( echo "/* Script for -z combreloc -z now -z relro: combine and sort reloc sections */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xw - rm -f ${COMBRELOC} - COMBRELOC= - unset RELRO_NOW -fi - -if test -n "$GENERATE_SHLIB_SCRIPT"; then - LD_FLAG=shared - DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}} - CREATE_SHLIB=" " - # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR. - ( - echo "/* Script for ld --shared: link shared library */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xs - if test -n "$GENERATE_COMBRELOC_SCRIPT"; then - LD_FLAG=cshared - DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}} - COMBRELOC=ldscripts/${EMULATION_NAME}.xsc.tmp - ( echo "/* Script for --shared -z combreloc: shared library, combine & sort relocs */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc - rm -f ${COMBRELOC} - LD_FLAG=wshared - RELRO_NOW=" " - COMBRELOC=ldscripts/${EMULATION_NAME}.xsw.tmp - ( echo "/* Script for --shared -z combreloc -z now -z relro: shared library, combine & sort relocs */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsw - rm -f ${COMBRELOC} - COMBRELOC= - unset RELRO_NOW - fi - unset CREATE_SHLIB -fi - -if test -n "$GENERATE_PIE_SCRIPT"; then - LD_FLAG=pie - DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}} - CREATE_PIE=" " - # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR. - ( - echo "/* Script for ld -pie: link position independent executable */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xd - if test -n "$GENERATE_COMBRELOC_SCRIPT"; then - LD_FLAG=cpie - DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}} - COMBRELOC=ldscripts/${EMULATION_NAME}.xdc.tmp - ( echo "/* Script for -pie -z combreloc: position independent executable, combine & sort relocs */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdc - rm -f ${COMBRELOC} - LD_FLAG=wpie - RELRO_NOW=" " - COMBRELOC=ldscripts/${EMULATION_NAME}.xdw.tmp - ( echo "/* Script for -pie -z combreloc -z now -z relro: position independent executable, combine & sort relocs */" - . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} - . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc - ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdw - rm -f ${COMBRELOC} - COMBRELOC= - unset RELRO_NOW - fi - unset CREATE_PIE -fi - -case " $EMULATION_LIBPATH " in - *" ${EMULATION_NAME} "*) COMPILE_IN=true;; -esac - -# Generate e${EMULATION_NAME}.c. -. ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em diff --git a/gnu/usr.bin/binutils/ld/ld.1 b/gnu/usr.bin/binutils/ld/ld.1 deleted file mode 100644 index 04594173b39..00000000000 --- a/gnu/usr.bin/binutils/ld/ld.1 +++ /dev/null @@ -1,2155 +0,0 @@ -.\" $FreeBSD$ -.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "LD 1" -.TH LD 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -ld \- The GNU linker -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -ld [\fBoptions\fR] \fIobjfile\fR ... -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -\&\fBld\fR combines a number of object and archive files, relocates -their data and ties up symbol references. Usually the last step in -compiling a program is to run \fBld\fR. -.PP -\&\fBld\fR accepts Linker Command Language files written in -a superset of \s-1AT&T\s0's Link Editor Command Language syntax, -to provide explicit and total control over the linking process. -.PP -This man page does not describe the command language; see the -\&\fBld\fR entry in \f(CW\*(C`info\*(C'\fR for full details on the command -language and on other aspects of the \s-1GNU\s0 linker. -.PP -This version of \fBld\fR uses the general purpose \s-1BFD\s0 libraries -to operate on object files. This allows \fBld\fR to read, combine, and -write object files in many different formats\-\-\-for example, \s-1COFF\s0 or -\&\f(CW\*(C`a.out\*(C'\fR. Different formats may be linked together to produce any -available kind of object file. -.PP -Aside from its flexibility, the \s-1GNU\s0 linker is more helpful than other -linkers in providing diagnostic information. Many linkers abandon -execution immediately upon encountering an error; whenever possible, -\&\fBld\fR continues executing, allowing you to identify other errors -(or, in some cases, to get an output file in spite of the error). -.PP -The \s-1GNU\s0 linker \fBld\fR is meant to cover a broad range of situations, -and to be as compatible as possible with other linkers. As a result, -you have many choices to control its behavior. -.SH "OPTIONS" -.IX Header "OPTIONS" -The linker supports a plethora of command-line options, but in actual -practice few of them are used in any particular context. -For instance, a frequent use of \fBld\fR is to link standard Unix -object files on a standard, supported Unix system. On such a system, to -link a file \f(CW\*(C`hello.o\*(C'\fR: -.PP -.Vb 1 -\& ld \-o /lib/crt0.o hello.o \-lc -.Ve -.PP -This tells \fBld\fR to produce a file called \fIoutput\fR as the -result of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR and -the library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard search -directories. (See the discussion of the \fB\-l\fR option below.) -.PP -Some of the command-line options to \fBld\fR may be specified at any -point in the command line. However, options which refer to files, such -as \fB\-l\fR or \fB\-T\fR, cause the file to be read at the point at -which the option appears in the command line, relative to the object -files and other file options. Repeating non-file options with a -different argument will either have no further effect, or override prior -occurrences (those further to the left on the command line) of that -option. Options which may be meaningfully specified more than once are -noted in the descriptions below. -.PP -Non-option arguments are object files or archives which are to be linked -together. They may follow, precede, or be mixed in with command-line -options, except that an object file argument may not be placed between -an option and its argument. -.PP -Usually the linker is invoked with at least one object file, but you can -specify other forms of binary input files using \fB\-l\fR, \fB\-R\fR, -and the script command language. If \fIno\fR binary input files at all -are specified, the linker does not produce any output, and issues the -message \fBNo input files\fR. -.PP -If the linker cannot recognize the format of an object file, it will -assume that it is a linker script. A script specified in this way -augments the main linker script used for the link (either the default -linker script or the one specified by using \fB\-T\fR). This feature -permits the linker to link against a file which appears to be an object -or an archive, but actually merely defines some symbol values, or uses -\&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Note that -specifying a script in this way merely augments the main linker script; -use the \fB\-T\fR option to replace the default linker script entirely. -.PP -For options whose names are a single letter, -option arguments must either follow the option letter without intervening -whitespace, or be given as separate arguments immediately following the -option that requires them. -.PP -For options whose names are multiple letters, either one dash or two can -precede the option name; for example, \fB\-trace\-symbol\fR and -\&\fB\-\-trace\-symbol\fR are equivalent. Note\-\-\-there is one exception to -this rule. Multiple letter options that start with a lower case 'o' can -only be preceded by two dashes. This is to reduce confusion with the -\&\fB\-o\fR option. So for example \fB\-omagic\fR sets the output file -name to \fBmagic\fR whereas \fB\-\-omagic\fR sets the \s-1NMAGIC\s0 flag on the -output. -.PP -Arguments to multiple-letter options must either be separated from the -option name by an equals sign, or be given as separate arguments -immediately following the option that requires them. For example, -\&\fB\-\-trace\-symbol foo\fR and \fB\-\-trace\-symbol=foo\fR are equivalent. -Unique abbreviations of the names of multiple-letter options are -accepted. -.PP -Note\-\-\-if the linker is being invoked indirectly, via a compiler driver -(e.g. \fBgcc\fR) then all the linker command line options should be -prefixed by \fB\-Wl,\fR (or whatever is appropriate for the particular -compiler driver) like this: -.PP -.Vb 1 -\& gcc \-Wl,\-\-startgroup foo.o bar.o \-Wl,\-\-endgroup -.Ve -.PP -This is important, because otherwise the compiler driver program may -silently drop the linker options, resulting in a bad link. -.PP -Here is a table of the generic command line switches accepted by the \s-1GNU\s0 -linker: -.IP "\fB@\fR\fIfile\fR" 4 -.IX Item "@file" -Read command-line options from \fIfile\fR. The options read are -inserted in place of the original @\fIfile\fR option. If \fIfile\fR -does not exist, or cannot be read, then the option will be treated -literally, and not removed. -.Sp -Options in \fIfile\fR are separated by whitespace. A whitespace -character may be included in an option by surrounding the entire -option in either single or double quotes. Any character (including a -backslash) may be included by prefixing the character to be included -with a backslash. The \fIfile\fR may itself contain additional -@\fIfile\fR options; any such options will be processed recursively. -.IP "\fB\-a\fR\fIkeyword\fR" 4 -.IX Item "-akeyword" -This option is supported for \s-1HP/UX\s0 compatibility. The \fIkeyword\fR -argument must be one of the strings \fBarchive\fR, \fBshared\fR, or -\&\fBdefault\fR. \fB\-aarchive\fR is functionally equivalent to -\&\fB\-Bstatic\fR, and the other two keywords are functionally equivalent -to \fB\-Bdynamic\fR. This option may be used any number of times. -.IP "\fB\-A\fR\fIarchitecture\fR" 4 -.IX Item "-Aarchitecture" -.PD 0 -.IP "\fB\-\-architecture=\fR\fIarchitecture\fR" 4 -.IX Item "--architecture=architecture" -.PD -In the current release of \fBld\fR, this option is useful only for the -Intel 960 family of architectures. In that \fBld\fR configuration, the -\&\fIarchitecture\fR argument identifies the particular architecture in -the 960 family, enabling some safeguards and modifying the -archive-library search path. -.Sp -Future releases of \fBld\fR may support similar functionality for -other architecture families. -.IP "\fB\-b\fR \fIinput-format\fR" 4 -.IX Item "-b input-format" -.PD 0 -.IP "\fB\-\-format=\fR\fIinput-format\fR" 4 -.IX Item "--format=input-format" -.PD -\&\fBld\fR may be configured to support more than one kind of object -file. If your \fBld\fR is configured this way, you can use the -\&\fB\-b\fR option to specify the binary format for input object files -that follow this option on the command line. Even when \fBld\fR is -configured to support alternative object formats, you don't usually need -to specify this, as \fBld\fR should be configured to expect as a -default input format the most usual format on each machine. -\&\fIinput-format\fR is a text string, the name of a particular format -supported by the \s-1BFD\s0 libraries. (You can list the available binary -formats with \fBobjdump \-i\fR.) -.Sp -You may want to use this option if you are linking files with an unusual -binary format. You can also use \fB\-b\fR to switch formats explicitly (when -linking object files of different formats), by including -\&\fB\-b\fR \fIinput-format\fR before each group of object files in a -particular format. -.Sp -The default format is taken from the environment variable -\&\f(CW\*(C`GNUTARGET\*(C'\fR. -.Sp -You can also define the input format from a script, using the command -\&\f(CW\*(C`TARGET\*(C'\fR; -.IP "\fB\-c\fR \fIMRI-commandfile\fR" 4 -.IX Item "-c MRI-commandfile" -.PD 0 -.IP "\fB\-\-mri\-script=\fR\fIMRI-commandfile\fR" 4 -.IX Item "--mri-script=MRI-commandfile" -.PD -For compatibility with linkers produced by \s-1MRI\s0, \fBld\fR accepts script -files written in an alternate, restricted command language, described in -the \s-1MRI\s0 Compatible Script Files section of \s-1GNU\s0 ld documentation. -Introduce \s-1MRI\s0 script files with -the option \fB\-c\fR; use the \fB\-T\fR option to run linker -scripts written in the general-purpose \fBld\fR scripting language. -If \fIMRI-cmdfile\fR does not exist, \fBld\fR looks for it in the directories -specified by any \fB\-L\fR options. -.IP "\fB\-d\fR" 4 -.IX Item "-d" -.PD 0 -.IP "\fB\-dc\fR" 4 -.IX Item "-dc" -.IP "\fB\-dp\fR" 4 -.IX Item "-dp" -.PD -These three options are equivalent; multiple forms are supported for -compatibility with other linkers. They assign space to common symbols -even if a relocatable output file is specified (with \fB\-r\fR). The -script command \f(CW\*(C`FORCE_COMMON_ALLOCATION\*(C'\fR has the same effect. -.IP "\fB\-e\fR \fIentry\fR" 4 -.IX Item "-e entry" -.PD 0 -.IP "\fB\-\-entry=\fR\fIentry\fR" 4 -.IX Item "--entry=entry" -.PD -Use \fIentry\fR as the explicit symbol for beginning execution of your -program, rather than the default entry point. If there is no symbol -named \fIentry\fR, the linker will try to parse \fIentry\fR as a number, -and use that as the entry address (the number will be interpreted in -base 10; you may use a leading \fB0x\fR for base 16, or a leading -\&\fB0\fR for base 8). -.IP "\fB\-\-exclude\-libs\fR \fIlib\fR\fB,\fR\fIlib\fR\fB,...\fR" 4 -.IX Item "--exclude-libs lib,lib,..." -Specifies a list of archive libraries from which symbols should not be automatically -exported. The library names may be delimited by commas or colons. Specifying -\&\f(CW\*(C`\-\-exclude\-libs ALL\*(C'\fR excludes symbols in all archive libraries from -automatic export. This option is available only for the i386 \s-1PE\s0 targeted -port of the linker and for \s-1ELF\s0 targeted ports. For i386 \s-1PE\s0, symbols -explicitly listed in a .def file are still exported, regardless of this -option. For \s-1ELF\s0 targeted ports, symbols affected by this option will -be treated as hidden. -.IP "\fB\-E\fR" 4 -.IX Item "-E" -.PD 0 -.IP "\fB\-\-export\-dynamic\fR" 4 -.IX Item "--export-dynamic" -.PD -When creating a dynamically linked executable, add all symbols to the -dynamic symbol table. The dynamic symbol table is the set of symbols -which are visible from dynamic objects at run time. -.Sp -If you do not use this option, the dynamic symbol table will normally -contain only those symbols which are referenced by some dynamic object -mentioned in the link. -.Sp -If you use \f(CW\*(C`dlopen\*(C'\fR to load a dynamic object which needs to refer -back to the symbols defined by the program, rather than some other -dynamic object, then you will probably need to use this option when -linking the program itself. -.Sp -You can also use the dynamic list to control what symbols should -be added to the dynamic symbol table if the output format supports it. -See the description of \fB\-\-dynamic\-list\fR. -.IP "\fB\-EB\fR" 4 -.IX Item "-EB" -Link big-endian objects. This affects the default output format. -.IP "\fB\-EL\fR" 4 -.IX Item "-EL" -Link little-endian objects. This affects the default output format. -.IP "\fB\-f\fR" 4 -.IX Item "-f" -.PD 0 -.IP "\fB\-\-auxiliary\fR \fIname\fR" 4 -.IX Item "--auxiliary name" -.PD -When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_AUXILIARY\s0 field -to the specified name. This tells the dynamic linker that the symbol -table of the shared object should be used as an auxiliary filter on the -symbol table of the shared object \fIname\fR. -.Sp -If you later link a program against this filter object, then, when you -run the program, the dynamic linker will see the \s-1DT_AUXILIARY\s0 field. If -the dynamic linker resolves any symbols from the filter object, it will -first check whether there is a definition in the shared object -\&\fIname\fR. If there is one, it will be used instead of the definition -in the filter object. The shared object \fIname\fR need not exist. -Thus the shared object \fIname\fR may be used to provide an alternative -implementation of certain functions, perhaps for debugging or for -machine specific performance. -.Sp -This option may be specified more than once. The \s-1DT_AUXILIARY\s0 entries -will be created in the order in which they appear on the command line. -.IP "\fB\-F\fR \fIname\fR" 4 -.IX Item "-F name" -.PD 0 -.IP "\fB\-\-filter\fR \fIname\fR" 4 -.IX Item "--filter name" -.PD -When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_FILTER\s0 field to -the specified name. This tells the dynamic linker that the symbol table -of the shared object which is being created should be used as a filter -on the symbol table of the shared object \fIname\fR. -.Sp -If you later link a program against this filter object, then, when you -run the program, the dynamic linker will see the \s-1DT_FILTER\s0 field. The -dynamic linker will resolve symbols according to the symbol table of the -filter object as usual, but it will actually link to the definitions -found in the shared object \fIname\fR. Thus the filter object can be -used to select a subset of the symbols provided by the object -\&\fIname\fR. -.Sp -Some older linkers used the \fB\-F\fR option throughout a compilation -toolchain for specifying object-file format for both input and output -object files. -The \s-1GNU\s0 linker uses other mechanisms for this purpose: the -\&\fB\-b\fR, \fB\-\-format\fR, \fB\-\-oformat\fR options, the -\&\f(CW\*(C`TARGET\*(C'\fR command in linker scripts, and the \f(CW\*(C`GNUTARGET\*(C'\fR -environment variable. -The \s-1GNU\s0 linker will ignore the \fB\-F\fR option when not -creating an \s-1ELF\s0 shared object. -.IP "\fB\-fini\fR \fIname\fR" 4 -.IX Item "-fini name" -When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the -executable or shared object is unloaded, by setting \s-1DT_FINI\s0 to the -address of the function. By default, the linker uses \f(CW\*(C`_fini\*(C'\fR as -the function to call. -.IP "\fB\-g\fR" 4 -.IX Item "-g" -Ignored. Provided for compatibility with other tools. -.IP "\fB\-G\fR\fIvalue\fR" 4 -.IX Item "-Gvalue" -.PD 0 -.IP "\fB\-\-gpsize=\fR\fIvalue\fR" 4 -.IX Item "--gpsize=value" -.PD -Set the maximum size of objects to be optimized using the \s-1GP\s0 register to -\&\fIsize\fR. This is only meaningful for object file formats such as -\&\s-1MIPS\s0 \s-1ECOFF\s0 which supports putting large and small objects into different -sections. This is ignored for other object file formats. -.IP "\fB\-h\fR\fIname\fR" 4 -.IX Item "-hname" -.PD 0 -.IP "\fB\-soname=\fR\fIname\fR" 4 -.IX Item "-soname=name" -.PD -When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_SONAME\s0 field to -the specified name. When an executable is linked with a shared object -which has a \s-1DT_SONAME\s0 field, then when the executable is run the dynamic -linker will attempt to load the shared object specified by the \s-1DT_SONAME\s0 -field rather than the using the file name given to the linker. -.IP "\fB\-i\fR" 4 -.IX Item "-i" -Perform an incremental link (same as option \fB\-r\fR). -.IP "\fB\-init\fR \fIname\fR" 4 -.IX Item "-init name" -When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the -executable or shared object is loaded, by setting \s-1DT_INIT\s0 to the address -of the function. By default, the linker uses \f(CW\*(C`_init\*(C'\fR as the -function to call. -.IP "\fB\-l\fR\fInamespec\fR" 4 -.IX Item "-lnamespec" -.PD 0 -.IP "\fB\-\-library=\fR\fInamespec\fR" 4 -.IX Item "--library=namespec" -.PD -Add the archive or object file specified by \fInamespec\fR to the -list of files to link. This option may be used any number of times. -If \fInamespec\fR is of the form \fI:\fIfilename\fI\fR, \fBld\fR -will search the library path for a file called \fIfilename\fR, otherise it -will search the library path for a file called \fIlib\fInamespec\fI.a\fR. -.Sp -On systems which support shared libraries, \fBld\fR may also search for -files other than \fIlib\fInamespec\fI.a\fR. Specifically, on \s-1ELF\s0 -and SunOS systems, \fBld\fR will search a directory for a library -called \fIlib\fInamespec\fI.so\fR before searching for one called -\&\fIlib\fInamespec\fI.a\fR. (By convention, a \f(CW\*(C`.so\*(C'\fR extension -indicates a shared library.) Note that this behavior does not apply -to \fI:\fIfilename\fI\fR, which always specifies a file called -\&\fIfilename\fR. -.Sp -The linker will search an archive only once, at the location where it is -specified on the command line. If the archive defines a symbol which -was undefined in some object which appeared before the archive on the -command line, the linker will include the appropriate file(s) from the -archive. However, an undefined symbol in an object appearing later on -the command line will not cause the linker to search the archive again. -.Sp -See the \fB\-(\fR option for a way to force the linker to search -archives multiple times. -.Sp -You may list the same archive multiple times on the command line. -.Sp -This type of archive searching is standard for Unix linkers. However, -if you are using \fBld\fR on \s-1AIX\s0, note that it is different from the -behaviour of the \s-1AIX\s0 linker. -.IP "\fB\-L\fR\fIsearchdir\fR" 4 -.IX Item "-Lsearchdir" -.PD 0 -.IP "\fB\-\-library\-path=\fR\fIsearchdir\fR" 4 -.IX Item "--library-path=searchdir" -.PD -Add path \fIsearchdir\fR to the list of paths that \fBld\fR will search -for archive libraries and \fBld\fR control scripts. You may use this -option any number of times. The directories are searched in the order -in which they are specified on the command line. Directories specified -on the command line are searched before the default directories. All -\&\fB\-L\fR options apply to all \fB\-l\fR options, regardless of the -order in which the options appear. -.Sp -If \fIsearchdir\fR begins with \f(CW\*(C`=\*(C'\fR, then the \f(CW\*(C`=\*(C'\fR will be replaced -by the \fIsysroot prefix\fR, a path specified when the linker is configured. -.Sp -The default set of paths searched (without being specified with -\&\fB\-L\fR) depends on which emulation mode \fBld\fR is using, and in -some cases also on how it was configured. -.Sp -The paths can also be specified in a link script with the -\&\f(CW\*(C`SEARCH_DIR\*(C'\fR command. Directories specified this way are searched -at the point in which the linker script appears in the command line. -.IP "\fB\-m\fR\fIemulation\fR" 4 -.IX Item "-memulation" -Emulate the \fIemulation\fR linker. You can list the available -emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. -.Sp -If the \fB\-m\fR option is not used, the emulation is taken from the -\&\f(CW\*(C`LDEMULATION\*(C'\fR environment variable, if that is defined. -.Sp -Otherwise, the default emulation depends upon how the linker was -configured. -.IP "\fB\-M\fR" 4 -.IX Item "-M" -.PD 0 -.IP "\fB\-\-print\-map\fR" 4 -.IX Item "--print-map" -.PD -Print a link map to the standard output. A link map provides -information about the link, including the following: -.RS 4 -.IP "\(bu" 4 -Where object files are mapped into memory. -.IP "\(bu" 4 -How common symbols are allocated. -.IP "\(bu" 4 -All archive members included in the link, with a mention of the symbol -which caused the archive member to be brought in. -.IP "\(bu" 4 -The values assigned to symbols. -.Sp -Note \- symbols whose values are computed by an expression which -involves a reference to a previous value of the same symbol may not -have correct result displayed in the link map. This is because the -linker discards intermediate results and only retains the final value -of an expression. Under such circumstances the linker will display -the final value enclosed by square brackets. Thus for example a -linker script containing: -.Sp -.Vb 3 -\& foo = 1 -\& foo = foo * 4 -\& foo = foo + 8 -.Ve -.Sp -will produce the following output in the link map if the \fB\-M\fR -option is used: -.Sp -.Vb 3 -\& 0x00000001 foo = 0x1 -\& [0x0000000c] foo = (foo * 0x4) -\& [0x0000000c] foo = (foo + 0x8) -.Ve -.Sp -See \fBExpressions\fR for more information about expressions in linker -scripts. -.RE -.RS 4 -.RE -.IP "\fB\-n\fR" 4 -.IX Item "-n" -.PD 0 -.IP "\fB\-\-nmagic\fR" 4 -.IX Item "--nmagic" -.PD -Turn off page alignment of sections, and mark the output as -\&\f(CW\*(C`NMAGIC\*(C'\fR if possible. -.IP "\fB\-N\fR" 4 -.IX Item "-N" -.PD 0 -.IP "\fB\-\-omagic\fR" 4 -.IX Item "--omagic" -.PD -Set the text and data sections to be readable and writable. Also, do -not page-align the data segment, and disable linking against shared -libraries. If the output format supports Unix style magic numbers, -mark the output as \f(CW\*(C`OMAGIC\*(C'\fR. Note: Although a writable text section -is allowed for PE-COFF targets, it does not conform to the format -specification published by Microsoft. -.IP "\fB\-\-no\-omagic\fR" 4 -.IX Item "--no-omagic" -This option negates most of the effects of the \fB\-N\fR option. It -sets the text section to be read-only, and forces the data segment to -be page-aligned. Note \- this option does not enable linking against -shared libraries. Use \fB\-Bdynamic\fR for this. -.IP "\fB\-o\fR \fIoutput\fR" 4 -.IX Item "-o output" -.PD 0 -.IP "\fB\-\-output=\fR\fIoutput\fR" 4 -.IX Item "--output=output" -.PD -Use \fIoutput\fR as the name for the program produced by \fBld\fR; if this -option is not specified, the name \fIa.out\fR is used by default. The -script command \f(CW\*(C`OUTPUT\*(C'\fR can also specify the output file name. -.IP "\fB\-O\fR \fIlevel\fR" 4 -.IX Item "-O level" -If \fIlevel\fR is a numeric values greater than zero \fBld\fR optimizes -the output. This might take significantly longer and therefore probably -should only be enabled for the final binary. -.IP "\fB\-q\fR" 4 -.IX Item "-q" -.PD 0 -.IP "\fB\-\-emit\-relocs\fR" 4 -.IX Item "--emit-relocs" -.PD -Leave relocation sections and contents in fully linked executables. -Post link analysis and optimization tools may need this information in -order to perform correct modifications of executables. This results -in larger executables. -.Sp -This option is currently only supported on \s-1ELF\s0 platforms. -.IP "\fB\-\-force\-dynamic\fR" 4 -.IX Item "--force-dynamic" -Force the output file to have dynamic sections. This option is specific -to VxWorks targets. -.IP "\fB\-r\fR" 4 -.IX Item "-r" -.PD 0 -.IP "\fB\-\-relocatable\fR" 4 -.IX Item "--relocatable" -.PD -Generate relocatable output\-\-\-i.e., generate an output file that can in -turn serve as input to \fBld\fR. This is often called \fIpartial -linking\fR. As a side effect, in environments that support standard Unix -magic numbers, this option also sets the output file's magic number to -\&\f(CW\*(C`OMAGIC\*(C'\fR. -If this option is not specified, an absolute file is produced. When -linking \*(C+ programs, this option \fIwill not\fR resolve references to -constructors; to do that, use \fB\-Ur\fR. -.Sp -When an input file does not have the same format as the output file, -partial linking is only supported if that input file does not contain any -relocations. Different output formats can have further restrictions; for -example some \f(CW\*(C`a.out\*(C'\fR\-based formats do not support partial linking -with input files in other formats at all. -.Sp -This option does the same thing as \fB\-i\fR. -.IP "\fB\-R\fR \fIfilename\fR" 4 -.IX Item "-R filename" -.PD 0 -.IP "\fB\-\-just\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--just-symbols=filename" -.PD -Read symbol names and their addresses from \fIfilename\fR, but do not -relocate it or include it in the output. This allows your output file -to refer symbolically to absolute locations of memory defined in other -programs. You may use this option more than once. -.Sp -For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is -followed by a directory name, rather than a file name, it is treated as -the \fB\-rpath\fR option. -.IP "\fB\-s\fR" 4 -.IX Item "-s" -.PD 0 -.IP "\fB\-\-strip\-all\fR" 4 -.IX Item "--strip-all" -.PD -Omit all symbol information from the output file. -.IP "\fB\-S\fR" 4 -.IX Item "-S" -.PD 0 -.IP "\fB\-\-strip\-debug\fR" 4 -.IX Item "--strip-debug" -.PD -Omit debugger symbol information (but not all symbols) from the output file. -.IP "\fB\-t\fR" 4 -.IX Item "-t" -.PD 0 -.IP "\fB\-\-trace\fR" 4 -.IX Item "--trace" -.PD -Print the names of the input files as \fBld\fR processes them. -.IP "\fB\-T\fR \fIscriptfile\fR" 4 -.IX Item "-T scriptfile" -.PD 0 -.IP "\fB\-\-script=\fR\fIscriptfile\fR" 4 -.IX Item "--script=scriptfile" -.PD -Use \fIscriptfile\fR as the linker script. This script replaces -\&\fBld\fR's default linker script (rather than adding to it), so -\&\fIcommandfile\fR must specify everything necessary to describe the -output file. If \fIscriptfile\fR does not exist in -the current directory, \f(CW\*(C`ld\*(C'\fR looks for it in the directories -specified by any preceding \fB\-L\fR options. Multiple \fB\-T\fR -options accumulate. -.IP "\fB\-dT\fR \fIscriptfile\fR" 4 -.IX Item "-dT scriptfile" -.PD 0 -.IP "\fB\-\-default\-script=\fR\fIscriptfile\fR" 4 -.IX Item "--default-script=scriptfile" -.PD -Use \fIscriptfile\fR as the default linker script. -.Sp -This option is similar to the \fB\-\-script\fR option except that -processing of the script is delayed until after the rest of the -command line has been processed. This allows options placed after the -\&\fB\-\-default\-script\fR option on the command line to affect the -behaviour of the linker script, which can be important when the linker -command line cannot be directly controlled by the user. (eg because -the command line is being constructed by another tool, such as -\&\fBgcc\fR). -.IP "\fB\-u\fR \fIsymbol\fR" 4 -.IX Item "-u symbol" -.PD 0 -.IP "\fB\-\-undefined=\fR\fIsymbol\fR" 4 -.IX Item "--undefined=symbol" -.PD -Force \fIsymbol\fR to be entered in the output file as an undefined -symbol. Doing this may, for example, trigger linking of additional -modules from standard libraries. \fB\-u\fR may be repeated with -different option arguments to enter additional undefined symbols. This -option is equivalent to the \f(CW\*(C`EXTERN\*(C'\fR linker script command. -.IP "\fB\-Ur\fR" 4 -.IX Item "-Ur" -For anything other than \*(C+ programs, this option is equivalent to -\&\fB\-r\fR: it generates relocatable output\-\-\-i.e., an output file that can in -turn serve as input to \fBld\fR. When linking \*(C+ programs, \fB\-Ur\fR -\&\fIdoes\fR resolve references to constructors, unlike \fB\-r\fR. -It does not work to use \fB\-Ur\fR on files that were themselves linked -with \fB\-Ur\fR; once the constructor table has been built, it cannot -be added to. Use \fB\-Ur\fR only for the last partial link, and -\&\fB\-r\fR for the others. -.IP "\fB\-\-unique[=\fR\fI\s-1SECTION\s0\fR\fB]\fR" 4 -.IX Item "--unique[=SECTION]" -Creates a separate output section for every input section matching -\&\fI\s-1SECTION\s0\fR, or if the optional wildcard \fI\s-1SECTION\s0\fR argument is -missing, for every orphan input section. An orphan section is one not -specifically mentioned in a linker script. You may use this option -multiple times on the command line; It prevents the normal merging of -input sections with the same name, overriding output section assignments -in a linker script. -.IP "\fB\-v\fR" 4 -.IX Item "-v" -.PD 0 -.IP "\fB\-\-version\fR" 4 -.IX Item "--version" -.IP "\fB\-V\fR" 4 -.IX Item "-V" -.PD -Display the version number for \fBld\fR. The \fB\-V\fR option also -lists the supported emulations. -.IP "\fB\-x\fR" 4 -.IX Item "-x" -.PD 0 -.IP "\fB\-\-discard\-all\fR" 4 -.IX Item "--discard-all" -.PD -Delete all local symbols. -.IP "\fB\-X\fR" 4 -.IX Item "-X" -.PD 0 -.IP "\fB\-\-discard\-locals\fR" 4 -.IX Item "--discard-locals" -.PD -Delete all temporary local symbols. (These symbols start with -system-specific local label prefixes, typically \fB.L\fR for \s-1ELF\s0 systems -or \fBL\fR for traditional a.out systems.) -.IP "\fB\-y\fR \fIsymbol\fR" 4 -.IX Item "-y symbol" -.PD 0 -.IP "\fB\-\-trace\-symbol=\fR\fIsymbol\fR" 4 -.IX Item "--trace-symbol=symbol" -.PD -Print the name of each linked file in which \fIsymbol\fR appears. This -option may be given any number of times. On many systems it is necessary -to prepend an underscore. -.Sp -This option is useful when you have an undefined symbol in your link but -don't know where the reference is coming from. -.IP "\fB\-Y\fR \fIpath\fR" 4 -.IX Item "-Y path" -Add \fIpath\fR to the default library search path. This option exists -for Solaris compatibility. -.IP "\fB\-z\fR \fIkeyword\fR" 4 -.IX Item "-z keyword" -The recognized keywords are: -.RS 4 -.IP "\fBcombreloc\fR" 4 -.IX Item "combreloc" -Combines multiple reloc sections and sorts them to make dynamic symbol -lookup caching possible. -.IP "\fBdefs\fR" 4 -.IX Item "defs" -Disallows undefined symbols in object files. Undefined symbols in -shared libraries are still allowed. -.IP "\fBexecstack\fR" 4 -.IX Item "execstack" -Marks the object as requiring executable stack. -.IP "\fBinitfirst\fR" 4 -.IX Item "initfirst" -This option is only meaningful when building a shared object. -It marks the object so that its runtime initialization will occur -before the runtime initialization of any other objects brought into -the process at the same time. Similarly the runtime finalization of -the object will occur after the runtime finalization of any other -objects. -.IP "\fBinterpose\fR" 4 -.IX Item "interpose" -Marks the object that its symbol table interposes before all symbols -but the primary executable. -.IP "\fBlazy\fR" 4 -.IX Item "lazy" -When generating an executable or shared library, mark it to tell the -dynamic linker to defer function call resolution to the point when -the function is called (lazy binding), rather than at load time. -Lazy binding is the default. -.IP "\fBloadfltr\fR" 4 -.IX Item "loadfltr" -Marks the object that its filters be processed immediately at -runtime. -.IP "\fBmuldefs\fR" 4 -.IX Item "muldefs" -Allows multiple definitions. -.IP "\fBnocombreloc\fR" 4 -.IX Item "nocombreloc" -Disables multiple reloc sections combining. -.IP "\fBnocopyreloc\fR" 4 -.IX Item "nocopyreloc" -Disables production of copy relocs. -.IP "\fBnodefaultlib\fR" 4 -.IX Item "nodefaultlib" -Marks the object that the search for dependencies of this object will -ignore any default library search paths. -.IP "\fBnodelete\fR" 4 -.IX Item "nodelete" -Marks the object shouldn't be unloaded at runtime. -.IP "\fBnodlopen\fR" 4 -.IX Item "nodlopen" -Marks the object not available to \f(CW\*(C`dlopen\*(C'\fR. -.IP "\fBnodump\fR" 4 -.IX Item "nodump" -Marks the object can not be dumped by \f(CW\*(C`dldump\*(C'\fR. -.IP "\fBnoexecstack\fR" 4 -.IX Item "noexecstack" -Marks the object as not requiring executable stack. -.IP "\fBnorelro\fR" 4 -.IX Item "norelro" -Don't create an \s-1ELF\s0 \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object. -.IP "\fBnow\fR" 4 -.IX Item "now" -When generating an executable or shared library, mark it to tell the -dynamic linker to resolve all symbols when the program is started, or -when the shared library is linked to using dlopen, instead of -deferring function call resolution to the point when the function is -first called. -.IP "\fBorigin\fR" 4 -.IX Item "origin" -Marks the object may contain \f(CW$ORIGIN\fR. -.IP "\fBrelro\fR" 4 -.IX Item "relro" -Create an \s-1ELF\s0 \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object. -.IP "\fBmax\-page\-size=\fR\fIvalue\fR" 4 -.IX Item "max-page-size=value" -Set the emulation maximum page size to \fIvalue\fR. -.IP "\fBcommon\-page\-size=\fR\fIvalue\fR" 4 -.IX Item "common-page-size=value" -Set the emulation common page size to \fIvalue\fR. -.RE -.RS 4 -.Sp -Other keywords are ignored for Solaris compatibility. -.RE -.IP "\fB\-(\fR \fIarchives\fR \fB\-)\fR" 4 -.IX Item "-( archives -)" -.PD 0 -.IP "\fB\-\-start\-group\fR \fIarchives\fR \fB\-\-end\-group\fR" 4 -.IX Item "--start-group archives --end-group" -.PD -The \fIarchives\fR should be a list of archive files. They may be -either explicit file names, or \fB\-l\fR options. -.Sp -The specified archives are searched repeatedly until no new undefined -references are created. Normally, an archive is searched only once in -the order that it is specified on the command line. If a symbol in that -archive is needed to resolve an undefined symbol referred to by an -object in an archive that appears later on the command line, the linker -would not be able to resolve that reference. By grouping the archives, -they all be searched repeatedly until all possible references are -resolved. -.Sp -Using this option has a significant performance cost. It is best to use -it only when there are unavoidable circular references between two or -more archives. -.IP "\fB\-\-accept\-unknown\-input\-arch\fR" 4 -.IX Item "--accept-unknown-input-arch" -.PD 0 -.IP "\fB\-\-no\-accept\-unknown\-input\-arch\fR" 4 -.IX Item "--no-accept-unknown-input-arch" -.PD -Tells the linker to accept input files whose architecture cannot be -recognised. The assumption is that the user knows what they are doing -and deliberately wants to link in these unknown input files. This was -the default behaviour of the linker, before release 2.14. The default -behaviour from release 2.14 onwards is to reject such input files, and -so the \fB\-\-accept\-unknown\-input\-arch\fR option has been added to -restore the old behaviour. -.IP "\fB\-\-add\-needed\fR" 4 -.IX Item "--add-needed" -.PD 0 -.IP "\fB\-\-no\-add\-needed\fR" 4 -.IX Item "--no-add-needed" -.PD -This option affects the treatment of dynamic libraries from \s-1ELF\s0 -\&\s-1DT_NEEDED\s0 tags in dynamic libraries mentioned on the command line after -the \fB\-\-add\-needed\fR option. Normally, the linker will not copy -a \s-1DT_NEEDED\s0 tags from each dynamic library to the produced output object. -\&\fB\-\-add\-needed\fR makes linker to copy \s-1DT_NEEDED\s0 tags from all -dynamic libraries mentioned after this flag. -\fB\-\-no\-add\-needed\fR restores the default behaviour. -.IP "\fB\-\-as\-needed\fR" 4 -.IX Item "--as-needed" -.PD 0 -.IP "\fB\-\-no\-as\-needed\fR" 4 -.IX Item "--no-as-needed" -.PD -This option affects \s-1ELF\s0 \s-1DT_NEEDED\s0 tags for dynamic -libraries mentioned on the command line after the \fB\-\-as\-needed\fR -option when \fB\-\-add\-needed\fR is in effect. -In such a case \fB\-\-as\-needed\fR causes \s-1DT_NEEDED\s0 tags -to only be emitted for libraries that satisfy some symbol reference -from regular objects which is undefined at the point that the library -was linked. -\&\fB\-\-no\-as\-needed\fR restores the default behaviour. -.IP "\fB\-assert\fR \fIkeyword\fR" 4 -.IX Item "-assert keyword" -This option is ignored for SunOS compatibility. -.IP "\fB\-Bdynamic\fR" 4 -.IX Item "-Bdynamic" -.PD 0 -.IP "\fB\-dy\fR" 4 -.IX Item "-dy" -.IP "\fB\-call_shared\fR" 4 -.IX Item "-call_shared" -.PD -Link against dynamic libraries. This is only meaningful on platforms -for which shared libraries are supported. This option is normally the -default on such platforms. The different variants of this option are -for compatibility with various systems. You may use this option -multiple times on the command line: it affects library searching for -\&\fB\-l\fR options which follow it. -.IP "\fB\-Bgroup\fR" 4 -.IX Item "-Bgroup" -Set the \f(CW\*(C`DF_1_GROUP\*(C'\fR flag in the \f(CW\*(C`DT_FLAGS_1\*(C'\fR entry in the dynamic -section. This causes the runtime linker to handle lookups in this -object and its dependencies to be performed only inside the group. -\&\fB\-\-unresolved\-symbols=report\-all\fR is implied. This option is -only meaningful on \s-1ELF\s0 platforms which support shared libraries. -.IP "\fB\-Bstatic\fR" 4 -.IX Item "-Bstatic" -.PD 0 -.IP "\fB\-dn\fR" 4 -.IX Item "-dn" -.IP "\fB\-non_shared\fR" 4 -.IX Item "-non_shared" -.IP "\fB\-static\fR" 4 -.IX Item "-static" -.PD -Do not link against shared libraries. This is only meaningful on -platforms for which shared libraries are supported. The different -variants of this option are for compatibility with various systems. You -may use this option multiple times on the command line: it affects -library searching for \fB\-l\fR options which follow it. This -option also implies \fB\-\-unresolved\-symbols=report\-all\fR. This -option can be used with \fB\-shared\fR. Doing so means that a -shared library is being created but that all of the library's external -references must be resolved by pulling in entries from static -libraries. -.IP "\fB\-Bsymbolic\fR" 4 -.IX Item "-Bsymbolic" -When creating a shared library, bind references to global symbols to the -definition within the shared library, if any. Normally, it is possible -for a program linked against a shared library to override the definition -within the shared library. This option is only meaningful on \s-1ELF\s0 -platforms which support shared libraries. -.IP "\fB\-Bsymbolic\-functions\fR" 4 -.IX Item "-Bsymbolic-functions" -When creating a shared library, bind references to global function -symbols to the definition within the shared library, if any. -This option is only meaningful on \s-1ELF\s0 platforms which support shared -libraries. -.IP "\fB\-\-dynamic\-list=\fR\fIdynamic-list-file\fR" 4 -.IX Item "--dynamic-list=dynamic-list-file" -Specify the name of a dynamic list file to the linker. This is -typically used when creating shared libraries to specify a list of -global symbols whose references shouldn't be bound to the definition -within the shared library, or creating dynamically linked executables -to specify a list of symbols which should be added to the symbol table -in the executable. This option is only meaningful on \s-1ELF\s0 platforms -which support shared libraries. -.Sp -The format of the dynamic list is the same as the version node without -scope and node name. See \fB\s-1VERSION\s0\fR for more information. -.IP "\fB\-\-dynamic\-list\-data\fR" 4 -.IX Item "--dynamic-list-data" -Include all global data symbols to the dynamic list. -.IP "\fB\-\-dynamic\-list\-cpp\-new\fR" 4 -.IX Item "--dynamic-list-cpp-new" -Provide the builtin dynamic list for \*(C+ operator new and delete. It -is mainly useful for building shared libstdc++. -.IP "\fB\-\-dynamic\-list\-cpp\-typeinfo\fR" 4 -.IX Item "--dynamic-list-cpp-typeinfo" -Provide the builtin dynamic list for \*(C+ runtime type identification. -.IP "\fB\-\-check\-sections\fR" 4 -.IX Item "--check-sections" -.PD 0 -.IP "\fB\-\-no\-check\-sections\fR" 4 -.IX Item "--no-check-sections" -.PD -Asks the linker \fInot\fR to check section addresses after they have -been assigned to see if there are any overlaps. Normally the linker will -perform this check, and if it finds any overlaps it will produce -suitable error messages. The linker does know about, and does make -allowances for sections in overlays. The default behaviour can be -restored by using the command line switch \fB\-\-check\-sections\fR. -.IP "\fB\-\-cref\fR" 4 -.IX Item "--cref" -Output a cross reference table. If a linker map file is being -generated, the cross reference table is printed to the map file. -Otherwise, it is printed on the standard output. -.Sp -The format of the table is intentionally simple, so that it may be -easily processed by a script if necessary. The symbols are printed out, -sorted by name. For each symbol, a list of file names is given. If the -symbol is defined, the first file listed is the location of the -definition. The remaining files contain references to the symbol. -.IP "\fB\-\-no\-define\-common\fR" 4 -.IX Item "--no-define-common" -This option inhibits the assignment of addresses to common symbols. -The script command \f(CW\*(C`INHIBIT_COMMON_ALLOCATION\*(C'\fR has the same effect. -.Sp -The \fB\-\-no\-define\-common\fR option allows decoupling -the decision to assign addresses to Common symbols from the choice -of the output file type; otherwise a non-Relocatable output type -forces assigning addresses to Common symbols. -Using \fB\-\-no\-define\-common\fR allows Common symbols that are referenced -from a shared library to be assigned addresses only in the main program. -This eliminates the unused duplicate space in the shared library, -and also prevents any possible confusion over resolving to the wrong -duplicate when there are many dynamic modules with specialized search -paths for runtime symbol resolution. -.IP "\fB\-\-defsym\fR \fIsymbol\fR\fB=\fR\fIexpression\fR" 4 -.IX Item "--defsym symbol=expression" -Create a global symbol in the output file, containing the absolute -address given by \fIexpression\fR. You may use this option as many -times as necessary to define multiple symbols in the command line. A -limited form of arithmetic is supported for the \fIexpression\fR in this -context: you may give a hexadecimal constant or the name of an existing -symbol, or use \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`\-\*(C'\fR to add or subtract hexadecimal -constants or symbols. If you need more elaborate expressions, consider -using the linker command language from a script. \fINote:\fR there should be no white -space between \fIsymbol\fR, the equals sign ("\fB=\fR"), and -\&\fIexpression\fR. -.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 -.IX Item "--demangle[=style]" -.PD 0 -.IP "\fB\-\-no\-demangle\fR" 4 -.IX Item "--no-demangle" -.PD -These options control whether to demangle symbol names in error messages -and other output. When the linker is told to demangle, it tries to -present symbol names in a readable fashion: it strips leading -underscores if they are used by the object file format, and converts \*(C+ -mangled symbol names into user readable names. Different compilers have -different mangling styles. The optional demangling style argument can be used -to choose an appropriate demangling style for your compiler. The linker will -demangle by default unless the environment variable \fB\s-1COLLECT_NO_DEMANGLE\s0\fR -is set. These options may be used to override the default. -.IP "\fB\-\-dynamic\-linker\fR \fIfile\fR" 4 -.IX Item "--dynamic-linker file" -Set the name of the dynamic linker. This is only meaningful when -generating dynamically linked \s-1ELF\s0 executables. The default dynamic -linker is normally correct; don't use this unless you know what you are -doing. -.IP "\fB\-\-fatal\-warnings\fR" 4 -.IX Item "--fatal-warnings" -Treat all warnings as errors. -.IP "\fB\-\-force\-exe\-suffix\fR" 4 -.IX Item "--force-exe-suffix" -Make sure that an output file has a .exe suffix. -.Sp -If a successfully built fully linked output file does not have a -\&\f(CW\*(C`.exe\*(C'\fR or \f(CW\*(C`.dll\*(C'\fR suffix, this option forces the linker to copy -the output file to one of the same name with a \f(CW\*(C`.exe\*(C'\fR suffix. This -option is useful when using unmodified Unix makefiles on a Microsoft -Windows host, since some versions of Windows won't run an image unless -it ends in a \f(CW\*(C`.exe\*(C'\fR suffix. -.IP "\fB\-\-gc\-sections\fR" 4 -.IX Item "--gc-sections" -.PD 0 -.IP "\fB\-\-no\-gc\-sections\fR" 4 -.IX Item "--no-gc-sections" -.PD -Enable garbage collection of unused input sections. It is ignored on -targets that do not support this option. This option is not compatible -with \fB\-r\fR or \fB\-\-emit\-relocs\fR. The default behaviour (of not -performing this garbage collection) can be restored by specifying -\&\fB\-\-no\-gc\-sections\fR on the command line. -.IP "\fB\-\-print\-gc\-sections\fR" 4 -.IX Item "--print-gc-sections" -.PD 0 -.IP "\fB\-\-no\-print\-gc\-sections\fR" 4 -.IX Item "--no-print-gc-sections" -.PD -List all sections removed by garbage collection. The listing is -printed on stderr. This option is only effective if garbage -collection has been enabled via the \fB\-\-gc\-sections\fR) option. The -default behaviour (of not listing the sections that are removed) can -be restored by specifying \fB\-\-no\-print\-gc\-sections\fR on the command -line. -.IP "\fB\-\-help\fR" 4 -.IX Item "--help" -Print a summary of the command-line options on the standard output and exit. -.IP "\fB\-\-target\-help\fR" 4 -.IX Item "--target-help" -Print a summary of all target specific options on the standard output and exit. -.IP "\fB\-Map\fR \fImapfile\fR" 4 -.IX Item "-Map mapfile" -Print a link map to the file \fImapfile\fR. See the description of the -\&\fB\-M\fR option, above. -.IP "\fB\-\-no\-keep\-memory\fR" 4 -.IX Item "--no-keep-memory" -\&\fBld\fR normally optimizes for speed over memory usage by caching the -symbol tables of input files in memory. This option tells \fBld\fR to -instead optimize for memory usage, by rereading the symbol tables as -necessary. This may be required if \fBld\fR runs out of memory space -while linking a large executable. -.IP "\fB\-\-no\-undefined\fR" 4 -.IX Item "--no-undefined" -.PD 0 -.IP "\fB\-z defs\fR" 4 -.IX Item "-z defs" -.PD -Report unresolved symbol references from regular object files. This -is done even if the linker is creating a non-symbolic shared library. -The switch \fB\-\-[no\-]allow\-shlib\-undefined\fR controls the -behaviour for reporting unresolved references found in shared -libraries being linked in. -.IP "\fB\-\-allow\-multiple\-definition\fR" 4 -.IX Item "--allow-multiple-definition" -.PD 0 -.IP "\fB\-z muldefs\fR" 4 -.IX Item "-z muldefs" -.PD -Normally when a symbol is defined multiple times, the linker will -report a fatal error. These options allow multiple definitions and the -first definition will be used. -.IP "\fB\-\-allow\-shlib\-undefined\fR" 4 -.IX Item "--allow-shlib-undefined" -.PD 0 -.IP "\fB\-\-no\-allow\-shlib\-undefined\fR" 4 -.IX Item "--no-allow-shlib-undefined" -.PD -Allows (the default) or disallows undefined symbols in shared libraries. -This switch is similar to \fB\-\-no\-undefined\fR except that it -determines the behaviour when the undefined symbols are in a -shared library rather than a regular object file. It does not affect -how undefined symbols in regular object files are handled. -.Sp -The reason that \fB\-\-allow\-shlib\-undefined\fR is the default is that -the shared library being specified at link time may not be the same as -the one that is available at load time, so the symbols might actually be -resolvable at load time. Plus there are some systems, (eg BeOS) where -undefined symbols in shared libraries is normal. (The kernel patches -them at load time to select which function is most appropriate -for the current architecture. This is used for example to dynamically -select an appropriate memset function). Apparently it is also normal -for \s-1HPPA\s0 shared libraries to have undefined symbols. -.IP "\fB\-\-no\-undefined\-version\fR" 4 -.IX Item "--no-undefined-version" -Normally when a symbol has an undefined version, the linker will ignore -it. This option disallows symbols with undefined version and a fatal error -will be issued instead. -.IP "\fB\-\-default\-symver\fR" 4 -.IX Item "--default-symver" -Create and use a default symbol version (the soname) for unversioned -exported symbols. -.IP "\fB\-\-default\-imported\-symver\fR" 4 -.IX Item "--default-imported-symver" -Create and use a default symbol version (the soname) for unversioned -imported symbols. -.IP "\fB\-\-no\-warn\-mismatch\fR" 4 -.IX Item "--no-warn-mismatch" -Normally \fBld\fR will give an error if you try to link together input -files that are mismatched for some reason, perhaps because they have -been compiled for different processors or for different endiannesses. -This option tells \fBld\fR that it should silently permit such possible -errors. This option should only be used with care, in cases when you -have taken some special action that ensures that the linker errors are -inappropriate. -.IP "\fB\-\-no\-warn\-search\-mismatch\fR" 4 -.IX Item "--no-warn-search-mismatch" -Normally \fBld\fR will give a warning if it finds an incompatible -library during a library search. This option silences the warning. -.IP "\fB\-\-no\-whole\-archive\fR" 4 -.IX Item "--no-whole-archive" -Turn off the effect of the \fB\-\-whole\-archive\fR option for subsequent -archive files. -.IP "\fB\-\-noinhibit\-exec\fR" 4 -.IX Item "--noinhibit-exec" -Retain the executable output file whenever it is still usable. -Normally, the linker will not produce an output file if it encounters -errors during the link process; it exits without writing an output file -when it issues any error whatsoever. -.IP "\fB\-nostdlib\fR" 4 -.IX Item "-nostdlib" -Only search library directories explicitly specified on the -command line. Library directories specified in linker scripts -(including linker scripts specified on the command line) are ignored. -.IP "\fB\-\-oformat\fR \fIoutput-format\fR" 4 -.IX Item "--oformat output-format" -\&\fBld\fR may be configured to support more than one kind of object -file. If your \fBld\fR is configured this way, you can use the -\&\fB\-\-oformat\fR option to specify the binary format for the output -object file. Even when \fBld\fR is configured to support alternative -object formats, you don't usually need to specify this, as \fBld\fR -should be configured to produce as a default output format the most -usual format on each machine. \fIoutput-format\fR is a text string, the -name of a particular format supported by the \s-1BFD\s0 libraries. (You can -list the available binary formats with \fBobjdump \-i\fR.) The script -command \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR can also specify the output format, but -this option overrides it. -.IP "\fB\-pie\fR" 4 -.IX Item "-pie" -.PD 0 -.IP "\fB\-\-pic\-executable\fR" 4 -.IX Item "--pic-executable" -.PD -Create a position independent executable. This is currently only supported on -\&\s-1ELF\s0 platforms. Position independent executables are similar to shared -libraries in that they are relocated by the dynamic linker to the virtual -address the \s-1OS\s0 chooses for them (which can vary between invocations). Like -normal dynamically linked executables they can be executed and symbols -defined in the executable cannot be overridden by shared libraries. -.IP "\fB\-qmagic\fR" 4 -.IX Item "-qmagic" -This option is ignored for Linux compatibility. -.IP "\fB\-Qy\fR" 4 -.IX Item "-Qy" -This option is ignored for \s-1SVR4\s0 compatibility. -.IP "\fB\-\-relax\fR" 4 -.IX Item "--relax" -An option with machine dependent effects. -This option is only supported on a few targets. -.Sp -On some platforms, the \fB\-\-relax\fR option performs global -optimizations that become possible when the linker resolves addressing -in the program, such as relaxing address modes and synthesizing new -instructions in the output object file. -.Sp -On some platforms these link time global optimizations may make symbolic -debugging of the resulting executable impossible. -This is known to be -the case for the Matsushita \s-1MN10200\s0 and \s-1MN10300\s0 family of processors. -.Sp -On platforms where this is not supported, \fB\-\-relax\fR is accepted, -but ignored. -.IP "\fB\-\-retain\-symbols\-file\fR \fIfilename\fR" 4 -.IX Item "--retain-symbols-file filename" -Retain \fIonly\fR the symbols listed in the file \fIfilename\fR, -discarding all others. \fIfilename\fR is simply a flat file, with one -symbol name per line. This option is especially useful in environments -(such as VxWorks) -where a large global symbol table is accumulated gradually, to conserve -run-time memory. -.Sp -\&\fB\-\-retain\-symbols\-file\fR does \fInot\fR discard undefined symbols, -or symbols needed for relocations. -.Sp -You may only specify \fB\-\-retain\-symbols\-file\fR once in the command -line. It overrides \fB\-s\fR and \fB\-S\fR. -.IP "\fB\-rpath\fR \fIdir\fR" 4 -.IX Item "-rpath dir" -Add a directory to the runtime library search path. This is used when -linking an \s-1ELF\s0 executable with shared objects. All \fB\-rpath\fR -arguments are concatenated and passed to the runtime linker, which uses -them to locate shared objects at runtime. The \fB\-rpath\fR option is -also used when locating shared objects which are needed by shared -objects explicitly included in the link; see the description of the -\&\fB\-rpath\-link\fR option. If \fB\-rpath\fR is not used when linking an -\&\s-1ELF\s0 executable, the contents of the environment variable -\&\f(CW\*(C`LD_RUN_PATH\*(C'\fR will be used if it is defined. -.Sp -The \fB\-rpath\fR option may also be used on SunOS. By default, on -SunOS, the linker will form a runtime search patch out of all the -\&\fB\-L\fR options it is given. If a \fB\-rpath\fR option is used, the -runtime search path will be formed exclusively using the \fB\-rpath\fR -options, ignoring the \fB\-L\fR options. This can be useful when using -gcc, which adds many \fB\-L\fR options which may be on \s-1NFS\s0 mounted -file systems. -.Sp -For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is -followed by a directory name, rather than a file name, it is treated as -the \fB\-rpath\fR option. -.IP "\fB\-rpath\-link\fR \fI\s-1DIR\s0\fR" 4 -.IX Item "-rpath-link DIR" -When using \s-1ELF\s0 or SunOS, one shared library may require another. This -happens when an \f(CW\*(C`ld \-shared\*(C'\fR link includes a shared library as one -of the input files. -.Sp -When the linker encounters such a dependency when doing a non-shared, -non-relocatable link, it will automatically try to locate the required -shared library and include it in the link, if it is not included -explicitly. In such a case, the \fB\-rpath\-link\fR option -specifies the first set of directories to search. The -\&\fB\-rpath\-link\fR option may specify a sequence of directory names -either by specifying a list of names separated by colons, or by -appearing multiple times. -.Sp -This option should be used with caution as it overrides the search path -that may have been hard compiled into a shared library. In such a case it -is possible to use unintentionally a different search path than the -runtime linker would do. -.Sp -The linker uses the following search paths to locate required shared -libraries: -.RS 4 -.IP "1." 4 -Any directories specified by \fB\-rpath\-link\fR options. -.IP "2." 4 -Any directories specified by \fB\-rpath\fR options. The difference -between \fB\-rpath\fR and \fB\-rpath\-link\fR is that directories -specified by \fB\-rpath\fR options are included in the executable and -used at runtime, whereas the \fB\-rpath\-link\fR option is only effective -at link time. Searching \fB\-rpath\fR in this way is only supported -by native linkers and cross linkers which have been configured with -the \fB\-\-with\-sysroot\fR option. -.IP "3." 4 -On an \s-1ELF\s0 system, if the \fB\-rpath\fR and \f(CW\*(C`rpath\-link\*(C'\fR options -were not used, search the contents of the environment variable -\&\f(CW\*(C`LD_RUN_PATH\*(C'\fR. It is for the native linker only. -.IP "4." 4 -On SunOS, if the \fB\-rpath\fR option was not used, search any -directories specified using \fB\-L\fR options. -.IP "5." 4 -For a native linker, the contents of the environment variable -\&\f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR. -.IP "6." 4 -For a native \s-1ELF\s0 linker, the directories in \f(CW\*(C`DT_RUNPATH\*(C'\fR or -\&\f(CW\*(C`DT_RPATH\*(C'\fR of a shared library are searched for shared -libraries needed by it. The \f(CW\*(C`DT_RPATH\*(C'\fR entries are ignored if -\&\f(CW\*(C`DT_RUNPATH\*(C'\fR entries exist. -.IP "7." 4 -The default directories, normally \fI/lib\fR and \fI/usr/lib\fR. -.IP "8." 4 -For a native linker on an \s-1ELF\s0 system, if the file \fI/etc/ld.so.conf\fR -exists, the list of directories found in that file. -.RE -.RS 4 -.Sp -If the required shared library is not found, the linker will issue a -warning and continue with the link. -.RE -.IP "\fB\-shared\fR" 4 -.IX Item "-shared" -.PD 0 -.IP "\fB\-Bshareable\fR" 4 -.IX Item "-Bshareable" -.PD -Create a shared library. This is currently only supported on \s-1ELF\s0, \s-1XCOFF\s0 -and SunOS platforms. On SunOS, the linker will automatically create a -shared library if the \fB\-e\fR option is not used and there are -undefined symbols in the link. -.IP "\fB\-\-sort\-common\fR" 4 -.IX Item "--sort-common" -This option tells \fBld\fR to sort the common symbols by size when it -places them in the appropriate output sections. First come all the one -byte symbols, then all the two byte, then all the four byte, and then -everything else. This is to prevent gaps between symbols due to -alignment constraints. -.IP "\fB\-\-sort\-section name\fR" 4 -.IX Item "--sort-section name" -This option will apply \f(CW\*(C`SORT_BY_NAME\*(C'\fR to all wildcard section -patterns in the linker script. -.IP "\fB\-\-sort\-section alignment\fR" 4 -.IX Item "--sort-section alignment" -This option will apply \f(CW\*(C`SORT_BY_ALIGNMENT\*(C'\fR to all wildcard section -patterns in the linker script. -.IP "\fB\-\-split\-by\-file [\fR\fIsize\fR\fB]\fR" 4 -.IX Item "--split-by-file [size]" -Similar to \fB\-\-split\-by\-reloc\fR but creates a new output section for -each input file when \fIsize\fR is reached. \fIsize\fR defaults to a -size of 1 if not given. -.IP "\fB\-\-split\-by\-reloc [\fR\fIcount\fR\fB]\fR" 4 -.IX Item "--split-by-reloc [count]" -Tries to creates extra sections in the output file so that no single -output section in the file contains more than \fIcount\fR relocations. -This is useful when generating huge relocatable files for downloading into -certain real time kernels with the \s-1COFF\s0 object file format; since \s-1COFF\s0 -cannot represent more than 65535 relocations in a single section. Note -that this will fail to work with object file formats which do not -support arbitrary sections. The linker will not split up individual -input sections for redistribution, so if a single input section contains -more than \fIcount\fR relocations one output section will contain that -many relocations. \fIcount\fR defaults to a value of 32768. -.IP "\fB\-\-stats\fR" 4 -.IX Item "--stats" -Compute and display statistics about the operation of the linker, such -as execution time and memory usage. -.IP "\fB\-\-sysroot=\fR\fIdirectory\fR" 4 -.IX Item "--sysroot=directory" -Use \fIdirectory\fR as the location of the sysroot, overriding the -configure-time default. This option is only supported by linkers -that were configured using \fB\-\-with\-sysroot\fR. -.IP "\fB\-\-traditional\-format\fR" 4 -.IX Item "--traditional-format" -For some targets, the output of \fBld\fR is different in some ways from -the output of some existing linker. This switch requests \fBld\fR to -use the traditional format instead. -.Sp -For example, on SunOS, \fBld\fR combines duplicate entries in the -symbol string table. This can reduce the size of an output file with -full debugging information by over 30 percent. Unfortunately, the SunOS -\&\f(CW\*(C`dbx\*(C'\fR program can not read the resulting program (\f(CW\*(C`gdb\*(C'\fR has no -trouble). The \fB\-\-traditional\-format\fR switch tells \fBld\fR to not -combine duplicate entries. -.IP "\fB\-\-section\-start\fR \fIsectionname\fR\fB=\fR\fIorg\fR" 4 -.IX Item "--section-start sectionname=org" -Locate a section in the output file at the absolute -address given by \fIorg\fR. You may use this option as many -times as necessary to locate multiple sections in the command -line. -\&\fIorg\fR must be a single hexadecimal integer; -for compatibility with other linkers, you may omit the leading -\&\fB0x\fR usually associated with hexadecimal values. \fINote:\fR there -should be no white space between \fIsectionname\fR, the equals -sign ("\fB=\fR"), and \fIorg\fR. -.IP "\fB\-Tbss\fR \fIorg\fR" 4 -.IX Item "-Tbss org" -.PD 0 -.IP "\fB\-Tdata\fR \fIorg\fR" 4 -.IX Item "-Tdata org" -.IP "\fB\-Ttext\fR \fIorg\fR" 4 -.IX Item "-Ttext org" -.PD -Same as \-\-section\-start, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or -\&\f(CW\*(C`.text\*(C'\fR as the \fIsectionname\fR. -.IP "\fB\-\-unresolved\-symbols=\fR\fImethod\fR" 4 -.IX Item "--unresolved-symbols=method" -Determine how to handle unresolved symbols. There are four possible -values for \fBmethod\fR: -.RS 4 -.IP "\fBignore-all\fR" 4 -.IX Item "ignore-all" -Do not report any unresolved symbols. -.IP "\fBreport-all\fR" 4 -.IX Item "report-all" -Report all unresolved symbols. This is the default. -.IP "\fBignore-in-object-files\fR" 4 -.IX Item "ignore-in-object-files" -Report unresolved symbols that are contained in shared libraries, but -ignore them if they come from regular object files. -.IP "\fBignore-in-shared-libs\fR" 4 -.IX Item "ignore-in-shared-libs" -Report unresolved symbols that come from regular object files, but -ignore them if they come from shared libraries. This can be useful -when creating a dynamic binary and it is known that all the shared -libraries that it should be referencing are included on the linker's -command line. -.RE -.RS 4 -.Sp -The behaviour for shared libraries on their own can also be controlled -by the \fB\-\-[no\-]allow\-shlib\-undefined\fR option. -.Sp -Normally the linker will generate an error message for each reported -unresolved symbol but the option \fB\-\-warn\-unresolved\-symbols\fR -can change this to a warning. -.RE -.IP "\fB\-\-dll\-verbose\fR" 4 -.IX Item "--dll-verbose" -.PD 0 -.IP "\fB\-\-verbose\fR" 4 -.IX Item "--verbose" -.PD -Display the version number for \fBld\fR and list the linker emulations -supported. Display which input files can and cannot be opened. Display -the linker script being used by the linker. -.IP "\fB\-\-version\-script=\fR\fIversion-scriptfile\fR" 4 -.IX Item "--version-script=version-scriptfile" -Specify the name of a version script to the linker. This is typically -used when creating shared libraries to specify additional information -about the version hierarchy for the library being created. This option -is only meaningful on \s-1ELF\s0 platforms which support shared libraries. -.IP "\fB\-\-warn\-common\fR" 4 -.IX Item "--warn-common" -Warn when a common symbol is combined with another common symbol or with -a symbol definition. Unix linkers allow this somewhat sloppy practise, -but linkers on some other operating systems do not. This option allows -you to find potential problems from combining global symbols. -Unfortunately, some C libraries use this practise, so you may get some -warnings about symbols in the libraries as well as in your programs. -.Sp -There are three kinds of global symbols, illustrated here by C examples: -.RS 4 -.IP "\fBint i = 1;\fR" 4 -.IX Item "int i = 1;" -A definition, which goes in the initialized data section of the output -file. -.IP "\fBextern int i;\fR" 4 -.IX Item "extern int i;" -An undefined reference, which does not allocate space. -There must be either a definition or a common symbol for the -variable somewhere. -.IP "\fBint i;\fR" 4 -.IX Item "int i;" -A common symbol. If there are only (one or more) common symbols for a -variable, it goes in the uninitialized data area of the output file. -The linker merges multiple common symbols for the same variable into a -single symbol. If they are of different sizes, it picks the largest -size. The linker turns a common symbol into a declaration, if there is -a definition of the same variable. -.RE -.RS 4 -.Sp -The \fB\-\-warn\-common\fR option can produce five kinds of warnings. -Each warning consists of a pair of lines: the first describes the symbol -just encountered, and the second describes the previous symbol -encountered with the same name. One or both of the two symbols will be -a common symbol. -.IP "1." 4 -Turning a common symbol into a reference, because there is already a -definition for the symbol. -.Sp -.Vb 3 -\& (
): warning: common of \`\*(Aq -\& overridden by definition -\& (
): warning: defined here -.Ve -.IP "2." 4 -Turning a common symbol into a reference, because a later definition for -the symbol is encountered. This is the same as the previous case, -except that the symbols are encountered in a different order. -.Sp -.Vb 3 -\& (
): warning: definition of \`\*(Aq -\& overriding common -\& (
): warning: common is here -.Ve -.IP "3." 4 -Merging a common symbol with a previous same-sized common symbol. -.Sp -.Vb 3 -\& (
): warning: multiple common -\& of \`\*(Aq -\& (
): warning: previous common is here -.Ve -.IP "4." 4 -Merging a common symbol with a previous larger common symbol. -.Sp -.Vb 3 -\& (
): warning: common of \`\*(Aq -\& overridden by larger common -\& (
): warning: larger common is here -.Ve -.IP "5." 4 -Merging a common symbol with a previous smaller common symbol. This is -the same as the previous case, except that the symbols are -encountered in a different order. -.Sp -.Vb 3 -\& (
): warning: common of \`\*(Aq -\& overriding smaller common -\& (
): warning: smaller common is here -.Ve -.RE -.RS 4 -.RE -.IP "\fB\-\-warn\-constructors\fR" 4 -.IX Item "--warn-constructors" -Warn if any global constructors are used. This is only useful for a few -object file formats. For formats like \s-1COFF\s0 or \s-1ELF\s0, the linker can not -detect the use of global constructors. -.IP "\fB\-\-warn\-multiple\-gp\fR" 4 -.IX Item "--warn-multiple-gp" -Warn if multiple global pointer values are required in the output file. -This is only meaningful for certain processors, such as the Alpha. -Specifically, some processors put large-valued constants in a special -section. A special register (the global pointer) points into the middle -of this section, so that constants can be loaded efficiently via a -base-register relative addressing mode. Since the offset in -base-register relative mode is fixed and relatively small (e.g., 16 -bits), this limits the maximum size of the constant pool. Thus, in -large programs, it is often necessary to use multiple global pointer -values in order to be able to address all possible constants. This -option causes a warning to be issued whenever this case occurs. -.IP "\fB\-\-warn\-once\fR" 4 -.IX Item "--warn-once" -Only warn once for each undefined symbol, rather than once per module -which refers to it. -.IP "\fB\-\-warn\-section\-align\fR" 4 -.IX Item "--warn-section-align" -Warn if the address of an output section is changed because of -alignment. Typically, the alignment will be set by an input section. -The address will only be changed if it not explicitly specified; that -is, if the \f(CW\*(C`SECTIONS\*(C'\fR command does not specify a start address for -the section. -.IP "\fB\-\-warn\-shared\-textrel\fR" 4 -.IX Item "--warn-shared-textrel" -Warn if the linker adds a \s-1DT_TEXTREL\s0 to a shared object. -.IP "\fB\-\-warn\-unresolved\-symbols\fR" 4 -.IX Item "--warn-unresolved-symbols" -If the linker is going to report an unresolved symbol (see the option -\&\fB\-\-unresolved\-symbols\fR) it will normally generate an error. -This option makes it generate a warning instead. -.IP "\fB\-\-error\-unresolved\-symbols\fR" 4 -.IX Item "--error-unresolved-symbols" -This restores the linker's default behaviour of generating errors when -it is reporting unresolved symbols. -.IP "\fB\-\-whole\-archive\fR" 4 -.IX Item "--whole-archive" -For each archive mentioned on the command line after the -\&\fB\-\-whole\-archive\fR option, include every object file in the archive -in the link, rather than searching the archive for the required object -files. This is normally used to turn an archive file into a shared -library, forcing every object to be included in the resulting shared -library. This option may be used more than once. -.Sp -Two notes when using this option from gcc: First, gcc doesn't know -about this option, so you have to use \fB\-Wl,\-whole\-archive\fR. -Second, don't forget to use \fB\-Wl,\-no\-whole\-archive\fR after your -list of archives, because gcc will add its own list of archives to -your link and you may not want this flag to affect those as well. -.IP "\fB\-\-wrap\fR \fIsymbol\fR" 4 -.IX Item "--wrap symbol" -Use a wrapper function for \fIsymbol\fR. Any undefined reference to -\&\fIsymbol\fR will be resolved to \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. Any -undefined reference to \f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR will be resolved to -\&\fIsymbol\fR. -.Sp -This can be used to provide a wrapper for a system function. The -wrapper function should be called \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. If it -wishes to call the system function, it should call -\&\f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR. -.Sp -Here is a trivial example: -.Sp -.Vb 6 -\& void * -\& _\|_wrap_malloc (size_t c) -\& { -\& printf ("malloc called with %zu\en", c); -\& return _\|_real_malloc (c); -\& } -.Ve -.Sp -If you link other code with this file using \fB\-\-wrap malloc\fR, then -all calls to \f(CW\*(C`malloc\*(C'\fR will call the function \f(CW\*(C`_\|_wrap_malloc\*(C'\fR -instead. The call to \f(CW\*(C`_\|_real_malloc\*(C'\fR in \f(CW\*(C`_\|_wrap_malloc\*(C'\fR will -call the real \f(CW\*(C`malloc\*(C'\fR function. -.Sp -You may wish to provide a \f(CW\*(C`_\|_real_malloc\*(C'\fR function as well, so that -links without the \fB\-\-wrap\fR option will succeed. If you do this, -you should not put the definition of \f(CW\*(C`_\|_real_malloc\*(C'\fR in the same -file as \f(CW\*(C`_\|_wrap_malloc\*(C'\fR; if you do, the assembler may resolve the -call before the linker has a chance to wrap it to \f(CW\*(C`malloc\*(C'\fR. -.IP "\fB\-\-eh\-frame\-hdr\fR" 4 -.IX Item "--eh-frame-hdr" -Request creation of \f(CW\*(C`.eh_frame_hdr\*(C'\fR section and \s-1ELF\s0 -\&\f(CW\*(C`PT_GNU_EH_FRAME\*(C'\fR segment header. -.IP "\fB\-\-enable\-new\-dtags\fR" 4 -.IX Item "--enable-new-dtags" -.PD 0 -.IP "\fB\-\-disable\-new\-dtags\fR" 4 -.IX Item "--disable-new-dtags" -.PD -This linker can create the new dynamic tags in \s-1ELF\s0. But the older \s-1ELF\s0 -systems may not understand them. If you specify -\&\fB\-\-enable\-new\-dtags\fR, the dynamic tags will be created as needed. -If you specify \fB\-\-disable\-new\-dtags\fR, no new dynamic tags will be -created. By default, the new dynamic tags are not created. Note that -those options are only available for \s-1ELF\s0 systems. -.IP "\fB\-\-hash\-size=\fR\fInumber\fR" 4 -.IX Item "--hash-size=number" -Set the default size of the linker's hash tables to a prime number -close to \fInumber\fR. Increasing this value can reduce the length of -time it takes the linker to perform its tasks, at the expense of -increasing the linker's memory requirements. Similarly reducing this -value can reduce the memory requirements at the expense of speed. -.IP "\fB\-\-hash\-style=\fR\fIstyle\fR" 4 -.IX Item "--hash-style=style" -Set the type of linker's hash table(s). \fIstyle\fR can be either -\&\f(CW\*(C`sysv\*(C'\fR for classic \s-1ELF\s0 \f(CW\*(C`.hash\*(C'\fR section, \f(CW\*(C`gnu\*(C'\fR for -new style \s-1GNU\s0 \f(CW\*(C`.gnu.hash\*(C'\fR section or \f(CW\*(C`both\*(C'\fR for both -the classic \s-1ELF\s0 \f(CW\*(C`.hash\*(C'\fR and new style \s-1GNU\s0 \f(CW\*(C`.gnu.hash\*(C'\fR -hash tables. The default is \f(CW\*(C`sysv\*(C'\fR. -.IP "\fB\-\-reduce\-memory\-overheads\fR" 4 -.IX Item "--reduce-memory-overheads" -This option reduces memory requirements at ld runtime, at the expense of -linking speed. This was introduced to select the old O(n^2) algorithm -for link map file generation, rather than the new O(n) algorithm which uses -about 40% more memory for symbol storage. -.Sp -Another effect of the switch is to set the default hash table size to -1021, which again saves memory at the cost of lengthening the linker's -run time. This is not done however if the \fB\-\-hash\-size\fR switch -has been used. -.Sp -The \fB\-\-reduce\-memory\-overheads\fR switch may be also be used to -enable other tradeoffs in future versions of the linker. -.PP -The i386 \s-1PE\s0 linker supports the \fB\-shared\fR option, which causes -the output to be a dynamically linked library (\s-1DLL\s0) instead of a -normal executable. You should name the output \f(CW\*(C`*.dll\*(C'\fR when you -use this option. In addition, the linker fully supports the standard -\&\f(CW\*(C`*.def\*(C'\fR files, which may be specified on the linker command line -like an object file (in fact, it should precede archives it exports -symbols from, to ensure that they get linked in, just like a normal -object file). -.PP -In addition to the options common to all targets, the i386 \s-1PE\s0 linker -support additional command line options that are specific to the i386 -\&\s-1PE\s0 target. Options that take values may be separated from their -values by either a space or an equals sign. -.IP "\fB\-\-add\-stdcall\-alias\fR" 4 -.IX Item "--add-stdcall-alias" -If given, symbols with a stdcall suffix (@\fInn\fR) will be exported -as-is and also with the suffix stripped. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-base\-file\fR \fIfile\fR" 4 -.IX Item "--base-file file" -Use \fIfile\fR as the name of a file in which to save the base -addresses of all the relocations needed for generating DLLs with -\&\fIdlltool\fR. -[This is an i386 \s-1PE\s0 specific option] -.IP "\fB\-\-dll\fR" 4 -.IX Item "--dll" -Create a \s-1DLL\s0 instead of a regular executable. You may also use -\&\fB\-shared\fR or specify a \f(CW\*(C`LIBRARY\*(C'\fR in a given \f(CW\*(C`.def\*(C'\fR -file. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-enable\-stdcall\-fixup\fR" 4 -.IX Item "--enable-stdcall-fixup" -.PD 0 -.IP "\fB\-\-disable\-stdcall\-fixup\fR" 4 -.IX Item "--disable-stdcall-fixup" -.PD -If the link finds a symbol that it cannot resolve, it will attempt to -do \*(L"fuzzy linking\*(R" by looking for another defined symbol that differs -only in the format of the symbol name (cdecl vs stdcall) and will -resolve that symbol by linking to the match. For example, the -undefined symbol \f(CW\*(C`_foo\*(C'\fR might be linked to the function -\&\f(CW\*(C`_foo@12\*(C'\fR, or the undefined symbol \f(CW\*(C`_bar@16\*(C'\fR might be linked -to the function \f(CW\*(C`_bar\*(C'\fR. When the linker does this, it prints a -warning, since it normally should have failed to link, but sometimes -import libraries generated from third-party dlls may need this feature -to be usable. If you specify \fB\-\-enable\-stdcall\-fixup\fR, this -feature is fully enabled and warnings are not printed. If you specify -\&\fB\-\-disable\-stdcall\-fixup\fR, this feature is disabled and such -mismatches are considered to be errors. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-export\-all\-symbols\fR" 4 -.IX Item "--export-all-symbols" -If given, all global symbols in the objects used to build a \s-1DLL\s0 will -be exported by the \s-1DLL\s0. Note that this is the default if there -otherwise wouldn't be any exported symbols. When symbols are -explicitly exported via \s-1DEF\s0 files or implicitly exported via function -attributes, the default is to not export anything else unless this -option is given. Note that the symbols \f(CW\*(C`DllMain@12\*(C'\fR, -\&\f(CW\*(C`DllEntryPoint@0\*(C'\fR, \f(CW\*(C`DllMainCRTStartup@12\*(C'\fR, and -\&\f(CW\*(C`impure_ptr\*(C'\fR will not be automatically -exported. Also, symbols imported from other DLLs will not be -re-exported, nor will symbols specifying the \s-1DLL\s0's internal layout -such as those beginning with \f(CW\*(C`_head_\*(C'\fR or ending with -\&\f(CW\*(C`_iname\*(C'\fR. In addition, no symbols from \f(CW\*(C`libgcc\*(C'\fR, -\&\f(CW\*(C`libstd++\*(C'\fR, \f(CW\*(C`libmingw32\*(C'\fR, or \f(CW\*(C`crtX.o\*(C'\fR will be exported. -Symbols whose names begin with \f(CW\*(C`_\|_rtti_\*(C'\fR or \f(CW\*(C`_\|_builtin_\*(C'\fR will -not be exported, to help with \*(C+ DLLs. Finally, there is an -extensive list of cygwin-private symbols that are not exported -(obviously, this applies on when building DLLs for cygwin targets). -These cygwin-excludes are: \f(CW\*(C`_cygwin_dll_entry@12\*(C'\fR, -\&\f(CW\*(C`_cygwin_crt0_common@8\*(C'\fR, \f(CW\*(C`_cygwin_noncygwin_dll_entry@12\*(C'\fR, -\&\f(CW\*(C`_fmode\*(C'\fR, \f(CW\*(C`_impure_ptr\*(C'\fR, \f(CW\*(C`cygwin_attach_dll\*(C'\fR, -\&\f(CW\*(C`cygwin_premain0\*(C'\fR, \f(CW\*(C`cygwin_premain1\*(C'\fR, \f(CW\*(C`cygwin_premain2\*(C'\fR, -\&\f(CW\*(C`cygwin_premain3\*(C'\fR, and \f(CW\*(C`environ\*(C'\fR. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-exclude\-symbols\fR \fIsymbol\fR\fB,\fR\fIsymbol\fR\fB,...\fR" 4 -.IX Item "--exclude-symbols symbol,symbol,..." -Specifies a list of symbols which should not be automatically -exported. The symbol names may be delimited by commas or colons. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-file\-alignment\fR" 4 -.IX Item "--file-alignment" -Specify the file alignment. Sections in the file will always begin at -file offsets which are multiples of this number. This defaults to -512. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-heap\fR \fIreserve\fR" 4 -.IX Item "--heap reserve" -.PD 0 -.IP "\fB\-\-heap\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4 -.IX Item "--heap reserve,commit" -.PD -Specify the amount of memory to reserve (and optionally commit) to be -used as heap for this program. The default is 1Mb reserved, 4K -committed. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-image\-base\fR \fIvalue\fR" 4 -.IX Item "--image-base value" -Use \fIvalue\fR as the base address of your program or dll. This is -the lowest memory location that will be used when your program or dll -is loaded. To reduce the need to relocate and improve performance of -your dlls, each should have a unique base address and not overlap any -other dlls. The default is 0x400000 for executables, and 0x10000000 -for dlls. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-kill\-at\fR" 4 -.IX Item "--kill-at" -If given, the stdcall suffixes (@\fInn\fR) will be stripped from -symbols before they are exported. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-large\-address\-aware\fR" 4 -.IX Item "--large-address-aware" -If given, the appropriate bit in the \*(L"Characteristics\*(R" field of the \s-1COFF\s0 -header is set to indicate that this executable supports virtual addresses -greater than 2 gigabytes. This should be used in conjunction with the /3GB -or /USERVA=\fIvalue\fR megabytes switch in the \*(L"[operating systems]\*(R" -section of the \s-1BOOT\s0.INI. Otherwise, this bit has no effect. -[This option is specific to \s-1PE\s0 targeted ports of the linker] -.IP "\fB\-\-major\-image\-version\fR \fIvalue\fR" 4 -.IX Item "--major-image-version value" -Sets the major number of the \*(L"image version\*(R". Defaults to 1. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-major\-os\-version\fR \fIvalue\fR" 4 -.IX Item "--major-os-version value" -Sets the major number of the \*(L"os version\*(R". Defaults to 4. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-major\-subsystem\-version\fR \fIvalue\fR" 4 -.IX Item "--major-subsystem-version value" -Sets the major number of the \*(L"subsystem version\*(R". Defaults to 4. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-minor\-image\-version\fR \fIvalue\fR" 4 -.IX Item "--minor-image-version value" -Sets the minor number of the \*(L"image version\*(R". Defaults to 0. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-minor\-os\-version\fR \fIvalue\fR" 4 -.IX Item "--minor-os-version value" -Sets the minor number of the \*(L"os version\*(R". Defaults to 0. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-minor\-subsystem\-version\fR \fIvalue\fR" 4 -.IX Item "--minor-subsystem-version value" -Sets the minor number of the \*(L"subsystem version\*(R". Defaults to 0. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-output\-def\fR \fIfile\fR" 4 -.IX Item "--output-def file" -The linker will create the file \fIfile\fR which will contain a \s-1DEF\s0 -file corresponding to the \s-1DLL\s0 the linker is generating. This \s-1DEF\s0 file -(which should be called \f(CW\*(C`*.def\*(C'\fR) may be used to create an import -library with \f(CW\*(C`dlltool\*(C'\fR or may be used as a reference to -automatically or implicitly exported symbols. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-out\-implib\fR \fIfile\fR" 4 -.IX Item "--out-implib file" -The linker will create the file \fIfile\fR which will contain an -import lib corresponding to the \s-1DLL\s0 the linker is generating. This -import lib (which should be called \f(CW\*(C`*.dll.a\*(C'\fR or \f(CW\*(C`*.a\*(C'\fR -may be used to link clients against the generated \s-1DLL\s0; this behaviour -makes it possible to skip a separate \f(CW\*(C`dlltool\*(C'\fR import library -creation step. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-enable\-auto\-image\-base\fR" 4 -.IX Item "--enable-auto-image-base" -Automatically choose the image base for DLLs, unless one is specified -using the \f(CW\*(C`\-\-image\-base\*(C'\fR argument. By using a hash generated -from the dllname to create unique image bases for each \s-1DLL\s0, in-memory -collisions and relocations which can delay program execution are -avoided. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-disable\-auto\-image\-base\fR" 4 -.IX Item "--disable-auto-image-base" -Do not automatically generate a unique image base. If there is no -user-specified image base (\f(CW\*(C`\-\-image\-base\*(C'\fR) then use the platform -default. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-dll\-search\-prefix\fR \fIstring\fR" 4 -.IX Item "--dll-search-prefix string" -When linking dynamically to a dll without an import library, -search for \f(CW\*(C`.dll\*(C'\fR in preference to -\&\f(CW\*(C`lib.dll\*(C'\fR. This behaviour allows easy distinction -between DLLs built for the various \*(L"subplatforms\*(R": native, cygwin, -uwin, pw, etc. For instance, cygwin DLLs typically use -\&\f(CW\*(C`\-\-dll\-search\-prefix=cyg\*(C'\fR. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-enable\-auto\-import\fR" 4 -.IX Item "--enable-auto-import" -Do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to \f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for -\&\s-1DATA\s0 imports from DLLs, and create the necessary thunking symbols when -building the import libraries with those \s-1DATA\s0 exports. Note: Use of the -\&'auto\-import' extension will cause the text section of the image file -to be made writable. This does not conform to the PE-COFF format -specification published by Microsoft. -.Sp -Using 'auto\-import' generally will 'just work' \*(-- but sometimes you may -see this message: -.Sp -"variable '' can't be auto-imported. Please read the -documentation for ld's \f(CW\*(C`\-\-enable\-auto\-import\*(C'\fR for details." -.Sp -This message occurs when some (sub)expression accesses an address -ultimately given by the sum of two constants (Win32 import tables only -allow one). Instances where this may occur include accesses to member -fields of struct variables imported from a \s-1DLL\s0, as well as using a -constant index into an array variable imported from a \s-1DLL\s0. Any -multiword variable (arrays, structs, long long, etc) may trigger -this error condition. However, regardless of the exact data type -of the offending exported variable, ld will always detect it, issue -the warning, and exit. -.Sp -There are several ways to address this difficulty, regardless of the -data type of the exported variable: -.Sp -One way is to use \-\-enable\-runtime\-pseudo\-reloc switch. This leaves the task -of adjusting references in your client code for runtime environment, so -this method works only when runtime environment supports this feature. -.Sp -A second solution is to force one of the 'constants' to be a variable \*(-- -that is, unknown and un-optimizable at compile time. For arrays, -there are two possibilities: a) make the indexee (the array's address) -a variable, or b) make the 'constant' index a variable. Thus: -.Sp -.Vb 3 -\& extern type extern_array[]; -\& extern_array[1] \-\-> -\& { volatile type *t=extern_array; t[1] } -.Ve -.Sp -or -.Sp -.Vb 3 -\& extern type extern_array[]; -\& extern_array[1] \-\-> -\& { volatile int t=1; extern_array[t] } -.Ve -.Sp -For structs (and most other multiword data types) the only option -is to make the struct itself (or the long long, or the ...) variable: -.Sp -.Vb 3 -\& extern struct s extern_struct; -\& extern_struct.field \-\-> -\& { volatile struct s *t=&extern_struct; t\->field } -.Ve -.Sp -or -.Sp -.Vb 3 -\& extern long long extern_ll; -\& extern_ll \-\-> -\& { volatile long long * local_ll=&extern_ll; *local_ll } -.Ve -.Sp -A third method of dealing with this difficulty is to abandon -\&'auto\-import' for the offending symbol and mark it with -\&\f(CW\*(C`_\|_declspec(dllimport)\*(C'\fR. However, in practise that -requires using compile-time #defines to indicate whether you are -building a \s-1DLL\s0, building client code that will link to the \s-1DLL\s0, or -merely building/linking to a static library. In making the choice -between the various methods of resolving the 'direct address with -constant offset' problem, you should consider typical real-world usage: -.Sp -Original: -.Sp -.Vb 7 -\& \-\-foo.h -\& extern int arr[]; -\& \-\-foo.c -\& #include "foo.h" -\& void main(int argc, char **argv){ -\& printf("%d\en",arr[1]); -\& } -.Ve -.Sp -Solution 1: -.Sp -.Vb 9 -\& \-\-foo.h -\& extern int arr[]; -\& \-\-foo.c -\& #include "foo.h" -\& void main(int argc, char **argv){ -\& /* This workaround is for win32 and cygwin; do not "optimize" */ -\& volatile int *parr = arr; -\& printf("%d\en",parr[1]); -\& } -.Ve -.Sp -Solution 2: -.Sp -.Vb 10 -\& \-\-foo.h -\& /* Note: auto\-export is assumed (no _\|_declspec(dllexport)) */ -\& #if (defined(_WIN32) || defined(_\|_CYGWIN_\|_)) && \e -\& !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) -\& #define FOO_IMPORT _\|_declspec(dllimport) -\& #else -\& #define FOO_IMPORT -\& #endif -\& extern FOO_IMPORT int arr[]; -\& \-\-foo.c -\& #include "foo.h" -\& void main(int argc, char **argv){ -\& printf("%d\en",arr[1]); -\& } -.Ve -.Sp -A fourth way to avoid this problem is to re-code your -library to use a functional interface rather than a data interface -for the offending variables (e.g. \fIset_foo()\fR and \fIget_foo()\fR accessor -functions). -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-disable\-auto\-import\fR" 4 -.IX Item "--disable-auto-import" -Do not attempt to do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to -\&\f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for \s-1DATA\s0 imports from DLLs. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-enable\-runtime\-pseudo\-reloc\fR" 4 -.IX Item "--enable-runtime-pseudo-reloc" -If your code contains expressions described in \-\-enable\-auto\-import section, -that is, \s-1DATA\s0 imports from \s-1DLL\s0 with non-zero offset, this switch will create -a vector of 'runtime pseudo relocations' which can be used by runtime -environment to adjust references to such data in your client code. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-disable\-runtime\-pseudo\-reloc\fR" 4 -.IX Item "--disable-runtime-pseudo-reloc" -Do not create pseudo relocations for non-zero offset \s-1DATA\s0 imports from -DLLs. This is the default. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-enable\-extra\-pe\-debug\fR" 4 -.IX Item "--enable-extra-pe-debug" -Show additional debug info related to auto-import symbol thunking. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-section\-alignment\fR" 4 -.IX Item "--section-alignment" -Sets the section alignment. Sections in memory will always begin at -addresses which are a multiple of this number. Defaults to 0x1000. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-stack\fR \fIreserve\fR" 4 -.IX Item "--stack reserve" -.PD 0 -.IP "\fB\-\-stack\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4 -.IX Item "--stack reserve,commit" -.PD -Specify the amount of memory to reserve (and optionally commit) to be -used as stack for this program. The default is 2Mb reserved, 4K -committed. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.IP "\fB\-\-subsystem\fR \fIwhich\fR" 4 -.IX Item "--subsystem which" -.PD 0 -.IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR" 4 -.IX Item "--subsystem which:major" -.IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR\fB.\fR\fIminor\fR" 4 -.IX Item "--subsystem which:major.minor" -.PD -Specifies the subsystem under which your program will execute. The -legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C'\fR, -\&\f(CW\*(C`console\*(C'\fR, \f(CW\*(C`posix\*(C'\fR, and \f(CW\*(C`xbox\*(C'\fR. You may optionally set -the subsystem version also. Numeric values are also accepted for -\&\fIwhich\fR. -[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] -.PP -The 68HC11 and 68HC12 linkers support specific options to control the -memory bank switching mapping and trampoline code generation. -.IP "\fB\-\-no\-trampoline\fR" 4 -.IX Item "--no-trampoline" -This option disables the generation of trampoline. By default a trampoline -is generated for each far function which is called using a \f(CW\*(C`jsr\*(C'\fR -instruction (this happens when a pointer to a far function is taken). -.IP "\fB\-\-bank\-window\fR \fIname\fR" 4 -.IX Item "--bank-window name" -This option indicates to the linker the name of the memory region in -the \fB\s-1MEMORY\s0\fR specification that describes the memory bank window. -The definition of such region is then used by the linker to compute -paging and addresses within the memory window. -.SH "ENVIRONMENT" -.IX Header "ENVIRONMENT" -You can change the behaviour of \fBld\fR with the environment variables -\&\f(CW\*(C`GNUTARGET\*(C'\fR, -\&\f(CW\*(C`LDEMULATION\*(C'\fR and \f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR. -.PP -\&\f(CW\*(C`GNUTARGET\*(C'\fR determines the input-file object format if you don't -use \fB\-b\fR (or its synonym \fB\-\-format\fR). Its value should be one -of the \s-1BFD\s0 names for an input format. If there is no -\&\f(CW\*(C`GNUTARGET\*(C'\fR in the environment, \fBld\fR uses the natural format -of the target. If \f(CW\*(C`GNUTARGET\*(C'\fR is set to \f(CW\*(C`default\*(C'\fR then \s-1BFD\s0 -attempts to discover the input format by examining binary input files; -this method often succeeds, but there are potential ambiguities, since -there is no method of ensuring that the magic number used to specify -object-file formats is unique. However, the configuration procedure for -\&\s-1BFD\s0 on each system places the conventional format for that system first -in the search-list, so ambiguities are resolved in favor of convention. -.PP -\&\f(CW\*(C`LDEMULATION\*(C'\fR determines the default emulation if you don't use the -\&\fB\-m\fR option. The emulation can affect various aspects of linker -behaviour, particularly the default linker script. You can list the -available emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. If -the \fB\-m\fR option is not used, and the \f(CW\*(C`LDEMULATION\*(C'\fR environment -variable is not defined, the default emulation depends upon how the -linker was configured. -.PP -Normally, the linker will default to demangling symbols. However, if -\&\f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR is set in the environment, then it will -default to not demangling symbols. This environment variable is used in -a similar fashion by the \f(CW\*(C`gcc\*(C'\fR linker wrapper program. The default -may be overridden by the \fB\-\-demangle\fR and \fB\-\-no\-demangle\fR -options. -.SH "SEE ALSO" -.IX Header "SEE ALSO" -\&\fIar\fR\|(1), \fInm\fR\|(1), \fIobjcopy\fR\|(1), \fIobjdump\fR\|(1), \fIreadelf\fR\|(1) and -the Info entries for \fIbinutils\fR and -\&\fIld\fR. -.SH "COPYRIGHT" -.IX Header "COPYRIGHT" -Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. -.PP -Permission is granted to copy, distribute and/or modify this document -under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 -or any later version published by the Free Software Foundation; -with no Invariant Sections, with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the -section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/libbfd/Makefile b/gnu/usr.bin/binutils/libbfd/Makefile deleted file mode 100644 index efb75648d0f..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libbfd/Makefile 284373 2015-06-14 03:33:27Z sjg $ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/bfd ${SRCDIR}/opcodes - -LIB= bfd -SRCS+= archive.c \ - archive64.c \ - archures.c \ - bfd.c \ - bfdio.c \ - bfdver.h \ - bfdwin.c \ - binary.c \ - cache.c \ - coffgen.c \ - config.h \ - corefile.c \ - dwarf1.c \ - dwarf2.c \ - elf-attrs.c \ - elf-eh-frame.c \ - elf-strtab.c \ - elf-vxworks.c \ - elf.c \ - format.c \ - hash.c \ - ihex.c \ - init.c \ - libbfd.c \ - linker.c \ - merge.c \ - opncls.c \ - reloc.c \ - section.c \ - simple.c \ - srec.c \ - stab-syms.c \ - stabs.c \ - syms.c \ - targets.c \ - targmatch.h \ - tekhex.c -.if ${TARGET_ARCH} == "sparc64" -WARNS?= 2 -.endif -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${SRCDIR}/bfd -INTERNALLIB= -CLEANFILES+= bfdver.h config.h targmatch.h - -SELARCH= -.if ${TARGET_ARCH} == "amd64" -SELARCH= &bfd_i386_arch -.elif ${TARGET_ARCH} == "sparc64" -SELARCH= &bfd_sparc_arch -.else -.for _a in ${ARCHS} -.if ${SELARCH} == "" -SELARCH+= &bfd_${_a}_arch -.else -SELARCH+= ,&bfd_${_a}_arch -.endif -.endfor -.endif -CFLAGS+= -DSELECT_ARCHITECTURES="${SELARCH}" - -SELVEC= -.for _v in ${VECS} -CFLAGS+= -DHAVE_${_v} -.if ${SELVEC} == "" -SELVEC+= &${_v} -.else -SELVEC+= ,&${_v} -.endif -.endfor -CFLAGS+= -DSELECT_VECS="${SELVEC}" -CFLAGS+= -DDEFAULT_VECTOR=${DEFAULT_VECTOR} -CFLAGS+= -DDEBUGDIR="NULL" - -# XXX:DEO should grab BFD_VERSION_DATE from ${VERSION}... -bfdver.h: Makefile - echo '#define BFD_VERSION 217500000' > ${.TARGET} - echo '#define BFD_VERSION_DATE 20070703' >> ${.TARGET} - echo '#define BFD_VERSION_STRING ${VERSION}' >> ${.TARGET} - echo '#define REPORT_BUGS_TO ""' >> ${.TARGET} - -targmatch.h: targmatch.sed config.bfd - sed -f ${.ALLSRC:M*.sed} ${.ALLSRC:M*.bfd} > ${.TARGET} - -config.h: config.h.fbsd -.if ${TARGET_ARCH} == "i386" - sed -e 's,!!TRAD_HEADER!!,"hosts/i386bsd.h",g' ${.ALLSRC} > ${.TARGET} -.else - sed -e 's,!!TRAD_HEADER!!,,g' ${.ALLSRC} > ${.TARGET} -.endif - -CLEANFILES+= elf32-target.h elf64-target.h -elf32-target.h: elfxx-target.h - sed -e s/NN/32/g ${.ALLSRC} > ${.TARGET} - -elf64-target.h: elfxx-target.h - sed -e s/NN/64/g ${.ALLSRC} > ${.TARGET} - -# avoid cicular dependency -GENDIRDEPS_FILTER+= N*/nm - -.include diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.amd64 b/gnu/usr.bin/binutils/libbfd/Makefile.amd64 deleted file mode 100644 index 31ad0d9302b..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.amd64 +++ /dev/null @@ -1,29 +0,0 @@ -# $FreeBSD$ - -.include "${.CURDIR}/Makefile.i386" - -# Get the i386 VECS. -I386_VECS:= ${VECS} - -DEFAULT_VECTOR= bfd_elf64_x86_64_freebsd_vec - -SRCS+= elf64-x86-64.c \ - efi-app-x86_64.c \ - elf64.c \ - elf64-gen.c \ - elf64-target.h \ - pepigen.c \ - pex64igen.c - -VECS= ${DEFAULT_VECTOR} \ - bfd_elf64_x86_64_vec \ - bfd_efi_app_x86_64_vec \ - ${I386_VECS} - -CLEANFILES+= pepigen.c pex64igen.c - -pepigen.c: peXXigen.c - sed -e s/XX/pep/g ${.ALLSRC} > ${.TARGET} - -pex64igen.c: peXXigen.c - sed -e s/XX/pex64/g ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.arm b/gnu/usr.bin/binutils/libbfd/Makefile.arm deleted file mode 100644 index 9d0a12b26a4..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.arm +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ - -.if ${TARGET_ARCH:Marm*eb} != "" -DEFAULT_VECTOR= bfd_elf32_bigarm_vec -.else -DEFAULT_VECTOR= bfd_elf32_littlearm_vec -.endif - -SRCS+= cpu-arm.c \ - elf32.c \ - elf32-arm.c \ - elf32-gen.c \ - elf32-target.h \ - elflink.c - -VECS+= ${DEFAULT_VECTOR} -.if ${TARGET_ARCH:Marm*eb} != "" -VECS+= bfd_elf32_littlearm_vec -.else -VECS+= bfd_elf32_bigarm_vec -.endif diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.depend b/gnu/usr.bin/binutils/libbfd/Makefile.depend deleted file mode 100644 index 18be76b0cb6..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.depend.host b/gnu/usr.bin/binutils/libbfd/Makefile.depend.host deleted file mode 100644 index f80275d86ab..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.depend.host +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.i386 b/gnu/usr.bin/binutils/libbfd/Makefile.i386 deleted file mode 100644 index e41e30d4dea..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.i386 +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ - -DEFAULT_VECTOR= bfd_elf32_i386_freebsd_vec - -SRCS+= cofflink.c \ - cpu-i386.c \ - efi-app-ia32.c \ - elf32-i386.c \ - elf32-target.h \ - elf32.c \ - elflink.c \ - peigen.c - -VECS= ${DEFAULT_VECTOR} \ - bfd_elf32_i386_vec \ - bfd_efi_app_ia32_vec - -peigen.c: peXXigen.c - sed -e s/XX/pe/g ${.ALLSRC} > ${.TARGET} - -CLEANFILES+= peigen.c diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.ia64 b/gnu/usr.bin/binutils/libbfd/Makefile.ia64 deleted file mode 100644 index c6ad44b6879..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.ia64 +++ /dev/null @@ -1,35 +0,0 @@ -# $FreeBSD: stable/10/gnu/usr.bin/binutils/libbfd/Makefile.ia64 218822 2011-02-18 20:54:12Z dim $ - -DEFAULT_VECTOR= bfd_elf64_ia64_freebsd_vec - -SRCS+= cofflink.c \ - cpu-ia64.c \ - efi-app-ia64.c \ - elf32.c \ - elf32-gen.c \ - elf32-target.h \ - elf64.c \ - elf64-gen.c \ - elf64-ia64.c \ - elf64-target.h \ - elflink.c \ - pepigen.c \ - pex64igen.c - -VECS+= ${DEFAULT_VECTOR} \ - bfd_efi_app_ia64_vec \ - bfd_elf64_ia64_little_vec \ - bfd_elf64_ia64_big_vec \ - bfd_elf64_little_generic_vec bfd_elf64_big_generic_vec \ - bfd_elf32_little_generic_vec bfd_elf32_big_generic_vec - -CLEANFILES+= elf64-ia64.c pepigen.c pex64igen.c - -elf64-ia64.c: elfxx-ia64.c - sed -e s/NN/64/g ${.ALLSRC} > ${.TARGET} - -pepigen.c: peXXigen.c - sed -e s/XX/pep/g ${.ALLSRC} > ${.TARGET} - -pex64igen.c: peXXigen.c - sed -e s/XX/pex64/g ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.powerpc b/gnu/usr.bin/binutils/libbfd/Makefile.powerpc deleted file mode 100644 index aa3e4f477a0..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.powerpc +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ - -ARCHS+= rs6000 - -DEFAULT_VECTOR= bfd_elf32_powerpc_vec - -SRCS+= cpu-powerpc.c \ - cpu-rs6000.c \ - elf32.c \ - elf32-gen.c \ - elf32-ppc.c \ - elf32-target.h \ - elflink.c \ - ppcboot.c \ - xcofflink.c - -VECS+= ${DEFAULT_VECTOR} \ - bfd_elf32_powerpcle_vec \ - ppcboot_vec diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 b/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 deleted file mode 100644 index a32e95dd364..00000000000 --- a/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -ARCHS+= rs6000 - -DEFAULT_VECTOR= bfd_elf64_powerpc_vec -NO_WERROR.clang= - -SRCS+= cpu-powerpc.c \ - cpu-rs6000.c \ - elf32.c \ - elf32-gen.c \ - elf32-ppc.c \ - elf32-target.h \ - elflink.c \ - elf64.c \ - elf64-gen.c \ - elf64-ppc.c \ - elf64-target.h \ - elflink.c \ - ppcboot.c \ - xcofflink.c - -VECS+= ${DEFAULT_VECTOR} \ - bfd_elf64_powerpcle_vec \ - bfd_elf32_powerpc_vec \ - bfd_elf32_powerpcle_vec \ - ppcboot_vec - diff --git a/gnu/usr.bin/binutils/libbfd/bfd.h b/gnu/usr.bin/binutils/libbfd/bfd.h deleted file mode 100644 index c6fcc4780c4..00000000000 --- a/gnu/usr.bin/binutils/libbfd/bfd.h +++ /dev/null @@ -1,5410 +0,0 @@ -/* $FreeBSD$ */ - -/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically - generated from "bfd-in.h", "init.c", "opncls.c", "libbfd.c", - "bfdio.c", "bfdwin.c", "section.c", "archures.c", "reloc.c", - "syms.c", "bfd.c", "archive.c", "corefile.c", "targets.c", "format.c", - "linker.c" and "simple.c". - Run "make headers" in your build bfd/ to regenerate. */ - -/* Main header file for the bfd library -- portable access to object files. - - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 - Free Software Foundation, Inc. - - Contributed by Cygnus Support. - - This file is part of BFD, the Binary File Descriptor library. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef __BFD_H_SEEN__ -#define __BFD_H_SEEN__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "ansidecl.h" -#include "symcat.h" -#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) -#ifndef SABER -/* This hack is to avoid a problem with some strict ANSI C preprocessors. - The problem is, "32_" is not a valid preprocessing token, and we don't - want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will - cause the inner CONCAT2 macros to be evaluated first, producing - still-valid pp-tokens. Then the final concatenation can be done. */ -#undef CONCAT4 -#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d)) -#endif -#endif - -/* This is a utility macro to handle the situation where the code - wants to place a constant string into the code, followed by a - comma and then the length of the string. Doing this by hand - is error prone, so using this macro is safer. The macro will - also safely handle the case where a NULL is passed as the arg. */ -#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0) -/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro - to create the arguments to another macro, since the preprocessor - will mis-count the number of arguments to the outer macro (by not - evaluating STRING_COMMA_LEN and so missing the comma). This is a - problem for example when trying to use STRING_COMMA_LEN to build - the arguments to the strncmp() macro. Hence this alternative - definition of strncmp is provided here. - - Note - these macros do NOT work if STR2 is not a constant string. */ -#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0) - /* strcpy() can have a similar problem, but since we know we are - copying a constant string, we can use memcpy which will be faster - since there is no need to check for a NUL byte inside STR. We - can also save time if we do not need to copy the terminating NUL. */ -#define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1) -#define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2)) - - -/* The word size used by BFD on the host. This may be 64 with a 32 - bit target if the host is 64 bit, or if other 64 bit targets have - been selected with --enable-targets, or if --enable-64-bit-bfd. */ -#define BFD_ARCH_SIZE 64 - -#if defined(__i386__) || defined(__powerpc__) || defined(__arm__) || defined(__mips__) -#define BFD_HOST_64BIT_LONG 0 -#define BFD_HOST_64_BIT long long -#define BFD_HOST_U_64_BIT unsigned long long -#elif defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__aarch64__) -#define BFD_HOST_64BIT_LONG 1 -#define BFD_HOST_64_BIT long -#define BFD_HOST_U_64_BIT unsigned long -#else -#error Unsupported architecture/platform. -#endif /* 64-bit host */ - -#define BFD_HOST_LONG_LONG 1 -typedef BFD_HOST_64_BIT bfd_int64_t; -typedef BFD_HOST_U_64_BIT bfd_uint64_t; - -#if BFD_ARCH_SIZE >= 64 -#define BFD64 -#endif - -#ifndef INLINE -#if __GNUC__ >= 2 -#define INLINE __inline__ -#else -#define INLINE -#endif -#endif - -/* Forward declaration. */ -typedef struct bfd bfd; - -/* Boolean type used in bfd. Too many systems define their own - versions of "boolean" for us to safely typedef a "boolean" of - our own. Using an enum for "bfd_boolean" has its own set of - problems, with strange looking casts required to avoid warnings - on some older compilers. Thus we just use an int. - - General rule: Functions which are bfd_boolean return TRUE on - success and FALSE on failure (unless they're a predicate). */ - -typedef int bfd_boolean; -#undef FALSE -#undef TRUE -#define FALSE 0 -#define TRUE 1 - -#ifdef BFD64 - -#ifndef BFD_HOST_64_BIT - #error No 64 bit integer type available -#endif /* ! defined (BFD_HOST_64_BIT) */ - -typedef BFD_HOST_U_64_BIT bfd_vma; -typedef BFD_HOST_64_BIT bfd_signed_vma; -typedef BFD_HOST_U_64_BIT bfd_size_type; -typedef BFD_HOST_U_64_BIT symvalue; - -#ifndef fprintf_vma -#if BFD_HOST_64BIT_LONG -#define sprintf_vma(s,x) sprintf (s, "%016lx", x) -#define fprintf_vma(f,x) fprintf (f, "%016lx", x) -#else -#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff))) -#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) -#define fprintf_vma(s,x) \ - fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) -#define sprintf_vma(s,x) \ - sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) -#endif -#endif - -#else /* not BFD64 */ - -/* Represent a target address. Also used as a generic unsigned type - which is guaranteed to be big enough to hold any arithmetic types - we need to deal with. */ -typedef unsigned long bfd_vma; - -/* A generic signed type which is guaranteed to be big enough to hold any - arithmetic types we need to deal with. Can be assumed to be compatible - with bfd_vma in the same way that signed and unsigned ints are compatible - (as parameters, in assignment, etc). */ -typedef long bfd_signed_vma; - -typedef unsigned long symvalue; -typedef unsigned long bfd_size_type; - -/* Print a bfd_vma x on stream s. */ -#define fprintf_vma(s,x) fprintf (s, "%08lx", x) -#define sprintf_vma(s,x) sprintf (s, "%08lx", x) - -#endif /* not BFD64 */ - -#define HALF_BFD_SIZE_TYPE \ - (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2)) - -#ifndef BFD_HOST_64_BIT -/* Fall back on a 32 bit type. The idea is to make these types always - available for function return types, but in the case that - BFD_HOST_64_BIT is undefined such a function should abort or - otherwise signal an error. */ -typedef bfd_signed_vma bfd_int64_t; -typedef bfd_vma bfd_uint64_t; -#endif - -/* An offset into a file. BFD always uses the largest possible offset - based on the build time availability of fseek, fseeko, or fseeko64. */ -typedef BFD_HOST_64_BIT file_ptr; -typedef unsigned BFD_HOST_64_BIT ufile_ptr; - -extern void bfd_sprintf_vma (bfd *, char *, bfd_vma); -extern void bfd_fprintf_vma (bfd *, void *, bfd_vma); - -#define printf_vma(x) fprintf_vma(stdout,x) -#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x) - -typedef unsigned int flagword; /* 32 bits of flags */ -typedef unsigned char bfd_byte; - -/* File formats. */ - -typedef enum bfd_format -{ - bfd_unknown = 0, /* File format is unknown. */ - bfd_object, /* Linker/assembler/compiler output. */ - bfd_archive, /* Object archive file. */ - bfd_core, /* Core dump. */ - bfd_type_end /* Marks the end; don't use it! */ -} -bfd_format; - -/* Values that may appear in the flags field of a BFD. These also - appear in the object_flags field of the bfd_target structure, where - they indicate the set of flags used by that backend (not all flags - are meaningful for all object file formats) (FIXME: at the moment, - the object_flags values have mostly just been copied from backend - to another, and are not necessarily correct). */ - -/* No flags. */ -#define BFD_NO_FLAGS 0x00 - -/* BFD contains relocation entries. */ -#define HAS_RELOC 0x01 - -/* BFD is directly executable. */ -#define EXEC_P 0x02 - -/* BFD has line number information (basically used for F_LNNO in a - COFF header). */ -#define HAS_LINENO 0x04 - -/* BFD has debugging information. */ -#define HAS_DEBUG 0x08 - -/* BFD has symbols. */ -#define HAS_SYMS 0x10 - -/* BFD has local symbols (basically used for F_LSYMS in a COFF - header). */ -#define HAS_LOCALS 0x20 - -/* BFD is a dynamic object. */ -#define DYNAMIC 0x40 - -/* Text section is write protected (if D_PAGED is not set, this is - like an a.out NMAGIC file) (the linker sets this by default, but - clears it for -r or -N). */ -#define WP_TEXT 0x80 - -/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the - linker sets this by default, but clears it for -r or -n or -N). */ -#define D_PAGED 0x100 - -/* BFD is relaxable (this means that bfd_relax_section may be able to - do something) (sometimes bfd_relax_section can do something even if - this is not set). */ -#define BFD_IS_RELAXABLE 0x200 - -/* This may be set before writing out a BFD to request using a - traditional format. For example, this is used to request that when - writing out an a.out object the symbols not be hashed to eliminate - duplicates. */ -#define BFD_TRADITIONAL_FORMAT 0x400 - -/* This flag indicates that the BFD contents are actually cached in - memory. If this is set, iostream points to a bfd_in_memory struct. */ -#define BFD_IN_MEMORY 0x800 - -/* The sections in this BFD specify a memory page. */ -#define HAS_LOAD_PAGE 0x1000 - -/* This BFD has been created by the linker and doesn't correspond - to any input file. */ -#define BFD_LINKER_CREATED 0x2000 - -/* Symbols and relocation. */ - -/* A count of carsyms (canonical archive symbols). */ -typedef unsigned long symindex; - -/* How to perform a relocation. */ -typedef const struct reloc_howto_struct reloc_howto_type; - -#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) - -/* General purpose part of a symbol X; - target specific parts are in libcoff.h, libaout.h, etc. */ - -#define bfd_get_section(x) ((x)->section) -#define bfd_get_output_section(x) ((x)->section->output_section) -#define bfd_set_section(x,y) ((x)->section) = (y) -#define bfd_asymbol_base(x) ((x)->section->vma) -#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value) -#define bfd_asymbol_name(x) ((x)->name) -/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/ -#define bfd_asymbol_bfd(x) ((x)->the_bfd) -#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour) - -/* A canonical archive symbol. */ -/* This is a type pun with struct ranlib on purpose! */ -typedef struct carsym -{ - char *name; - file_ptr file_offset; /* Look here to find the file. */ -} -carsym; /* To make these you call a carsymogen. */ - -/* Used in generating armaps (archive tables of contents). - Perhaps just a forward definition would do? */ -struct orl /* Output ranlib. */ -{ - char **name; /* Symbol name. */ - union - { - file_ptr pos; - bfd *abfd; - } u; /* bfd* or file position. */ - int namidx; /* Index into string table. */ -}; - -/* Linenumber stuff. */ -typedef struct lineno_cache_entry -{ - unsigned int line_number; /* Linenumber from start of function. */ - union - { - struct bfd_symbol *sym; /* Function name. */ - bfd_vma offset; /* Offset into section. */ - } u; -} -alent; - -/* Object and core file sections. */ - -#define align_power(addr, align) \ - (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align))) - -typedef struct bfd_section *sec_ptr; - -#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) -#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) -#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0) -#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) -#define bfd_section_name(bfd, ptr) ((ptr)->name) -#define bfd_section_size(bfd, ptr) ((ptr)->size) -#define bfd_get_section_size(ptr) ((ptr)->size) -#define bfd_section_vma(bfd, ptr) ((ptr)->vma) -#define bfd_section_lma(bfd, ptr) ((ptr)->lma) -#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) -#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0) -#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) - -#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) - -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE) -#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE) -#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) -/* Find the address one past the end of SEC. */ -#define bfd_get_section_limit(bfd, sec) \ - (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \ - / bfd_octets_per_byte (bfd)) - -/* Return TRUE if section has been discarded. */ -#define elf_discarded_section(sec) \ - (!bfd_is_abs_section (sec) \ - && bfd_is_abs_section ((sec)->output_section) \ - && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \ - && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS) - -/* Forward define. */ -struct stat; - -typedef enum bfd_print_symbol -{ - bfd_print_symbol_name, - bfd_print_symbol_more, - bfd_print_symbol_all -} bfd_print_symbol_type; - -/* Information about a symbol that nm needs. */ - -typedef struct _symbol_info -{ - symvalue value; - char type; - const char *name; /* Symbol name. */ - unsigned char stab_type; /* Stab type. */ - char stab_other; /* Stab other. */ - short stab_desc; /* Stab desc. */ - const char *stab_name; /* String for stab type. */ -} symbol_info; - -/* Get the name of a stabs type code. */ - -extern const char *bfd_get_stab_name (int); - -/* Hash table routines. There is no way to free up a hash table. */ - -/* An element in the hash table. Most uses will actually use a larger - structure, and an instance of this will be the first field. */ - -struct bfd_hash_entry -{ - /* Next entry for this hash code. */ - struct bfd_hash_entry *next; - /* String being hashed. */ - const char *string; - /* Hash code. This is the full hash code, not the index into the - table. */ - unsigned long hash; -}; - -/* A hash table. */ - -struct bfd_hash_table -{ - /* The hash array. */ - struct bfd_hash_entry **table; - /* A function used to create new elements in the hash table. The - first entry is itself a pointer to an element. When this - function is first invoked, this pointer will be NULL. However, - having the pointer permits a hierarchy of method functions to be - built each of which calls the function in the superclass. Thus - each function should be written to allocate a new block of memory - only if the argument is NULL. */ - struct bfd_hash_entry *(*newfunc) - (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); - /* An objalloc for this hash table. This is a struct objalloc *, - but we use void * to avoid requiring the inclusion of objalloc.h. */ - void *memory; - /* The number of slots in the hash table. */ - unsigned int size; - /* The number of entries in the hash table. */ - unsigned int count; - /* The size of elements. */ - unsigned int entsize; - /* If non-zero, don't grow the hash table. */ - unsigned int frozen:1; -}; - -/* Initialize a hash table. */ -extern bfd_boolean bfd_hash_table_init - (struct bfd_hash_table *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *), - unsigned int); - -/* Initialize a hash table specifying a size. */ -extern bfd_boolean bfd_hash_table_init_n - (struct bfd_hash_table *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *), - unsigned int, unsigned int); - -/* Free up a hash table. */ -extern void bfd_hash_table_free - (struct bfd_hash_table *); - -/* Look up a string in a hash table. If CREATE is TRUE, a new entry - will be created for this string if one does not already exist. The - COPY argument must be TRUE if this routine should copy the string - into newly allocated memory when adding an entry. */ -extern struct bfd_hash_entry *bfd_hash_lookup - (struct bfd_hash_table *, const char *, bfd_boolean create, - bfd_boolean copy); - -/* Replace an entry in a hash table. */ -extern void bfd_hash_replace - (struct bfd_hash_table *, struct bfd_hash_entry *old, - struct bfd_hash_entry *nw); - -/* Base method for creating a hash table entry. */ -extern struct bfd_hash_entry *bfd_hash_newfunc - (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); - -/* Grab some space for a hash table entry. */ -extern void *bfd_hash_allocate - (struct bfd_hash_table *, unsigned int); - -/* Traverse a hash table in a random order, calling a function on each - element. If the function returns FALSE, the traversal stops. The - INFO argument is passed to the function. */ -extern void bfd_hash_traverse - (struct bfd_hash_table *, - bfd_boolean (*) (struct bfd_hash_entry *, void *), - void *info); - -/* Allows the default size of a hash table to be configured. New hash - tables allocated using bfd_hash_table_init will be created with - this size. */ -extern void bfd_hash_set_default_size (bfd_size_type); - -/* This structure is used to keep track of stabs in sections - information while linking. */ - -struct stab_info -{ - /* A hash table used to hold stabs strings. */ - struct bfd_strtab_hash *strings; - /* The header file hash table. */ - struct bfd_hash_table includes; - /* The first .stabstr section. */ - struct bfd_section *stabstr; -}; - -#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table - -/* User program access to BFD facilities. */ - -/* Direct I/O routines, for programs which know more about the object - file than BFD does. Use higher level routines if possible. */ - -extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *); -extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *); -extern int bfd_seek (bfd *, file_ptr, int); -extern file_ptr bfd_tell (bfd *); -extern int bfd_flush (bfd *); -extern int bfd_stat (bfd *, struct stat *); - -/* Deprecated old routines. */ -#if __GNUC__ -#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \ - (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \ - bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) -#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \ - (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \ - bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) -#else -#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \ - (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \ - bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) -#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \ - (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\ - bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) -#endif -extern void warn_deprecated (const char *, const char *, int, const char *); - -/* Cast from const char * to char * so that caller can assign to - a char * without a warning. */ -#define bfd_get_filename(abfd) ((char *) (abfd)->filename) -#define bfd_get_cacheable(abfd) ((abfd)->cacheable) -#define bfd_get_format(abfd) ((abfd)->format) -#define bfd_get_target(abfd) ((abfd)->xvec->name) -#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour) -#define bfd_family_coff(abfd) \ - (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \ - bfd_get_flavour (abfd) == bfd_target_xcoff_flavour) -#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG) -#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE) -#define bfd_header_big_endian(abfd) \ - ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG) -#define bfd_header_little_endian(abfd) \ - ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE) -#define bfd_get_file_flags(abfd) ((abfd)->flags) -#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) -#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) -#define bfd_my_archive(abfd) ((abfd)->my_archive) -#define bfd_has_map(abfd) ((abfd)->has_armap) - -#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) -#define bfd_usrdata(abfd) ((abfd)->usrdata) - -#define bfd_get_start_address(abfd) ((abfd)->start_address) -#define bfd_get_symcount(abfd) ((abfd)->symcount) -#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) -#define bfd_count_sections(abfd) ((abfd)->section_count) - -#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount) - -#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) - -#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE) - -extern bfd_boolean bfd_cache_close - (bfd *abfd); -/* NB: This declaration should match the autogenerated one in libbfd.h. */ - -extern bfd_boolean bfd_cache_close_all (void); - -extern bfd_boolean bfd_record_phdr - (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma, - bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **); - -/* Byte swapping routines. */ - -bfd_uint64_t bfd_getb64 (const void *); -bfd_uint64_t bfd_getl64 (const void *); -bfd_int64_t bfd_getb_signed_64 (const void *); -bfd_int64_t bfd_getl_signed_64 (const void *); -bfd_vma bfd_getb32 (const void *); -bfd_vma bfd_getl32 (const void *); -bfd_signed_vma bfd_getb_signed_32 (const void *); -bfd_signed_vma bfd_getl_signed_32 (const void *); -bfd_vma bfd_getb16 (const void *); -bfd_vma bfd_getl16 (const void *); -bfd_signed_vma bfd_getb_signed_16 (const void *); -bfd_signed_vma bfd_getl_signed_16 (const void *); -void bfd_putb64 (bfd_uint64_t, void *); -void bfd_putl64 (bfd_uint64_t, void *); -void bfd_putb32 (bfd_vma, void *); -void bfd_putl32 (bfd_vma, void *); -void bfd_putb16 (bfd_vma, void *); -void bfd_putl16 (bfd_vma, void *); - -/* Byte swapping routines which take size and endiannes as arguments. */ - -bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean); -void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean); - -extern bfd_boolean bfd_section_already_linked_table_init (void); -extern void bfd_section_already_linked_table_free (void); - -/* Externally visible ECOFF routines. */ - -#if defined(__STDC__) || defined(ALMOST_STDC) -struct ecoff_debug_info; -struct ecoff_debug_swap; -struct ecoff_extr; -struct bfd_symbol; -struct bfd_link_info; -struct bfd_link_hash_entry; -struct bfd_elf_version_tree; -#endif -extern bfd_vma bfd_ecoff_get_gp_value - (bfd * abfd); -extern bfd_boolean bfd_ecoff_set_gp_value - (bfd *abfd, bfd_vma gp_value); -extern bfd_boolean bfd_ecoff_set_regmasks - (bfd *abfd, unsigned long gprmask, unsigned long fprmask, - unsigned long *cprmask); -extern void *bfd_ecoff_debug_init - (bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, struct bfd_link_info *); -extern void bfd_ecoff_debug_free - (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, struct bfd_link_info *); -extern bfd_boolean bfd_ecoff_debug_accumulate - (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, bfd *input_bfd, - struct ecoff_debug_info *input_debug, - const struct ecoff_debug_swap *input_swap, struct bfd_link_info *); -extern bfd_boolean bfd_ecoff_debug_accumulate_other - (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, bfd *input_bfd, - struct bfd_link_info *); -extern bfd_boolean bfd_ecoff_debug_externals - (bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, bfd_boolean relocatable, - bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *), - void (*set_index) (struct bfd_symbol *, bfd_size_type)); -extern bfd_boolean bfd_ecoff_debug_one_external - (bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, const char *name, - struct ecoff_extr *esym); -extern bfd_size_type bfd_ecoff_debug_size - (bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap); -extern bfd_boolean bfd_ecoff_write_debug - (bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, file_ptr where); -extern bfd_boolean bfd_ecoff_write_accumulated_debug - (void *handle, bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, - struct bfd_link_info *info, file_ptr where); - -/* Externally visible ELF routines. */ - -struct bfd_link_needed_list -{ - struct bfd_link_needed_list *next; - bfd *by; - const char *name; -}; - -enum dynamic_lib_link_class { - DYN_NORMAL = 0, - DYN_AS_NEEDED = 1, - DYN_DT_NEEDED = 2, - DYN_NO_ADD_NEEDED = 4, - DYN_NO_NEEDED = 8 -}; - -enum notice_asneeded_action { - notice_as_needed, - notice_not_needed, - notice_needed -}; - -extern bfd_boolean bfd_elf_record_link_assignment - (bfd *, struct bfd_link_info *, const char *, bfd_boolean, - bfd_boolean); -extern struct bfd_link_needed_list *bfd_elf_get_needed_list - (bfd *, struct bfd_link_info *); -extern bfd_boolean bfd_elf_get_bfd_needed_list - (bfd *, struct bfd_link_needed_list **); -extern bfd_boolean bfd_elf_size_dynamic_sections - (bfd *, const char *, const char *, const char *, const char * const *, - struct bfd_link_info *, struct bfd_section **, - struct bfd_elf_version_tree *); -extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr - (bfd *, struct bfd_link_info *); -extern void bfd_elf_set_dt_needed_name - (bfd *, const char *); -extern const char *bfd_elf_get_dt_soname - (bfd *); -extern void bfd_elf_set_dyn_lib_class - (bfd *, enum dynamic_lib_link_class); -extern int bfd_elf_get_dyn_lib_class - (bfd *); -extern struct bfd_link_needed_list *bfd_elf_get_runpath_list - (bfd *, struct bfd_link_info *); -extern bfd_boolean bfd_elf_discard_info - (bfd *, struct bfd_link_info *); -extern unsigned int _bfd_elf_default_action_discarded - (struct bfd_section *); - -/* Return an upper bound on the number of bytes required to store a - copy of ABFD's program header table entries. Return -1 if an error - occurs; bfd_get_error will return an appropriate code. */ -extern long bfd_get_elf_phdr_upper_bound - (bfd *abfd); - -/* Copy ABFD's program header table entries to *PHDRS. The entries - will be stored as an array of Elf_Internal_Phdr structures, as - defined in include/elf/internal.h. To find out how large the - buffer needs to be, call bfd_get_elf_phdr_upper_bound. - - Return the number of program header table entries read, or -1 if an - error occurs; bfd_get_error will return an appropriate code. */ -extern int bfd_get_elf_phdrs - (bfd *abfd, void *phdrs); - -/* Create a new BFD as if by bfd_openr. Rather than opening a file, - reconstruct an ELF file by reading the segments out of remote memory - based on the ELF file header at EHDR_VMA and the ELF program headers it - points to. If not null, *LOADBASEP is filled in with the difference - between the VMAs from which the segments were read, and the VMAs the - file headers (and hence BFD's idea of each section's VMA) put them at. - - The function TARGET_READ_MEMORY is called to copy LEN bytes from the - remote memory at target address VMA into the local buffer at MYADDR; it - should return zero on success or an `errno' code on failure. TEMPL must - be a BFD for an ELF target with the word size and byte order found in - the remote memory. */ -extern bfd *bfd_elf_bfd_from_remote_memory - (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, - int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len)); - -/* Return the arch_size field of an elf bfd, or -1 if not elf. */ -extern int bfd_get_arch_size - (bfd *); - -/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */ -extern int bfd_get_sign_extend_vma - (bfd *); - -extern struct bfd_section *_bfd_elf_tls_setup - (bfd *, struct bfd_link_info *); - -extern void _bfd_fix_excluded_sec_syms - (bfd *, struct bfd_link_info *); - -extern unsigned bfd_m68k_mach_to_features (int); - -extern int bfd_m68k_features_to_mach (unsigned); - -extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs - (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, - char **); - -extern bfd_boolean bfd_bfin_elf32_create_embedded_relocs - (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, - char **); - -/* SunOS shared library support routines for the linker. */ - -extern struct bfd_link_needed_list *bfd_sunos_get_needed_list - (bfd *, struct bfd_link_info *); -extern bfd_boolean bfd_sunos_record_link_assignment - (bfd *, struct bfd_link_info *, const char *); -extern bfd_boolean bfd_sunos_size_dynamic_sections - (bfd *, struct bfd_link_info *, struct bfd_section **, - struct bfd_section **, struct bfd_section **); - -/* Linux shared library support routines for the linker. */ - -extern bfd_boolean bfd_i386linux_size_dynamic_sections - (bfd *, struct bfd_link_info *); -extern bfd_boolean bfd_m68klinux_size_dynamic_sections - (bfd *, struct bfd_link_info *); -extern bfd_boolean bfd_sparclinux_size_dynamic_sections - (bfd *, struct bfd_link_info *); - -/* mmap hacks */ - -struct _bfd_window_internal; -typedef struct _bfd_window_internal bfd_window_internal; - -typedef struct _bfd_window -{ - /* What the user asked for. */ - void *data; - bfd_size_type size; - /* The actual window used by BFD. Small user-requested read-only - regions sharing a page may share a single window into the object - file. Read-write versions shouldn't until I've fixed things to - keep track of which portions have been claimed by the - application; don't want to give the same region back when the - application wants two writable copies! */ - struct _bfd_window_internal *i; -} -bfd_window; - -extern void bfd_init_window - (bfd_window *); -extern void bfd_free_window - (bfd_window *); -extern bfd_boolean bfd_get_file_window - (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean); - -/* XCOFF support routines for the linker. */ - -extern bfd_boolean bfd_xcoff_link_record_set - (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type); -extern bfd_boolean bfd_xcoff_import_symbol - (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma, - const char *, const char *, const char *, unsigned int); -extern bfd_boolean bfd_xcoff_export_symbol - (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *); -extern bfd_boolean bfd_xcoff_link_count_reloc - (bfd *, struct bfd_link_info *, const char *); -extern bfd_boolean bfd_xcoff_record_link_assignment - (bfd *, struct bfd_link_info *, const char *); -extern bfd_boolean bfd_xcoff_size_dynamic_sections - (bfd *, struct bfd_link_info *, const char *, const char *, - unsigned long, unsigned long, unsigned long, bfd_boolean, - int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean); -extern bfd_boolean bfd_xcoff_link_generate_rtinit - (bfd *, const char *, const char *, bfd_boolean); - -/* XCOFF support routines for ar. */ -extern bfd_boolean bfd_xcoff_ar_archive_set_magic - (bfd *, char *); - -/* Externally visible COFF routines. */ - -#if defined(__STDC__) || defined(ALMOST_STDC) -struct internal_syment; -union internal_auxent; -#endif - -extern bfd_boolean bfd_coff_get_syment - (bfd *, struct bfd_symbol *, struct internal_syment *); - -extern bfd_boolean bfd_coff_get_auxent - (bfd *, struct bfd_symbol *, int, union internal_auxent *); - -extern bfd_boolean bfd_coff_set_symbol_class - (bfd *, struct bfd_symbol *, unsigned int); - -extern bfd_boolean bfd_m68k_coff_create_embedded_relocs - (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **); - -/* ARM VFP11 erratum workaround support. */ -typedef enum -{ - BFD_ARM_VFP11_FIX_DEFAULT, - BFD_ARM_VFP11_FIX_NONE, - BFD_ARM_VFP11_FIX_SCALAR, - BFD_ARM_VFP11_FIX_VECTOR -} bfd_arm_vfp11_fix; - -extern void bfd_elf32_arm_init_maps - (bfd *); - -extern void bfd_elf32_arm_set_vfp11_fix - (bfd *, struct bfd_link_info *); - -extern bfd_boolean bfd_elf32_arm_vfp11_erratum_scan - (bfd *, struct bfd_link_info *); - -extern void bfd_elf32_arm_vfp11_fix_veneer_locations - (bfd *, struct bfd_link_info *); - -/* ARM Interworking support. Called from linker. */ -extern bfd_boolean bfd_arm_allocate_interworking_sections - (struct bfd_link_info *); - -extern bfd_boolean bfd_arm_process_before_allocation - (bfd *, struct bfd_link_info *, int); - -extern bfd_boolean bfd_arm_get_bfd_for_interworking - (bfd *, struct bfd_link_info *); - -/* PE ARM Interworking support. Called from linker. */ -extern bfd_boolean bfd_arm_pe_allocate_interworking_sections - (struct bfd_link_info *); - -extern bfd_boolean bfd_arm_pe_process_before_allocation - (bfd *, struct bfd_link_info *, int); - -extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking - (bfd *, struct bfd_link_info *); - -/* ELF ARM Interworking support. Called from linker. */ -extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections - (struct bfd_link_info *); - -extern bfd_boolean bfd_elf32_arm_process_before_allocation - (bfd *, struct bfd_link_info *); - -void bfd_elf32_arm_set_target_relocs - (bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix, - int, int); - -extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking - (bfd *, struct bfd_link_info *); - -extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd - (bfd *, struct bfd_link_info *); - -/* ELF ARM mapping symbol support */ -#define BFD_ARM_SPECIAL_SYM_TYPE_MAP (1 << 0) -#define BFD_ARM_SPECIAL_SYM_TYPE_TAG (1 << 1) -#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER (1 << 2) -#define BFD_ARM_SPECIAL_SYM_TYPE_ANY (~0) -extern bfd_boolean bfd_is_arm_special_symbol_name - (const char * name, int type); - -extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int); - -/* ARM Note section processing. */ -extern bfd_boolean bfd_arm_merge_machines - (bfd *, bfd *); - -extern bfd_boolean bfd_arm_update_notes - (bfd *, const char *); - -extern unsigned int bfd_arm_get_mach_from_notes - (bfd *, const char *); - -/* TI COFF load page support. */ -extern void bfd_ticoff_set_section_load_page - (struct bfd_section *, int); - -extern int bfd_ticoff_get_section_load_page - (struct bfd_section *); - -/* H8/300 functions. */ -extern bfd_vma bfd_h8300_pad_address - (bfd *, bfd_vma); - -/* IA64 Itanium code generation. Called from linker. */ -extern void bfd_elf32_ia64_after_parse - (int); - -extern void bfd_elf64_ia64_after_parse - (int); - -/* This structure is used for a comdat section, as in PE. A comdat - section is associated with a particular symbol. When the linker - sees a comdat section, it keeps only one of the sections with a - given name and associated with a given symbol. */ - -struct coff_comdat_info -{ - /* The name of the symbol associated with a comdat section. */ - const char *name; - - /* The local symbol table index of the symbol associated with a - comdat section. This is only meaningful to the object file format - specific code; it is not an index into the list returned by - bfd_canonicalize_symtab. */ - long symbol; -}; - -extern struct coff_comdat_info *bfd_coff_get_comdat_section - (bfd *, struct bfd_section *); - -/* Extracted from init.c. */ -void bfd_init (void); - -/* Extracted from opncls.c. */ -bfd *bfd_fopen (const char *filename, const char *target, - const char *mode, int fd); - -bfd *bfd_openr (const char *filename, const char *target); - -bfd *bfd_fdopenr (const char *filename, const char *target, int fd); - -bfd *bfd_openstreamr (const char *, const char *, void *); - -bfd *bfd_openr_iovec (const char *filename, const char *target, - void *(*open) (struct bfd *nbfd, - void *open_closure), - void *open_closure, - file_ptr (*pread) (struct bfd *nbfd, - void *stream, - void *buf, - file_ptr nbytes, - file_ptr offset), - int (*close) (struct bfd *nbfd, - void *stream), - int (*stat) (struct bfd *abfd, - void *stream, - struct stat *sb)); - -bfd *bfd_openw (const char *filename, const char *target); - -bfd_boolean bfd_close (bfd *abfd); - -bfd_boolean bfd_close_all_done (bfd *); - -bfd *bfd_create (const char *filename, bfd *templ); - -bfd_boolean bfd_make_writable (bfd *abfd); - -bfd_boolean bfd_make_readable (bfd *abfd); - -unsigned long bfd_calc_gnu_debuglink_crc32 - (unsigned long crc, const unsigned char *buf, bfd_size_type len); - -char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); - -struct bfd_section *bfd_create_gnu_debuglink_section - (bfd *abfd, const char *filename); - -bfd_boolean bfd_fill_in_gnu_debuglink_section - (bfd *abfd, struct bfd_section *sect, const char *filename); - -/* Extracted from libbfd.c. */ - -/* Byte swapping macros for user section data. */ - -#define bfd_put_8(abfd, val, ptr) \ - ((void) (*((unsigned char *) (ptr)) = (val) & 0xff)) -#define bfd_put_signed_8 \ - bfd_put_8 -#define bfd_get_8(abfd, ptr) \ - (*(unsigned char *) (ptr) & 0xff) -#define bfd_get_signed_8(abfd, ptr) \ - (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) - -#define bfd_put_16(abfd, val, ptr) \ - BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) -#define bfd_put_signed_16 \ - bfd_put_16 -#define bfd_get_16(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx16, (ptr)) -#define bfd_get_signed_16(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) - -#define bfd_put_32(abfd, val, ptr) \ - BFD_SEND (abfd, bfd_putx32, ((val),(ptr))) -#define bfd_put_signed_32 \ - bfd_put_32 -#define bfd_get_32(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx32, (ptr)) -#define bfd_get_signed_32(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx_signed_32, (ptr)) - -#define bfd_put_64(abfd, val, ptr) \ - BFD_SEND (abfd, bfd_putx64, ((val), (ptr))) -#define bfd_put_signed_64 \ - bfd_put_64 -#define bfd_get_64(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx64, (ptr)) -#define bfd_get_signed_64(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx_signed_64, (ptr)) - -#define bfd_get(bits, abfd, ptr) \ - ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \ - : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ - : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ - : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ - : (abort (), (bfd_vma) - 1)) - -#define bfd_put(bits, abfd, val, ptr) \ - ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ - : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ - : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ - : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ - : (abort (), (void) 0)) - - -/* Byte swapping macros for file header data. */ - -#define bfd_h_put_8(abfd, val, ptr) \ - bfd_put_8 (abfd, val, ptr) -#define bfd_h_put_signed_8(abfd, val, ptr) \ - bfd_put_8 (abfd, val, ptr) -#define bfd_h_get_8(abfd, ptr) \ - bfd_get_8 (abfd, ptr) -#define bfd_h_get_signed_8(abfd, ptr) \ - bfd_get_signed_8 (abfd, ptr) - -#define bfd_h_put_16(abfd, val, ptr) \ - BFD_SEND (abfd, bfd_h_putx16, (val, ptr)) -#define bfd_h_put_signed_16 \ - bfd_h_put_16 -#define bfd_h_get_16(abfd, ptr) \ - BFD_SEND (abfd, bfd_h_getx16, (ptr)) -#define bfd_h_get_signed_16(abfd, ptr) \ - BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr)) - -#define bfd_h_put_32(abfd, val, ptr) \ - BFD_SEND (abfd, bfd_h_putx32, (val, ptr)) -#define bfd_h_put_signed_32 \ - bfd_h_put_32 -#define bfd_h_get_32(abfd, ptr) \ - BFD_SEND (abfd, bfd_h_getx32, (ptr)) -#define bfd_h_get_signed_32(abfd, ptr) \ - BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr)) - -#define bfd_h_put_64(abfd, val, ptr) \ - BFD_SEND (abfd, bfd_h_putx64, (val, ptr)) -#define bfd_h_put_signed_64 \ - bfd_h_put_64 -#define bfd_h_get_64(abfd, ptr) \ - BFD_SEND (abfd, bfd_h_getx64, (ptr)) -#define bfd_h_get_signed_64(abfd, ptr) \ - BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr)) - -/* Aliases for the above, which should eventually go away. */ - -#define H_PUT_64 bfd_h_put_64 -#define H_PUT_32 bfd_h_put_32 -#define H_PUT_16 bfd_h_put_16 -#define H_PUT_8 bfd_h_put_8 -#define H_PUT_S64 bfd_h_put_signed_64 -#define H_PUT_S32 bfd_h_put_signed_32 -#define H_PUT_S16 bfd_h_put_signed_16 -#define H_PUT_S8 bfd_h_put_signed_8 -#define H_GET_64 bfd_h_get_64 -#define H_GET_32 bfd_h_get_32 -#define H_GET_16 bfd_h_get_16 -#define H_GET_8 bfd_h_get_8 -#define H_GET_S64 bfd_h_get_signed_64 -#define H_GET_S32 bfd_h_get_signed_32 -#define H_GET_S16 bfd_h_get_signed_16 -#define H_GET_S8 bfd_h_get_signed_8 - - -/* Extracted from bfdio.c. */ -long bfd_get_mtime (bfd *abfd); - -file_ptr bfd_get_size (bfd *abfd); - -/* Extracted from bfdwin.c. */ -/* Extracted from section.c. */ -typedef struct bfd_section -{ - /* The name of the section; the name isn't a copy, the pointer is - the same as that passed to bfd_make_section. */ - const char *name; - - /* A unique sequence number. */ - int id; - - /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ - int index; - - /* The next section in the list belonging to the BFD, or NULL. */ - struct bfd_section *next; - - /* The previous section in the list belonging to the BFD, or NULL. */ - struct bfd_section *prev; - - /* The field flags contains attributes of the section. Some - flags are read in from the object file, and some are - synthesized from other information. */ - flagword flags; - -#define SEC_NO_FLAGS 0x000 - - /* Tells the OS to allocate space for this section when loading. - This is clear for a section containing debug information only. */ -#define SEC_ALLOC 0x001 - - /* Tells the OS to load the section from the file when loading. - This is clear for a .bss section. */ -#define SEC_LOAD 0x002 - - /* The section contains data still to be relocated, so there is - some relocation information too. */ -#define SEC_RELOC 0x004 - - /* A signal to the OS that the section contains read only data. */ -#define SEC_READONLY 0x008 - - /* The section contains code only. */ -#define SEC_CODE 0x010 - - /* The section contains data only. */ -#define SEC_DATA 0x020 - - /* The section will reside in ROM. */ -#define SEC_ROM 0x040 - - /* The section contains constructor information. This section - type is used by the linker to create lists of constructors and - destructors used by <>. When a back end sees a symbol - which should be used in a constructor list, it creates a new - section for the type of name (e.g., <<__CTOR_LIST__>>), attaches - the symbol to it, and builds a relocation. To build the lists - of constructors, all the linker has to do is catenate all the - sections called <<__CTOR_LIST__>> and relocate the data - contained within - exactly the operations it would peform on - standard data. */ -#define SEC_CONSTRUCTOR 0x080 - - /* The section has contents - a data section could be - <> | <>; a debug section could be - <> */ -#define SEC_HAS_CONTENTS 0x100 - - /* An instruction to the linker to not output the section - even if it has information which would normally be written. */ -#define SEC_NEVER_LOAD 0x200 - - /* The section contains thread local data. */ -#define SEC_THREAD_LOCAL 0x400 - - /* The section has GOT references. This flag is only for the - linker, and is currently only used by the elf32-hppa back end. - It will be set if global offset table references were detected - in this section, which indicate to the linker that the section - contains PIC code, and must be handled specially when doing a - static link. */ -#define SEC_HAS_GOT_REF 0x800 - - /* The section contains common symbols (symbols may be defined - multiple times, the value of a symbol is the amount of - space it requires, and the largest symbol value is the one - used). Most targets have exactly one of these (which we - translate to bfd_com_section_ptr), but ECOFF has two. */ -#define SEC_IS_COMMON 0x1000 - - /* The section contains only debugging information. For - example, this is set for ELF .debug and .stab sections. - strip tests this flag to see if a section can be - discarded. */ -#define SEC_DEBUGGING 0x2000 - - /* The contents of this section are held in memory pointed to - by the contents field. This is checked by bfd_get_section_contents, - and the data is retrieved from memory if appropriate. */ -#define SEC_IN_MEMORY 0x4000 - - /* The contents of this section are to be excluded by the - linker for executable and shared objects unless those - objects are to be further relocated. */ -#define SEC_EXCLUDE 0x8000 - - /* The contents of this section are to be sorted based on the sum of - the symbol and addend values specified by the associated relocation - entries. Entries without associated relocation entries will be - appended to the end of the section in an unspecified order. */ -#define SEC_SORT_ENTRIES 0x10000 - - /* When linking, duplicate sections of the same name should be - discarded, rather than being combined into a single section as - is usually done. This is similar to how common symbols are - handled. See SEC_LINK_DUPLICATES below. */ -#define SEC_LINK_ONCE 0x20000 - - /* If SEC_LINK_ONCE is set, this bitfield describes how the linker - should handle duplicate sections. */ -#define SEC_LINK_DUPLICATES 0x40000 - - /* This value for SEC_LINK_DUPLICATES means that duplicate - sections with the same name should simply be discarded. */ -#define SEC_LINK_DUPLICATES_DISCARD 0x0 - - /* This value for SEC_LINK_DUPLICATES means that the linker - should warn if there are any duplicate sections, although - it should still only link one copy. */ -#define SEC_LINK_DUPLICATES_ONE_ONLY 0x80000 - - /* This value for SEC_LINK_DUPLICATES means that the linker - should warn if any duplicate sections are a different size. */ -#define SEC_LINK_DUPLICATES_SAME_SIZE 0x100000 - - /* This value for SEC_LINK_DUPLICATES means that the linker - should warn if any duplicate sections contain different - contents. */ -#define SEC_LINK_DUPLICATES_SAME_CONTENTS \ - (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE) - - /* This section was created by the linker as part of dynamic - relocation or other arcane processing. It is skipped when - going through the first-pass output, trusting that someone - else up the line will take care of it later. */ -#define SEC_LINKER_CREATED 0x200000 - - /* This section should not be subject to garbage collection. - Also set to inform the linker that this section should not be - listed in the link map as discarded. */ -#define SEC_KEEP 0x400000 - - /* This section contains "short" data, and should be placed - "near" the GP. */ -#define SEC_SMALL_DATA 0x800000 - - /* Attempt to merge identical entities in the section. - Entity size is given in the entsize field. */ -#define SEC_MERGE 0x1000000 - - /* If given with SEC_MERGE, entities to merge are zero terminated - strings where entsize specifies character size instead of fixed - size entries. */ -#define SEC_STRINGS 0x2000000 - - /* This section contains data about section groups. */ -#define SEC_GROUP 0x4000000 - - /* The section is a COFF shared library section. This flag is - only for the linker. If this type of section appears in - the input file, the linker must copy it to the output file - without changing the vma or size. FIXME: Although this - was originally intended to be general, it really is COFF - specific (and the flag was renamed to indicate this). It - might be cleaner to have some more general mechanism to - allow the back end to control what the linker does with - sections. */ -#define SEC_COFF_SHARED_LIBRARY 0x10000000 - - /* This section contains data which may be shared with other - executables or shared objects. This is for COFF only. */ -#define SEC_COFF_SHARED 0x20000000 - - /* When a section with this flag is being linked, then if the size of - the input section is less than a page, it should not cross a page - boundary. If the size of the input section is one page or more, - it should be aligned on a page boundary. This is for TI - TMS320C54X only. */ -#define SEC_TIC54X_BLOCK 0x40000000 - - /* Conditionally link this section; do not link if there are no - references found to any symbol in the section. This is for TI - TMS320C54X only. */ -#define SEC_TIC54X_CLINK 0x80000000 - - /* End of section flags. */ - - /* Some internal packed boolean fields. */ - - /* See the vma field. */ - unsigned int user_set_vma : 1; - - /* A mark flag used by some of the linker backends. */ - unsigned int linker_mark : 1; - - /* Another mark flag used by some of the linker backends. Set for - output sections that have an input section. */ - unsigned int linker_has_input : 1; - - /* Mark flags used by some linker backends for garbage collection. */ - unsigned int gc_mark : 1; - unsigned int gc_mark_from_eh : 1; - - /* The following flags are used by the ELF linker. */ - - /* Mark sections which have been allocated to segments. */ - unsigned int segment_mark : 1; - - /* Type of sec_info information. */ - unsigned int sec_info_type:3; -#define ELF_INFO_TYPE_NONE 0 -#define ELF_INFO_TYPE_STABS 1 -#define ELF_INFO_TYPE_MERGE 2 -#define ELF_INFO_TYPE_EH_FRAME 3 -#define ELF_INFO_TYPE_JUST_SYMS 4 - - /* Nonzero if this section uses RELA relocations, rather than REL. */ - unsigned int use_rela_p:1; - - /* Bits used by various backends. The generic code doesn't touch - these fields. */ - - /* Nonzero if this section has TLS related relocations. */ - unsigned int has_tls_reloc:1; - - /* Nonzero if this section has a call to __tls_get_addr. */ - unsigned int has_tls_get_addr_call:1; - - /* Nonzero if this section has a gp reloc. */ - unsigned int has_gp_reloc:1; - - /* Nonzero if this section needs the relax finalize pass. */ - unsigned int need_finalize_relax:1; - - /* Whether relocations have been processed. */ - unsigned int reloc_done : 1; - - /* End of internal packed boolean fields. */ - - /* The virtual memory address of the section - where it will be - at run time. The symbols are relocated against this. The - user_set_vma flag is maintained by bfd; if it's not set, the - backend can assign addresses (for example, in <>, where - the default address for <<.data>> is dependent on the specific - target and various flags). */ - bfd_vma vma; - - /* The load address of the section - where it would be in a - rom image; really only used for writing section header - information. */ - bfd_vma lma; - - /* The size of the section in octets, as it will be output. - Contains a value even if the section has no contents (e.g., the - size of <<.bss>>). */ - bfd_size_type size; - - /* For input sections, the original size on disk of the section, in - octets. This field is used by the linker relaxation code. It is - currently only set for sections where the linker relaxation scheme - doesn't cache altered section and reloc contents (stabs, eh_frame, - SEC_MERGE, some coff relaxing targets), and thus the original size - needs to be kept to read the section multiple times. - For output sections, rawsize holds the section size calculated on - a previous linker relaxation pass. */ - bfd_size_type rawsize; - - /* If this section is going to be output, then this value is the - offset in *bytes* into the output section of the first byte in the - input section (byte ==> smallest addressable unit on the - target). In most cases, if this was going to start at the - 100th octet (8-bit quantity) in the output section, this value - would be 100. However, if the target byte size is 16 bits - (bfd_octets_per_byte is "2"), this value would be 50. */ - bfd_vma output_offset; - - /* The output section through which to map on output. */ - struct bfd_section *output_section; - - /* The alignment requirement of the section, as an exponent of 2 - - e.g., 3 aligns to 2^3 (or 8). */ - unsigned int alignment_power; - - /* If an input section, a pointer to a vector of relocation - records for the data in this section. */ - struct reloc_cache_entry *relocation; - - /* If an output section, a pointer to a vector of pointers to - relocation records for the data in this section. */ - struct reloc_cache_entry **orelocation; - - /* The number of relocation records in one of the above. */ - unsigned reloc_count; - - /* Information below is back end specific - and not always used - or updated. */ - - /* File position of section data. */ - file_ptr filepos; - - /* File position of relocation info. */ - file_ptr rel_filepos; - - /* File position of line data. */ - file_ptr line_filepos; - - /* Pointer to data for applications. */ - void *userdata; - - /* If the SEC_IN_MEMORY flag is set, this points to the actual - contents. */ - unsigned char *contents; - - /* Attached line number information. */ - alent *lineno; - - /* Number of line number records. */ - unsigned int lineno_count; - - /* Entity size for merging purposes. */ - unsigned int entsize; - - /* Points to the kept section if this section is a link-once section, - and is discarded. */ - struct bfd_section *kept_section; - - /* When a section is being output, this value changes as more - linenumbers are written out. */ - file_ptr moving_line_filepos; - - /* What the section number is in the target world. */ - int target_index; - - void *used_by_bfd; - - /* If this is a constructor section then here is a list of the - relocations created to relocate items within it. */ - struct relent_chain *constructor_chain; - - /* The BFD which owns the section. */ - bfd *owner; - - /* A symbol which points at this section only. */ - struct bfd_symbol *symbol; - struct bfd_symbol **symbol_ptr_ptr; - - /* Early in the link process, map_head and map_tail are used to build - a list of input sections attached to an output section. Later, - output sections use these fields for a list of bfd_link_order - structs. */ - union { - struct bfd_link_order *link_order; - struct bfd_section *s; - } map_head, map_tail; -} asection; - -/* These sections are global, and are managed by BFD. The application - and target back end are not permitted to change the values in - these sections. New code should use the section_ptr macros rather - than referring directly to the const sections. The const sections - may eventually vanish. */ -#define BFD_ABS_SECTION_NAME "*ABS*" -#define BFD_UND_SECTION_NAME "*UND*" -#define BFD_COM_SECTION_NAME "*COM*" -#define BFD_IND_SECTION_NAME "*IND*" - -/* The absolute section. */ -extern asection bfd_abs_section; -#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) -#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) -/* Pointer to the undefined section. */ -extern asection bfd_und_section; -#define bfd_und_section_ptr ((asection *) &bfd_und_section) -#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) -/* Pointer to the common section. */ -extern asection bfd_com_section; -#define bfd_com_section_ptr ((asection *) &bfd_com_section) -/* Pointer to the indirect section. */ -extern asection bfd_ind_section; -#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) -#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) - -#define bfd_is_const_section(SEC) \ - ( ((SEC) == bfd_abs_section_ptr) \ - || ((SEC) == bfd_und_section_ptr) \ - || ((SEC) == bfd_com_section_ptr) \ - || ((SEC) == bfd_ind_section_ptr)) - -/* Macros to handle insertion and deletion of a bfd's sections. These - only handle the list pointers, ie. do not adjust section_count, - target_index etc. */ -#define bfd_section_list_remove(ABFD, S) \ - do \ - { \ - asection *_s = S; \ - asection *_next = _s->next; \ - asection *_prev = _s->prev; \ - if (_prev) \ - _prev->next = _next; \ - else \ - (ABFD)->sections = _next; \ - if (_next) \ - _next->prev = _prev; \ - else \ - (ABFD)->section_last = _prev; \ - } \ - while (0) -#define bfd_section_list_append(ABFD, S) \ - do \ - { \ - asection *_s = S; \ - bfd *_abfd = ABFD; \ - _s->next = NULL; \ - if (_abfd->section_last) \ - { \ - _s->prev = _abfd->section_last; \ - _abfd->section_last->next = _s; \ - } \ - else \ - { \ - _s->prev = NULL; \ - _abfd->sections = _s; \ - } \ - _abfd->section_last = _s; \ - } \ - while (0) -#define bfd_section_list_prepend(ABFD, S) \ - do \ - { \ - asection *_s = S; \ - bfd *_abfd = ABFD; \ - _s->prev = NULL; \ - if (_abfd->sections) \ - { \ - _s->next = _abfd->sections; \ - _abfd->sections->prev = _s; \ - } \ - else \ - { \ - _s->next = NULL; \ - _abfd->section_last = _s; \ - } \ - _abfd->sections = _s; \ - } \ - while (0) -#define bfd_section_list_insert_after(ABFD, A, S) \ - do \ - { \ - asection *_a = A; \ - asection *_s = S; \ - asection *_next = _a->next; \ - _s->next = _next; \ - _s->prev = _a; \ - _a->next = _s; \ - if (_next) \ - _next->prev = _s; \ - else \ - (ABFD)->section_last = _s; \ - } \ - while (0) -#define bfd_section_list_insert_before(ABFD, B, S) \ - do \ - { \ - asection *_b = B; \ - asection *_s = S; \ - asection *_prev = _b->prev; \ - _s->prev = _prev; \ - _s->next = _b; \ - _b->prev = _s; \ - if (_prev) \ - _prev->next = _s; \ - else \ - (ABFD)->sections = _s; \ - } \ - while (0) -#define bfd_section_removed_from_list(ABFD, S) \ - ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S)) - -#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX) \ - /* name, id, index, next, prev, flags, user_set_vma, */ \ - { NAME, IDX, 0, NULL, NULL, FLAGS, 0, \ - \ - /* linker_mark, linker_has_input, gc_mark, gc_mark_from_eh, */ \ - 0, 0, 1, 0, \ - \ - /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */ \ - 0, 0, 0, 0, \ - \ - /* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax, */ \ - 0, 0, 0, \ - \ - /* reloc_done, vma, lma, size, rawsize */ \ - 0, 0, 0, 0, 0, \ - \ - /* output_offset, output_section, alignment_power, */ \ - 0, (struct bfd_section *) &SEC, 0, \ - \ - /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ - NULL, NULL, 0, 0, 0, \ - \ - /* line_filepos, userdata, contents, lineno, lineno_count, */ \ - 0, NULL, NULL, NULL, 0, \ - \ - /* entsize, kept_section, moving_line_filepos, */ \ - 0, NULL, 0, \ - \ - /* target_index, used_by_bfd, constructor_chain, owner, */ \ - 0, NULL, NULL, NULL, \ - \ - /* symbol, symbol_ptr_ptr, */ \ - (struct bfd_symbol *) SYM, &SEC.symbol, \ - \ - /* map_head, map_tail */ \ - { NULL }, { NULL } \ - } - -void bfd_section_list_clear (bfd *); - -asection *bfd_get_section_by_name (bfd *abfd, const char *name); - -asection *bfd_get_section_by_name_if - (bfd *abfd, - const char *name, - bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj), - void *obj); - -char *bfd_get_unique_section_name - (bfd *abfd, const char *templat, int *count); - -asection *bfd_make_section_old_way (bfd *abfd, const char *name); - -asection *bfd_make_section_anyway_with_flags - (bfd *abfd, const char *name, flagword flags); - -asection *bfd_make_section_anyway (bfd *abfd, const char *name); - -asection *bfd_make_section_with_flags - (bfd *, const char *name, flagword flags); - -asection *bfd_make_section (bfd *, const char *name); - -bfd_boolean bfd_set_section_flags - (bfd *abfd, asection *sec, flagword flags); - -void bfd_map_over_sections - (bfd *abfd, - void (*func) (bfd *abfd, asection *sect, void *obj), - void *obj); - -asection *bfd_sections_find_if - (bfd *abfd, - bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj), - void *obj); - -bfd_boolean bfd_set_section_size - (bfd *abfd, asection *sec, bfd_size_type val); - -bfd_boolean bfd_set_section_contents - (bfd *abfd, asection *section, const void *data, - file_ptr offset, bfd_size_type count); - -bfd_boolean bfd_get_section_contents - (bfd *abfd, asection *section, void *location, file_ptr offset, - bfd_size_type count); - -bfd_boolean bfd_malloc_and_get_section - (bfd *abfd, asection *section, bfd_byte **buf); - -bfd_boolean bfd_copy_private_section_data - (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); - -#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ - BFD_SEND (obfd, _bfd_copy_private_section_data, \ - (ibfd, isection, obfd, osection)) -bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec); - -bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); - -/* Extracted from archures.c. */ -enum bfd_architecture -{ - bfd_arch_unknown, /* File arch not known. */ - bfd_arch_obscure, /* Arch known, not one of these. */ - bfd_arch_m68k, /* Motorola 68xxx */ -#define bfd_mach_m68000 1 -#define bfd_mach_m68008 2 -#define bfd_mach_m68010 3 -#define bfd_mach_m68020 4 -#define bfd_mach_m68030 5 -#define bfd_mach_m68040 6 -#define bfd_mach_m68060 7 -#define bfd_mach_cpu32 8 -#define bfd_mach_fido 9 -#define bfd_mach_mcf_isa_a_nodiv 10 -#define bfd_mach_mcf_isa_a 11 -#define bfd_mach_mcf_isa_a_mac 12 -#define bfd_mach_mcf_isa_a_emac 13 -#define bfd_mach_mcf_isa_aplus 14 -#define bfd_mach_mcf_isa_aplus_mac 15 -#define bfd_mach_mcf_isa_aplus_emac 16 -#define bfd_mach_mcf_isa_b_nousp 17 -#define bfd_mach_mcf_isa_b_nousp_mac 18 -#define bfd_mach_mcf_isa_b_nousp_emac 19 -#define bfd_mach_mcf_isa_b 20 -#define bfd_mach_mcf_isa_b_mac 21 -#define bfd_mach_mcf_isa_b_emac 22 -#define bfd_mach_mcf_isa_b_float 23 -#define bfd_mach_mcf_isa_b_float_mac 24 -#define bfd_mach_mcf_isa_b_float_emac 25 -#define bfd_mach_mcf_isa_c 26 -#define bfd_mach_mcf_isa_c_mac 27 -#define bfd_mach_mcf_isa_c_emac 28 - bfd_arch_vax, /* DEC Vax */ - bfd_arch_i960, /* Intel 960 */ - /* The order of the following is important. - lower number indicates a machine type that - only accepts a subset of the instructions - available to machines with higher numbers. - The exception is the "ca", which is - incompatible with all other machines except - "core". */ - -#define bfd_mach_i960_core 1 -#define bfd_mach_i960_ka_sa 2 -#define bfd_mach_i960_kb_sb 3 -#define bfd_mach_i960_mc 4 -#define bfd_mach_i960_xa 5 -#define bfd_mach_i960_ca 6 -#define bfd_mach_i960_jx 7 -#define bfd_mach_i960_hx 8 - - bfd_arch_or32, /* OpenRISC 32 */ - - bfd_arch_sparc, /* SPARC */ -#define bfd_mach_sparc 1 -/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ -#define bfd_mach_sparc_sparclet 2 -#define bfd_mach_sparc_sparclite 3 -#define bfd_mach_sparc_v8plus 4 -#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */ -#define bfd_mach_sparc_sparclite_le 6 -#define bfd_mach_sparc_v9 7 -#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */ -#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */ -#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */ -/* Nonzero if MACH has the v9 instruction set. */ -#define bfd_mach_sparc_v9_p(mach) \ - ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \ - && (mach) != bfd_mach_sparc_sparclite_le) -/* Nonzero if MACH is a 64 bit sparc architecture. */ -#define bfd_mach_sparc_64bit_p(mach) \ - ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb) - bfd_arch_spu, /* PowerPC SPU */ -#define bfd_mach_spu 256 - bfd_arch_mips, /* MIPS Rxxxx */ -#define bfd_mach_mips3000 3000 -#define bfd_mach_mips3900 3900 -#define bfd_mach_mips4000 4000 -#define bfd_mach_mips4010 4010 -#define bfd_mach_mips4100 4100 -#define bfd_mach_mips4111 4111 -#define bfd_mach_mips4120 4120 -#define bfd_mach_mips4300 4300 -#define bfd_mach_mips4400 4400 -#define bfd_mach_mips4600 4600 -#define bfd_mach_mips4650 4650 -#define bfd_mach_mips5000 5000 -#define bfd_mach_mips5400 5400 -#define bfd_mach_mips5500 5500 -#define bfd_mach_mips6000 6000 -#define bfd_mach_mips7000 7000 -#define bfd_mach_mips8000 8000 -#define bfd_mach_mips9000 9000 -#define bfd_mach_mips10000 10000 -#define bfd_mach_mips12000 12000 -#define bfd_mach_mips16 16 -#define bfd_mach_mips5 5 -#define bfd_mach_mips_octeon 6502 -#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01 */ -#define bfd_mach_mipsisa32 32 -#define bfd_mach_mipsisa32r2 33 -#define bfd_mach_mipsisa64 64 -#define bfd_mach_mipsisa64r2 65 - bfd_arch_i386, /* Intel 386 */ -#define bfd_mach_i386_i386 1 -#define bfd_mach_i386_i8086 2 -#define bfd_mach_i386_i386_intel_syntax 3 -#define bfd_mach_x86_64 64 -#define bfd_mach_x86_64_intel_syntax 65 - bfd_arch_we32k, /* AT&T WE32xxx */ - bfd_arch_tahoe, /* CCI/Harris Tahoe */ - bfd_arch_i860, /* Intel 860 */ - bfd_arch_i370, /* IBM 360/370 Mainframes */ - bfd_arch_romp, /* IBM ROMP PC/RT */ - bfd_arch_convex, /* Convex */ - bfd_arch_m88k, /* Motorola 88xxx */ - bfd_arch_m98k, /* Motorola 98xxx */ - bfd_arch_pyramid, /* Pyramid Technology */ - bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300) */ -#define bfd_mach_h8300 1 -#define bfd_mach_h8300h 2 -#define bfd_mach_h8300s 3 -#define bfd_mach_h8300hn 4 -#define bfd_mach_h8300sn 5 -#define bfd_mach_h8300sx 6 -#define bfd_mach_h8300sxn 7 - bfd_arch_pdp11, /* DEC PDP-11 */ - bfd_arch_powerpc, /* PowerPC */ -#define bfd_mach_ppc 32 -#define bfd_mach_ppc64 64 -#define bfd_mach_ppc_403 403 -#define bfd_mach_ppc_403gc 4030 -#define bfd_mach_ppc_505 505 -#define bfd_mach_ppc_601 601 -#define bfd_mach_ppc_602 602 -#define bfd_mach_ppc_603 603 -#define bfd_mach_ppc_ec603e 6031 -#define bfd_mach_ppc_604 604 -#define bfd_mach_ppc_620 620 -#define bfd_mach_ppc_630 630 -#define bfd_mach_ppc_750 750 -#define bfd_mach_ppc_860 860 -#define bfd_mach_ppc_a35 35 -#define bfd_mach_ppc_rs64ii 642 -#define bfd_mach_ppc_rs64iii 643 -#define bfd_mach_ppc_7400 7400 -#define bfd_mach_ppc_e500 500 - bfd_arch_rs6000, /* IBM RS/6000 */ -#define bfd_mach_rs6k 6000 -#define bfd_mach_rs6k_rs1 6001 -#define bfd_mach_rs6k_rsc 6003 -#define bfd_mach_rs6k_rs2 6002 - bfd_arch_hppa, /* HP PA RISC */ -#define bfd_mach_hppa10 10 -#define bfd_mach_hppa11 11 -#define bfd_mach_hppa20 20 -#define bfd_mach_hppa20w 25 - bfd_arch_d10v, /* Mitsubishi D10V */ -#define bfd_mach_d10v 1 -#define bfd_mach_d10v_ts2 2 -#define bfd_mach_d10v_ts3 3 - bfd_arch_d30v, /* Mitsubishi D30V */ - bfd_arch_dlx, /* DLX */ - bfd_arch_m68hc11, /* Motorola 68HC11 */ - bfd_arch_m68hc12, /* Motorola 68HC12 */ -#define bfd_mach_m6812_default 0 -#define bfd_mach_m6812 1 -#define bfd_mach_m6812s 2 - bfd_arch_z8k, /* Zilog Z8000 */ -#define bfd_mach_z8001 1 -#define bfd_mach_z8002 2 - bfd_arch_h8500, /* Renesas H8/500 (formerly Hitachi H8/500) */ - bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH) */ -#define bfd_mach_sh 1 -#define bfd_mach_sh2 0x20 -#define bfd_mach_sh_dsp 0x2d -#define bfd_mach_sh2a 0x2a -#define bfd_mach_sh2a_nofpu 0x2b -#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1 -#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2 -#define bfd_mach_sh2a_or_sh4 0x2a3 -#define bfd_mach_sh2a_or_sh3e 0x2a4 -#define bfd_mach_sh2e 0x2e -#define bfd_mach_sh3 0x30 -#define bfd_mach_sh3_nommu 0x31 -#define bfd_mach_sh3_dsp 0x3d -#define bfd_mach_sh3e 0x3e -#define bfd_mach_sh4 0x40 -#define bfd_mach_sh4_nofpu 0x41 -#define bfd_mach_sh4_nommu_nofpu 0x42 -#define bfd_mach_sh4a 0x4a -#define bfd_mach_sh4a_nofpu 0x4b -#define bfd_mach_sh4al_dsp 0x4d -#define bfd_mach_sh5 0x50 - bfd_arch_alpha, /* Dec Alpha */ -#define bfd_mach_alpha_ev4 0x10 -#define bfd_mach_alpha_ev5 0x20 -#define bfd_mach_alpha_ev6 0x30 - bfd_arch_arm, /* Advanced Risc Machines ARM. */ -#define bfd_mach_arm_unknown 0 -#define bfd_mach_arm_2 1 -#define bfd_mach_arm_2a 2 -#define bfd_mach_arm_3 3 -#define bfd_mach_arm_3M 4 -#define bfd_mach_arm_4 5 -#define bfd_mach_arm_4T 6 -#define bfd_mach_arm_5 7 -#define bfd_mach_arm_5T 8 -#define bfd_mach_arm_5TE 9 -#define bfd_mach_arm_XScale 10 -#define bfd_mach_arm_ep9312 11 -#define bfd_mach_arm_iWMMXt 12 -#define bfd_mach_arm_iWMMXt2 13 - bfd_arch_ns32k, /* National Semiconductors ns32000 */ - bfd_arch_w65, /* WDC 65816 */ - bfd_arch_tic30, /* Texas Instruments TMS320C30 */ - bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X */ -#define bfd_mach_tic3x 30 -#define bfd_mach_tic4x 40 - bfd_arch_tic54x, /* Texas Instruments TMS320C54X */ - bfd_arch_tic80, /* TI TMS320c80 (MVP) */ - bfd_arch_v850, /* NEC V850 */ -#define bfd_mach_v850 1 -#define bfd_mach_v850e 'E' -#define bfd_mach_v850e1 '1' - bfd_arch_arc, /* ARC Cores */ -#define bfd_mach_arc_5 5 -#define bfd_mach_arc_6 6 -#define bfd_mach_arc_7 7 -#define bfd_mach_arc_8 8 - bfd_arch_m32c, /* Renesas M16C/M32C. */ -#define bfd_mach_m16c 0x75 -#define bfd_mach_m32c 0x78 - bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D) */ -#define bfd_mach_m32r 1 /* For backwards compatibility. */ -#define bfd_mach_m32rx 'x' -#define bfd_mach_m32r2 '2' - bfd_arch_mn10200, /* Matsushita MN10200 */ - bfd_arch_mn10300, /* Matsushita MN10300 */ -#define bfd_mach_mn10300 300 -#define bfd_mach_am33 330 -#define bfd_mach_am33_2 332 - bfd_arch_fr30, -#define bfd_mach_fr30 0x46523330 - bfd_arch_frv, -#define bfd_mach_frv 1 -#define bfd_mach_frvsimple 2 -#define bfd_mach_fr300 300 -#define bfd_mach_fr400 400 -#define bfd_mach_fr450 450 -#define bfd_mach_frvtomcat 499 /* fr500 prototype */ -#define bfd_mach_fr500 500 -#define bfd_mach_fr550 550 - bfd_arch_mcore, - bfd_arch_mep, -#define bfd_mach_mep 1 -#define bfd_mach_mep_h1 0x6831 - bfd_arch_ia64, /* HP/Intel ia64 */ -#define bfd_mach_ia64_elf64 64 -#define bfd_mach_ia64_elf32 32 - bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */ -#define bfd_mach_ip2022 1 -#define bfd_mach_ip2022ext 2 - bfd_arch_iq2000, /* Vitesse IQ2000. */ -#define bfd_mach_iq2000 1 -#define bfd_mach_iq10 2 - bfd_arch_mt, -#define bfd_mach_ms1 1 -#define bfd_mach_mrisc2 2 -#define bfd_mach_ms2 3 - bfd_arch_pj, - bfd_arch_avr, /* Atmel AVR microcontrollers. */ -#define bfd_mach_avr1 1 -#define bfd_mach_avr2 2 -#define bfd_mach_avr3 3 -#define bfd_mach_avr4 4 -#define bfd_mach_avr5 5 -#define bfd_mach_avr6 6 - bfd_arch_bfin, /* ADI Blackfin */ -#define bfd_mach_bfin 1 - bfd_arch_cr16, /* National Semiconductor CompactRISC (ie CR16). */ -#define bfd_mach_cr16 1 - bfd_arch_cr16c, /* National Semiconductor CompactRISC. */ -#define bfd_mach_cr16c 1 - bfd_arch_crx, /* National Semiconductor CRX. */ -#define bfd_mach_crx 1 - bfd_arch_cris, /* Axis CRIS */ -#define bfd_mach_cris_v0_v10 255 -#define bfd_mach_cris_v32 32 -#define bfd_mach_cris_v10_v32 1032 - bfd_arch_s390, /* IBM s390 */ -#define bfd_mach_s390_31 31 -#define bfd_mach_s390_64 64 - bfd_arch_score, /* Sunplus score */ - bfd_arch_openrisc, /* OpenRISC */ - bfd_arch_mmix, /* Donald Knuth's educational processor. */ - bfd_arch_xstormy16, -#define bfd_mach_xstormy16 1 - bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */ -#define bfd_mach_msp11 11 -#define bfd_mach_msp110 110 -#define bfd_mach_msp12 12 -#define bfd_mach_msp13 13 -#define bfd_mach_msp14 14 -#define bfd_mach_msp15 15 -#define bfd_mach_msp16 16 -#define bfd_mach_msp21 21 -#define bfd_mach_msp31 31 -#define bfd_mach_msp32 32 -#define bfd_mach_msp33 33 -#define bfd_mach_msp41 41 -#define bfd_mach_msp42 42 -#define bfd_mach_msp43 43 -#define bfd_mach_msp44 44 - bfd_arch_xc16x, /* Infineon's XC16X Series. */ -#define bfd_mach_xc16x 1 -#define bfd_mach_xc16xl 2 -#define bfd_mach_xc16xs 3 - bfd_arch_xtensa, /* Tensilica's Xtensa cores. */ -#define bfd_mach_xtensa 1 - bfd_arch_maxq, /* Dallas MAXQ 10/20 */ -#define bfd_mach_maxq10 10 -#define bfd_mach_maxq20 20 - bfd_arch_z80, -#define bfd_mach_z80strict 1 /* No undocumented opcodes. */ -#define bfd_mach_z80 3 /* With ixl, ixh, iyl, and iyh. */ -#define bfd_mach_z80full 7 /* All undocumented instructions. */ -#define bfd_mach_r800 11 /* R800: successor with multiplication. */ - bfd_arch_last - }; - -typedef struct bfd_arch_info -{ - int bits_per_word; - int bits_per_address; - int bits_per_byte; - enum bfd_architecture arch; - unsigned long mach; - const char *arch_name; - const char *printable_name; - unsigned int section_align_power; - /* TRUE if this is the default machine for the architecture. - The default arch should be the first entry for an arch so that - all the entries for that arch can be accessed via <>. */ - bfd_boolean the_default; - const struct bfd_arch_info * (*compatible) - (const struct bfd_arch_info *a, const struct bfd_arch_info *b); - - bfd_boolean (*scan) (const struct bfd_arch_info *, const char *); - - const struct bfd_arch_info *next; -} -bfd_arch_info_type; - -const char *bfd_printable_name (bfd *abfd); - -const bfd_arch_info_type *bfd_scan_arch (const char *string); - -const char **bfd_arch_list (void); - -const bfd_arch_info_type *bfd_arch_get_compatible - (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns); - -void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg); - -enum bfd_architecture bfd_get_arch (bfd *abfd); - -unsigned long bfd_get_mach (bfd *abfd); - -unsigned int bfd_arch_bits_per_byte (bfd *abfd); - -unsigned int bfd_arch_bits_per_address (bfd *abfd); - -const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd); - -const bfd_arch_info_type *bfd_lookup_arch - (enum bfd_architecture arch, unsigned long machine); - -const char *bfd_printable_arch_mach - (enum bfd_architecture arch, unsigned long machine); - -unsigned int bfd_octets_per_byte (bfd *abfd); - -unsigned int bfd_arch_mach_octets_per_byte - (enum bfd_architecture arch, unsigned long machine); - -/* Extracted from reloc.c. */ -typedef enum bfd_reloc_status -{ - /* No errors detected. */ - bfd_reloc_ok, - - /* The relocation was performed, but there was an overflow. */ - bfd_reloc_overflow, - - /* The address to relocate was not within the section supplied. */ - bfd_reloc_outofrange, - - /* Used by special functions. */ - bfd_reloc_continue, - - /* Unsupported relocation size requested. */ - bfd_reloc_notsupported, - - /* Unused. */ - bfd_reloc_other, - - /* The symbol to relocate against was undefined. */ - bfd_reloc_undefined, - - /* The relocation was performed, but may not be ok - presently - generated only when linking i960 coff files with i960 b.out - symbols. If this type is returned, the error_message argument - to bfd_perform_relocation will be set. */ - bfd_reloc_dangerous - } - bfd_reloc_status_type; - - -typedef struct reloc_cache_entry -{ - /* A pointer into the canonical table of pointers. */ - struct bfd_symbol **sym_ptr_ptr; - - /* offset in section. */ - bfd_size_type address; - - /* addend for relocation value. */ - bfd_vma addend; - - /* Pointer to how to perform the required relocation. */ - reloc_howto_type *howto; - -} -arelent; - -enum complain_overflow -{ - /* Do not complain on overflow. */ - complain_overflow_dont, - - /* Complain if the value overflows when considered as a signed - number one bit larger than the field. ie. A bitfield of N bits - is allowed to represent -2**n to 2**n-1. */ - complain_overflow_bitfield, - - /* Complain if the value overflows when considered as a signed - number. */ - complain_overflow_signed, - - /* Complain if the value overflows when considered as an - unsigned number. */ - complain_overflow_unsigned -}; - -struct reloc_howto_struct -{ - /* The type field has mainly a documentary use - the back end can - do what it wants with it, though normally the back end's - external idea of what a reloc number is stored - in this field. For example, a PC relative word relocation - in a coff environment has the type 023 - because that's - what the outside world calls a R_PCRWORD reloc. */ - unsigned int type; - - /* The value the final relocation is shifted right by. This drops - unwanted data from the relocation. */ - unsigned int rightshift; - - /* The size of the item to be relocated. This is *not* a - power-of-two measure. To get the number of bytes operated - on by a type of relocation, use bfd_get_reloc_size. */ - int size; - - /* The number of bits in the item to be relocated. This is used - when doing overflow checking. */ - unsigned int bitsize; - - /* Notes that the relocation is relative to the location in the - data section of the addend. The relocation function will - subtract from the relocation value the address of the location - being relocated. */ - bfd_boolean pc_relative; - - /* The bit position of the reloc value in the destination. - The relocated value is left shifted by this amount. */ - unsigned int bitpos; - - /* What type of overflow error should be checked for when - relocating. */ - enum complain_overflow complain_on_overflow; - - /* If this field is non null, then the supplied function is - called rather than the normal function. This allows really - strange relocation methods to be accommodated (e.g., i960 callj - instructions). */ - bfd_reloc_status_type (*special_function) - (bfd *, arelent *, struct bfd_symbol *, void *, asection *, - bfd *, char **); - - /* The textual name of the relocation type. */ - char *name; - - /* Some formats record a relocation addend in the section contents - rather than with the relocation. For ELF formats this is the - distinction between USE_REL and USE_RELA (though the code checks - for USE_REL == 1/0). The value of this field is TRUE if the - addend is recorded with the section contents; when performing a - partial link (ld -r) the section contents (the data) will be - modified. The value of this field is FALSE if addends are - recorded with the relocation (in arelent.addend); when performing - a partial link the relocation will be modified. - All relocations for all ELF USE_RELA targets should set this field - to FALSE (values of TRUE should be looked on with suspicion). - However, the converse is not true: not all relocations of all ELF - USE_REL targets set this field to TRUE. Why this is so is peculiar - to each particular target. For relocs that aren't used in partial - links (e.g. GOT stuff) it doesn't matter what this is set to. */ - bfd_boolean partial_inplace; - - /* src_mask selects the part of the instruction (or data) to be used - in the relocation sum. If the target relocations don't have an - addend in the reloc, eg. ELF USE_REL, src_mask will normally equal - dst_mask to extract the addend from the section contents. If - relocations do have an addend in the reloc, eg. ELF USE_RELA, this - field should be zero. Non-zero values for ELF USE_RELA targets are - bogus as in those cases the value in the dst_mask part of the - section contents should be treated as garbage. */ - bfd_vma src_mask; - - /* dst_mask selects which parts of the instruction (or data) are - replaced with a relocated value. */ - bfd_vma dst_mask; - - /* When some formats create PC relative instructions, they leave - the value of the pc of the place being relocated in the offset - slot of the instruction, so that a PC relative relocation can - be made just by adding in an ordinary offset (e.g., sun3 a.out). - Some formats leave the displacement part of an instruction - empty (e.g., m88k bcs); this flag signals the fact. */ - bfd_boolean pcrel_offset; -}; - -#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ - { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC } -#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \ - HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \ - NAME, FALSE, 0, 0, IN) - -#define EMPTY_HOWTO(C) \ - HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \ - NULL, FALSE, 0, 0, FALSE) - -#define HOWTO_PREPARE(relocation, symbol) \ - { \ - if (symbol != NULL) \ - { \ - if (bfd_is_com_section (symbol->section)) \ - { \ - relocation = 0; \ - } \ - else \ - { \ - relocation = symbol->value; \ - } \ - } \ - } - -unsigned int bfd_get_reloc_size (reloc_howto_type *); - -typedef struct relent_chain -{ - arelent relent; - struct relent_chain *next; -} -arelent_chain; - -bfd_reloc_status_type bfd_check_overflow - (enum complain_overflow how, - unsigned int bitsize, - unsigned int rightshift, - unsigned int addrsize, - bfd_vma relocation); - -bfd_reloc_status_type bfd_perform_relocation - (bfd *abfd, - arelent *reloc_entry, - void *data, - asection *input_section, - bfd *output_bfd, - char **error_message); - -bfd_reloc_status_type bfd_install_relocation - (bfd *abfd, - arelent *reloc_entry, - void *data, bfd_vma data_start, - asection *input_section, - char **error_message); - -enum bfd_reloc_code_real { - _dummy_first_bfd_reloc_code_real, - - -/* Basic absolute relocations of N bits. */ - BFD_RELOC_64, - BFD_RELOC_32, - BFD_RELOC_26, - BFD_RELOC_24, - BFD_RELOC_16, - BFD_RELOC_14, - BFD_RELOC_8, - -/* PC-relative relocations. Sometimes these are relative to the address -of the relocation itself; sometimes they are relative to the start of -the section containing the relocation. It depends on the specific target. - -The 24-bit relocation is used in some Intel 960 configurations. */ - BFD_RELOC_64_PCREL, - BFD_RELOC_32_PCREL, - BFD_RELOC_24_PCREL, - BFD_RELOC_16_PCREL, - BFD_RELOC_12_PCREL, - BFD_RELOC_8_PCREL, - -/* Section relative relocations. Some targets need this for DWARF2. */ - BFD_RELOC_32_SECREL, - -/* For ELF. */ - BFD_RELOC_32_GOT_PCREL, - BFD_RELOC_16_GOT_PCREL, - BFD_RELOC_8_GOT_PCREL, - BFD_RELOC_32_GOTOFF, - BFD_RELOC_16_GOTOFF, - BFD_RELOC_LO16_GOTOFF, - BFD_RELOC_HI16_GOTOFF, - BFD_RELOC_HI16_S_GOTOFF, - BFD_RELOC_8_GOTOFF, - BFD_RELOC_64_PLT_PCREL, - BFD_RELOC_32_PLT_PCREL, - BFD_RELOC_24_PLT_PCREL, - BFD_RELOC_16_PLT_PCREL, - BFD_RELOC_8_PLT_PCREL, - BFD_RELOC_64_PLTOFF, - BFD_RELOC_32_PLTOFF, - BFD_RELOC_16_PLTOFF, - BFD_RELOC_LO16_PLTOFF, - BFD_RELOC_HI16_PLTOFF, - BFD_RELOC_HI16_S_PLTOFF, - BFD_RELOC_8_PLTOFF, - -/* Relocations used by 68K ELF. */ - BFD_RELOC_68K_GLOB_DAT, - BFD_RELOC_68K_JMP_SLOT, - BFD_RELOC_68K_RELATIVE, - -/* Linkage-table relative. */ - BFD_RELOC_32_BASEREL, - BFD_RELOC_16_BASEREL, - BFD_RELOC_LO16_BASEREL, - BFD_RELOC_HI16_BASEREL, - BFD_RELOC_HI16_S_BASEREL, - BFD_RELOC_8_BASEREL, - BFD_RELOC_RVA, - -/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */ - BFD_RELOC_8_FFnn, - -/* These PC-relative relocations are stored as word displacements -- -i.e., byte displacements shifted right two bits. The 30-bit word -displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the -SPARC. (SPARC tools generally refer to this as <>.) The -signed 16-bit displacement is used on the MIPS, and the 23-bit -displacement is used on the Alpha. */ - BFD_RELOC_32_PCREL_S2, - BFD_RELOC_16_PCREL_S2, - BFD_RELOC_23_PCREL_S2, - -/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of -the target word. These are used on the SPARC. */ - BFD_RELOC_HI22, - BFD_RELOC_LO10, - -/* For systems that allocate a Global Pointer register, these are -displacements off that register. These relocation types are -handled specially, because the value the register will have is -decided relatively late. */ - BFD_RELOC_GPREL16, - BFD_RELOC_GPREL32, - -/* Reloc types used for i960/b.out. */ - BFD_RELOC_I960_CALLJ, - -/* SPARC ELF relocations. There is probably some overlap with other -relocation types already defined. */ - BFD_RELOC_NONE, - BFD_RELOC_SPARC_WDISP22, - BFD_RELOC_SPARC22, - BFD_RELOC_SPARC13, - BFD_RELOC_SPARC_GOT10, - BFD_RELOC_SPARC_GOT13, - BFD_RELOC_SPARC_GOT22, - BFD_RELOC_SPARC_PC10, - BFD_RELOC_SPARC_PC22, - BFD_RELOC_SPARC_WPLT30, - BFD_RELOC_SPARC_COPY, - BFD_RELOC_SPARC_GLOB_DAT, - BFD_RELOC_SPARC_JMP_SLOT, - BFD_RELOC_SPARC_RELATIVE, - BFD_RELOC_SPARC_UA16, - BFD_RELOC_SPARC_UA32, - BFD_RELOC_SPARC_UA64, - -/* I think these are specific to SPARC a.out (e.g., Sun 4). */ - BFD_RELOC_SPARC_BASE13, - BFD_RELOC_SPARC_BASE22, - -/* SPARC64 relocations */ -#define BFD_RELOC_SPARC_64 BFD_RELOC_64 - BFD_RELOC_SPARC_10, - BFD_RELOC_SPARC_11, - BFD_RELOC_SPARC_OLO10, - BFD_RELOC_SPARC_HH22, - BFD_RELOC_SPARC_HM10, - BFD_RELOC_SPARC_LM22, - BFD_RELOC_SPARC_PC_HH22, - BFD_RELOC_SPARC_PC_HM10, - BFD_RELOC_SPARC_PC_LM22, - BFD_RELOC_SPARC_WDISP16, - BFD_RELOC_SPARC_WDISP19, - BFD_RELOC_SPARC_7, - BFD_RELOC_SPARC_6, - BFD_RELOC_SPARC_5, -#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL - BFD_RELOC_SPARC_PLT32, - BFD_RELOC_SPARC_PLT64, - BFD_RELOC_SPARC_HIX22, - BFD_RELOC_SPARC_LOX10, - BFD_RELOC_SPARC_H44, - BFD_RELOC_SPARC_M44, - BFD_RELOC_SPARC_L44, - BFD_RELOC_SPARC_REGISTER, - -/* SPARC little endian relocation */ - BFD_RELOC_SPARC_REV32, - -/* SPARC TLS relocations */ - BFD_RELOC_SPARC_TLS_GD_HI22, - BFD_RELOC_SPARC_TLS_GD_LO10, - BFD_RELOC_SPARC_TLS_GD_ADD, - BFD_RELOC_SPARC_TLS_GD_CALL, - BFD_RELOC_SPARC_TLS_LDM_HI22, - BFD_RELOC_SPARC_TLS_LDM_LO10, - BFD_RELOC_SPARC_TLS_LDM_ADD, - BFD_RELOC_SPARC_TLS_LDM_CALL, - BFD_RELOC_SPARC_TLS_LDO_HIX22, - BFD_RELOC_SPARC_TLS_LDO_LOX10, - BFD_RELOC_SPARC_TLS_LDO_ADD, - BFD_RELOC_SPARC_TLS_IE_HI22, - BFD_RELOC_SPARC_TLS_IE_LO10, - BFD_RELOC_SPARC_TLS_IE_LD, - BFD_RELOC_SPARC_TLS_IE_LDX, - BFD_RELOC_SPARC_TLS_IE_ADD, - BFD_RELOC_SPARC_TLS_LE_HIX22, - BFD_RELOC_SPARC_TLS_LE_LOX10, - BFD_RELOC_SPARC_TLS_DTPMOD32, - BFD_RELOC_SPARC_TLS_DTPMOD64, - BFD_RELOC_SPARC_TLS_DTPOFF32, - BFD_RELOC_SPARC_TLS_DTPOFF64, - BFD_RELOC_SPARC_TLS_TPOFF32, - BFD_RELOC_SPARC_TLS_TPOFF64, - -/* SPU Relocations. */ - BFD_RELOC_SPU_IMM7, - BFD_RELOC_SPU_IMM8, - BFD_RELOC_SPU_IMM10, - BFD_RELOC_SPU_IMM10W, - BFD_RELOC_SPU_IMM16, - BFD_RELOC_SPU_IMM16W, - BFD_RELOC_SPU_IMM18, - BFD_RELOC_SPU_PCREL9a, - BFD_RELOC_SPU_PCREL9b, - BFD_RELOC_SPU_PCREL16, - BFD_RELOC_SPU_LO16, - BFD_RELOC_SPU_HI16, - BFD_RELOC_SPU_PPU32, - BFD_RELOC_SPU_PPU64, - -/* Alpha ECOFF and ELF relocations. Some of these treat the symbol or -"addend" in some special way. -For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when -writing; when reading, it will be the absolute section symbol. The -addend is the displacement in bytes of the "lda" instruction from -the "ldah" instruction (which is at the address of this reloc). */ - BFD_RELOC_ALPHA_GPDISP_HI16, - -/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as -with GPDISP_HI16 relocs. The addend is ignored when writing the -relocations out, and is filled in with the file's GP value on -reading, for convenience. */ - BFD_RELOC_ALPHA_GPDISP_LO16, - -/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 -relocation except that there is no accompanying GPDISP_LO16 -relocation. */ - BFD_RELOC_ALPHA_GPDISP, - -/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; -the assembler turns it into a LDQ instruction to load the address of -the symbol, and then fills in a register in the real instruction. - -The LITERAL reloc, at the LDQ instruction, refers to the .lita -section symbol. The addend is ignored when writing, but is filled -in with the file's GP value on reading, for convenience, as with the -GPDISP_LO16 reloc. - -The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. -It should refer to the symbol to be referenced, as with 16_GOTOFF, -but it generates output not based on the position within the .got -section, but relative to the GP value chosen for the file during the -final link stage. - -The LITUSE reloc, on the instruction using the loaded address, gives -information to the linker that it might be able to use to optimize -away some literal section references. The symbol is ignored (read -as the absolute section symbol), and the "addend" indicates the type -of instruction using the register: -1 - "memory" fmt insn -2 - byte-manipulation (byte offset reg) -3 - jsr (target of branch) */ - BFD_RELOC_ALPHA_LITERAL, - BFD_RELOC_ALPHA_ELF_LITERAL, - BFD_RELOC_ALPHA_LITUSE, - -/* The HINT relocation indicates a value that should be filled into the -"hint" field of a jmp/jsr/ret instruction, for possible branch- -prediction logic which may be provided on some processors. */ - BFD_RELOC_ALPHA_HINT, - -/* The LINKAGE relocation outputs a linkage pair in the object file, -which is filled by the linker. */ - BFD_RELOC_ALPHA_LINKAGE, - -/* The CODEADDR relocation outputs a STO_CA in the object file, -which is filled by the linker. */ - BFD_RELOC_ALPHA_CODEADDR, - -/* The GPREL_HI/LO relocations together form a 32-bit offset from the -GP register. */ - BFD_RELOC_ALPHA_GPREL_HI16, - BFD_RELOC_ALPHA_GPREL_LO16, - -/* Like BFD_RELOC_23_PCREL_S2, except that the source and target must -share a common GP, and the target address is adjusted for -STO_ALPHA_STD_GPLOAD. */ - BFD_RELOC_ALPHA_BRSGP, - -/* Alpha thread-local storage relocations. */ - BFD_RELOC_ALPHA_TLSGD, - BFD_RELOC_ALPHA_TLSLDM, - BFD_RELOC_ALPHA_DTPMOD64, - BFD_RELOC_ALPHA_GOTDTPREL16, - BFD_RELOC_ALPHA_DTPREL64, - BFD_RELOC_ALPHA_DTPREL_HI16, - BFD_RELOC_ALPHA_DTPREL_LO16, - BFD_RELOC_ALPHA_DTPREL16, - BFD_RELOC_ALPHA_GOTTPREL16, - BFD_RELOC_ALPHA_TPREL64, - BFD_RELOC_ALPHA_TPREL_HI16, - BFD_RELOC_ALPHA_TPREL_LO16, - BFD_RELOC_ALPHA_TPREL16, - -/* Bits 27..2 of the relocation address shifted right 2 bits; -simple reloc otherwise. */ - BFD_RELOC_MIPS_JMP, - -/* The MIPS16 jump instruction. */ - BFD_RELOC_MIPS16_JMP, - -/* MIPS16 GP relative reloc. */ - BFD_RELOC_MIPS16_GPREL, - -/* High 16 bits of 32-bit value; simple reloc. */ - BFD_RELOC_HI16, - -/* High 16 bits of 32-bit value but the low 16 bits will be sign -extended and added to form the final result. If the low 16 -bits form a negative number, we need to add one to the high value -to compensate for the borrow when the low bits are added. */ - BFD_RELOC_HI16_S, - -/* Low 16 bits. */ - BFD_RELOC_LO16, - -/* High 16 bits of 32-bit pc-relative value */ - BFD_RELOC_HI16_PCREL, - -/* High 16 bits of 32-bit pc-relative value, adjusted */ - BFD_RELOC_HI16_S_PCREL, - -/* Low 16 bits of pc-relative value */ - BFD_RELOC_LO16_PCREL, - -/* MIPS16 high 16 bits of 32-bit value. */ - BFD_RELOC_MIPS16_HI16, - -/* MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign -extended and added to form the final result. If the low 16 -bits form a negative number, we need to add one to the high value -to compensate for the borrow when the low bits are added. */ - BFD_RELOC_MIPS16_HI16_S, - -/* MIPS16 low 16 bits. */ - BFD_RELOC_MIPS16_LO16, - -/* Relocation against a MIPS literal section. */ - BFD_RELOC_MIPS_LITERAL, - -/* MIPS ELF relocations. */ - BFD_RELOC_MIPS_GOT16, - BFD_RELOC_MIPS_CALL16, - BFD_RELOC_MIPS_GOT_HI16, - BFD_RELOC_MIPS_GOT_LO16, - BFD_RELOC_MIPS_CALL_HI16, - BFD_RELOC_MIPS_CALL_LO16, - BFD_RELOC_MIPS_SUB, - BFD_RELOC_MIPS_GOT_PAGE, - BFD_RELOC_MIPS_GOT_OFST, - BFD_RELOC_MIPS_GOT_DISP, - BFD_RELOC_MIPS_SHIFT5, - BFD_RELOC_MIPS_SHIFT6, - BFD_RELOC_MIPS_INSERT_A, - BFD_RELOC_MIPS_INSERT_B, - BFD_RELOC_MIPS_DELETE, - BFD_RELOC_MIPS_HIGHEST, - BFD_RELOC_MIPS_HIGHER, - BFD_RELOC_MIPS_SCN_DISP, - BFD_RELOC_MIPS_REL16, - BFD_RELOC_MIPS_RELGOT, - BFD_RELOC_MIPS_JALR, - BFD_RELOC_MIPS_TLS_DTPMOD32, - BFD_RELOC_MIPS_TLS_DTPREL32, - BFD_RELOC_MIPS_TLS_DTPMOD64, - BFD_RELOC_MIPS_TLS_DTPREL64, - BFD_RELOC_MIPS_TLS_GD, - BFD_RELOC_MIPS_TLS_LDM, - BFD_RELOC_MIPS_TLS_DTPREL_HI16, - BFD_RELOC_MIPS_TLS_DTPREL_LO16, - BFD_RELOC_MIPS_TLS_GOTTPREL, - BFD_RELOC_MIPS_TLS_TPREL32, - BFD_RELOC_MIPS_TLS_TPREL64, - BFD_RELOC_MIPS_TLS_TPREL_HI16, - BFD_RELOC_MIPS_TLS_TPREL_LO16, - - -/* MIPS ELF relocations (VxWorks extensions). */ - BFD_RELOC_MIPS_COPY, - BFD_RELOC_MIPS_JUMP_SLOT, - - -/* Fujitsu Frv Relocations. */ - BFD_RELOC_FRV_LABEL16, - BFD_RELOC_FRV_LABEL24, - BFD_RELOC_FRV_LO16, - BFD_RELOC_FRV_HI16, - BFD_RELOC_FRV_GPREL12, - BFD_RELOC_FRV_GPRELU12, - BFD_RELOC_FRV_GPREL32, - BFD_RELOC_FRV_GPRELHI, - BFD_RELOC_FRV_GPRELLO, - BFD_RELOC_FRV_GOT12, - BFD_RELOC_FRV_GOTHI, - BFD_RELOC_FRV_GOTLO, - BFD_RELOC_FRV_FUNCDESC, - BFD_RELOC_FRV_FUNCDESC_GOT12, - BFD_RELOC_FRV_FUNCDESC_GOTHI, - BFD_RELOC_FRV_FUNCDESC_GOTLO, - BFD_RELOC_FRV_FUNCDESC_VALUE, - BFD_RELOC_FRV_FUNCDESC_GOTOFF12, - BFD_RELOC_FRV_FUNCDESC_GOTOFFHI, - BFD_RELOC_FRV_FUNCDESC_GOTOFFLO, - BFD_RELOC_FRV_GOTOFF12, - BFD_RELOC_FRV_GOTOFFHI, - BFD_RELOC_FRV_GOTOFFLO, - BFD_RELOC_FRV_GETTLSOFF, - BFD_RELOC_FRV_TLSDESC_VALUE, - BFD_RELOC_FRV_GOTTLSDESC12, - BFD_RELOC_FRV_GOTTLSDESCHI, - BFD_RELOC_FRV_GOTTLSDESCLO, - BFD_RELOC_FRV_TLSMOFF12, - BFD_RELOC_FRV_TLSMOFFHI, - BFD_RELOC_FRV_TLSMOFFLO, - BFD_RELOC_FRV_GOTTLSOFF12, - BFD_RELOC_FRV_GOTTLSOFFHI, - BFD_RELOC_FRV_GOTTLSOFFLO, - BFD_RELOC_FRV_TLSOFF, - BFD_RELOC_FRV_TLSDESC_RELAX, - BFD_RELOC_FRV_GETTLSOFF_RELAX, - BFD_RELOC_FRV_TLSOFF_RELAX, - BFD_RELOC_FRV_TLSMOFF, - - -/* This is a 24bit GOT-relative reloc for the mn10300. */ - BFD_RELOC_MN10300_GOTOFF24, - -/* This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes -in the instruction. */ - BFD_RELOC_MN10300_GOT32, - -/* This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes -in the instruction. */ - BFD_RELOC_MN10300_GOT24, - -/* This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes -in the instruction. */ - BFD_RELOC_MN10300_GOT16, - -/* Copy symbol at runtime. */ - BFD_RELOC_MN10300_COPY, - -/* Create GOT entry. */ - BFD_RELOC_MN10300_GLOB_DAT, - -/* Create PLT entry. */ - BFD_RELOC_MN10300_JMP_SLOT, - -/* Adjust by program base. */ - BFD_RELOC_MN10300_RELATIVE, - - -/* i386/elf relocations */ - BFD_RELOC_386_GOT32, - BFD_RELOC_386_PLT32, - BFD_RELOC_386_COPY, - BFD_RELOC_386_GLOB_DAT, - BFD_RELOC_386_JUMP_SLOT, - BFD_RELOC_386_RELATIVE, - BFD_RELOC_386_GOTOFF, - BFD_RELOC_386_GOTPC, - BFD_RELOC_386_TLS_TPOFF, - BFD_RELOC_386_TLS_IE, - BFD_RELOC_386_TLS_GOTIE, - BFD_RELOC_386_TLS_LE, - BFD_RELOC_386_TLS_GD, - BFD_RELOC_386_TLS_LDM, - BFD_RELOC_386_TLS_LDO_32, - BFD_RELOC_386_TLS_IE_32, - BFD_RELOC_386_TLS_LE_32, - BFD_RELOC_386_TLS_DTPMOD32, - BFD_RELOC_386_TLS_DTPOFF32, - BFD_RELOC_386_TLS_TPOFF32, - BFD_RELOC_386_TLS_GOTDESC, - BFD_RELOC_386_TLS_DESC_CALL, - BFD_RELOC_386_TLS_DESC, - -/* x86-64/elf relocations */ - BFD_RELOC_X86_64_GOT32, - BFD_RELOC_X86_64_PLT32, - BFD_RELOC_X86_64_COPY, - BFD_RELOC_X86_64_GLOB_DAT, - BFD_RELOC_X86_64_JUMP_SLOT, - BFD_RELOC_X86_64_RELATIVE, - BFD_RELOC_X86_64_GOTPCREL, - BFD_RELOC_X86_64_32S, - BFD_RELOC_X86_64_DTPMOD64, - BFD_RELOC_X86_64_DTPOFF64, - BFD_RELOC_X86_64_TPOFF64, - BFD_RELOC_X86_64_TLSGD, - BFD_RELOC_X86_64_TLSLD, - BFD_RELOC_X86_64_DTPOFF32, - BFD_RELOC_X86_64_GOTTPOFF, - BFD_RELOC_X86_64_TPOFF32, - BFD_RELOC_X86_64_GOTOFF64, - BFD_RELOC_X86_64_GOTPC32, - BFD_RELOC_X86_64_GOT64, - BFD_RELOC_X86_64_GOTPCREL64, - BFD_RELOC_X86_64_GOTPC64, - BFD_RELOC_X86_64_GOTPLT64, - BFD_RELOC_X86_64_PLTOFF64, - BFD_RELOC_X86_64_GOTPC32_TLSDESC, - BFD_RELOC_X86_64_TLSDESC_CALL, - BFD_RELOC_X86_64_TLSDESC, - -/* ns32k relocations */ - BFD_RELOC_NS32K_IMM_8, - BFD_RELOC_NS32K_IMM_16, - BFD_RELOC_NS32K_IMM_32, - BFD_RELOC_NS32K_IMM_8_PCREL, - BFD_RELOC_NS32K_IMM_16_PCREL, - BFD_RELOC_NS32K_IMM_32_PCREL, - BFD_RELOC_NS32K_DISP_8, - BFD_RELOC_NS32K_DISP_16, - BFD_RELOC_NS32K_DISP_32, - BFD_RELOC_NS32K_DISP_8_PCREL, - BFD_RELOC_NS32K_DISP_16_PCREL, - BFD_RELOC_NS32K_DISP_32_PCREL, - -/* PDP11 relocations */ - BFD_RELOC_PDP11_DISP_8_PCREL, - BFD_RELOC_PDP11_DISP_6_PCREL, - -/* Picojava relocs. Not all of these appear in object files. */ - BFD_RELOC_PJ_CODE_HI16, - BFD_RELOC_PJ_CODE_LO16, - BFD_RELOC_PJ_CODE_DIR16, - BFD_RELOC_PJ_CODE_DIR32, - BFD_RELOC_PJ_CODE_REL16, - BFD_RELOC_PJ_CODE_REL32, - -/* Power(rs6000) and PowerPC relocations. */ - BFD_RELOC_PPC_B26, - BFD_RELOC_PPC_BA26, - BFD_RELOC_PPC_TOC16, - BFD_RELOC_PPC_B16, - BFD_RELOC_PPC_B16_BRTAKEN, - BFD_RELOC_PPC_B16_BRNTAKEN, - BFD_RELOC_PPC_BA16, - BFD_RELOC_PPC_BA16_BRTAKEN, - BFD_RELOC_PPC_BA16_BRNTAKEN, - BFD_RELOC_PPC_COPY, - BFD_RELOC_PPC_GLOB_DAT, - BFD_RELOC_PPC_JMP_SLOT, - BFD_RELOC_PPC_RELATIVE, - BFD_RELOC_PPC_LOCAL24PC, - BFD_RELOC_PPC_EMB_NADDR32, - BFD_RELOC_PPC_EMB_NADDR16, - BFD_RELOC_PPC_EMB_NADDR16_LO, - BFD_RELOC_PPC_EMB_NADDR16_HI, - BFD_RELOC_PPC_EMB_NADDR16_HA, - BFD_RELOC_PPC_EMB_SDAI16, - BFD_RELOC_PPC_EMB_SDA2I16, - BFD_RELOC_PPC_EMB_SDA2REL, - BFD_RELOC_PPC_EMB_SDA21, - BFD_RELOC_PPC_EMB_MRKREF, - BFD_RELOC_PPC_EMB_RELSEC16, - BFD_RELOC_PPC_EMB_RELST_LO, - BFD_RELOC_PPC_EMB_RELST_HI, - BFD_RELOC_PPC_EMB_RELST_HA, - BFD_RELOC_PPC_EMB_BIT_FLD, - BFD_RELOC_PPC_EMB_RELSDA, - BFD_RELOC_PPC64_HIGHER, - BFD_RELOC_PPC64_HIGHER_S, - BFD_RELOC_PPC64_HIGHEST, - BFD_RELOC_PPC64_HIGHEST_S, - BFD_RELOC_PPC64_TOC16_LO, - BFD_RELOC_PPC64_TOC16_HI, - BFD_RELOC_PPC64_TOC16_HA, - BFD_RELOC_PPC64_TOC, - BFD_RELOC_PPC64_PLTGOT16, - BFD_RELOC_PPC64_PLTGOT16_LO, - BFD_RELOC_PPC64_PLTGOT16_HI, - BFD_RELOC_PPC64_PLTGOT16_HA, - BFD_RELOC_PPC64_ADDR16_DS, - BFD_RELOC_PPC64_ADDR16_LO_DS, - BFD_RELOC_PPC64_GOT16_DS, - BFD_RELOC_PPC64_GOT16_LO_DS, - BFD_RELOC_PPC64_PLT16_LO_DS, - BFD_RELOC_PPC64_SECTOFF_DS, - BFD_RELOC_PPC64_SECTOFF_LO_DS, - BFD_RELOC_PPC64_TOC16_DS, - BFD_RELOC_PPC64_TOC16_LO_DS, - BFD_RELOC_PPC64_PLTGOT16_DS, - BFD_RELOC_PPC64_PLTGOT16_LO_DS, - -/* PowerPC and PowerPC64 thread-local storage relocations. */ - BFD_RELOC_PPC_TLS, - BFD_RELOC_PPC_TLSGD, - BFD_RELOC_PPC_TLSLD, - BFD_RELOC_PPC_DTPMOD, - BFD_RELOC_PPC_TPREL16, - BFD_RELOC_PPC_TPREL16_LO, - BFD_RELOC_PPC_TPREL16_HI, - BFD_RELOC_PPC_TPREL16_HA, - BFD_RELOC_PPC_TPREL, - BFD_RELOC_PPC_DTPREL16, - BFD_RELOC_PPC_DTPREL16_LO, - BFD_RELOC_PPC_DTPREL16_HI, - BFD_RELOC_PPC_DTPREL16_HA, - BFD_RELOC_PPC_DTPREL, - BFD_RELOC_PPC_GOT_TLSGD16, - BFD_RELOC_PPC_GOT_TLSGD16_LO, - BFD_RELOC_PPC_GOT_TLSGD16_HI, - BFD_RELOC_PPC_GOT_TLSGD16_HA, - BFD_RELOC_PPC_GOT_TLSLD16, - BFD_RELOC_PPC_GOT_TLSLD16_LO, - BFD_RELOC_PPC_GOT_TLSLD16_HI, - BFD_RELOC_PPC_GOT_TLSLD16_HA, - BFD_RELOC_PPC_GOT_TPREL16, - BFD_RELOC_PPC_GOT_TPREL16_LO, - BFD_RELOC_PPC_GOT_TPREL16_HI, - BFD_RELOC_PPC_GOT_TPREL16_HA, - BFD_RELOC_PPC_GOT_DTPREL16, - BFD_RELOC_PPC_GOT_DTPREL16_LO, - BFD_RELOC_PPC_GOT_DTPREL16_HI, - BFD_RELOC_PPC_GOT_DTPREL16_HA, - BFD_RELOC_PPC64_TPREL16_DS, - BFD_RELOC_PPC64_TPREL16_LO_DS, - BFD_RELOC_PPC64_TPREL16_HIGHER, - BFD_RELOC_PPC64_TPREL16_HIGHERA, - BFD_RELOC_PPC64_TPREL16_HIGHEST, - BFD_RELOC_PPC64_TPREL16_HIGHESTA, - BFD_RELOC_PPC64_DTPREL16_DS, - BFD_RELOC_PPC64_DTPREL16_LO_DS, - BFD_RELOC_PPC64_DTPREL16_HIGHER, - BFD_RELOC_PPC64_DTPREL16_HIGHERA, - BFD_RELOC_PPC64_DTPREL16_HIGHEST, - BFD_RELOC_PPC64_DTPREL16_HIGHESTA, - -/* IBM 370/390 relocations */ - BFD_RELOC_I370_D12, - -/* The type of reloc used to build a constructor table - at the moment -probably a 32 bit wide absolute relocation, but the target can choose. -It generally does map to one of the other relocation types. */ - BFD_RELOC_CTOR, - -/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are -not stored in the instruction. */ - BFD_RELOC_ARM_PCREL_BRANCH, - -/* ARM 26 bit pc-relative branch. The lowest bit must be zero and is -not stored in the instruction. The 2nd lowest bit comes from a 1 bit -field in the instruction. */ - BFD_RELOC_ARM_PCREL_BLX, - -/* Thumb 22 bit pc-relative branch. The lowest bit must be zero and is -not stored in the instruction. The 2nd lowest bit comes from a 1 bit -field in the instruction. */ - BFD_RELOC_THUMB_PCREL_BLX, - -/* ARM 26-bit pc-relative branch for an unconditional BL or BLX instruction. */ - BFD_RELOC_ARM_PCREL_CALL, - -/* ARM 26-bit pc-relative branch for B or conditional BL instruction. */ - BFD_RELOC_ARM_PCREL_JUMP, - -/* Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches. -The lowest bit must be zero and is not stored in the instruction. -Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an -"nn" one smaller in all cases. Note further that BRANCH23 -corresponds to R_ARM_THM_CALL. */ - BFD_RELOC_THUMB_PCREL_BRANCH7, - BFD_RELOC_THUMB_PCREL_BRANCH9, - BFD_RELOC_THUMB_PCREL_BRANCH12, - BFD_RELOC_THUMB_PCREL_BRANCH20, - BFD_RELOC_THUMB_PCREL_BRANCH23, - BFD_RELOC_THUMB_PCREL_BRANCH25, - -/* 12-bit immediate offset, used in ARM-format ldr and str instructions. */ - BFD_RELOC_ARM_OFFSET_IMM, - -/* 5-bit immediate offset, used in Thumb-format ldr and str instructions. */ - BFD_RELOC_ARM_THUMB_OFFSET, - -/* Pc-relative or absolute relocation depending on target. Used for -entries in .init_array sections. */ - BFD_RELOC_ARM_TARGET1, - -/* Read-only segment base relative address. */ - BFD_RELOC_ARM_ROSEGREL32, - -/* Data segment base relative address. */ - BFD_RELOC_ARM_SBREL32, - -/* This reloc is used for references to RTTI data from exception handling -tables. The actual definition depends on the target. It may be a -pc-relative or some form of GOT-indirect relocation. */ - BFD_RELOC_ARM_TARGET2, - -/* 31-bit PC relative address. */ - BFD_RELOC_ARM_PREL31, - -/* Low and High halfword relocations for MOVW and MOVT instructions. */ - BFD_RELOC_ARM_MOVW, - BFD_RELOC_ARM_MOVT, - BFD_RELOC_ARM_MOVW_PCREL, - BFD_RELOC_ARM_MOVT_PCREL, - BFD_RELOC_ARM_THUMB_MOVW, - BFD_RELOC_ARM_THUMB_MOVT, - BFD_RELOC_ARM_THUMB_MOVW_PCREL, - BFD_RELOC_ARM_THUMB_MOVT_PCREL, - -/* Relocations for setting up GOTs and PLTs for shared libraries. */ - BFD_RELOC_ARM_JUMP_SLOT, - BFD_RELOC_ARM_GLOB_DAT, - BFD_RELOC_ARM_GOT32, - BFD_RELOC_ARM_PLT32, - BFD_RELOC_ARM_RELATIVE, - BFD_RELOC_ARM_GOTOFF, - BFD_RELOC_ARM_GOTPC, - -/* ARM thread-local storage relocations. */ - BFD_RELOC_ARM_TLS_GD32, - BFD_RELOC_ARM_TLS_LDO32, - BFD_RELOC_ARM_TLS_LDM32, - BFD_RELOC_ARM_TLS_DTPOFF32, - BFD_RELOC_ARM_TLS_DTPMOD32, - BFD_RELOC_ARM_TLS_TPOFF32, - BFD_RELOC_ARM_TLS_IE32, - BFD_RELOC_ARM_TLS_LE32, - -/* ARM group relocations. */ - BFD_RELOC_ARM_ALU_PC_G0_NC, - BFD_RELOC_ARM_ALU_PC_G0, - BFD_RELOC_ARM_ALU_PC_G1_NC, - BFD_RELOC_ARM_ALU_PC_G1, - BFD_RELOC_ARM_ALU_PC_G2, - BFD_RELOC_ARM_LDR_PC_G0, - BFD_RELOC_ARM_LDR_PC_G1, - BFD_RELOC_ARM_LDR_PC_G2, - BFD_RELOC_ARM_LDRS_PC_G0, - BFD_RELOC_ARM_LDRS_PC_G1, - BFD_RELOC_ARM_LDRS_PC_G2, - BFD_RELOC_ARM_LDC_PC_G0, - BFD_RELOC_ARM_LDC_PC_G1, - BFD_RELOC_ARM_LDC_PC_G2, - BFD_RELOC_ARM_ALU_SB_G0_NC, - BFD_RELOC_ARM_ALU_SB_G0, - BFD_RELOC_ARM_ALU_SB_G1_NC, - BFD_RELOC_ARM_ALU_SB_G1, - BFD_RELOC_ARM_ALU_SB_G2, - BFD_RELOC_ARM_LDR_SB_G0, - BFD_RELOC_ARM_LDR_SB_G1, - BFD_RELOC_ARM_LDR_SB_G2, - BFD_RELOC_ARM_LDRS_SB_G0, - BFD_RELOC_ARM_LDRS_SB_G1, - BFD_RELOC_ARM_LDRS_SB_G2, - BFD_RELOC_ARM_LDC_SB_G0, - BFD_RELOC_ARM_LDC_SB_G1, - BFD_RELOC_ARM_LDC_SB_G2, - -/* These relocs are only used within the ARM assembler. They are not -(at present) written to any object files. */ - BFD_RELOC_ARM_IMMEDIATE, - BFD_RELOC_ARM_ADRL_IMMEDIATE, - BFD_RELOC_ARM_T32_IMMEDIATE, - BFD_RELOC_ARM_T32_ADD_IMM, - BFD_RELOC_ARM_T32_IMM12, - BFD_RELOC_ARM_T32_ADD_PC12, - BFD_RELOC_ARM_SHIFT_IMM, - BFD_RELOC_ARM_SMC, - BFD_RELOC_ARM_SWI, - BFD_RELOC_ARM_MULTI, - BFD_RELOC_ARM_CP_OFF_IMM, - BFD_RELOC_ARM_CP_OFF_IMM_S2, - BFD_RELOC_ARM_T32_CP_OFF_IMM, - BFD_RELOC_ARM_T32_CP_OFF_IMM_S2, - BFD_RELOC_ARM_ADR_IMM, - BFD_RELOC_ARM_LDR_IMM, - BFD_RELOC_ARM_LITERAL, - BFD_RELOC_ARM_IN_POOL, - BFD_RELOC_ARM_OFFSET_IMM8, - BFD_RELOC_ARM_T32_OFFSET_U8, - BFD_RELOC_ARM_T32_OFFSET_IMM, - BFD_RELOC_ARM_HWLITERAL, - BFD_RELOC_ARM_THUMB_ADD, - BFD_RELOC_ARM_THUMB_IMM, - BFD_RELOC_ARM_THUMB_SHIFT, - -/* Renesas / SuperH SH relocs. Not all of these appear in object files. */ - BFD_RELOC_SH_PCDISP8BY2, - BFD_RELOC_SH_PCDISP12BY2, - BFD_RELOC_SH_IMM3, - BFD_RELOC_SH_IMM3U, - BFD_RELOC_SH_DISP12, - BFD_RELOC_SH_DISP12BY2, - BFD_RELOC_SH_DISP12BY4, - BFD_RELOC_SH_DISP12BY8, - BFD_RELOC_SH_DISP20, - BFD_RELOC_SH_DISP20BY8, - BFD_RELOC_SH_IMM4, - BFD_RELOC_SH_IMM4BY2, - BFD_RELOC_SH_IMM4BY4, - BFD_RELOC_SH_IMM8, - BFD_RELOC_SH_IMM8BY2, - BFD_RELOC_SH_IMM8BY4, - BFD_RELOC_SH_PCRELIMM8BY2, - BFD_RELOC_SH_PCRELIMM8BY4, - BFD_RELOC_SH_SWITCH16, - BFD_RELOC_SH_SWITCH32, - BFD_RELOC_SH_USES, - BFD_RELOC_SH_COUNT, - BFD_RELOC_SH_ALIGN, - BFD_RELOC_SH_CODE, - BFD_RELOC_SH_DATA, - BFD_RELOC_SH_LABEL, - BFD_RELOC_SH_LOOP_START, - BFD_RELOC_SH_LOOP_END, - BFD_RELOC_SH_COPY, - BFD_RELOC_SH_GLOB_DAT, - BFD_RELOC_SH_JMP_SLOT, - BFD_RELOC_SH_RELATIVE, - BFD_RELOC_SH_GOTPC, - BFD_RELOC_SH_GOT_LOW16, - BFD_RELOC_SH_GOT_MEDLOW16, - BFD_RELOC_SH_GOT_MEDHI16, - BFD_RELOC_SH_GOT_HI16, - BFD_RELOC_SH_GOTPLT_LOW16, - BFD_RELOC_SH_GOTPLT_MEDLOW16, - BFD_RELOC_SH_GOTPLT_MEDHI16, - BFD_RELOC_SH_GOTPLT_HI16, - BFD_RELOC_SH_PLT_LOW16, - BFD_RELOC_SH_PLT_MEDLOW16, - BFD_RELOC_SH_PLT_MEDHI16, - BFD_RELOC_SH_PLT_HI16, - BFD_RELOC_SH_GOTOFF_LOW16, - BFD_RELOC_SH_GOTOFF_MEDLOW16, - BFD_RELOC_SH_GOTOFF_MEDHI16, - BFD_RELOC_SH_GOTOFF_HI16, - BFD_RELOC_SH_GOTPC_LOW16, - BFD_RELOC_SH_GOTPC_MEDLOW16, - BFD_RELOC_SH_GOTPC_MEDHI16, - BFD_RELOC_SH_GOTPC_HI16, - BFD_RELOC_SH_COPY64, - BFD_RELOC_SH_GLOB_DAT64, - BFD_RELOC_SH_JMP_SLOT64, - BFD_RELOC_SH_RELATIVE64, - BFD_RELOC_SH_GOT10BY4, - BFD_RELOC_SH_GOT10BY8, - BFD_RELOC_SH_GOTPLT10BY4, - BFD_RELOC_SH_GOTPLT10BY8, - BFD_RELOC_SH_GOTPLT32, - BFD_RELOC_SH_SHMEDIA_CODE, - BFD_RELOC_SH_IMMU5, - BFD_RELOC_SH_IMMS6, - BFD_RELOC_SH_IMMS6BY32, - BFD_RELOC_SH_IMMU6, - BFD_RELOC_SH_IMMS10, - BFD_RELOC_SH_IMMS10BY2, - BFD_RELOC_SH_IMMS10BY4, - BFD_RELOC_SH_IMMS10BY8, - BFD_RELOC_SH_IMMS16, - BFD_RELOC_SH_IMMU16, - BFD_RELOC_SH_IMM_LOW16, - BFD_RELOC_SH_IMM_LOW16_PCREL, - BFD_RELOC_SH_IMM_MEDLOW16, - BFD_RELOC_SH_IMM_MEDLOW16_PCREL, - BFD_RELOC_SH_IMM_MEDHI16, - BFD_RELOC_SH_IMM_MEDHI16_PCREL, - BFD_RELOC_SH_IMM_HI16, - BFD_RELOC_SH_IMM_HI16_PCREL, - BFD_RELOC_SH_PT_16, - BFD_RELOC_SH_TLS_GD_32, - BFD_RELOC_SH_TLS_LD_32, - BFD_RELOC_SH_TLS_LDO_32, - BFD_RELOC_SH_TLS_IE_32, - BFD_RELOC_SH_TLS_LE_32, - BFD_RELOC_SH_TLS_DTPMOD32, - BFD_RELOC_SH_TLS_DTPOFF32, - BFD_RELOC_SH_TLS_TPOFF32, - -/* ARC Cores relocs. -ARC 22 bit pc-relative branch. The lowest two bits must be zero and are -not stored in the instruction. The high 20 bits are installed in bits 26 -through 7 of the instruction. */ - BFD_RELOC_ARC_B22_PCREL, - -/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not -stored in the instruction. The high 24 bits are installed in bits 23 -through 0. */ - BFD_RELOC_ARC_B26, - -/* ADI Blackfin 16 bit immediate absolute reloc. */ - BFD_RELOC_BFIN_16_IMM, - -/* ADI Blackfin 16 bit immediate absolute reloc higher 16 bits. */ - BFD_RELOC_BFIN_16_HIGH, - -/* ADI Blackfin 'a' part of LSETUP. */ - BFD_RELOC_BFIN_4_PCREL, - -/* ADI Blackfin. */ - BFD_RELOC_BFIN_5_PCREL, - -/* ADI Blackfin 16 bit immediate absolute reloc lower 16 bits. */ - BFD_RELOC_BFIN_16_LOW, - -/* ADI Blackfin. */ - BFD_RELOC_BFIN_10_PCREL, - -/* ADI Blackfin 'b' part of LSETUP. */ - BFD_RELOC_BFIN_11_PCREL, - -/* ADI Blackfin. */ - BFD_RELOC_BFIN_12_PCREL_JUMP, - -/* ADI Blackfin Short jump, pcrel. */ - BFD_RELOC_BFIN_12_PCREL_JUMP_S, - -/* ADI Blackfin Call.x not implemented. */ - BFD_RELOC_BFIN_24_PCREL_CALL_X, - -/* ADI Blackfin Long Jump pcrel. */ - BFD_RELOC_BFIN_24_PCREL_JUMP_L, - -/* ADI Blackfin FD-PIC relocations. */ - BFD_RELOC_BFIN_GOT17M4, - BFD_RELOC_BFIN_GOTHI, - BFD_RELOC_BFIN_GOTLO, - BFD_RELOC_BFIN_FUNCDESC, - BFD_RELOC_BFIN_FUNCDESC_GOT17M4, - BFD_RELOC_BFIN_FUNCDESC_GOTHI, - BFD_RELOC_BFIN_FUNCDESC_GOTLO, - BFD_RELOC_BFIN_FUNCDESC_VALUE, - BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4, - BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI, - BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO, - BFD_RELOC_BFIN_GOTOFF17M4, - BFD_RELOC_BFIN_GOTOFFHI, - BFD_RELOC_BFIN_GOTOFFLO, - -/* ADI Blackfin GOT relocation. */ - BFD_RELOC_BFIN_GOT, - -/* ADI Blackfin PLTPC relocation. */ - BFD_RELOC_BFIN_PLTPC, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_PUSH, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_CONST, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_ADD, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_SUB, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_MULT, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_DIV, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_MOD, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_LSHIFT, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_RSHIFT, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_AND, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_OR, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_XOR, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_LAND, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_LOR, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_LEN, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_NEG, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_COMP, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_PAGE, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_HWPAGE, - -/* ADI Blackfin arithmetic relocation. */ - BFD_ARELOC_BFIN_ADDR, - -/* Mitsubishi D10V relocs. -This is a 10-bit reloc with the right 2 bits -assumed to be 0. */ - BFD_RELOC_D10V_10_PCREL_R, - -/* Mitsubishi D10V relocs. -This is a 10-bit reloc with the right 2 bits -assumed to be 0. This is the same as the previous reloc -except it is in the left container, i.e., -shifted left 15 bits. */ - BFD_RELOC_D10V_10_PCREL_L, - -/* This is an 18-bit reloc with the right 2 bits -assumed to be 0. */ - BFD_RELOC_D10V_18, - -/* This is an 18-bit reloc with the right 2 bits -assumed to be 0. */ - BFD_RELOC_D10V_18_PCREL, - -/* Mitsubishi D30V relocs. -This is a 6-bit absolute reloc. */ - BFD_RELOC_D30V_6, - -/* This is a 6-bit pc-relative reloc with -the right 3 bits assumed to be 0. */ - BFD_RELOC_D30V_9_PCREL, - -/* This is a 6-bit pc-relative reloc with -the right 3 bits assumed to be 0. Same -as the previous reloc but on the right side -of the container. */ - BFD_RELOC_D30V_9_PCREL_R, - -/* This is a 12-bit absolute reloc with the -right 3 bitsassumed to be 0. */ - BFD_RELOC_D30V_15, - -/* This is a 12-bit pc-relative reloc with -the right 3 bits assumed to be 0. */ - BFD_RELOC_D30V_15_PCREL, - -/* This is a 12-bit pc-relative reloc with -the right 3 bits assumed to be 0. Same -as the previous reloc but on the right side -of the container. */ - BFD_RELOC_D30V_15_PCREL_R, - -/* This is an 18-bit absolute reloc with -the right 3 bits assumed to be 0. */ - BFD_RELOC_D30V_21, - -/* This is an 18-bit pc-relative reloc with -the right 3 bits assumed to be 0. */ - BFD_RELOC_D30V_21_PCREL, - -/* This is an 18-bit pc-relative reloc with -the right 3 bits assumed to be 0. Same -as the previous reloc but on the right side -of the container. */ - BFD_RELOC_D30V_21_PCREL_R, - -/* This is a 32-bit absolute reloc. */ - BFD_RELOC_D30V_32, - -/* This is a 32-bit pc-relative reloc. */ - BFD_RELOC_D30V_32_PCREL, - -/* DLX relocs */ - BFD_RELOC_DLX_HI16_S, - -/* DLX relocs */ - BFD_RELOC_DLX_LO16, - -/* DLX relocs */ - BFD_RELOC_DLX_JMP26, - -/* Renesas M16C/M32C Relocations. */ - BFD_RELOC_M32C_HI8, - BFD_RELOC_M32C_RL_JUMP, - BFD_RELOC_M32C_RL_1ADDR, - BFD_RELOC_M32C_RL_2ADDR, - -/* Renesas M32R (formerly Mitsubishi M32R) relocs. -This is a 24 bit absolute address. */ - BFD_RELOC_M32R_24, - -/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */ - BFD_RELOC_M32R_10_PCREL, - -/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ - BFD_RELOC_M32R_18_PCREL, - -/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */ - BFD_RELOC_M32R_26_PCREL, - -/* This is a 16-bit reloc containing the high 16 bits of an address -used when the lower 16 bits are treated as unsigned. */ - BFD_RELOC_M32R_HI16_ULO, - -/* This is a 16-bit reloc containing the high 16 bits of an address -used when the lower 16 bits are treated as signed. */ - BFD_RELOC_M32R_HI16_SLO, - -/* This is a 16-bit reloc containing the lower 16 bits of an address. */ - BFD_RELOC_M32R_LO16, - -/* This is a 16-bit reloc containing the small data area offset for use in -add3, load, and store instructions. */ - BFD_RELOC_M32R_SDA16, - -/* For PIC. */ - BFD_RELOC_M32R_GOT24, - BFD_RELOC_M32R_26_PLTREL, - BFD_RELOC_M32R_COPY, - BFD_RELOC_M32R_GLOB_DAT, - BFD_RELOC_M32R_JMP_SLOT, - BFD_RELOC_M32R_RELATIVE, - BFD_RELOC_M32R_GOTOFF, - BFD_RELOC_M32R_GOTOFF_HI_ULO, - BFD_RELOC_M32R_GOTOFF_HI_SLO, - BFD_RELOC_M32R_GOTOFF_LO, - BFD_RELOC_M32R_GOTPC24, - BFD_RELOC_M32R_GOT16_HI_ULO, - BFD_RELOC_M32R_GOT16_HI_SLO, - BFD_RELOC_M32R_GOT16_LO, - BFD_RELOC_M32R_GOTPC_HI_ULO, - BFD_RELOC_M32R_GOTPC_HI_SLO, - BFD_RELOC_M32R_GOTPC_LO, - -/* This is a 9-bit reloc */ - BFD_RELOC_V850_9_PCREL, - -/* This is a 22-bit reloc */ - BFD_RELOC_V850_22_PCREL, - -/* This is a 16 bit offset from the short data area pointer. */ - BFD_RELOC_V850_SDA_16_16_OFFSET, - -/* This is a 16 bit offset (of which only 15 bits are used) from the -short data area pointer. */ - BFD_RELOC_V850_SDA_15_16_OFFSET, - -/* This is a 16 bit offset from the zero data area pointer. */ - BFD_RELOC_V850_ZDA_16_16_OFFSET, - -/* This is a 16 bit offset (of which only 15 bits are used) from the -zero data area pointer. */ - BFD_RELOC_V850_ZDA_15_16_OFFSET, - -/* This is an 8 bit offset (of which only 6 bits are used) from the -tiny data area pointer. */ - BFD_RELOC_V850_TDA_6_8_OFFSET, - -/* This is an 8bit offset (of which only 7 bits are used) from the tiny -data area pointer. */ - BFD_RELOC_V850_TDA_7_8_OFFSET, - -/* This is a 7 bit offset from the tiny data area pointer. */ - BFD_RELOC_V850_TDA_7_7_OFFSET, - -/* This is a 16 bit offset from the tiny data area pointer. */ - BFD_RELOC_V850_TDA_16_16_OFFSET, - -/* This is a 5 bit offset (of which only 4 bits are used) from the tiny -data area pointer. */ - BFD_RELOC_V850_TDA_4_5_OFFSET, - -/* This is a 4 bit offset from the tiny data area pointer. */ - BFD_RELOC_V850_TDA_4_4_OFFSET, - -/* This is a 16 bit offset from the short data area pointer, with the -bits placed non-contiguously in the instruction. */ - BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET, - -/* This is a 16 bit offset from the zero data area pointer, with the -bits placed non-contiguously in the instruction. */ - BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET, - -/* This is a 6 bit offset from the call table base pointer. */ - BFD_RELOC_V850_CALLT_6_7_OFFSET, - -/* This is a 16 bit offset from the call table base pointer. */ - BFD_RELOC_V850_CALLT_16_16_OFFSET, - -/* Used for relaxing indirect function calls. */ - BFD_RELOC_V850_LONGCALL, - -/* Used for relaxing indirect jumps. */ - BFD_RELOC_V850_LONGJUMP, - -/* Used to maintain alignment whilst relaxing. */ - BFD_RELOC_V850_ALIGN, - -/* This is a variation of BFD_RELOC_LO16 that can be used in v850e ld.bu -instructions. */ - BFD_RELOC_V850_LO16_SPLIT_OFFSET, - -/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the -instruction. */ - BFD_RELOC_MN10300_32_PCREL, - -/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the -instruction. */ - BFD_RELOC_MN10300_16_PCREL, - -/* This is a 8bit DP reloc for the tms320c30, where the most -significant 8 bits of a 24 bit word are placed into the least -significant 8 bits of the opcode. */ - BFD_RELOC_TIC30_LDP, - -/* This is a 7bit reloc for the tms320c54x, where the least -significant 7 bits of a 16 bit word are placed into the least -significant 7 bits of the opcode. */ - BFD_RELOC_TIC54X_PARTLS7, - -/* This is a 9bit DP reloc for the tms320c54x, where the most -significant 9 bits of a 16 bit word are placed into the least -significant 9 bits of the opcode. */ - BFD_RELOC_TIC54X_PARTMS9, - -/* This is an extended address 23-bit reloc for the tms320c54x. */ - BFD_RELOC_TIC54X_23, - -/* This is a 16-bit reloc for the tms320c54x, where the least -significant 16 bits of a 23-bit extended address are placed into -the opcode. */ - BFD_RELOC_TIC54X_16_OF_23, - -/* This is a reloc for the tms320c54x, where the most -significant 7 bits of a 23-bit extended address are placed into -the opcode. */ - BFD_RELOC_TIC54X_MS7_OF_23, - -/* This is a 48 bit reloc for the FR30 that stores 32 bits. */ - BFD_RELOC_FR30_48, - -/* This is a 32 bit reloc for the FR30 that stores 20 bits split up into -two sections. */ - BFD_RELOC_FR30_20, - -/* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in -4 bits. */ - BFD_RELOC_FR30_6_IN_4, - -/* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset -into 8 bits. */ - BFD_RELOC_FR30_8_IN_8, - -/* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset -into 8 bits. */ - BFD_RELOC_FR30_9_IN_8, - -/* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset -into 8 bits. */ - BFD_RELOC_FR30_10_IN_8, - -/* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative -short offset into 8 bits. */ - BFD_RELOC_FR30_9_PCREL, - -/* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative -short offset into 11 bits. */ - BFD_RELOC_FR30_12_PCREL, - -/* Motorola Mcore relocations. */ - BFD_RELOC_MCORE_PCREL_IMM8BY4, - BFD_RELOC_MCORE_PCREL_IMM11BY2, - BFD_RELOC_MCORE_PCREL_IMM4BY2, - BFD_RELOC_MCORE_PCREL_32, - BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, - BFD_RELOC_MCORE_RVA, - -/* Toshiba Media Processor Relocations. */ - BFD_RELOC_MEP_8, - BFD_RELOC_MEP_16, - BFD_RELOC_MEP_32, - BFD_RELOC_MEP_PCREL8A2, - BFD_RELOC_MEP_PCREL12A2, - BFD_RELOC_MEP_PCREL17A2, - BFD_RELOC_MEP_PCREL24A2, - BFD_RELOC_MEP_PCABS24A2, - BFD_RELOC_MEP_LOW16, - BFD_RELOC_MEP_HI16U, - BFD_RELOC_MEP_HI16S, - BFD_RELOC_MEP_GPREL, - BFD_RELOC_MEP_TPREL, - BFD_RELOC_MEP_TPREL7, - BFD_RELOC_MEP_TPREL7A2, - BFD_RELOC_MEP_TPREL7A4, - BFD_RELOC_MEP_UIMM24, - BFD_RELOC_MEP_ADDR24A4, - BFD_RELOC_MEP_GNU_VTINHERIT, - BFD_RELOC_MEP_GNU_VTENTRY, - - -/* These are relocations for the GETA instruction. */ - BFD_RELOC_MMIX_GETA, - BFD_RELOC_MMIX_GETA_1, - BFD_RELOC_MMIX_GETA_2, - BFD_RELOC_MMIX_GETA_3, - -/* These are relocations for a conditional branch instruction. */ - BFD_RELOC_MMIX_CBRANCH, - BFD_RELOC_MMIX_CBRANCH_J, - BFD_RELOC_MMIX_CBRANCH_1, - BFD_RELOC_MMIX_CBRANCH_2, - BFD_RELOC_MMIX_CBRANCH_3, - -/* These are relocations for the PUSHJ instruction. */ - BFD_RELOC_MMIX_PUSHJ, - BFD_RELOC_MMIX_PUSHJ_1, - BFD_RELOC_MMIX_PUSHJ_2, - BFD_RELOC_MMIX_PUSHJ_3, - BFD_RELOC_MMIX_PUSHJ_STUBBABLE, - -/* These are relocations for the JMP instruction. */ - BFD_RELOC_MMIX_JMP, - BFD_RELOC_MMIX_JMP_1, - BFD_RELOC_MMIX_JMP_2, - BFD_RELOC_MMIX_JMP_3, - -/* This is a relocation for a relative address as in a GETA instruction or -a branch. */ - BFD_RELOC_MMIX_ADDR19, - -/* This is a relocation for a relative address as in a JMP instruction. */ - BFD_RELOC_MMIX_ADDR27, - -/* This is a relocation for an instruction field that may be a general -register or a value 0..255. */ - BFD_RELOC_MMIX_REG_OR_BYTE, - -/* This is a relocation for an instruction field that may be a general -register. */ - BFD_RELOC_MMIX_REG, - -/* This is a relocation for two instruction fields holding a register and -an offset, the equivalent of the relocation. */ - BFD_RELOC_MMIX_BASE_PLUS_OFFSET, - -/* This relocation is an assertion that the expression is not allocated as -a global register. It does not modify contents. */ - BFD_RELOC_MMIX_LOCAL, - -/* This is a 16 bit reloc for the AVR that stores 8 bit pc relative -short offset into 7 bits. */ - BFD_RELOC_AVR_7_PCREL, - -/* This is a 16 bit reloc for the AVR that stores 13 bit pc relative -short offset into 12 bits. */ - BFD_RELOC_AVR_13_PCREL, - -/* This is a 16 bit reloc for the AVR that stores 17 bit value (usually -program memory address) into 16 bits. */ - BFD_RELOC_AVR_16_PM, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually -data memory address) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_LO8_LDI, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit -of data memory address) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_HI8_LDI, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit -of program memory address) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_HH8_LDI, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit -of 32 bit value) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_MS8_LDI, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value -(usually data memory address) into 8 bit immediate value of SUBI insn. */ - BFD_RELOC_AVR_LO8_LDI_NEG, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value -(high 8 bit of data memory address) into 8 bit immediate value of -SUBI insn. */ - BFD_RELOC_AVR_HI8_LDI_NEG, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value -(most high 8 bit of program memory address) into 8 bit immediate value -of LDI or SUBI insn. */ - BFD_RELOC_AVR_HH8_LDI_NEG, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value (msb -of 32 bit value) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_MS8_LDI_NEG, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually -command address) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_LO8_LDI_PM, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value -(command address) into 8 bit immediate value of LDI insn. If the address -is beyond the 128k boundary, the linker inserts a jump stub for this reloc -in the lower 128k. */ - BFD_RELOC_AVR_LO8_LDI_GS, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit -of command address) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_HI8_LDI_PM, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit -of command address) into 8 bit immediate value of LDI insn. If the address -is beyond the 128k boundary, the linker inserts a jump stub for this reloc -below 128k. */ - BFD_RELOC_AVR_HI8_LDI_GS, - -/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit -of command address) into 8 bit immediate value of LDI insn. */ - BFD_RELOC_AVR_HH8_LDI_PM, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value -(usually command address) into 8 bit immediate value of SUBI insn. */ - BFD_RELOC_AVR_LO8_LDI_PM_NEG, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value -(high 8 bit of 16 bit command address) into 8 bit immediate value -of SUBI insn. */ - BFD_RELOC_AVR_HI8_LDI_PM_NEG, - -/* This is a 16 bit reloc for the AVR that stores negated 8 bit value -(high 6 bit of 22 bit command address) into 8 bit immediate -value of SUBI insn. */ - BFD_RELOC_AVR_HH8_LDI_PM_NEG, - -/* This is a 32 bit reloc for the AVR that stores 23 bit value -into 22 bits. */ - BFD_RELOC_AVR_CALL, - -/* This is a 16 bit reloc for the AVR that stores all needed bits -for absolute addressing with ldi with overflow check to linktime */ - BFD_RELOC_AVR_LDI, - -/* This is a 6 bit reloc for the AVR that stores offset for ldd/std -instructions */ - BFD_RELOC_AVR_6, - -/* This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw -instructions */ - BFD_RELOC_AVR_6_ADIW, - -/* Direct 12 bit. */ - BFD_RELOC_390_12, - -/* 12 bit GOT offset. */ - BFD_RELOC_390_GOT12, - -/* 32 bit PC relative PLT address. */ - BFD_RELOC_390_PLT32, - -/* Copy symbol at runtime. */ - BFD_RELOC_390_COPY, - -/* Create GOT entry. */ - BFD_RELOC_390_GLOB_DAT, - -/* Create PLT entry. */ - BFD_RELOC_390_JMP_SLOT, - -/* Adjust by program base. */ - BFD_RELOC_390_RELATIVE, - -/* 32 bit PC relative offset to GOT. */ - BFD_RELOC_390_GOTPC, - -/* 16 bit GOT offset. */ - BFD_RELOC_390_GOT16, - -/* PC relative 16 bit shifted by 1. */ - BFD_RELOC_390_PC16DBL, - -/* 16 bit PC rel. PLT shifted by 1. */ - BFD_RELOC_390_PLT16DBL, - -/* PC relative 32 bit shifted by 1. */ - BFD_RELOC_390_PC32DBL, - -/* 32 bit PC rel. PLT shifted by 1. */ - BFD_RELOC_390_PLT32DBL, - -/* 32 bit PC rel. GOT shifted by 1. */ - BFD_RELOC_390_GOTPCDBL, - -/* 64 bit GOT offset. */ - BFD_RELOC_390_GOT64, - -/* 64 bit PC relative PLT address. */ - BFD_RELOC_390_PLT64, - -/* 32 bit rel. offset to GOT entry. */ - BFD_RELOC_390_GOTENT, - -/* 64 bit offset to GOT. */ - BFD_RELOC_390_GOTOFF64, - -/* 12-bit offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_390_GOTPLT12, - -/* 16-bit offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_390_GOTPLT16, - -/* 32-bit offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_390_GOTPLT32, - -/* 64-bit offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_390_GOTPLT64, - -/* 32-bit rel. offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_390_GOTPLTENT, - -/* 16-bit rel. offset from the GOT to a PLT entry. */ - BFD_RELOC_390_PLTOFF16, - -/* 32-bit rel. offset from the GOT to a PLT entry. */ - BFD_RELOC_390_PLTOFF32, - -/* 64-bit rel. offset from the GOT to a PLT entry. */ - BFD_RELOC_390_PLTOFF64, - -/* s390 tls relocations. */ - BFD_RELOC_390_TLS_LOAD, - BFD_RELOC_390_TLS_GDCALL, - BFD_RELOC_390_TLS_LDCALL, - BFD_RELOC_390_TLS_GD32, - BFD_RELOC_390_TLS_GD64, - BFD_RELOC_390_TLS_GOTIE12, - BFD_RELOC_390_TLS_GOTIE32, - BFD_RELOC_390_TLS_GOTIE64, - BFD_RELOC_390_TLS_LDM32, - BFD_RELOC_390_TLS_LDM64, - BFD_RELOC_390_TLS_IE32, - BFD_RELOC_390_TLS_IE64, - BFD_RELOC_390_TLS_IEENT, - BFD_RELOC_390_TLS_LE32, - BFD_RELOC_390_TLS_LE64, - BFD_RELOC_390_TLS_LDO32, - BFD_RELOC_390_TLS_LDO64, - BFD_RELOC_390_TLS_DTPMOD, - BFD_RELOC_390_TLS_DTPOFF, - BFD_RELOC_390_TLS_TPOFF, - -/* Long displacement extension. */ - BFD_RELOC_390_20, - BFD_RELOC_390_GOT20, - BFD_RELOC_390_GOTPLT20, - BFD_RELOC_390_TLS_GOTIE20, - -/* Score relocations */ - BFD_RELOC_SCORE_DUMMY1, - -/* Low 16 bit for load/store */ - BFD_RELOC_SCORE_GPREL15, - -/* This is a 24-bit reloc with the right 1 bit assumed to be 0 */ - BFD_RELOC_SCORE_DUMMY2, - BFD_RELOC_SCORE_JMP, - -/* This is a 19-bit reloc with the right 1 bit assumed to be 0 */ - BFD_RELOC_SCORE_BRANCH, - -/* This is a 11-bit reloc with the right 1 bit assumed to be 0 */ - BFD_RELOC_SCORE16_JMP, - -/* This is a 8-bit reloc with the right 1 bit assumed to be 0 */ - BFD_RELOC_SCORE16_BRANCH, - -/* Undocumented Score relocs */ - BFD_RELOC_SCORE_GOT15, - BFD_RELOC_SCORE_GOT_LO16, - BFD_RELOC_SCORE_CALL15, - BFD_RELOC_SCORE_DUMMY_HI16, - -/* Scenix IP2K - 9-bit register number / data address */ - BFD_RELOC_IP2K_FR9, - -/* Scenix IP2K - 4-bit register/data bank number */ - BFD_RELOC_IP2K_BANK, - -/* Scenix IP2K - low 13 bits of instruction word address */ - BFD_RELOC_IP2K_ADDR16CJP, - -/* Scenix IP2K - high 3 bits of instruction word address */ - BFD_RELOC_IP2K_PAGE3, - -/* Scenix IP2K - ext/low/high 8 bits of data address */ - BFD_RELOC_IP2K_LO8DATA, - BFD_RELOC_IP2K_HI8DATA, - BFD_RELOC_IP2K_EX8DATA, - -/* Scenix IP2K - low/high 8 bits of instruction word address */ - BFD_RELOC_IP2K_LO8INSN, - BFD_RELOC_IP2K_HI8INSN, - -/* Scenix IP2K - even/odd PC modifier to modify snb pcl.0 */ - BFD_RELOC_IP2K_PC_SKIP, - -/* Scenix IP2K - 16 bit word address in text section. */ - BFD_RELOC_IP2K_TEXT, - -/* Scenix IP2K - 7-bit sp or dp offset */ - BFD_RELOC_IP2K_FR_OFFSET, - -/* Scenix VPE4K coprocessor - data/insn-space addressing */ - BFD_RELOC_VPE4KMATH_DATA, - BFD_RELOC_VPE4KMATH_INSN, - -/* These two relocations are used by the linker to determine which of -the entries in a C++ virtual function table are actually used. When -the --gc-sections option is given, the linker will zero out the entries -that are not used, so that the code for those functions need not be -included in the output. - -VTABLE_INHERIT is a zero-space relocation used to describe to the -linker the inheritance tree of a C++ virtual function table. The -relocation's symbol should be the parent class' vtable, and the -relocation should be located at the child vtable. - -VTABLE_ENTRY is a zero-space relocation that describes the use of a -virtual function table entry. The reloc's symbol should refer to the -table of the class mentioned in the code. Off of that base, an offset -describes the entry that is being used. For Rela hosts, this offset -is stored in the reloc's addend. For Rel hosts, we are forced to put -this offset in the reloc's section offset. */ - BFD_RELOC_VTABLE_INHERIT, - BFD_RELOC_VTABLE_ENTRY, - -/* Intel IA64 Relocations. */ - BFD_RELOC_IA64_IMM14, - BFD_RELOC_IA64_IMM22, - BFD_RELOC_IA64_IMM64, - BFD_RELOC_IA64_DIR32MSB, - BFD_RELOC_IA64_DIR32LSB, - BFD_RELOC_IA64_DIR64MSB, - BFD_RELOC_IA64_DIR64LSB, - BFD_RELOC_IA64_GPREL22, - BFD_RELOC_IA64_GPREL64I, - BFD_RELOC_IA64_GPREL32MSB, - BFD_RELOC_IA64_GPREL32LSB, - BFD_RELOC_IA64_GPREL64MSB, - BFD_RELOC_IA64_GPREL64LSB, - BFD_RELOC_IA64_LTOFF22, - BFD_RELOC_IA64_LTOFF64I, - BFD_RELOC_IA64_PLTOFF22, - BFD_RELOC_IA64_PLTOFF64I, - BFD_RELOC_IA64_PLTOFF64MSB, - BFD_RELOC_IA64_PLTOFF64LSB, - BFD_RELOC_IA64_FPTR64I, - BFD_RELOC_IA64_FPTR32MSB, - BFD_RELOC_IA64_FPTR32LSB, - BFD_RELOC_IA64_FPTR64MSB, - BFD_RELOC_IA64_FPTR64LSB, - BFD_RELOC_IA64_PCREL21B, - BFD_RELOC_IA64_PCREL21BI, - BFD_RELOC_IA64_PCREL21M, - BFD_RELOC_IA64_PCREL21F, - BFD_RELOC_IA64_PCREL22, - BFD_RELOC_IA64_PCREL60B, - BFD_RELOC_IA64_PCREL64I, - BFD_RELOC_IA64_PCREL32MSB, - BFD_RELOC_IA64_PCREL32LSB, - BFD_RELOC_IA64_PCREL64MSB, - BFD_RELOC_IA64_PCREL64LSB, - BFD_RELOC_IA64_LTOFF_FPTR22, - BFD_RELOC_IA64_LTOFF_FPTR64I, - BFD_RELOC_IA64_LTOFF_FPTR32MSB, - BFD_RELOC_IA64_LTOFF_FPTR32LSB, - BFD_RELOC_IA64_LTOFF_FPTR64MSB, - BFD_RELOC_IA64_LTOFF_FPTR64LSB, - BFD_RELOC_IA64_SEGREL32MSB, - BFD_RELOC_IA64_SEGREL32LSB, - BFD_RELOC_IA64_SEGREL64MSB, - BFD_RELOC_IA64_SEGREL64LSB, - BFD_RELOC_IA64_SECREL32MSB, - BFD_RELOC_IA64_SECREL32LSB, - BFD_RELOC_IA64_SECREL64MSB, - BFD_RELOC_IA64_SECREL64LSB, - BFD_RELOC_IA64_REL32MSB, - BFD_RELOC_IA64_REL32LSB, - BFD_RELOC_IA64_REL64MSB, - BFD_RELOC_IA64_REL64LSB, - BFD_RELOC_IA64_LTV32MSB, - BFD_RELOC_IA64_LTV32LSB, - BFD_RELOC_IA64_LTV64MSB, - BFD_RELOC_IA64_LTV64LSB, - BFD_RELOC_IA64_IPLTMSB, - BFD_RELOC_IA64_IPLTLSB, - BFD_RELOC_IA64_COPY, - BFD_RELOC_IA64_LTOFF22X, - BFD_RELOC_IA64_LDXMOV, - BFD_RELOC_IA64_TPREL14, - BFD_RELOC_IA64_TPREL22, - BFD_RELOC_IA64_TPREL64I, - BFD_RELOC_IA64_TPREL64MSB, - BFD_RELOC_IA64_TPREL64LSB, - BFD_RELOC_IA64_LTOFF_TPREL22, - BFD_RELOC_IA64_DTPMOD64MSB, - BFD_RELOC_IA64_DTPMOD64LSB, - BFD_RELOC_IA64_LTOFF_DTPMOD22, - BFD_RELOC_IA64_DTPREL14, - BFD_RELOC_IA64_DTPREL22, - BFD_RELOC_IA64_DTPREL64I, - BFD_RELOC_IA64_DTPREL32MSB, - BFD_RELOC_IA64_DTPREL32LSB, - BFD_RELOC_IA64_DTPREL64MSB, - BFD_RELOC_IA64_DTPREL64LSB, - BFD_RELOC_IA64_LTOFF_DTPREL22, - -/* Motorola 68HC11 reloc. -This is the 8 bit high part of an absolute address. */ - BFD_RELOC_M68HC11_HI8, - -/* Motorola 68HC11 reloc. -This is the 8 bit low part of an absolute address. */ - BFD_RELOC_M68HC11_LO8, - -/* Motorola 68HC11 reloc. -This is the 3 bit of a value. */ - BFD_RELOC_M68HC11_3B, - -/* Motorola 68HC11 reloc. -This reloc marks the beginning of a jump/call instruction. -It is used for linker relaxation to correctly identify beginning -of instruction and change some branches to use PC-relative -addressing mode. */ - BFD_RELOC_M68HC11_RL_JUMP, - -/* Motorola 68HC11 reloc. -This reloc marks a group of several instructions that gcc generates -and for which the linker relaxation pass can modify and/or remove -some of them. */ - BFD_RELOC_M68HC11_RL_GROUP, - -/* Motorola 68HC11 reloc. -This is the 16-bit lower part of an address. It is used for 'call' -instruction to specify the symbol address without any special -transformation (due to memory bank window). */ - BFD_RELOC_M68HC11_LO16, - -/* Motorola 68HC11 reloc. -This is a 8-bit reloc that specifies the page number of an address. -It is used by 'call' instruction to specify the page number of -the symbol. */ - BFD_RELOC_M68HC11_PAGE, - -/* Motorola 68HC11 reloc. -This is a 24-bit reloc that represents the address with a 16-bit -value and a 8-bit page number. The symbol address is transformed -to follow the 16K memory bank of 68HC12 (seen as mapped in the window). */ - BFD_RELOC_M68HC11_24, - -/* Motorola 68HC12 reloc. -This is the 5 bits of a value. */ - BFD_RELOC_M68HC12_5B, - -/* NS CR16C Relocations. */ - BFD_RELOC_16C_NUM08, - BFD_RELOC_16C_NUM08_C, - BFD_RELOC_16C_NUM16, - BFD_RELOC_16C_NUM16_C, - BFD_RELOC_16C_NUM32, - BFD_RELOC_16C_NUM32_C, - BFD_RELOC_16C_DISP04, - BFD_RELOC_16C_DISP04_C, - BFD_RELOC_16C_DISP08, - BFD_RELOC_16C_DISP08_C, - BFD_RELOC_16C_DISP16, - BFD_RELOC_16C_DISP16_C, - BFD_RELOC_16C_DISP24, - BFD_RELOC_16C_DISP24_C, - BFD_RELOC_16C_DISP24a, - BFD_RELOC_16C_DISP24a_C, - BFD_RELOC_16C_REG04, - BFD_RELOC_16C_REG04_C, - BFD_RELOC_16C_REG04a, - BFD_RELOC_16C_REG04a_C, - BFD_RELOC_16C_REG14, - BFD_RELOC_16C_REG14_C, - BFD_RELOC_16C_REG16, - BFD_RELOC_16C_REG16_C, - BFD_RELOC_16C_REG20, - BFD_RELOC_16C_REG20_C, - BFD_RELOC_16C_ABS20, - BFD_RELOC_16C_ABS20_C, - BFD_RELOC_16C_ABS24, - BFD_RELOC_16C_ABS24_C, - BFD_RELOC_16C_IMM04, - BFD_RELOC_16C_IMM04_C, - BFD_RELOC_16C_IMM16, - BFD_RELOC_16C_IMM16_C, - BFD_RELOC_16C_IMM20, - BFD_RELOC_16C_IMM20_C, - BFD_RELOC_16C_IMM24, - BFD_RELOC_16C_IMM24_C, - BFD_RELOC_16C_IMM32, - BFD_RELOC_16C_IMM32_C, - -/* NS CR16 Relocations. */ - BFD_RELOC_CR16_NUM8, - BFD_RELOC_CR16_NUM16, - BFD_RELOC_CR16_NUM32, - BFD_RELOC_CR16_NUM32a, - BFD_RELOC_CR16_REGREL0, - BFD_RELOC_CR16_REGREL4, - BFD_RELOC_CR16_REGREL4a, - BFD_RELOC_CR16_REGREL14, - BFD_RELOC_CR16_REGREL14a, - BFD_RELOC_CR16_REGREL16, - BFD_RELOC_CR16_REGREL20, - BFD_RELOC_CR16_REGREL20a, - BFD_RELOC_CR16_ABS20, - BFD_RELOC_CR16_ABS24, - BFD_RELOC_CR16_IMM4, - BFD_RELOC_CR16_IMM8, - BFD_RELOC_CR16_IMM16, - BFD_RELOC_CR16_IMM20, - BFD_RELOC_CR16_IMM24, - BFD_RELOC_CR16_IMM32, - BFD_RELOC_CR16_IMM32a, - BFD_RELOC_CR16_DISP4, - BFD_RELOC_CR16_DISP8, - BFD_RELOC_CR16_DISP16, - BFD_RELOC_CR16_DISP20, - BFD_RELOC_CR16_DISP24, - BFD_RELOC_CR16_DISP24a, - -/* NS CRX Relocations. */ - BFD_RELOC_CRX_REL4, - BFD_RELOC_CRX_REL8, - BFD_RELOC_CRX_REL8_CMP, - BFD_RELOC_CRX_REL16, - BFD_RELOC_CRX_REL24, - BFD_RELOC_CRX_REL32, - BFD_RELOC_CRX_REGREL12, - BFD_RELOC_CRX_REGREL22, - BFD_RELOC_CRX_REGREL28, - BFD_RELOC_CRX_REGREL32, - BFD_RELOC_CRX_ABS16, - BFD_RELOC_CRX_ABS32, - BFD_RELOC_CRX_NUM8, - BFD_RELOC_CRX_NUM16, - BFD_RELOC_CRX_NUM32, - BFD_RELOC_CRX_IMM16, - BFD_RELOC_CRX_IMM32, - BFD_RELOC_CRX_SWITCH8, - BFD_RELOC_CRX_SWITCH16, - BFD_RELOC_CRX_SWITCH32, - -/* These relocs are only used within the CRIS assembler. They are not -(at present) written to any object files. */ - BFD_RELOC_CRIS_BDISP8, - BFD_RELOC_CRIS_UNSIGNED_5, - BFD_RELOC_CRIS_SIGNED_6, - BFD_RELOC_CRIS_UNSIGNED_6, - BFD_RELOC_CRIS_SIGNED_8, - BFD_RELOC_CRIS_UNSIGNED_8, - BFD_RELOC_CRIS_SIGNED_16, - BFD_RELOC_CRIS_UNSIGNED_16, - BFD_RELOC_CRIS_LAPCQ_OFFSET, - BFD_RELOC_CRIS_UNSIGNED_4, - -/* Relocs used in ELF shared libraries for CRIS. */ - BFD_RELOC_CRIS_COPY, - BFD_RELOC_CRIS_GLOB_DAT, - BFD_RELOC_CRIS_JUMP_SLOT, - BFD_RELOC_CRIS_RELATIVE, - -/* 32-bit offset to symbol-entry within GOT. */ - BFD_RELOC_CRIS_32_GOT, - -/* 16-bit offset to symbol-entry within GOT. */ - BFD_RELOC_CRIS_16_GOT, - -/* 32-bit offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_CRIS_32_GOTPLT, - -/* 16-bit offset to symbol-entry within GOT, with PLT handling. */ - BFD_RELOC_CRIS_16_GOTPLT, - -/* 32-bit offset to symbol, relative to GOT. */ - BFD_RELOC_CRIS_32_GOTREL, - -/* 32-bit offset to symbol with PLT entry, relative to GOT. */ - BFD_RELOC_CRIS_32_PLT_GOTREL, - -/* 32-bit offset to symbol with PLT entry, relative to this relocation. */ - BFD_RELOC_CRIS_32_PLT_PCREL, - -/* Intel i860 Relocations. */ - BFD_RELOC_860_COPY, - BFD_RELOC_860_GLOB_DAT, - BFD_RELOC_860_JUMP_SLOT, - BFD_RELOC_860_RELATIVE, - BFD_RELOC_860_PC26, - BFD_RELOC_860_PLT26, - BFD_RELOC_860_PC16, - BFD_RELOC_860_LOW0, - BFD_RELOC_860_SPLIT0, - BFD_RELOC_860_LOW1, - BFD_RELOC_860_SPLIT1, - BFD_RELOC_860_LOW2, - BFD_RELOC_860_SPLIT2, - BFD_RELOC_860_LOW3, - BFD_RELOC_860_LOGOT0, - BFD_RELOC_860_SPGOT0, - BFD_RELOC_860_LOGOT1, - BFD_RELOC_860_SPGOT1, - BFD_RELOC_860_LOGOTOFF0, - BFD_RELOC_860_SPGOTOFF0, - BFD_RELOC_860_LOGOTOFF1, - BFD_RELOC_860_SPGOTOFF1, - BFD_RELOC_860_LOGOTOFF2, - BFD_RELOC_860_LOGOTOFF3, - BFD_RELOC_860_LOPC, - BFD_RELOC_860_HIGHADJ, - BFD_RELOC_860_HAGOT, - BFD_RELOC_860_HAGOTOFF, - BFD_RELOC_860_HAPC, - BFD_RELOC_860_HIGH, - BFD_RELOC_860_HIGOT, - BFD_RELOC_860_HIGOTOFF, - -/* OpenRISC Relocations. */ - BFD_RELOC_OPENRISC_ABS_26, - BFD_RELOC_OPENRISC_REL_26, - -/* H8 elf Relocations. */ - BFD_RELOC_H8_DIR16A8, - BFD_RELOC_H8_DIR16R8, - BFD_RELOC_H8_DIR24A8, - BFD_RELOC_H8_DIR24R8, - BFD_RELOC_H8_DIR32A16, - -/* Sony Xstormy16 Relocations. */ - BFD_RELOC_XSTORMY16_REL_12, - BFD_RELOC_XSTORMY16_12, - BFD_RELOC_XSTORMY16_24, - BFD_RELOC_XSTORMY16_FPTR16, - -/* Self-describing complex relocations. */ - BFD_RELOC_RELC, - - -/* Infineon Relocations. */ - BFD_RELOC_XC16X_PAG, - BFD_RELOC_XC16X_POF, - BFD_RELOC_XC16X_SEG, - BFD_RELOC_XC16X_SOF, - -/* Relocations used by VAX ELF. */ - BFD_RELOC_VAX_GLOB_DAT, - BFD_RELOC_VAX_JMP_SLOT, - BFD_RELOC_VAX_RELATIVE, - -/* Morpho MT - 16 bit immediate relocation. */ - BFD_RELOC_MT_PC16, - -/* Morpho MT - Hi 16 bits of an address. */ - BFD_RELOC_MT_HI16, - -/* Morpho MT - Low 16 bits of an address. */ - BFD_RELOC_MT_LO16, - -/* Morpho MT - Used to tell the linker which vtable entries are used. */ - BFD_RELOC_MT_GNU_VTINHERIT, - -/* Morpho MT - Used to tell the linker which vtable entries are used. */ - BFD_RELOC_MT_GNU_VTENTRY, - -/* Morpho MT - 8 bit immediate relocation. */ - BFD_RELOC_MT_PCINSN8, - -/* msp430 specific relocation codes */ - BFD_RELOC_MSP430_10_PCREL, - BFD_RELOC_MSP430_16_PCREL, - BFD_RELOC_MSP430_16, - BFD_RELOC_MSP430_16_PCREL_BYTE, - BFD_RELOC_MSP430_16_BYTE, - BFD_RELOC_MSP430_2X_PCREL, - BFD_RELOC_MSP430_RL_PCREL, - -/* IQ2000 Relocations. */ - BFD_RELOC_IQ2000_OFFSET_16, - BFD_RELOC_IQ2000_OFFSET_21, - BFD_RELOC_IQ2000_UHI16, - -/* Special Xtensa relocation used only by PLT entries in ELF shared -objects to indicate that the runtime linker should set the value -to one of its own internal functions or data structures. */ - BFD_RELOC_XTENSA_RTLD, - -/* Xtensa relocations for ELF shared objects. */ - BFD_RELOC_XTENSA_GLOB_DAT, - BFD_RELOC_XTENSA_JMP_SLOT, - BFD_RELOC_XTENSA_RELATIVE, - -/* Xtensa relocation used in ELF object files for symbols that may require -PLT entries. Otherwise, this is just a generic 32-bit relocation. */ - BFD_RELOC_XTENSA_PLT, - -/* Xtensa relocations to mark the difference of two local symbols. -These are only needed to support linker relaxation and can be ignored -when not relaxing. The field is set to the value of the difference -assuming no relaxation. The relocation encodes the position of the -first symbol so the linker can determine whether to adjust the field -value. */ - BFD_RELOC_XTENSA_DIFF8, - BFD_RELOC_XTENSA_DIFF16, - BFD_RELOC_XTENSA_DIFF32, - -/* Generic Xtensa relocations for instruction operands. Only the slot -number is encoded in the relocation. The relocation applies to the -last PC-relative immediate operand, or if there are no PC-relative -immediates, to the last immediate operand. */ - BFD_RELOC_XTENSA_SLOT0_OP, - BFD_RELOC_XTENSA_SLOT1_OP, - BFD_RELOC_XTENSA_SLOT2_OP, - BFD_RELOC_XTENSA_SLOT3_OP, - BFD_RELOC_XTENSA_SLOT4_OP, - BFD_RELOC_XTENSA_SLOT5_OP, - BFD_RELOC_XTENSA_SLOT6_OP, - BFD_RELOC_XTENSA_SLOT7_OP, - BFD_RELOC_XTENSA_SLOT8_OP, - BFD_RELOC_XTENSA_SLOT9_OP, - BFD_RELOC_XTENSA_SLOT10_OP, - BFD_RELOC_XTENSA_SLOT11_OP, - BFD_RELOC_XTENSA_SLOT12_OP, - BFD_RELOC_XTENSA_SLOT13_OP, - BFD_RELOC_XTENSA_SLOT14_OP, - -/* Alternate Xtensa relocations. Only the slot is encoded in the -relocation. The meaning of these relocations is opcode-specific. */ - BFD_RELOC_XTENSA_SLOT0_ALT, - BFD_RELOC_XTENSA_SLOT1_ALT, - BFD_RELOC_XTENSA_SLOT2_ALT, - BFD_RELOC_XTENSA_SLOT3_ALT, - BFD_RELOC_XTENSA_SLOT4_ALT, - BFD_RELOC_XTENSA_SLOT5_ALT, - BFD_RELOC_XTENSA_SLOT6_ALT, - BFD_RELOC_XTENSA_SLOT7_ALT, - BFD_RELOC_XTENSA_SLOT8_ALT, - BFD_RELOC_XTENSA_SLOT9_ALT, - BFD_RELOC_XTENSA_SLOT10_ALT, - BFD_RELOC_XTENSA_SLOT11_ALT, - BFD_RELOC_XTENSA_SLOT12_ALT, - BFD_RELOC_XTENSA_SLOT13_ALT, - BFD_RELOC_XTENSA_SLOT14_ALT, - -/* Xtensa relocations for backward compatibility. These have all been -replaced by BFD_RELOC_XTENSA_SLOT0_OP. */ - BFD_RELOC_XTENSA_OP0, - BFD_RELOC_XTENSA_OP1, - BFD_RELOC_XTENSA_OP2, - -/* Xtensa relocation to mark that the assembler expanded the -instructions from an original target. The expansion size is -encoded in the reloc size. */ - BFD_RELOC_XTENSA_ASM_EXPAND, - -/* Xtensa relocation to mark that the linker should simplify -assembler-expanded instructions. This is commonly used -internally by the linker after analysis of a -BFD_RELOC_XTENSA_ASM_EXPAND. */ - BFD_RELOC_XTENSA_ASM_SIMPLIFY, - -/* 8 bit signed offset in (ix+d) or (iy+d). */ - BFD_RELOC_Z80_DISP8, - -/* DJNZ offset. */ - BFD_RELOC_Z8K_DISP7, - -/* CALR offset. */ - BFD_RELOC_Z8K_CALLR, - -/* 4 bit value. */ - BFD_RELOC_Z8K_IMM4L, - BFD_RELOC_UNUSED }; -typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; -reloc_howto_type *bfd_reloc_type_lookup - (bfd *abfd, bfd_reloc_code_real_type code); -reloc_howto_type *bfd_reloc_name_lookup - (bfd *abfd, const char *reloc_name); - -const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); - -/* Extracted from syms.c. */ - -typedef struct bfd_symbol -{ - /* A pointer to the BFD which owns the symbol. This information - is necessary so that a back end can work out what additional - information (invisible to the application writer) is carried - with the symbol. - - This field is *almost* redundant, since you can use section->owner - instead, except that some symbols point to the global sections - bfd_{abs,com,und}_section. This could be fixed by making - these globals be per-bfd (or per-target-flavor). FIXME. */ - struct bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ - - /* The text of the symbol. The name is left alone, and not copied; the - application may not alter it. */ - const char *name; - - /* The value of the symbol. This really should be a union of a - numeric value with a pointer, since some flags indicate that - a pointer to another symbol is stored here. */ - symvalue value; - - /* Attributes of a symbol. */ -#define BSF_NO_FLAGS 0x00 - - /* The symbol has local scope; <> in <>. The value - is the offset into the section of the data. */ -#define BSF_LOCAL 0x01 - - /* The symbol has global scope; initialized data in <>. The - value is the offset into the section of the data. */ -#define BSF_GLOBAL 0x02 - - /* The symbol has global scope and is exported. The value is - the offset into the section of the data. */ -#define BSF_EXPORT BSF_GLOBAL /* No real difference. */ - - /* A normal C symbol would be one of: - <>, <>, <> or - <>. */ - - /* The symbol is a debugging record. The value has an arbitrary - meaning, unless BSF_DEBUGGING_RELOC is also set. */ -#define BSF_DEBUGGING 0x08 - - /* The symbol denotes a function entry point. Used in ELF, - perhaps others someday. */ -#define BSF_FUNCTION 0x10 - - /* Used by the linker. */ -#define BSF_KEEP 0x20 -#define BSF_KEEP_G 0x40 - - /* A weak global symbol, overridable without warnings by - a regular global symbol of the same name. */ -#define BSF_WEAK 0x80 - - /* This symbol was created to point to a section, e.g. ELF's - STT_SECTION symbols. */ -#define BSF_SECTION_SYM 0x100 - - /* The symbol used to be a common symbol, but now it is - allocated. */ -#define BSF_OLD_COMMON 0x200 - - /* The default value for common data. */ -#define BFD_FORT_COMM_DEFAULT_VALUE 0 - - /* In some files the type of a symbol sometimes alters its - location in an output file - ie in coff a <> symbol - which is also <> symbol appears where it was - declared and not at the end of a section. This bit is set - by the target BFD part to convey this information. */ -#define BSF_NOT_AT_END 0x400 - - /* Signal that the symbol is the label of constructor section. */ -#define BSF_CONSTRUCTOR 0x800 - - /* Signal that the symbol is a warning symbol. The name is a - warning. The name of the next symbol is the one to warn about; - if a reference is made to a symbol with the same name as the next - symbol, a warning is issued by the linker. */ -#define BSF_WARNING 0x1000 - - /* Signal that the symbol is indirect. This symbol is an indirect - pointer to the symbol with the same name as the next symbol. */ -#define BSF_INDIRECT 0x2000 - - /* BSF_FILE marks symbols that contain a file name. This is used - for ELF STT_FILE symbols. */ -#define BSF_FILE 0x4000 - - /* Symbol is from dynamic linking information. */ -#define BSF_DYNAMIC 0x8000 - - /* The symbol denotes a data object. Used in ELF, and perhaps - others someday. */ -#define BSF_OBJECT 0x10000 - - /* This symbol is a debugging symbol. The value is the offset - into the section of the data. BSF_DEBUGGING should be set - as well. */ -#define BSF_DEBUGGING_RELOC 0x20000 - - /* This symbol is thread local. Used in ELF. */ -#define BSF_THREAD_LOCAL 0x40000 - - /* This symbol represents a complex relocation expression, - with the expression tree serialized in the symbol name. */ -#define BSF_RELC 0x80000 - - /* This symbol represents a signed complex relocation expression, - with the expression tree serialized in the symbol name. */ -#define BSF_SRELC 0x100000 - - flagword flags; - - /* A pointer to the section to which this symbol is - relative. This will always be non NULL, there are special - sections for undefined and absolute symbols. */ - struct bfd_section *section; - - /* Back end special data. */ - union - { - void *p; - bfd_vma i; - } - udata; -} -asymbol; - -#define bfd_get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) - -bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym); - -bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name); - -#define bfd_is_local_label_name(abfd, name) \ - BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) - -bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym); - -#define bfd_is_target_special_symbol(abfd, sym) \ - BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym)) - -#define bfd_canonicalize_symtab(abfd, location) \ - BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location)) - -bfd_boolean bfd_set_symtab - (bfd *abfd, asymbol **location, unsigned int count); - -void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol); - -#define bfd_make_empty_symbol(abfd) \ - BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) - -asymbol *_bfd_generic_make_empty_symbol (bfd *); - -#define bfd_make_debug_symbol(abfd,ptr,size) \ - BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) - -int bfd_decode_symclass (asymbol *symbol); - -bfd_boolean bfd_is_undefined_symclass (int symclass); - -void bfd_symbol_info (asymbol *symbol, symbol_info *ret); - -bfd_boolean bfd_copy_private_symbol_data - (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); - -#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ - BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ - (ibfd, isymbol, obfd, osymbol)) - -/* Extracted from bfd.c. */ -struct bfd -{ - /* A unique identifier of the BFD */ - unsigned int id; - - /* The filename the application opened the BFD with. */ - const char *filename; - - /* A pointer to the target jump table. */ - const struct bfd_target *xvec; - - /* The IOSTREAM, and corresponding IO vector that provide access - to the file backing the BFD. */ - void *iostream; - const struct bfd_iovec *iovec; - - /* Is the file descriptor being cached? That is, can it be closed as - needed, and re-opened when accessed later? */ - bfd_boolean cacheable; - - /* Marks whether there was a default target specified when the - BFD was opened. This is used to select which matching algorithm - to use to choose the back end. */ - bfd_boolean target_defaulted; - - /* The caching routines use these to maintain a - least-recently-used list of BFDs. */ - struct bfd *lru_prev, *lru_next; - - /* When a file is closed by the caching routines, BFD retains - state information on the file here... */ - ufile_ptr where; - - /* ... and here: (``once'' means at least once). */ - bfd_boolean opened_once; - - /* Set if we have a locally maintained mtime value, rather than - getting it from the file each time. */ - bfd_boolean mtime_set; - - /* File modified time, if mtime_set is TRUE. */ - long mtime; - - /* Reserved for an unimplemented file locking extension. */ - int ifd; - - /* The format which belongs to the BFD. (object, core, etc.) */ - bfd_format format; - - /* The direction with which the BFD was opened. */ - enum bfd_direction - { - no_direction = 0, - read_direction = 1, - write_direction = 2, - both_direction = 3 - } - direction; - - /* Format_specific flags. */ - flagword flags; - - /* Currently my_archive is tested before adding origin to - anything. I believe that this can become always an add of - origin, with origin set to 0 for non archive files. */ - ufile_ptr origin; - - /* Remember when output has begun, to stop strange things - from happening. */ - bfd_boolean output_has_begun; - - /* A hash table for section names. */ - struct bfd_hash_table section_htab; - - /* Pointer to linked list of sections. */ - struct bfd_section *sections; - - /* The last section on the section list. */ - struct bfd_section *section_last; - - /* The number of sections. */ - unsigned int section_count; - - /* Stuff only useful for object files: - The start address. */ - bfd_vma start_address; - - /* Used for input and output. */ - unsigned int symcount; - - /* Symbol table for output BFD (with symcount entries). */ - struct bfd_symbol **outsymbols; - - /* Used for slurped dynamic symbol tables. */ - unsigned int dynsymcount; - - /* Pointer to structure which contains architecture information. */ - const struct bfd_arch_info *arch_info; - - /* Flag set if symbols from this BFD should not be exported. */ - bfd_boolean no_export; - - /* Stuff only useful for archives. */ - void *arelt_data; - struct bfd *my_archive; /* The containing archive BFD. */ - struct bfd *archive_next; /* The next BFD in the archive. */ - struct bfd *archive_head; /* The first BFD in the archive. */ - bfd_boolean has_armap; - - /* A chain of BFD structures involved in a link. */ - struct bfd *link_next; - - /* A field used by _bfd_generic_link_add_archive_symbols. This will - be used only for archive elements. */ - int archive_pass; - - /* Used by the back end to hold private data. */ - union - { - struct aout_data_struct *aout_data; - struct artdata *aout_ar_data; - struct _oasys_data *oasys_obj_data; - struct _oasys_ar_data *oasys_ar_data; - struct coff_tdata *coff_obj_data; - struct pe_tdata *pe_obj_data; - struct xcoff_tdata *xcoff_obj_data; - struct ecoff_tdata *ecoff_obj_data; - struct ieee_data_struct *ieee_data; - struct ieee_ar_data_struct *ieee_ar_data; - struct srec_data_struct *srec_data; - struct ihex_data_struct *ihex_data; - struct tekhex_data_struct *tekhex_data; - struct elf_obj_tdata *elf_obj_data; - struct nlm_obj_tdata *nlm_obj_data; - struct bout_data_struct *bout_data; - struct mmo_data_struct *mmo_data; - struct sun_core_struct *sun_core_data; - struct sco5_core_struct *sco5_core_data; - struct trad_core_struct *trad_core_data; - struct som_data_struct *som_data; - struct hpux_core_struct *hpux_core_data; - struct hppabsd_core_struct *hppabsd_core_data; - struct sgi_core_struct *sgi_core_data; - struct lynx_core_struct *lynx_core_data; - struct osf_core_struct *osf_core_data; - struct cisco_core_struct *cisco_core_data; - struct versados_data_struct *versados_data; - struct netbsd_core_struct *netbsd_core_data; - struct mach_o_data_struct *mach_o_data; - struct mach_o_fat_data_struct *mach_o_fat_data; - struct bfd_pef_data_struct *pef_data; - struct bfd_pef_xlib_data_struct *pef_xlib_data; - struct bfd_sym_data_struct *sym_data; - void *any; - } - tdata; - - /* Used by the application to hold private data. */ - void *usrdata; - - /* Where all the allocated stuff under this BFD goes. This is a - struct objalloc *, but we use void * to avoid requiring the inclusion - of objalloc.h. */ - void *memory; -}; - -typedef enum bfd_error -{ - bfd_error_no_error = 0, - bfd_error_system_call, - bfd_error_invalid_target, - bfd_error_wrong_format, - bfd_error_wrong_object_format, - bfd_error_invalid_operation, - bfd_error_no_memory, - bfd_error_no_symbols, - bfd_error_no_armap, - bfd_error_no_more_archived_files, - bfd_error_malformed_archive, - bfd_error_file_not_recognized, - bfd_error_file_ambiguously_recognized, - bfd_error_no_contents, - bfd_error_nonrepresentable_section, - bfd_error_no_debug_section, - bfd_error_bad_value, - bfd_error_file_truncated, - bfd_error_file_too_big, - bfd_error_on_input, - bfd_error_invalid_error_code -} -bfd_error_type; - -bfd_error_type bfd_get_error (void); - -void bfd_set_error (bfd_error_type error_tag, ...); - -const char *bfd_errmsg (bfd_error_type error_tag); - -void bfd_perror (const char *message); - -typedef void (*bfd_error_handler_type) (const char *, ...); - -bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); - -void bfd_set_error_program_name (const char *); - -bfd_error_handler_type bfd_get_error_handler (void); - -long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect); - -long bfd_canonicalize_reloc - (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); - -void bfd_set_reloc - (bfd *abfd, asection *sec, arelent **rel, unsigned int count); - -bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags); - -int bfd_get_arch_size (bfd *abfd); - -int bfd_get_sign_extend_vma (bfd *abfd); - -bfd_boolean bfd_set_start_address (bfd *abfd, bfd_vma vma); - -unsigned int bfd_get_gp_size (bfd *abfd); - -void bfd_set_gp_size (bfd *abfd, unsigned int i); - -bfd_vma bfd_scan_vma (const char *string, const char **end, int base); - -bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd); - -#define bfd_copy_private_header_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_copy_private_header_data, \ - (ibfd, obfd)) -bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd); - -#define bfd_copy_private_bfd_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ - (ibfd, obfd)) -bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd); - -#define bfd_merge_private_bfd_data(ibfd, obfd) \ - BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ - (ibfd, obfd)) -bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags); - -#define bfd_set_private_flags(abfd, flags) \ - BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags)) -#define bfd_sizeof_headers(abfd, info) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, info)) - -#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ - BFD_SEND (abfd, _bfd_find_nearest_line, \ - (abfd, sec, syms, off, file, func, line)) - -#define bfd_find_line(abfd, syms, sym, file, line) \ - BFD_SEND (abfd, _bfd_find_line, \ - (abfd, syms, sym, file, line)) - -#define bfd_find_inliner_info(abfd, file, func, line) \ - BFD_SEND (abfd, _bfd_find_inliner_info, \ - (abfd, file, func, line)) - -#define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - -#define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - -#define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - -#define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - -#define bfd_update_armap_timestamp(abfd) \ - BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) - -#define bfd_set_arch_mach(abfd, arch, mach)\ - BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) - -#define bfd_relax_section(abfd, section, link_info, again) \ - BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) - -#define bfd_gc_sections(abfd, link_info) \ - BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) - -#define bfd_merge_sections(abfd, link_info) \ - BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) - -#define bfd_is_group_section(abfd, sec) \ - BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec)) - -#define bfd_discard_group(abfd, sec) \ - BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) - -#define bfd_link_hash_table_create(abfd) \ - BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) - -#define bfd_link_hash_table_free(abfd, hash) \ - BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) - -#define bfd_link_add_symbols(abfd, info) \ - BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) - -#define bfd_link_just_syms(abfd, sec, info) \ - BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) - -#define bfd_final_link(abfd, info) \ - BFD_SEND (abfd, _bfd_final_link, (abfd, info)) - -#define bfd_free_cached_info(abfd) \ - BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) - -#define bfd_get_dynamic_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) - -#define bfd_print_private_bfd_data(abfd, file)\ - BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) - -#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) - -#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \ - BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \ - dyncount, dynsyms, ret)) - -#define bfd_get_dynamic_reloc_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) - -#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) - -extern bfd_byte *bfd_get_relocated_section_contents - (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, - bfd_boolean, asymbol **); - -bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative); - -struct bfd_preserve -{ - void *marker; - void *tdata; - flagword flags; - const struct bfd_arch_info *arch_info; - struct bfd_section *sections; - struct bfd_section *section_last; - unsigned int section_count; - struct bfd_hash_table section_htab; -}; - -bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *); - -void bfd_preserve_restore (bfd *, struct bfd_preserve *); - -void bfd_preserve_finish (bfd *, struct bfd_preserve *); - -bfd_vma bfd_emul_get_maxpagesize (const char *); - -void bfd_emul_set_maxpagesize (const char *, bfd_vma); - -bfd_vma bfd_emul_get_commonpagesize (const char *); - -void bfd_emul_set_commonpagesize (const char *, bfd_vma); - -char *bfd_demangle (bfd *, const char *, int); - -/* Extracted from archive.c. */ -symindex bfd_get_next_mapent - (bfd *abfd, symindex previous, carsym **sym); - -bfd_boolean bfd_set_archive_head (bfd *output, bfd *new_head); - -bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous); - -/* Extracted from corefile.c. */ -const char *bfd_core_file_failing_command (bfd *abfd); - -int bfd_core_file_failing_signal (bfd *abfd); - -bfd_boolean core_file_matches_executable_p - (bfd *core_bfd, bfd *exec_bfd); - -bfd_boolean generic_core_file_matches_executable_p - (bfd *core_bfd, bfd *exec_bfd); - -/* Extracted from targets.c. */ -#define BFD_SEND(bfd, message, arglist) \ - ((*((bfd)->xvec->message)) arglist) - -#ifdef DEBUG_BFD_SEND -#undef BFD_SEND -#define BFD_SEND(bfd, message, arglist) \ - (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ - ((*((bfd)->xvec->message)) arglist) : \ - (bfd_assert (__FILE__,__LINE__), NULL)) -#endif -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) - -#ifdef DEBUG_BFD_SEND -#undef BFD_SEND_FMT -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ - (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \ - (bfd_assert (__FILE__,__LINE__), NULL)) -#endif - -enum bfd_flavour -{ - bfd_target_unknown_flavour, - bfd_target_aout_flavour, - bfd_target_coff_flavour, - bfd_target_ecoff_flavour, - bfd_target_xcoff_flavour, - bfd_target_elf_flavour, - bfd_target_ieee_flavour, - bfd_target_nlm_flavour, - bfd_target_oasys_flavour, - bfd_target_tekhex_flavour, - bfd_target_srec_flavour, - bfd_target_ihex_flavour, - bfd_target_som_flavour, - bfd_target_os9k_flavour, - bfd_target_versados_flavour, - bfd_target_msdos_flavour, - bfd_target_ovax_flavour, - bfd_target_evax_flavour, - bfd_target_mmo_flavour, - bfd_target_mach_o_flavour, - bfd_target_pef_flavour, - bfd_target_pef_xlib_flavour, - bfd_target_sym_flavour -}; - -enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN }; - -/* Forward declaration. */ -typedef struct bfd_link_info _bfd_link_info; - -typedef struct bfd_target -{ - /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */ - char *name; - - /* The "flavour" of a back end is a general indication about - the contents of a file. */ - enum bfd_flavour flavour; - - /* The order of bytes within the data area of a file. */ - enum bfd_endian byteorder; - - /* The order of bytes within the header parts of a file. */ - enum bfd_endian header_byteorder; - - /* A mask of all the flags which an executable may have set - - from the set <>, <>, ...<>. */ - flagword object_flags; - - /* A mask of all the flags which a section may have set - from - the set <>, <>, ...<>. */ - flagword section_flags; - - /* The character normally found at the front of a symbol. - (if any), perhaps `_'. */ - char symbol_leading_char; - - /* The pad character for file names within an archive header. */ - char ar_pad_char; - - /* The maximum number of characters in an archive header. */ - unsigned short ar_max_namelen; - - /* Entries for byte swapping for data. These are different from the - other entry points, since they don't take a BFD as the first argument. - Certain other handlers could do the same. */ - bfd_uint64_t (*bfd_getx64) (const void *); - bfd_int64_t (*bfd_getx_signed_64) (const void *); - void (*bfd_putx64) (bfd_uint64_t, void *); - bfd_vma (*bfd_getx32) (const void *); - bfd_signed_vma (*bfd_getx_signed_32) (const void *); - void (*bfd_putx32) (bfd_vma, void *); - bfd_vma (*bfd_getx16) (const void *); - bfd_signed_vma (*bfd_getx_signed_16) (const void *); - void (*bfd_putx16) (bfd_vma, void *); - - /* Byte swapping for the headers. */ - bfd_uint64_t (*bfd_h_getx64) (const void *); - bfd_int64_t (*bfd_h_getx_signed_64) (const void *); - void (*bfd_h_putx64) (bfd_uint64_t, void *); - bfd_vma (*bfd_h_getx32) (const void *); - bfd_signed_vma (*bfd_h_getx_signed_32) (const void *); - void (*bfd_h_putx32) (bfd_vma, void *); - bfd_vma (*bfd_h_getx16) (const void *); - bfd_signed_vma (*bfd_h_getx_signed_16) (const void *); - void (*bfd_h_putx16) (bfd_vma, void *); - - /* Format dependent routines: these are vectors of entry points - within the target vector structure, one for each format to check. */ - - /* Check the format of a file being read. Return a <> or zero. */ - const struct bfd_target *(*_bfd_check_format[bfd_type_end]) (bfd *); - - /* Set the format of a file being written. */ - bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *); - - /* Write cached information into a file being written, at <>. */ - bfd_boolean (*_bfd_write_contents[bfd_type_end]) (bfd *); - - - /* Generic entry points. */ -#define BFD_JUMP_TABLE_GENERIC(NAME) \ - NAME##_close_and_cleanup, \ - NAME##_bfd_free_cached_info, \ - NAME##_new_section_hook, \ - NAME##_get_section_contents, \ - NAME##_get_section_contents_in_window - - /* Called when the BFD is being closed to do any necessary cleanup. */ - bfd_boolean (*_close_and_cleanup) (bfd *); - /* Ask the BFD to free all cached information. */ - bfd_boolean (*_bfd_free_cached_info) (bfd *); - /* Called when a new section is created. */ - bfd_boolean (*_new_section_hook) (bfd *, sec_ptr); - /* Read the contents of a section. */ - bfd_boolean (*_bfd_get_section_contents) - (bfd *, sec_ptr, void *, file_ptr, bfd_size_type); - bfd_boolean (*_bfd_get_section_contents_in_window) - (bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type); - - /* Entry points to copy private data. */ -#define BFD_JUMP_TABLE_COPY(NAME) \ - NAME##_bfd_copy_private_bfd_data, \ - NAME##_bfd_merge_private_bfd_data, \ - _bfd_generic_init_private_section_data, \ - NAME##_bfd_copy_private_section_data, \ - NAME##_bfd_copy_private_symbol_data, \ - NAME##_bfd_copy_private_header_data, \ - NAME##_bfd_set_private_flags, \ - NAME##_bfd_print_private_bfd_data - - /* Called to copy BFD general private data from one object file - to another. */ - bfd_boolean (*_bfd_copy_private_bfd_data) (bfd *, bfd *); - /* Called to merge BFD general private data from one object file - to a common output file when linking. */ - bfd_boolean (*_bfd_merge_private_bfd_data) (bfd *, bfd *); - /* Called to initialize BFD private section data from one object file - to another. */ -#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ - BFD_SEND (obfd, _bfd_init_private_section_data, (ibfd, isec, obfd, osec, link_info)) - bfd_boolean (*_bfd_init_private_section_data) - (bfd *, sec_ptr, bfd *, sec_ptr, struct bfd_link_info *); - /* Called to copy BFD private section data from one object file - to another. */ - bfd_boolean (*_bfd_copy_private_section_data) - (bfd *, sec_ptr, bfd *, sec_ptr); - /* Called to copy BFD private symbol data from one symbol - to another. */ - bfd_boolean (*_bfd_copy_private_symbol_data) - (bfd *, asymbol *, bfd *, asymbol *); - /* Called to copy BFD private header data from one object file - to another. */ - bfd_boolean (*_bfd_copy_private_header_data) - (bfd *, bfd *); - /* Called to set private backend flags. */ - bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword); - - /* Called to print private BFD data. */ - bfd_boolean (*_bfd_print_private_bfd_data) (bfd *, void *); - - /* Core file entry points. */ -#define BFD_JUMP_TABLE_CORE(NAME) \ - NAME##_core_file_failing_command, \ - NAME##_core_file_failing_signal, \ - NAME##_core_file_matches_executable_p - - char * (*_core_file_failing_command) (bfd *); - int (*_core_file_failing_signal) (bfd *); - bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *); - - /* Archive entry points. */ -#define BFD_JUMP_TABLE_ARCHIVE(NAME) \ - NAME##_slurp_armap, \ - NAME##_slurp_extended_name_table, \ - NAME##_construct_extended_name_table, \ - NAME##_truncate_arname, \ - NAME##_write_armap, \ - NAME##_read_ar_hdr, \ - NAME##_openr_next_archived_file, \ - NAME##_get_elt_at_index, \ - NAME##_generic_stat_arch_elt, \ - NAME##_update_armap_timestamp - - bfd_boolean (*_bfd_slurp_armap) (bfd *); - bfd_boolean (*_bfd_slurp_extended_name_table) (bfd *); - bfd_boolean (*_bfd_construct_extended_name_table) - (bfd *, char **, bfd_size_type *, const char **); - void (*_bfd_truncate_arname) (bfd *, const char *, char *); - bfd_boolean (*write_armap) - (bfd *, unsigned int, struct orl *, unsigned int, int); - void * (*_bfd_read_ar_hdr_fn) (bfd *); - bfd * (*openr_next_archived_file) (bfd *, bfd *); -#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i)) - bfd * (*_bfd_get_elt_at_index) (bfd *, symindex); - int (*_bfd_stat_arch_elt) (bfd *, struct stat *); - bfd_boolean (*_bfd_update_armap_timestamp) (bfd *); - - /* Entry points used for symbols. */ -#define BFD_JUMP_TABLE_SYMBOLS(NAME) \ - NAME##_get_symtab_upper_bound, \ - NAME##_canonicalize_symtab, \ - NAME##_make_empty_symbol, \ - NAME##_print_symbol, \ - NAME##_get_symbol_info, \ - NAME##_bfd_is_local_label_name, \ - NAME##_bfd_is_target_special_symbol, \ - NAME##_get_lineno, \ - NAME##_find_nearest_line, \ - _bfd_generic_find_line, \ - NAME##_find_inliner_info, \ - NAME##_bfd_make_debug_symbol, \ - NAME##_read_minisymbols, \ - NAME##_minisymbol_to_symbol - - long (*_bfd_get_symtab_upper_bound) (bfd *); - long (*_bfd_canonicalize_symtab) - (bfd *, struct bfd_symbol **); - struct bfd_symbol * - (*_bfd_make_empty_symbol) (bfd *); - void (*_bfd_print_symbol) - (bfd *, void *, struct bfd_symbol *, bfd_print_symbol_type); -#define bfd_print_symbol(b,p,s,e) BFD_SEND (b, _bfd_print_symbol, (b,p,s,e)) - void (*_bfd_get_symbol_info) - (bfd *, struct bfd_symbol *, symbol_info *); -#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) - bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); - bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); - alent * (*_get_lineno) (bfd *, struct bfd_symbol *); - bfd_boolean (*_bfd_find_nearest_line) - (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, - const char **, const char **, unsigned int *); - bfd_boolean (*_bfd_find_line) - (bfd *, struct bfd_symbol **, struct bfd_symbol *, - const char **, unsigned int *); - bfd_boolean (*_bfd_find_inliner_info) - (bfd *, const char **, const char **, unsigned int *); - /* Back-door to allow format-aware applications to create debug symbols - while using BFD for everything else. Currently used by the assembler - when creating COFF files. */ - asymbol * (*_bfd_make_debug_symbol) - (bfd *, void *, unsigned long size); -#define bfd_read_minisymbols(b, d, m, s) \ - BFD_SEND (b, _read_minisymbols, (b, d, m, s)) - long (*_read_minisymbols) - (bfd *, bfd_boolean, void **, unsigned int *); -#define bfd_minisymbol_to_symbol(b, d, m, f) \ - BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) - asymbol * (*_minisymbol_to_symbol) - (bfd *, bfd_boolean, const void *, asymbol *); - - /* Routines for relocs. */ -#define BFD_JUMP_TABLE_RELOCS(NAME) \ - NAME##_get_reloc_upper_bound, \ - NAME##_canonicalize_reloc, \ - NAME##_bfd_reloc_type_lookup, \ - NAME##_bfd_reloc_name_lookup - - long (*_get_reloc_upper_bound) (bfd *, sec_ptr); - long (*_bfd_canonicalize_reloc) - (bfd *, sec_ptr, arelent **, struct bfd_symbol **); - /* See documentation on reloc types. */ - reloc_howto_type * - (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type); - reloc_howto_type * - (*reloc_name_lookup) (bfd *, const char *); - - - /* Routines used when writing an object file. */ -#define BFD_JUMP_TABLE_WRITE(NAME) \ - NAME##_set_arch_mach, \ - NAME##_set_section_contents - - bfd_boolean (*_bfd_set_arch_mach) - (bfd *, enum bfd_architecture, unsigned long); - bfd_boolean (*_bfd_set_section_contents) - (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type); - - /* Routines used by the linker. */ -#define BFD_JUMP_TABLE_LINK(NAME) \ - NAME##_sizeof_headers, \ - NAME##_bfd_get_relocated_section_contents, \ - NAME##_bfd_relax_section, \ - NAME##_bfd_link_hash_table_create, \ - NAME##_bfd_link_hash_table_free, \ - NAME##_bfd_link_add_symbols, \ - NAME##_bfd_link_just_syms, \ - NAME##_bfd_final_link, \ - NAME##_bfd_link_split_section, \ - NAME##_bfd_gc_sections, \ - NAME##_bfd_merge_sections, \ - NAME##_bfd_is_group_section, \ - NAME##_bfd_discard_group, \ - NAME##_section_already_linked \ - - int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *); - bfd_byte * (*_bfd_get_relocated_section_contents) - (bfd *, struct bfd_link_info *, struct bfd_link_order *, - bfd_byte *, bfd_boolean, struct bfd_symbol **); - - bfd_boolean (*_bfd_relax_section) - (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *); - - /* Create a hash table for the linker. Different backends store - different information in this table. */ - struct bfd_link_hash_table * - (*_bfd_link_hash_table_create) (bfd *); - - /* Release the memory associated with the linker hash table. */ - void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *); - - /* Add symbols from this object file into the hash table. */ - bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); - - /* Indicate that we are only retrieving symbol values from this section. */ - void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); - - /* Do a link based on the link_order structures attached to each - section of the BFD. */ - bfd_boolean (*_bfd_final_link) (bfd *, struct bfd_link_info *); - - /* Should this section be split up into smaller pieces during linking. */ - bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *); - - /* Remove sections that are not referenced from the output. */ - bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); - - /* Attempt to merge SEC_MERGE sections. */ - bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *); - - /* Is this section a member of a group? */ - bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *); - - /* Discard members of a group. */ - bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *); - - /* Check if SEC has been already linked during a reloceatable or - final link. */ - void (*_section_already_linked) (bfd *, struct bfd_section *, - struct bfd_link_info *); - - /* Routines to handle dynamic symbols and relocs. */ -#define BFD_JUMP_TABLE_DYNAMIC(NAME) \ - NAME##_get_dynamic_symtab_upper_bound, \ - NAME##_canonicalize_dynamic_symtab, \ - NAME##_get_synthetic_symtab, \ - NAME##_get_dynamic_reloc_upper_bound, \ - NAME##_canonicalize_dynamic_reloc - - /* Get the amount of memory required to hold the dynamic symbols. */ - long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *); - /* Read in the dynamic symbols. */ - long (*_bfd_canonicalize_dynamic_symtab) - (bfd *, struct bfd_symbol **); - /* Create synthetized symbols. */ - long (*_bfd_get_synthetic_symtab) - (bfd *, long, struct bfd_symbol **, long, struct bfd_symbol **, - struct bfd_symbol **); - /* Get the amount of memory required to hold the dynamic relocs. */ - long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *); - /* Read in the dynamic relocs. */ - long (*_bfd_canonicalize_dynamic_reloc) - (bfd *, arelent **, struct bfd_symbol **); - - /* Opposite endian version of this target. */ - const struct bfd_target * alternative_target; - - /* Data for use by back-end routines, which isn't - generic enough to belong in this structure. */ - const void *backend_data; - -} bfd_target; - -bfd_boolean bfd_set_default_target (const char *name); - -const bfd_target *bfd_find_target (const char *target_name, bfd *abfd); - -const char ** bfd_target_list (void); - -const bfd_target *bfd_search_for_target - (int (*search_func) (const bfd_target *, void *), - void *); - -/* Extracted from format.c. */ -bfd_boolean bfd_check_format (bfd *abfd, bfd_format format); - -bfd_boolean bfd_check_format_matches - (bfd *abfd, bfd_format format, char ***matching); - -bfd_boolean bfd_set_format (bfd *abfd, bfd_format format); - -const char *bfd_format_string (bfd_format format); - -/* Extracted from linker.c. */ -bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec); - -#define bfd_link_split_section(abfd, sec) \ - BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) - -void bfd_section_already_linked (bfd *abfd, asection *sec, - struct bfd_link_info *info); - -#define bfd_section_already_linked(abfd, sec, info) \ - BFD_SEND (abfd, _section_already_linked, (abfd, sec, info)) - -/* Extracted from simple.c. */ -bfd_byte *bfd_simple_get_relocated_section_contents - (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/gnu/usr.bin/binutils/libbfd/config.h.fbsd b/gnu/usr.bin/binutils/libbfd/config.h.fbsd deleted file mode 100644 index e1c1cf660f4..00000000000 --- a/gnu/usr.bin/binutils/libbfd/config.h.fbsd +++ /dev/null @@ -1,297 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* Define to 1 if you have the declaration of `basename', and to 0 if you - don't. */ -#define HAVE_DECL_BASENAME 0 - -/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ -#define HAVE_DECL_FFS 1 - -/* Define to 1 if you have the declaration of `free', and to 0 if you don't. - */ -#define HAVE_DECL_FREE 1 - -/* Define to 1 if you have the declaration of `fseeko', and to 0 if you don't. - */ -#define HAVE_DECL_FSEEKO 1 - -/* Define to 1 if you have the declaration of `fseeko64', and to 0 if you - don't. */ -#define HAVE_DECL_FSEEKO64 0 - -/* Define to 1 if you have the declaration of `ftello', and to 0 if you don't. - */ -#define HAVE_DECL_FTELLO 1 - -/* Define to 1 if you have the declaration of `ftello64', and to 0 if you - don't. */ -#define HAVE_DECL_FTELLO64 0 - -/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. - */ -#define HAVE_DECL_GETENV 1 - -/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. - */ -#define HAVE_DECL_MALLOC 1 - -/* Define to 1 if you have the declaration of `realloc', and to 0 if you - don't. */ -#define HAVE_DECL_REALLOC 1 - -/* Define to 1 if you have the declaration of `snprintf', and to 0 if you - don't. */ -#define HAVE_DECL_SNPRINTF 1 - -/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't. - */ -#define HAVE_DECL_STPCPY 1 - -/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't. - */ -#define HAVE_DECL_STRSTR 1 - -/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VSNPRINTF 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `fcntl' function. */ -#define HAVE_FCNTL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `fdopen' function. */ -#define HAVE_FDOPEN 1 - -/* Define to 1 if you have the `fopen64' function. */ -/* #undef HAVE_FOPEN64 */ - -/* Define to 1 if you have the `fseeko' function. */ -#define HAVE_FSEEKO 1 - -/* Define to 1 if you have the `fseeko64' function. */ -/* #undef HAVE_FSEEKO64 */ - -/* Define to 1 if you have the `ftello' function. */ -#define HAVE_FTELLO 1 - -/* Define to 1 if you have the `ftello64' function. */ -/* #undef HAVE_FTELLO64 */ - -/* Define to 1 if you have the `getgid' function. */ -#define HAVE_GETGID 1 - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the `getuid' function. */ -#define HAVE_GETUID 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define if has lwpstatus_t. */ -/* #undef HAVE_LWPSTATUS_T */ - -/* Define if has lwpstatus_t.pr_context. */ -/* #undef HAVE_LWPSTATUS_T_PR_CONTEXT */ - -/* Define if has lwpstatus_t.pr_reg. */ -/* #undef HAVE_LWPSTATUS_T_PR_REG */ - -/* Define if has lwpxstatus_t. */ -/* #undef HAVE_LWPXSTATUS_T */ - -/* Define to 1 if you have the `madvise' function. */ -#define HAVE_MADVISE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define to 1 if you have the `mprotect' function. */ -#define HAVE_MPROTECT 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define if has prpsinfo32_t. */ -/* #undef HAVE_PRPSINFO32_T */ - -/* Define if has prpsinfo_t. */ -#define HAVE_PRPSINFO_T 1 - -/* Define if has prstatus32_t. */ -/* #undef HAVE_PRSTATUS32_T */ - -/* Define if has prstatus32_t.pr_who. */ -/* #undef HAVE_PRSTATUS32_T_PR_WHO */ - -/* Define if has prstatus_t. */ -#define HAVE_PRSTATUS_T 1 - -/* Define if has prstatus_t.pr_who. */ -/* #undef HAVE_PRSTATUS_T_PR_WHO */ - -/* Define if has psinfo32_t. */ -/* #undef HAVE_PSINFO32_T */ - -/* Define if has psinfo_t. */ -/* #undef HAVE_PSINFO_T */ - -/* Define if has pstatus32_t. */ -/* #undef HAVE_PSTATUS32_T */ - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has pxstatus_t. */ -/* #undef HAVE_PXSTATUS_T */ - -/* Define to 1 if you have the `setitimer' function. */ -#define HAVE_SETITIMER 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strtoull' function. */ -#define HAVE_STRTOULL 1 - -/* Define if struct core_dumpx has member c_impl */ -/* #undef HAVE_ST_C_IMPL */ - -/* Define to 1 if you have the `sysconf' function. */ -#define HAVE_SYSCONF 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if has win32_pstatus_t. */ -/* #undef HAVE_WIN32_PSTATUS_T */ - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "bfd" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* The size of a `char', as computed by sizeof. */ -/* #undef SIZEOF_CHAR */ - -/* The size of a `int', as computed by sizeof. */ -/* #undef SIZEOF_INT */ - -/* The size of a `long', as computed by sizeof. */ -/* #define SIZEOF_LONG 4 */ - -/* The size of a `long long', as computed by sizeof. */ -/* #define SIZEOF_LONG_LONG 8 */ - -/* The size of a `off_t', as computed by sizeof. */ -/* #define SIZEOF_OFF_T 8 */ - -/* The size of a `short', as computed by sizeof. */ -/* #undef SIZEOF_SHORT */ - -/* The size of a `void *', as computed by sizeof. */ -/* #undef SIZEOF_VOID_P */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -#define STRING_WITH_STRINGS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Name of host specific header file to include in trad-core.c. */ -#define TRAD_HEADER !!TRAD_HEADER!! - -/* Use b modifier when opening binary files? */ -/* #undef USE_BINARY_FOPEN */ - -/* Use mmap if it's available? */ -/* #undef USE_MMAP */ - -/* Define if we should default to creating read-only plt entries */ -/* #undef USE_SECUREPLT */ - -/* Version number of package */ -/* #define VERSION "2.17.50" */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif diff --git a/gnu/usr.bin/binutils/libbfd/elf-fbsd-brand.c b/gnu/usr.bin/binutils/libbfd/elf-fbsd-brand.c deleted file mode 100644 index b8ba60e5f7d..00000000000 --- a/gnu/usr.bin/binutils/libbfd/elf-fbsd-brand.c +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * Copyright (c) 2002, 2003 David E. O'Brien - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#define ELF_OSABI ELFOSABI_FREEBSD -#define elf_backend_post_process_headers _bfd_elf_set_osabi diff --git a/gnu/usr.bin/binutils/libbinutils/Makefile b/gnu/usr.bin/binutils/libbinutils/Makefile deleted file mode 100644 index 05fbd7266c6..00000000000 --- a/gnu/usr.bin/binutils/libbinutils/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libbinutils/Makefile 228601 2011-12-16 22:19:13Z dim $ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/binutils - -LIB= binutils -SRCS+= arlex.l \ - arparse.y \ - arsup.c \ - binemul.c \ - bucomm.c \ - debug.c \ - dwarf.c \ - emul_vanilla.c \ - filemode.c \ - ieee.c \ - rdcoff.c \ - rddbg.c \ - rename.c \ - stabs.c \ - unwind-ia64.c \ - version.c \ - wrstabs.c -CFLAGS+= -DTARGET=\"${TARGET_TUPLE}\" -CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -DYY_NO_INPUT -CFLAGS+= -I${SRCDIR}/binutils -CFLAGS+= -I${SRCDIR}/bfd -INTERNALLIB= - -.include diff --git a/gnu/usr.bin/binutils/libbinutils/Makefile.depend b/gnu/usr.bin/binutils/libbinutils/Makefile.depend deleted file mode 100644 index 22816670db5..00000000000 --- a/gnu/usr.bin/binutils/libbinutils/Makefile.depend +++ /dev/null @@ -1,15 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libbinutils/Makefile.depend 295989 2016-02-24 17:20:11Z bdrewery $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/usr.bin/binutils/libbfd \ - include \ - include/xlocale \ - usr.bin/yacc.host \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/libbinutils/config.h b/gnu/usr.bin/binutils/libbinutils/config.h deleted file mode 100644 index 5c457f1eeaf..00000000000 --- a/gnu/usr.bin/binutils/libbinutils/config.h +++ /dev/null @@ -1,215 +0,0 @@ -/* $FreeBSD$ */ - -/* FreeBSD isn't any form of AIX. */ -#define bin_dummy_emulation bin_vanilla_emulation - -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.in by autoheader. */ - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* Suffix used for executables, if any. */ -#define EXECUTABLE_SUFFIX "" - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -/* #undef HAVE_ALLOCA_H */ - -/* Define to 1 if you have the declaration of `environ', and to 0 if you - don't. */ -#define HAVE_DECL_ENVIRON 0 - -/* Define to 1 if you have the declaration of `fprintf', and to 0 if you - don't. */ -#define HAVE_DECL_FPRINTF 1 - -/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you - don't. */ -#define HAVE_DECL_GETC_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. - */ -#define HAVE_DECL_GETENV 1 - -/* Is the prototype for getopt in in the expected format? */ -#define HAVE_DECL_GETOPT 1 - -/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. - */ -#define HAVE_DECL_SBRK 1 - -/* Define to 1 if you have the declaration of `snprintf', and to 0 if you - don't. */ -#define HAVE_DECL_SNPRINTF 1 - -/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't. - */ -#define HAVE_DECL_STPCPY 1 - -/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't. - */ -#define HAVE_DECL_STRSTR 1 - -/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VSNPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Does the platform use an executable suffix? */ -/* #undef HAVE_EXECUTABLE_SUFFIX */ - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Is fopen64 available? */ -/* #undef HAVE_FOPEN64 */ - -/* Define to 1 if you have the `getc_unlocked' function. */ -#define HAVE_GETC_UNLOCKED 1 - -/* Does define struct utimbuf? */ -#define HAVE_GOOD_UTIME_H 1 - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkdtemp' function. */ -#define HAVE_MKDTEMP 1 - -/* Define to 1 if you have the `mkstemp' function. */ -#define HAVE_MKSTEMP 1 - -/* Define to 1 if you have the `sbrk' function. */ -/* #undef HAVE_SBRK */ - -/* Define to 1 if you have the `setmode' function. */ -#define HAVE_SETMODE 1 - -/* Is stat64 available? */ -/* #undef HAVE_STAT64 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strcoll' function. */ -#define HAVE_STRCOLL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Is the type time_t defined in ? */ -#define HAVE_TIME_T_IN_TIME_H 1 - -/* Is the type time_t defined in ? */ -#define HAVE_TIME_T_IN_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `utimes' function. */ -#define HAVE_UTIMES 1 - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "binutils" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Configured target name. */ -/* #define TARGET "i386-unknown-freebsd9.0" */ - -/* Define to 1 if user symbol names have a leading underscore, 0 if not. */ -#define TARGET_PREPENDS_UNDERSCORE 0 - -/* Use b modifier when opening binary files? */ -/* #undef USE_BINARY_FOPEN */ - -/* Version number of package */ -/* #define VERSION "2.17.50" */ - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#define YYTEXT_POINTER 1 - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Enable LFS */ -/* #undef _LARGEFILE64_SOURCE */ diff --git a/gnu/usr.bin/binutils/libiberty/Makefile b/gnu/usr.bin/binutils/libiberty/Makefile deleted file mode 100644 index e5fffb04284..00000000000 --- a/gnu/usr.bin/binutils/libiberty/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libiberty/Makefile 218822 2011-02-18 20:54:12Z dim $ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/libiberty - -LIB= iberty -SRCS= argv.c \ - concat.c \ - choose-temp.c \ - cp-demangle.c \ - cp-demint.c \ - cplus-dem.c \ - dyn-string.c \ - getpwd.c \ - getruntime.c \ - filename_cmp.c \ - floatformat.c \ - hashtab.c \ - hex.c \ - lbasename.c \ - lrealpath.c \ - make-relative-prefix.c \ - make-temp-file.c \ - objalloc.c \ - obstack.c \ - safe-ctype.c \ - unlink-if-ordinary.c \ - xatexit.c \ - xexit.c \ - xmalloc.c \ - xstrdup.c \ - xstrerror.c - -# The following files are needed by gdb(1) -SRCS+= splay-tree.c - -WARNS?= 2 -CFLAGS+= -DHAVE_CONFIG_H -INTERNALLIB= - -.include diff --git a/gnu/usr.bin/binutils/libiberty/Makefile.depend b/gnu/usr.bin/binutils/libiberty/Makefile.depend deleted file mode 100644 index fc3122d4ab1..00000000000 --- a/gnu/usr.bin/binutils/libiberty/Makefile.depend +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libiberty/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - lib/msun \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/libiberty/config.h b/gnu/usr.bin/binutils/libiberty/config.h deleted file mode 100644 index 4361330c7f1..00000000000 --- a/gnu/usr.bin/binutils/libiberty/config.h +++ /dev/null @@ -1,449 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.ac by autoheader. */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ALLOCA_H */ - -/* Define to 1 if you have the `asprintf' function. */ -#define HAVE_ASPRINTF 1 - -/* Define to 1 if you have the `atexit' function. */ -#define HAVE_ATEXIT 1 - -/* Define to 1 if you have the `basename' function. */ -#define HAVE_BASENAME 1 - -/* Define to 1 if you have the `bcmp' function. */ -#define HAVE_BCMP 1 - -/* Define to 1 if you have the `bcopy' function. */ -#define HAVE_BCOPY 1 - -/* Define to 1 if you have the `bsearch' function. */ -#define HAVE_BSEARCH 1 - -/* Define to 1 if you have the `bzero' function. */ -#define HAVE_BZERO 1 - -/* Define to 1 if you have the `calloc' function. */ -#define HAVE_CALLOC 1 - -/* Define to 1 if you have the `canonicalize_file_name' function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define to 1 if you have the `clock' function. */ -#define HAVE_CLOCK 1 - -/* Define to 1 if you have the declaration of `asprintf', and to 0 if you - don't. */ -#define HAVE_DECL_ASPRINTF 1 - -/* Define to 1 if you have the declaration of `basename', and to 0 if you - don't. */ -#define HAVE_DECL_BASENAME 0 - -/* Define to 1 if you have the declaration of `calloc', and to 0 if you don't. - */ -#define HAVE_DECL_CALLOC 1 - -/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ -#define HAVE_DECL_FFS 1 - -/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. - */ -#define HAVE_DECL_GETENV 1 - -/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. - */ -#define HAVE_DECL_GETOPT 1 - -/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. - */ -#define HAVE_DECL_MALLOC 1 - -/* Define to 1 if you have the declaration of `realloc', and to 0 if you - don't. */ -#define HAVE_DECL_REALLOC 1 - -/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. - */ -#define HAVE_DECL_SBRK 1 - -/* Define to 1 if you have the declaration of `snprintf', and to 0 if you - don't. */ -#define HAVE_DECL_SNPRINTF 1 - -/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you - don't. */ -#define HAVE_DECL_STRVERSCMP 0 - -/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VASPRINTF 1 - -/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VSNPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `ffs' function. */ -#define HAVE_FFS 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - -/* Define to 1 if you have the `getcwd' function. */ -#define HAVE_GETCWD 1 - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the `getrusage' function. */ -#define HAVE_GETRUSAGE 1 - -/* Define to 1 if you have the `getsysinfo' function. */ -/* #undef HAVE_GETSYSINFO */ - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `index' function. */ -#define HAVE_INDEX 1 - -/* Define to 1 if you have the `insque' function. */ -#define HAVE_INSQUE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MACHINE_HAL_SYSINFO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define to 1 if you have the `memchr' function. */ -#define HAVE_MEMCHR 1 - -/* Define to 1 if you have the `memcmp' function. */ -#define HAVE_MEMCMP 1 - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mempcpy' function. */ -/* #undef HAVE_MEMPCPY */ - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mkstemps' function. */ -#define HAVE_MKSTEMPS 1 - -/* Define to 1 if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define to 1 if you have the `on_exit' function. */ -/* #undef HAVE_ON_EXIT */ - -/* Define to 1 if you have the `psignal' function. */ -#define HAVE_PSIGNAL 1 - -/* Define to 1 if you have the `pstat_getdynamic' function. */ -/* #undef HAVE_PSTAT_GETDYNAMIC */ - -/* Define to 1 if you have the `pstat_getstatic' function. */ -/* #undef HAVE_PSTAT_GETSTATIC */ - -/* Define to 1 if you have the `putenv' function. */ -#define HAVE_PUTENV 1 - -/* Define to 1 if you have the `random' function. */ -#define HAVE_RANDOM 1 - -/* Define to 1 if you have the `realpath' function. */ -#define HAVE_REALPATH 1 - -/* Define to 1 if you have the `rename' function. */ -#define HAVE_RENAME 1 - -/* Define to 1 if you have the `rindex' function. */ -#define HAVE_RINDEX 1 - -/* Define to 1 if you have the `sbrk' function. */ -/* #undef HAVE_SBRK */ - -/* Define to 1 if you have the `setenv' function. */ -#define HAVE_SETENV 1 - -/* Define to 1 if you have the `sigsetmask' function. */ -#define HAVE_SIGSETMASK 1 - -/* Define to 1 if you have the `snprintf' function. */ -#define HAVE_SNPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STDIO_EXT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `stpcpy' function. */ -#define HAVE_STPCPY 1 - -/* Define to 1 if you have the `stpncpy' function. */ -#define HAVE_STPNCPY 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strncasecmp' function. */ -#define HAVE_STRNCASECMP 1 - -/* Define to 1 if you have the `strndup' function. */ -#define HAVE_STRNDUP 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strsignal' function. */ -#define HAVE_STRSIGNAL 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the `strtod' function. */ -#define HAVE_STRTOD 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - -/* Define to 1 if you have the `strverscmp' function. */ -/* #undef HAVE_STRVERSCMP */ - -/* Define to 1 if you have the `sysconf' function. */ -#define HAVE_SYSCONF 1 - -/* Define to 1 if you have the `sysctl' function. */ -#define HAVE_SYSCTL 1 - -/* Define to 1 if you have the `sysmp' function. */ -/* #undef HAVE_SYSMP */ - -/* Define if you have the sys_errlist variable. */ -#define HAVE_SYS_ERRLIST 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MMAN_H 1 - -/* Define if you have the sys_nerr variable. */ -#define HAVE_SYS_NERR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_PSTAT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define if you have the sys_siglist variable. */ -#define HAVE_SYS_SIGLIST 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCTL_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSINFO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSMP_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSTEMCFG_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TABLE_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the `table' function. */ -/* #undef HAVE_TABLE */ - -/* Define to 1 if you have the `times' function. */ -#define HAVE_TIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the `tmpnam' function. */ -#define HAVE_TMPNAM 1 - -/* Define if you have the \`uintptr_t' type. */ -#define HAVE_UINTPTR_T 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `vasprintf' function. */ -#define HAVE_VASPRINTF 1 - -/* Define to 1 if you have the `vfork' function. */ -#define HAVE_VFORK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VFORK_H */ - -/* Define to 1 if you have the `vfprintf' function. */ -#define HAVE_VFPRINTF 1 - -/* Define to 1 if you have the `vprintf' function. */ -#define HAVE_VPRINTF 1 - -/* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the `vsprintf' function. */ -#define HAVE_VSPRINTF 1 - -/* Define to 1 if you have the `wait3' function. */ -#define HAVE_WAIT3 1 - -/* Define to 1 if you have the `wait4' function. */ -#define HAVE_WAIT4 1 - -/* Define to 1 if you have the `waitpid' function. */ -#define HAVE_WAITPID 1 - -/* Define to 1 if `fork' works. */ -#define HAVE_WORKING_FORK 1 - -/* Define to 1 if `vfork' works. */ -#define HAVE_WORKING_VFORK 1 - -/* Define to 1 if you have the `_doprnt' function. */ -/* #undef HAVE__DOPRNT */ - -/* Define if you have the _system_configuration variable. */ -/* #undef HAVE__SYSTEM_CONFIGURATION */ - -/* Define to 1 if you have the `__fsetlocking' function. */ -/* #undef HAVE___FSETLOCKING */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if errno must be declared even when is included. */ -/* #undef NEED_DECLARATION_ERRNO */ - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -/* #define PACKAGE_VERSION "" */ - -/* The size of a `int', as computed by sizeof. */ -/* #define SIZEOF_INT 4 */ - -/* Define if you know the direction of stack growth for your system; otherwise - it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows - toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#define STACK_DIRECTION -1 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to an unsigned 64-bit type available in the compiler. */ -#define UNSIGNED_64BIT_TYPE uint64_t - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#if defined(__powerpc__) || defined(__sparc64__) -# define WORDS_BIGENDIAN 1 -#endif - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Define to `unsigned long' if does not define. */ -/* #undef uintptr_t */ - -/* Define as `fork' if `vfork' does not work. */ -/* #undef vfork */ diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile b/gnu/usr.bin/binutils/libopcodes/Makefile deleted file mode 100644 index 6691ed704ea..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libopcodes/Makefile 218822 2011-02-18 20:54:12Z dim $ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/opcodes - -LIB= opcodes -SRCS+= dis-buf.c dis-init.c disassemble.c i386-opc.c -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${SRCDIR}/opcodes -I${SRCDIR}/bfd -INTERNALLIB= - -# If set, BINUTILSDISTDIR is the path to a directory containing the full GNU -# binutils release. FreeBSD only distributes the bits that are required to -# build native architectures. BINUTILSDISTDIR is needed to build cross tools. -.if defined(BINUTILSDISTDIR) && exists(${BINUTILSDISTDIR}) -.PATH: ${BINUTILSDISTDIR}/bfd ${BINUTILSDISTDIR}/opcodes -CFLAGS+= -I${BINUTILSDISTDIR}/opcodes -I${BINUTILSDISTDIR}/bfd -CFLAGS+= -I${BINUTILSDISTDIR}/include -.endif - -.include diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 b/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 deleted file mode 100644 index 0d320b34814..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 84906 2001-10-14 01:31:37Z obrien $ - -SRCS+= i386-dis.c -CFLAGS+= -DARCH_i386 diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.arm b/gnu/usr.bin/binutils/libopcodes/Makefile.arm deleted file mode 100644 index 3410d678c02..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/Makefile.arm +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/binutils/libopcodes/Makefile.arm 160580 2006-07-22 14:59:50Z obrien $ - -SRCS+= arm-dis.c -CFLAGS+= -DARCH_arm diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.depend b/gnu/usr.bin/binutils/libopcodes/Makefile.depend deleted file mode 100644 index 18be76b0cb6..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.i386 b/gnu/usr.bin/binutils/libopcodes/Makefile.i386 deleted file mode 100644 index 5b1ce3a9689..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/Makefile.i386 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -SRCS+= i386-dis.c -CFLAGS+= -DARCH_i386 diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc b/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc deleted file mode 100644 index cc010ec4a30..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -SRCS+= ppc-dis.c ppc-opc.c -CFLAGS+= -DARCH_powerpc -DARCH_rs6000 diff --git a/gnu/usr.bin/binutils/libopcodes/config.h b/gnu/usr.bin/binutils/libopcodes/config.h deleted file mode 100644 index dcb0fadfe62..00000000000 --- a/gnu/usr.bin/binutils/libopcodes/config.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $FreeBSD: stable/11/gnu/usr.bin/binutils/libopcodes/config.h 218822 2011-02-18 20:54:12Z dim $ */ - -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* Define to 1 if you have the declaration of `basename', and to 0 if you - don't. */ -#define HAVE_DECL_BASENAME 0 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "opcodes" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -/* #define VERSION "2.17.50" */ diff --git a/gnu/usr.bin/binutils/objcopy/Makefile b/gnu/usr.bin/binutils/objcopy/Makefile deleted file mode 100644 index 4b75c0085c1..00000000000 --- a/gnu/usr.bin/binutils/objcopy/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc - -PROG= objcopy -SRCS= objcopy.c not-strip.c -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbinutils -CFLAGS+= -I${SRCDIR}/binutils -I${SRCDIR}/bfd -DPADD= ${GNURELTOP}/libbinutils/libbinutils${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libbfd/libbfd${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libiberty/libiberty${PIE_SUFFIX}.a -LDADD= ${DPADD} - -.include diff --git a/gnu/usr.bin/binutils/objcopy/Makefile.depend b/gnu/usr.bin/binutils/objcopy/Makefile.depend deleted file mode 100644 index c27a80a4800..00000000000 --- a/gnu/usr.bin/binutils/objcopy/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libbinutils \ - gnu/usr.bin/binutils/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/objcopy/objcopy.1 b/gnu/usr.bin/binutils/objcopy/objcopy.1 deleted file mode 100644 index 66f051d3b86..00000000000 --- a/gnu/usr.bin/binutils/objcopy/objcopy.1 +++ /dev/null @@ -1,858 +0,0 @@ -.\" $FreeBSD$ -.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "OBJCOPY 1" -.TH OBJCOPY 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -objcopy \- copy and translate object files -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -objcopy [\fB\-F\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] - [\fB\-I\fR \fIbfdname\fR|\fB\-\-input\-target=\fR\fIbfdname\fR] - [\fB\-O\fR \fIbfdname\fR|\fB\-\-output\-target=\fR\fIbfdname\fR] - [\fB\-B\fR \fIbfdarch\fR|\fB\-\-binary\-architecture=\fR\fIbfdarch\fR] - [\fB\-S\fR|\fB\-\-strip\-all\fR] - [\fB\-g\fR|\fB\-\-strip\-debug\fR] - [\fB\-K\fR \fIsymbolname\fR|\fB\-\-keep\-symbol=\fR\fIsymbolname\fR] - [\fB\-N\fR \fIsymbolname\fR|\fB\-\-strip\-symbol=\fR\fIsymbolname\fR] - [\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR] - [\fB\-G\fR \fIsymbolname\fR|\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR] - [\fB\-\-localize\-hidden\fR] - [\fB\-L\fR \fIsymbolname\fR|\fB\-\-localize\-symbol=\fR\fIsymbolname\fR] - [\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR] - [\fB\-W\fR \fIsymbolname\fR|\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR] - [\fB\-w\fR|\fB\-\-wildcard\fR] - [\fB\-x\fR|\fB\-\-discard\-all\fR] - [\fB\-X\fR|\fB\-\-discard\-locals\fR] - [\fB\-b\fR \fIbyte\fR|\fB\-\-byte=\fR\fIbyte\fR] - [\fB\-i\fR \fIinterleave\fR|\fB\-\-interleave=\fR\fIinterleave\fR] - [\fB\-j\fR \fIsectionname\fR|\fB\-\-only\-section=\fR\fIsectionname\fR] - [\fB\-R\fR \fIsectionname\fR|\fB\-\-remove\-section=\fR\fIsectionname\fR] - [\fB\-p\fR|\fB\-\-preserve\-dates\fR] - [\fB\-\-debugging\fR] - [\fB\-\-gap\-fill=\fR\fIval\fR] - [\fB\-\-pad\-to=\fR\fIaddress\fR] - [\fB\-\-set\-start=\fR\fIval\fR] - [\fB\-\-adjust\-start=\fR\fIincr\fR] - [\fB\-\-change\-addresses=\fR\fIincr\fR] - [\fB\-\-change\-section\-address\fR \fIsection\fR{=,+,\-}\fIval\fR] - [\fB\-\-change\-section\-lma\fR \fIsection\fR{=,+,\-}\fIval\fR] - [\fB\-\-change\-section\-vma\fR \fIsection\fR{=,+,\-}\fIval\fR] - [\fB\-\-change\-warnings\fR] [\fB\-\-no\-change\-warnings\fR] - [\fB\-\-set\-section\-flags\fR \fIsection\fR=\fIflags\fR] - [\fB\-\-add\-section\fR \fIsectionname\fR=\fIfilename\fR] - [\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR[,\fIflags\fR]] - [\fB\-\-change\-leading\-char\fR] [\fB\-\-remove\-leading\-char\fR] - [\fB\-\-reverse\-bytes=\fR\fInum\fR] - [\fB\-\-srec\-len=\fR\fIival\fR] [\fB\-\-srec\-forceS3\fR] - [\fB\-\-redefine\-sym\fR \fIold\fR=\fInew\fR] - [\fB\-\-redefine\-syms=\fR\fIfilename\fR] - [\fB\-\-weaken\fR] - [\fB\-\-keep\-symbols=\fR\fIfilename\fR] - [\fB\-\-strip\-symbols=\fR\fIfilename\fR] - [\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR] - [\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR] - [\fB\-\-localize\-symbols=\fR\fIfilename\fR] - [\fB\-\-globalize\-symbols=\fR\fIfilename\fR] - [\fB\-\-weaken\-symbols=\fR\fIfilename\fR] - [\fB\-\-alt\-machine\-code=\fR\fIindex\fR] - [\fB\-\-prefix\-symbols=\fR\fIstring\fR] - [\fB\-\-prefix\-sections=\fR\fIstring\fR] - [\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR] - [\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR] - [\fB\-\-keep\-file\-symbols\fR] - [\fB\-\-only\-keep\-debug\fR] - [\fB\-\-extract\-symbol\fR] - [\fB\-\-writable\-text\fR] - [\fB\-\-readonly\-text\fR] - [\fB\-\-pure\fR] - [\fB\-\-impure\fR] - [\fB\-v\fR|\fB\-\-verbose\fR] - [\fB\-V\fR|\fB\-\-version\fR] - [\fB\-\-help\fR] [\fB\-\-info\fR] - \fIinfile\fR [\fIoutfile\fR] -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -The \s-1GNU\s0 \fBobjcopy\fR utility copies the contents of an object -file to another. \fBobjcopy\fR uses the \s-1GNU\s0 \s-1BFD\s0 Library to -read and write the object files. It can write the destination object -file in a format different from that of the source object file. The -exact behavior of \fBobjcopy\fR is controlled by command-line options. -Note that \fBobjcopy\fR should be able to copy a fully linked file -between any two formats. However, copying a relocatable object file -between any two formats may not work as expected. -.PP -\&\fBobjcopy\fR creates temporary files to do its translations and -deletes them afterward. \fBobjcopy\fR uses \s-1BFD\s0 to do all its -translation work; it has access to all the formats described in \s-1BFD\s0 -and thus is able to recognize most formats without being told -explicitly. -.PP -\&\fBobjcopy\fR can be used to generate S\-records by using an output -target of \fBsrec\fR (e.g., use \fB\-O srec\fR). -.PP -\&\fBobjcopy\fR can be used to generate a raw binary file by using an -output target of \fBbinary\fR (e.g., use \fB\-O binary\fR). When -\&\fBobjcopy\fR generates a raw binary file, it will essentially produce -a memory dump of the contents of the input object file. All symbols and -relocation information will be discarded. The memory dump will start at -the load address of the lowest section copied into the output file. -.PP -When generating an S\-record or a raw binary file, it may be helpful to -use \fB\-S\fR to remove sections containing debugging information. In -some cases \fB\-R\fR will be useful to remove sections which contain -information that is not needed by the binary file. -.PP -Note\-\-\-\fBobjcopy\fR is not able to change the endianness of its input -files. If the input format has an endianness (some formats do not), -\&\fBobjcopy\fR can only copy the inputs into file formats that have the -same endianness or which have no endianness (e.g., \fBsrec\fR). -(However, see the \fB\-\-reverse\-bytes\fR option.) -.SH "OPTIONS" -.IX Header "OPTIONS" -.IP "\fIinfile\fR" 4 -.IX Item "infile" -.PD 0 -.IP "\fIoutfile\fR" 4 -.IX Item "outfile" -.PD -The input and output files, respectively. -If you do not specify \fIoutfile\fR, \fBobjcopy\fR creates a -temporary file and destructively renames the result with -the name of \fIinfile\fR. -.IP "\fB\-I\fR \fIbfdname\fR" 4 -.IX Item "-I bfdname" -.PD 0 -.IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4 -.IX Item "--input-target=bfdname" -.PD -Consider the source file's object format to be \fIbfdname\fR, rather than -attempting to deduce it. -.IP "\fB\-O\fR \fIbfdname\fR" 4 -.IX Item "-O bfdname" -.PD 0 -.IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4 -.IX Item "--output-target=bfdname" -.PD -Write the output file using the object format \fIbfdname\fR. -.IP "\fB\-F\fR \fIbfdname\fR" 4 -.IX Item "-F bfdname" -.PD 0 -.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 -.IX Item "--target=bfdname" -.PD -Use \fIbfdname\fR as the object format for both the input and the output -file; i.e., simply transfer data from source to destination with no -translation. -.IP "\fB\-B\fR \fIbfdarch\fR" 4 -.IX Item "-B bfdarch" -.PD 0 -.IP "\fB\-\-binary\-architecture=\fR\fIbfdarch\fR" 4 -.IX Item "--binary-architecture=bfdarch" -.PD -Useful when transforming a raw binary input file into an object file. -In this case the output architecture can be set to \fIbfdarch\fR. This -option will be ignored if the input file has a known \fIbfdarch\fR. You -can access this binary data inside a program by referencing the special -symbols that are created by the conversion process. These symbols are -called _binary_\fIobjfile\fR_start, _binary_\fIobjfile\fR_end and -_binary_\fIobjfile\fR_size. e.g. you can transform a picture file into -an object file and then access it in your code using these symbols. -.IP "\fB\-j\fR \fIsectionname\fR" 4 -.IX Item "-j sectionname" -.PD 0 -.IP "\fB\-\-only\-section=\fR\fIsectionname\fR" 4 -.IX Item "--only-section=sectionname" -.PD -Copy only the named section from the input file to the output file. -This option may be given more than once. Note that using this option -inappropriately may make the output file unusable. -.IP "\fB\-R\fR \fIsectionname\fR" 4 -.IX Item "-R sectionname" -.PD 0 -.IP "\fB\-\-remove\-section=\fR\fIsectionname\fR" 4 -.IX Item "--remove-section=sectionname" -.PD -Remove any section named \fIsectionname\fR from the output file. This -option may be given more than once. Note that using this option -inappropriately may make the output file unusable. -.IP "\fB\-S\fR" 4 -.IX Item "-S" -.PD 0 -.IP "\fB\-\-strip\-all\fR" 4 -.IX Item "--strip-all" -.PD -Do not copy relocation and symbol information from the source file. -.IP "\fB\-g\fR" 4 -.IX Item "-g" -.PD 0 -.IP "\fB\-\-strip\-debug\fR" 4 -.IX Item "--strip-debug" -.PD -Do not copy debugging symbols or sections from the source file. -.IP "\fB\-\-strip\-unneeded\fR" 4 -.IX Item "--strip-unneeded" -Strip all symbols that are not needed for relocation processing. -.IP "\fB\-K\fR \fIsymbolname\fR" 4 -.IX Item "-K symbolname" -.PD 0 -.IP "\fB\-\-keep\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--keep-symbol=symbolname" -.PD -When stripping symbols, keep symbol \fIsymbolname\fR even if it would -normally be stripped. This option may be given more than once. -.IP "\fB\-N\fR \fIsymbolname\fR" 4 -.IX Item "-N symbolname" -.PD 0 -.IP "\fB\-\-strip\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--strip-symbol=symbolname" -.PD -Do not copy symbol \fIsymbolname\fR from the source file. This option -may be given more than once. -.IP "\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--strip-unneeded-symbol=symbolname" -Do not copy symbol \fIsymbolname\fR from the source file unless it is needed -by a relocation. This option may be given more than once. -.IP "\fB\-G\fR \fIsymbolname\fR" 4 -.IX Item "-G symbolname" -.PD 0 -.IP "\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--keep-global-symbol=symbolname" -.PD -Keep only symbol \fIsymbolname\fR global. Make all other symbols local -to the file, so that they are not visible externally. This option may -be given more than once. -.IP "\fB\-\-localize\-hidden\fR" 4 -.IX Item "--localize-hidden" -In an \s-1ELF\s0 object, mark all symbols that have hidden or internal visibility -as local. This option applies on top of symbol-specific localization options -such as \fB\-L\fR. -.IP "\fB\-L\fR \fIsymbolname\fR" 4 -.IX Item "-L symbolname" -.PD 0 -.IP "\fB\-\-localize\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--localize-symbol=symbolname" -.PD -Make symbol \fIsymbolname\fR local to the file, so that it is not -visible externally. This option may be given more than once. -.IP "\fB\-W\fR \fIsymbolname\fR" 4 -.IX Item "-W symbolname" -.PD 0 -.IP "\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--weaken-symbol=symbolname" -.PD -Make symbol \fIsymbolname\fR weak. This option may be given more than once. -.IP "\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR" 4 -.IX Item "--globalize-symbol=symbolname" -Give symbol \fIsymbolname\fR global scoping so that it is visible -outside of the file in which it is defined. This option may be given -more than once. -.IP "\fB\-w\fR" 4 -.IX Item "-w" -.PD 0 -.IP "\fB\-\-wildcard\fR" 4 -.IX Item "--wildcard" -.PD -Permit regular expressions in \fIsymbolname\fRs used in other command -line options. The question mark (?), asterisk (*), backslash (\e) and -square brackets ([]) operators can be used anywhere in the symbol -name. If the first character of the symbol name is the exclamation -point (!) then the sense of the switch is reversed for that symbol. -For example: -.Sp -.Vb 1 -\& \-w \-W !foo \-W fo* -.Ve -.Sp -would cause objcopy to weaken all symbols that start with \*(L"fo\*(R" -except for the symbol \*(L"foo\*(R". -.IP "\fB\-x\fR" 4 -.IX Item "-x" -.PD 0 -.IP "\fB\-\-discard\-all\fR" 4 -.IX Item "--discard-all" -.PD -Do not copy non-global symbols from the source file. -.IP "\fB\-X\fR" 4 -.IX Item "-X" -.PD 0 -.IP "\fB\-\-discard\-locals\fR" 4 -.IX Item "--discard-locals" -.PD -Do not copy compiler-generated local symbols. -(These usually start with \fBL\fR or \fB.\fR.) -.IP "\fB\-b\fR \fIbyte\fR" 4 -.IX Item "-b byte" -.PD 0 -.IP "\fB\-\-byte=\fR\fIbyte\fR" 4 -.IX Item "--byte=byte" -.PD -Keep only every \fIbyte\fRth byte of the input file (header data is not -affected). \fIbyte\fR can be in the range from 0 to \fIinterleave\fR\-1, -where \fIinterleave\fR is given by the \fB\-i\fR or \fB\-\-interleave\fR -option, or the default of 4. This option is useful for creating files -to program \s-1ROM\s0. It is typically used with an \f(CW\*(C`srec\*(C'\fR output -target. -.IP "\fB\-i\fR \fIinterleave\fR" 4 -.IX Item "-i interleave" -.PD 0 -.IP "\fB\-\-interleave=\fR\fIinterleave\fR" 4 -.IX Item "--interleave=interleave" -.PD -Only copy one out of every \fIinterleave\fR bytes. Select which byte to -copy with the \fB\-b\fR or \fB\-\-byte\fR option. The default is 4. -\&\fBobjcopy\fR ignores this option if you do not specify either \fB\-b\fR or -\&\fB\-\-byte\fR. -.IP "\fB\-p\fR" 4 -.IX Item "-p" -.PD 0 -.IP "\fB\-\-preserve\-dates\fR" 4 -.IX Item "--preserve-dates" -.PD -Set the access and modification dates of the output file to be the same -as those of the input file. -.IP "\fB\-\-debugging\fR" 4 -.IX Item "--debugging" -Convert debugging information, if possible. This is not the default -because only certain debugging formats are supported, and the -conversion process can be time consuming. -.IP "\fB\-\-gap\-fill\fR \fIval\fR" 4 -.IX Item "--gap-fill val" -Fill gaps between sections with \fIval\fR. This operation applies to -the \fIload address\fR (\s-1LMA\s0) of the sections. It is done by increasing -the size of the section with the lower address, and filling in the extra -space created with \fIval\fR. -.IP "\fB\-\-pad\-to\fR \fIaddress\fR" 4 -.IX Item "--pad-to address" -Pad the output file up to the load address \fIaddress\fR. This is -done by increasing the size of the last section. The extra space is -filled in with the value specified by \fB\-\-gap\-fill\fR (default zero). -.IP "\fB\-\-set\-start\fR \fIval\fR" 4 -.IX Item "--set-start val" -Set the start address of the new file to \fIval\fR. Not all object file -formats support setting the start address. -.IP "\fB\-\-change\-start\fR \fIincr\fR" 4 -.IX Item "--change-start incr" -.PD 0 -.IP "\fB\-\-adjust\-start\fR \fIincr\fR" 4 -.IX Item "--adjust-start incr" -.PD -Change the start address by adding \fIincr\fR. Not all object file -formats support setting the start address. -.IP "\fB\-\-change\-addresses\fR \fIincr\fR" 4 -.IX Item "--change-addresses incr" -.PD 0 -.IP "\fB\-\-adjust\-vma\fR \fIincr\fR" 4 -.IX Item "--adjust-vma incr" -.PD -Change the \s-1VMA\s0 and \s-1LMA\s0 addresses of all sections, as well as the start -address, by adding \fIincr\fR. Some object file formats do not permit -section addresses to be changed arbitrarily. Note that this does not -relocate the sections; if the program expects sections to be loaded at a -certain address, and this option is used to change the sections such -that they are loaded at a different address, the program may fail. -.IP "\fB\-\-change\-section\-address\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 -.IX Item "--change-section-address section{=,+,-}val" -.PD 0 -.IP "\fB\-\-adjust\-section\-vma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 -.IX Item "--adjust-section-vma section{=,+,-}val" -.PD -Set or change both the \s-1VMA\s0 address and the \s-1LMA\s0 address of the named -\&\fIsection\fR. If \fB=\fR is used, the section address is set to -\&\fIval\fR. Otherwise, \fIval\fR is added to or subtracted from the -section address. See the comments under \fB\-\-change\-addresses\fR, -above. If \fIsection\fR does not exist in the input file, a warning will -be issued, unless \fB\-\-no\-change\-warnings\fR is used. -.IP "\fB\-\-change\-section\-lma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 -.IX Item "--change-section-lma section{=,+,-}val" -Set or change the \s-1LMA\s0 address of the named \fIsection\fR. The \s-1LMA\s0 -address is the address where the section will be loaded into memory at -program load time. Normally this is the same as the \s-1VMA\s0 address, which -is the address of the section at program run time, but on some systems, -especially those where a program is held in \s-1ROM\s0, the two can be -different. If \fB=\fR is used, the section address is set to -\&\fIval\fR. Otherwise, \fIval\fR is added to or subtracted from the -section address. See the comments under \fB\-\-change\-addresses\fR, -above. If \fIsection\fR does not exist in the input file, a warning -will be issued, unless \fB\-\-no\-change\-warnings\fR is used. -.IP "\fB\-\-change\-section\-vma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 -.IX Item "--change-section-vma section{=,+,-}val" -Set or change the \s-1VMA\s0 address of the named \fIsection\fR. The \s-1VMA\s0 -address is the address where the section will be located once the -program has started executing. Normally this is the same as the \s-1LMA\s0 -address, which is the address where the section will be loaded into -memory, but on some systems, especially those where a program is held in -\&\s-1ROM\s0, the two can be different. If \fB=\fR is used, the section address -is set to \fIval\fR. Otherwise, \fIval\fR is added to or subtracted -from the section address. See the comments under -\&\fB\-\-change\-addresses\fR, above. If \fIsection\fR does not exist in -the input file, a warning will be issued, unless -\&\fB\-\-no\-change\-warnings\fR is used. -.IP "\fB\-\-change\-warnings\fR" 4 -.IX Item "--change-warnings" -.PD 0 -.IP "\fB\-\-adjust\-warnings\fR" 4 -.IX Item "--adjust-warnings" -.PD -If \fB\-\-change\-section\-address\fR or \fB\-\-change\-section\-lma\fR or -\&\fB\-\-change\-section\-vma\fR is used, and the named section does not -exist, issue a warning. This is the default. -.IP "\fB\-\-no\-change\-warnings\fR" 4 -.IX Item "--no-change-warnings" -.PD 0 -.IP "\fB\-\-no\-adjust\-warnings\fR" 4 -.IX Item "--no-adjust-warnings" -.PD -Do not issue a warning if \fB\-\-change\-section\-address\fR or -\&\fB\-\-adjust\-section\-lma\fR or \fB\-\-adjust\-section\-vma\fR is used, even -if the named section does not exist. -.IP "\fB\-\-set\-section\-flags\fR \fIsection\fR\fB=\fR\fIflags\fR" 4 -.IX Item "--set-section-flags section=flags" -Set the flags for the named section. The \fIflags\fR argument is a -comma separated string of flag names. The recognized names are -\&\fBalloc\fR, \fBcontents\fR, \fBload\fR, \fBnoload\fR, -\&\fBreadonly\fR, \fBcode\fR, \fBdata\fR, \fBrom\fR, \fBshare\fR, and -\&\fBdebug\fR. You can set the \fBcontents\fR flag for a section which -does not have contents, but it is not meaningful to clear the -\&\fBcontents\fR flag of a section which does have contents\*(--just remove -the section instead. Not all flags are meaningful for all object file -formats. -.IP "\fB\-\-add\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4 -.IX Item "--add-section sectionname=filename" -Add a new section named \fIsectionname\fR while copying the file. The -contents of the new section are taken from the file \fIfilename\fR. The -size of the section will be the size of the file. This option only -works on file formats which can support sections with arbitrary names. -.IP "\fB\-\-rename\-section\fR \fIoldname\fR\fB=\fR\fInewname\fR\fB[,\fR\fIflags\fR\fB]\fR" 4 -.IX Item "--rename-section oldname=newname[,flags]" -Rename a section from \fIoldname\fR to \fInewname\fR, optionally -changing the section's flags to \fIflags\fR in the process. This has -the advantage over usng a linker script to perform the rename in that -the output stays as an object file and does not become a linked -executable. -.Sp -This option is particularly helpful when the input format is binary, -since this will always create a section called .data. If for example, -you wanted instead to create a section called .rodata containing binary -data you could use the following command line to achieve it: -.Sp -.Vb 3 -\& objcopy \-I binary \-O \-B \e -\& \-\-rename\-section .data=.rodata,alloc,load,readonly,data,contents \e -\& -.Ve -.IP "\fB\-\-change\-leading\-char\fR" 4 -.IX Item "--change-leading-char" -Some object file formats use special characters at the start of -symbols. The most common such character is underscore, which compilers -often add before every symbol. This option tells \fBobjcopy\fR to -change the leading character of every symbol when it converts between -object file formats. If the object file formats use the same leading -character, this option has no effect. Otherwise, it will add a -character, or remove a character, or change a character, as -appropriate. -.IP "\fB\-\-remove\-leading\-char\fR" 4 -.IX Item "--remove-leading-char" -If the first character of a global symbol is a special symbol leading -character used by the object file format, remove the character. The -most common symbol leading character is underscore. This option will -remove a leading underscore from all global symbols. This can be useful -if you want to link together objects of different file formats with -different conventions for symbol names. This is different from -\&\fB\-\-change\-leading\-char\fR because it always changes the symbol name -when appropriate, regardless of the object file format of the output -file. -.IP "\fB\-\-reverse\-bytes=\fR\fInum\fR" 4 -.IX Item "--reverse-bytes=num" -Reverse the bytes in a section with output contents. A section length must -be evenly divisible by the value given in order for the swap to be able to -take place. Reversing takes place before the interleaving is performed. -.Sp -This option is used typically in generating \s-1ROM\s0 images for problematic -target systems. For example, on some target boards, the 32\-bit words -fetched from 8\-bit ROMs are re-assembled in little-endian byte order -regardless of the \s-1CPU\s0 byte order. Depending on the programming model, the -endianness of the \s-1ROM\s0 may need to be modified. -.Sp -Consider a simple file with a section containing the following eight -bytes: \f(CW12345678\fR. -.Sp -Using \fB\-\-reverse\-bytes=2\fR for the above example, the bytes in the -output file would be ordered \f(CW21436587\fR. -.Sp -Using \fB\-\-reverse\-bytes=4\fR for the above example, the bytes in the -output file would be ordered \f(CW43218765\fR. -.Sp -By using \fB\-\-reverse\-bytes=2\fR for the above example, followed by -\&\fB\-\-reverse\-bytes=4\fR on the output file, the bytes in the second -output file would be ordered \f(CW34127856\fR. -.IP "\fB\-\-srec\-len=\fR\fIival\fR" 4 -.IX Item "--srec-len=ival" -Meaningful only for srec output. Set the maximum length of the Srecords -being produced to \fIival\fR. This length covers both address, data and -crc fields. -.IP "\fB\-\-srec\-forceS3\fR" 4 -.IX Item "--srec-forceS3" -Meaningful only for srec output. Avoid generation of S1/S2 records, -creating S3\-only record format. -.IP "\fB\-\-redefine\-sym\fR \fIold\fR\fB=\fR\fInew\fR" 4 -.IX Item "--redefine-sym old=new" -Change the name of a symbol \fIold\fR, to \fInew\fR. This can be useful -when one is trying link two things together for which you have no -source, and there are name collisions. -.IP "\fB\-\-redefine\-syms=\fR\fIfilename\fR" 4 -.IX Item "--redefine-syms=filename" -Apply \fB\-\-redefine\-sym\fR to each symbol pair "\fIold\fR \fInew\fR" -listed in the file \fIfilename\fR. \fIfilename\fR is simply a flat file, -with one symbol pair per line. Line comments may be introduced by the hash -character. This option may be given more than once. -.IP "\fB\-\-weaken\fR" 4 -.IX Item "--weaken" -Change all global symbols in the file to be weak. This can be useful -when building an object which will be linked against other objects using -the \fB\-R\fR option to the linker. This option is only effective when -using an object file format which supports weak symbols. -.IP "\fB\-\-keep\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--keep-symbols=filename" -Apply \fB\-\-keep\-symbol\fR option to each symbol listed in the file -\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol -name per line. Line comments may be introduced by the hash character. -This option may be given more than once. -.IP "\fB\-\-strip\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--strip-symbols=filename" -Apply \fB\-\-strip\-symbol\fR option to each symbol listed in the file -\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol -name per line. Line comments may be introduced by the hash character. -This option may be given more than once. -.IP "\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--strip-unneeded-symbols=filename" -Apply \fB\-\-strip\-unneeded\-symbol\fR option to each symbol listed in -the file \fIfilename\fR. \fIfilename\fR is simply a flat file, with one -symbol name per line. Line comments may be introduced by the hash -character. This option may be given more than once. -.IP "\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--keep-global-symbols=filename" -Apply \fB\-\-keep\-global\-symbol\fR option to each symbol listed in the -file \fIfilename\fR. \fIfilename\fR is simply a flat file, with one -symbol name per line. Line comments may be introduced by the hash -character. This option may be given more than once. -.IP "\fB\-\-localize\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--localize-symbols=filename" -Apply \fB\-\-localize\-symbol\fR option to each symbol listed in the file -\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol -name per line. Line comments may be introduced by the hash character. -This option may be given more than once. -.IP "\fB\-\-globalize\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--globalize-symbols=filename" -Apply \fB\-\-globalize\-symbol\fR option to each symbol listed in the file -\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol -name per line. Line comments may be introduced by the hash character. -This option may be given more than once. -.IP "\fB\-\-weaken\-symbols=\fR\fIfilename\fR" 4 -.IX Item "--weaken-symbols=filename" -Apply \fB\-\-weaken\-symbol\fR option to each symbol listed in the file -\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol -name per line. Line comments may be introduced by the hash character. -This option may be given more than once. -.IP "\fB\-\-alt\-machine\-code=\fR\fIindex\fR" 4 -.IX Item "--alt-machine-code=index" -If the output architecture has alternate machine codes, use the -\&\fIindex\fRth code instead of the default one. This is useful in case -a machine is assigned an official code and the tool-chain adopts the -new code, but other applications still depend on the original code -being used. For \s-1ELF\s0 based architectures if the \fIindex\fR -alternative does not exist then the value is treated as an absolute -number to be stored in the e_machine field of the \s-1ELF\s0 header. -.IP "\fB\-\-writable\-text\fR" 4 -.IX Item "--writable-text" -Mark the output text as writable. This option isn't meaningful for all -object file formats. -.IP "\fB\-\-readonly\-text\fR" 4 -.IX Item "--readonly-text" -Make the output text write protected. This option isn't meaningful for all -object file formats. -.IP "\fB\-\-pure\fR" 4 -.IX Item "--pure" -Mark the output file as demand paged. This option isn't meaningful for all -object file formats. -.IP "\fB\-\-impure\fR" 4 -.IX Item "--impure" -Mark the output file as impure. This option isn't meaningful for all -object file formats. -.IP "\fB\-\-prefix\-symbols=\fR\fIstring\fR" 4 -.IX Item "--prefix-symbols=string" -Prefix all symbols in the output file with \fIstring\fR. -.IP "\fB\-\-prefix\-sections=\fR\fIstring\fR" 4 -.IX Item "--prefix-sections=string" -Prefix all section names in the output file with \fIstring\fR. -.IP "\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR" 4 -.IX Item "--prefix-alloc-sections=string" -Prefix all the names of all allocated sections in the output file with -\&\fIstring\fR. -.IP "\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR" 4 -.IX Item "--add-gnu-debuglink=path-to-file" -Creates a .gnu_debuglink section which contains a reference to \fIpath-to-file\fR -and adds it to the output file. -.IP "\fB\-\-keep\-file\-symbols\fR" 4 -.IX Item "--keep-file-symbols" -When stripping a file, perhaps with \fB\-\-strip\-debug\fR or -\&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names, -which would otherwise get stripped. -.IP "\fB\-\-only\-keep\-debug\fR" 4 -.IX Item "--only-keep-debug" -Strip a file, removing contents of any sections that would not be -stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections -intact. In \s-1ELF\s0 files, this preserves all note sections in the output. -.Sp -The intention is that this option will be used in conjunction with -\&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One a -stripped binary which will occupy less space in \s-1RAM\s0 and in a -distribution and the second a debugging information file which is only -needed if debugging abilities are required. The suggested procedure -to create these files is as follows: -.RS 4 -.IP "1." 4 -.IX Item "1." -\&\f(CW\*(C`foo\*(C'\fR then... -.ie n .IP "1." 4 -.el .IP "1." 4 -.IX Item "1." -create a file containing the debugging info. -.ie n .IP "1." 4 -.el .IP "1." 4 -.IX Item "1." -stripped executable. -.ie n .IP "1." 4 -.el .IP "1." 4 -.IX Item "1." -to add a link to the debugging info into the stripped executable. -.RE -.RS 4 -.Sp -Note \- the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info -file is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is -optional. You could instead do this: -.IP "1." 4 -.IX Item "1." -.PD 0 -.ie n .IP "1." 4 -.el .IP "1." 4 -.IX Item "1." -.ie n .IP "1." 4 -.el .IP "1." 4 -.IX Item "1." -.ie n .IP "1." 4 -.el .IP "1." 4 -.IX Item "1." -.RE -.RS 4 -.PD -.Sp -i.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the -full executable. It does not have to be a file created by the -\&\fB\-\-only\-keep\-debug\fR switch. -.Sp -Note \- this switch is only intended for use on fully linked files. It -does not make sense to use it on object files where the debugging -information may be incomplete. Besides the gnu_debuglink feature -currently only supports the presence of one filename containing -debugging information, not multiple filenames on a one-per-object-file -basis. -.RE -.IP "\fB\-\-extract\-symbol\fR" 4 -.IX Item "--extract-symbol" -Keep the file's section flags and symbols but remove all section data. -Specifically, the option: -.RS 4 -.IP "*" 4 -.IX Item "*" -.PD 0 -.IP "*" 4 -.IX Item "*" -.IP "*" 4 -.IX Item "*" -.IP "*" 4 -.IX Item "*" -.RE -.RS 4 -.PD -.Sp -This option is used to build a \fI.sym\fR file for a VxWorks kernel. -It can also be a useful way of reducing the size of a \fB\-\-just\-symbols\fR -linker input file. -.RE -.IP "\fB\-V\fR" 4 -.IX Item "-V" -.PD 0 -.IP "\fB\-\-version\fR" 4 -.IX Item "--version" -.PD -Show the version number of \fBobjcopy\fR. -.IP "\fB\-v\fR" 4 -.IX Item "-v" -.PD 0 -.IP "\fB\-\-verbose\fR" 4 -.IX Item "--verbose" -.PD -Verbose output: list all object files modified. In the case of -archives, \fBobjcopy \-V\fR lists all members of the archive. -.IP "\fB\-\-help\fR" 4 -.IX Item "--help" -Show a summary of the options to \fBobjcopy\fR. -.IP "\fB\-\-info\fR" 4 -.IX Item "--info" -Display a list showing all architectures and object formats available. -.IP "\fB@\fR\fIfile\fR" 4 -.IX Item "@file" -Read command-line options from \fIfile\fR. The options read are -inserted in place of the original @\fIfile\fR option. If \fIfile\fR -does not exist, or cannot be read, then the option will be treated -literally, and not removed. -.Sp -Options in \fIfile\fR are separated by whitespace. A whitespace -character may be included in an option by surrounding the entire -option in either single or double quotes. Any character (including a -backslash) may be included by prefixing the character to be included -with a backslash. The \fIfile\fR may itself contain additional -@\fIfile\fR options; any such options will be processed recursively. -.SH "SEE ALSO" -.IX Header "SEE ALSO" -\&\fIld\fR\|(1), \fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR. -.SH "COPYRIGHT" -.IX Header "COPYRIGHT" -Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. -.PP -Permission is granted to copy, distribute and/or modify this document -under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 -or any later version published by the Free Software Foundation; -with no Invariant Sections, with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the -section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/objdump/Makefile b/gnu/usr.bin/binutils/objdump/Makefile deleted file mode 100644 index 38bc68caa78..00000000000 --- a/gnu/usr.bin/binutils/objdump/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ - -.include "../Makefile.inc0" - -.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc - -PROG= objdump -SRCS= objdump.c prdbg.c -CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbinutils -CFLAGS+= -I${SRCDIR}/binutils -CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" -DPADD= ${GNURELTOP}/libbinutils/libbinutils${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libopcodes/libopcodes${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libbfd/libbfd${PIE_SUFFIX}.a -DPADD+= ${GNURELTOP}/libiberty/libiberty${PIE_SUFFIX}.a -LDADD= ${DPADD} - -.include diff --git a/gnu/usr.bin/binutils/objdump/Makefile.depend b/gnu/usr.bin/binutils/objdump/Makefile.depend deleted file mode 100644 index 38831ab06c3..00000000000 --- a/gnu/usr.bin/binutils/objdump/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libbinutils \ - gnu/usr.bin/binutils/libiberty \ - gnu/usr.bin/binutils/libopcodes \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/binutils/objdump/objdump.1 b/gnu/usr.bin/binutils/objdump/objdump.1 deleted file mode 100644 index 04a7a7f6331..00000000000 --- a/gnu/usr.bin/binutils/objdump/objdump.1 +++ /dev/null @@ -1,640 +0,0 @@ -.\" $FreeBSD$ -.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "OBJDUMP 1" -.TH OBJDUMP 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -objdump \- display information from object files. -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -objdump [\fB\-a\fR|\fB\-\-archive\-headers\fR] - [\fB\-b\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] - [\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR] ] - [\fB\-d\fR|\fB\-\-disassemble\fR] - [\fB\-D\fR|\fB\-\-disassemble\-all\fR] - [\fB\-z\fR|\fB\-\-disassemble\-zeroes\fR] - [\fB\-EB\fR|\fB\-EL\fR|\fB\-\-endian=\fR{big | little }] - [\fB\-f\fR|\fB\-\-file\-headers\fR] - [\fB\-\-file\-start\-context\fR] - [\fB\-g\fR|\fB\-\-debugging\fR] - [\fB\-e\fR|\fB\-\-debugging\-tags\fR] - [\fB\-h\fR|\fB\-\-section\-headers\fR|\fB\-\-headers\fR] - [\fB\-i\fR|\fB\-\-info\fR] - [\fB\-j\fR \fIsection\fR|\fB\-\-section=\fR\fIsection\fR] - [\fB\-l\fR|\fB\-\-line\-numbers\fR] - [\fB\-S\fR|\fB\-\-source\fR] - [\fB\-m\fR \fImachine\fR|\fB\-\-architecture=\fR\fImachine\fR] - [\fB\-M\fR \fIoptions\fR|\fB\-\-disassembler\-options=\fR\fIoptions\fR] - [\fB\-p\fR|\fB\-\-private\-headers\fR] - [\fB\-r\fR|\fB\-\-reloc\fR] - [\fB\-R\fR|\fB\-\-dynamic\-reloc\fR] - [\fB\-s\fR|\fB\-\-full\-contents\fR] - [\fB\-W\fR|\fB\-\-dwarf\fR] - [\fB\-G\fR|\fB\-\-stabs\fR] - [\fB\-t\fR|\fB\-\-syms\fR] - [\fB\-T\fR|\fB\-\-dynamic\-syms\fR] - [\fB\-x\fR|\fB\-\-all\-headers\fR] - [\fB\-w\fR|\fB\-\-wide\fR] - [\fB\-\-start\-address=\fR\fIaddress\fR] - [\fB\-\-stop\-address=\fR\fIaddress\fR] - [\fB\-\-prefix\-addresses\fR] - [\fB\-\-[no\-]show\-raw\-insn\fR] - [\fB\-\-adjust\-vma=\fR\fIoffset\fR] - [\fB\-\-special\-syms\fR] - [\fB\-V\fR|\fB\-\-version\fR] - [\fB\-H\fR|\fB\-\-help\fR] - \fIobjfile\fR... -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -\&\fBobjdump\fR displays information about one or more object files. -The options control what particular information to display. This -information is mostly useful to programmers who are working on the -compilation tools, as opposed to programmers who just want their -program to compile and work. -.PP -\&\fIobjfile\fR... are the object files to be examined. When you -specify archives, \fBobjdump\fR shows information on each of the member -object files. -.PP -GNU \&\fBobjdump\fR will be removed from a future version of the -FreeBSD base system. Users who require GNU \&\fBobjdump\fR are advised -to install the binutils port or package. -.SH "OPTIONS" -.IX Header "OPTIONS" -The long and short forms of options, shown here as alternatives, are -equivalent. At least one option from the list -\&\fB\-a,\-d,\-D,\-e,\-f,\-g,\-G,\-h,\-H,\-p,\-r,\-R,\-s,\-S,\-t,\-T,\-V,\-x\fR must be given. -.IP "\fB\-a\fR" 4 -.IX Item "-a" -.PD 0 -.IP "\fB\-\-archive\-header\fR" 4 -.IX Item "--archive-header" -.PD -If any of the \fIobjfile\fR files are archives, display the archive -header information (in a format similar to \fBls \-l\fR). Besides the -information you could list with \fBar tv\fR, \fBobjdump \-a\fR shows -the object file format of each archive member. -.IP "\fB\-\-adjust\-vma=\fR\fIoffset\fR" 4 -.IX Item "--adjust-vma=offset" -When dumping information, first add \fIoffset\fR to all the section -addresses. This is useful if the section addresses do not correspond to -the symbol table, which can happen when putting sections at particular -addresses when using a format which can not represent section addresses, -such as a.out. -.IP "\fB\-b\fR \fIbfdname\fR" 4 -.IX Item "-b bfdname" -.PD 0 -.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 -.IX Item "--target=bfdname" -.PD -Specify that the object-code format for the object files is -\&\fIbfdname\fR. This option may not be necessary; \fIobjdump\fR can -automatically recognize many formats. -.Sp -For example, -.Sp -.Vb 1 -\& objdump \-b oasys \-m vax \-h fu.o -.Ve -.Sp -displays summary information from the section headers (\fB\-h\fR) of -\&\fIfu.o\fR, which is explicitly identified (\fB\-m\fR) as a \s-1VAX\s0 object -file in the format produced by Oasys compilers. You can list the -formats available with the \fB\-i\fR option. -.IP "\fB\-C\fR" 4 -.IX Item "-C" -.PD 0 -.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 -.IX Item "--demangle[=style]" -.PD -Decode (\fIdemangle\fR) low-level symbol names into user-level names. -Besides removing any initial underscore prepended by the system, this -makes \*(C+ function names readable. Different compilers have different -mangling styles. The optional demangling style argument can be used to -choose an appropriate demangling style for your compiler. -.IP "\fB\-g\fR" 4 -.IX Item "-g" -.PD 0 -.IP "\fB\-\-debugging\fR" 4 -.IX Item "--debugging" -.PD -Display debugging information. This attempts to parse debugging -information stored in the file and print it out using a C like syntax. -Only certain types of debugging information have been implemented. -Some other types are supported by \fBreadelf \-w\fR. -.IP "\fB\-e\fR" 4 -.IX Item "-e" -.PD 0 -.IP "\fB\-\-debugging\-tags\fR" 4 -.IX Item "--debugging-tags" -.PD -Like \fB\-g\fR, but the information is generated in a format compatible -with ctags tool. -.IP "\fB\-d\fR" 4 -.IX Item "-d" -.PD 0 -.IP "\fB\-\-disassemble\fR" 4 -.IX Item "--disassemble" -.PD -Display the assembler mnemonics for the machine instructions from -\&\fIobjfile\fR. This option only disassembles those sections which are -expected to contain instructions. -.IP "\fB\-D\fR" 4 -.IX Item "-D" -.PD 0 -.IP "\fB\-\-disassemble\-all\fR" 4 -.IX Item "--disassemble-all" -.PD -Like \fB\-d\fR, but disassemble the contents of all sections, not just -those expected to contain instructions. -.IP "\fB\-\-prefix\-addresses\fR" 4 -.IX Item "--prefix-addresses" -When disassembling, print the complete address on each line. This is -the older disassembly format. -.IP "\fB\-EB\fR" 4 -.IX Item "-EB" -.PD 0 -.IP "\fB\-EL\fR" 4 -.IX Item "-EL" -.IP "\fB\-\-endian={big|little}\fR" 4 -.IX Item "--endian={big|little}" -.PD -Specify the endianness of the object files. This only affects -disassembly. This can be useful when disassembling a file format which -does not describe endianness information, such as S\-records. -.IP "\fB\-f\fR" 4 -.IX Item "-f" -.PD 0 -.IP "\fB\-\-file\-headers\fR" 4 -.IX Item "--file-headers" -.PD -Display summary information from the overall header of -each of the \fIobjfile\fR files. -.IP "\fB\-\-file\-start\-context\fR" 4 -.IX Item "--file-start-context" -Specify that when displaying interlisted source code/disassembly -(assumes \fB\-S\fR) from a file that has not yet been displayed, extend the -context to the start of the file. -.IP "\fB\-h\fR" 4 -.IX Item "-h" -.PD 0 -.IP "\fB\-\-section\-headers\fR" 4 -.IX Item "--section-headers" -.IP "\fB\-\-headers\fR" 4 -.IX Item "--headers" -.PD -Display summary information from the section headers of the -object file. -.Sp -File segments may be relocated to nonstandard addresses, for example by -using the \fB\-Ttext\fR, \fB\-Tdata\fR, or \fB\-Tbss\fR options to -\&\fBld\fR. However, some object file formats, such as a.out, do not -store the starting address of the file segments. In those situations, -although \fBld\fR relocates the sections correctly, using \fBobjdump -\&\-h\fR to list the file section headers cannot show the correct addresses. -Instead, it shows the usual addresses, which are implicit for the -target. -.IP "\fB\-H\fR" 4 -.IX Item "-H" -.PD 0 -.IP "\fB\-\-help\fR" 4 -.IX Item "--help" -.PD -Print a summary of the options to \fBobjdump\fR and exit. -.IP "\fB\-i\fR" 4 -.IX Item "-i" -.PD 0 -.IP "\fB\-\-info\fR" 4 -.IX Item "--info" -.PD -Display a list showing all architectures and object formats available -for specification with \fB\-b\fR or \fB\-m\fR. -.IP "\fB\-j\fR \fIname\fR" 4 -.IX Item "-j name" -.PD 0 -.IP "\fB\-\-section=\fR\fIname\fR" 4 -.IX Item "--section=name" -.PD -Display information only for section \fIname\fR. -.IP "\fB\-l\fR" 4 -.IX Item "-l" -.PD 0 -.IP "\fB\-\-line\-numbers\fR" 4 -.IX Item "--line-numbers" -.PD -Label the display (using debugging information) with the filename and -source line numbers corresponding to the object code or relocs shown. -Only useful with \fB\-d\fR, \fB\-D\fR, or \fB\-r\fR. -.IP "\fB\-m\fR \fImachine\fR" 4 -.IX Item "-m machine" -.PD 0 -.IP "\fB\-\-architecture=\fR\fImachine\fR" 4 -.IX Item "--architecture=machine" -.PD -Specify the architecture to use when disassembling object files. This -can be useful when disassembling object files which do not describe -architecture information, such as S\-records. You can list the available -architectures with the \fB\-i\fR option. -.IP "\fB\-M\fR \fIoptions\fR" 4 -.IX Item "-M options" -.PD 0 -.IP "\fB\-\-disassembler\-options=\fR\fIoptions\fR" 4 -.IX Item "--disassembler-options=options" -.PD -Pass target specific information to the disassembler. Only supported on -some targets. If it is necessary to specify more than one -disassembler option then multiple \fB\-M\fR options can be used or -can be placed together into a comma separated list. -.Sp -If the target is an \s-1ARM\s0 architecture then this switch can be used to -select which register name set is used during disassembler. Specifying -\&\fB\-M reg-names-std\fR (the default) will select the register names as -used in \s-1ARM\s0's instruction set documentation, but with register 13 called -\&'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying -\&\fB\-M reg-names-apcs\fR will select the name set used by the \s-1ARM\s0 -Procedure Call Standard, whilst specifying \fB\-M reg-names-raw\fR will -just use \fBr\fR followed by the register number. -.Sp -There are also two variants on the \s-1APCS\s0 register naming scheme enabled -by \fB\-M reg-names-atpcs\fR and \fB\-M reg-names-special-atpcs\fR which -use the ARM/Thumb Procedure Call Standard naming conventions. (Either -with the normal register names or the special register names). -.Sp -This option can also be used for \s-1ARM\s0 architectures to force the -disassembler to interpret all instructions as Thumb instructions by -using the switch \fB\-\-disassembler\-options=force\-thumb\fR. This can be -useful when attempting to disassemble thumb code produced by other -compilers. -.Sp -For the x86, some of the options duplicate functions of the \fB\-m\fR -switch, but allow finer grained control. Multiple selections from the -following may be specified as a comma separated string. -\&\fBx86\-64\fR, \fBi386\fR and \fBi8086\fR select disassembly for -the given architecture. \fBintel\fR and \fBatt\fR select between -intel syntax mode and \s-1AT&T\s0 syntax mode. \fBaddr64\fR, \fBaddr32\fR, -\&\fBaddr16\fR, \fBdata32\fR and \fBdata16\fR specify the default -address size and operand size. These four options will be overridden if -\&\fBx86\-64\fR, \fBi386\fR or \fBi8086\fR appear later in the -option string. Lastly, \fBsuffix\fR, when in \s-1AT&T\s0 mode, -instructs the disassembler to print a mnemonic suffix even when the -suffix could be inferred by the operands. -.Sp -For \s-1PPC\s0, \fBbooke\fR, \fBbooke32\fR and \fBbooke64\fR select -disassembly of BookE instructions. \fB32\fR and \fB64\fR select -PowerPC and PowerPC64 disassembly, respectively. \fBe300\fR selects -disassembly for the e300 family. \fB440\fR selects disassembly for -the PowerPC 440. -.Sp -For \s-1MIPS\s0, this option controls the printing of instruction mnemonic -names and register names in disassembled instructions. Multiple -selections from the following may be specified as a comma separated -string, and invalid options are ignored: -.RS 4 -.ie n .IP """no\-aliases""" 4 -.el .IP "\f(CWno\-aliases\fR" 4 -.IX Item "no-aliases" -Print the 'raw' instruction mnemonic instead of some pseudo -instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move', -\&'sll' instead of 'nop', etc. -.ie n .IP """gpr\-names=\f(CIABI\f(CW""" 4 -.el .IP "\f(CWgpr\-names=\f(CIABI\f(CW\fR" 4 -.IX Item "gpr-names=ABI" -Print \s-1GPR\s0 (general-purpose register) names as appropriate -for the specified \s-1ABI\s0. By default, \s-1GPR\s0 names are selected according to -the \s-1ABI\s0 of the binary being disassembled. -.ie n .IP """fpr\-names=\f(CIABI\f(CW""" 4 -.el .IP "\f(CWfpr\-names=\f(CIABI\f(CW\fR" 4 -.IX Item "fpr-names=ABI" -Print \s-1FPR\s0 (floating-point register) names as -appropriate for the specified \s-1ABI\s0. By default, \s-1FPR\s0 numbers are printed -rather than names. -.ie n .IP """cp0\-names=\f(CIARCH\f(CW""" 4 -.el .IP "\f(CWcp0\-names=\f(CIARCH\f(CW\fR" 4 -.IX Item "cp0-names=ARCH" -Print \s-1CP0\s0 (system control coprocessor; coprocessor 0) register names -as appropriate for the \s-1CPU\s0 or architecture specified by -\&\fI\s-1ARCH\s0\fR. By default, \s-1CP0\s0 register names are selected according to -the architecture and \s-1CPU\s0 of the binary being disassembled. -.ie n .IP """hwr\-names=\f(CIARCH\f(CW""" 4 -.el .IP "\f(CWhwr\-names=\f(CIARCH\f(CW\fR" 4 -.IX Item "hwr-names=ARCH" -Print \s-1HWR\s0 (hardware register, used by the \f(CW\*(C`rdhwr\*(C'\fR instruction) names -as appropriate for the \s-1CPU\s0 or architecture specified by -\&\fI\s-1ARCH\s0\fR. By default, \s-1HWR\s0 names are selected according to -the architecture and \s-1CPU\s0 of the binary being disassembled. -.ie n .IP """reg\-names=\f(CIABI\f(CW""" 4 -.el .IP "\f(CWreg\-names=\f(CIABI\f(CW\fR" 4 -.IX Item "reg-names=ABI" -Print \s-1GPR\s0 and \s-1FPR\s0 names as appropriate for the selected \s-1ABI\s0. -.ie n .IP """reg\-names=\f(CIARCH\f(CW""" 4 -.el .IP "\f(CWreg\-names=\f(CIARCH\f(CW\fR" 4 -.IX Item "reg-names=ARCH" -Print CPU-specific register names (\s-1CP0\s0 register and \s-1HWR\s0 names) -as appropriate for the selected \s-1CPU\s0 or architecture. -.RE -.RS 4 -.Sp -For any of the options listed above, \fI\s-1ABI\s0\fR or -\&\fI\s-1ARCH\s0\fR may be specified as \fBnumeric\fR to have numbers printed -rather than names, for the selected types of registers. -You can list the available values of \fI\s-1ABI\s0\fR and \fI\s-1ARCH\s0\fR using -the \fB\-\-help\fR option. -.Sp -For \s-1VAX\s0, you can specify function entry addresses with \fB\-M -entry:0xf00ba\fR. You can use this multiple times to properly -disassemble \s-1VAX\s0 binary files that don't contain symbol tables (like -\&\s-1ROM\s0 dumps). In these cases, the function entry mask would otherwise -be decoded as \s-1VAX\s0 instructions, which would probably lead the rest -of the function being wrongly disassembled. -.RE -.IP "\fB\-p\fR" 4 -.IX Item "-p" -.PD 0 -.IP "\fB\-\-private\-headers\fR" 4 -.IX Item "--private-headers" -.PD -Print information that is specific to the object file format. The exact -information printed depends upon the object file format. For some -object file formats, no additional information is printed. -.IP "\fB\-r\fR" 4 -.IX Item "-r" -.PD 0 -.IP "\fB\-\-reloc\fR" 4 -.IX Item "--reloc" -.PD -Print the relocation entries of the file. If used with \fB\-d\fR or -\&\fB\-D\fR, the relocations are printed interspersed with the -disassembly. -.IP "\fB\-R\fR" 4 -.IX Item "-R" -.PD 0 -.IP "\fB\-\-dynamic\-reloc\fR" 4 -.IX Item "--dynamic-reloc" -.PD -Print the dynamic relocation entries of the file. This is only -meaningful for dynamic objects, such as certain types of shared -libraries. -.IP "\fB\-s\fR" 4 -.IX Item "-s" -.PD 0 -.IP "\fB\-\-full\-contents\fR" 4 -.IX Item "--full-contents" -.PD -Display the full contents of any sections requested. By default all -non-empty sections are displayed. -.IP "\fB\-S\fR" 4 -.IX Item "-S" -.PD 0 -.IP "\fB\-\-source\fR" 4 -.IX Item "--source" -.PD -Display source code intermixed with disassembly, if possible. Implies -\&\fB\-d\fR. -.IP "\fB\-\-show\-raw\-insn\fR" 4 -.IX Item "--show-raw-insn" -When disassembling instructions, print the instruction in hex as well as -in symbolic form. This is the default except when -\&\fB\-\-prefix\-addresses\fR is used. -.IP "\fB\-\-no\-show\-raw\-insn\fR" 4 -.IX Item "--no-show-raw-insn" -When disassembling instructions, do not print the instruction bytes. -This is the default when \fB\-\-prefix\-addresses\fR is used. -.IP "\fB\-W\fR" 4 -.IX Item "-W" -.PD 0 -.IP "\fB\-\-dwarf\fR" 4 -.IX Item "--dwarf" -.PD -Displays the contents of the \s-1DWARF\s0 debug sections in the file, if any -are present. -.IP "\fB\-G\fR" 4 -.IX Item "-G" -.PD 0 -.IP "\fB\-\-stabs\fR" 4 -.IX Item "--stabs" -.PD -Display the full contents of any sections requested. Display the -contents of the .stab and .stab.index and .stab.excl sections from an -\&\s-1ELF\s0 file. This is only useful on systems (such as Solaris 2.0) in which -\&\f(CW\*(C`.stab\*(C'\fR debugging symbol-table entries are carried in an \s-1ELF\s0 -section. In most other file formats, debugging symbol-table entries are -interleaved with linkage symbols, and are visible in the \fB\-\-syms\fR -output. -.IP "\fB\-\-start\-address=\fR\fIaddress\fR" 4 -.IX Item "--start-address=address" -Start displaying data at the specified address. This affects the output -of the \fB\-d\fR, \fB\-r\fR and \fB\-s\fR options. -.IP "\fB\-\-stop\-address=\fR\fIaddress\fR" 4 -.IX Item "--stop-address=address" -Stop displaying data at the specified address. This affects the output -of the \fB\-d\fR, \fB\-r\fR and \fB\-s\fR options. -.IP "\fB\-t\fR" 4 -.IX Item "-t" -.PD 0 -.IP "\fB\-\-syms\fR" 4 -.IX Item "--syms" -.PD -Print the symbol table entries of the file. -This is similar to the information provided by the \fBnm\fR program. -.IP "\fB\-T\fR" 4 -.IX Item "-T" -.PD 0 -.IP "\fB\-\-dynamic\-syms\fR" 4 -.IX Item "--dynamic-syms" -.PD -Print the dynamic symbol table entries of the file. This is only -meaningful for dynamic objects, such as certain types of shared -libraries. This is similar to the information provided by the \fBnm\fR -program when given the \fB\-D\fR (\fB\-\-dynamic\fR) option. -.IP "\fB\-\-special\-syms\fR" 4 -.IX Item "--special-syms" -When displaying symbols include those which the target considers to be -special in some way and which would not normally be of interest to the -user. -.IP "\fB\-V\fR" 4 -.IX Item "-V" -.PD 0 -.IP "\fB\-\-version\fR" 4 -.IX Item "--version" -.PD -Print the version number of \fBobjdump\fR and exit. -.IP "\fB\-x\fR" 4 -.IX Item "-x" -.PD 0 -.IP "\fB\-\-all\-headers\fR" 4 -.IX Item "--all-headers" -.PD -Display all available header information, including the symbol table and -relocation entries. Using \fB\-x\fR is equivalent to specifying all of -\&\fB\-a \-f \-h \-p \-r \-t\fR. -.IP "\fB\-w\fR" 4 -.IX Item "-w" -.PD 0 -.IP "\fB\-\-wide\fR" 4 -.IX Item "--wide" -.PD -Format some lines for output devices that have more than 80 columns. -Also do not truncate symbol names when they are displayed. -.IP "\fB\-z\fR" 4 -.IX Item "-z" -.PD 0 -.IP "\fB\-\-disassemble\-zeroes\fR" 4 -.IX Item "--disassemble-zeroes" -.PD -Normally the disassembly output will skip blocks of zeroes. This -option directs the disassembler to disassemble those blocks, just like -any other data. -.IP "\fB@\fR\fIfile\fR" 4 -.IX Item "@file" -Read command-line options from \fIfile\fR. The options read are -inserted in place of the original @\fIfile\fR option. If \fIfile\fR -does not exist, or cannot be read, then the option will be treated -literally, and not removed. -.Sp -Options in \fIfile\fR are separated by whitespace. A whitespace -character may be included in an option by surrounding the entire -option in either single or double quotes. Any character (including a -backslash) may be included by prefixing the character to be included -with a backslash. The \fIfile\fR may itself contain additional -@\fIfile\fR options; any such options will be processed recursively. -.SH "SEE ALSO" -.IX Header "SEE ALSO" -\&\fInm\fR\|(1), \fIreadelf\fR\|(1), and the Info entries for \fIbinutils\fR. -.SH "COPYRIGHT" -.IX Header "COPYRIGHT" -Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. -.PP -Permission is granted to copy, distribute and/or modify this document -under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 -or any later version published by the Free Software Foundation; -with no Invariant Sections, with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the -section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/update.sh b/gnu/usr.bin/binutils/update.sh deleted file mode 100755 index e5d1a6796f8..00000000000 --- a/gnu/usr.bin/binutils/update.sh +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh -# -# This script installs the main files generated by the binutils -# "configure" scripts and makefiles. It can be used for upgrading to -# a new version of binutils. -# -# Don't forget to change the VERSION definition in the top level -# "Makefile.inc0". - -gnudir=$(pwd) -contribdir="${gnudir}/../../../contrib/binutils" -platform="`uname -m`" - -rm -rf build -mkdir build - -echo "binutils elf configuration for $platform" - -(cd build - ${contribdir}/configure $platform-unknown-freebsd || exit - (cd gas - echo "Updating as" - make config.h || exit - cp config.h ${gnudir}/as/$platform/config.h || exit - ) - (cd ld - echo "Updating ld" - make config.h ldemul-list.h || exit - cp config.h ${gnudir}/ld || exit - cp ldemul-list.h ${gnudir}/ld/$platform || exit - ) - (cd bfd - echo "Updating libbfd" - make bfd.h config.h || exit - cp bfd.h ${gnudir}/libbfd/$platform || exit - cp config.h ${gnudir}/libbfd/$platform || exit - ) - (cd binutils - echo "Updating libbinutils" - make config.h || exit - cp config.h ${gnudir}/libbinutils/config.h || exit - ) - ) - -rm -rf build diff --git a/gnu/usr.bin/cc/Makefile b/gnu/usr.bin/cc/Makefile deleted file mode 100644 index c8d556c8c76..00000000000 --- a/gnu/usr.bin/cc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/Makefile 289393 2015-10-15 22:55:08Z bdrewery $ - -.include - -# The order of some of these are rather important. Some depend on previous -# subdirs. - -SUBDIR= cc_tools .WAIT \ - libiberty libcpp libdecnumber cc_int cc cc1 include - -.if ${MK_CPP} != "no" -SUBDIR+= cpp -.endif - -.if ${MK_CXX} != "no" -SUBDIR+= cc1plus c++ -.endif - -.if ${MK_GCOV} != "no" -SUBDIR+= gcov -.endif - -SUBDIR_DEPEND_c++:= libcpp libiberty -SUBDIR_DEPEND_cc= libcpp libiberty -SUBDIR_DEPEND_cpp= libcpp libiberty -SUBDIR_DEPEND_cc1plus= cc_int libcpp libdecnumber libiberty -SUBDIR_DEPEND_cc1= cc_int libcpp libdecnumber libiberty -SUBDIR_DEPEND_gcov= libiberty - -SUBDIR_PARALLEL= - -.include diff --git a/gnu/usr.bin/cc/Makefile.fe b/gnu/usr.bin/cc/Makefile.fe deleted file mode 100644 index a681510cf02..00000000000 --- a/gnu/usr.bin/cc/Makefile.fe +++ /dev/null @@ -1,29 +0,0 @@ -# $FreeBSD$ - -# Front-end-only bits - -.include "Makefile.ver" - -# -# These were previously defined in gcc.c. Just copy previous values from -# there. We ifdef most of them out for FREEBSD_NATIVE builds anyway. -# gcc.c won't compile without them though. -DRIVER_DEFINES = -DGCC_DRIVER \ - -DDEFAULT_TARGET_VERSION=\"$(BASEVER)\" \ - -DDEFAULT_TARGET_MACHINE=\"$(GCC_TARGET)\" \ - -DENABLE_SHARED_LIBGCC - -CFLAGS+= ${DRIVER_DEFINES} - -.PATH: ../cc_tools ${GCCDIR} ${GCCDIR}/doc ${GCCDIR}/config/${GCC_CPU} - -SRCS= gcc.c opts-common.c options.c intl.c prefix.c version.c - -# Include -march=native support for native-ish compilers only -.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64") && \ - ${GCC_CPU} == "i386" -SRCS+= driver-${GCC_CPU}.c -.endif - -DPADD= ${LIBCPP} ${LIBIBERTY} -LDADD= ${LIBCPP} ${LIBIBERTY} diff --git a/gnu/usr.bin/cc/Makefile.inc b/gnu/usr.bin/cc/Makefile.inc deleted file mode 100644 index cbd690e9e18..00000000000 --- a/gnu/usr.bin/cc/Makefile.inc +++ /dev/null @@ -1,115 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/Makefile.inc 272350 2014-10-01 08:26:51Z andrew $ - -.include -.include "../Makefile.inc" - -# Sometimes this is .include'd several times... -.if !defined(__CC_MAKEFILE_INC__) -__CC_MAKEFILE_INC__= ${MFILE} - -GCCVER= 4.2 -GCCDIR= ${SRCTOP}/contrib/gcc -GCCLIB= ${SRCTOP}/contrib/gcclibs - -.include "Makefile.tgt" - -# Machine description. -MD_FILE= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.md -GCC_TARGET= ${TARGET_ARCH}-midnightbsd-freebsd - -CFLAGS+= -DGCCVER=\"${GCCVER}\" -CFLAGS+= -DIN_GCC -DHAVE_CONFIG_H -CFLAGS+= -DPREFIX=\"${TOOLS_PREFIX}/usr\" -#CFLAGS+= -DWANT_COMPILER_INVARIANTS -CSTD?= gnu89 - -.if ${TARGET_ARCH} != ${MACHINE_ARCH} -CFLAGS+= -DCROSS_DIRECTORY_STRUCTURE -CFLAGS+= -DTARGET_SYSTEM_ROOT=\"${TOOLS_PREFIX}\" -.endif - -.if ${TARGET_CPUARCH} == "arm" -CFLAGS+= -DTARGET_ARM_EABI -.endif - -.if ${TARGET_ARCH:Marm*eb} != "" -CFLAGS += -DTARGET_ENDIAN_DEFAULT=MASK_BIG_END -.endif -.if ${TARGET_ARCH:Marmv6*} != "" -CFLAGS += -DFREEBSD_ARCH_armv6 -.endif -.if ${TARGET_ARCH:Marmv7*} != "" -CFLAGS += -DFREEBSD_ARCH_armv7 -.endif - -.if ${TARGET_CPUARCH} == "mips" -.if ${TARGET_ARCH:Mmips*el*} != "" -CFLAGS += -DTARGET_ENDIAN_DEFAULT=0 -.endif - -.if ${TARGET_ARCH:Mmips64*} != "" -MIPS_ABI_DEFAULT=ABI_64 -.elif ${TARGET_ARCH:Mmipsn32*} != "" -MIPS_ABI_DEFAULT=ABI_N32 -.else -MIPS_ABI_DEFAULT=ABI_32 -.endif -CFLAGS += -DMIPS_ABI_DEFAULT=${MIPS_ABI_DEFAULT} - -# If we are compiling for the O32 ABI, we need to default to MIPS-III rather -# than taking the ISA from the ABI requirements, since FreeBSD is built with -# a number of MIPS-III features/instructions and that is the minimum ISA we -# support, not the O32 default MIPS-I. -.if ${MIPS_ABI_DEFAULT} == "ABI_32" -TARGET_CPUTYPE?=mips3 -.endif - -# GCC by default takes the ISA from the ABI's requirements. If world is built -# with a superior ISA, since we lack multilib, we have to set the right -# default ISA to be able to link against what's in /usr/lib. Terrible stuff. -.if defined(TARGET_CPUTYPE) -CFLAGS += -DMIPS_CPU_STRING_DEFAULT=\"${TARGET_CPUTYPE}\" -.endif -.endif - -.if defined(WANT_FORCE_OPTIMIZATION_DOWNGRADE) -CFLAGS+= -DFORCE_OPTIMIZATION_DOWNGRADE=${WANT_FORCE_OPTIMIZATION_DOWNGRADE} -.endif - -.if exists(${.OBJDIR}/../cc_tools) -CFLAGS+= -I${.OBJDIR}/../cc_tools -.endif -CFLAGS+= -I${.CURDIR}/../cc_tools -# This must go after the -I for cc_tools to resolve ambiguities for hash.h -# correctly. -CFLAGS+= -I${GCCDIR} -I${GCCDIR}/config - -CFLAGS+= -I${GCCLIB}/include -CFLAGS+= -I${GCCLIB}/libcpp/include -CFLAGS+= -I${GCCLIB}/libdecnumber - -.if exists(${.OBJDIR}/../cc_int) -LIBBACKEND= ${.OBJDIR}/../cc_int/libbackend.a -.else -LIBBACKEND= ${.CURDIR}/../cc_int/libbackend.a -.endif - -.if exists(${.OBJDIR}/../libiberty) -LIBIBERTY= ${.OBJDIR}/../libiberty/libiberty.a -.else -LIBIBERTY= ${.CURDIR}/../libiberty/libiberty.a -.endif - -.if exists(${.OBJDIR}/../libcpp) -LIBCPP= ${.OBJDIR}/../libcpp/libcpp.a -.else -LIBCPP= ${.CURDIR}/../libcpp/libcpp.a -.endif - -.if exists(${.OBJDIR}/../libdecnumber) -LIBDECNUMBER= ${.OBJDIR}/../libdecnumber/libdecnumber.a -.else -LIBDECNUMBER= ${.CURDIR}/../libdecnumber/libdecnumber.a -.endif - -.endif # !__CC_MAKEFILE_INC__ diff --git a/gnu/usr.bin/cc/Makefile.tgt b/gnu/usr.bin/cc/Makefile.tgt deleted file mode 100644 index b1a7f1608c7..00000000000 --- a/gnu/usr.bin/cc/Makefile.tgt +++ /dev/null @@ -1,23 +0,0 @@ -# $FreeBSD$ - -# These assignments duplicate much of the functionality of -# MACHINE_CPUARCH, but there's no easy way to export make functions... - -.if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} -.else -TARGET_CPUARCH=${MACHINE_CPUARCH} -.endif -TARGET_ARCH?= ${MACHINE_ARCH} -GCC_CPU=${TARGET_CPUARCH:C/amd64/i386/:C/powerpc/rs6000/:C/sparc64/sparc/} - -.if ${TARGET_ARCH} == "sparc64" -TARGET_CPU_DEFAULT= TARGET_CPU_ultrasparc -.endif -.if ${TARGET_ARCH:Marm*eb} != "" || \ - (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el*} == "") -TARGET_BIG_ENDIAN=t -.endif -.if ${TARGET_ARCH} == "powerpc64" -TARGET_CPU_DEFAULT= \"powerpc64\" -.endif diff --git a/gnu/usr.bin/cc/Makefile.ver b/gnu/usr.bin/cc/Makefile.ver deleted file mode 100644 index 6ccdc03e29b..00000000000 --- a/gnu/usr.bin/cc/Makefile.ver +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/Makefile.ver 226702 2011-10-24 20:52:41Z obrien $ - -BASEVER!= cat ${GCCDIR}/BASE-VER -DATESTAMP!= cat ${GCCDIR}/DATESTAMP -DEVPHASE!= cat ${GCCDIR}/DEV-PHASE - -version.o: version.c ${GCCDIR}/BASE-VER ${GCCDIR}/DATESTAMP ${GCCDIR}/DEV-PHASE - ${CC} ${CFLAGS} -DBASEVER=\"${BASEVER}\" \ - -DDATESTAMP=\"\ ${DATESTAMP}\" \ - -DDEVPHASE=\"\ ${DEVPHASE}\" -c ${.IMPSRC} diff --git a/gnu/usr.bin/cc/c++/Makefile b/gnu/usr.bin/cc/c++/Makefile deleted file mode 100644 index a03f8d7ecdd..00000000000 --- a/gnu/usr.bin/cc/c++/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/c++/Makefile 265420 2014-05-06 04:22:01Z imp $ - -MAN= -.include - -.include "../Makefile.inc" -.include "../Makefile.fe" - -.PATH: ${GCCDIR}/cp - -PROG= g++ -SRCS+= g++spec.c - -DPADD= ${LIBCPP} ${LIBIBERTY} -LDADD= ${LIBCPP} ${LIBIBERTY} - -.if ${MK_CLANG_IS_CC} == "no" -LINKS= ${BINDIR}/g++ ${BINDIR}/c++ -LINKS+= ${BINDIR}/g++ ${BINDIR}/CC -.endif - -.include diff --git a/gnu/usr.bin/cc/c++/Makefile.depend b/gnu/usr.bin/cc/c++/Makefile.depend deleted file mode 100644 index 2bea3c0fa88..00000000000 --- a/gnu/usr.bin/cc/c++/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/cc/cc_tools \ - gnu/usr.bin/cc/libcpp \ - gnu/usr.bin/cc/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cc/Makefile b/gnu/usr.bin/cc/cc/Makefile deleted file mode 100644 index 62fcec4a9bc..00000000000 --- a/gnu/usr.bin/cc/cc/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/cc/Makefile 265420 2014-05-06 04:22:01Z imp $ - -.include - -.include "../Makefile.inc" -.include "../Makefile.fe" - -PROG= gcc -MAN= gcc.1 -SRCS+= gccspec.c - -.if ${MK_SHARED_TOOLCHAIN} == "no" -NO_SHARED?=yes -.endif - -MLINKS= gcc.1 g++.1 -.if ${MK_CLANG_IS_CC} == "no" -LINKS= ${BINDIR}/gcc ${BINDIR}/cc -MLINKS+= gcc.1 cc.1 gcc.1 c++.1 gcc.1 CC.1 -.endif - -.include diff --git a/gnu/usr.bin/cc/cc/Makefile.depend b/gnu/usr.bin/cc/cc/Makefile.depend deleted file mode 100644 index 2bea3c0fa88..00000000000 --- a/gnu/usr.bin/cc/cc/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/cc/cc_tools \ - gnu/usr.bin/cc/libcpp \ - gnu/usr.bin/cc/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cc1/Makefile b/gnu/usr.bin/cc/cc1/Makefile deleted file mode 100644 index 7b2ec040ecd..00000000000 --- a/gnu/usr.bin/cc/cc1/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# $FreeBSD$ - -MAN= -.include - -.include "../Makefile.inc" - -.PATH: ${GCCDIR} - -PROG= cc1 -SRCS= main.c c-parser.c c-lang.c -BINDIR= ${LIBEXECDIR} -.if ${MK_SHARED_TOOLCHAIN} == "no" -NO_SHARED?=yes -.endif - -OBJS+= ${PROG}-checksum.o -DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} -LDADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} - -DOBJS+= ${SRCS:N*.h:R:S/$/.o/g} -${PROG}-dummy: ${DOBJS} - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${DOBJS} ${LDADD} -CLEANFILES+= ${PROG}-dummy - -${PROG}-checksum.c: ${PROG}-dummy - ../cc_tools/genchecksum ${PROG}-dummy > ${.TARGET} -CLEANFILES+= ${PROG}-checksum.c - -.include diff --git a/gnu/usr.bin/cc/cc1/Makefile.depend b/gnu/usr.bin/cc/cc1/Makefile.depend deleted file mode 100644 index 54acaaf4b5b..00000000000 --- a/gnu/usr.bin/cc/cc1/Makefile.depend +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/cc/cc_int \ - gnu/usr.bin/cc/cc_tools \ - gnu/usr.bin/cc/libcpp \ - gnu/usr.bin/cc/libdecnumber \ - gnu/usr.bin/cc/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cc1plus/Makefile b/gnu/usr.bin/cc/cc1plus/Makefile deleted file mode 100644 index 1d928745312..00000000000 --- a/gnu/usr.bin/cc/cc1plus/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# $FreeBSD$ - -MAN= -.include - -.include "../Makefile.inc" - -.PATH: ${GCCDIR}/cp ${GCCDIR} - -PROG= cc1plus -SRCS= cfns.h -SRCS+= main.c cp-lang.c c-opts.c call.c class.c cvt.c cxx-pretty-print.c \ - decl.c decl2.c error.c except.c expr.c dump.c friend.c init.c lex.c \ - mangle.c method.c name-lookup.c parser.c pt.c ptree.c repo.c rtti.c \ - search.c semantics.c tree.c typeck.c typeck2.c optimize.c \ - cp-objcp-common.c cp-gimplify.c tree-mudflap.c - -BINDIR= ${LIBEXECDIR} -.if ${MK_SHARED_TOOLCHAIN} == "no" -NO_SHARED?=yes -.endif - -CFLAGS+= -I${GCCDIR}/cp -I. - -OBJS+= ${PROG}-checksum.o -DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} -LDADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} - -#----------------------------------------------------------------------- -# C++ parser -cfns.h: cfns.gperf - gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \ - ${.ALLSRC} > ${.TARGET} || (rm -f ${.TARGET}; false) -CLEANFILES= cfns.h - -DOBJS+= ${SRCS:N*.h:R:S/$/.o/g} -${PROG}-dummy: ${DOBJS} - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${DOBJS} ${LDADD} -CLEANFILES+= ${PROG}-dummy - -${PROG}-checksum.c: ${PROG}-dummy - ../cc_tools/genchecksum ${PROG}-dummy > ${.TARGET} -CLEANFILES+= ${PROG}-checksum.c - -.include diff --git a/gnu/usr.bin/cc/cc1plus/Makefile.depend b/gnu/usr.bin/cc/cc1plus/Makefile.depend deleted file mode 100644 index 7615829e9d1..00000000000 --- a/gnu/usr.bin/cc/cc1plus/Makefile.depend +++ /dev/null @@ -1,23 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/cc/cc_int \ - gnu/usr.bin/cc/cc_tools \ - gnu/usr.bin/cc/libcpp \ - gnu/usr.bin/cc/libdecnumber \ - gnu/usr.bin/cc/libiberty \ - gnu/usr.bin/gperf.host \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cc_int/Makefile b/gnu/usr.bin/cc/cc_int/Makefile deleted file mode 100644 index 33808a53689..00000000000 --- a/gnu/usr.bin/cc/cc_int/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -# $FreeBSD$ - -.include - -.include "../Makefile.inc" -.include "../Makefile.ver" - -.PATH: ../cc_tools ${GCCDIR} ${GCCDIR}/config/${GCC_CPU} - -LIB= backend -INTERNALLIB= - -EXTRA_OBJS= -GGC= ggc-page.o -host_hook_obj= host-default.o - -# -# Most lists copied verbatim from GCC Makefiles. -# -OBJS-common = \ - double-int.o tree-chrec.o tree-scalar-evolution.o tree-data-ref.o \ - tree-cfg.o tree-dfa.o tree-eh.o tree-ssa.o tree-optimize.o tree-gimple.o \ - gimplify.o tree-pretty-print.o tree-into-ssa.o \ - tree-outof-ssa.o tree-ssa-ccp.o tree-vn.o tree-ssa-uncprop.o \ - tree-ssa-dce.o tree-ssa-copy.o tree-nrv.o tree-ssa-copyrename.o \ - tree-ssa-pre.o tree-ssa-live.o tree-ssa-operands.o tree-ssa-alias.o \ - tree-ssa-alias-warnings.o \ - tree-ssa-phiopt.o tree-ssa-forwprop.o tree-nested.o tree-ssa-dse.o \ - tree-ssa-dom.o domwalk.o tree-tailcall.o gimple-low.o tree-iterator.o \ - omp-low.o tree-phinodes.o tree-ssanames.o tree-sra.o tree-complex.o \ - tree-vect-generic.o tree-ssa-loop.o tree-ssa-loop-niter.o \ - tree-ssa-loop-manip.o tree-ssa-threadupdate.o tree-ssa-threadedge.o \ - tree-vectorizer.o tree-vect-analyze.o tree-vect-transform.o \ - tree-vect-patterns.o tree-ssa-loop-prefetch.o \ - tree-ssa-loop-ivcanon.o tree-ssa-propagate.o tree-ssa-address.o \ - tree-ssa-math-opts.o \ - tree-ssa-loop-ivopts.o tree-if-conv.o tree-ssa-loop-unswitch.o \ - alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \ - cfg.o cfganal.o cfgbuild.o cfgcleanup.o cfglayout.o cfgloop.o \ - cfgloopanal.o cfgloopmanip.o loop-init.o loop-unswitch.o loop-unroll.o \ - cfgrtl.o combine.o conflict.o convert.o coverage.o cse.o cselib.o \ - dbxout.o ddg.o tree-ssa-loop-ch.o loop-invariant.o tree-ssa-loop-im.o \ - debug.o df-core.o df-problems.o df-scan.o dfp.o diagnostic.o dojump.o \ - dominance.o loop-doloop.o \ - dwarf2asm.o dwarf2out.o emit-rtl.o except.o explow.o loop-iv.o \ - expmed.o expr.o final.o flow.o fold-const.o function.o gcse.o \ - genrtl.o ggc-common.o global.o graph.o gtype-desc.o \ - haifa-sched.o hooks.o ifcvt.o insn-attrtab.o insn-emit.o insn-modes.o \ - insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o \ - integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o \ - mode-switching.o modulo-sched.o optabs.o options.o opts.o opts-common.o \ - params.o postreload.o postreload-gcse.o predict.o \ - insn-preds.o insn-automata.o pointer-set.o \ - print-rtl.o print-tree.o profile.o value-prof.o var-tracking.o \ - real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \ - reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \ - sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o \ - see.o simplify-rtx.o sreal.o stmt.o stor-layout.o stringpool.o \ - struct-equiv.o targhooks.o timevar.o toplev.o tracer.o tree.o tree-dump.o \ - varasm.o varray.o vec.o version.o vmsdbgout.o xcoffout.o alloc-pool.o \ - et-forest.o cfghooks.o bt-load.o pretty-print.o $(GGC) web.o passes.o \ - tree-profile.o rtlhooks.o cfgexpand.o lambda-mat.o \ - lambda-trans.o lambda-code.o tree-loop-linear.o tree-ssa-sink.o \ - tree-vrp.o tree-stdarg.o tree-cfgcleanup.o tree-ssa-reassoc.o \ - tree-ssa-structalias.o tree-object-size.o \ - rtl-factoring.o - -OBJS-archive= $(EXTRA_OBJS) $(host_hook_obj) tree-inline.o \ - cgraph.o cgraphunit.o tree-nomudflap.o ipa.o ipa-inline.o \ - ipa-utils.o ipa-reference.o ipa-pure-const.o ipa-type-escape.o \ - ipa-prop.o ipa-cp.o - -OBJS-md= ${GCC_CPU}.o -.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-c.c) -OBJS-md+= ${GCC_CPU}-c.o -.endif - -# Target specific, C specific object file -C_TARGET_OBJS= - -# Language-specific object files for C and Objective C. -C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \ - c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \ - c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \ - c-objc-common.o c-dump.o c-pch.o c-parser.o $(C_TARGET_OBJS) \ - c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o - -# Language-specific object files for C. -C_OBJS = c-lang.o stub-objc.o $(C_AND_OBJC_OBJS) - -# Put objC stub objects in library. objc frontend will override it -# Put dummy checksum object in library too. It will be overridden -# by each indidual front-end binary as needed. -OBJS-dummy= stub-objc.o dummy-checksum.o - -OBJS-all= ${OBJS-common} ${OBJS-archive} ${OBJS-md} ${C_AND_OBJC_OBJS} \ - ${OBJS-dummy} - -SRCS+= ${OBJS-all:R:S/$/.c/g} - -toplev.o: toplev.c - ${CC} ${CFLAGS} -DTARGET_NAME=\"${GCC_TARGET}\" -c ${.IMPSRC} - -# make sure we don't find .o's in ../cc_tools/ -CLEANFILES+= ${OBJS-all} - -.include diff --git a/gnu/usr.bin/cc/cc_int/Makefile.depend b/gnu/usr.bin/cc/cc_int/Makefile.depend deleted file mode 100644 index ea841fdbb8d..00000000000 --- a/gnu/usr.bin/cc/cc_int/Makefile.depend +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/usr.bin/cc/cc_tools \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cc_tools/Makefile b/gnu/usr.bin/cc/cc_tools/Makefile deleted file mode 100644 index 2e5ff3884b1..00000000000 --- a/gnu/usr.bin/cc/cc_tools/Makefile +++ /dev/null @@ -1,445 +0,0 @@ -# $FreeBSD$ - -.include - -CFLAGS+= -I. - -.include "../Makefile.inc" -# Some of the logic needed in here is defined in Makefile.hdrs as it is shared -# with gnu/lib. -.include "Makefile.hdrs" - -CFLAGS+= -g -CFLAGS+= -DGENERATOR_FILE -DHAVE_CONFIG_H - -# Override LIBIBERTY set by Makefile.inc, We use our own for -# build tools. -LIBIBERTY= libiberty.a - -.PATH: ${GCCDIR} ${GCCLIB}/libiberty - -#----------------------------------------------------------------------- -# Determine content of variables used by the target/host config files - -# -# The list of headers to go into tm.h -# -.for H in ${TARGET_INC} -.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR} -.if exists($D/$H) -TARGET_INC_FILES+= $D/$H -.endif -.endfor -.endfor - -# -# gtyp includes. -# -srcdir= ${GCCDIR} -CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \ - ${GCCLIB}/libcpp/include/cpplib.h -SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h -CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h -HASHTAB_H= ${GCCLIB}/include/hashtab.h -SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h -out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c -tm_file_list= ${TARGET_INC_FILES} -host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h -GTFILES_SRCDIR= ${srcdir} - -# Copied unchanged from gcc/Makefile.in -GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \ - $(CPP_ID_DATA_H) $(host_xm_file_list) \ - $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \ - $(srcdir)/coverage.c $(srcdir)/rtl.h \ - $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \ - $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \ - $(srcdir)/ipa-reference.h $(srcdir)/output.h \ - $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \ - $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \ - $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ - $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \ - $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \ - $(srcdir)/dojump.c $(srcdir)/tree-profile.c \ - $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \ - $(srcdir)/function.c $(srcdir)/except.h \ - $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \ - $(srcdir)/profile.c $(srcdir)/regclass.c \ - $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \ - $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \ - $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \ - $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \ - $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \ - $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \ - $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \ - $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \ - $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \ - $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \ - $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \ - $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \ - $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \ - $(srcdir)/tree-ssa-structalias.c \ - $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \ - $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \ - -# The list of frontend directories to look into -GTFILES_LANG_DIR_NAMES= - -.if ${MK_CXX} != "no" -GTFILES_LANG_DIR_NAMES+= cp -.endif - -# The list of language specific files for gengtype -.for L in ${GTFILES_LANG_DIR_NAMES} c -.if exists(${GCCDIR}/$L-config-lang.in) -# Source the language config file -L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' -.else -L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' -.endif -.for F in ${L_GTFILES} -GTFILES_FILES+= $F -GTFILES_LANGS+= $L -.endfor -.endfor -GTFILES+= ${GTFILES_FILES} - -# -# Tree definition files. -# -TREE_DEF_FILES= - -.if ${MK_CXX} != "no" -TREE_DEF_FILES+= cp/cp-tree.def -.endif - -#----------------------------------------------------------------------- -# Build rules for header files and generator tools - -# Host config -config.h: - TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ - HEADERS="auto-host.h ansidecl.h" \ - DEFINES="" \ - /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} - -GENSRCS+= config.h -CLEANFILES+= cs-config.h - -# Build config -bconfig.h: - TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ - HEADERS="auto-host.h ansidecl.h" \ - DEFINES="" \ - /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} -.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) - echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} -.endif - -GENSRCS+= bconfig.h -CLEANFILES+= cs-bconfig.h - -# tconfig.h -GENSRCS+= tconfig.h -CLEANFILES+= cs-tconfig.h - -# Options -GENONLY+= optionlist options.h options.c - -# Target machine config -GENSRCS+= tm.h -CLEANFILES+= cs-tm.h - -# Target machine protos/preds. -tm_p.h: - TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ - HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \ - DEFINES="" \ - /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h - -GENSRCS+= tm_p.h -CLEANFILES+= cs-tm_p.h - -# gencheck -gencheck.h: ${TREE_DEF_FILES} -.for F in ${TREE_DEF_FILES} - echo "#include \"$F\"" >> ${.TARGET} -.endfor - touch ${.TARGET} - -GENSRCS+= gencheck.h - - -# Source header for gtyp generator. -gtyp-gen.h: ${GTFILES} - echo "/* This file is machine generated. Do not edit. */" > ${.TARGET} - echo "static const char * const srcdir = " >> ${.TARGET} - echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET} - echo "static const char * const lang_files[] = {" >> ${.TARGET} -.for F in ${GTFILES_FILES} - echo "\"$F\", " >> ${.TARGET} -.endfor - echo "NULL};" >> ${.TARGET} - echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET} -.for F in ${GTFILES_LANGS} - echo "\"$F\", " >> ${.TARGET} -.endfor - echo "NULL};" >> ${.TARGET} - echo "static const char * const all_files[] = {" >> ${.TARGET} -.for F in ${GTFILES} - echo "\"$F\", " >> ${.TARGET} -.endfor - echo "NULL};" >> ${.TARGET} - echo "static const char * const lang_dir_names[] = {" >> ${.TARGET} -.for F in c ${GTFILES_LANG_DIR_NAMES} - echo "\"$F\", " >> ${.TARGET} -.endfor - echo "NULL};" >> ${.TARGET} - -GENSRCS+= gtyp-gen.h - -# Version header for gcov -GENSRCS+= gcov-iov.h - -# Multilib config file -multilib.h: -.if ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH} == "amd64" - echo 'static const char *const multilib_raw[] = { \ - ". !m64 !m32;", \ - "64:../lib m64 !m32;", \ - "32:../lib32 !m64 m32;", NULL };' > ${.TARGET} - echo 'static const char *multilib_options = "m64/m32";' >> ${.TARGET} - echo 'static const char *const multilib_matches_raw[] = { \ - "m64 m64;", "m32 m32;", NULL };' >> ${.TARGET} -.else - echo 'static const char *const multilib_raw[] = { \ - ". ;", NULL };' > ${.TARGET} - echo 'static const char *multilib_options = "";' >> ${.TARGET} - echo 'static const char *const multilib_matches_raw[] = { \ - NULL };' >> ${.TARGET} -.endif - echo 'static const char *multilib_extra = "";' >> ${.TARGET} - echo 'static const char *const multilib_exclusions_raw[] = { \ - NULL };' >> ${.TARGET} - -GENSRCS+= multilib.h - -configargs.h: - echo 'static const char configuration_arguments[] =' > ${.TARGET} - echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET} - echo 'static const char thread_model[] = "posix";' >> ${.TARGET} - echo 'static const struct {' >> ${.TARGET} - echo ' const char *name, *value;' >> ${.TARGET} - echo '} configure_default_options[] = {' >> ${.TARGET} - echo ' { "NULL", "NULL" } };' >> ${.TARGET} - -GENSRCS+= configargs.h - -# Language spec files -specs.h: - echo '#include "cp/lang-specs.h"' > ${.TARGET} - -GENSRCS+= specs.h - -gstdint.h: - echo '#include "sys/types.h"' > ${.TARGET} - echo '#include "sys/stdint.h"' >> ${.TARGET} - -GENSRCS+= gstdint.h - -# Linked headers -GENSRCS+= gthr-default.h - -GENSRCS+= unwind.h - -# -# gtype gunk -# -gengtype-lex.c: gengtype-lex.l - flex -ogengtype-lex.c ${.ALLSRC} - -gengtype-yacc.h: gengtype-yacc.y - yacc -d -o gengtype-yacc.c ${.ALLSRC} - -gengtype-yacc.c: gengtype-yacc.h .NOMETA - -gengtype-yacc+%DIKED.c: gengtype-yacc.c - cat ${.ALLSRC} > ${.TARGET} - sed -e "s/xmalloc/malloc/g" \ - -e "s/xrealloc/realloc/g" \ - -e "s/malloc/xmalloc/g" \ - -e "s/realloc/xrealloc/g" \ - ${.ALLSRC} > ${.TARGET} - -GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c -CLEANFILES+= gengtype-yacc.c - -gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \ - ${LIBIBERTY} - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} - -gtype-desc.h: gengtype - ${BTOOLSPATH:U.}/gengtype - touch ${.TARGET} - -gtype-desc.c: gtype-desc.h - -GENONLY+= gtype-desc.c gtype-desc.h -CLEANFILES+= gt-*.h gtype-*.h - -# -# Generator tools. -# -.for F in check checksum genrtl modes -gen$F: gen$F.o errors.o ${LIBIBERTY} - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -.endfor - -.for F in attr attrtab automata codes conditions config constants emit \ - extract flags opinit output peep preds recog -gen$F: gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \ - gensupport.o print-rtl.o errors.o ${LIBIBERTY} - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm -.endfor - -gencondmd: gencondmd.o - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} - -# -# Generated .md files. -# -insn-conditions.md: gencondmd - ${BTOOLSPATH:U.}/gencondmd > ${.TARGET} -GENSRCS+= insn-conditions.md - -# -# Generated header files. -# - -.for F in constants -insn-$F.h: gen$F ${MD_FILE} - ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET} -GENSRCS+= insn-$F.h -.endfor - -.for F in attr codes config flags -insn-$F.h: gen$F ${MD_FILE} insn-conditions.md - ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} -GENSRCS+= insn-$F.h -.endfor - -# Header files with irregular names. -genrtl.h: gengenrtl - ${BTOOLSPATH:U.}/gengenrtl -h > ${.TARGET} -GENSRCS+= genrtl.h - -tm-preds.h: genpreds - ${BTOOLSPATH:U.}/genpreds -h ${MD_FILE} > ${.TARGET} -GENSRCS+= tm-preds.h - -tm-constrs.h: genpreds - ${BTOOLSPATH:U.}/genpreds -c ${MD_FILE} > ${.TARGET} -GENSRCS+= tm-constrs.h - -tree-check.h: gencheck - ${BTOOLSPATH:U.}/gencheck > ${.TARGET} -GENSRCS+= tree-check.h - -insn-modes.h: genmodes - ${BTOOLSPATH:U.}/genmodes -h > ${.TARGET} -GENSRCS+= insn-modes.h - -# -# Generated source files. -# -.for F in attrtab automata emit extract opinit output peep preds recog -insn-$F.c: gen$F ${MD_FILE} insn-conditions.md - ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} -GENONLY+= insn-$F.c -.endfor - -.for F in conditions -insn-$F.c: gen$F ${MD_FILE} - ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET} -GENSRCS+= insn-$F.c -.endfor - -# Source files with irregular names. -insn-modes.c: genmodes - ${BTOOLSPATH:U.}/genmodes > ${.TARGET} -GENONLY+= insn-modes.c - -min-insn-modes.c: genmodes - ${BTOOLSPATH:U.}/genmodes -m > ${.TARGET} -GENSRCS+= min-insn-modes.c - -genrtl.c: gengenrtl - ${BTOOLSPATH:U.}/gengenrtl > ${.TARGET} -GENONLY+= genrtl.c - -gencondmd.c: genconditions ${MD_FILE} - ${BTOOLSPATH:U.}/genconditions ${MD_FILE} > ${.TARGET} -GENSRCS+= gencondmd.c - -#----------------------------------------------------------------------- -# Build tools. - -GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \ - genconditions gencondmd genconfig genconstants genemit \ - genextract genflags gengenrtl gengtype genmodes genopinit \ - genoutput genpeep genpreds genrecog - -${GNTOOLS:C,$,.o,} ${GNTOOLS}: ${BUILD_TOOLS_META} -all: ${GNTOOLS} ${GENSRCS} ${GENONLY} -build-tools: all -beforedepend: ${GENONLY} - -# -#----------------------------------------------------------------------- -# Build 'pocket' libiberty exclusively for build tools use. - -LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ - dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \ - hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \ - partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \ - xmalloc.c xmemdup.c xstrdup.c xstrerror.c -LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g} - -.for _src in ${LIBIBERTY_SRCS} -${_src:R:S/$/.o/}: ${_src} ${BUILD_TOOLS_META} - ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC} -.endfor - -${LIBIBERTY}: ${LIBIBERTY_OBJS} ${BUILD_TOOLS_META} - @rm -f ${.TARGET} - @${AR} ${ARFLAGS} ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` - ${RANLIB} ${.TARGET} -CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS} - - -#----------------------------------------------------------------------- -# Fixups. - -# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't -# define PROG because we have multiple programs. -# -SRCS= errors.c genattr.c genattrtab.c \ - genautomata.c gencheck.c genchecksum.c gencodes.c \ - genconditions.c genconfig.c genconstants.c genemit.c \ - genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \ - genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \ - gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \ - vec.c - -SRCS+= ${GENSRCS} -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g} -${OBJS} ${GENOBJS}: ${BUILD_TOOLS_META} -CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS} - -#----------------------------------------------------------------------- -# Manual dependencies. -.include "Makefile.dep" - -.include -# DO NOT DELETE diff --git a/gnu/usr.bin/cc/cc_tools/Makefile.dep b/gnu/usr.bin/cc/cc_tools/Makefile.dep deleted file mode 100644 index a1a848b2413..00000000000 --- a/gnu/usr.bin/cc/cc_tools/Makefile.dep +++ /dev/null @@ -1,153 +0,0 @@ -# $FreeBSD$ - -OBJS_DEPEND_GUESS.errors.o+= bconfig.h auto-host.h - -OBJS_DEPEND_GUESS.genattr.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genattrtab.o+= bconfig.h \ - auto-host.h \ - tm.h options.h \ - insn-modes.h \ - gtype-desc.h - -OBJS_DEPEND_GUESS.genautomata.o+= bconfig.h \ - auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.gencheck.o+= bconfig.h auto-host.h \ - tm.h options.h \ - gencheck.h - -OBJS_DEPEND_GUESS.genchecksum.o+= bconfig.h \ - auto-host.h - -OBJS_DEPEND_GUESS.gencodes.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genconditions.o+= bconfig.h \ - auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genconfig.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genconstants.o+= bconfig.h \ - auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genemit.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genextract.o+= bconfig.h \ - auto-host.h \ - tm.h options.h \ - insn-modes.h \ - insn-config.h - -OBJS_DEPEND_GUESS.genflags.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.gengenrtl.o+= bconfig.h auto-host.h - -OBJS_DEPEND_GUESS.gengtype.o+= bconfig.h auto-host.h \ - tm.h options.h \ - gtyp-gen.h - -OBJS_DEPEND_GUESS.genmddeps.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genmodes.o+= bconfig.h auto-host.h - -OBJS_DEPEND_GUESS.genopinit.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genoutput.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genpeep.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genpreds.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.genrecog.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.gensupport.o+= bconfig.h \ - auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.ggc-none.o+= bconfig.h auto-host.h \ - gtype-desc.h - -OBJS_DEPEND_GUESS.print-rtl.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.read-rtl.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.rtl.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-modes.h \ - gtype-desc.h - -OBJS_DEPEND_GUESS.insn-modes.o+= insn-modes.c config.h auto-host.h \ - tm.h options.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.min-insn-modes.o+= bconfig.h auto-host.h \ - insn-modes.h - -OBJS_DEPEND_GUESS.gengtype-lex.o+= \ - bconfig.h auto-host.h \ - gengtype-yacc.h - -OBJS_DEPEND_GUESS.gengtype-yacc+%DIKED.o+= \ - bconfig.h \ - auto-host.h \ - tm.h options.h \ - -OBJS_DEPEND_GUESS.insn-conditions.o+= insn-conditions.c bconfig.h auto-host.h \ - insn-constants.h \ - tm.h options.h \ - insn-modes.h \ - tm_p.h \ - tm-preds.h \ - options.h - -OBJS_DEPEND_GUESS.gencondmd.o+= \ - tm.h options.h tm_p.h \ - tm-preds.h tm-constrs.h tree-check.h \ - insn-constants.h - -OBJS_DEPEND_GUESS.gencondmd.o+= bconfig.h auto-host.h \ - tm.h options.h \ - insn-constants.h \ - insn-modes.h \ - tm_p.h \ - tm-preds.h \ - tree-check.h \ - tm-constrs.h - -OBJS_DEPEND_GUESS.vec.o+= bconfig.h auto-host.h \ - insn-modes.h \ - tree-check.h \ - gtype-desc.h diff --git a/gnu/usr.bin/cc/cc_tools/Makefile.depend b/gnu/usr.bin/cc/cc_tools/Makefile.depend deleted file mode 100644 index 7e06312d1eb..00000000000 --- a/gnu/usr.bin/cc/cc_tools/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/msun \ - usr.bin/yacc.host \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cc_tools/Makefile.hdrs b/gnu/usr.bin/cc/cc_tools/Makefile.hdrs deleted file mode 100644 index f2576f7fdf0..00000000000 --- a/gnu/usr.bin/cc/cc_tools/Makefile.hdrs +++ /dev/null @@ -1,136 +0,0 @@ -# $FreeBSD$ -# -# This is logic for common headers shared inside of gnu/lib. It used to -# live in gnu/usr.bin/cc/cc_tools/Makefile. - -.if !defined(TARGET_CPUARCH) || !defined(GCC_CPU) -.error ${.CURDIR}: Must include gnu/usr.bin/cc/Makefile.tgt first. -.endif - -# -# The list of headers to go into tm.h -# -TARGET_INC+= options.h -.if ${TARGET_CPUARCH} == "amd64" -TARGET_INC+= i386/biarch64.h -.endif -.if ${TARGET_CPUARCH} != "arm" -TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h -.endif -.if ${TARGET_CPUARCH} == "i386" || ${TARGET_CPUARCH} == "amd64" -TARGET_INC+= ${GCC_CPU}/unix.h -TARGET_INC+= ${GCC_CPU}/att.h -.endif -TARGET_INC+= dbxelf.h -TARGET_INC+= elfos-undef.h -TARGET_INC+= elfos.h -TARGET_INC+= freebsd-native.h -TARGET_INC+= freebsd-spec.h -TARGET_INC+= freebsd.h -.if ${TARGET_CPUARCH} != "i386" && ${TARGET_CPUARCH} != "amd64" -. if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h) -TARGET_INC+= ${GCC_CPU}/sysv4.h -. endif -.endif -.if ${TARGET_CPUARCH} == "amd64" -TARGET_INC+= ${GCC_CPU}/x86-64.h -.endif -.if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "mips" -TARGET_INC+= ${GCC_CPU}/elf.h -.endif -.if ${TARGET_CPUARCH} == "arm" -TARGET_INC+= ${GCC_CPU}/aout.h -TARGET_INC+= ${GCC_CPU}/bpabi.h -.endif -.if ${TARGET_ARCH} == "powerpc64" -TARGET_INC+= ${GCC_CPU}/biarch64.h -TARGET_INC+= ${GCC_CPU}/default64.h -.endif -.if ${TARGET_ARCH} == "powerpcspe" -TARGET_INC+= ${GCC_CPU}/freebsdspe.h -TARGET_INC+= ${GCC_CPU}/e500-double.h -.endif -TARGET_INC+= ${GCC_CPU}/freebsd.h -.if ${TARGET_CPUARCH} == "amd64" -TARGET_INC+= ${GCC_CPU}/freebsd64.h -.endif -.if ${TARGET_CPUARCH} == "arm" -TARGET_INC+= ${GCC_CPU}/arm.h -.endif -TARGET_INC+= defaults.h - -# -# Option files. -# -OPT_FILES= c.opt common.opt - -.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt) -OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt -.endif - -.if exists(${.CURDIR}/${GCC_CPU}-freebsd.opt) -OPT_FILES+= ${.CURDIR}/${GCC_CPU}-freebsd.opt -.endif - -.if ${TARGET_CPUARCH} == "powerpc" -OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/sysv4.opt -.endif - -.if ${TARGET_CPUARCH} == "sparc64" -OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt -.endif - -.if exists(${.CURDIR}/freebsd.opt) -OPT_FILES+= ${.CURDIR}/freebsd.opt -.endif - - -# Options -optionlist: ${OPT_FILES} - LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET} - -options.h: optionlist - LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \ - -f ${GCCDIR}/opth-gen.awk \ - < ${.ALLSRC} > ${.TARGET} - -options.c: optionlist - LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \ - -f ${GCCDIR}/optc-gen.awk \ - -v header_name="config.h system.h coretypes.h tm.h" \ - < ${.ALLSRC} > ${.TARGET} - -# Target machine config -tm.h: - TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ - HEADERS="${TARGET_INC}" \ - DEFINES="" \ - /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} -.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) - echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} -.endif - -# tconfig.h -tconfig.h: - TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ - HEADERS="auto-host.h ansidecl.h" \ - DEFINES="USED_FOR_TARGET" \ - /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} - -# Version header for gcov -gcov-iov.h: - echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET} - -# Linked headers -gthr-default.h: ${GCCDIR}/gthr-posix.h .NOMETA - ln -sf ${.ALLSRC} ${.TARGET} - -.if ${TARGET_CPUARCH} == "arm" -unwind.h: ${GCCDIR}/config/arm/unwind-arm.h -.else -unwind.h: ${GCCDIR}/unwind-generic.h -.endif - -unwind.h: .NOMETA - ln -sf ${.ALLSRC} ${.TARGET} - diff --git a/gnu/usr.bin/cc/cc_tools/arm.md.diff b/gnu/usr.bin/cc/cc_tools/arm.md.diff deleted file mode 100644 index f395b20ba22..00000000000 --- a/gnu/usr.bin/cc/cc_tools/arm.md.diff +++ /dev/null @@ -1,41 +0,0 @@ -$FreeBSD$ -Index: arm.md -=================================================================== -RCS file: /cognet/ncvs/src/contrib/gcc/config/arm/arm.md,v -retrieving revision 1.1.1.7 -diff -u -p -r1.1.1.7 arm.md ---- arm.md 3 Jun 2005 03:28:42 -0000 1.1.1.7 -+++ arm.md 6 Nov 2006 02:44:36 -0000 -@@ -8840,7 +8840,7 @@ - val2 = INTVAL (XEXP (XEXP (operands[3], 0), 1)); - arith[0] = operands[0]; - arith[3] = operands[1]; -- if (val1 < val2) -+ if (val1 <= val2) - { - arith[1] = ldm[1]; - arith[2] = ldm[2]; -@@ -8870,7 +8870,7 @@ - else - output_asm_insn (\"ldm%?ia\\t%0, {%1, %2}\", ldm); - } -- else -+ else if (val2) - { - ldm[0] = XEXP (operands[2], 0); - if (val1 < val2) -@@ -8878,6 +8878,14 @@ - else - output_asm_insn (\"ldm%?da\\t%0, {%1, %2}\", ldm); - } -+ else { -+ ldm[0] = operands[0]; -+ ldm[1] = XEXP(operands[2], 0); -+ output_asm_insn(\"ldr\\t%0, [%1]\", ldm); -+ ldm[0] = operands[4]; -+ ldm[1] = XEXP(operands[3], 0); -+ output_asm_insn(\"ldr\\t%0, [%1]\", ldm); -+ } - output_asm_insn (\"%I3%?\\t%0, %1, %2\", arith); - return \"\"; - }" diff --git a/gnu/usr.bin/cc/cc_tools/auto-host.h b/gnu/usr.bin/cc/cc_tools/auto-host.h deleted file mode 100644 index 7b72ea9117e..00000000000 --- a/gnu/usr.bin/cc/cc_tools/auto-host.h +++ /dev/null @@ -1,1411 +0,0 @@ -/* auto-host.h. Generated by configure. */ -/* config.in. Generated from configure.ac by autoheader. */ -/* $FreeBSD$ */ - -/* Define as the number of bits in a byte, if \`limits.h' doesn't. */ -#ifndef USED_FOR_TARGET -/* #undef CHAR_BIT */ -#endif - - -/* Define 0/1 to force the choice for exception handling model. */ -#ifndef USED_FOR_TARGET -/* #undef CONFIG_SJLJ_EXCEPTIONS */ -#endif - - -/* Define to enable the use of a default assembler. */ -#ifndef USED_FOR_TARGET -/* #undef DEFAULT_ASSEMBLER */ -#endif - - -/* Define to enable the use of a default linker. */ -#ifndef USED_FOR_TARGET -/* #undef DEFAULT_LINKER */ -#endif - - -/* Define if you want to use __cxa_atexit, rather than atexit, to register C++ - destructors for local statics and global objects. This is essential for - fully standards-compliant handling of destructors, but requires - __cxa_atexit in libc. */ -#ifndef USED_FOR_TARGET -#define DEFAULT_USE_CXA_ATEXIT 1 -#endif - - -/* Define if you want assertions enabled. This is a cheap check. */ -#ifndef USED_FOR_TARGET -#define ENABLE_ASSERT_CHECKING 1 -#endif - - -/* Define if you want more run-time sanity checks. This one gets a grab bag of - miscellaneous but relatively cheap checks. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_CHECKING */ -#endif - - -/* Define to 1 to enable decimal float extension to C. */ -#ifndef USED_FOR_TARGET -#define ENABLE_DECIMAL_FLOAT 0 -#endif - - -/* Define if you want fold checked that it never destructs its argument. This - is quite expensive. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_FOLD_CHECKING */ -#endif - - -/* Define if you want the garbage collector to operate in maximally paranoid - mode, validating the entire heap and collecting garbage at every - opportunity. This is extremely expensive. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_GC_ALWAYS_COLLECT */ -#endif - - -/* Define if you want the garbage collector to do object poisoning and other - memory allocation checks. This is quite expensive. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_GC_CHECKING */ -#endif - - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_NLS */ -#endif - - -/* Define if you want all operations on RTL (the basic data structure of the - optimizer and back end) to be checked for dynamic type safety at runtime. - This is quite expensive. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_RTL_CHECKING */ -#endif - - -/* Define if you want RTL flag accesses to be checked against the RTL codes - that are supported for each access macro. This is relatively cheap. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_RTL_FLAG_CHECKING */ -#endif - - -/* Define if you want runtime assertions enabled. This is a cheap check. */ -#define ENABLE_RUNTIME_CHECKING 1 - -/* Define if you want all operations on trees (the basic data structure of the - front ends) to be checked for dynamic type safety at runtime. This is - moderately expensive. The tree browser debugging routines will also be - enabled by this option. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_TREE_CHECKING */ -#endif - - -/* Define if you want to run subprograms and generated programs through - valgrind (a memory checker). This is extremely expensive. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_VALGRIND_CHECKING */ -#endif - - -/* Define to 1 if installation paths should be looked up in the Windows - Registry. Ignored on non-Windows hosts. */ -#ifndef USED_FOR_TARGET -/* #undef ENABLE_WIN32_REGISTRY */ -#endif - - -/* Define to the name of a file containing a list of extra machine modes for - this architecture. */ -#ifndef USED_FOR_TARGET -/* #undef EXTRA_MODES_FILE */ -#endif - - -/* Define to enable detailed memory allocation stats gathering. */ -#ifndef USED_FOR_TARGET -/* #undef GATHER_STATISTICS */ -#endif - - -/* Define to the type of elements in the array set by `getgroups'. Usually - this is either `int' or `gid_t'. */ -#ifndef USED_FOR_TARGET -#define GETGROUPS_T gid_t -#endif - - -/* Define if the zone collector is in use */ -#ifndef USED_FOR_TARGET -/* #undef GGC_ZONE */ -#endif - - -/* mcontext_t fields start with __ */ -#ifndef USED_FOR_TARGET -/* #undef HAS_MCONTEXT_T_UNDERSCORES */ -#endif - - -/* Define to 1 if you have the `alphasort' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_ALPHASORT 1 -#endif - - -/* Define if your assembler supports dwarf2 .file/.loc directives, and - preserves file table indices exactly as given. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_DWARF2_DEBUG_LINE 1 -#endif - - -/* Define if your assembler supports explicit relocations. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_AS_EXPLICIT_RELOCS */ -#endif - - -/* Define if your assembler supports fprnd. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_AS_FPRND */ -#endif - - -/* Define if your assembler supports the --gdwarf2 option. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_GDWARF2_DEBUG_FLAG 1 -#endif - - -/* Define true if the assembler supports '.long foo@GOTOFF'. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_GOTOFF_IN_DATA 1 -#endif - - -/* Define if your assembler supports the --gstabs option. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_GSTABS_DEBUG_FLAG 1 -#endif - - -/* Define if your assembler supports the Sun syntax for cmov. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_AS_IX86_CMOV_SUN_SYNTAX */ -#endif - - -/* Define if your assembler supports the ffreep mnemonic. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_IX86_FFREEP 1 -#endif - - -/* Define if your assembler supports the lituse_jsrdirect relocation. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_AS_JSRDIRECT_RELOCS */ -#endif - - -/* Define if your assembler supports .sleb128 and .uleb128. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_LEB128 1 -#endif - - -/* Define if your assembler supports ltoffx and ldxmov relocations. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_LTOFFX_LDXMOV_RELOCS 1 -#endif - - -/* Define if your assembler supports mfcr field. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_MFCRF 1 -#endif - - -/* Define if your assembler supports the -no-mul-bug-abort option. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION */ -#endif - - -/* Define if your assembler supports offsetable %lo(). */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_OFFSETABLE_LO10 1 -#endif - - -/* Define if your assembler supports popcntb field. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_AS_POPCNTB */ -#endif - - -/* Define if your assembler supports .register. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_REGISTER_PSEUDO_OP 1 -#endif - - -/* Define if your assembler supports R_PPC_REL16 relocs. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_REL16 -#endif - - -/* Define if your assembler supports -relax option. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_RELAX_OPTION 1 -#endif - - -/* Define if your assembler and linker support unaligned PC relative relocs. - */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_SPARC_UA_PCREL 1 -#endif - - -/* Define if your assembler and linker support unaligned PC relative relocs - against hidden symbols. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_SPARC_UA_PCREL_HIDDEN 1 -#endif - - -/* Define if your assembler supports thread-local storage. */ -#ifndef USED_FOR_TARGET -#define HAVE_AS_TLS 1 -#endif - - -/* Define to 1 if you have the `atoll' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_ATOLL 1 -#endif - - -/* Define to 1 if you have the `atoq' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_ATOQ */ -#endif - - -/* Define to 1 if you have the `clearerr_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_CLEARERR_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `clock' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_CLOCK 1 -#endif - - -/* Define if defines clock_t. */ -#ifndef USED_FOR_TARGET -#define HAVE_CLOCK_T 1 -#endif - - -/* Define 0/1 if your assembler and linker support COMDAT groups. */ -#ifndef USED_FOR_TARGET -#define HAVE_COMDAT_GROUP 1 -#endif - - -/* Define to 1 if we found a declaration for 'abort', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_ABORT 1 -#endif - - -/* Define to 1 if we found a declaration for 'asprintf', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_ASPRINTF 1 -#endif - - -/* Define to 1 if we found a declaration for 'atof', otherwise define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_ATOF 1 -#endif - - -/* Define to 1 if we found a declaration for 'atol', otherwise define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_ATOL 1 -#endif - - -/* Define to 1 if we found a declaration for 'basename', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_BASENAME 0 -#endif - - -/* Define to 1 if we found a declaration for 'calloc', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_CALLOC 1 -#endif - - -/* Define to 1 if we found a declaration for 'clearerr_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_CLEARERR_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'clock', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_CLOCK 1 -#endif - - -/* Define to 1 if we found a declaration for 'errno', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_ERRNO 1 -#endif - - -/* Define to 1 if we found a declaration for 'feof_unlocked', otherwise define - to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FEOF_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'ferror_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FERROR_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'fflush_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FFLUSH_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'fgetc_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FGETC_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'fgets_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FGETS_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'fileno_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FILENO_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'fprintf_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FPRINTF_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'fputc_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FPUTC_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'fputs_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FPUTS_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'fread_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FREAD_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'free', otherwise define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FREE 1 -#endif - - -/* Define to 1 if we found a declaration for 'fwrite_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_FWRITE_UNLOCKED 0 -#endif - - -/* Define to 1 if we found a declaration for 'getchar_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETCHAR_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'getcwd', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETCWD 1 -#endif - - -/* Define to 1 if we found a declaration for 'getc_unlocked', otherwise define - to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETC_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'getenv', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETENV 1 -#endif - - -/* Define to 1 if we found a declaration for 'getopt', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETOPT 1 -#endif - - -/* Define to 1 if we found a declaration for 'getpagesize', otherwise define - to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETPAGESIZE 1 -#endif - - -/* Define to 1 if we found a declaration for 'getrlimit', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETRLIMIT 1 -#endif - - -/* Define to 1 if we found a declaration for 'getrusage', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETRUSAGE 1 -#endif - - -/* Define to 1 if we found a declaration for 'getwd', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_GETWD 1 -#endif - - -/* Define to 1 if we found a declaration for 'ldgetname', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_LDGETNAME 0 -#endif - - -/* Define to 1 if we found a declaration for 'malloc', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_MALLOC 1 -#endif - - -/* Define to 1 if we found a declaration for 'putchar_unlocked', otherwise - define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_PUTCHAR_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'putc_unlocked', otherwise define - to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_PUTC_UNLOCKED 1 -#endif - - -/* Define to 1 if we found a declaration for 'realloc', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_REALLOC 1 -#endif - - -/* Define to 1 if we found a declaration for 'sbrk', otherwise define to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_SBRK 1 -#endif - - -/* Define to 1 if we found a declaration for 'setrlimit', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_SETRLIMIT 1 -#endif - - -/* Define to 1 if we found a declaration for 'sigaltstack', otherwise define - to 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_SIGALTSTACK 1 -#endif - - -/* Define to 1 if we found a declaration for 'snprintf', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_SNPRINTF 1 -#endif - - -/* Define to 1 if we found a declaration for 'strsignal', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_STRSIGNAL 1 -#endif - - -/* Define to 1 if we found a declaration for 'strstr', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_STRSTR 1 -#endif - - -/* Define to 1 if we found a declaration for 'strverscmp', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_STRVERSCMP 0 -#endif - - -/* Define to 1 if we found a declaration for 'times', otherwise define to 0. - */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_TIMES 1 -#endif - - -/* Define to 1 if we found a declaration for 'vasprintf', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_VASPRINTF 1 -#endif - - -/* Define to 1 if we found a declaration for 'vsnprintf', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#define HAVE_DECL_VSNPRINTF 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_DIRECT_H */ -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_FCNTL_H 1 -#endif - - -/* Define to 1 if you have the `feof_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_FEOF_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `ferror_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_FERROR_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `fflush_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FFLUSH_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fgetc_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FGETC_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fgets_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FGETS_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fileno_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_FILENO_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `fork' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_FORK 1 -#endif - - -/* Define to 1 if you have the `fprintf_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FPRINTF_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fputc_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FPUTC_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fputs_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FPUTS_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fread_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FREAD_UNLOCKED */ -#endif - - -/* Define to 1 if you have the `fwrite_unlocked' function. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_FWRITE_UNLOCKED */ -#endif - - -/* Define if your assembler supports .balign and .p2align. */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_BALIGN_AND_P2ALIGN 1 -#endif - - -/* Define if your assembler uses the new HImode fild and fist notation. */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_FILDS_FISTS 1 -#endif - - -/* Define if your assembler and linker support .hidden. */ -#define HAVE_GAS_HIDDEN 1 - -/* Define if your assembler supports specifying the maximum number of bytes to - skip when using the GAS .p2align command. */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_MAX_SKIP_P2ALIGN 1 -#endif - - -/* Define if your assembler supports .nsubspa comdat option. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_GAS_NSUBSPA_COMDAT */ -#endif - - -/* Define if your assembler and linker support 32-bit section relative relocs - via '.secrel32 label'. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_GAS_PE_SECREL32_RELOC */ -#endif - - -/* Define 0/1 if your assembler supports marking sections with SHF_MERGE flag. - */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_SHF_MERGE 1 -#endif - - -/* Define if your assembler supports .subsection and .subsection -1 starts - emitting at the beginning of your section. */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_SUBSECTION_ORDERING 1 -#endif - - -/* Define if your assembler supports .weak. */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_WEAK 1 -#endif - - -/* Define if your assembler supports .weakref. */ -#ifndef USED_FOR_TARGET -#define HAVE_GAS_WEAKREF 1 -#endif - - -/* Define to 1 if you have the `getchar_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_GETCHAR_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `getc_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_GETC_UNLOCKED 1 -#endif - - -/* Define to 1 if system unwind library has _Unwind_GetIPInfo. */ -#define HAVE_GETIPINFO 1 - -/* Define to 1 if you have the `getrlimit' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_GETRLIMIT 1 -#endif - - -/* Define to 1 if you have the `getrusage' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_GETRUSAGE 1 -#endif - - -/* Define to 1 if you have the `gettimeofday' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_GETTIMEOFDAY 1 -#endif - - -/* Define if you have the iconv() function. */ -#ifndef USED_FOR_TARGET -#define HAVE_ICONV 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_ICONV_H */ -#endif - - -/* Define .init_array/.fini_array sections are available and working. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_INITFINI_ARRAY */ -#endif - - -/* Define if you have a working header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_INTTYPES_H 1 -#endif - - -/* Define to 1 if you have the `kill' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_KILL 1 -#endif - - -/* Define if you have and nl_langinfo(CODESET). */ -#ifndef USED_FOR_TARGET -#define HAVE_LANGINFO_CODESET 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_LANGINFO_H 1 -#endif - - -/* Define if your file defines LC_MESSAGES. */ -#ifndef USED_FOR_TARGET -#define HAVE_LC_MESSAGES 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_LDFCN_H */ -#endif - - -/* Define if your linker supports --as-needed and --no-as-needed options. */ -#ifndef USED_FOR_TARGET -#define HAVE_LD_AS_NEEDED 1 -#endif - - -/* Define if your linker supports --demangle option. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_LD_DEMANGLE */ -#endif - - -/* Define if your linker supports --eh-frame-hdr option. */ -#define HAVE_LD_EH_FRAME_HDR 1 - -/* Define if your PowerPC64 linker only needs function descriptor syms. */ -#ifndef USED_FOR_TARGET -#define HAVE_LD_NO_DOT_SYMS 1 -#endif - - -/* Define if your linker supports -pie option. */ -#ifndef USED_FOR_TARGET -#define HAVE_LD_PIE 1 -#endif - - -/* Define if your linker links a mix of read-only and read-write sections into - a read-write section. */ -#ifndef USED_FOR_TARGET -#define HAVE_LD_RO_RW_SECTION_MIXING 1 -#endif - - -/* Define if your linker supports -Bstatic/-Bdynamic option. */ -#ifndef USED_FOR_TARGET -#define HAVE_LD_STATIC_DYNAMIC 1 -#endif - - -/* Define if your linker supports --sysroot. */ -#ifndef USED_FOR_TARGET -#define HAVE_LD_SYSROOT 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_LIMITS_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_LOCALE_H 1 -#endif - - -/* Define to 1 if the system has the type `long long'. */ -#ifndef USED_FOR_TARGET -#define HAVE_LONG_LONG 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_MALLOC_H */ -#endif - - -/* Define to 1 if you have the `mbstowcs' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_MBSTOWCS 1 -#endif - - -/* Define if valgrind's memcheck.h header is installed. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_MEMCHECK_H */ -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_MEMORY_H 1 -#endif - - -/* Define to 1 if you have the `mincore' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_MINCORE 1 -#endif - - -/* Define to 1 if you have the `mmap' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_MMAP 1 -#endif - - -/* Define if mmap with MAP_ANON(YMOUS) works. */ -#ifndef USED_FOR_TARGET -#define HAVE_MMAP_ANON 1 -#endif - - -/* Define if mmap of /dev/zero works. */ -#ifndef USED_FOR_TARGET -#define HAVE_MMAP_DEV_ZERO 1 -#endif - - -/* Define if read-only mmap of a plain file works. */ -#ifndef USED_FOR_TARGET -#define HAVE_MMAP_FILE 1 -#endif - - -/* Define to 1 if you have the `nl_langinfo' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_NL_LANGINFO 1 -#endif - - -/* Define to 1 if you have the `putchar_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_PUTCHAR_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `putc_unlocked' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_PUTC_UNLOCKED 1 -#endif - - -/* Define to 1 if you have the `scandir' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_SCANDIR 1 -#endif - - -/* Define to 1 if you have the `setlocale' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_SETLOCALE 1 -#endif - - -/* Define to 1 if you have the `setrlimit' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_SETRLIMIT 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_STDDEF_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_STDINT_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_STDLIB_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_STRINGS_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_STRING_H 1 -#endif - - -/* Define to 1 if you have the `strsignal' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_STRSIGNAL 1 -#endif - - -/* Define if defines struct tms. */ -#ifndef USED_FOR_TARGET -#define HAVE_STRUCT_TMS 1 -#endif - - -/* Define to 1 if you have the `sysconf' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYSCONF 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_FILE_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_MMAN_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_PARAM_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_RESOURCE_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_STAT_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_TIMES_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_TIME_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_TYPES_H 1 -#endif - - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#ifndef USED_FOR_TARGET -#define HAVE_SYS_WAIT_H 1 -#endif - - -/* Define to 1 if you have the `times' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_TIMES 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_TIME_H 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_UNISTD_H 1 -#endif - - -/* Define if valgrind's valgrind/memcheck.h header is installed. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_VALGRIND_MEMCHECK_H */ -#endif - - -/* Define to 1 if you have the `vfork' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_VFORK 1 -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE_VFORK_H */ -#endif - - -/* Define to 1 if you have the header file. */ -#ifndef USED_FOR_TARGET -#define HAVE_WCHAR_H 1 -#endif - - -/* Define to 1 if you have the `wcswidth' function. */ -#ifndef USED_FOR_TARGET -#define HAVE_WCSWIDTH 1 -#endif - - -/* Define to 1 if `fork' works. */ -#ifndef USED_FOR_TARGET -#define HAVE_WORKING_FORK 1 -#endif - - -/* Define this macro if mbstowcs does not crash when its first argument is - NULL. */ -#ifndef USED_FOR_TARGET -#define HAVE_WORKING_MBSTOWCS 1 -#endif - - -/* Define to 1 if `vfork' works. */ -#ifndef USED_FOR_TARGET -#define HAVE_WORKING_VFORK 1 -#endif - - -/* Define to 1 if the system has the type `__int64'. */ -#ifndef USED_FOR_TARGET -/* #undef HAVE___INT64 */ -#endif - - -/* Define as const if the declaration of iconv() needs const. */ -#ifndef USED_FOR_TARGET -#define ICONV_CONST const -#endif - - -/* Define if host mkdir takes a single argument. */ -#ifndef USED_FOR_TARGET -/* #undef MKDIR_TAKES_ONE_ARG */ -#endif - - -/* Define to 1 if HOST_WIDE_INT must be 64 bits wide (see hwint.h). */ -#ifndef USED_FOR_TARGET -#define NEED_64BIT_HOST_WIDE_INT 1 -#endif - - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -#ifndef USED_FOR_TARGET -/* #undef NO_MINUS_C_MINUS_O */ -#endif - - -/* Define to the address where bug reports for this package should be sent. */ -#ifndef USED_FOR_TARGET -#define PACKAGE_BUGREPORT "" -#endif - - -/* Define to the full name of this package. */ -#ifndef USED_FOR_TARGET -#define PACKAGE_NAME "" -#endif - - -/* Define to the full name and version of this package. */ -#ifndef USED_FOR_TARGET -#define PACKAGE_STRING "" -#endif - - -/* Define to the one symbol short name of this package. */ -#ifndef USED_FOR_TARGET -#define PACKAGE_TARNAME "" -#endif - - -/* Define to the version of this package. */ -#ifndef USED_FOR_TARGET -#define PACKAGE_VERSION "" -#endif - - -/* Define to PREFIX/include if cpp should also search that directory. */ -#ifndef USED_FOR_TARGET -/* #undef PREFIX_INCLUDE_DIR */ -#endif - - -/* The size of a `int', as computed by sizeof. */ -#ifndef USED_FOR_TARGET -#define SIZEOF_INT 4 -#endif - - -/* The size of a `long', as computed by sizeof. */ -#ifndef USED_FOR_TARGET -#define SIZEOF_LONG 4 -#endif - - -/* The size of a `long long', as computed by sizeof. */ -#ifndef USED_FOR_TARGET -#define SIZEOF_LONG_LONG 8 -#endif - - -/* The size of a `short', as computed by sizeof. */ -#ifndef USED_FOR_TARGET -#define SIZEOF_SHORT 2 -#endif - - -/* The size of a `void *', as computed by sizeof. */ -#ifndef USED_FOR_TARGET -#define SIZEOF_VOID_P 4 -#endif - - -/* The size of a `__int64', as computed by sizeof. */ -#ifndef USED_FOR_TARGET -/* #undef SIZEOF___INT64 */ -#endif - - -/* Define to 1 if you have the ANSI C header files. */ -#ifndef USED_FOR_TARGET -#define STDC_HEADERS 1 -#endif - - -/* Define if you can safely include both and . */ -#ifndef USED_FOR_TARGET -#define STRING_WITH_STRINGS 1 -#endif - - -/* Define if TFmode long double should be the default */ -#ifndef USED_FOR_TARGET -/* #undef TARGET_DEFAULT_LONG_DOUBLE_128 */ -#endif - - -/* Define if your target C library provides stack protector support */ -#ifndef USED_FOR_TARGET -#define TARGET_LIBC_PROVIDES_SSP 1 -#endif - - -/* Define to 1 if you can safely include both and . */ -#ifndef USED_FOR_TARGET -#define TIME_WITH_SYS_TIME 1 -#endif - - -/* Define if your assembler mis-optimizes .eh_frame data. */ -#ifndef USED_FOR_TARGET -/* #undef USE_AS_TRADITIONAL_FORMAT */ -#endif - - -/* Define to 1 if the 'long long' (or '__int64') is wider than 'long' but - still efficiently supported by the host hardware. */ -#ifndef USED_FOR_TARGET -/* #undef USE_LONG_LONG_FOR_WIDEST_FAST_INT */ -#endif - - -/* Define if location_t is fileline integer cookie. */ -#ifndef USED_FOR_TARGET -/* #undef USE_MAPPED_LOCATION */ -#endif - - -/* Define to be the last component of the Windows registry key under which to - look for installation paths. The full key used will be - HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}. - The default is the GCC version number. */ -#ifndef USED_FOR_TARGET -/* #undef WIN32_REGISTRY_KEY */ -#endif - - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#ifndef USED_FOR_TARGET -/* #undef WORDS_BIGENDIAN */ -#endif - - -/* Always define this when using the GNU C Library */ -#ifndef USED_FOR_TARGET -/* #undef _GNU_SOURCE */ -#endif - - -/* Define to `int' if doesn't define. */ -#ifndef USED_FOR_TARGET -/* #undef gid_t */ -#endif - - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `int' if does not define. */ -#ifndef USED_FOR_TARGET -/* #undef pid_t */ -#endif - - -/* Define to \`long' if doesn't define. */ -#ifndef USED_FOR_TARGET -/* #undef rlim_t */ -#endif - - -/* Define to `int' if does not define. */ -#ifndef USED_FOR_TARGET -/* #undef ssize_t */ -#endif - - -/* Define to `int' if doesn't define. */ -#ifndef USED_FOR_TARGET -/* #undef uid_t */ -#endif - - -/* Define as `fork' if `vfork' does not work. */ -#ifndef USED_FOR_TARGET -/* #undef vfork */ -#endif - -/* Override SIZEOF_?? using proper values. */ -#include diff --git a/gnu/usr.bin/cc/cc_tools/elfos-undef.h b/gnu/usr.bin/cc/cc_tools/elfos-undef.h deleted file mode 100644 index e889865e838..00000000000 --- a/gnu/usr.bin/cc/cc_tools/elfos-undef.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $FreeBSD$ */ - -/* This header exists to avoid editing contrib/gcc/config/elfos.h - which - isn't coded to be defensive as it should... */ - -#undef ASM_DECLARE_OBJECT_NAME -#undef ASM_OUTPUT_IDENT -#undef IDENT_ASM_OP -#undef READONLY_DATA_SECTION_ASM_OP diff --git a/gnu/usr.bin/cc/cc_tools/freebsd-native.h b/gnu/usr.bin/cc/cc_tools/freebsd-native.h deleted file mode 100644 index 7e11bd83537..00000000000 --- a/gnu/usr.bin/cc/cc_tools/freebsd-native.h +++ /dev/null @@ -1,60 +0,0 @@ -/* $FreeBSD$ */ - -/* FREEBSD_NATIVE is defined when gcc is integrated into the FreeBSD - source tree so it can be configured appropriately without using - the GNU configure/build mechanism. */ - -#define FREEBSD_NATIVE 1 - -/* Fake out gcc/config/freebsd.h. */ -#define FBSD_MAJOR 12 -#define FBSD_CC_VER 1200001 /* form like __FreeBSD_version */ - -#undef SYSTEM_INCLUDE_DIR /* We don't need one for now. */ -#undef TOOL_INCLUDE_DIR /* We don't need one for now. */ -#undef LOCAL_INCLUDE_DIR /* We don't wish to support one. */ - -/* Look for the include files in the system-defined places. */ -#define GPLUSPLUS_INCLUDE_DIR "/usr/include/c++/"GCCVER -#define GPLUSPLUS_BACKWARD_INCLUDE_DIR "/usr/include/c++/"GCCVER"/backward" -#define GCC_INCLUDE_DIR PREFIX"/include/gcc/"GCCVER -#define STANDARD_INCLUDE_DIR "/usr/include" - -/* Under FreeBSD, the normal location of the compiler back ends is the - /usr/libexec directory. - - ``cc --print-search-dirs'' gives: - install: STANDARD_EXEC_PREFIX/ - programs: STANDARD_EXEC_PREFIX:MD_EXEC_PREFIX - libraries: STANDARD_STARTFILE_PREFIX -*/ -#undef STANDARD_BINDIR_PREFIX /* We don't need one for now. */ -#define STANDARD_EXEC_PREFIX PREFIX"/libexec/" -#define STANDARD_LIBEXEC_PREFIX PREFIX"/libexec/" -#define TOOLDIR_BASE_PREFIX PREFIX -#undef MD_EXEC_PREFIX /* We don't want one. */ -#define FBSD_DATA_PREFIX PREFIX"/libdata/gcc/" - -/* Under FreeBSD, the normal location of the various *crt*.o files is the - /usr/lib directory. */ - -#undef MD_STARTFILE_PREFIX /* We don't need one for now. */ -#define STANDARD_STARTFILE_PREFIX "/usr/lib/" -#define STARTFILE_PREFIX_SPEC "/usr/lib/" - -#if 0 -#define LIBGCC_SPEC "%{shared: -lgcc_pic} \ - %{!shared: %{!pg: -lgcc} %{pg: -lgcc_p}}" -#endif -#define LIBSTDCXX_PROFILE "-lstdc++_p" -#define MATH_LIBRARY_PROFILE "-lm_p" -#define FORTRAN_LIBRARY_PROFILE "-lg2c_p" - -#define LIBGCC_SPEC "-lgcc" -/* For the native system compiler, we actually build libgcc in a profiled - version. So we should use it with -pg. */ -#define LIBGCC_STATIC_LIB_SPEC "%{pg: -lgcc_p;:-lgcc}" -#define LIBGCC_EH_STATIC_LIB_SPEC "%{pg: -lgcc_eh_p;:-lgcc_eh}" - -/* FreeBSD is 4.4BSD derived */ -#define bsd4_4 diff --git a/gnu/usr.bin/cc/cc_tools/freebsd.opt b/gnu/usr.bin/cc/cc_tools/freebsd.opt deleted file mode 100644 index f71a5058b9e..00000000000 --- a/gnu/usr.bin/cc/cc_tools/freebsd.opt +++ /dev/null @@ -1,6 +0,0 @@ -; $FreeBSD$ - -fformat-extensions -Common Report Var(flag_format_extensions) Init(0) -Allow FreeBSD kernel-specific printf format specifiers. - diff --git a/gnu/usr.bin/cc/cc_tools/i386-freebsd.opt b/gnu/usr.bin/cc/cc_tools/i386-freebsd.opt deleted file mode 100644 index ca71a8bb568..00000000000 --- a/gnu/usr.bin/cc/cc_tools/i386-freebsd.opt +++ /dev/null @@ -1,13 +0,0 @@ -; $FreeBSD$ - -mno-align-long-strings -Target RejectNegative Report Mask(NO_ALIGN_LONG_STRINGS) -Do not align long strings specially - -malign-long-strings -Target RejectNegative Report InverseMask(NO_ALIGN_LONG_STRINGS, ALIGN_LONG_STRINGS) Undocumented - -mprofiler-epilogue -Target Report Mask(PROFILER_EPILOGUE) -Function profiler epilogue - diff --git a/gnu/usr.bin/cc/cc_tools/size-host.h b/gnu/usr.bin/cc/cc_tools/size-host.h deleted file mode 100644 index 8d5136f6541..00000000000 --- a/gnu/usr.bin/cc/cc_tools/size-host.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $FreeBSD$ */ - -#ifdef SIZEOF_INT -# undef SIZEOF_INT -#endif - -#ifdef SIZEOF_SHORT -# undef SIZEOF_SHORT -#endif - -#ifdef SIZEOF_LONG -# undef SIZEOF_LONG -#endif - -#ifdef SIZEOF_VOID_P -# undef SIZEOF_VOID_P -#endif - -#ifdef SIZEOF_LONG_LONG -# undef SIZEOF_LONG_LONG -#endif - -#ifdef HOST_WIDE_INT -# undef HOST_WIDE_INT -#endif - -#define SIZEOF_INT 4 -#define SIZEOF_SHORT 2 -#define SIZEOF_LONG_LONG 8 - -#if __LP64__ -#define SIZEOF_LONG 8 -#define SIZEOF_VOID_P 8 -#define HOST_WIDE_INT long -#else -#define SIZEOF_LONG 4 -#define SIZEOF_VOID_P 4 -#define HOST_WIDE_INT long long -#endif - -#ifdef WORDS_BIGENDIAN -#undef WORDS_BIGENDIAN -#endif - -#if defined(__sparc64__) || defined(__ARMEB__) -#define WORDS_BIGENDIAN 1 -#endif diff --git a/gnu/usr.bin/cc/cpp/Makefile b/gnu/usr.bin/cc/cpp/Makefile deleted file mode 100644 index 651044d50e8..00000000000 --- a/gnu/usr.bin/cc/cpp/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/cpp/Makefile 265420 2014-05-06 04:22:01Z imp $ - -.include - -.include "../Makefile.inc" -.include "../Makefile.fe" - -PROG= gcpp -SRCS+= cppspec.c - -.if ${MK_CLANG_IS_CC} == "no" -LINKS= ${BINDIR}/gcpp ${BINDIR}/cpp -MLINKS= gcpp.1 cpp.1 -.endif - -.include diff --git a/gnu/usr.bin/cc/cpp/Makefile.depend b/gnu/usr.bin/cc/cpp/Makefile.depend deleted file mode 100644 index 2bea3c0fa88..00000000000 --- a/gnu/usr.bin/cc/cpp/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/cc/cc_tools \ - gnu/usr.bin/cc/libcpp \ - gnu/usr.bin/cc/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/cpp/gcpp.1 b/gnu/usr.bin/cc/cpp/gcpp.1 deleted file mode 100644 index 3a1bc366c22..00000000000 --- a/gnu/usr.bin/cc/cpp/gcpp.1 +++ /dev/null @@ -1,929 +0,0 @@ -.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sh \" Subsection heading -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. | will give a -.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to -.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' -.\" expand to `' in nroff, nothing in troff, for use with C<>. -.tr \(*W-|\(bv\*(Tr -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.if \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 -.if n .na -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "CPP 1" -.TH CPP 1 "2007-07-19" "gcc-4.2.1" "GNU" -.SH "NAME" -cpp \- The C Preprocessor -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -cpp [\fB\-D\fR\fImacro\fR[=\fIdefn\fR]...] [\fB\-U\fR\fImacro\fR] - [\fB\-I\fR\fIdir\fR...] [\fB\-iquote\fR\fIdir\fR...] - [\fB\-W\fR\fIwarn\fR...] - [\fB\-M\fR|\fB\-MM\fR] [\fB\-MG\fR] [\fB\-MF\fR \fIfilename\fR] - [\fB\-MP\fR] [\fB\-MQ\fR \fItarget\fR...] - [\fB\-MT\fR \fItarget\fR...] - [\fB\-P\fR] [\fB\-fno\-working\-directory\fR] - [\fB\-x\fR \fIlanguage\fR] [\fB\-std=\fR\fIstandard\fR] - \fIinfile\fR \fIoutfile\fR -.PP -Only the most useful options are listed here; see below for the remainder. -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -The C preprocessor, often known as \fIcpp\fR, is a \fImacro processor\fR -that is used automatically by the C compiler to transform your program -before compilation. It is called a macro processor because it allows -you to define \fImacros\fR, which are brief abbreviations for longer -constructs. -.PP -The C preprocessor is intended to be used only with C and \*(C+ source -code. In the past, it has been abused as a general text processor. It -will choke on input which does not obey C's lexical rules. For -example, apostrophes will be interpreted as the beginning of character -constants, and cause errors. Also, you cannot rely on it preserving -characteristics of the input which are not significant to C\-family -languages. If a Makefile is preprocessed, all the hard tabs will be -removed, and the Makefile will not work. -.PP -Having said that, you can often get away with using cpp on things which -are not C. Other Algol-ish programming languages are often safe -(Pascal, Ada, etc.) So is assembly, with caution. \fB\-traditional\-cpp\fR -mode preserves more white space, and is otherwise more permissive. Many -of the problems can be avoided by writing C or \*(C+ style comments -instead of native language comments, and keeping macros simple. -.PP -Wherever possible, you should use a preprocessor geared to the language -you are writing in. Modern versions of the \s-1GNU\s0 assembler have macro -facilities. Most high level programming languages have their own -conditional compilation and inclusion mechanism. If all else fails, -try a true general text processor, such as \s-1GNU\s0 M4. -.PP -C preprocessors vary in some details. This manual discusses the \s-1GNU\s0 C -preprocessor, which provides a small superset of the features of \s-1ISO\s0 -Standard C. In its default mode, the \s-1GNU\s0 C preprocessor does not do a -few things required by the standard. These are features which are -rarely, if ever, used, and may cause surprising changes to the meaning -of a program which does not expect them. To get strict \s-1ISO\s0 Standard C, -you should use the \fB\-std=c89\fR or \fB\-std=c99\fR options, depending -on which version of the standard you want. To get all the mandatory -diagnostics, you must also use \fB\-pedantic\fR. -.PP -This manual describes the behavior of the \s-1ISO\s0 preprocessor. To -minimize gratuitous differences, where the \s-1ISO\s0 preprocessor's -behavior does not conflict with traditional semantics, the -traditional preprocessor should behave the same way. The various -differences that do exist are detailed in the section \fBTraditional -Mode\fR. -.PP -For clarity, unless noted otherwise, references to \fB\s-1CPP\s0\fR in this -manual refer to \s-1GNU\s0 \s-1CPP\s0. -.SH "OPTIONS" -.IX Header "OPTIONS" -The C preprocessor expects two file names as arguments, \fIinfile\fR and -\&\fIoutfile\fR. The preprocessor reads \fIinfile\fR together with any -other files it specifies with \fB#include\fR. All the output generated -by the combined input files is written in \fIoutfile\fR. -.PP -Either \fIinfile\fR or \fIoutfile\fR may be \fB\-\fR, which as -\&\fIinfile\fR means to read from standard input and as \fIoutfile\fR -means to write to standard output. Also, if either file is omitted, it -means the same as if \fB\-\fR had been specified for that file. -.PP -Unless otherwise noted, or the option ends in \fB=\fR, all options -which take an argument may have that argument appear either immediately -after the option, or with a space between option and argument: -\&\fB\-Ifoo\fR and \fB\-I foo\fR have the same effect. -.PP -Many options have multi-letter names; therefore multiple single-letter -options may \fInot\fR be grouped: \fB\-dM\fR is very different from -\&\fB\-d\ \-M\fR. -.IP "\fB\-D\fR \fIname\fR" 4 -.IX Item "-D name" -Predefine \fIname\fR as a macro, with definition \f(CW1\fR. -.IP "\fB\-D\fR \fIname\fR\fB=\fR\fIdefinition\fR" 4 -.IX Item "-D name=definition" -The contents of \fIdefinition\fR are tokenized and processed as if -they appeared during translation phase three in a \fB#define\fR -directive. In particular, the definition will be truncated by -embedded newline characters. -.Sp -If you are invoking the preprocessor from a shell or shell-like -program you may need to use the shell's quoting syntax to protect -characters such as spaces that have a meaning in the shell syntax. -.Sp -If you wish to define a function-like macro on the command line, write -its argument list with surrounding parentheses before the equals sign -(if any). Parentheses are meaningful to most shells, so you will need -to quote the option. With \fBsh\fR and \fBcsh\fR, -\&\fB\-D'\fR\fIname\fR\fB(\fR\fIargs...\fR\fB)=\fR\fIdefinition\fR\fB'\fR works. -.Sp -\&\fB\-D\fR and \fB\-U\fR options are processed in the order they -are given on the command line. All \fB\-imacros\fR \fIfile\fR and -\&\fB\-include\fR \fIfile\fR options are processed after all -\&\fB\-D\fR and \fB\-U\fR options. -.IP "\fB\-U\fR \fIname\fR" 4 -.IX Item "-U name" -Cancel any previous definition of \fIname\fR, either built in or -provided with a \fB\-D\fR option. -.IP "\fB\-undef\fR" 4 -.IX Item "-undef" -Do not predefine any system-specific or GCC-specific macros. The -standard predefined macros remain defined. -.IP "\fB\-I\fR \fIdir\fR" 4 -.IX Item "-I dir" -Add the directory \fIdir\fR to the list of directories to be searched -for header files. -.Sp -Directories named by \fB\-I\fR are searched before the standard -system include directories. If the directory \fIdir\fR is a standard -system include directory, the option is ignored to ensure that the -default search order for system directories and the special treatment -of system headers are not defeated -\&. -.IP "\fB\-o\fR \fIfile\fR" 4 -.IX Item "-o file" -Write output to \fIfile\fR. This is the same as specifying \fIfile\fR -as the second non-option argument to \fBcpp\fR. \fBgcc\fR has a -different interpretation of a second non-option argument, so you must -use \fB\-o\fR to specify the output file. -.IP "\fB\-Wall\fR" 4 -.IX Item "-Wall" -Turns on all optional warnings which are desirable for normal code. -At present this is \fB\-Wcomment\fR, \fB\-Wtrigraphs\fR, -\&\fB\-Wmultichar\fR and a warning about integer promotion causing a -change of sign in \f(CW\*(C`#if\*(C'\fR expressions. Note that many of the -preprocessor's warnings are on by default and have no options to -control them. -.IP "\fB\-Wcomment\fR" 4 -.IX Item "-Wcomment" -.PD 0 -.IP "\fB\-Wcomments\fR" 4 -.IX Item "-Wcomments" -.PD -Warn whenever a comment-start sequence \fB/*\fR appears in a \fB/*\fR -comment, or whenever a backslash-newline appears in a \fB//\fR comment. -(Both forms have the same effect.) -.IP "\fB\-Wtrigraphs\fR" 4 -.IX Item "-Wtrigraphs" -Most trigraphs in comments cannot affect the meaning of the program. -However, a trigraph that would form an escaped newline (\fB??/\fR at -the end of a line) can, by changing where the comment begins or ends. -Therefore, only trigraphs that would form escaped newlines produce -warnings inside a comment. -.Sp -This option is implied by \fB\-Wall\fR. If \fB\-Wall\fR is not -given, this option is still enabled unless trigraphs are enabled. To -get trigraph conversion without warnings, but get the other -\&\fB\-Wall\fR warnings, use \fB\-trigraphs \-Wall \-Wno\-trigraphs\fR. -.IP "\fB\-Wtraditional\fR" 4 -.IX Item "-Wtraditional" -Warn about certain constructs that behave differently in traditional and -\&\s-1ISO\s0 C. Also warn about \s-1ISO\s0 C constructs that have no traditional C -equivalent, and problematic constructs which should be avoided. -.IP "\fB\-Wimport\fR" 4 -.IX Item "-Wimport" -Warn the first time \fB#import\fR is used. -.IP "\fB\-Wundef\fR" 4 -.IX Item "-Wundef" -Warn whenever an identifier which is not a macro is encountered in an -\&\fB#if\fR directive, outside of \fBdefined\fR. Such identifiers are -replaced with zero. -.IP "\fB\-Wunused\-macros\fR" 4 -.IX Item "-Wunused-macros" -Warn about macros defined in the main file that are unused. A macro -is \fIused\fR if it is expanded or tested for existence at least once. -The preprocessor will also warn if the macro has not been used at the -time it is redefined or undefined. -.Sp -Built-in macros, macros defined on the command line, and macros -defined in include files are not warned about. -.Sp -\&\fINote:\fR If a macro is actually used, but only used in skipped -conditional blocks, then \s-1CPP\s0 will report it as unused. To avoid the -warning in such a case, you might improve the scope of the macro's -definition by, for example, moving it into the first skipped block. -Alternatively, you could provide a dummy use with something like: -.Sp -.Vb 2 -\& #if defined the_macro_causing_the_warning -\& #endif -.Ve -.IP "\fB\-Wendif\-labels\fR" 4 -.IX Item "-Wendif-labels" -Warn whenever an \fB#else\fR or an \fB#endif\fR are followed by text. -This usually happens in code of the form -.Sp -.Vb 5 -\& #if FOO -\& ... -\& #else FOO -\& ... -\& #endif FOO -.Ve -.Sp -The second and third \f(CW\*(C`FOO\*(C'\fR should be in comments, but often are not -in older programs. This warning is on by default. -.IP "\fB\-Werror\fR" 4 -.IX Item "-Werror" -Make all warnings into hard errors. Source code which triggers warnings -will be rejected. -.IP "\fB\-Wsystem\-headers\fR" 4 -.IX Item "-Wsystem-headers" -Issue warnings for code in system headers. These are normally unhelpful -in finding bugs in your own code, therefore suppressed. If you are -responsible for the system library, you may want to see them. -.IP "\fB\-w\fR" 4 -.IX Item "-w" -Suppress all warnings, including those which \s-1GNU\s0 \s-1CPP\s0 issues by default. -.IP "\fB\-pedantic\fR" 4 -.IX Item "-pedantic" -Issue all the mandatory diagnostics listed in the C standard. Some of -them are left out by default, since they trigger frequently on harmless -code. -.IP "\fB\-pedantic\-errors\fR" 4 -.IX Item "-pedantic-errors" -Issue all the mandatory diagnostics, and make all mandatory diagnostics -into errors. This includes mandatory diagnostics that \s-1GCC\s0 issues -without \fB\-pedantic\fR but treats as warnings. -.IP "\fB\-M\fR" 4 -.IX Item "-M" -Instead of outputting the result of preprocessing, output a rule -suitable for \fBmake\fR describing the dependencies of the main -source file. The preprocessor outputs one \fBmake\fR rule containing -the object file name for that source file, a colon, and the names of all -the included files, including those coming from \fB\-include\fR or -\&\fB\-imacros\fR command line options. -.Sp -Unless specified explicitly (with \fB\-MT\fR or \fB\-MQ\fR), the -object file name consists of the basename of the source file with any -suffix replaced with object file suffix. If there are many included -files then the rule is split into several lines using \fB\e\fR\-newline. -The rule has no commands. -.Sp -This option does not suppress the preprocessor's debug output, such as -\&\fB\-dM\fR. To avoid mixing such debug output with the dependency -rules you should explicitly specify the dependency output file with -\&\fB\-MF\fR, or use an environment variable like -\&\fB\s-1DEPENDENCIES_OUTPUT\s0\fR. Debug output -will still be sent to the regular output stream as normal. -.Sp -Passing \fB\-M\fR to the driver implies \fB\-E\fR, and suppresses -warnings with an implicit \fB\-w\fR. -.IP "\fB\-MM\fR" 4 -.IX Item "-MM" -Like \fB\-M\fR but do not mention header files that are found in -system header directories, nor header files that are included, -directly or indirectly, from such a header. -.Sp -This implies that the choice of angle brackets or double quotes in an -\&\fB#include\fR directive does not in itself determine whether that -header will appear in \fB\-MM\fR dependency output. This is a -slight change in semantics from \s-1GCC\s0 versions 3.0 and earlier. -.IP "\fB\-MF\fR \fIfile\fR" 4 -.IX Item "-MF file" -When used with \fB\-M\fR or \fB\-MM\fR, specifies a -file to write the dependencies to. If no \fB\-MF\fR switch is given -the preprocessor sends the rules to the same place it would have sent -preprocessed output. -.Sp -When used with the driver options \fB\-MD\fR or \fB\-MMD\fR, -\&\fB\-MF\fR overrides the default dependency output file. -.IP "\fB\-MG\fR" 4 -.IX Item "-MG" -In conjunction with an option such as \fB\-M\fR requesting -dependency generation, \fB\-MG\fR assumes missing header files are -generated files and adds them to the dependency list without raising -an error. The dependency filename is taken directly from the -\&\f(CW\*(C`#include\*(C'\fR directive without prepending any path. \fB\-MG\fR -also suppresses preprocessed output, as a missing header file renders -this useless. -.Sp -This feature is used in automatic updating of makefiles. -.IP "\fB\-MP\fR" 4 -.IX Item "-MP" -This option instructs \s-1CPP\s0 to add a phony target for each dependency -other than the main file, causing each to depend on nothing. These -dummy rules work around errors \fBmake\fR gives if you remove header -files without updating the \fIMakefile\fR to match. -.Sp -This is typical output: -.Sp -.Vb 1 -\& test.o: test.c test.h -.Ve -.Sp -.Vb 1 -\& test.h: -.Ve -.IP "\fB\-MT\fR \fItarget\fR" 4 -.IX Item "-MT target" -Change the target of the rule emitted by dependency generation. By -default \s-1CPP\s0 takes the name of the main input file, including any path, -deletes any file suffix such as \fB.c\fR, and appends the platform's -usual object suffix. The result is the target. -.Sp -An \fB\-MT\fR option will set the target to be exactly the string you -specify. If you want multiple targets, you can specify them as a single -argument to \fB\-MT\fR, or use multiple \fB\-MT\fR options. -.Sp -For example, \fB\-MT\ '$(objpfx)foo.o'\fR might give -.Sp -.Vb 1 -\& $(objpfx)foo.o: foo.c -.Ve -.IP "\fB\-MQ\fR \fItarget\fR" 4 -.IX Item "-MQ target" -Same as \fB\-MT\fR, but it quotes any characters which are special to -Make. \fB\-MQ\ '$(objpfx)foo.o'\fR gives -.Sp -.Vb 1 -\& $$(objpfx)foo.o: foo.c -.Ve -.Sp -The default target is automatically quoted, as if it were given with -\&\fB\-MQ\fR. -.IP "\fB\-MD\fR" 4 -.IX Item "-MD" -\&\fB\-MD\fR is equivalent to \fB\-M \-MF\fR \fIfile\fR, except that -\&\fB\-E\fR is not implied. The driver determines \fIfile\fR based on -whether an \fB\-o\fR option is given. If it is, the driver uses its -argument but with a suffix of \fI.d\fR, otherwise it take the -basename of the input file and applies a \fI.d\fR suffix. -.Sp -If \fB\-MD\fR is used in conjunction with \fB\-E\fR, any -\&\fB\-o\fR switch is understood to specify the dependency output file, but if used without \fB\-E\fR, each \fB\-o\fR -is understood to specify a target object file. -.Sp -Since \fB\-E\fR is not implied, \fB\-MD\fR can be used to generate -a dependency output file as a side-effect of the compilation process. -.IP "\fB\-MMD\fR" 4 -.IX Item "-MMD" -Like \fB\-MD\fR except mention only user header files, not system -header files. -.IP "\fB\-x c\fR" 4 -.IX Item "-x c" -.PD 0 -.IP "\fB\-x c++\fR" 4 -.IX Item "-x c++" -.IP "\fB\-x assembler-with-cpp\fR" 4 -.IX Item "-x assembler-with-cpp" -.PD -Specify the source language: C, \*(C+, or assembly. This has nothing -to do with standards conformance or extensions; it merely selects which -base syntax to expect. If you give none of these options, cpp will -deduce the language from the extension of the source file: \&\fB.c\fR, -\fB.cc\fR, or \fB.S\fR. Some other common extensions for \*(C+ and -assembly are also recognized. If cpp does not recognize the extension, -it will treat the file as C; this is the most generic mode. -.Sp -\&\fINote:\fR Previous versions of cpp accepted a \fB\-lang\fR option -which selected both the language and the standards conformance level. -This option has been removed, because it conflicts with the \fB\-l\fR -option. -.IP "\fB\-std=\fR\fIstandard\fR" 4 -.IX Item "-std=standard" -.PD 0 -.IP "\fB\-ansi\fR" 4 -.IX Item "-ansi" -.PD -Specify the standard to which the code should conform. Currently \s-1CPP\s0 -knows about C and \*(C+ standards; others may be added in the future. -.Sp -\&\fIstandard\fR -may be one of: -.RS 4 -.ie n .IP """iso9899:1990""" 4 -.el .IP "\f(CWiso9899:1990\fR" 4 -.IX Item "iso9899:1990" -.PD 0 -.ie n .IP """c89""" 4 -.el .IP "\f(CWc89\fR" 4 -.IX Item "c89" -.PD -The \s-1ISO\s0 C standard from 1990. \fBc89\fR is the customary shorthand for -this version of the standard. -.Sp -The \fB\-ansi\fR option is equivalent to \fB\-std=c89\fR. -.ie n .IP """iso9899:199409""" 4 -.el .IP "\f(CWiso9899:199409\fR" 4 -.IX Item "iso9899:199409" -The 1990 C standard, as amended in 1994. -.ie n .IP """iso9899:1999""" 4 -.el .IP "\f(CWiso9899:1999\fR" 4 -.IX Item "iso9899:1999" -.PD 0 -.ie n .IP """c99""" 4 -.el .IP "\f(CWc99\fR" 4 -.IX Item "c99" -.ie n .IP """iso9899:199x""" 4 -.el .IP "\f(CWiso9899:199x\fR" 4 -.IX Item "iso9899:199x" -.ie n .IP """c9x""" 4 -.el .IP "\f(CWc9x\fR" 4 -.IX Item "c9x" -.PD -The revised \s-1ISO\s0 C standard, published in December 1999. Before -publication, this was known as C9X. -.ie n .IP """gnu89""" 4 -.el .IP "\f(CWgnu89\fR" 4 -.IX Item "gnu89" -The 1990 C standard plus \s-1GNU\s0 extensions. This is the default. -.ie n .IP """gnu99""" 4 -.el .IP "\f(CWgnu99\fR" 4 -.IX Item "gnu99" -.PD 0 -.ie n .IP """gnu9x""" 4 -.el .IP "\f(CWgnu9x\fR" 4 -.IX Item "gnu9x" -.PD -The 1999 C standard plus \s-1GNU\s0 extensions. -.ie n .IP """c++98""" 4 -.el .IP "\f(CWc++98\fR" 4 -.IX Item "c++98" -The 1998 \s-1ISO\s0 \*(C+ standard plus amendments. -.ie n .IP """gnu++98""" 4 -.el .IP "\f(CWgnu++98\fR" 4 -.IX Item "gnu++98" -The same as \fB\-std=c++98\fR plus \s-1GNU\s0 extensions. This is the -default for \*(C+ code. -.RE -.RS 4 -.RE -.IP "\fB\-I\-\fR" 4 -.IX Item "-I-" -Split the include path. Any directories specified with \fB\-I\fR -options before \fB\-I\-\fR are searched only for headers requested with -\&\f(CW\*(C`#include\ "\f(CIfile\f(CW"\*(C'\fR; they are not searched for -\&\f(CW\*(C`#include\ <\f(CIfile\f(CW>\*(C'\fR. If additional directories are -specified with \fB\-I\fR options after the \fB\-I\-\fR, those -directories are searched for all \fB#include\fR directives. -.Sp -In addition, \fB\-I\-\fR inhibits the use of the directory of the current -file directory as the first search directory for \f(CW\*(C`#include\ "\f(CIfile\f(CW"\*(C'\fR. -.Sp -This option has been deprecated. -.IP "\fB\-nostdinc\fR" 4 -.IX Item "-nostdinc" -Do not search the standard system directories for header files. -Only the directories you have specified with \fB\-I\fR options -(and the directory of the current file, if appropriate) are searched. -.IP "\fB\-nostdinc++\fR" 4 -.IX Item "-nostdinc++" -Do not search for header files in the \*(C+\-specific standard directories, -but do still search the other standard directories. (This option is -used when building the \*(C+ library.) -.IP "\fB\-include\fR \fIfile\fR" 4 -.IX Item "-include file" -Process \fIfile\fR as if \f(CW\*(C`#include "file"\*(C'\fR appeared as the first -line of the primary source file. However, the first directory searched -for \fIfile\fR is the preprocessor's working directory \fIinstead of\fR -the directory containing the main source file. If not found there, it -is searched for in the remainder of the \f(CW\*(C`#include "..."\*(C'\fR search -chain as normal. -.Sp -If multiple \fB\-include\fR options are given, the files are included -in the order they appear on the command line. -.IP "\fB\-imacros\fR \fIfile\fR" 4 -.IX Item "-imacros file" -Exactly like \fB\-include\fR, except that any output produced by -scanning \fIfile\fR is thrown away. Macros it defines remain defined. -This allows you to acquire all the macros from a header without also -processing its declarations. -.Sp -All files specified by \fB\-imacros\fR are processed before all files -specified by \fB\-include\fR. -.IP "\fB\-idirafter\fR \fIdir\fR" 4 -.IX Item "-idirafter dir" -Search \fIdir\fR for header files, but do it \fIafter\fR all -directories specified with \fB\-I\fR and the standard system directories -have been exhausted. \fIdir\fR is treated as a system include directory. -.IP "\fB\-iprefix\fR \fIprefix\fR" 4 -.IX Item "-iprefix prefix" -Specify \fIprefix\fR as the prefix for subsequent \fB\-iwithprefix\fR -options. If the prefix represents a directory, you should include the -final \fB/\fR. -.IP "\fB\-iwithprefix\fR \fIdir\fR" 4 -.IX Item "-iwithprefix dir" -.PD 0 -.IP "\fB\-iwithprefixbefore\fR \fIdir\fR" 4 -.IX Item "-iwithprefixbefore dir" -.PD -Append \fIdir\fR to the prefix specified previously with -\&\fB\-iprefix\fR, and add the resulting directory to the include search -path. \fB\-iwithprefixbefore\fR puts it in the same place \fB\-I\fR -would; \fB\-iwithprefix\fR puts it where \fB\-idirafter\fR would. -.IP "\fB\-isysroot\fR \fIdir\fR" 4 -.IX Item "-isysroot dir" -This option is like the \fB\-\-sysroot\fR option, but applies only to -header files. See the \fB\-\-sysroot\fR option for more information. -.IP "\fB\-imultilib\fR \fIdir\fR" 4 -.IX Item "-imultilib dir" -Use \fIdir\fR as a subdirectory of the directory containing -target-specific \*(C+ headers. -.IP "\fB\-isystem\fR \fIdir\fR" 4 -.IX Item "-isystem dir" -Search \fIdir\fR for header files, after all directories specified by -\&\fB\-I\fR but before the standard system directories. Mark it -as a system directory, so that it gets the same special treatment as -is applied to the standard system directories. -.IP "\fB\-iquote\fR \fIdir\fR" 4 -.IX Item "-iquote dir" -Search \fIdir\fR only for header files requested with -\&\f(CW\*(C`#include\ "\f(CIfile\f(CW"\*(C'\fR; they are not searched for -\&\f(CW\*(C`#include\ <\f(CIfile\f(CW>\*(C'\fR, before all directories specified by -\&\fB\-I\fR and before the standard system directories. -.IP "\fB\-fdollars\-in\-identifiers\fR" 4 -.IX Item "-fdollars-in-identifiers" -Accept \fB$\fR in identifiers. -.IP "\fB\-fextended\-identifiers\fR" 4 -.IX Item "-fextended-identifiers" -Accept universal character names in identifiers. This option is -experimental; in a future version of \s-1GCC\s0, it will be enabled by -default for C99 and \*(C+. -.IP "\fB\-fpreprocessed\fR" 4 -.IX Item "-fpreprocessed" -Indicate to the preprocessor that the input file has already been -preprocessed. This suppresses things like macro expansion, trigraph -conversion, escaped newline splicing, and processing of most directives. -The preprocessor still recognizes and removes comments, so that you can -pass a file preprocessed with \fB\-C\fR to the compiler without -problems. In this mode the integrated preprocessor is little more than -a tokenizer for the front ends. -.Sp -\&\fB\-fpreprocessed\fR is implicit if the input file has one of the -extensions \fB.i\fR, \fB.ii\fR or \fB.mi\fR. These are the -extensions that \s-1GCC\s0 uses for preprocessed files created by -\&\fB\-save\-temps\fR. -.IP "\fB\-ftabstop=\fR\fIwidth\fR" 4 -.IX Item "-ftabstop=width" -Set the distance between tab stops. This helps the preprocessor report -correct column numbers in warnings or errors, even if tabs appear on the -line. If the value is less than 1 or greater than 100, the option is -ignored. The default is 8. -.IP "\fB\-fexec\-charset=\fR\fIcharset\fR" 4 -.IX Item "-fexec-charset=charset" -Set the execution character set, used for string and character -constants. The default is \s-1UTF\-8\s0. \fIcharset\fR can be any encoding -supported by the system's \f(CW\*(C`iconv\*(C'\fR library routine. -.IP "\fB\-fwide\-exec\-charset=\fR\fIcharset\fR" 4 -.IX Item "-fwide-exec-charset=charset" -Set the wide execution character set, used for wide string and -character constants. The default is \s-1UTF\-32\s0 or \s-1UTF\-16\s0, whichever -corresponds to the width of \f(CW\*(C`wchar_t\*(C'\fR. As with -\&\fB\-fexec\-charset\fR, \fIcharset\fR can be any encoding supported -by the system's \f(CW\*(C`iconv\*(C'\fR library routine; however, you will have -problems with encodings that do not fit exactly in \f(CW\*(C`wchar_t\*(C'\fR. -.IP "\fB\-finput\-charset=\fR\fIcharset\fR" 4 -.IX Item "-finput-charset=charset" -Set the input character set, used for translation from the character -set of the input file to the source character set used by \s-1GCC\s0. If the -locale does not specify, or \s-1GCC\s0 cannot get this information from the -locale, the default is \s-1UTF\-8\s0. This can be overridden by either the locale -or this command line option. Currently the command line option takes -precedence if there's a conflict. \fIcharset\fR can be any encoding -supported by the system's \f(CW\*(C`iconv\*(C'\fR library routine. -.IP "\fB\-fworking\-directory\fR" 4 -.IX Item "-fworking-directory" -Enable generation of linemarkers in the preprocessor output that will -let the compiler know the current working directory at the time of -preprocessing. When this option is enabled, the preprocessor will -emit, after the initial linemarker, a second linemarker with the -current working directory followed by two slashes. \s-1GCC\s0 will use this -directory, when it's present in the preprocessed input, as the -directory emitted as the current working directory in some debugging -information formats. This option is implicitly enabled if debugging -information is enabled, but this can be inhibited with the negated -form \fB\-fno\-working\-directory\fR. If the \fB\-P\fR flag is -present in the command line, this option has no effect, since no -\&\f(CW\*(C`#line\*(C'\fR directives are emitted whatsoever. -.IP "\fB\-fno\-show\-column\fR" 4 -.IX Item "-fno-show-column" -Do not print column numbers in diagnostics. This may be necessary if -diagnostics are being scanned by a program that does not understand the -column numbers, such as \fBdejagnu\fR. -.IP "\fB\-A\fR \fIpredicate\fR\fB=\fR\fIanswer\fR" 4 -.IX Item "-A predicate=answer" -Make an assertion with the predicate \fIpredicate\fR and answer -\&\fIanswer\fR. This form is preferred to the older form \fB\-A\fR -\&\fIpredicate\fR\fB(\fR\fIanswer\fR\fB)\fR, which is still supported, because -it does not use shell special characters. -.IP "\fB\-A \-\fR\fIpredicate\fR\fB=\fR\fIanswer\fR" 4 -.IX Item "-A -predicate=answer" -Cancel an assertion with the predicate \fIpredicate\fR and answer -\&\fIanswer\fR. -.IP "\fB\-dCHARS\fR" 4 -.IX Item "-dCHARS" -\&\fI\s-1CHARS\s0\fR is a sequence of one or more of the following characters, -and must not be preceded by a space. Other characters are interpreted -by the compiler proper, or reserved for future versions of \s-1GCC\s0, and so -are silently ignored. If you specify characters whose behavior -conflicts, the result is undefined. -.RS 4 -.IP "\fBM\fR" 4 -.IX Item "M" -Instead of the normal output, generate a list of \fB#define\fR -directives for all the macros defined during the execution of the -preprocessor, including predefined macros. This gives you a way of -finding out what is predefined in your version of the preprocessor. -Assuming you have no file \fIfoo.h\fR, the command -.Sp -.Vb 1 -\& touch foo.h; cpp -dM foo.h -.Ve -.Sp -will show all the predefined macros. -.IP "\fBD\fR" 4 -.IX Item "D" -Like \fBM\fR except in two respects: it does \fInot\fR include the -predefined macros, and it outputs \fIboth\fR the \fB#define\fR -directives and the result of preprocessing. Both kinds of output go to -the standard output file. -.IP "\fBN\fR" 4 -.IX Item "N" -Like \fBD\fR, but emit only the macro names, not their expansions. -.IP "\fBI\fR" 4 -.IX Item "I" -Output \fB#include\fR directives in addition to the result of -preprocessing. -.RE -.RS 4 -.RE -.IP "\fB\-P\fR" 4 -.IX Item "-P" -Inhibit generation of linemarkers in the output from the preprocessor. -This might be useful when running the preprocessor on something that is -not C code, and will be sent to a program which might be confused by the -linemarkers. -.IP "\fB\-C\fR" 4 -.IX Item "-C" -Do not discard comments. All comments are passed through to the output -file, except for comments in processed directives, which are deleted -along with the directive. -.Sp -You should be prepared for side effects when using \fB\-C\fR; it -causes the preprocessor to treat comments as tokens in their own right. -For example, comments appearing at the start of what would be a -directive line have the effect of turning that line into an ordinary -source line, since the first token on the line is no longer a \fB#\fR. -.IP "\fB\-CC\fR" 4 -.IX Item "-CC" -Do not discard comments, including during macro expansion. This is -like \fB\-C\fR, except that comments contained within macros are -also passed through to the output file where the macro is expanded. -.Sp -In addition to the side-effects of the \fB\-C\fR option, the -\&\fB\-CC\fR option causes all \*(C+\-style comments inside a macro -to be converted to C\-style comments. This is to prevent later use -of that macro from inadvertently commenting out the remainder of -the source line. -.Sp -The \fB\-CC\fR option is generally used to support lint comments. -.IP "\fB\-traditional\-cpp\fR" 4 -.IX Item "-traditional-cpp" -Try to imitate the behavior of old-fashioned C preprocessors, as -opposed to \s-1ISO\s0 C preprocessors. -.IP "\fB\-trigraphs\fR" 4 -.IX Item "-trigraphs" -Process trigraph sequences. -.IP "\fB\-remap\fR" 4 -.IX Item "-remap" -Enable special code to work around file systems which only permit very -short file names, such as \s-1MS\-DOS\s0. -.IP "\fB\-\-help\fR" 4 -.IX Item "--help" -.PD 0 -.IP "\fB\-\-target\-help\fR" 4 -.IX Item "--target-help" -.PD -Print text describing all the command line options instead of -preprocessing anything. -.IP "\fB\-v\fR" 4 -.IX Item "-v" -Verbose mode. Print out \s-1GNU\s0 \s-1CPP\s0's version number at the beginning of -execution, and report the final form of the include path. -.IP "\fB\-H\fR" 4 -.IX Item "-H" -Print the name of each header file used, in addition to other normal -activities. Each name is indented to show how deep in the -\&\fB#include\fR stack it is. Precompiled header files are also -printed, even if they are found to be invalid; an invalid precompiled -header file is printed with \fB...x\fR and a valid one with \fB...!\fR . -.IP "\fB\-version\fR" 4 -.IX Item "-version" -.PD 0 -.IP "\fB\-\-version\fR" 4 -.IX Item "--version" -.PD -Print out \s-1GNU\s0 \s-1CPP\s0's version number. With one dash, proceed to -preprocess as normal. With two dashes, exit immediately. -.SH "ENVIRONMENT" -.IX Header "ENVIRONMENT" -This section describes the environment variables that affect how \s-1CPP\s0 -operates. You can use them to specify directories or prefixes to use -when searching for include files, or to control dependency output. -.PP -Note that you can also specify places to search using options such as -\&\fB\-I\fR, and control dependency output with options like -\&\fB\-M\fR. These take precedence over -environment variables, which in turn take precedence over the -configuration of \s-1GCC\s0. -.IP "\fB\s-1CPATH\s0\fR" 4 -.IX Item "CPATH" -.PD 0 -.IP "\fBC_INCLUDE_PATH\fR" 4 -.IX Item "C_INCLUDE_PATH" -.IP "\fB\s-1CPLUS_INCLUDE_PATH\s0\fR" 4 -.IX Item "CPLUS_INCLUDE_PATH" -.PD -Each variable's value is a list of directories separated by a special -character, much like \fB\s-1PATH\s0\fR, in which to look for header files. -The special character, \f(CW\*(C`PATH_SEPARATOR\*(C'\fR, is target-dependent and -determined at \s-1GCC\s0 build time. For Microsoft Windows-based targets it is a -semicolon, and for almost all other targets it is a colon. -.Sp -\&\fB\s-1CPATH\s0\fR specifies a list of directories to be searched as if -specified with \fB\-I\fR, but after any paths given with \fB\-I\fR -options on the command line. This environment variable is used -regardless of which language is being preprocessed. -.Sp -The remaining environment variables apply only when preprocessing the -particular language indicated. Each specifies a list of directories -to be searched as if specified with \fB\-isystem\fR, but after any -paths given with \fB\-isystem\fR options on the command line. -.Sp -In all these variables, an empty element instructs the compiler to -search its current working directory. Empty elements can appear at the -beginning or end of a path. For instance, if the value of -\&\fB\s-1CPATH\s0\fR is \f(CW\*(C`:/special/include\*(C'\fR, that has the same -effect as \fB\-I.\ \-I/special/include\fR. -.IP "\fB\s-1DEPENDENCIES_OUTPUT\s0\fR" 4 -.IX Item "DEPENDENCIES_OUTPUT" -If this variable is set, its value specifies how to output -dependencies for Make based on the non-system header files processed -by the compiler. System header files are ignored in the dependency -output. -.Sp -The value of \fB\s-1DEPENDENCIES_OUTPUT\s0\fR can be just a file name, in -which case the Make rules are written to that file, guessing the target -name from the source file name. Or the value can have the form -\&\fIfile\fR\fB \fR\fItarget\fR, in which case the rules are written to -file \fIfile\fR using \fItarget\fR as the target name. -.Sp -In other words, this environment variable is equivalent to combining -the options \fB\-MM\fR and \fB\-MF\fR, -with an optional \fB\-MT\fR switch too. -.IP "\fB\s-1SUNPRO_DEPENDENCIES\s0\fR" 4 -.IX Item "SUNPRO_DEPENDENCIES" -This variable is the same as \fB\s-1DEPENDENCIES_OUTPUT\s0\fR (see above), -except that system header files are not ignored, so it implies -\&\fB\-M\fR rather than \fB\-MM\fR. However, the dependence on the -main input file is omitted. -.SH "SEE ALSO" -.IX Header "SEE ALSO" -\&\fIgpl\fR\|(7), \fIgfdl\fR\|(7), \fIfsf\-funding\fR\|(7), -\&\fIgcc\fR\|(1), \fIas\fR\|(1), \fIld\fR\|(1), and the Info entries for \fIcpp\fR, \fIgcc\fR, and -\&\fIbinutils\fR. -.SH "COPYRIGHT" -.IX Header "COPYRIGHT" -Copyright (c) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, -1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. -.PP -Permission is granted to copy, distribute and/or modify this document -under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 or -any later version published by the Free Software Foundation. A copy of -the license is included in the -man page \fIgfdl\fR\|(7). -This manual contains no Invariant Sections. The Front-Cover Texts are -(a) (see below), and the Back-Cover Texts are (b) (see below). -.PP -(a) The \s-1FSF\s0's Front-Cover Text is: -.PP -.Vb 1 -\& A GNU Manual -.Ve -.PP -(b) The \s-1FSF\s0's Back-Cover Text is: -.PP -.Vb 3 -\& You have freedom to copy and modify this GNU Manual, like GNU -\& software. Copies published by the Free Software Foundation raise -\& funds for GNU development. -.Ve diff --git a/gnu/usr.bin/cc/gcov/Makefile b/gnu/usr.bin/cc/gcov/Makefile deleted file mode 100644 index f263780d65a..00000000000 --- a/gnu/usr.bin/cc/gcov/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/cc/gcov/Makefile 245539 2013-01-17 05:56:28Z andrew $ - -.include - -.include "../Makefile.inc" -.include "../Makefile.ver" - -.PATH: ${GCCDIR} ${GCCDIR}/doc - -PROG= gcov -SRCS= gcov.c version.c errors.c -MAN= gcov.1 - -DPADD= ${LIBIBERTY} -LDADD= ${LIBIBERTY} - -.include diff --git a/gnu/usr.bin/cc/gcov/Makefile.depend b/gnu/usr.bin/cc/gcov/Makefile.depend deleted file mode 100644 index de48a531065..00000000000 --- a/gnu/usr.bin/cc/gcov/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/usr.bin/cc/cc_tools \ - gnu/usr.bin/cc/libiberty \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/include/Makefile b/gnu/usr.bin/cc/include/Makefile deleted file mode 100644 index 9d9ad75fd64..00000000000 --- a/gnu/usr.bin/cc/include/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# $FreeBSD$ - -.include - -.include "../Makefile.inc" - -INCSDIR=${INCLUDEDIR}/gcc/${GCCVER} - -.PATH: ${GCCDIR}/config/${GCC_CPU} ${SRCTOP}/contrib/llvm-project/clang/lib/Headers - -.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64" -INCS= ammintrin.h emmintrin.h mmintrin.h mm3dnow.h pmmintrin.h \ - tmmintrin.h xmmintrin.h mm_malloc.h -INCS+= wmmintrin.h __wmmintrin_aes.h __wmmintrin_pclmul.h -.elif ${TARGET_ARCH} == "arm" -INCS= mmintrin.h -.elif ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "powerpc64" || \ - ${TARGET_ARCH} == "powerpcspe" -INCS= ppc-asm.h altivec.h spe.h -.endif - -mm_malloc.h: pmm_malloc.h - @rm -rf ${.TARGET} - @cp ${.ALLSRC} ${.TARGET} -CLEANFILES+= mm_malloc.h - -.include diff --git a/gnu/usr.bin/cc/include/Makefile.depend b/gnu/usr.bin/cc/include/Makefile.depend deleted file mode 100644 index f80275d86ab..00000000000 --- a/gnu/usr.bin/cc/include/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/include/__wmmintrin_aes.h b/gnu/usr.bin/cc/include/__wmmintrin_aes.h deleted file mode 100644 index ff8a3457948..00000000000 --- a/gnu/usr.bin/cc/include/__wmmintrin_aes.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright 2013 John-Mark Gurney - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#ifndef _WMMINTRIN_AES_H_ -#define _WMMINTRIN_AES_H_ - -#include - -#define MAKE_AES(name) \ -static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) \ -_mm_## name ##_si128(__m128i __V, __m128i __R) \ -{ \ - __m128i v = __V; \ - \ - __asm__ (#name " %2, %0": "=x" (v): "0" (v), "xm" (__R)); \ - \ - return v; \ -} - -MAKE_AES(aesimc) -MAKE_AES(aesenc) -MAKE_AES(aesenclast) -MAKE_AES(aesdec) -MAKE_AES(aesdeclast) - -#undef MAKE_AES - -#endif /* _WMMINTRIN_AES_H_ */ diff --git a/gnu/usr.bin/cc/include/__wmmintrin_pclmul.h b/gnu/usr.bin/cc/include/__wmmintrin_pclmul.h deleted file mode 100644 index 5bebd81be26..00000000000 --- a/gnu/usr.bin/cc/include/__wmmintrin_pclmul.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright 2013 John-Mark Gurney - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#ifndef _WMMINTRIN_PCLMUL_H_ -#define _WMMINTRIN_PCLMUL_H_ - -#include - -/* - * c selects which parts of a and b to multiple: - * 0x00: a[ 63: 0] * b[ 63: 0] - * 0x01: a[127:64] * b[ 63: 0] - * 0x10: a[ 63: 0] * b[127:64] - * 0x11: a[127:64] * b[127:64] - */ -#define _mm_clmulepi64_si128(a, b, c) \ -({ \ - __m128i _a = (a); \ - __m128i _b = (b); \ - \ - __asm__("pclmulqdq %3, %2, %0": "=x" (_a): "0" (_a), "xm" (_b), \ - "i" (c)); \ - \ - _a; \ -}) - -#endif /* _WMMINTRIN_PCLMUL_H_ */ diff --git a/gnu/usr.bin/cc/libcpp/Makefile b/gnu/usr.bin/cc/libcpp/Makefile deleted file mode 100644 index d21bd8352bc..00000000000 --- a/gnu/usr.bin/cc/libcpp/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# $FreeBSD$ - -.include - -# Use our headers in preference to ones from ../cc_tools. -CFLAGS+= -I${.CURDIR} -I. - -.include "../Makefile.inc" - -.PATH: ${GCCLIB}/libcpp - -LIB= cpp -SRCS= localedir.h -SRCS+= charset.c directives.c directives-only.c errors.c expr.c \ - files.c identifiers.c init.c lex.c line-map.c macro.c \ - mkdeps.c pch.c symtab.c traditional.c -INTERNALLIB= -WARNS?= 1 - -localedir.h: Makefile - echo '#define LOCALEDIR "/usr/share/locale"' > localedir.h -SRCS+= localedir.h -CLEANFILES+= localedir.h - -.include diff --git a/gnu/usr.bin/cc/libcpp/Makefile.depend b/gnu/usr.bin/cc/libcpp/Makefile.depend deleted file mode 100644 index 18be76b0cb6..00000000000 --- a/gnu/usr.bin/cc/libcpp/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/libcpp/config.h b/gnu/usr.bin/cc/libcpp/config.h deleted file mode 100644 index 5577f2840df..00000000000 --- a/gnu/usr.bin/cc/libcpp/config.h +++ /dev/null @@ -1,292 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.ac by autoheader. */ -/* $FreeBSD$ */ - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Define if you want more run-time sanity checks. */ -/* #undef ENABLE_CHECKING */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -/* #undef HAVE_ALLOCA_H */ - -/* Define to 1 if you have the `clearerr_unlocked' function. */ -#define HAVE_CLEARERR_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `abort', and to 0 if you don't. - */ -#define HAVE_DECL_ABORT 1 - -/* Define to 1 if you have the declaration of `asprintf', and to 0 if you - don't. */ -#define HAVE_DECL_ASPRINTF 1 - -/* Define to 1 if you have the declaration of `basename', and to 0 if you - don't. */ -#define HAVE_DECL_BASENAME 0 - -/* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_CLEARERR_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `errno', and to 0 if you don't. - */ -#define HAVE_DECL_ERRNO 0 - -/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you - don't. */ -#define HAVE_DECL_FEOF_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FERROR_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FFLUSH_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fgetc_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FGETC_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FGETS_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fileno_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FILENO_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `fprintf_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FPRINTF_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fputc_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FPUTC_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fputs_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FPUTS_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fread_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FREAD_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `fwrite_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_FWRITE_UNLOCKED 0 - -/* Define to 1 if you have the declaration of `getchar_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_GETCHAR_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you - don't. */ -#define HAVE_DECL_GETC_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. - */ -#define HAVE_DECL_GETOPT 1 - -/* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if - you don't. */ -#define HAVE_DECL_PUTCHAR_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `putc_unlocked', and to 0 if you - don't. */ -#define HAVE_DECL_PUTC_UNLOCKED 1 - -/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VASPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `feof_unlocked' function. */ -#define HAVE_FEOF_UNLOCKED 1 - -/* Define to 1 if you have the `ferror_unlocked' function. */ -#define HAVE_FERROR_UNLOCKED 1 - -/* Define to 1 if you have the `fflush_unlocked' function. */ -/* #undef HAVE_FFLUSH_UNLOCKED */ - -/* Define to 1 if you have the `fgetc_unlocked' function. */ -/* #undef HAVE_FGETC_UNLOCKED */ - -/* Define to 1 if you have the `fgets_unlocked' function. */ -/* #undef HAVE_FGETS_UNLOCKED */ - -/* Define to 1 if you have the `fileno_unlocked' function. */ -#define HAVE_FILENO_UNLOCKED 1 - -/* Define to 1 if you have the `fprintf_unlocked' function. */ -/* #undef HAVE_FPRINTF_UNLOCKED */ - -/* Define to 1 if you have the `fputc_unlocked' function. */ -/* #undef HAVE_FPUTC_UNLOCKED */ - -/* Define to 1 if you have the `fputs_unlocked' function. */ -/* #undef HAVE_FPUTS_UNLOCKED */ - -/* Define to 1 if you have the `fread_unlocked' function. */ -/* #undef HAVE_FREAD_UNLOCKED */ - -/* Define to 1 if you have the `fwrite_unlocked' function. */ -/* #undef HAVE_FWRITE_UNLOCKED */ - -/* Define to 1 if you have the `getchar_unlocked' function. */ -#define HAVE_GETCHAR_UNLOCKED 1 - -/* Define to 1 if you have the `getc_unlocked' function. */ -#define HAVE_GETC_UNLOCKED 1 - -/* Define if you have the iconv() function. */ -#if XXXKAN -#define HAVE_ICONV 1 -#endif - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ICONV_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define if you have and nl_langinfo(CODESET). */ -#define HAVE_LANGINFO_CODESET 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if libc includes obstacks. */ -/* #undef HAVE_OBSTACK */ - -/* Define to 1 if you have the `putchar_unlocked' function. */ -#define HAVE_PUTCHAR_UNLOCKED 1 - -/* Define to 1 if you have the `putc_unlocked' function. */ -#define HAVE_PUTC_UNLOCKED 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if defines \`uchar'. */ -/* #undef HAVE_UCHAR */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the widest efficient host integer type at least as wide as the - target's size_t type. */ -#define HOST_WIDE_INT long - -#if XXXKAN -/* Define as const if the declaration of iconv() needs const. */ -#define ICONV_CONST const -#endif - -/* Define to the name of this package. */ -#define PACKAGE "cpplib" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "gcc-bugs@gcc.gnu.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "cpplib" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "cpplib " - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "cpplib" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION " " - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -#define STRING_WITH_STRINGS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to 1 if your declares `struct tm'. */ -/* #undef TM_IN_SYS_TIME */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `long' if does not define. */ -/* #undef off_t */ - -/* Define to `unsigned' if does not define. */ -/* #undef size_t */ - -typedef unsigned char uchar; - -#include diff --git a/gnu/usr.bin/cc/libdecnumber/Makefile b/gnu/usr.bin/cc/libdecnumber/Makefile deleted file mode 100644 index 2987c1c89b1..00000000000 --- a/gnu/usr.bin/cc/libdecnumber/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ - -.include - -# Use our headers in preference to ones from ../cc_tools. -CFLAGS+= -I${.CURDIR} -I. - -.include "../Makefile.inc" - -.PATH: ${GCCLIB}/libdecnumber - -LIB= decnumber -SRCS= decNumber.c decContext.c decUtility.c \ - decimal32.c decimal64.c decimal128.c - -INTERNALLIB= -WARNS?= 1 - -.include diff --git a/gnu/usr.bin/cc/libdecnumber/Makefile.depend b/gnu/usr.bin/cc/libdecnumber/Makefile.depend deleted file mode 100644 index ea841fdbb8d..00000000000 --- a/gnu/usr.bin/cc/libdecnumber/Makefile.depend +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/usr.bin/cc/cc_tools \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/libdecnumber/config.h b/gnu/usr.bin/cc/libdecnumber/config.h deleted file mode 100644 index 53b586f254d..00000000000 --- a/gnu/usr.bin/cc/libdecnumber/config.h +++ /dev/null @@ -1,80 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.ac by autoheader. */ -/* $FreeBSD$ */ - -/* Define to 1 if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "gcc-bugs@gcc.gnu.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "libdecnumber" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libdecnumber " - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libdecnumber" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION " " - -/* The size of a `char', as computed by sizeof. */ -/* #undef SIZEOF_CHAR */ - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 8 - -/* The size of a `short', as computed by sizeof. */ -/* #undef SIZEOF_SHORT */ - -/* The size of a `void *', as computed by sizeof. */ -/* #undef SIZEOF_VOID_P */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `long' if does not define. */ -/* #undef off_t */ - -#include diff --git a/gnu/usr.bin/cc/libiberty/Makefile b/gnu/usr.bin/cc/libiberty/Makefile deleted file mode 100644 index adaa1287879..00000000000 --- a/gnu/usr.bin/cc/libiberty/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -.include - -# -# Make sure we will pick up our config.h file first, not the one from -# cc_tools. -# -CFLAGS+= -I${.CURDIR} - -.include "../Makefile.inc" - -.PATH: ${GCCLIB}/libiberty - -LIB= iberty -SRCS= argv.c choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ - dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \ - hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \ - partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \ - xmalloc.c xmemdup.c xstrdup.c xstrerror.c make-relative-prefix.c \ - pexecute.c pex-common.c pex-one.c lrealpath.c strverscmp.c \ - regex.c -INTERNALLIB= -WARNS?= 1 - -CFLAGS+= -UPREFIX - -.include diff --git a/gnu/usr.bin/cc/libiberty/Makefile.depend b/gnu/usr.bin/cc/libiberty/Makefile.depend deleted file mode 100644 index 18be76b0cb6..00000000000 --- a/gnu/usr.bin/cc/libiberty/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/cc/libiberty/config.h b/gnu/usr.bin/cc/libiberty/config.h deleted file mode 100644 index 5a99758f863..00000000000 --- a/gnu/usr.bin/cc/libiberty/config.h +++ /dev/null @@ -1,448 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.in. Generated from configure.ac by autoheader. */ -/* $FreeBSD$ */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ALLOCA_H */ - -/* Define to 1 if you have the `asprintf' function. */ -#define HAVE_ASPRINTF 1 - -/* Define to 1 if you have the `atexit' function. */ -#define HAVE_ATEXIT 1 - -/* Define to 1 if you have the `basename' function. */ -#define HAVE_BASENAME 1 - -/* Define to 1 if you have the `bcmp' function. */ -#define HAVE_BCMP 1 - -/* Define to 1 if you have the `bcopy' function. */ -#define HAVE_BCOPY 1 - -/* Define to 1 if you have the `bsearch' function. */ -#define HAVE_BSEARCH 1 - -/* Define to 1 if you have the `bzero' function. */ -#define HAVE_BZERO 1 - -/* Define to 1 if you have the `calloc' function. */ -#define HAVE_CALLOC 1 - -/* Define to 1 if you have the `canonicalize_file_name' function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define to 1 if you have the `clock' function. */ -#define HAVE_CLOCK 1 - -/* Define to 1 if you have the declaration of `asprintf', and to 0 if you - don't. */ -#define HAVE_DECL_ASPRINTF 1 - -/* Define to 1 if you have the declaration of `basename', and to 0 if you - don't. */ -#define HAVE_DECL_BASENAME 0 - -/* Define to 1 if you have the declaration of `calloc', and to 0 if you don't. - */ -#define HAVE_DECL_CALLOC 1 - -/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ -#define HAVE_DECL_FFS 1 - -/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. - */ -#define HAVE_DECL_GETENV 1 - -/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. - */ -#define HAVE_DECL_GETOPT 1 - -/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. - */ -#define HAVE_DECL_MALLOC 1 - -/* Define to 1 if you have the declaration of `realloc', and to 0 if you - don't. */ -#define HAVE_DECL_REALLOC 1 - -/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. - */ -#define HAVE_DECL_SBRK 1 - -/* Define to 1 if you have the declaration of `snprintf', and to 0 if you - don't. */ -#define HAVE_DECL_SNPRINTF 1 - -/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you - don't. */ -#define HAVE_DECL_STRVERSCMP 0 - -/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VASPRINTF 1 - -/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you - don't. */ -#define HAVE_DECL_VSNPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `ffs' function. */ -#define HAVE_FFS 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - -/* Define to 1 if you have the `getcwd' function. */ -#define HAVE_GETCWD 1 - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the `getrusage' function. */ -#define HAVE_GETRUSAGE 1 - -/* Define to 1 if you have the `getsysinfo' function. */ -/* #undef HAVE_GETSYSINFO */ - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `index' function. */ -#define HAVE_INDEX 1 - -/* Define to 1 if you have the `insque' function. */ -#define HAVE_INSQUE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MACHINE_HAL_SYSINFO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define to 1 if you have the `memchr' function. */ -#define HAVE_MEMCHR 1 - -/* Define to 1 if you have the `memcmp' function. */ -#define HAVE_MEMCMP 1 - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mempcpy' function. */ -/* #undef HAVE_MEMPCPY */ - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mkstemps' function. */ -#define HAVE_MKSTEMPS 1 - -/* Define to 1 if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define to 1 if you have the `on_exit' function. */ -/* #undef HAVE_ON_EXIT */ - -/* Define to 1 if you have the `psignal' function. */ -#define HAVE_PSIGNAL 1 - -/* Define to 1 if you have the `pstat_getdynamic' function. */ -/* #undef HAVE_PSTAT_GETDYNAMIC */ - -/* Define to 1 if you have the `pstat_getstatic' function. */ -/* #undef HAVE_PSTAT_GETSTATIC */ - -/* Define to 1 if you have the `putenv' function. */ -#define HAVE_PUTENV 1 - -/* Define to 1 if you have the `random' function. */ -#define HAVE_RANDOM 1 - -/* Define to 1 if you have the `realpath' function. */ -#define HAVE_REALPATH 1 - -/* Define to 1 if you have the `rename' function. */ -#define HAVE_RENAME 1 - -/* Define to 1 if you have the `rindex' function. */ -#define HAVE_RINDEX 1 - -/* Define to 1 if you have the `sbrk' function. */ -/* #undef HAVE_SBRK */ - -/* Define to 1 if you have the `setenv' function. */ -#define HAVE_SETENV 1 - -/* Define to 1 if you have the `sigsetmask' function. */ -#define HAVE_SIGSETMASK 1 - -/* Define to 1 if you have the `snprintf' function. */ -#define HAVE_SNPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STDIO_EXT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `stpcpy' function. */ -#define HAVE_STPCPY 1 - -/* Define to 1 if you have the `stpncpy' function. */ -/* #undef HAVE_STPNCPY */ - -/* Define to 1 if you have the `strcasecmp' function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strncasecmp' function. */ -#define HAVE_STRNCASECMP 1 - -/* Define to 1 if you have the `strndup' function. */ -#define HAVE_STRNDUP 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strsignal' function. */ -#define HAVE_STRSIGNAL 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the `strtod' function. */ -#define HAVE_STRTOD 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - -/* Define to 1 if you have the `strverscmp' function. */ -/* #undef HAVE_STRVERSCMP */ - -/* Define to 1 if you have the `sysconf' function. */ -#define HAVE_SYSCONF 1 - -/* Define to 1 if you have the `sysctl' function. */ -#define HAVE_SYSCTL 1 - -/* Define to 1 if you have the `sysmp' function. */ -/* #undef HAVE_SYSMP */ - -/* Define if you have the sys_errlist variable. */ -#define HAVE_SYS_ERRLIST 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MMAN_H 1 - -/* Define if you have the sys_nerr variable. */ -#define HAVE_SYS_NERR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_PSTAT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define if you have the sys_siglist variable. */ -#define HAVE_SYS_SIGLIST 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCTL_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSINFO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSMP_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSTEMCFG_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TABLE_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the `table' function. */ -/* #undef HAVE_TABLE */ - -/* Define to 1 if you have the `times' function. */ -#define HAVE_TIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the `tmpnam' function. */ -#define HAVE_TMPNAM 1 - -/* Define if you have the \`uintptr_t' type. */ -#define HAVE_UINTPTR_T 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `vasprintf' function. */ -#define HAVE_VASPRINTF 1 - -/* Define to 1 if you have the `vfork' function. */ -#define HAVE_VFORK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VFORK_H */ - -/* Define to 1 if you have the `vfprintf' function. */ -#define HAVE_VFPRINTF 1 - -/* Define to 1 if you have the `vprintf' function. */ -#define HAVE_VPRINTF 1 - -/* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the `vsprintf' function. */ -#define HAVE_VSPRINTF 1 - -/* Define to 1 if you have the `wait3' function. */ -#define HAVE_WAIT3 1 - -/* Define to 1 if you have the `wait4' function. */ -#define HAVE_WAIT4 1 - -/* Define to 1 if you have the `waitpid' function. */ -#define HAVE_WAITPID 1 - -/* Define to 1 if `fork' works. */ -#define HAVE_WORKING_FORK 1 - -/* Define to 1 if `vfork' works. */ -#define HAVE_WORKING_VFORK 1 - -/* Define to 1 if you have the `_doprnt' function. */ -/* #undef HAVE__DOPRNT */ - -/* Define if you have the _system_configuration variable. */ -/* #undef HAVE__SYSTEM_CONFIGURATION */ - -/* Define to 1 if you have the `__fsetlocking' function. */ -/* #undef HAVE___FSETLOCKING */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if errno must be declared even when is included. */ -/* #undef NEED_DECLARATION_ERRNO */ - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* Define if you know the direction of stack growth for your system; otherwise - it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows - toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#define STACK_DIRECTION -1 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to an unsigned 64-bit type available in the compiler. */ -#define UNSIGNED_64BIT_TYPE uint64_t - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Define to `unsigned long' if does not define. */ -/* #undef uintptr_t */ - -/* Define as `fork' if `vfork' does not work. */ -/* #undef vfork */ - -#include diff --git a/gnu/usr.bin/dtc/Makefile b/gnu/usr.bin/dtc/Makefile deleted file mode 100644 index d9fcc6404a9..00000000000 --- a/gnu/usr.bin/dtc/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# $FreeBSD$ - -.include - -DTCDIR= ${.CURDIR}/../../../contrib/dtc -_LIBFDTDIR= ${.CURDIR}/../../../sys/contrib/libfdt -.PATH: ${DTCDIR} ${_LIBFDTDIR} - -PROG= dtc - -SRCS= dtc.c checks.c fstree.c livetree.c treesource.c data.c \ - flattree.c srcpos.c util.c \ - fdt.c fdt_ro.c fdt_rw.c fdt_strerror.c \ - fdt_sw.c fdt_wip.c ${DTCVERSIONFILE} - -WARNS?= 2 -CFLAGS+= -I. -I${.CURDIR} -I${DTCDIR} -I${_LIBFDTDIR} - -VERSIONMAJ!= awk '/^VERSION =/ { print $$3 }' ${DTCDIR}/Makefile -VERSIONMIN!= awk '/^PATCHLEVEL =/ { print $$3 }' ${DTCDIR}/Makefile -VERSIONSUB!= awk '/^SUBLEVEL =/ { print $$3 }' ${DTCDIR}/Makefile -VERSIONEXTRA= - -DTCVERSION:= ${VERSIONMAJ}.${VERSIONMIN}.${VERSIONSUB}${VERSIONEXTRA} -DTCVERSIONFILE:= version_gen.h - -MAN= - -BISON= yacc -LEX= lex - -OBJS+= dtc-parser.tab.o dtc-lexer.lex.o - -CLEANFILES+= dtc-parser.tab.o dtc-lexer.lex.o dtc-parser.tab.c \ - dtc-parser.tab.h dtc-lexer.lex.c ${DTCVERSIONFILE} - -${DTCVERSIONFILE}: ${DTCDIR}/Makefile - @echo '#define DTC_VERSION "DTC ${DTCVERSION}"' > ${DTCVERSIONFILE} - -dtc-parser.tab.o: dtc-parser.tab.c dtc-parser.tab.h -dtc-lexer.lex.o: dtc-lexer.lex.c dtc-parser.tab.h - -dtc-parser.tab.c: dtc-parser.y - ${BISON} -o$@ -d ${DTCDIR}/dtc-parser.y - -dtc-parser.tab.h: dtc-parser.tab.c - -dtc-lexer.lex.c: dtc-lexer.l - ${LEX} -o$@ ${DTCDIR}/dtc-lexer.l - -.include diff --git a/gnu/usr.bin/dtc/Makefile.depend b/gnu/usr.bin/dtc/Makefile.depend deleted file mode 100644 index d084433f911..00000000000 --- a/gnu/usr.bin/dtc/Makefile.depend +++ /dev/null @@ -1,18 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.bin/yacc.host \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/gdb/Makefile b/gnu/usr.bin/gdb/Makefile deleted file mode 100644 index c9564c232a3..00000000000 --- a/gnu/usr.bin/gdb/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ - -.include - -SUBDIR= libgdb gdb kgdb - -.if ${MK_GDB_LIBEXEC} == "no" -.if exists(${.CURDIR}/gdbserver/reg-${MACHINE_CPUARCH}.c) -SUBDIR+=gdbserver -.endif -.endif - -.include diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc deleted file mode 100644 index 069e7929ab2..00000000000 --- a/gnu/usr.bin/gdb/Makefile.inc +++ /dev/null @@ -1,69 +0,0 @@ -.include - -VERSION= "6.1.1 [MidnightBSD]" -VENDOR= marcel - -PACKAGE= gdb - -BMAKE_GDB= ${.CURDIR:H} -BMAKE_ROOT= ${BMAKE_GDB:H} -BMAKE_BU= ${BMAKE_ROOT}/binutils - -CNTRB_BU= ${SRCTOP}/contrib/binutils -CNTRB_GDB= ${SRCTOP}/contrib/gdb - -OBJ_BU= ${OBJTOP}/gnu/usr.bin/binutils -OBJ_GDB= ${OBJTOP}/gnu/usr.bin/gdb - -# These assignments duplicate much of the functionality of -# MACHINE_CPUARCH, but there's no easy way to export make functions... - -.if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} -.else -TARGET_CPUARCH=${MACHINE_CPUARCH} -.endif -TARGET_ARCH?= ${MACHINE_ARCH} -TARGET_SUBDIR= ${BMAKE_GDB}/arch/${TARGET_CPUARCH} - -.if ${TARGET_ARCH} != ${MACHINE_ARCH} -GDB_CROSS_DEBUGGER= -.endif - -.PATH: ${CNTRB_GDB}/gdb ${CNTRB_GDB}/gdb/cli ${CNTRB_GDB}/gdb/mi \ - ${CNTRB_GDB}/gdb/signals ${CNTRB_GDB}/gdb/tui ${TARGET_SUBDIR} - -CFLAGS+= -DHAVE_CONFIG_H -DRL_NO_COMPAT -DMI_OUT=1 -CFLAGS+= -DDEBUGDIR=\"${DEBUGDIR}\" -CFLAGS+= -I. -CFLAGS+= -I${TARGET_SUBDIR} -CFLAGS+= -I${BMAKE_BU}/libbfd -I${BMAKE_BU}/libbfd/${TARGET_CPUARCH} -CFLAGS+= -I${CNTRB_GDB}/gdb -CFLAGS+= -I${CNTRB_GDB}/gdb/config -CFLAGS+= -I${CNTRB_BU}/include -CFLAGS+= -I${CNTRB_GDB}/include -CFLAGS+= -I${CNTRB_BU}/bfd -CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/edit - -# Some bits here currently rely on some of the linker-merging magic that happens -# with -fcommon. While this is the default right now, explicitly set -fcommon -# so that it continues to build when the default flips. -CFCOMMONFLAG= -fcommon - -GENSRCS+= nm.h tm.h - -.if defined(GDB_CROSS_DEBUGGER) -CFLAGS+= -DCROSS_DEBUGGER -I${BMAKE_ROOT:H:H} -GDB_SUFFIX= -${TARGET_ARCH} -MAN= -.elif ${MK_GDB_LIBEXEC} != "no" -BINDIR?= /usr/libexec -MAN= -.endif - -.include "${TARGET_SUBDIR}/Makefile" - -SRCS+= ${GENSRCS} -CLEANFILES+= ${GENSRCS} - -.include "../Makefile.inc" diff --git a/gnu/usr.bin/gdb/arch/amd64/Makefile b/gnu/usr.bin/gdb/arch/amd64/Makefile deleted file mode 100644 index a43e894e749..00000000000 --- a/gnu/usr.bin/gdb/arch/amd64/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# $FreeBSD$ - -GENSRCS+= xm.h -.if !defined(GDB_CROSS_DEBUGGER) -LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c -LIBSRCS+= amd64-nat.c amd64bsd-nat.c amd64fbsd-nat.c -.endif -LIBSRCS+= solib.c solib-svr4.c -LIBSRCS+= amd64-tdep.c amd64fbsd-tdep.c i386-tdep.c i386bsd-tdep.c \ - i386fbsd-tdep-fixed.c i387-tdep.c - -nm.h: - echo '#include "i386/nm-fbsd64.h"' > ${.TARGET} - -tm.h: - echo '#include "i386/tm-fbsd.h"' > ${.TARGET} - -xm.h: - echo '#include "i386/xm-i386.h"' > ${.TARGET} - -# Fix source static/extern mismatch nits that GCC 4.2 warns about. -CLEANFILES+= i386fbsd-tdep-fixed.c -i386fbsd-tdep-fixed.c: i386fbsd-tdep.c - sed -e '48s/^static //' ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/amd64/config.h b/gnu/usr.bin/gdb/arch/amd64/config.h deleted file mode 100644 index 6908c793ece..00000000000 --- a/gnu/usr.bin/gdb/arch/amd64/config.h +++ /dev/null @@ -1,550 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated automatically by configure. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if the `long double' type works. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define if you have . */ -/* #undef HAVE_VFORK_H */ - -/* Define as __inline if that's what the C compiler calls it. */ -/* #undef inline */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define vfork as fork if vfork does not work. */ -/* #undef vfork */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Define if your struct reg has r_fs. */ -/* #undef HAVE_STRUCT_REG_R_FS */ - -/* Define if your struct stat has st_blocks. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define if your struct reg has r_gs. */ -/* #undef HAVE_STRUCT_REG_R_GS */ - -/* Define if exists and defines struct link_map which has - members with an ``l_'' prefix. (For Solaris, SVR4, and - SVR4-like systems.) */ -#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 - -/* Define if exists and defines struct link_map which has - members with an ``lm_'' prefix. (For SunOS.) */ -/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ - -/* Define if exists and defines a struct so_map which has - members with an ``som_'' prefix. (Found on older *BSD systems.) */ -/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ - -/* Define if has struct link_map32 */ -/* #undef HAVE_STRUCT_LINK_MAP32 */ - -/* Define if has link_map32 (solaris sparc-64 target) */ -/* #undef _SYSCALL32 */ - -/* Define if the prfpregset_t type is broken. */ -/* #undef PRFPREGSET_T_BROKEN */ - -/* Define if you want to use new multi-fd /proc interface - (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ -/* #undef NEW_PROC_API */ - -/* Define if ioctl argument PIOCSET is available. */ -/* #undef HAVE_PROCFS_PIOCSET */ - -/* Define if the `long long' type works. */ -#define CC_HAS_LONG_LONG 1 - -/* Define if the "ll" format works to print long long ints. */ -#define PRINTF_HAS_LONG_LONG 1 - -/* Define if the "%Lg" format works to print long doubles. */ -#define PRINTF_HAS_LONG_DOUBLE 1 - -/* Define if the "%Lg" format works to scan long doubles. */ -#define SCANF_HAS_LONG_DOUBLE 1 - -/* Define if using Solaris thread debugging. */ -/* #undef HAVE_THREAD_DB_LIB */ - -/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ -/* #undef START_INFERIOR_TRAPS_EXPECTED */ -/* #undef sys_quotactl */ - -/* Define if you have HPUX threads */ -/* #undef HAVE_HPUX_THREAD_SUPPORT */ - -/* Define if on solaris uses int instead of - size_t, and assorted other type changes. */ -/* #undef PROC_SERVICE_IS_OLD */ - -/* Define if the simulator is being linked in. */ -#define WITH_SIM 1 - -/* Set to true if the save_state_t structure is present */ -/* #undef HAVE_STRUCT_SAVE_STATE_T */ - -/* Set to true if the save_state_t structure has the ss_wide member */ -/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ - -/* Define if defines the PTRACE_GETREGS request. */ -/* #undef HAVE_PTRACE_GETREGS */ - -/* Define if defines the PTRACE_GETFPXREGS request. */ -/* #undef HAVE_PTRACE_GETFPXREGS */ - -/* Define if defines the PT_GETDBREGS request. */ -#define HAVE_PT_GETDBREGS 1 - -/* Define if defines the PT_GETXMMREGS request. */ -/* #undef HAVE_PT_GETXMMREGS */ - -/* Define if libunwind library is being used. */ -/* #undef HAVE_LIBUNWIND */ - -/* hostfile */ -#define GDB_XM_FILE config/i386/xm-i386.h - -/* targetfile */ -#define GDB_TM_FILE config/i386/tm-fbsd.h - -/* nativefile */ -#ifndef CROSS_DEBUGGER -#define GDB_NM_FILE config/i386/nm-fbsd64.h -#endif - -/* Define to 1 so gets a definition of anon_hdl. Works - around a problem on IRIX 5. */ -#ifndef _KMEMUSER -/* #undef _KMEMUSER */ -#endif - -/* Define if you have the __argz_count function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define if you have the __argz_next function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define if you have the __argz_stringify function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define if you have the _mcleanup function. */ -#define HAVE__MCLEANUP 1 - -/* Define if you have the canonicalize_file_name function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define if you have the dcgettext function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the monstartup function. */ -#define HAVE_MONSTARTUP 1 - -/* Define if you have the munmap function. */ -#define HAVE_MUNMAP 1 - -/* Define if you have the poll function. */ -#define HAVE_POLL 1 - -/* Define if you have the pread64 function. */ -/* #undef HAVE_PREAD64 */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the realpath function. */ -#define HAVE_REALPATH 1 - -/* Define if you have the sbrk function. */ -/* #undef HAVE_SBRK */ - -/* Define if you have the setenv function. */ -#define HAVE_SETENV 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setpgrp function. */ -#define HAVE_SETPGRP 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the sigprocmask function. */ -#define HAVE_SIGPROCMASK 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 1 - -/* Define if you have the socketpair function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define if you have the stpcpy function. */ -#define HAVE_STPCPY 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the syscall function. */ -#define HAVE_SYSCALL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the header file. */ -#define HAVE_CURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_IA64_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_MACHINE_REG_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_PROC_SERVICE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PTRACE_H */ - -/* Define if you have the header file. */ -#define HAVE_SGTTY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DEBUGREG_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FAULT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_REG_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_USER_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIO_H */ - -/* Define if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_DB_H */ - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_VALUES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_WAIT_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the w library (-lw). */ -/* #undef HAVE_LIBW */ - -/* Define if you have the stpcpy function */ -#define HAVE_STPCPY 1 - -/* Define if your locale.h file contains LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if NLS is requested */ -/* #undef ENABLE_NLS */ - -/* Define as 1 if you have gettext and don't want to use GNU gettext. */ -/* #undef HAVE_GETTEXT */ - -/* Name of this package. */ -#define PACKAGE "gdb" - -/* Define to BFD's default architecture. */ -#define DEFAULT_BFD_ARCH bfd_i386_arch - -/* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf64_x86_64_vec - -/* Define to 1 if your system has the _etext variable. */ -#define HAVE__ETEXT 1 - -/* Define to 1 to avoid a clash between and on - Solaris 2.[78] when using GCC. */ -/* #undef _MSE_INT_H */ - -/* Define to 1 if we found this declaration otherwise define to 0. */ -#define HAVE_DECL_GETOPT 0 - -/* Define if sigsetjmp is available. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if the regex included in libiberty should be used. */ -#define USE_INCLUDED_REGEX 1 - -/* Define to 1 if your system has struct reg in . */ -#define HAVE_STRUCT_REG 1 - -/* Define if provides the uintptr_t type. */ -#define HAVE_UINTPTR_T 1 - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if realloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_REALLOC */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if strerror is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRERROR */ - -/* Define if strdup is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRDUP */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has prrun_t. */ -/* #undef HAVE_PRRUN_T */ - -/* Define if has gregset_t. */ -#define HAVE_GREGSET_T 1 - -/* Define if has fpregset_t. */ -#define HAVE_FPREGSET_T 1 - -/* Define if has prgregset_t. */ -#define HAVE_PRGREGSET_T 1 - -/* Define if has prfpregset_t. */ -#define HAVE_PRFPREGSET_T 1 - -/* Define if has prgregset32_t. */ -/* #undef HAVE_PRGREGSET32_T */ - -/* Define if has prfpregset32_t. */ -/* #undef HAVE_PRFPREGSET32_T */ - -/* Define if has lwpid_t. */ -#define HAVE_LWPID_T 1 - -/* Define if has psaddr_t. */ -#define HAVE_PSADDR_T 1 - -/* Define if has prsysent_t. */ -/* #undef HAVE_PRSYSENT_T */ - -/* Define if has pr_sigset_t. */ -/* #undef HAVE_PR_SIGSET_T */ - -/* Define if has pr_sigaction64_t. */ -/* #undef HAVE_PR_SIGACTION64_T */ - -/* Define if has pr_siginfo64_t. */ -/* #undef HAVE_PR_SIGINFO64_T */ - -/* Define if has the TD_NOTALLOC error code. */ -/* #undef THREAD_DB_HAS_TD_NOTALLOC */ - -/* Define if we can use the tkill syscall. */ -/* #undef HAVE_TKILL_SYSCALL */ - -/* Define to the default OS ABI for this configuration. */ -/* #undef GDB_OSABI_DEFAULT */ - -/* Define to be a string naming the default host character set. */ -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - diff --git a/gnu/usr.bin/gdb/arch/amd64/init.c b/gnu/usr.bin/gdb/arch/amd64/init.c deleted file mode 100644 index 1b296f4a940..00000000000 --- a/gnu/usr.bin/gdb/arch/amd64/init.c +++ /dev/null @@ -1,234 +0,0 @@ -/* $FreeBSD$ */ - -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ -#include "defs.h" /* For initialize_file_ftype. */ -#include "call-cmds.h" /* For initialize_all_files. */ -extern initialize_file_ftype _initialize_gdbtypes; -extern initialize_file_ftype _initialize_amd64fbsd_tdep; -extern initialize_file_ftype _initialize_i386_tdep; -extern initialize_file_ftype _initialize_i386bsd_tdep; -extern initialize_file_ftype _initialize_i386fbsd_tdep; -extern initialize_file_ftype _initialize_corelow; -extern initialize_file_ftype _initialize_solib; -extern initialize_file_ftype _initialize_svr4_solib; -extern initialize_file_ftype _initialize_ser_hardwire; -extern initialize_file_ftype _initialize_ser_pipe; -extern initialize_file_ftype _initialize_ser_tcp; -extern initialize_file_ftype _initialize_kernel_u_addr; -extern initialize_file_ftype _initialize_infptrace; -extern initialize_file_ftype _initialize_inftarg; -extern initialize_file_ftype _initialize_amd64fbsd_nat; -extern initialize_file_ftype _initialize_gcore; -extern initialize_file_ftype _initialize_fbsd_proc; -extern initialize_file_ftype _initialize_remote; -extern initialize_file_ftype _initialize_dcache; -extern initialize_file_ftype _initialize_sr_support; -extern initialize_file_ftype _initialize_tracepoint; -extern initialize_file_ftype _initialize_ax_gdb; -extern initialize_file_ftype _initialize_annotate; -extern initialize_file_ftype _initialize_auxv; -extern initialize_file_ftype _initialize_breakpoint; -extern initialize_file_ftype _initialize_regcache; -extern initialize_file_ftype _initialize_charset; -extern initialize_file_ftype _initialize_dummy_frame; -extern initialize_file_ftype _initialize_source; -extern initialize_file_ftype _initialize_values; -extern initialize_file_ftype _initialize_valops; -extern initialize_file_ftype _initialize_valarith; -extern initialize_file_ftype _initialize_valprint; -extern initialize_file_ftype _initialize_printcmd; -extern initialize_file_ftype _initialize_symtab; -extern initialize_file_ftype _initialize_symfile; -extern initialize_file_ftype _initialize_symmisc; -extern initialize_file_ftype _initialize_infcall; -extern initialize_file_ftype _initialize_infcmd; -extern initialize_file_ftype _initialize_infrun; -extern initialize_file_ftype _initialize_stack; -extern initialize_file_ftype _initialize_thread; -extern initialize_file_ftype _initialize_interpreter; -extern initialize_file_ftype _initialize_macrocmd; -extern initialize_file_ftype _initialize_gdbarch; -extern initialize_file_ftype _initialize_gdbarch_utils; -extern initialize_file_ftype _initialize_gdb_osabi; -extern initialize_file_ftype _initialize_copying; -extern initialize_file_ftype _initialize_mem; -extern initialize_file_ftype _initialize_parse; -extern initialize_file_ftype _initialize_language; -extern initialize_file_ftype _initialize_frame_reg; -extern initialize_file_ftype _initialize_signals; -extern initialize_file_ftype _initialize_kod; -extern initialize_file_ftype _initialize_gdb_events; -extern initialize_file_ftype _initialize_exec; -extern initialize_file_ftype _initialize_maint_cmds; -extern initialize_file_ftype _initialize_demangler; -extern initialize_file_ftype _initialize_dbxread; -extern initialize_file_ftype _initialize_coffread; -extern initialize_file_ftype _initialize_elfread; -extern initialize_file_ftype _initialize_mipsread; -extern initialize_file_ftype _initialize_stabsread; -extern initialize_file_ftype _initialize_core; -extern initialize_file_ftype _initialize_dwarf2_frame; -extern initialize_file_ftype _initialize_c_language; -extern initialize_file_ftype _initialize_f_language; -extern initialize_file_ftype _initialize_objc_language; -extern initialize_file_ftype _initialize_ui_out; -extern initialize_file_ftype _initialize_cli_out; -extern initialize_file_ftype _initialize_varobj; -extern initialize_file_ftype _initialize_java_language; -extern initialize_file_ftype _initialize_m2_language; -extern initialize_file_ftype _initialize_pascal_language; -extern initialize_file_ftype _initialize_pascal_valprint; -extern initialize_file_ftype _initialize_scheme_language; -extern initialize_file_ftype _initialize_complaints; -extern initialize_file_ftype _initialize_typeprint; -extern initialize_file_ftype _initialize_cp_valprint; -extern initialize_file_ftype _initialize_f_valprint; -extern initialize_file_ftype _initialize_nlmread; -extern initialize_file_ftype _initialize_serial; -extern initialize_file_ftype _initialize_mdebugread; -extern initialize_file_ftype _initialize_user_regs; -extern initialize_file_ftype _initialize_frame; -extern initialize_file_ftype _initialize_frame_unwind; -extern initialize_file_ftype _initialize_frame_base; -extern initialize_file_ftype _initialize_gnu_v2_abi; -extern initialize_file_ftype _initialize_gnu_v3_abi; -extern initialize_file_ftype _initialize_hpacc_abi; -extern initialize_file_ftype _initialize_cp_abi; -extern initialize_file_ftype _initialize_cp_support; -extern initialize_file_ftype _initialize_cp_namespace; -extern initialize_file_ftype _initialize_reggroup; -extern initialize_file_ftype _initialize_inflow; -extern initialize_file_ftype _initialize_cli_dump; -extern initialize_file_ftype _initialize_cli_logging; -extern initialize_file_ftype _initialize_cli_interp; -extern initialize_file_ftype _initialize_mi_out; -extern initialize_file_ftype _initialize_mi_cmds; -extern initialize_file_ftype _initialize_mi_cmd_env; -extern initialize_file_ftype _initialize_mi_interp; -extern initialize_file_ftype _initialize_mi_main; -extern initialize_file_ftype _initialize_thread_db; -extern initialize_file_ftype _initialize_tui_hooks; -extern initialize_file_ftype _initialize_tui_interp; -extern initialize_file_ftype _initialize_tui_layout; -extern initialize_file_ftype _initialize_tui_out; -extern initialize_file_ftype _initialize_tui_regs; -extern initialize_file_ftype _initialize_tui_stack; -extern initialize_file_ftype _initialize_tui_win; -void -initialize_all_files (void) -{ - _initialize_gdbtypes (); - _initialize_amd64fbsd_tdep (); - _initialize_i386_tdep (); - _initialize_i386bsd_tdep (); - _initialize_i386fbsd_tdep (); - _initialize_corelow (); - _initialize_solib (); - _initialize_svr4_solib (); - _initialize_ser_hardwire (); - _initialize_ser_pipe (); - _initialize_ser_tcp (); -#ifndef CROSS_DEBUGGER - _initialize_kernel_u_addr (); - _initialize_infptrace (); - _initialize_inftarg (); - _initialize_amd64fbsd_nat (); - _initialize_gcore (); - _initialize_fbsd_proc (); - _initialize_thread_db (); -#endif - _initialize_remote (); - _initialize_dcache (); - _initialize_sr_support (); - _initialize_tracepoint (); - _initialize_ax_gdb (); - _initialize_annotate (); - _initialize_auxv (); - _initialize_breakpoint (); - _initialize_regcache (); - _initialize_charset (); - _initialize_dummy_frame (); - _initialize_source (); - _initialize_values (); - _initialize_valops (); - _initialize_valarith (); - _initialize_valprint (); - _initialize_printcmd (); - _initialize_symtab (); - _initialize_symfile (); - _initialize_symmisc (); - _initialize_infcall (); - _initialize_infcmd (); - _initialize_infrun (); - _initialize_stack (); - _initialize_thread (); - _initialize_interpreter (); - _initialize_macrocmd (); - _initialize_gdbarch (); - _initialize_gdbarch_utils (); - _initialize_gdb_osabi (); - _initialize_copying (); - _initialize_mem (); - _initialize_parse (); - _initialize_language (); - _initialize_frame_reg (); - _initialize_signals (); - _initialize_kod (); - _initialize_gdb_events (); - _initialize_exec (); - _initialize_maint_cmds (); - _initialize_demangler (); - _initialize_dbxread (); - _initialize_coffread (); - _initialize_elfread (); - _initialize_mipsread (); - _initialize_stabsread (); - _initialize_core (); - _initialize_dwarf2_frame (); - _initialize_c_language (); - _initialize_f_language (); - _initialize_objc_language (); - _initialize_ui_out (); - _initialize_cli_out (); - _initialize_varobj (); - _initialize_java_language (); - _initialize_m2_language (); - _initialize_pascal_language (); - _initialize_pascal_valprint (); - _initialize_scheme_language (); - _initialize_complaints (); - _initialize_typeprint (); - _initialize_cp_valprint (); - _initialize_f_valprint (); - _initialize_nlmread (); - _initialize_serial (); - _initialize_mdebugread (); - _initialize_user_regs (); - _initialize_frame (); - _initialize_frame_unwind (); - _initialize_frame_base (); - _initialize_gnu_v2_abi (); - _initialize_gnu_v3_abi (); - _initialize_hpacc_abi (); - _initialize_cp_abi (); - _initialize_cp_support (); - _initialize_cp_namespace (); - _initialize_reggroup (); - _initialize_inflow (); - _initialize_cli_dump (); - _initialize_cli_logging (); - _initialize_cli_interp (); - _initialize_mi_out (); - _initialize_mi_cmds (); - _initialize_mi_cmd_env (); - _initialize_mi_interp (); - _initialize_mi_main (); - _initialize_tui_hooks (); - _initialize_tui_interp (); - _initialize_tui_layout (); - _initialize_tui_out (); - _initialize_tui_regs (); - _initialize_tui_stack (); - _initialize_tui_win (); -} diff --git a/gnu/usr.bin/gdb/arch/arm/Makefile b/gnu/usr.bin/gdb/arch/arm/Makefile deleted file mode 100644 index 22aee06a7bf..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ - -GENSRCS+= xm.h -LIBSRCS+= armfbsd-nat.c -LIBSRCS+= arm-tdep.c armfbsd-tdep.c solib.c solib-svr4.c -.if !defined(GDB_CROSS_DEBUGGER) -LIBSRCS+= fbsd-threads.c -.endif - -nm.h: -#XXX this should be arm/nm-fbsd.h but won't until it's merged into the gdb repo - echo '#include "nm-fbsd.h"' > ${.TARGET} - -tm.h: -#XXX this should be arm/tm-fbsd.h - echo '#include "tm-fbsd.h"' > ${.TARGET} - -xm.h: -#XXX this should be arm/xm-fbsd.h - echo '#include "xm-fbsd.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/arm/armfbsd-nat.c b/gnu/usr.bin/gdb/arch/arm/armfbsd-nat.c deleted file mode 100644 index 674deffaa3f..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/armfbsd-nat.c +++ /dev/null @@ -1,552 +0,0 @@ -/* $FreeBSD$ */ - - /* Native-dependent code for BSD Unix running on ARM's, for GDB. - Copyright 1988, 1989, 1991, 1992, 1994, 1996, 1999, 2002 - Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include "defs.h" - -#ifndef FETCH_INFERIOR_REGISTERS -#ifndef CROSS_DEBUGGER -#error Not FETCH_INFERIOR_REGISTERS -#endif -#endif /* !FETCH_INFERIOR_REGISTERS */ - -#include "arm-tdep.h" - -#include -#ifndef CROSS_DEBUGGER -#include -#include -#include -#endif -#include "inferior.h" -#include "regcache.h" -#include "gdbcore.h" - -extern int arm_apcs_32; - -#ifdef CROSS_DEBUGGER -struct reg { - unsigned int r[13]; - unsigned int r_sp; - unsigned int r_lr; - unsigned int r_pc; - unsigned int r_cpsr; -}; - -typedef struct fp_extended_precision { - u_int32_t fp_exponent; - u_int32_t fp_mantissa_hi; - u_int32_t fp_mantissa_lo; -} fp_extended_precision_t; - -typedef struct fp_extended_precision fp_reg_t; - -struct fpreg { - unsigned int fpr_fpsr; - fp_reg_t fpr[8]; -}; -#endif - -void -supply_gregset (struct reg *gregset) -{ - int regno; - CORE_ADDR r_pc; - - /* Integer registers. */ - for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++) - supply_register (regno, (char *) &gregset->r[regno]); - - supply_register (ARM_SP_REGNUM, (char *) &gregset->r_sp); - supply_register (ARM_LR_REGNUM, (char *) &gregset->r_lr); - supply_register (ARM_PC_REGNUM, (char *) &gregset->r_pc); - - if (arm_apcs_32) - supply_register (ARM_PS_REGNUM, (char *) &gregset->r_cpsr); - else - supply_register (ARM_PS_REGNUM, (char *) &gregset->r_pc); -} - -/* Fill register REGNO (if it is a general-purpose register) in - *GREGSETPS with the value in GDB's register array. If REGNO is -1, - do this for all registers. */ - -void -fill_gregset (struct reg *gregset, int regno) -{ - int i; - - for (i = ARM_A1_REGNUM; i < ARM_SP_REGNUM; i++) - if ((regno == -1 || regno == i)) - regcache_collect (i, &gregset->r[i]); - if (regno == -1 || regno == ARM_SP_REGNUM) - regcache_collect (ARM_SP_REGNUM, &gregset->r_sp); - if (regno == -1 || regno == ARM_LR_REGNUM) - regcache_collect (ARM_LR_REGNUM, &gregset->r_lr); - if (regno == -1 || regno == ARM_PC_REGNUM) - regcache_collect (ARM_PC_REGNUM, &gregset->r_pc); - if (regno == -1 || regno == ARM_PS_REGNUM) - regcache_collect (ARM_PS_REGNUM, &gregset->r_cpsr); -} - -void -supply_fpregset (struct fpreg *fparegset) -{ - int regno; - - for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) - supply_register - (regno, (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]); - - supply_register (ARM_FPS_REGNUM, (char *) &fparegset->fpr_fpsr); -} - -void -fill_fpregset (struct fpreg *fparegset, int regno) -{ - int i; - - for (i = ARM_F0_REGNUM; i <= ARM_F7_REGNUM; i++) - if (regno == -1 || regno == i) - regcache_raw_supply(current_regcache, i, - &fparegset->fpr[i - ARM_F0_REGNUM]); - if (regno == -1 || regno == ARM_FPS_REGNUM) - regcache_raw_supply(current_regcache, ARM_FPS_REGNUM, - &fparegset->fpr_fpsr); -} - -static void -fetch_register (int regno) -{ - struct reg inferior_registers; -#ifndef CROSS_DEBUGGER - int ret; - - ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_registers, 0); - - if (ret < 0) - { - warning ("unable to fetch general register"); - return; - } -#endif - - switch (regno) - { - case ARM_SP_REGNUM: - supply_register (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); - break; - - case ARM_LR_REGNUM: - supply_register (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); - break; - - case ARM_PC_REGNUM: - /* This is ok: we're running native... */ - inferior_registers.r_pc = ADDR_BITS_REMOVE (inferior_registers.r_pc); - supply_register (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); - break; - - case ARM_PS_REGNUM: - if (arm_apcs_32) - supply_register (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); - else - supply_register (ARM_PS_REGNUM, (char *) &inferior_registers.r_pc); - break; - - default: - supply_register (regno, (char *) &inferior_registers.r[regno]); - break; - } -} - -static void -fetch_regs (void) -{ - struct reg inferior_registers; -#ifndef CROSS_DEBUGGER - int ret; -#endif - int regno; - -#ifndef CROSS_DEBUGGER - ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_registers, 0); - - if (ret < 0) - { - warning ("unable to fetch general registers"); - return; - } -#endif - - supply_gregset (&inferior_registers); -} - -static void -fetch_fp_register (int regno) -{ - struct fpreg inferior_fp_registers; -#ifndef CROSS_DEBUGGER - int ret; - - ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); - - if (ret < 0) - { - warning ("unable to fetch floating-point register"); - return; - } -#endif - - switch (regno) - { - case ARM_FPS_REGNUM: - supply_register (ARM_FPS_REGNUM, - (char *) &inferior_fp_registers.fpr_fpsr); - break; - - default: - supply_register - (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); - break; - } -} - -static void -fetch_fp_regs (void) -{ - struct fpreg inferior_fp_registers; -#ifndef CROSS_DEBUGGER - int ret; -#endif - int regno; - -#ifndef CROSS_DEBUGGER - ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); - - if (ret < 0) - { - warning ("unable to fetch general registers"); - return; - } -#endif - - supply_fpregset (&inferior_fp_registers); -} - -void -fetch_inferior_registers (int regno) -{ - if (regno >= 0) - { - if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) - fetch_register (regno); - else - fetch_fp_register (regno); - } - else - { - fetch_regs (); - fetch_fp_regs (); - } -} - - -static void -store_register (int regno) -{ - struct reg inferior_registers; -#ifndef CROSS_DEBUGGER - int ret; - - ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_registers, 0); - - if (ret < 0) - { - warning ("unable to fetch general registers"); - return; - } -#endif - - switch (regno) - { - case ARM_SP_REGNUM: - regcache_collect (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); - break; - - case ARM_LR_REGNUM: - regcache_collect (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); - break; - - case ARM_PC_REGNUM: - if (arm_apcs_32) - regcache_collect (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); - else - { - unsigned pc_val; - - regcache_collect (ARM_PC_REGNUM, (char *) &pc_val); - - pc_val = ADDR_BITS_REMOVE (pc_val); - inferior_registers.r_pc - ^= ADDR_BITS_REMOVE (inferior_registers.r_pc); - inferior_registers.r_pc |= pc_val; - } - break; - - case ARM_PS_REGNUM: - if (arm_apcs_32) - regcache_collect (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); - else - { - unsigned psr_val; - - regcache_collect (ARM_PS_REGNUM, (char *) &psr_val); - - psr_val ^= ADDR_BITS_REMOVE (psr_val); - inferior_registers.r_pc = ADDR_BITS_REMOVE (inferior_registers.r_pc); - inferior_registers.r_pc |= psr_val; - } - break; - - default: - regcache_collect (regno, (char *) &inferior_registers.r[regno]); - break; - } - -#ifndef CROSS_DEBUGGER - ret = ptrace (PT_SETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_registers, 0); - - if (ret < 0) - warning ("unable to write register %d to inferior", regno); -#endif -} - -static void -store_regs (void) -{ - struct reg inferior_registers; - int ret; - int regno; - - - for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++) - regcache_collect (regno, (char *) &inferior_registers.r[regno]); - - regcache_collect (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); - regcache_collect (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); - - if (arm_apcs_32) - { - regcache_collect (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); - regcache_collect (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); - } - else - { - unsigned pc_val; - unsigned psr_val; - - regcache_collect (ARM_PC_REGNUM, (char *) &pc_val); - regcache_collect (ARM_PS_REGNUM, (char *) &psr_val); - - pc_val = ADDR_BITS_REMOVE (pc_val); - psr_val ^= ADDR_BITS_REMOVE (psr_val); - - inferior_registers.r_pc = pc_val | psr_val; - } - -#ifndef CROSS_DEBUGGER - ret = ptrace (PT_SETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_registers, 0); - - if (ret < 0) - warning ("unable to store general registers"); -#endif -} - -static void -store_fp_register (int regno) -{ - struct fpreg inferior_fp_registers; -#ifndef CROSS_DEBUGGER - int ret; - - ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); - - if (ret < 0) - { - warning ("unable to fetch floating-point registers"); - return; - } -#endif - - switch (regno) - { - case ARM_FPS_REGNUM: - regcache_collect (ARM_FPS_REGNUM, - (char *) &inferior_fp_registers.fpr_fpsr); - break; - - default: - regcache_collect - (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); - break; - } - -#ifndef CROSS_DEBUGGER - ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); - - if (ret < 0) - warning ("unable to write register %d to inferior", regno); -#endif -} - -static void -store_fp_regs (void) -{ - struct fpreg inferior_fp_registers; - int ret; - int regno; - - - for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) - regcache_collect - (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); - - regcache_collect (ARM_FPS_REGNUM, (char *) &inferior_fp_registers.fpr_fpsr); - -#ifndef CROSS_DEBUGGER - ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); - - if (ret < 0) - warning ("unable to store floating-point registers"); -#endif -} - -void -store_inferior_registers (int regno) -{ - if (regno >= 0) - { - if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) - store_register (regno); - else - store_fp_register (regno); - } - else - { - store_regs (); - store_fp_regs (); - } -} - - -struct md_core -{ - struct reg intreg; - struct fpreg freg; -}; - -static void -fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, - int which, CORE_ADDR ignore) -{ - struct md_core *core_reg = (struct md_core *) core_reg_sect; - int regno; - CORE_ADDR r_pc; - - supply_gregset (&core_reg->intreg); - supply_fpregset (&core_reg->freg); -} - -static void -fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, - int which, CORE_ADDR ignore) -{ - struct reg gregset; - struct fpreg fparegset; - - switch (which) - { - case 0: /* Integer registers. */ - if (core_reg_size != sizeof (struct reg)) - warning ("wrong size of register set in core file"); - else - { - /* The memcpy may be unnecessary, but we can't really be sure - of the alignment of the data in the core file. */ - memcpy (&gregset, core_reg_sect, sizeof (gregset)); - supply_gregset (&gregset); - } - break; - - case 2: - if (core_reg_size != sizeof (struct fpreg)) - warning ("wrong size of FPA register set in core file"); - else - { - /* The memcpy may be unnecessary, but we can't really be sure - of the alignment of the data in the core file. */ - memcpy (&fparegset, core_reg_sect, sizeof (fparegset)); - supply_fpregset (&fparegset); - } - break; - - default: - /* Don't know what kind of register request this is; just ignore it. */ - break; - } -} - -static struct core_fns arm_freebsd_core_fns = -{ - bfd_target_unknown_flavour, /* core_flovour. */ - default_check_format, /* check_format. */ - default_core_sniffer, /* core_sniffer. */ - fetch_core_registers, /* core_read_registers. */ - NULL -}; - -static struct core_fns arm_freebsd_elfcore_fns = -{ - bfd_target_elf_flavour, /* core_flovour. */ - default_check_format, /* check_format. */ - default_core_sniffer, /* core_sniffer. */ - fetch_elfcore_registers, /* core_read_registers. */ - NULL -}; - -void -_initialize_arm_fbsdnat (void) -{ - add_core_fns (&arm_freebsd_core_fns); - add_core_fns (&arm_freebsd_elfcore_fns); -} diff --git a/gnu/usr.bin/gdb/arch/arm/armfbsd-tdep.c b/gnu/usr.bin/gdb/arch/arm/armfbsd-tdep.c deleted file mode 100644 index 785897dad34..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/armfbsd-tdep.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $FreeBSD$ */ - -/* Target-specific functions for ARM running under NetBSD. - Copyright 2002, 2003 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include "defs.h" -#include "osabi.h" - -#include "arch-utils.h" -#include "arm-tdep.h" -#include "solib-svr4.h" - -/* Description of the longjmp buffer. */ -#define ARM_FBSD_JB_PC 24 -#define ARM_FBSD_JB_ELEMENT_SIZE INT_REGISTER_SIZE - -static void -arm_freebsd_init_abi_common (struct gdbarch_info info, - struct gdbarch *gdbarch) -{ - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - - tdep->lowest_pc = 0x8000; - - tdep->jb_pc = ARM_FBSD_JB_PC; - tdep->jb_elt_size = ARM_FBSD_JB_ELEMENT_SIZE; -} - -static void -arm_freebsd_elf_init_abi (struct gdbarch_info info, - struct gdbarch *gdbarch) -{ - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - - arm_freebsd_init_abi_common (info, gdbarch); - - /* FreeBSD ELF uses SVR4-style shared libraries. */ - set_gdbarch_in_solib_call_trampoline - (gdbarch, generic_in_solib_call_trampoline); - set_solib_svr4_fetch_link_map_offsets - (gdbarch, svr4_ilp32_fetch_link_map_offsets); - - tdep->fp_model = ARM_FLOAT_SOFT_VFP; -} - -void -_initialize_armfbsd_tdep (void) -{ - gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_FREEBSD_ELF, - arm_freebsd_elf_init_abi); -} diff --git a/gnu/usr.bin/gdb/arch/arm/config.h b/gnu/usr.bin/gdb/arch/arm/config.h deleted file mode 100644 index 863f2d9c701..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/config.h +++ /dev/null @@ -1,562 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated automatically by configure. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if the `long double' type works. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define if you have . */ -/* #undef HAVE_VFORK_H */ - -/* Define as __inline if that's what the C compiler calls it. */ -/* #undef inline */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define vfork as fork if vfork does not work. */ -/* #undef vfork */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Define if your struct reg has r_fs. */ -/* #define HAVE_STRUCT_REG_R_FS 1 */ - -/* Define if your struct stat has st_blocks. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define if your struct reg has r_gs. */ -/* #define HAVE_STRUCT_REG_R_GS 1 */ - -/* Define if exists and defines struct link_map which has - members with an ``l_'' prefix. (For Solaris, SVR4, and - SVR4-like systems.) */ -#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 - -/* Define if exists and defines struct link_map which has - members with an ``lm_'' prefix. (For SunOS.) */ -/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ - -/* Define if exists and defines a struct so_map which has - members with an ``som_'' prefix. (Found on older *BSD systems.) */ -/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ - -/* Define if has struct link_map32 */ -/* #undef HAVE_STRUCT_LINK_MAP32 */ - -/* Define if has link_map32 (solaris sparc-64 target) */ -/* #undef _SYSCALL32 */ - -/* Define if the prfpregset_t type is broken. */ -/* #undef PRFPREGSET_T_BROKEN */ - -/* Define if you want to use new multi-fd /proc interface - (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ -/* #undef NEW_PROC_API */ - -/* Define if ioctl argument PIOCSET is available. */ -/* #undef HAVE_PROCFS_PIOCSET */ - -/* Define if the `long long' type works. */ -#define CC_HAS_LONG_LONG 1 - -/* Define if the "ll" format works to print long long ints. */ -#define PRINTF_HAS_LONG_LONG 1 - -/* Define if the "%Lg" format works to print long doubles. */ -#define PRINTF_HAS_LONG_DOUBLE 1 - -/* Define if the "%Lg" format works to scan long doubles. */ -#define SCANF_HAS_LONG_DOUBLE 1 - -/* Define if using Solaris thread debugging. */ -/* #undef HAVE_THREAD_DB_LIB */ - -/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ -/* #undef START_INFERIOR_TRAPS_EXPECTED */ -/* #undef sys_quotactl */ - -/* Define if you have HPUX threads */ -/* #undef HAVE_HPUX_THREAD_SUPPORT */ - -/* Define if on solaris uses int instead of - size_t, and assorted other type changes. */ -/* #undef PROC_SERVICE_IS_OLD */ - -/* Define if the simulator is being linked in. */ -#define WITH_SIM 1 - -/* Set to true if the save_state_t structure is present */ -/* #undef HAVE_STRUCT_SAVE_STATE_T */ - -/* Set to true if the save_state_t structure has the ss_wide member */ -/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ - -/* Define if defines the PTRACE_GETREGS request. */ -/* #undef HAVE_PTRACE_GETREGS */ - -/* Define if defines the PTRACE_GETFPXREGS request. */ -/* #undef HAVE_PTRACE_GETFPXREGS */ - -/* Define if defines the PT_GETDBREGS request. */ -#define HAVE_PT_GETDBREGS 1 - -/* Define if defines the PT_GETXMMREGS request. */ -/* #undef HAVE_PT_GETXMMREGS */ - -/* Define if libunwind library is being used. */ -/* #undef HAVE_LIBUNWIND */ - -/* hostfile */ -#if 0 -#define GDB_XM_FILE config/arm/xm-fbsd.h -#else -#define GDB_XM_FILE xm-fbsd.h -#endif - -/* targetfile */ -#if 0 -#define GDB_TM_FILE config/arm/tm-fbsd.h -#else -#define GDB_TM_FILE tm-fbsd.h -#endif - -/* nativefile */ -#ifndef CROSS_DEBUGGER -#if 0 -#define GDB_NM_FILE config/arm/nm-fbsd.h -#else -#define GDB_NM_FILE nm-fbsd.h -#endif -#endif - -/* Define to 1 so gets a definition of anon_hdl. Works - around a problem on IRIX 5. */ -#ifndef _KMEMUSER -/* #undef _KMEMUSER */ -#endif - -/* Define if you have the __argz_count function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define if you have the __argz_next function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define if you have the __argz_stringify function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define if you have the _mcleanup function. */ -#define HAVE__MCLEANUP 1 - -/* Define if you have the canonicalize_file_name function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define if you have the dcgettext function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the monstartup function. */ -#define HAVE_MONSTARTUP 1 - -/* Define if you have the munmap function. */ -#define HAVE_MUNMAP 1 - -/* Define if you have the poll function. */ -#define HAVE_POLL 1 - -/* Define if you have the pread64 function. */ -/* #undef HAVE_PREAD64 */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the realpath function. */ -#define HAVE_REALPATH 1 - -/* Define if you have the sbrk function. */ -/* #undef HAVE_SBRK */ - -/* Define if you have the setenv function. */ -#define HAVE_SETENV 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setpgrp function. */ -#define HAVE_SETPGRP 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the sigprocmask function. */ -#define HAVE_SIGPROCMASK 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 1 - -/* Define if you have the socketpair function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define if you have the stpcpy function. */ -#define HAVE_STPCPY 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the syscall function. */ -#define HAVE_SYSCALL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the header file. */ -#define HAVE_CURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_IA64_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_MACHINE_REG_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_PROC_SERVICE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PTRACE_H */ - -/* Define if you have the header file. */ -#define HAVE_SGTTY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DEBUGREG_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FAULT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_REG_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_USER_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIO_H */ - -/* Define if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_DB_H */ - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_VALUES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_WAIT_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the w library (-lw). */ -/* #undef HAVE_LIBW */ - -/* Define if you have the stpcpy function */ -#define HAVE_STPCPY 1 - -/* Define if your locale.h file contains LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if NLS is requested */ -/* #undef ENABLE_NLS */ - -/* Define as 1 if you have gettext and don't want to use GNU gettext. */ -/* #undef HAVE_GETTEXT */ - -/* Name of this package. */ -#define PACKAGE "gdb" - -/* Define to BFD's default architecture. */ -#define DEFAULT_BFD_ARCH bfd_arm_arch - -/* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf32_littlearm_vec - -/* Define to 1 if your system has the _etext variable. */ -#define HAVE__ETEXT 1 - -/* Define to 1 to avoid a clash between and on - Solaris 2.[78] when using GCC. */ -/* #undef _MSE_INT_H */ - -/* Define to 1 if we found this declaration otherwise define to 0. */ -#define HAVE_DECL_GETOPT 0 - -/* Define if sigsetjmp is available. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if the regex included in libiberty should be used. */ -#define USE_INCLUDED_REGEX 1 - -/* Define to 1 if your system has struct reg in . */ -#define HAVE_STRUCT_REG 1 - -/* Define if provides the uintptr_t type. */ -#define HAVE_UINTPTR_T 1 - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if realloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_REALLOC */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if strerror is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRERROR */ - -/* Define if strdup is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRDUP */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has prrun_t. */ -/* #undef HAVE_PRRUN_T */ - -/* Define if has gregset_t. */ -#define HAVE_GREGSET_T 1 - -/* Define if has fpregset_t. */ -#define HAVE_FPREGSET_T 1 - -/* Define if has prgregset_t. */ -#define HAVE_PRGREGSET_T 1 - -/* Define if has prfpregset_t. */ -#define HAVE_PRFPREGSET_T 1 - -/* Define if has prgregset32_t. */ -/* #undef HAVE_PRGREGSET32_T */ - -/* Define if has prfpregset32_t. */ -/* #undef HAVE_PRFPREGSET32_T */ - -/* Define if has lwpid_t. */ -#define HAVE_LWPID_T 1 - -/* Define if has psaddr_t. */ -#define HAVE_PSADDR_T 1 - -/* Define if has prsysent_t. */ -/* #undef HAVE_PRSYSENT_T */ - -/* Define if has pr_sigset_t. */ -/* #undef HAVE_PR_SIGSET_T */ - -/* Define if has pr_sigaction64_t. */ -/* #undef HAVE_PR_SIGACTION64_T */ - -/* Define if has pr_siginfo64_t. */ -/* #undef HAVE_PR_SIGINFO64_T */ - -/* Define if has the TD_NOTALLOC error code. */ -/* #undef THREAD_DB_HAS_TD_NOTALLOC */ - -/* Define if we can use the tkill syscall. */ -/* #undef HAVE_TKILL_SYSCALL */ - -/* Define to the default OS ABI for this configuration. */ -/* #undef GDB_OSABI_DEFAULT */ - -/* Define to be a string naming the default host character set. */ -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - diff --git a/gnu/usr.bin/gdb/arch/arm/init.c b/gnu/usr.bin/gdb/arch/arm/init.c deleted file mode 100644 index d4064dadd4a..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/init.c +++ /dev/null @@ -1,228 +0,0 @@ -/* $FreeBSD$ */ - -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ -#include "defs.h" /* For initialize_file_ftype. */ -#include "call-cmds.h" /* For initialize_all_files. */ -extern initialize_file_ftype _initialize_gdbtypes; -extern initialize_file_ftype _initialize_arm_tdep; -extern initialize_file_ftype _initialize_armfbsd_tdep; -extern initialize_file_ftype _initialize_corelow; -extern initialize_file_ftype _initialize_solib; -extern initialize_file_ftype _initialize_svr4_solib; -extern initialize_file_ftype _initialize_ser_hardwire; -extern initialize_file_ftype _initialize_ser_pipe; -extern initialize_file_ftype _initialize_ser_tcp; -#ifndef CROSS_DEBUGGER -extern initialize_file_ftype _initialize_kernel_u_addr; -extern initialize_file_ftype _initialize_infptrace; -extern initialize_file_ftype _initialize_inftarg; -#endif -extern initialize_file_ftype _initialize_arm_fbsdnat; -extern initialize_file_ftype _initialize_remote; -extern initialize_file_ftype _initialize_dcache; -extern initialize_file_ftype _initialize_sr_support; -extern initialize_file_ftype _initialize_tracepoint; -extern initialize_file_ftype _initialize_ax_gdb; -extern initialize_file_ftype _initialize_annotate; -extern initialize_file_ftype _initialize_auxv; -extern initialize_file_ftype _initialize_breakpoint; -extern initialize_file_ftype _initialize_regcache; -extern initialize_file_ftype _initialize_charset; -extern initialize_file_ftype _initialize_dummy_frame; -extern initialize_file_ftype _initialize_source; -extern initialize_file_ftype _initialize_values; -extern initialize_file_ftype _initialize_valops; -extern initialize_file_ftype _initialize_valarith; -extern initialize_file_ftype _initialize_valprint; -extern initialize_file_ftype _initialize_printcmd; -extern initialize_file_ftype _initialize_symtab; -extern initialize_file_ftype _initialize_symfile; -extern initialize_file_ftype _initialize_symmisc; -extern initialize_file_ftype _initialize_infcall; -extern initialize_file_ftype _initialize_infcmd; -extern initialize_file_ftype _initialize_infrun; -extern initialize_file_ftype _initialize_stack; -extern initialize_file_ftype _initialize_thread; -extern initialize_file_ftype _initialize_interpreter; -extern initialize_file_ftype _initialize_macrocmd; -extern initialize_file_ftype _initialize_gdbarch; -extern initialize_file_ftype _initialize_gdbarch_utils; -extern initialize_file_ftype _initialize_gdb_osabi; -extern initialize_file_ftype _initialize_copying; -extern initialize_file_ftype _initialize_mem; -extern initialize_file_ftype _initialize_parse; -extern initialize_file_ftype _initialize_language; -extern initialize_file_ftype _initialize_frame_reg; -extern initialize_file_ftype _initialize_signals; -extern initialize_file_ftype _initialize_kod; -extern initialize_file_ftype _initialize_gdb_events; -extern initialize_file_ftype _initialize_exec; -extern initialize_file_ftype _initialize_maint_cmds; -extern initialize_file_ftype _initialize_demangler; -extern initialize_file_ftype _initialize_dbxread; -extern initialize_file_ftype _initialize_coffread; -extern initialize_file_ftype _initialize_elfread; -extern initialize_file_ftype _initialize_mipsread; -extern initialize_file_ftype _initialize_stabsread; -extern initialize_file_ftype _initialize_core; -extern initialize_file_ftype _initialize_dwarf2_frame; -extern initialize_file_ftype _initialize_c_language; -extern initialize_file_ftype _initialize_f_language; -extern initialize_file_ftype _initialize_objc_language; -extern initialize_file_ftype _initialize_ui_out; -extern initialize_file_ftype _initialize_cli_out; -extern initialize_file_ftype _initialize_varobj; -extern initialize_file_ftype _initialize_java_language; -extern initialize_file_ftype _initialize_m2_language; -extern initialize_file_ftype _initialize_pascal_language; -extern initialize_file_ftype _initialize_pascal_valprint; -extern initialize_file_ftype _initialize_scheme_language; -extern initialize_file_ftype _initialize_complaints; -extern initialize_file_ftype _initialize_typeprint; -extern initialize_file_ftype _initialize_cp_valprint; -extern initialize_file_ftype _initialize_f_valprint; -extern initialize_file_ftype _initialize_nlmread; -extern initialize_file_ftype _initialize_serial; -extern initialize_file_ftype _initialize_mdebugread; -extern initialize_file_ftype _initialize_user_regs; -extern initialize_file_ftype _initialize_frame; -extern initialize_file_ftype _initialize_frame_unwind; -extern initialize_file_ftype _initialize_frame_base; -extern initialize_file_ftype _initialize_gnu_v2_abi; -extern initialize_file_ftype _initialize_gnu_v3_abi; -extern initialize_file_ftype _initialize_hpacc_abi; -extern initialize_file_ftype _initialize_cp_abi; -extern initialize_file_ftype _initialize_cp_support; -extern initialize_file_ftype _initialize_cp_namespace; -extern initialize_file_ftype _initialize_reggroup; -extern initialize_file_ftype _initialize_inflow; -extern initialize_file_ftype _initialize_cli_dump; -extern initialize_file_ftype _initialize_cli_logging; -extern initialize_file_ftype _initialize_cli_interp; -extern initialize_file_ftype _initialize_mi_out; -extern initialize_file_ftype _initialize_mi_cmds; -extern initialize_file_ftype _initialize_mi_cmd_env; -extern initialize_file_ftype _initialize_mi_interp; -extern initialize_file_ftype _initialize_mi_main; -extern initialize_file_ftype _initialize_thread_db; -extern initialize_file_ftype _initialize_tui_hooks; -extern initialize_file_ftype _initialize_tui_interp; -extern initialize_file_ftype _initialize_tui_layout; -extern initialize_file_ftype _initialize_tui_out; -extern initialize_file_ftype _initialize_tui_regs; -extern initialize_file_ftype _initialize_tui_stack; -extern initialize_file_ftype _initialize_tui_win; -void -initialize_all_files (void) -{ - _initialize_gdbtypes (); - _initialize_arm_tdep (); - _initialize_armfbsd_tdep (); - _initialize_corelow (); - _initialize_solib (); - _initialize_svr4_solib (); - _initialize_ser_hardwire (); - _initialize_ser_pipe (); - _initialize_ser_tcp (); -#ifndef CROSS_DEBUGGER - _initialize_kernel_u_addr (); - _initialize_infptrace (); - _initialize_inftarg (); - _initialize_thread_db (); -#endif - _initialize_arm_fbsdnat (); - _initialize_remote (); - _initialize_dcache (); - _initialize_sr_support (); - _initialize_tracepoint (); - _initialize_ax_gdb (); - _initialize_annotate (); - _initialize_auxv (); - _initialize_breakpoint (); - _initialize_regcache (); - _initialize_charset (); - _initialize_dummy_frame (); - _initialize_source (); - _initialize_values (); - _initialize_valops (); - _initialize_valarith (); - _initialize_valprint (); - _initialize_printcmd (); - _initialize_symtab (); - _initialize_symfile (); - _initialize_symmisc (); - _initialize_infcall (); - _initialize_infcmd (); - _initialize_infrun (); - _initialize_stack (); - _initialize_thread (); - _initialize_interpreter (); - _initialize_macrocmd (); - _initialize_gdbarch (); - _initialize_gdbarch_utils (); - _initialize_gdb_osabi (); - _initialize_copying (); - _initialize_mem (); - _initialize_parse (); - _initialize_language (); - _initialize_frame_reg (); - _initialize_signals (); - _initialize_kod (); - _initialize_gdb_events (); - _initialize_exec (); - _initialize_maint_cmds (); - _initialize_demangler (); - _initialize_dbxread (); - _initialize_coffread (); - _initialize_elfread (); - _initialize_mipsread (); - _initialize_stabsread (); - _initialize_core (); - _initialize_dwarf2_frame (); - _initialize_c_language (); - _initialize_f_language (); - _initialize_objc_language (); - _initialize_ui_out (); - _initialize_cli_out (); - _initialize_varobj (); - _initialize_java_language (); - _initialize_m2_language (); - _initialize_pascal_language (); - _initialize_pascal_valprint (); - _initialize_scheme_language (); - _initialize_complaints (); - _initialize_typeprint (); - _initialize_cp_valprint (); - _initialize_f_valprint (); - _initialize_nlmread (); - _initialize_serial (); - _initialize_mdebugread (); - _initialize_user_regs (); - _initialize_frame (); - _initialize_frame_unwind (); - _initialize_frame_base (); - _initialize_gnu_v2_abi (); - _initialize_gnu_v3_abi (); - _initialize_hpacc_abi (); - _initialize_cp_abi (); - _initialize_cp_support (); - _initialize_cp_namespace (); - _initialize_reggroup (); - _initialize_inflow (); - _initialize_cli_dump (); - _initialize_cli_logging (); - _initialize_cli_interp (); - _initialize_mi_out (); - _initialize_mi_cmds (); - _initialize_mi_cmd_env (); - _initialize_mi_interp (); - _initialize_mi_main (); - _initialize_tui_hooks (); - _initialize_tui_interp (); - _initialize_tui_layout (); - _initialize_tui_out (); - _initialize_tui_regs (); - _initialize_tui_stack (); - _initialize_tui_win (); -} diff --git a/gnu/usr.bin/gdb/arch/arm/nm-fbsd.h b/gnu/usr.bin/gdb/arch/arm/nm-fbsd.h deleted file mode 100644 index 8134b1a5d88..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/nm-fbsd.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $FreeBSD$ */ - -/* Native-dependent definitions for ARM running NetBSD, for GDB. - Copyright 1986, 1987, 1989, 1992, 1994, 1999 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef NM_FBSD_H -#define NM_FBSD_H - -/* Type of the third argument to the `ptrace' system call. */ -#define PTRACE_ARG3_TYPE caddr_t - -/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ -#define FETCH_INFERIOR_REGISTERS - -/* We can attach and detach. */ -#define ATTACH_DETACH - -#endif /* NM_FBSD_H */ diff --git a/gnu/usr.bin/gdb/arch/arm/tm-fbsd.h b/gnu/usr.bin/gdb/arch/arm/tm-fbsd.h deleted file mode 100644 index b010a969acf..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/tm-fbsd.h +++ /dev/null @@ -1,28 +0,0 @@ -/* $FreeBSD$ */ - -/* Macro definitions for ARM running under NetBSD. - Copyright 2003 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef TM_FBSD_H -#define TM_FBSD_H - -#include "solib.h" - -#endif /* TM_FBSD_H */ diff --git a/gnu/usr.bin/gdb/arch/arm/xm-fbsd.h b/gnu/usr.bin/gdb/arch/arm/xm-fbsd.h deleted file mode 100644 index 75f8077564c..00000000000 --- a/gnu/usr.bin/gdb/arch/arm/xm-fbsd.h +++ /dev/null @@ -1,22 +0,0 @@ -/* $FreeBSD$ */ - -/* Parameters for execution on an ARM running NetBSD, for GDB. - Copyright 1994 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - diff --git a/gnu/usr.bin/gdb/arch/i386/Makefile b/gnu/usr.bin/gdb/arch/i386/Makefile deleted file mode 100644 index 3d962789082..00000000000 --- a/gnu/usr.bin/gdb/arch/i386/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# $FreeBSD$ - -GENSRCS+= xm.h -.if !defined(GDB_CROSS_DEBUGGER) -LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c -LIBSRCS+= i386-nat.c i386bsd-nat.c i386fbsd-nat.c -.endif -LIBSRCS+= solib.c solib-svr4.c -LIBSRCS+= i386-tdep.c i386bsd-tdep.c i386fbsd-tdep-fixed.c i387-tdep.c - -nm.h: - echo '#include "i386/nm-fbsd.h"' > ${.TARGET} - -tm.h: - echo '#include "i386/tm-fbsd.h"' > ${.TARGET} - -xm.h: - echo '#include "i386/xm-i386.h"' > ${.TARGET} - -# Fix source static/extern mismatch nits that GCC 4.2 warns about. -CLEANFILES += i386fbsd-tdep-fixed.c -i386fbsd-tdep-fixed.c: i386fbsd-tdep.c - sed -e '48s/^static\ //' ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/i386/config.h b/gnu/usr.bin/gdb/arch/i386/config.h deleted file mode 100644 index 3f7f579433d..00000000000 --- a/gnu/usr.bin/gdb/arch/i386/config.h +++ /dev/null @@ -1,550 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated automatically by configure. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if the `long double' type works. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define if you have . */ -/* #undef HAVE_VFORK_H */ - -/* Define as __inline if that's what the C compiler calls it. */ -/* #undef inline */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define vfork as fork if vfork does not work. */ -/* #undef vfork */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Define if your struct reg has r_fs. */ -#define HAVE_STRUCT_REG_R_FS 1 - -/* Define if your struct stat has st_blocks. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define if your struct reg has r_gs. */ -#define HAVE_STRUCT_REG_R_GS 1 - -/* Define if exists and defines struct link_map which has - members with an ``l_'' prefix. (For Solaris, SVR4, and - SVR4-like systems.) */ -#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 - -/* Define if exists and defines struct link_map which has - members with an ``lm_'' prefix. (For SunOS.) */ -/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ - -/* Define if exists and defines a struct so_map which has - members with an ``som_'' prefix. (Found on older *BSD systems.) */ -/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ - -/* Define if has struct link_map32 */ -/* #undef HAVE_STRUCT_LINK_MAP32 */ - -/* Define if has link_map32 (solaris sparc-64 target) */ -/* #undef _SYSCALL32 */ - -/* Define if the prfpregset_t type is broken. */ -/* #undef PRFPREGSET_T_BROKEN */ - -/* Define if you want to use new multi-fd /proc interface - (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ -/* #undef NEW_PROC_API */ - -/* Define if ioctl argument PIOCSET is available. */ -/* #undef HAVE_PROCFS_PIOCSET */ - -/* Define if the `long long' type works. */ -#define CC_HAS_LONG_LONG 1 - -/* Define if the "ll" format works to print long long ints. */ -#define PRINTF_HAS_LONG_LONG 1 - -/* Define if the "%Lg" format works to print long doubles. */ -#define PRINTF_HAS_LONG_DOUBLE 1 - -/* Define if the "%Lg" format works to scan long doubles. */ -#define SCANF_HAS_LONG_DOUBLE 1 - -/* Define if using Solaris thread debugging. */ -/* #undef HAVE_THREAD_DB_LIB */ - -/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ -/* #undef START_INFERIOR_TRAPS_EXPECTED */ -/* #undef sys_quotactl */ - -/* Define if you have HPUX threads */ -/* #undef HAVE_HPUX_THREAD_SUPPORT */ - -/* Define if on solaris uses int instead of - size_t, and assorted other type changes. */ -/* #undef PROC_SERVICE_IS_OLD */ - -/* Define if the simulator is being linked in. */ -#define WITH_SIM 1 - -/* Set to true if the save_state_t structure is present */ -/* #undef HAVE_STRUCT_SAVE_STATE_T */ - -/* Set to true if the save_state_t structure has the ss_wide member */ -/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ - -/* Define if defines the PTRACE_GETREGS request. */ -/* #undef HAVE_PTRACE_GETREGS */ - -/* Define if defines the PTRACE_GETFPXREGS request. */ -/* #undef HAVE_PTRACE_GETFPXREGS */ - -/* Define if defines the PT_GETDBREGS request. */ -#define HAVE_PT_GETDBREGS 1 - -/* Define if defines the PT_GETXMMREGS request. */ -#define HAVE_PT_GETXMMREGS - -/* Define if libunwind library is being used. */ -/* #undef HAVE_LIBUNWIND */ - -/* hostfile */ -#define GDB_XM_FILE config/i386/xm-i386.h - -/* targetfile */ -#define GDB_TM_FILE config/i386/tm-fbsd.h - -/* nativefile */ -#ifndef CROSS_DEBUGGER -#define GDB_NM_FILE config/i386/nm-fbsd.h -#endif - -/* Define to 1 so gets a definition of anon_hdl. Works - around a problem on IRIX 5. */ -#ifndef _KMEMUSER -/* #undef _KMEMUSER */ -#endif - -/* Define if you have the __argz_count function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define if you have the __argz_next function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define if you have the __argz_stringify function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define if you have the _mcleanup function. */ -#define HAVE__MCLEANUP 1 - -/* Define if you have the canonicalize_file_name function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define if you have the dcgettext function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the monstartup function. */ -#define HAVE_MONSTARTUP 1 - -/* Define if you have the munmap function. */ -#define HAVE_MUNMAP 1 - -/* Define if you have the poll function. */ -#define HAVE_POLL 1 - -/* Define if you have the pread64 function. */ -/* #undef HAVE_PREAD64 */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the realpath function. */ -#define HAVE_REALPATH 1 - -/* Define if you have the sbrk function. */ -/* #undef HAVE_SBRK */ - -/* Define if you have the setenv function. */ -#define HAVE_SETENV 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setpgrp function. */ -#define HAVE_SETPGRP 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the sigprocmask function. */ -#define HAVE_SIGPROCMASK 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 1 - -/* Define if you have the socketpair function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define if you have the stpcpy function. */ -#define HAVE_STPCPY 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the syscall function. */ -#define HAVE_SYSCALL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the header file. */ -#define HAVE_CURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_IA64_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_MACHINE_REG_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_PROC_SERVICE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PTRACE_H */ - -/* Define if you have the header file. */ -#define HAVE_SGTTY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DEBUGREG_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FAULT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_REG_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_USER_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIO_H */ - -/* Define if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_DB_H */ - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_VALUES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_WAIT_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the w library (-lw). */ -/* #undef HAVE_LIBW */ - -/* Define if you have the stpcpy function */ -#define HAVE_STPCPY 1 - -/* Define if your locale.h file contains LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if NLS is requested */ -/* #undef ENABLE_NLS */ - -/* Define as 1 if you have gettext and don't want to use GNU gettext. */ -/* #undef HAVE_GETTEXT */ - -/* Name of this package. */ -#define PACKAGE "gdb" - -/* Define to BFD's default architecture. */ -#define DEFAULT_BFD_ARCH bfd_i386_arch - -/* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf32_i386_freebsd_vec - -/* Define to 1 if your system has the _etext variable. */ -#define HAVE__ETEXT 1 - -/* Define to 1 to avoid a clash between and on - Solaris 2.[78] when using GCC. */ -/* #undef _MSE_INT_H */ - -/* Define to 1 if we found this declaration otherwise define to 0. */ -#define HAVE_DECL_GETOPT 0 - -/* Define if sigsetjmp is available. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if the regex included in libiberty should be used. */ -#define USE_INCLUDED_REGEX 1 - -/* Define to 1 if your system has struct reg in . */ -#define HAVE_STRUCT_REG 1 - -/* Define if provides the uintptr_t type. */ -#define HAVE_UINTPTR_T 1 - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if realloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_REALLOC */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if strerror is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRERROR */ - -/* Define if strdup is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRDUP */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has prrun_t. */ -/* #undef HAVE_PRRUN_T */ - -/* Define if has gregset_t. */ -#define HAVE_GREGSET_T 1 - -/* Define if has fpregset_t. */ -#define HAVE_FPREGSET_T 1 - -/* Define if has prgregset_t. */ -#define HAVE_PRGREGSET_T 1 - -/* Define if has prfpregset_t. */ -#define HAVE_PRFPREGSET_T 1 - -/* Define if has prgregset32_t. */ -/* #undef HAVE_PRGREGSET32_T */ - -/* Define if has prfpregset32_t. */ -/* #undef HAVE_PRFPREGSET32_T */ - -/* Define if has lwpid_t. */ -#define HAVE_LWPID_T 1 - -/* Define if has psaddr_t. */ -#define HAVE_PSADDR_T 1 - -/* Define if has prsysent_t. */ -/* #undef HAVE_PRSYSENT_T */ - -/* Define if has pr_sigset_t. */ -/* #undef HAVE_PR_SIGSET_T */ - -/* Define if has pr_sigaction64_t. */ -/* #undef HAVE_PR_SIGACTION64_T */ - -/* Define if has pr_siginfo64_t. */ -/* #undef HAVE_PR_SIGINFO64_T */ - -/* Define if has the TD_NOTALLOC error code. */ -/* #undef THREAD_DB_HAS_TD_NOTALLOC */ - -/* Define if we can use the tkill syscall. */ -/* #undef HAVE_TKILL_SYSCALL */ - -/* Define to the default OS ABI for this configuration. */ -/* #undef GDB_OSABI_DEFAULT */ - -/* Define to be a string naming the default host character set. */ -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - diff --git a/gnu/usr.bin/gdb/arch/i386/init.c b/gnu/usr.bin/gdb/arch/i386/init.c deleted file mode 100644 index 7675d8e688c..00000000000 --- a/gnu/usr.bin/gdb/arch/i386/init.c +++ /dev/null @@ -1,236 +0,0 @@ -/* $FreeBSD$ */ - -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ -#include "defs.h" /* For initialize_file_ftype. */ -#include "call-cmds.h" /* For initialize_all_files. */ -extern initialize_file_ftype _initialize_gdbtypes; -extern initialize_file_ftype _initialize_i386_tdep; -extern initialize_file_ftype _initialize_i386bsd_tdep; -extern initialize_file_ftype _initialize_i386fbsd_tdep; -extern initialize_file_ftype _initialize_corelow; -extern initialize_file_ftype _initialize_solib; -extern initialize_file_ftype _initialize_svr4_solib; -extern initialize_file_ftype _initialize_ser_hardwire; -extern initialize_file_ftype _initialize_ser_pipe; -extern initialize_file_ftype _initialize_ser_tcp; -extern initialize_file_ftype _initialize_kernel_u_addr; -extern initialize_file_ftype _initialize_infptrace; -extern initialize_file_ftype _initialize_inftarg; -extern initialize_file_ftype _initialize_i386_nat; -extern initialize_file_ftype _initialize_i386bsd_nat; -extern initialize_file_ftype _initialize_i386fbsd_nat; -extern initialize_file_ftype _initialize_gcore; -extern initialize_file_ftype _initialize_fbsd_proc; -extern initialize_file_ftype _initialize_remote; -extern initialize_file_ftype _initialize_dcache; -extern initialize_file_ftype _initialize_sr_support; -extern initialize_file_ftype _initialize_tracepoint; -extern initialize_file_ftype _initialize_ax_gdb; -extern initialize_file_ftype _initialize_annotate; -extern initialize_file_ftype _initialize_auxv; -extern initialize_file_ftype _initialize_breakpoint; -extern initialize_file_ftype _initialize_regcache; -extern initialize_file_ftype _initialize_charset; -extern initialize_file_ftype _initialize_dummy_frame; -extern initialize_file_ftype _initialize_source; -extern initialize_file_ftype _initialize_values; -extern initialize_file_ftype _initialize_valops; -extern initialize_file_ftype _initialize_valarith; -extern initialize_file_ftype _initialize_valprint; -extern initialize_file_ftype _initialize_printcmd; -extern initialize_file_ftype _initialize_symtab; -extern initialize_file_ftype _initialize_symfile; -extern initialize_file_ftype _initialize_symmisc; -extern initialize_file_ftype _initialize_infcall; -extern initialize_file_ftype _initialize_infcmd; -extern initialize_file_ftype _initialize_infrun; -extern initialize_file_ftype _initialize_stack; -extern initialize_file_ftype _initialize_thread; -extern initialize_file_ftype _initialize_interpreter; -extern initialize_file_ftype _initialize_macrocmd; -extern initialize_file_ftype _initialize_gdbarch; -extern initialize_file_ftype _initialize_gdbarch_utils; -extern initialize_file_ftype _initialize_gdb_osabi; -extern initialize_file_ftype _initialize_copying; -extern initialize_file_ftype _initialize_mem; -extern initialize_file_ftype _initialize_parse; -extern initialize_file_ftype _initialize_language; -extern initialize_file_ftype _initialize_frame_reg; -extern initialize_file_ftype _initialize_signals; -extern initialize_file_ftype _initialize_kod; -extern initialize_file_ftype _initialize_gdb_events; -extern initialize_file_ftype _initialize_exec; -extern initialize_file_ftype _initialize_maint_cmds; -extern initialize_file_ftype _initialize_demangler; -extern initialize_file_ftype _initialize_dbxread; -extern initialize_file_ftype _initialize_coffread; -extern initialize_file_ftype _initialize_elfread; -extern initialize_file_ftype _initialize_mipsread; -extern initialize_file_ftype _initialize_stabsread; -extern initialize_file_ftype _initialize_core; -extern initialize_file_ftype _initialize_dwarf2_frame; -extern initialize_file_ftype _initialize_c_language; -extern initialize_file_ftype _initialize_f_language; -extern initialize_file_ftype _initialize_objc_language; -extern initialize_file_ftype _initialize_ui_out; -extern initialize_file_ftype _initialize_cli_out; -extern initialize_file_ftype _initialize_varobj; -extern initialize_file_ftype _initialize_java_language; -extern initialize_file_ftype _initialize_m2_language; -extern initialize_file_ftype _initialize_pascal_language; -extern initialize_file_ftype _initialize_pascal_valprint; -extern initialize_file_ftype _initialize_scheme_language; -extern initialize_file_ftype _initialize_complaints; -extern initialize_file_ftype _initialize_typeprint; -extern initialize_file_ftype _initialize_cp_valprint; -extern initialize_file_ftype _initialize_f_valprint; -extern initialize_file_ftype _initialize_nlmread; -extern initialize_file_ftype _initialize_serial; -extern initialize_file_ftype _initialize_mdebugread; -extern initialize_file_ftype _initialize_user_regs; -extern initialize_file_ftype _initialize_frame; -extern initialize_file_ftype _initialize_frame_unwind; -extern initialize_file_ftype _initialize_frame_base; -extern initialize_file_ftype _initialize_gnu_v2_abi; -extern initialize_file_ftype _initialize_gnu_v3_abi; -extern initialize_file_ftype _initialize_hpacc_abi; -extern initialize_file_ftype _initialize_cp_abi; -extern initialize_file_ftype _initialize_cp_support; -extern initialize_file_ftype _initialize_cp_namespace; -extern initialize_file_ftype _initialize_reggroup; -extern initialize_file_ftype _initialize_inflow; -extern initialize_file_ftype _initialize_cli_dump; -extern initialize_file_ftype _initialize_cli_logging; -extern initialize_file_ftype _initialize_cli_interp; -extern initialize_file_ftype _initialize_mi_out; -extern initialize_file_ftype _initialize_mi_cmds; -extern initialize_file_ftype _initialize_mi_cmd_env; -extern initialize_file_ftype _initialize_mi_interp; -extern initialize_file_ftype _initialize_mi_main; -extern initialize_file_ftype _initialize_thread_db; -extern initialize_file_ftype _initialize_tui_hooks; -extern initialize_file_ftype _initialize_tui_interp; -extern initialize_file_ftype _initialize_tui_layout; -extern initialize_file_ftype _initialize_tui_out; -extern initialize_file_ftype _initialize_tui_regs; -extern initialize_file_ftype _initialize_tui_stack; -extern initialize_file_ftype _initialize_tui_win; -void -initialize_all_files (void) -{ - _initialize_gdbtypes (); - _initialize_i386_tdep (); - _initialize_i386bsd_tdep (); - _initialize_i386fbsd_tdep (); - _initialize_corelow (); - _initialize_solib (); - _initialize_svr4_solib (); - _initialize_ser_hardwire (); - _initialize_ser_pipe (); - _initialize_ser_tcp (); -#ifndef CROSS_DEBUGGER - _initialize_kernel_u_addr (); - _initialize_infptrace (); - _initialize_inftarg (); - _initialize_i386_nat (); - _initialize_i386bsd_nat (); - _initialize_i386fbsd_nat (); - _initialize_gcore (); - _initialize_fbsd_proc (); - _initialize_thread_db (); -#endif - _initialize_remote (); - _initialize_dcache (); - _initialize_sr_support (); - _initialize_tracepoint (); - _initialize_ax_gdb (); - _initialize_annotate (); - _initialize_auxv (); - _initialize_breakpoint (); - _initialize_regcache (); - _initialize_charset (); - _initialize_dummy_frame (); - _initialize_source (); - _initialize_values (); - _initialize_valops (); - _initialize_valarith (); - _initialize_valprint (); - _initialize_printcmd (); - _initialize_symtab (); - _initialize_symfile (); - _initialize_symmisc (); - _initialize_infcall (); - _initialize_infcmd (); - _initialize_infrun (); - _initialize_stack (); - _initialize_thread (); - _initialize_interpreter (); - _initialize_macrocmd (); - _initialize_gdbarch (); - _initialize_gdbarch_utils (); - _initialize_gdb_osabi (); - _initialize_copying (); - _initialize_mem (); - _initialize_parse (); - _initialize_language (); - _initialize_frame_reg (); - _initialize_signals (); - _initialize_kod (); - _initialize_gdb_events (); - _initialize_exec (); - _initialize_maint_cmds (); - _initialize_demangler (); - _initialize_dbxread (); - _initialize_coffread (); - _initialize_elfread (); - _initialize_mipsread (); - _initialize_stabsread (); - _initialize_core (); - _initialize_dwarf2_frame (); - _initialize_c_language (); - _initialize_f_language (); - _initialize_objc_language (); - _initialize_ui_out (); - _initialize_cli_out (); - _initialize_varobj (); - _initialize_java_language (); - _initialize_m2_language (); - _initialize_pascal_language (); - _initialize_pascal_valprint (); - _initialize_scheme_language (); - _initialize_complaints (); - _initialize_typeprint (); - _initialize_cp_valprint (); - _initialize_f_valprint (); - _initialize_nlmread (); - _initialize_serial (); - _initialize_mdebugread (); - _initialize_user_regs (); - _initialize_frame (); - _initialize_frame_unwind (); - _initialize_frame_base (); - _initialize_gnu_v2_abi (); - _initialize_gnu_v3_abi (); - _initialize_hpacc_abi (); - _initialize_cp_abi (); - _initialize_cp_support (); - _initialize_cp_namespace (); - _initialize_reggroup (); - _initialize_inflow (); - _initialize_cli_dump (); - _initialize_cli_logging (); - _initialize_cli_interp (); - _initialize_mi_out (); - _initialize_mi_cmds (); - _initialize_mi_cmd_env (); - _initialize_mi_interp (); - _initialize_mi_main (); - _initialize_tui_hooks (); - _initialize_tui_interp (); - _initialize_tui_layout (); - _initialize_tui_out (); - _initialize_tui_regs (); - _initialize_tui_stack (); - _initialize_tui_win (); -} diff --git a/gnu/usr.bin/gdb/arch/mips/Makefile b/gnu/usr.bin/gdb/arch/mips/Makefile deleted file mode 100644 index 24e9cfce25e..00000000000 --- a/gnu/usr.bin/gdb/arch/mips/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD$ - -# -# XXX Should set DEFAULT_BFD_VEC based on target. -# -.if !defined(GDB_CROSS_DEBUGGER) -LIBSRCS+= mipsfbsd-nat.c fbsd-threads.c -.endif -LIBSRCS+= solib.c solib-svr4.c -LIBSRCS+= mips-tdep.c mipsfbsd-tdep.c fbsd-proc.c - -nm.h: - echo '#include "mips/nm-fbsd.h"' > ${.TARGET} - -tm.h: - echo '#include "mips/tm-fbsd.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/mips/config.h b/gnu/usr.bin/gdb/arch/mips/config.h deleted file mode 100644 index c0b04cc5e55..00000000000 --- a/gnu/usr.bin/gdb/arch/mips/config.h +++ /dev/null @@ -1,550 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated automatically by configure. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if the `long double' type works. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define if you have . */ -/* #undef HAVE_VFORK_H */ - -/* Define as __inline if that's what the C compiler calls it. */ -/* #undef inline */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define vfork as fork if vfork does not work. */ -/* #undef vfork */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Define if your struct reg has r_fs. */ -/* #undef HAVE_STRUCT_REG_R_FS */ - -/* Define if your struct stat has st_blocks. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define if your struct reg has r_gs. */ -/* #undef HAVE_STRUCT_REG_R_GS */ - -/* Define if exists and defines struct link_map which has - members with an ``l_'' prefix. (For Solaris, SVR4, and - SVR4-like systems.) */ -#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 - -/* Define if exists and defines struct link_map which has - members with an ``lm_'' prefix. (For SunOS.) */ -/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ - -/* Define if exists and defines a struct so_map which has - members with an ``som_'' prefix. (Found on older *BSD systems.) */ -/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ - -/* Define if has struct link_map32 */ -/* #undef HAVE_STRUCT_LINK_MAP32 */ - -/* Define if has link_map32 (solaris sparc-64 target) */ -/* #undef _SYSCALL32 */ - -/* Define if the prfpregset_t type is broken. */ -/* #undef PRFPREGSET_T_BROKEN */ - -/* Define if you want to use new multi-fd /proc interface - (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ -/* #undef NEW_PROC_API */ - -/* Define if ioctl argument PIOCSET is available. */ -/* #undef HAVE_PROCFS_PIOCSET */ - -/* Define if the `long long' type works. */ -#define CC_HAS_LONG_LONG 1 - -/* Define if the "ll" format works to print long long ints. */ -#define PRINTF_HAS_LONG_LONG 1 - -/* Define if the "%Lg" format works to print long doubles. */ -#define PRINTF_HAS_LONG_DOUBLE 1 - -/* Define if the "%Lg" format works to scan long doubles. */ -#define SCANF_HAS_LONG_DOUBLE 1 - -/* Define if using Solaris thread debugging. */ -/* #undef HAVE_THREAD_DB_LIB */ - -/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ -/* #undef START_INFERIOR_TRAPS_EXPECTED */ -/* #undef sys_quotactl */ - -/* Define if you have HPUX threads */ -/* #undef HAVE_HPUX_THREAD_SUPPORT */ - -/* Define if on solaris uses int instead of - size_t, and assorted other type changes. */ -/* #undef PROC_SERVICE_IS_OLD */ - -/* Define if the simulator is being linked in. */ -#define WITH_SIM 1 - -/* Set to true if the save_state_t structure is present */ -/* #undef HAVE_STRUCT_SAVE_STATE_T */ - -/* Set to true if the save_state_t structure has the ss_wide member */ -/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ - -/* Define if defines the PTRACE_GETREGS request. */ -/* #undef HAVE_PTRACE_GETREGS */ - -/* Define if defines the PTRACE_GETFPXREGS request. */ -/* #undef HAVE_PTRACE_GETFPXREGS */ - -/* Define if defines the PT_GETDBREGS request. */ -#define HAVE_PT_GETDBREGS 1 - -/* Define if defines the PT_GETXMMREGS request. */ -/* #undef HAVE_PT_GETXMMREGS */ - -/* Define if libunwind library is being used. */ -/* #undef HAVE_LIBUNWIND */ - -/* hostfile */ -/* #undef GDB_XM_FILE */ - -/* targetfile */ -#define GDB_TM_FILE config/mips/tm-fbsd.h - -/* nativefile */ -#ifndef CROSS_DEBUGGER -#define GDB_NM_FILE config/mips/nm-fbsd.h -#endif - -/* Define to 1 so gets a definition of anon_hdl. Works - around a problem on IRIX 5. */ -#ifndef _KMEMUSER -/* #undef _KMEMUSER */ -#endif - -/* Define if you have the __argz_count function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define if you have the __argz_next function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define if you have the __argz_stringify function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define if you have the _mcleanup function. */ -#define HAVE__MCLEANUP 1 - -/* Define if you have the canonicalize_file_name function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define if you have the dcgettext function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the monstartup function. */ -#define HAVE_MONSTARTUP 1 - -/* Define if you have the munmap function. */ -#define HAVE_MUNMAP 1 - -/* Define if you have the poll function. */ -#define HAVE_POLL 1 - -/* Define if you have the pread64 function. */ -/* #undef HAVE_PREAD64 */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the realpath function. */ -#define HAVE_REALPATH 1 - -/* Define if you have the sbrk function. */ -/* #undef HAVE_SBRK */ - -/* Define if you have the setenv function. */ -#define HAVE_SETENV 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setpgrp function. */ -#define HAVE_SETPGRP 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the sigprocmask function. */ -#define HAVE_SIGPROCMASK 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 1 - -/* Define if you have the socketpair function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define if you have the stpcpy function. */ -#define HAVE_STPCPY 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the syscall function. */ -#define HAVE_SYSCALL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the header file. */ -#define HAVE_CURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_IA64_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_MACHINE_REG_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_PROC_SERVICE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PTRACE_H */ - -/* Define if you have the header file. */ -#define HAVE_SGTTY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DEBUGREG_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FAULT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_REG_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_USER_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIO_H */ - -/* Define if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_DB_H */ - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_VALUES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_WAIT_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the w library (-lw). */ -/* #undef HAVE_LIBW */ - -/* Define if you have the stpcpy function */ -#define HAVE_STPCPY 1 - -/* Define if your locale.h file contains LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if NLS is requested */ -/* #undef ENABLE_NLS */ - -/* Define as 1 if you have gettext and don't want to use GNU gettext. */ -/* #undef HAVE_GETTEXT */ - -/* Name of this package. */ -#define PACKAGE "gdb" - -/* Define to BFD's default architecture. */ -#define DEFAULT_BFD_ARCH bfd_mips_arch - -/* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf32_littlemips_vec - -/* Define to 1 if your system has the _etext variable. */ -#define HAVE__ETEXT 1 - -/* Define to 1 to avoid a clash between and on - Solaris 2.[78] when using GCC. */ -/* #undef _MSE_INT_H */ - -/* Define to 1 if we found this declaration otherwise define to 0. */ -#define HAVE_DECL_GETOPT 0 - -/* Define if sigsetjmp is available. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if the regex included in libiberty should be used. */ -#define USE_INCLUDED_REGEX 1 - -/* Define to 1 if your system has struct reg in . */ -#define HAVE_STRUCT_REG 1 - -/* Define if provides the uintptr_t type. */ -#define HAVE_UINTPTR_T 1 - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if realloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_REALLOC */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if strerror is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRERROR */ - -/* Define if strdup is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRDUP */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has prrun_t. */ -/* #undef HAVE_PRRUN_T */ - -/* Define if has gregset_t. */ -#define HAVE_GREGSET_T 1 - -/* Define if has fpregset_t. */ -#define HAVE_FPREGSET_T 1 - -/* Define if has prgregset_t. */ -#define HAVE_PRGREGSET_T 1 - -/* Define if has prfpregset_t. */ -#define HAVE_PRFPREGSET_T 1 - -/* Define if has prgregset32_t. */ -/* #undef HAVE_PRGREGSET32_T */ - -/* Define if has prfpregset32_t. */ -/* #undef HAVE_PRFPREGSET32_T */ - -/* Define if has lwpid_t. */ -#define HAVE_LWPID_T 1 - -/* Define if has psaddr_t. */ -#define HAVE_PSADDR_T 1 - -/* Define if has prsysent_t. */ -/* #undef HAVE_PRSYSENT_T */ - -/* Define if has pr_sigset_t. */ -/* #undef HAVE_PR_SIGSET_T */ - -/* Define if has pr_sigaction64_t. */ -/* #undef HAVE_PR_SIGACTION64_T */ - -/* Define if has pr_siginfo64_t. */ -/* #undef HAVE_PR_SIGINFO64_T */ - -/* Define if has the TD_NOTALLOC error code. */ -/* #undef THREAD_DB_HAS_TD_NOTALLOC */ - -/* Define if we can use the tkill syscall. */ -/* #undef HAVE_TKILL_SYSCALL */ - -/* Define to the default OS ABI for this configuration. */ -/* #undef GDB_OSABI_DEFAULT */ - -/* Define to be a string naming the default host character set. */ -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - diff --git a/gnu/usr.bin/gdb/arch/mips/init.c b/gnu/usr.bin/gdb/arch/mips/init.c deleted file mode 100644 index 491b2b3ee39..00000000000 --- a/gnu/usr.bin/gdb/arch/mips/init.c +++ /dev/null @@ -1,233 +0,0 @@ -/* $FreeBSD$ */ - -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ -#include "defs.h" /* For initialize_file_ftype. */ -#include "call-cmds.h" /* For initialize_all_files. */ -extern initialize_file_ftype _initialize_gdbtypes; -extern initialize_file_ftype _initialize_mips_tdep; -extern initialize_file_ftype _initialize_mipsfbsd_tdep; -extern initialize_file_ftype _initialize_corelow; -extern initialize_file_ftype _initialize_ser_hardwire; -extern initialize_file_ftype _initialize_ser_pipe; -extern initialize_file_ftype _initialize_ser_tcp; -extern initialize_file_ftype _initialize_mipsfbsd_nat; -extern initialize_file_ftype _initialize_mips_nat; -extern initialize_file_ftype _initialize_kernel_u_addr; -extern initialize_file_ftype _initialize_infptrace; -extern initialize_file_ftype _initialize_inftarg; -extern initialize_file_ftype _initialize_solib; -extern initialize_file_ftype _initialize_svr4_solib; -extern initialize_file_ftype _initialize_svr4_lm; -extern initialize_file_ftype _initialize_remote; -extern initialize_file_ftype _initialize_dcache; -extern initialize_file_ftype _initialize_sr_support; -extern initialize_file_ftype _initialize_tracepoint; -extern initialize_file_ftype _initialize_ax_gdb; -extern initialize_file_ftype _initialize_annotate; -extern initialize_file_ftype _initialize_auxv; -extern initialize_file_ftype _initialize_breakpoint; -extern initialize_file_ftype _initialize_regcache; -extern initialize_file_ftype _initialize_charset; -extern initialize_file_ftype _initialize_dummy_frame; -extern initialize_file_ftype _initialize_source; -extern initialize_file_ftype _initialize_values; -extern initialize_file_ftype _initialize_valops; -extern initialize_file_ftype _initialize_valarith; -extern initialize_file_ftype _initialize_valprint; -extern initialize_file_ftype _initialize_printcmd; -extern initialize_file_ftype _initialize_symtab; -extern initialize_file_ftype _initialize_symfile; -extern initialize_file_ftype _initialize_symmisc; -extern initialize_file_ftype _initialize_infcall; -extern initialize_file_ftype _initialize_infcmd; -extern initialize_file_ftype _initialize_infrun; -extern initialize_file_ftype _initialize_stack; -extern initialize_file_ftype _initialize_thread; -extern initialize_file_ftype _initialize_interpreter; -extern initialize_file_ftype _initialize_macrocmd; -extern initialize_file_ftype _initialize_gdbarch; -extern initialize_file_ftype _initialize_gdbarch_utils; -extern initialize_file_ftype _initialize_gdb_osabi; -extern initialize_file_ftype _initialize_copying; -extern initialize_file_ftype _initialize_mem; -extern initialize_file_ftype _initialize_parse; -extern initialize_file_ftype _initialize_language; -extern initialize_file_ftype _initialize_frame_reg; -extern initialize_file_ftype _initialize_signals; -extern initialize_file_ftype _initialize_kod; -extern initialize_file_ftype _initialize_gdb_events; -extern initialize_file_ftype _initialize_exec; -extern initialize_file_ftype _initialize_maint_cmds; -extern initialize_file_ftype _initialize_demangler; -extern initialize_file_ftype _initialize_dbxread; -extern initialize_file_ftype _initialize_coffread; -extern initialize_file_ftype _initialize_elfread; -extern initialize_file_ftype _initialize_mipsread; -extern initialize_file_ftype _initialize_stabsread; -extern initialize_file_ftype _initialize_core; -extern initialize_file_ftype _initialize_dwarf2_frame; -extern initialize_file_ftype _initialize_c_language; -extern initialize_file_ftype _initialize_f_language; -extern initialize_file_ftype _initialize_objc_language; -extern initialize_file_ftype _initialize_ui_out; -extern initialize_file_ftype _initialize_cli_out; -extern initialize_file_ftype _initialize_varobj; -extern initialize_file_ftype _initialize_java_language; -extern initialize_file_ftype _initialize_m2_language; -extern initialize_file_ftype _initialize_pascal_language; -extern initialize_file_ftype _initialize_pascal_valprint; -extern initialize_file_ftype _initialize_scheme_language; -extern initialize_file_ftype _initialize_complaints; -extern initialize_file_ftype _initialize_typeprint; -extern initialize_file_ftype _initialize_cp_valprint; -extern initialize_file_ftype _initialize_f_valprint; -extern initialize_file_ftype _initialize_nlmread; -extern initialize_file_ftype _initialize_serial; -extern initialize_file_ftype _initialize_mdebugread; -extern initialize_file_ftype _initialize_user_regs; -extern initialize_file_ftype _initialize_frame; -extern initialize_file_ftype _initialize_frame_unwind; -extern initialize_file_ftype _initialize_frame_base; -extern initialize_file_ftype _initialize_gnu_v2_abi; -extern initialize_file_ftype _initialize_gnu_v3_abi; -extern initialize_file_ftype _initialize_hpacc_abi; -extern initialize_file_ftype _initialize_cp_abi; -extern initialize_file_ftype _initialize_cp_support; -extern initialize_file_ftype _initialize_cp_namespace; -extern initialize_file_ftype _initialize_reggroup; -extern initialize_file_ftype _initialize_inflow; -extern initialize_file_ftype _initialize_cli_dump; -extern initialize_file_ftype _initialize_cli_logging; -extern initialize_file_ftype _initialize_cli_interp; -extern initialize_file_ftype _initialize_mi_out; -extern initialize_file_ftype _initialize_mi_cmds; -extern initialize_file_ftype _initialize_mi_cmd_env; -extern initialize_file_ftype _initialize_mi_interp; -extern initialize_file_ftype _initialize_mi_main; -extern initialize_file_ftype _initialize_tui_hooks; -extern initialize_file_ftype _initialize_tui_interp; -extern initialize_file_ftype _initialize_tui_layout; -extern initialize_file_ftype _initialize_tui_out; -extern initialize_file_ftype _initialize_tui_regs; -extern initialize_file_ftype _initialize_tui_stack; -extern initialize_file_ftype _initialize_tui_win; -void -initialize_all_files (void) -{ - _initialize_gdbtypes (); - _initialize_mips_tdep (); - _initialize_mipsfbsd_tdep (); - _initialize_corelow (); - _initialize_solib (); - _initialize_svr4_solib (); - _initialize_ser_hardwire (); - _initialize_ser_pipe (); - _initialize_ser_tcp (); -#ifndef CROSS_DEBUGGER -#if 0 - _initialize_mipsfbsd_nat (); - _initialize_mips_nat (); -#endif - _initialize_kernel_u_addr (); - _initialize_infptrace (); - _initialize_inftarg (); - _initialize_thread_db (); -#if 0 - _initialize_svr4_lm (); -#endif -#endif - _initialize_remote (); - _initialize_dcache (); - _initialize_sr_support (); - _initialize_tracepoint (); - _initialize_ax_gdb (); - _initialize_annotate (); - _initialize_auxv (); - _initialize_breakpoint (); - _initialize_regcache (); - _initialize_charset (); - _initialize_dummy_frame (); - _initialize_source (); - _initialize_values (); - _initialize_valops (); - _initialize_valarith (); - _initialize_valprint (); - _initialize_printcmd (); - _initialize_symtab (); - _initialize_symfile (); - _initialize_symmisc (); - _initialize_infcall (); - _initialize_infcmd (); - _initialize_infrun (); - _initialize_stack (); - _initialize_thread (); - _initialize_interpreter (); - _initialize_macrocmd (); - _initialize_gdbarch (); - _initialize_gdbarch_utils (); - _initialize_gdb_osabi (); - _initialize_copying (); - _initialize_mem (); - _initialize_parse (); - _initialize_language (); - _initialize_frame_reg (); - _initialize_signals (); - _initialize_kod (); - _initialize_gdb_events (); - _initialize_exec (); - _initialize_maint_cmds (); - _initialize_demangler (); - _initialize_dbxread (); - _initialize_coffread (); - _initialize_elfread (); - _initialize_mipsread (); - _initialize_stabsread (); - _initialize_core (); - _initialize_dwarf2_frame (); - _initialize_c_language (); - _initialize_f_language (); - _initialize_objc_language (); - _initialize_ui_out (); - _initialize_cli_out (); - _initialize_varobj (); - _initialize_java_language (); - _initialize_m2_language (); - _initialize_pascal_language (); - _initialize_pascal_valprint (); - _initialize_scheme_language (); - _initialize_complaints (); - _initialize_typeprint (); - _initialize_cp_valprint (); - _initialize_f_valprint (); - _initialize_nlmread (); - _initialize_serial (); - _initialize_mdebugread (); - _initialize_user_regs (); - _initialize_frame (); - _initialize_frame_unwind (); - _initialize_frame_base (); - _initialize_gnu_v2_abi (); - _initialize_gnu_v3_abi (); - _initialize_hpacc_abi (); - _initialize_cp_abi (); - _initialize_cp_support (); - _initialize_cp_namespace (); - _initialize_reggroup (); - _initialize_inflow (); - _initialize_cli_dump (); - _initialize_cli_logging (); - _initialize_cli_interp (); - _initialize_mi_out (); - _initialize_mi_cmds (); - _initialize_mi_cmd_env (); - _initialize_mi_interp (); - _initialize_mi_main (); - _initialize_tui_hooks (); - _initialize_tui_interp (); - _initialize_tui_layout (); - _initialize_tui_out (); - _initialize_tui_regs (); - _initialize_tui_stack (); - _initialize_tui_win (); -} diff --git a/gnu/usr.bin/gdb/arch/powerpc/Makefile b/gnu/usr.bin/gdb/arch/powerpc/Makefile deleted file mode 100644 index fa41a237d1f..00000000000 --- a/gnu/usr.bin/gdb/arch/powerpc/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.if !defined(GDB_CROSS_DEBUGGER) -LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c -LIBSRCS+= ppcfbsd-nat.c -.endif -LIBSRCS+= solib.c solib-svr4.c -LIBSRCS+= ppc-sysv-tdep.c ppcfbsd-tdep.c rs6000-tdep.c - -nm.h: - echo '#include "powerpc/nm-fbsd.h"' > ${.TARGET} - -tm.h: - echo '#include "powerpc/tm-ppc-eabi.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/powerpc/config.h b/gnu/usr.bin/gdb/arch/powerpc/config.h deleted file mode 100644 index 8686a99d1f5..00000000000 --- a/gnu/usr.bin/gdb/arch/powerpc/config.h +++ /dev/null @@ -1,550 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated automatically by configure. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if the `long double' type works. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define if you have . */ -/* #undef HAVE_VFORK_H */ - -/* Define as __inline if that's what the C compiler calls it. */ -/* #undef inline */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define vfork as fork if vfork does not work. */ -/* #undef vfork */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Define if your struct reg has r_fs. */ -/* #undef HAVE_STRUCT_REG_R_FS */ - -/* Define if your struct stat has st_blocks. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define if your struct reg has r_gs. */ -/* #undef HAVE_STRUCT_REG_R_GS */ - -/* Define if exists and defines struct link_map which has - members with an ``l_'' prefix. (For Solaris, SVR4, and - SVR4-like systems.) */ -#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 - -/* Define if exists and defines struct link_map which has - members with an ``lm_'' prefix. (For SunOS.) */ -/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ - -/* Define if exists and defines a struct so_map which has - members with an ``som_'' prefix. (Found on older *BSD systems.) */ -/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ - -/* Define if has struct link_map32 */ -/* #undef HAVE_STRUCT_LINK_MAP32 */ - -/* Define if has link_map32 (solaris sparc-64 target) */ -/* #undef _SYSCALL32 */ - -/* Define if the prfpregset_t type is broken. */ -/* #undef PRFPREGSET_T_BROKEN */ - -/* Define if you want to use new multi-fd /proc interface - (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ -/* #undef NEW_PROC_API */ - -/* Define if ioctl argument PIOCSET is available. */ -/* #undef HAVE_PROCFS_PIOCSET */ - -/* Define if the `long long' type works. */ -#define CC_HAS_LONG_LONG 1 - -/* Define if the "ll" format works to print long long ints. */ -#define PRINTF_HAS_LONG_LONG 1 - -/* Define if the "%Lg" format works to print long doubles. */ -#define PRINTF_HAS_LONG_DOUBLE 1 - -/* Define if the "%Lg" format works to scan long doubles. */ -#define SCANF_HAS_LONG_DOUBLE 1 - -/* Define if using Solaris thread debugging. */ -/* #undef HAVE_THREAD_DB_LIB */ - -/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ -/* #undef START_INFERIOR_TRAPS_EXPECTED */ -/* #undef sys_quotactl */ - -/* Define if you have HPUX threads */ -/* #undef HAVE_HPUX_THREAD_SUPPORT */ - -/* Define if on solaris uses int instead of - size_t, and assorted other type changes. */ -/* #undef PROC_SERVICE_IS_OLD */ - -/* Define if the simulator is being linked in. */ -#define WITH_SIM 1 - -/* Set to true if the save_state_t structure is present */ -/* #undef HAVE_STRUCT_SAVE_STATE_T */ - -/* Set to true if the save_state_t structure has the ss_wide member */ -/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ - -/* Define if defines the PTRACE_GETREGS request. */ -/* #undef HAVE_PTRACE_GETREGS */ - -/* Define if defines the PTRACE_GETFPXREGS request. */ -/* #undef HAVE_PTRACE_GETFPXREGS */ - -/* Define if defines the PT_GETDBREGS request. */ -#define HAVE_PT_GETDBREGS 1 - -/* Define if defines the PT_GETXMMREGS request. */ -/* #undef HAVE_PT_GETXMMREGS */ - -/* Define if libunwind library is being used. */ -/* #undef HAVE_LIBUNWIND */ - -/* hostfile */ -/* #undef GDB_XM_FILE */ - -/* targetfile */ -#define GDB_TM_FILE config/powerpc/tm-ppc-eabi.h - -/* nativefile */ -#ifndef CROSS_DEBUGGER -#define GDB_NM_FILE config/powerpc/nm-fbsd.h -#endif - -/* Define to 1 so gets a definition of anon_hdl. Works - around a problem on IRIX 5. */ -#ifndef _KMEMUSER -/* #undef _KMEMUSER */ -#endif - -/* Define if you have the __argz_count function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define if you have the __argz_next function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define if you have the __argz_stringify function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define if you have the _mcleanup function. */ -#define HAVE__MCLEANUP 1 - -/* Define if you have the canonicalize_file_name function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define if you have the dcgettext function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the monstartup function. */ -#define HAVE_MONSTARTUP 1 - -/* Define if you have the munmap function. */ -#define HAVE_MUNMAP 1 - -/* Define if you have the poll function. */ -#define HAVE_POLL 1 - -/* Define if you have the pread64 function. */ -/* #undef HAVE_PREAD64 */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the realpath function. */ -#define HAVE_REALPATH 1 - -/* Define if you have the sbrk function. */ -/* #undef HAVE_SBRK */ - -/* Define if you have the setenv function. */ -#define HAVE_SETENV 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setpgrp function. */ -#define HAVE_SETPGRP 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the sigprocmask function. */ -#define HAVE_SIGPROCMASK 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 1 - -/* Define if you have the socketpair function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define if you have the stpcpy function. */ -#define HAVE_STPCPY 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the syscall function. */ -#define HAVE_SYSCALL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the header file. */ -#define HAVE_CURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_IA64_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_MACHINE_REG_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_PROC_SERVICE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PTRACE_H */ - -/* Define if you have the header file. */ -#define HAVE_SGTTY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DEBUGREG_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FAULT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_REG_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_USER_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIO_H */ - -/* Define if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_DB_H */ - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_VALUES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_WAIT_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the w library (-lw). */ -/* #undef HAVE_LIBW */ - -/* Define if you have the stpcpy function */ -#define HAVE_STPCPY 1 - -/* Define if your locale.h file contains LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if NLS is requested */ -/* #undef ENABLE_NLS */ - -/* Define as 1 if you have gettext and don't want to use GNU gettext. */ -/* #undef HAVE_GETTEXT */ - -/* Name of this package. */ -#define PACKAGE "gdb" - -/* Define to BFD's default architecture. */ -#define DEFAULT_BFD_ARCH bfd_rs6000_arch - -/* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf32_powerpc_vec - -/* Define to 1 if your system has the _etext variable. */ -#define HAVE__ETEXT 1 - -/* Define to 1 to avoid a clash between and on - Solaris 2.[78] when using GCC. */ -/* #undef _MSE_INT_H */ - -/* Define to 1 if we found this declaration otherwise define to 0. */ -#define HAVE_DECL_GETOPT 0 - -/* Define if sigsetjmp is available. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if the regex included in libiberty should be used. */ -#define USE_INCLUDED_REGEX 1 - -/* Define to 1 if your system has struct reg in . */ -#define HAVE_STRUCT_REG 1 - -/* Define if provides the uintptr_t type. */ -#define HAVE_UINTPTR_T 1 - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if realloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_REALLOC */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if strerror is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRERROR */ - -/* Define if strdup is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRDUP */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has prrun_t. */ -/* #undef HAVE_PRRUN_T */ - -/* Define if has gregset_t. */ -#define HAVE_GREGSET_T 1 - -/* Define if has fpregset_t. */ -#define HAVE_FPREGSET_T 1 - -/* Define if has prgregset_t. */ -#define HAVE_PRGREGSET_T 1 - -/* Define if has prfpregset_t. */ -#define HAVE_PRFPREGSET_T 1 - -/* Define if has prgregset32_t. */ -/* #undef HAVE_PRGREGSET32_T */ - -/* Define if has prfpregset32_t. */ -/* #undef HAVE_PRFPREGSET32_T */ - -/* Define if has lwpid_t. */ -#define HAVE_LWPID_T 1 - -/* Define if has psaddr_t. */ -#define HAVE_PSADDR_T 1 - -/* Define if has prsysent_t. */ -/* #undef HAVE_PRSYSENT_T */ - -/* Define if has pr_sigset_t. */ -/* #undef HAVE_PR_SIGSET_T */ - -/* Define if has pr_sigaction64_t. */ -/* #undef HAVE_PR_SIGACTION64_T */ - -/* Define if has pr_siginfo64_t. */ -/* #undef HAVE_PR_SIGINFO64_T */ - -/* Define if has the TD_NOTALLOC error code. */ -/* #undef THREAD_DB_HAS_TD_NOTALLOC */ - -/* Define if we can use the tkill syscall. */ -/* #undef HAVE_TKILL_SYSCALL */ - -/* Define to the default OS ABI for this configuration. */ -/* #undef GDB_OSABI_DEFAULT */ - -/* Define to be a string naming the default host character set. */ -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - diff --git a/gnu/usr.bin/gdb/arch/powerpc/init.c b/gnu/usr.bin/gdb/arch/powerpc/init.c deleted file mode 100644 index 5b96bd5137a..00000000000 --- a/gnu/usr.bin/gdb/arch/powerpc/init.c +++ /dev/null @@ -1,230 +0,0 @@ -/* $FreeBSD$ */ - -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ -#include "defs.h" /* For initialize_file_ftype. */ -#include "call-cmds.h" /* For initialize_all_files. */ -extern initialize_file_ftype _initialize_gdbtypes; -extern initialize_file_ftype _initialize_rs6000_tdep; -extern initialize_file_ftype _initialize_ppcfbsd_tdep; -extern initialize_file_ftype _initialize_corelow; -extern initialize_file_ftype _initialize_solib; -extern initialize_file_ftype _initialize_svr4_solib; -extern initialize_file_ftype _initialize_ser_hardwire; -extern initialize_file_ftype _initialize_ser_pipe; -extern initialize_file_ftype _initialize_ser_tcp; -extern initialize_file_ftype _initialize_fbsd_proc; -extern initialize_file_ftype _initialize_gcore; -extern initialize_file_ftype _initialize_kernel_u_addr; -extern initialize_file_ftype _initialize_infptrace; -extern initialize_file_ftype _initialize_inftarg; -extern initialize_file_ftype _initialize_ppcfbsd_nat; -extern initialize_file_ftype _initialize_thread_db; -extern initialize_file_ftype _initialize_remote; -extern initialize_file_ftype _initialize_dcache; -extern initialize_file_ftype _initialize_sr_support; -extern initialize_file_ftype _initialize_tracepoint; -extern initialize_file_ftype _initialize_ax_gdb; -extern initialize_file_ftype _initialize_annotate; -extern initialize_file_ftype _initialize_auxv; -extern initialize_file_ftype _initialize_breakpoint; -extern initialize_file_ftype _initialize_regcache; -extern initialize_file_ftype _initialize_charset; -extern initialize_file_ftype _initialize_dummy_frame; -extern initialize_file_ftype _initialize_source; -extern initialize_file_ftype _initialize_values; -extern initialize_file_ftype _initialize_valops; -extern initialize_file_ftype _initialize_valarith; -extern initialize_file_ftype _initialize_valprint; -extern initialize_file_ftype _initialize_printcmd; -extern initialize_file_ftype _initialize_symtab; -extern initialize_file_ftype _initialize_symfile; -extern initialize_file_ftype _initialize_symmisc; -extern initialize_file_ftype _initialize_infcall; -extern initialize_file_ftype _initialize_infcmd; -extern initialize_file_ftype _initialize_infrun; -extern initialize_file_ftype _initialize_stack; -extern initialize_file_ftype _initialize_thread; -extern initialize_file_ftype _initialize_interpreter; -extern initialize_file_ftype _initialize_macrocmd; -extern initialize_file_ftype _initialize_gdbarch; -extern initialize_file_ftype _initialize_gdbarch_utils; -extern initialize_file_ftype _initialize_gdb_osabi; -extern initialize_file_ftype _initialize_copying; -extern initialize_file_ftype _initialize_mem; -extern initialize_file_ftype _initialize_parse; -extern initialize_file_ftype _initialize_language; -extern initialize_file_ftype _initialize_frame_reg; -extern initialize_file_ftype _initialize_signals; -extern initialize_file_ftype _initialize_kod; -extern initialize_file_ftype _initialize_gdb_events; -extern initialize_file_ftype _initialize_exec; -extern initialize_file_ftype _initialize_maint_cmds; -extern initialize_file_ftype _initialize_demangler; -extern initialize_file_ftype _initialize_dbxread; -extern initialize_file_ftype _initialize_coffread; -extern initialize_file_ftype _initialize_elfread; -extern initialize_file_ftype _initialize_mipsread; -extern initialize_file_ftype _initialize_stabsread; -extern initialize_file_ftype _initialize_core; -extern initialize_file_ftype _initialize_dwarf2_frame; -extern initialize_file_ftype _initialize_c_language; -extern initialize_file_ftype _initialize_f_language; -extern initialize_file_ftype _initialize_objc_language; -extern initialize_file_ftype _initialize_ui_out; -extern initialize_file_ftype _initialize_cli_out; -extern initialize_file_ftype _initialize_varobj; -extern initialize_file_ftype _initialize_java_language; -extern initialize_file_ftype _initialize_m2_language; -extern initialize_file_ftype _initialize_pascal_language; -extern initialize_file_ftype _initialize_pascal_valprint; -extern initialize_file_ftype _initialize_scheme_language; -extern initialize_file_ftype _initialize_complaints; -extern initialize_file_ftype _initialize_typeprint; -extern initialize_file_ftype _initialize_cp_valprint; -extern initialize_file_ftype _initialize_f_valprint; -extern initialize_file_ftype _initialize_nlmread; -extern initialize_file_ftype _initialize_serial; -extern initialize_file_ftype _initialize_mdebugread; -extern initialize_file_ftype _initialize_user_regs; -extern initialize_file_ftype _initialize_frame; -extern initialize_file_ftype _initialize_frame_unwind; -extern initialize_file_ftype _initialize_frame_base; -extern initialize_file_ftype _initialize_gnu_v2_abi; -extern initialize_file_ftype _initialize_gnu_v3_abi; -extern initialize_file_ftype _initialize_hpacc_abi; -extern initialize_file_ftype _initialize_cp_abi; -extern initialize_file_ftype _initialize_cp_support; -extern initialize_file_ftype _initialize_cp_namespace; -extern initialize_file_ftype _initialize_reggroup; -extern initialize_file_ftype _initialize_inflow; -extern initialize_file_ftype _initialize_cli_dump; -extern initialize_file_ftype _initialize_cli_logging; -extern initialize_file_ftype _initialize_cli_interp; -extern initialize_file_ftype _initialize_mi_out; -extern initialize_file_ftype _initialize_mi_cmds; -extern initialize_file_ftype _initialize_mi_cmd_env; -extern initialize_file_ftype _initialize_mi_interp; -extern initialize_file_ftype _initialize_mi_main; -extern initialize_file_ftype _initialize_tui_hooks; -extern initialize_file_ftype _initialize_tui_interp; -extern initialize_file_ftype _initialize_tui_layout; -extern initialize_file_ftype _initialize_tui_out; -extern initialize_file_ftype _initialize_tui_regs; -extern initialize_file_ftype _initialize_tui_stack; -extern initialize_file_ftype _initialize_tui_win; -void -initialize_all_files (void) -{ - _initialize_gdbtypes (); - _initialize_rs6000_tdep (); - _initialize_ppcfbsd_tdep (); - _initialize_corelow (); - _initialize_solib (); - _initialize_svr4_solib (); - _initialize_ser_hardwire (); - _initialize_ser_pipe (); - _initialize_ser_tcp (); -#ifndef CROSS_DEBUGGER - _initialize_fbsd_proc (); - _initialize_gcore (); - _initialize_kernel_u_addr (); - _initialize_infptrace (); - _initialize_inftarg (); - _initialize_ppcfbsd_nat (); - _initialize_thread_db (); -#endif - _initialize_remote (); - _initialize_dcache (); - _initialize_sr_support (); - _initialize_tracepoint (); - _initialize_ax_gdb (); - _initialize_annotate (); - _initialize_auxv (); - _initialize_breakpoint (); - _initialize_regcache (); - _initialize_charset (); - _initialize_dummy_frame (); - _initialize_source (); - _initialize_values (); - _initialize_valops (); - _initialize_valarith (); - _initialize_valprint (); - _initialize_printcmd (); - _initialize_symtab (); - _initialize_symfile (); - _initialize_symmisc (); - _initialize_infcall (); - _initialize_infcmd (); - _initialize_infrun (); - _initialize_stack (); - _initialize_thread (); - _initialize_interpreter (); - _initialize_macrocmd (); - _initialize_gdbarch (); - _initialize_gdbarch_utils (); - _initialize_gdb_osabi (); - _initialize_copying (); - _initialize_mem (); - _initialize_parse (); - _initialize_language (); - _initialize_frame_reg (); - _initialize_signals (); - _initialize_kod (); - _initialize_gdb_events (); - _initialize_exec (); - _initialize_maint_cmds (); - _initialize_demangler (); - _initialize_dbxread (); - _initialize_coffread (); - _initialize_elfread (); - _initialize_mipsread (); - _initialize_stabsread (); - _initialize_core (); - _initialize_dwarf2_frame (); - _initialize_c_language (); - _initialize_f_language (); - _initialize_objc_language (); - _initialize_ui_out (); - _initialize_cli_out (); - _initialize_varobj (); - _initialize_java_language (); - _initialize_m2_language (); - _initialize_pascal_language (); - _initialize_pascal_valprint (); - _initialize_scheme_language (); - _initialize_complaints (); - _initialize_typeprint (); - _initialize_cp_valprint (); - _initialize_f_valprint (); - _initialize_nlmread (); - _initialize_serial (); - _initialize_mdebugread (); - _initialize_user_regs (); - _initialize_frame (); - _initialize_frame_unwind (); - _initialize_frame_base (); - _initialize_gnu_v2_abi (); - _initialize_gnu_v3_abi (); - _initialize_hpacc_abi (); - _initialize_cp_abi (); - _initialize_cp_support (); - _initialize_cp_namespace (); - _initialize_reggroup (); - _initialize_inflow (); - _initialize_cli_dump (); - _initialize_cli_logging (); - _initialize_cli_interp (); - _initialize_mi_out (); - _initialize_mi_cmds (); - _initialize_mi_cmd_env (); - _initialize_mi_interp (); - _initialize_mi_main (); - _initialize_tui_hooks (); - _initialize_tui_interp (); - _initialize_tui_layout (); - _initialize_tui_out (); - _initialize_tui_regs (); - _initialize_tui_stack (); - _initialize_tui_win (); -} diff --git a/gnu/usr.bin/gdb/arch/powerpc64/Makefile b/gnu/usr.bin/gdb/arch/powerpc64/Makefile deleted file mode 100644 index fa41a237d1f..00000000000 --- a/gnu/usr.bin/gdb/arch/powerpc64/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.if !defined(GDB_CROSS_DEBUGGER) -LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c -LIBSRCS+= ppcfbsd-nat.c -.endif -LIBSRCS+= solib.c solib-svr4.c -LIBSRCS+= ppc-sysv-tdep.c ppcfbsd-tdep.c rs6000-tdep.c - -nm.h: - echo '#include "powerpc/nm-fbsd.h"' > ${.TARGET} - -tm.h: - echo '#include "powerpc/tm-ppc-eabi.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/powerpc64/config.h b/gnu/usr.bin/gdb/arch/powerpc64/config.h deleted file mode 100644 index 6ec6560e420..00000000000 --- a/gnu/usr.bin/gdb/arch/powerpc64/config.h +++ /dev/null @@ -1,550 +0,0 @@ -/* $FreeBSD$ */ - -/* config.h. Generated automatically by configure. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if the `long double' type works. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define if you have . */ -/* #undef HAVE_VFORK_H */ - -/* Define as __inline if that's what the C compiler calls it. */ -/* #undef inline */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define vfork as fork if vfork does not work. */ -/* #undef vfork */ - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - -/* Define if your struct reg has r_fs. */ -/* #undef HAVE_STRUCT_REG_R_FS */ - -/* Define if your struct stat has st_blocks. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define if your struct reg has r_gs. */ -/* #undef HAVE_STRUCT_REG_R_GS */ - -/* Define if exists and defines struct link_map which has - members with an ``l_'' prefix. (For Solaris, SVR4, and - SVR4-like systems.) */ -#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 - -/* Define if exists and defines struct link_map which has - members with an ``lm_'' prefix. (For SunOS.) */ -/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ - -/* Define if exists and defines a struct so_map which has - members with an ``som_'' prefix. (Found on older *BSD systems.) */ -/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ - -/* Define if has struct link_map32 */ -/* #undef HAVE_STRUCT_LINK_MAP32 */ - -/* Define if has link_map32 (solaris sparc-64 target) */ -/* #undef _SYSCALL32 */ - -/* Define if the prfpregset_t type is broken. */ -/* #undef PRFPREGSET_T_BROKEN */ - -/* Define if you want to use new multi-fd /proc interface - (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ -/* #undef NEW_PROC_API */ - -/* Define if ioctl argument PIOCSET is available. */ -/* #undef HAVE_PROCFS_PIOCSET */ - -/* Define if the `long long' type works. */ -#define CC_HAS_LONG_LONG 1 - -/* Define if the "ll" format works to print long long ints. */ -#define PRINTF_HAS_LONG_LONG 1 - -/* Define if the "%Lg" format works to print long doubles. */ -#define PRINTF_HAS_LONG_DOUBLE 1 - -/* Define if the "%Lg" format works to scan long doubles. */ -#define SCANF_HAS_LONG_DOUBLE 1 - -/* Define if using Solaris thread debugging. */ -/* #undef HAVE_THREAD_DB_LIB */ - -/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ -/* #undef START_INFERIOR_TRAPS_EXPECTED */ -/* #undef sys_quotactl */ - -/* Define if you have HPUX threads */ -/* #undef HAVE_HPUX_THREAD_SUPPORT */ - -/* Define if on solaris uses int instead of - size_t, and assorted other type changes. */ -/* #undef PROC_SERVICE_IS_OLD */ - -/* Define if the simulator is being linked in. */ -#define WITH_SIM 1 - -/* Set to true if the save_state_t structure is present */ -/* #undef HAVE_STRUCT_SAVE_STATE_T */ - -/* Set to true if the save_state_t structure has the ss_wide member */ -/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ - -/* Define if defines the PTRACE_GETREGS request. */ -/* #undef HAVE_PTRACE_GETREGS */ - -/* Define if defines the PTRACE_GETFPXREGS request. */ -/* #undef HAVE_PTRACE_GETFPXREGS */ - -/* Define if defines the PT_GETDBREGS request. */ -#define HAVE_PT_GETDBREGS 1 - -/* Define if defines the PT_GETXMMREGS request. */ -/* #undef HAVE_PT_GETXMMREGS */ - -/* Define if libunwind library is being used. */ -/* #undef HAVE_LIBUNWIND */ - -/* hostfile */ -/* #undef GDB_XM_FILE */ - -/* targetfile */ -#define GDB_TM_FILE config/powerpc/tm-ppc-eabi.h - -/* nativefile */ -#ifndef CROSS_DEBUGGER -#define GDB_NM_FILE config/ia64/nm-fbsd.h -#endif - -/* Define to 1 so gets a definition of anon_hdl. Works - around a problem on IRIX 5. */ -#ifndef _KMEMUSER -/* #undef _KMEMUSER */ -#endif - -/* Define if you have the __argz_count function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define if you have the __argz_next function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define if you have the __argz_stringify function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define if you have the _mcleanup function. */ -#define HAVE__MCLEANUP 1 - -/* Define if you have the canonicalize_file_name function. */ -/* #undef HAVE_CANONICALIZE_FILE_NAME */ - -/* Define if you have the dcgettext function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the monstartup function. */ -#define HAVE_MONSTARTUP 1 - -/* Define if you have the munmap function. */ -#define HAVE_MUNMAP 1 - -/* Define if you have the poll function. */ -#define HAVE_POLL 1 - -/* Define if you have the pread64 function. */ -/* #undef HAVE_PREAD64 */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the realpath function. */ -#define HAVE_REALPATH 1 - -/* Define if you have the sbrk function. */ -/* #undef HAVE_SBRK */ - -/* Define if you have the setenv function. */ -#define HAVE_SETENV 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setpgrp function. */ -#define HAVE_SETPGRP 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the sigprocmask function. */ -#define HAVE_SIGPROCMASK 1 - -/* Define if you have the sigsetmask function. */ -#define HAVE_SIGSETMASK 1 - -/* Define if you have the socketpair function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define if you have the stpcpy function. */ -#define HAVE_STPCPY 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strchr function. */ -#define HAVE_STRCHR 1 - -/* Define if you have the syscall function. */ -#define HAVE_SYSCALL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define if you have the header file. */ -#define HAVE_CURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_IA64_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_LIBUNWIND_H */ - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_MACHINE_REG_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_NLIST_H 1 - -/* Define if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_PROC_SERVICE_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_PTRACE_H */ - -/* Define if you have the header file. */ -#define HAVE_SGTTY_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DEBUGREG_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_FAULT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PROCFS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_REG_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_USER_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_TERM_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_TERMIO_H */ - -/* Define if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_DB_H */ - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_VALUES_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_WAIT_H */ - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the m library (-lm). */ -#define HAVE_LIBM 1 - -/* Define if you have the w library (-lw). */ -/* #undef HAVE_LIBW */ - -/* Define if you have the stpcpy function */ -#define HAVE_STPCPY 1 - -/* Define if your locale.h file contains LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if NLS is requested */ -/* #undef ENABLE_NLS */ - -/* Define as 1 if you have gettext and don't want to use GNU gettext. */ -/* #undef HAVE_GETTEXT */ - -/* Name of this package. */ -#define PACKAGE "gdb" - -/* Define to BFD's default architecture. */ -#define DEFAULT_BFD_ARCH bfd_rs6000_arch - -/* Define to BFD's default target vector. */ -#define DEFAULT_BFD_VEC bfd_elf64_powerpc_vec - -/* Define to 1 if your system has the _etext variable. */ -#define HAVE__ETEXT 1 - -/* Define to 1 to avoid a clash between and on - Solaris 2.[78] when using GCC. */ -/* #undef _MSE_INT_H */ - -/* Define to 1 if we found this declaration otherwise define to 0. */ -#define HAVE_DECL_GETOPT 0 - -/* Define if sigsetjmp is available. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if the regex included in libiberty should be used. */ -#define USE_INCLUDED_REGEX 1 - -/* Define to 1 if your system has struct reg in . */ -#define HAVE_STRUCT_REG 1 - -/* Define if provides the uintptr_t type. */ -#define HAVE_UINTPTR_T 1 - -/* Define if malloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Define if realloc is not declared in system header files. */ -/* #undef NEED_DECLARATION_REALLOC */ - -/* Define if free is not declared in system header files. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if strerror is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRERROR */ - -/* Define if strdup is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRDUP */ - -/* Define if strstr is not declared in system header files. */ -/* #undef NEED_DECLARATION_STRSTR */ - -/* Define if canonicalize_file_name is not declared in system header files. */ -#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 - -/* Define if has pstatus_t. */ -/* #undef HAVE_PSTATUS_T */ - -/* Define if has prrun_t. */ -/* #undef HAVE_PRRUN_T */ - -/* Define if has gregset_t. */ -#define HAVE_GREGSET_T 1 - -/* Define if has fpregset_t. */ -#define HAVE_FPREGSET_T 1 - -/* Define if has prgregset_t. */ -#define HAVE_PRGREGSET_T 1 - -/* Define if has prfpregset_t. */ -#define HAVE_PRFPREGSET_T 1 - -/* Define if has prgregset32_t. */ -/* #undef HAVE_PRGREGSET32_T */ - -/* Define if has prfpregset32_t. */ -/* #undef HAVE_PRFPREGSET32_T */ - -/* Define if has lwpid_t. */ -#define HAVE_LWPID_T 1 - -/* Define if has psaddr_t. */ -#define HAVE_PSADDR_T 1 - -/* Define if has prsysent_t. */ -/* #undef HAVE_PRSYSENT_T */ - -/* Define if has pr_sigset_t. */ -/* #undef HAVE_PR_SIGSET_T */ - -/* Define if has pr_sigaction64_t. */ -/* #undef HAVE_PR_SIGACTION64_T */ - -/* Define if has pr_siginfo64_t. */ -/* #undef HAVE_PR_SIGINFO64_T */ - -/* Define if has the TD_NOTALLOC error code. */ -/* #undef THREAD_DB_HAS_TD_NOTALLOC */ - -/* Define if we can use the tkill syscall. */ -/* #undef HAVE_TKILL_SYSCALL */ - -/* Define to the default OS ABI for this configuration. */ -/* #undef GDB_OSABI_DEFAULT */ - -/* Define to be a string naming the default host character set. */ -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define as const if the declaration of iconv() needs const. */ -/* #undef ICONV_CONST */ - diff --git a/gnu/usr.bin/gdb/arch/powerpc64/init.c b/gnu/usr.bin/gdb/arch/powerpc64/init.c deleted file mode 100644 index 5b96bd5137a..00000000000 --- a/gnu/usr.bin/gdb/arch/powerpc64/init.c +++ /dev/null @@ -1,230 +0,0 @@ -/* $FreeBSD$ */ - -/* Do not modify this file. */ -/* It is created automatically by the Makefile. */ -#include "defs.h" /* For initialize_file_ftype. */ -#include "call-cmds.h" /* For initialize_all_files. */ -extern initialize_file_ftype _initialize_gdbtypes; -extern initialize_file_ftype _initialize_rs6000_tdep; -extern initialize_file_ftype _initialize_ppcfbsd_tdep; -extern initialize_file_ftype _initialize_corelow; -extern initialize_file_ftype _initialize_solib; -extern initialize_file_ftype _initialize_svr4_solib; -extern initialize_file_ftype _initialize_ser_hardwire; -extern initialize_file_ftype _initialize_ser_pipe; -extern initialize_file_ftype _initialize_ser_tcp; -extern initialize_file_ftype _initialize_fbsd_proc; -extern initialize_file_ftype _initialize_gcore; -extern initialize_file_ftype _initialize_kernel_u_addr; -extern initialize_file_ftype _initialize_infptrace; -extern initialize_file_ftype _initialize_inftarg; -extern initialize_file_ftype _initialize_ppcfbsd_nat; -extern initialize_file_ftype _initialize_thread_db; -extern initialize_file_ftype _initialize_remote; -extern initialize_file_ftype _initialize_dcache; -extern initialize_file_ftype _initialize_sr_support; -extern initialize_file_ftype _initialize_tracepoint; -extern initialize_file_ftype _initialize_ax_gdb; -extern initialize_file_ftype _initialize_annotate; -extern initialize_file_ftype _initialize_auxv; -extern initialize_file_ftype _initialize_breakpoint; -extern initialize_file_ftype _initialize_regcache; -extern initialize_file_ftype _initialize_charset; -extern initialize_file_ftype _initialize_dummy_frame; -extern initialize_file_ftype _initialize_source; -extern initialize_file_ftype _initialize_values; -extern initialize_file_ftype _initialize_valops; -extern initialize_file_ftype _initialize_valarith; -extern initialize_file_ftype _initialize_valprint; -extern initialize_file_ftype _initialize_printcmd; -extern initialize_file_ftype _initialize_symtab; -extern initialize_file_ftype _initialize_symfile; -extern initialize_file_ftype _initialize_symmisc; -extern initialize_file_ftype _initialize_infcall; -extern initialize_file_ftype _initialize_infcmd; -extern initialize_file_ftype _initialize_infrun; -extern initialize_file_ftype _initialize_stack; -extern initialize_file_ftype _initialize_thread; -extern initialize_file_ftype _initialize_interpreter; -extern initialize_file_ftype _initialize_macrocmd; -extern initialize_file_ftype _initialize_gdbarch; -extern initialize_file_ftype _initialize_gdbarch_utils; -extern initialize_file_ftype _initialize_gdb_osabi; -extern initialize_file_ftype _initialize_copying; -extern initialize_file_ftype _initialize_mem; -extern initialize_file_ftype _initialize_parse; -extern initialize_file_ftype _initialize_language; -extern initialize_file_ftype _initialize_frame_reg; -extern initialize_file_ftype _initialize_signals; -extern initialize_file_ftype _initialize_kod; -extern initialize_file_ftype _initialize_gdb_events; -extern initialize_file_ftype _initialize_exec; -extern initialize_file_ftype _initialize_maint_cmds; -extern initialize_file_ftype _initialize_demangler; -extern initialize_file_ftype _initialize_dbxread; -extern initialize_file_ftype _initialize_coffread; -extern initialize_file_ftype _initialize_elfread; -extern initialize_file_ftype _initialize_mipsread; -extern initialize_file_ftype _initialize_stabsread; -extern initialize_file_ftype _initialize_core; -extern initialize_file_ftype _initialize_dwarf2_frame; -extern initialize_file_ftype _initialize_c_language; -extern initialize_file_ftype _initialize_f_language; -extern initialize_file_ftype _initialize_objc_language; -extern initialize_file_ftype _initialize_ui_out; -extern initialize_file_ftype _initialize_cli_out; -extern initialize_file_ftype _initialize_varobj; -extern initialize_file_ftype _initialize_java_language; -extern initialize_file_ftype _initialize_m2_language; -extern initialize_file_ftype _initialize_pascal_language; -extern initialize_file_ftype _initialize_pascal_valprint; -extern initialize_file_ftype _initialize_scheme_language; -extern initialize_file_ftype _initialize_complaints; -extern initialize_file_ftype _initialize_typeprint; -extern initialize_file_ftype _initialize_cp_valprint; -extern initialize_file_ftype _initialize_f_valprint; -extern initialize_file_ftype _initialize_nlmread; -extern initialize_file_ftype _initialize_serial; -extern initialize_file_ftype _initialize_mdebugread; -extern initialize_file_ftype _initialize_user_regs; -extern initialize_file_ftype _initialize_frame; -extern initialize_file_ftype _initialize_frame_unwind; -extern initialize_file_ftype _initialize_frame_base; -extern initialize_file_ftype _initialize_gnu_v2_abi; -extern initialize_file_ftype _initialize_gnu_v3_abi; -extern initialize_file_ftype _initialize_hpacc_abi; -extern initialize_file_ftype _initialize_cp_abi; -extern initialize_file_ftype _initialize_cp_support; -extern initialize_file_ftype _initialize_cp_namespace; -extern initialize_file_ftype _initialize_reggroup; -extern initialize_file_ftype _initialize_inflow; -extern initialize_file_ftype _initialize_cli_dump; -extern initialize_file_ftype _initialize_cli_logging; -extern initialize_file_ftype _initialize_cli_interp; -extern initialize_file_ftype _initialize_mi_out; -extern initialize_file_ftype _initialize_mi_cmds; -extern initialize_file_ftype _initialize_mi_cmd_env; -extern initialize_file_ftype _initialize_mi_interp; -extern initialize_file_ftype _initialize_mi_main; -extern initialize_file_ftype _initialize_tui_hooks; -extern initialize_file_ftype _initialize_tui_interp; -extern initialize_file_ftype _initialize_tui_layout; -extern initialize_file_ftype _initialize_tui_out; -extern initialize_file_ftype _initialize_tui_regs; -extern initialize_file_ftype _initialize_tui_stack; -extern initialize_file_ftype _initialize_tui_win; -void -initialize_all_files (void) -{ - _initialize_gdbtypes (); - _initialize_rs6000_tdep (); - _initialize_ppcfbsd_tdep (); - _initialize_corelow (); - _initialize_solib (); - _initialize_svr4_solib (); - _initialize_ser_hardwire (); - _initialize_ser_pipe (); - _initialize_ser_tcp (); -#ifndef CROSS_DEBUGGER - _initialize_fbsd_proc (); - _initialize_gcore (); - _initialize_kernel_u_addr (); - _initialize_infptrace (); - _initialize_inftarg (); - _initialize_ppcfbsd_nat (); - _initialize_thread_db (); -#endif - _initialize_remote (); - _initialize_dcache (); - _initialize_sr_support (); - _initialize_tracepoint (); - _initialize_ax_gdb (); - _initialize_annotate (); - _initialize_auxv (); - _initialize_breakpoint (); - _initialize_regcache (); - _initialize_charset (); - _initialize_dummy_frame (); - _initialize_source (); - _initialize_values (); - _initialize_valops (); - _initialize_valarith (); - _initialize_valprint (); - _initialize_printcmd (); - _initialize_symtab (); - _initialize_symfile (); - _initialize_symmisc (); - _initialize_infcall (); - _initialize_infcmd (); - _initialize_infrun (); - _initialize_stack (); - _initialize_thread (); - _initialize_interpreter (); - _initialize_macrocmd (); - _initialize_gdbarch (); - _initialize_gdbarch_utils (); - _initialize_gdb_osabi (); - _initialize_copying (); - _initialize_mem (); - _initialize_parse (); - _initialize_language (); - _initialize_frame_reg (); - _initialize_signals (); - _initialize_kod (); - _initialize_gdb_events (); - _initialize_exec (); - _initialize_maint_cmds (); - _initialize_demangler (); - _initialize_dbxread (); - _initialize_coffread (); - _initialize_elfread (); - _initialize_mipsread (); - _initialize_stabsread (); - _initialize_core (); - _initialize_dwarf2_frame (); - _initialize_c_language (); - _initialize_f_language (); - _initialize_objc_language (); - _initialize_ui_out (); - _initialize_cli_out (); - _initialize_varobj (); - _initialize_java_language (); - _initialize_m2_language (); - _initialize_pascal_language (); - _initialize_pascal_valprint (); - _initialize_scheme_language (); - _initialize_complaints (); - _initialize_typeprint (); - _initialize_cp_valprint (); - _initialize_f_valprint (); - _initialize_nlmread (); - _initialize_serial (); - _initialize_mdebugread (); - _initialize_user_regs (); - _initialize_frame (); - _initialize_frame_unwind (); - _initialize_frame_base (); - _initialize_gnu_v2_abi (); - _initialize_gnu_v3_abi (); - _initialize_hpacc_abi (); - _initialize_cp_abi (); - _initialize_cp_support (); - _initialize_cp_namespace (); - _initialize_reggroup (); - _initialize_inflow (); - _initialize_cli_dump (); - _initialize_cli_logging (); - _initialize_cli_interp (); - _initialize_mi_out (); - _initialize_mi_cmds (); - _initialize_mi_cmd_env (); - _initialize_mi_interp (); - _initialize_mi_main (); - _initialize_tui_hooks (); - _initialize_tui_interp (); - _initialize_tui_layout (); - _initialize_tui_out (); - _initialize_tui_regs (); - _initialize_tui_stack (); - _initialize_tui_win (); -} diff --git a/gnu/usr.bin/gdb/gdb/Makefile b/gnu/usr.bin/gdb/gdb/Makefile deleted file mode 100644 index 3cf15f6a24a..00000000000 --- a/gnu/usr.bin/gdb/gdb/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ - -PROG= gdb${GDB_SUFFIX} -SRCS= gdb.c - -BULIBS= ${OBJ_BU}/libbfd/libbfd${PIE_SUFFIX}.a \ - ${OBJ_BU}/libopcodes/libopcodes${PIE_SUFFIX}.a \ - ${OBJ_BU}/libiberty/libiberty${PIE_SUFFIX}.a -GDBLIBS= ${OBJ_GDB}/libgdb/libgdb${PIE_SUFFIX}.a - -# libthread_db.so calls back into gdb for the proc services. Make all the -# global symbols visible. -LDFLAGS+= -Wl,-E - -DPADD= ${GDBLIBS} ${BULIBS} -LDADD= ${GDBLIBS} ${BULIBS} -LIBADD+= m edit ncursesw gnuregex - -.include -CFLAGS+= -DDEBUGDIR=\"${DEBUGDIR}\" diff --git a/gnu/usr.bin/gdb/gdb/Makefile.depend b/gnu/usr.bin/gdb/gdb/Makefile.depend deleted file mode 100644 index ee6269e741a..00000000000 --- a/gnu/usr.bin/gdb/gdb/Makefile.depend +++ /dev/null @@ -1,25 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libreadline/readline \ - gnu/lib/libregex \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libiberty \ - gnu/usr.bin/binutils/libopcodes \ - gnu/usr.bin/gdb/libgdb \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/msun \ - lib/ncurses/ncursesw \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/gdb/gdb/gdb.1 b/gnu/usr.bin/gdb/gdb/gdb.1 deleted file mode 100644 index 635e5c31188..00000000000 --- a/gnu/usr.bin/gdb/gdb/gdb.1 +++ /dev/null @@ -1,376 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $FreeBSD$ -.TH gdb 1 "4nov1991" "GNU Tools" "GNU Tools" -.SH NAME -gdb \- The GNU Debugger -.SH SYNOPSIS -.na -.TP -.B gdb -.RB "[\|" \-help "\|]" -.RB "[\|" \-nx "\|]" -.RB "[\|" \-q "\|]" -.RB "[\|" \-batch "\|]" -.RB "[\|" \-cd=\c -.I dir\c -\|] -.RB "[\|" \-f "\|]" -.RB "[\|" "\-b\ "\c -.IR bps "\|]" -.RB "[\|" "\-tty="\c -.IR dev "\|]" -.RB "[\|" "\-s "\c -.I symfile\c -\&\|] -.RB "[\|" "\-e "\c -.I prog\c -\&\|] -.RB "[\|" "\-se "\c -.I prog\c -\&\|] -.RB "[\|" "\-c "\c -.I core\c -\&\|] -.RB "[\|" "\-x "\c -.I cmds\c -\&\|] -.RB "[\|" "\-d "\c -.I dir\c -\&\|] -.RB "[\|" \c -.I prog\c -.RB "[\|" \c -.IR core \||\| procID\c -\&\|]\&\|] -.ad b -.SH DEPRECATION NOTICE -This version of gdb is deprecated and will be removed from future versions -of the FreeBSD base system. -A newer version of gdb is available from ports or packages -(devel/gdb). -.SH DESCRIPTION -The purpose of a debugger such as GDB is to allow you to see what is -going on ``inside'' another program while it executes\(em\&or what another -program was doing at the moment it crashed. - -GDB can do four main kinds of things (plus other things in support of -these) to help you catch bugs in the act: - -.TP -\ \ \ \(bu -Start your program, specifying anything that might affect its behavior. - -.TP -\ \ \ \(bu -Make your program stop on specified conditions. - -.TP -\ \ \ \(bu -Examine what has happened, when your program has stopped. - -.TP -\ \ \ \(bu -Change things in your program, so you can experiment with correcting the -effects of one bug and go on to learn about another. -.PP - -You can use GDB to debug programs written in C, C++, and Modula-2. -Fortran support will be added when a GNU Fortran compiler is ready. - -GDB is invoked with the shell command \c -.B gdb\c -\&. Once started, it reads -commands from the terminal until you tell it to exit with the GDB -command \c -.B quit\c -\&. You can get online help from \c -.B gdb\c -\& itself -by using the command \c -.B help\c -\&. - -You can run \c -.B gdb\c -\& with no arguments or options; but the most -usual way to start GDB is with one argument or two, specifying an -executable program as the argument: -.sp -.br -gdb\ program -.br -.sp - -You can also start with both an executable program and a core file specified: -.sp -.br -gdb\ program\ core -.br -.sp - -You can, instead, specify a process ID as a second argument, if you want -to debug a running process: -.sp -.br -gdb\ program\ 1234 -.br -.sp - -would attach GDB to process \c -.B 1234\c -\& (unless you also have a file -named `\|\c -.B 1234\c -\&\|'; GDB does check for a core file first). - -Here are some of the most frequently needed GDB commands: -.TP -.B break \fR[\|\fIfile\fB:\fR\|]\fIfunction -\& -Set a breakpoint at \c -.I function\c -\& (in \c -.I file\c -\&). -.TP -.B run \fR[\|\fIarglist\fR\|] -Start your program (with \c -.I arglist\c -\&, if specified). -.TP -.B bt -Backtrace: display the program stack. -.TP -.BI print " expr"\c -\& -Display the value of an expression. -.TP -.B c -Continue running your program (after stopping, e.g. at a breakpoint). -.TP -.B next -Execute next program line (after stopping); step \c -.I over\c -\& any -function calls in the line. -.TP -.B step -Execute next program line (after stopping); step \c -.I into\c -\& any -function calls in the line. -.TP -.B help \fR[\|\fIname\fR\|] -Show information about GDB command \c -.I name\c -\&, or general information -about using GDB. -.TP -.B quit -Exit from GDB. -.PP -For full details on GDB, see \c -.I -Using GDB: A Guide to the GNU Source-Level Debugger\c -\&, by Richard M. Stallman and Roland H. Pesch. The same text is available online -as the \c -.B gdb\c -\& entry in the \c -.B info\c -\& program. -.SH OPTIONS -Any arguments other than options specify an executable -file and core file (or process ID); that is, the first argument -encountered with no -associated option flag is equivalent to a `\|\c -.B \-se\c -\&\|' option, and the -second, if any, is equivalent to a `\|\c -.B \-c\c -\&\|' option if it's the name of a file. Many options have -both long and short forms; both are shown here. The long forms are also -recognized if you truncate them, so long as enough of the option is -present to be unambiguous. (If you prefer, you can flag option -arguments with `\|\c -.B +\c -\&\|' rather than `\|\c -.B \-\c -\&\|', though we illustrate the -more usual convention.) - -All the options and command line arguments you give are processed -in sequential order. The order makes a difference when the -`\|\c -.B \-x\c -\&\|' option is used. - -.TP -.B \-help -.TP -.B \-h -List all options, with brief explanations. - -.TP -.BI "\-symbols=" "file"\c -.TP -.BI "\-s " "file"\c -\& -Read symbol table from file \c -.I file\c -\&. - -.TP -.BI "\-exec=" "file"\c -.TP -.BI "\-e " "file"\c -\& -Use file \c -.I file\c -\& as the executable file to execute when -appropriate, and for examining pure data in conjunction with a core -dump. - -.TP -.BI "\-se=" "file"\c -\& -Read symbol table from file \c -.I file\c -\& and use it as the executable -file. - -.TP -.BI "\-core=" "file"\c -.TP -.BI "\-c " "file"\c -\& -Use file \c -.I file\c -\& as a core dump to examine. - -.TP -.BI "\-command=" "file"\c -.TP -.BI "\-x " "file"\c -\& -Execute GDB commands from file \c -.I file\c -\&. - -.TP -.BI "\-directory=" "directory"\c -.TP -.BI "\-d " "directory"\c -\& -Add \c -.I directory\c -\& to the path to search for source files. -.PP - -.TP -.B \-nx -.TP -.B \-n -Do not execute commands from any `\|\c -.B .gdbinit\c -\&\|' initialization files. -Normally, the commands in these files are executed after all the -command options and arguments have been processed. - - -.TP -.B \-quiet -.TP -.B \-q -``Quiet''. Do not print the introductory and copyright messages. These -messages are also suppressed in batch mode. - -.TP -.B \-batch -Run in batch mode. Exit with status \c -.B 0\c -\& after processing all the command -files specified with `\|\c -.B \-x\c -\&\|' (and `\|\c -.B .gdbinit\c -\&\|', if not inhibited). -Exit with nonzero status if an error occurs in executing the GDB -commands in the command files. - -Batch mode may be useful for running GDB as a filter, for example to -download and run a program on another computer; in order to make this -more useful, the message -.sp -.br -Program\ exited\ normally. -.br -.sp - -(which is ordinarily issued whenever a program running under GDB control -terminates) is not issued when running in batch mode. - -.TP -.BI "\-cd=" "directory"\c -\& -Run GDB using \c -.I directory\c -\& as its working directory, -instead of the current directory. - -.TP -.B \-fullname -.TP -.B \-f -Emacs sets this option when it runs GDB as a subprocess. It tells GDB -to output the full file name and line number in a standard, -recognizable fashion each time a stack frame is displayed (which -includes each time the program stops). This recognizable format looks -like two `\|\c -.B \e032\c -\&\|' characters, followed by the file name, line number -and character position separated by colons, and a newline. The -Emacs-to-GDB interface program uses the two `\|\c -.B \e032\c -\&\|' characters as -a signal to display the source code for the frame. - -.TP -.BI "\-b " "bps"\c -\& -Set the line speed (baud rate or bits per second) of any serial -interface used by GDB for remote debugging. - -.TP -.BI "\-tty=" "device"\c -\& -Run using \c -.I device\c -\& for your program's standard input and output. -.PP - -.SH "SEE ALSO" -.RB "`\|" gdb "\|'" -entry in -.B info\c -\&; -.I -Using GDB: A Guide to the GNU Source-Level Debugger\c -, Richard M. Stallman and Roland H. Pesch, July 1991. -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile b/gnu/usr.bin/gdb/gdbserver/Makefile deleted file mode 100644 index fa46e6de14f..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# $FreeBSD$ - -# Not elf specific so don't install in /usr/libexec/elf -BINDIR=/usr/bin - -GDBDIR= ${SRCTOP}/contrib/gdb -.PATH: ${GDBDIR}/gdb/signals -.PATH: ${GDBDIR}/gdb/gdbserver -.PATH: ${GDBDIR}/gdb - -PROG= gdbserver - -SRCS= inferiors.c mem-break.c regcache.c remote-utils.c \ - server.c signals.c target.c utils.c -SRCS+= fbsd-low.c - -SRCS+= fbsd-${MACHINE_CPUARCH}-low.c reg-${MACHINE_CPUARCH}.c -.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" -SRCS+= i387-fp.c -.endif -#CFLAGS+= -I${.CURDIR}/../arch/${MACHINE_ARCH} -CFLAGS+= -I${GDBDIR}/gdb/gdbserver -CFLAGS+= -I${GDBDIR}/gdb/regformats -CFLAGS+= -DNO_MMALLOC -DGDBSERVER - -.include diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile.depend b/gnu/usr.bin/gdb/gdbserver/Makefile.depend deleted file mode 100644 index d5ed563ecfc..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/Makefile.depend +++ /dev/null @@ -1,18 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-amd64-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-amd64-low.c deleted file mode 100644 index 82a8c93f3df..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/fbsd-amd64-low.c +++ /dev/null @@ -1,213 +0,0 @@ -/* GNU/FreeBSD/amd64 specific low level interface, for the remote server for GDB. - Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 - Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "server.h" -#include "fbsd-low.h" -#include "i387-fp.h" - -#include -#include -#include -#include - -/* Mapping between the general-purpose registers in `struct user' - format and GDB's register array layout. */ -static int amd64_regmap[] = { - offsetof(struct reg, r_rax), - offsetof(struct reg, r_rbx), - offsetof(struct reg, r_rcx), - offsetof(struct reg, r_rdx), - offsetof(struct reg, r_rsi), - offsetof(struct reg, r_rdi), - offsetof(struct reg, r_rbp), - offsetof(struct reg, r_rsp), - offsetof(struct reg, r_r8), - offsetof(struct reg, r_r9), - offsetof(struct reg, r_r10), - offsetof(struct reg, r_r11), - offsetof(struct reg, r_r12), - offsetof(struct reg, r_r13), - offsetof(struct reg, r_r14), - offsetof(struct reg, r_r15), - offsetof(struct reg, r_rip), - offsetof(struct reg, r_rflags), /* XXX 64-bit */ - offsetof(struct reg, r_cs), - offsetof(struct reg, r_ss), - offsetof(struct reg, r_ds), - offsetof(struct reg, r_es), - offsetof(struct reg, r_fs), - offsetof(struct reg, r_gs), -}; -#define AMD64_NUM_REGS (sizeof(amd64_regmap) / sizeof(amd64_regmap[0])) - -static const char amd64_breakpoint[] = { 0xCC }; -#define AMD64_BP_LEN 1 - -extern int debug_threads; - -static int -amd64_cannot_store_register(int regno) -{ - - return (regno >= AMD64_NUM_REGS); -} - -static int -amd64_cannot_fetch_register(int regno) -{ - - return (regno >= AMD64_NUM_REGS); -} - -static void -amd64_fill_gregset(void *buf) -{ - int i; - - for (i = 0; i < AMD64_NUM_REGS; i++) - collect_register(i, ((char *)buf) + amd64_regmap[i]); -} - -static void -amd64_store_gregset(const void *buf) -{ - int i; - - for (i = 0; i < AMD64_NUM_REGS; i++) - supply_register(i, ((char *)buf) + amd64_regmap[i]); -} - -static void -amd64_fill_fpregset(void *buf) -{ - - i387_cache_to_fsave(buf); -} - -static void -amd64_store_fpregset(const void *buf) -{ - - i387_fsave_to_cache(buf); -} - -static void -amd64_fill_fpxregset(void *buf) -{ - - i387_cache_to_fxsave(buf); -} - -static void -amd64_store_fpxregset(const void *buf) -{ - - i387_fxsave_to_cache(buf); -} - - -struct regset_info target_regsets[] = { - { - PT_GETREGS, - PT_SETREGS, - sizeof(struct reg), - GENERAL_REGS, - amd64_fill_gregset, - amd64_store_gregset, - }, -#ifdef HAVE_PTRACE_GETFPXREGS - { - PTRACE_GETFPXREGS, - PTRACE_SETFPXREGS, - sizeof(elf_fpxregset_t), - EXTENDED_REGS, - amd64_fill_fpxregset, - amd64_store_fpxregset, - }, -#endif - { - PT_GETFPREGS, - PT_SETFPREGS, - sizeof(struct fpreg), - FP_REGS, - amd64_fill_fpregset, - amd64_store_fpregset, - }, - { - 0, - 0, - -1, - -1, - NULL, - NULL, - } -}; - -static CORE_ADDR -amd64_get_pc(void) -{ - unsigned long pc; - - collect_register_by_name("rip", &pc); - - if (debug_threads) - fprintf(stderr, "stop pc (before any decrement) is %016lx\n", pc); - - return (pc); -} - -static void -amd64_set_pc(CORE_ADDR newpc) -{ - - if (debug_threads) - fprintf(stderr, "set pc to %016lx\n", (long)newpc); - supply_register_by_name("rip", &newpc); -} - -static int -amd64_breakpoint_at(CORE_ADDR pc) -{ - unsigned char c; - - read_inferior_memory(pc, &c, 1); - if (c == 0xCC) - return (1); - - return (0); -} - -struct fbsd_target_ops the_low_target = { - AMD64_NUM_REGS, - amd64_regmap, - amd64_cannot_fetch_register, - amd64_cannot_store_register, - amd64_get_pc, - amd64_set_pc, - amd64_breakpoint, - AMD64_BP_LEN, - NULL, - 1, - amd64_breakpoint_at, -}; diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-arm-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-arm-low.c deleted file mode 100644 index faea705f94f..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/fbsd-arm-low.c +++ /dev/null @@ -1,146 +0,0 @@ -/* FreeBSD/ARM specific low level interface, for the remote server for GDB. - Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "server.h" -#include "fbsd-low.h" - -#ifdef HAVE_SYS_REG_H -#include -#endif - -#include -#include - -#define arm_num_regs 26 - -static int arm_regmap[] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 36, 40, 44, 48, 52, 56, 60, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - 64 -}; - -static int -arm_cannot_store_register (int regno) -{ - return (regno >= arm_num_regs); -} - -static int -arm_cannot_fetch_register (int regno) -{ - return (regno >= arm_num_regs); -} - -extern int debug_threads; - -static CORE_ADDR -arm_get_pc () -{ - unsigned long pc; - collect_register_by_name ("pc", &pc); - if (debug_threads) - fprintf (stderr, "stop pc is %08lx\n", pc); - return pc; -} - -static void -arm_set_pc (CORE_ADDR pc) -{ - unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); -} - -/* Correct in either endianness. We do not support Thumb yet. */ -static const unsigned long arm_breakpoint = 0xef9f0001; -#define arm_breakpoint_len 4 - -static int -arm_breakpoint_at (CORE_ADDR where) -{ - unsigned long insn; - - (*the_target->read_memory) (where, (char *) &insn, 4); - if (insn == arm_breakpoint) - return 1; - - /* If necessary, recognize more trap instructions here. GDB only uses the - one. */ - return 0; -} - -/* We only place breakpoints in empty marker functions, and thread locking - is outside of the function. So rather than importing software single-step, - we can just run until exit. */ -static CORE_ADDR -arm_reinsert_addr () -{ - unsigned long pc; - collect_register_by_name ("lr", &pc); - return pc; -} - -static void -arm_fill_gregset (void *buf) -{ - int i; - - for (i = 0; i < arm_num_regs; i++) - if (arm_regmap[i] != -1) - collect_register (i, ((char *) buf) + arm_regmap[i]); - -} - -static void -arm_store_gregset (const void *buf) -{ - int i; - - for (i = 0; i < arm_num_regs; i++) - if (arm_regmap[i] != -1) - supply_register (i, ((char *) buf) + arm_regmap[i]); - -} - - -struct regset_info target_regsets[] = { - {PT_GETREGS, PT_SETREGS, sizeof (struct reg), - GENERAL_REGS, - arm_fill_gregset, arm_store_gregset }, - { 0, 0, -1, -1, NULL, NULL } -}; - -struct fbsd_target_ops the_low_target = { - arm_num_regs, - arm_regmap, - arm_cannot_fetch_register, - arm_cannot_store_register, - arm_get_pc, - arm_set_pc, - (const char *) &arm_breakpoint, - arm_breakpoint_len, - arm_reinsert_addr, - 0, - arm_breakpoint_at, -}; diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c deleted file mode 100644 index cd296f9b665..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c +++ /dev/null @@ -1,176 +0,0 @@ -/* GNU/Linux/i386 specific low level interface, for the remote server for GDB. - Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 - Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "server.h" -#include "fbsd-low.h" -#include "i387-fp.h" - -#ifdef HAVE_SYS_REG_H -#include -#else -#include -#endif - -/* This module only supports access to the general purpose registers. */ - -#define i386_num_regs 16 - -/* This stuff comes from i386-fbsd-nat.c. */ - -/* Mapping between the general-purpose registers in `struct user' - format and GDB's register array layout. */ -static int i386_regmap[] = -{ - tEAX * 4, tECX * 4, tEDX * 4, tEBX * 4, - tESP * 4, tEBP * 4, tESI * 4, tEDI * 4, - tEIP * 4, tEFLAGS * 4, tCS * 4, tSS * 4, - tDS * 4, tES * 4, tFS * 4, tGS * 4 -}; - -static int -i386_cannot_store_register (int regno) -{ - return (regno >= i386_num_regs); -} - -static int -i386_cannot_fetch_register (int regno) -{ - return (regno >= i386_num_regs); -} - - -#include -#include - -static void -i386_fill_gregset (void *buf) -{ - int i; - - for (i = 0; i < i386_num_regs; i++) - collect_register (i, ((char *) buf) + i386_regmap[i]); - -} - -static void -i386_store_gregset (const void *buf) -{ - int i; - - for (i = 0; i < i386_num_regs; i++) - supply_register (i, ((char *) buf) + i386_regmap[i]); - -} - -static void -i386_fill_fpregset (void *buf) -{ - i387_cache_to_fsave (buf); -} - -static void -i386_store_fpregset (const void *buf) -{ - i387_fsave_to_cache (buf); -} - -static void -i386_fill_fpxregset (void *buf) -{ - i387_cache_to_fxsave (buf); -} - -static void -i386_store_fpxregset (const void *buf) -{ - i387_fxsave_to_cache (buf); -} - - -struct regset_info target_regsets[] = { - { PT_GETREGS, PT_SETREGS, sizeof (struct reg), - GENERAL_REGS, - i386_fill_gregset, i386_store_gregset }, -#ifdef HAVE_PTRACE_GETFPXREGS - { PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, sizeof (elf_fpxregset_t), - EXTENDED_REGS, - i386_fill_fpxregset, i386_store_fpxregset }, -#endif - { PT_GETFPREGS, PT_SETFPREGS, sizeof (struct fpreg), - FP_REGS, - i386_fill_fpregset, i386_store_fpregset }, - { 0, 0, -1, -1, NULL, NULL } -}; - -static const char i386_breakpoint[] = { 0xCC }; -#define i386_breakpoint_len 1 - -extern int debug_threads; - -static CORE_ADDR -i386_get_pc () -{ - unsigned long pc; - - collect_register_by_name ("eip", &pc); - - if (debug_threads) - fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc); - return pc; -} - -static void -i386_set_pc (CORE_ADDR newpc) -{ - if (debug_threads) - fprintf (stderr, "set pc to %08lx\n", (long) newpc); - supply_register_by_name ("eip", &newpc); -} - -static int -i386_breakpoint_at (CORE_ADDR pc) -{ - unsigned char c; - - read_inferior_memory (pc, &c, 1); - if (c == 0xCC) - return 1; - - return 0; -} - -struct fbsd_target_ops the_low_target = { - i386_num_regs, - i386_regmap, - i386_cannot_fetch_register, - i386_cannot_store_register, - i386_get_pc, - i386_set_pc, - i386_breakpoint, - i386_breakpoint_len, - NULL, - 1, - i386_breakpoint_at, -}; diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-low.c deleted file mode 100644 index ab6ff2f3073..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/fbsd-low.c +++ /dev/null @@ -1,1265 +0,0 @@ -/* Low level interface to ptrace, for the remote server for GDB. - Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "server.h" -#include "fbsd-low.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* ``all_threads'' is keyed by the LWP ID - it should be the thread ID instead, - however. This requires changing the ID in place when we go from !using_threads - to using_threads, immediately. - - ``all_processes'' is keyed by the process ID - which on Linux is (presently) - the same as the LWP ID. */ - -struct inferior_list all_processes; - -/* FIXME this is a bit of a hack, and could be removed. */ -int stopping_threads; - -/* FIXME make into a target method? */ -int using_threads; - -static void fbsd_resume_one_process (struct inferior_list_entry *entry, - int step, int signal); -static void fbsd_resume (struct thread_resume *resume_info); -static void stop_all_processes (void); -static int fbsd_wait_for_event (struct thread_info *child); - -struct pending_signals -{ - int signal; - struct pending_signals *prev; -}; - -#define PTRACE_ARG3_TYPE caddr_t -#define PTRACE_XFER_TYPE int - -int debug_threads = 0; - -#define pid_of(proc) ((proc)->head.id) - -/* FIXME: Delete eventually. */ -#define inferior_pid (pid_of (get_thread_process (current_inferior))) - -/* This function should only be called if the process got a SIGTRAP. - The SIGTRAP could mean several things. - - On i386, where decr_pc_after_break is non-zero: - If we were single-stepping this process using PT_STEP, - we will get only the one SIGTRAP (even if the instruction we - stepped over was a breakpoint). The value of $eip will be the - next instruction. - If we continue the process using PTRACE_CONT, we will get a - SIGTRAP when we hit a breakpoint. The value of $eip will be - the instruction after the breakpoint (i.e. needs to be - decremented). If we report the SIGTRAP to GDB, we must also - report the undecremented PC. If we cancel the SIGTRAP, we - must resume at the decremented PC. - - (Presumably, not yet tested) On a non-decr_pc_after_break machine - with hardware or kernel single-step: - If we single-step over a breakpoint instruction, our PC will - point at the following instruction. If we continue and hit a - breakpoint instruction, our PC will point at the breakpoint - instruction. */ - -static CORE_ADDR -get_stop_pc (void) -{ - CORE_ADDR stop_pc = (*the_low_target.get_pc) (); - - if (get_thread_process (current_inferior)->stepping) - return stop_pc; - else - return stop_pc - the_low_target.decr_pc_after_break; -} - -static void * -add_process (int pid) -{ - struct process_info *process; - - process = (struct process_info *) malloc (sizeof (*process)); - memset (process, 0, sizeof (*process)); - - process->head.id = pid; - - /* Default to tid == lwpid == pid. */ - process->tid = pid; - process->lwpid = pid; - - add_inferior_to_list (&all_processes, &process->head); - - return process; -} - -/* Start an inferior process and returns its pid. - ALLARGS is a vector of program-name and args. */ - -static int -fbsd_create_inferior (char *program, char **allargs) -{ - void *new_process; - int pid; - - pid = vfork (); - if (pid < 0) - perror_with_name ("vfork"); - - if (pid == 0) - { - ptrace (PT_TRACE_ME, 0, 0, 0); - - setpgid (0, 0); - - execv (program, allargs); - - fprintf (stderr, "Cannot exec %s: %s.\n", program, - strerror (errno)); - fflush (stderr); - _exit (0177); - } - - new_process = add_process (pid); - add_thread (pid, new_process); - - return pid; -} - -/* Attach to an inferior process. */ - -void -fbsd_attach_lwp (int pid, int tid) -{ - struct process_info *new_process; - - if (ptrace (PT_ATTACH, pid, 0, 0) != 0) - { - fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid, - strerror (errno), errno); - fflush (stderr); - - /* If we fail to attach to an LWP, just return. */ - if (!using_threads) - _exit (0177); - return; - } - - new_process = (struct process_info *) add_process (pid); - add_thread (tid, new_process); - - /* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH - brings it to a halt. We should ignore that SIGSTOP and resume the process - (unless this is the first process, in which case the flag will be cleared - in fbsd_attach). - - On the other hand, if we are currently trying to stop all threads, we - should treat the new thread as if we had sent it a SIGSTOP. This works - because we are guaranteed that add_process added us to the end of the - list, and so the new thread has not yet reached wait_for_sigstop (but - will). */ - if (! stopping_threads) - new_process->stop_expected = 1; -} - -int -fbsd_attach (int pid) -{ - struct process_info *process; - - fbsd_attach_lwp (pid, pid); - - /* Don't ignore the initial SIGSTOP if we just attached to this process. */ - process = (struct process_info *) find_inferior_id (&all_processes, pid); - process->stop_expected = 0; - - return 0; -} - -/* Kill the inferior process. Make us have no inferior. */ - -static void -fbsd_kill_one_process (struct inferior_list_entry *entry) -{ - struct thread_info *thread = (struct thread_info *) entry; - struct process_info *process = get_thread_process (thread); - int wstat; - - do - { - ptrace (PT_KILL, pid_of (process), 0, 0); - - /* Make sure it died. The loop is most likely unnecessary. */ - wstat = fbsd_wait_for_event (thread); - } while (WIFSTOPPED (wstat)); -} - -static void -fbsd_kill (void) -{ - for_each_inferior (&all_threads, fbsd_kill_one_process); -} - -static void -fbsd_detach_one_process (struct inferior_list_entry *entry) -{ - struct thread_info *thread = (struct thread_info *) entry; - struct process_info *process = get_thread_process (thread); - - ptrace (PT_DETACH, pid_of (process), 0, 0); -} - -static void -fbsd_detach (void) -{ - for_each_inferior (&all_threads, fbsd_detach_one_process); -} - -/* Return nonzero if the given thread is still alive. */ -static int -fbsd_thread_alive (int tid) -{ - if (find_inferior_id (&all_threads, tid) != NULL) - return 1; - else - return 0; -} - -/* Return nonzero if this process stopped at a breakpoint which - no longer appears to be inserted. Also adjust the PC - appropriately to resume where the breakpoint used to be. */ -static int -check_removed_breakpoint (struct process_info *event_child) -{ - CORE_ADDR stop_pc; - struct thread_info *saved_inferior; - - if (event_child->pending_is_breakpoint == 0) - return 0; - - if (debug_threads) - fprintf (stderr, "Checking for breakpoint.\n"); - - saved_inferior = current_inferior; - current_inferior = get_process_thread (event_child); - - stop_pc = get_stop_pc (); - - /* If the PC has changed since we stopped, then we shouldn't do - anything. This happens if, for instance, GDB handled the - decr_pc_after_break subtraction itself. */ - if (stop_pc != event_child->pending_stop_pc) - { - if (debug_threads) - fprintf (stderr, "Ignoring, PC was changed.\n"); - - event_child->pending_is_breakpoint = 0; - current_inferior = saved_inferior; - return 0; - } - - /* If the breakpoint is still there, we will report hitting it. */ - if ((*the_low_target.breakpoint_at) (stop_pc)) - { - if (debug_threads) - fprintf (stderr, "Ignoring, breakpoint is still present.\n"); - current_inferior = saved_inferior; - return 0; - } - - if (debug_threads) - fprintf (stderr, "Removed breakpoint.\n"); - - /* For decr_pc_after_break targets, here is where we perform the - decrement. We go immediately from this function to resuming, - and can not safely call get_stop_pc () again. */ - if (the_low_target.set_pc != NULL) - (*the_low_target.set_pc) (stop_pc); - - /* We consumed the pending SIGTRAP. */ - event_child->pending_is_breakpoint = 0; - event_child->status_pending_p = 0; - event_child->status_pending = 0; - - current_inferior = saved_inferior; - return 1; -} - -/* Return 1 if this process has an interesting status pending. This function - may silently resume an inferior process. */ -static int -status_pending_p (struct inferior_list_entry *entry, void *dummy) -{ - struct process_info *process = (struct process_info *) entry; - - if (process->status_pending_p) - if (check_removed_breakpoint (process)) - { - /* This thread was stopped at a breakpoint, and the breakpoint - is now gone. We were told to continue (or step...) all threads, - so GDB isn't trying to single-step past this breakpoint. - So instead of reporting the old SIGTRAP, pretend we got to - the breakpoint just after it was removed instead of just - before; resume the process. */ - fbsd_resume_one_process (&process->head, 0, 0); - return 0; - } - - return process->status_pending_p; -} - -static void -fbsd_wait_for_process (struct process_info **childp, int *wstatp) -{ - int ret; - int to_wait_for = -1; - - if (*childp != NULL) - to_wait_for = (*childp)->lwpid; - - while (1) - { - ret = waitpid (to_wait_for, wstatp, WNOHANG); - - if (ret == -1) - { - if (errno != ECHILD) - perror_with_name ("waitpid"); - } - else if (ret > 0) - break; - - usleep (1000); - } - - if (debug_threads - && (!WIFSTOPPED (*wstatp) - || (WSTOPSIG (*wstatp) != 32 - && WSTOPSIG (*wstatp) != 33))) - fprintf (stderr, "Got an event from %d (%x)\n", ret, *wstatp); - - if (to_wait_for == -1) - *childp = (struct process_info *) find_inferior_id (&all_processes, ret); - - (*childp)->stopped = 1; - (*childp)->pending_is_breakpoint = 0; - - if (debug_threads - && WIFSTOPPED (*wstatp)) - { - current_inferior = (struct thread_info *) - find_inferior_id (&all_threads, (*childp)->tid); - /* For testing only; i386_stop_pc prints out a diagnostic. */ - if (the_low_target.get_pc != NULL) - get_stop_pc (); - } -} - -static int -fbsd_wait_for_event (struct thread_info *child) -{ - CORE_ADDR stop_pc; - struct process_info *event_child; - int wstat; - - /* Check for a process with a pending status. */ - /* It is possible that the user changed the pending task's registers since - it stopped. We correctly handle the change of PC if we hit a breakpoint - (in check_removed_breakpoint); signals should be reported anyway. */ - if (child == NULL) - { - event_child = (struct process_info *) - find_inferior (&all_processes, status_pending_p, NULL); - if (debug_threads && event_child) - fprintf (stderr, "Got a pending child %d\n", event_child->lwpid); - } - else - { - event_child = get_thread_process (child); - if (event_child->status_pending_p - && check_removed_breakpoint (event_child)) - event_child = NULL; - } - - if (event_child != NULL) - { - if (event_child->status_pending_p) - { - if (debug_threads) - fprintf (stderr, "Got an event from pending child %d (%04x)\n", - event_child->lwpid, event_child->status_pending); - wstat = event_child->status_pending; - event_child->status_pending_p = 0; - event_child->status_pending = 0; - current_inferior = get_process_thread (event_child); - return wstat; - } - } - - /* We only enter this loop if no process has a pending wait status. Thus - any action taken in response to a wait status inside this loop is - responding as soon as we detect the status, not after any pending - events. */ - while (1) - { - if (child == NULL) - event_child = NULL; - else - event_child = get_thread_process (child); - - fbsd_wait_for_process (&event_child, &wstat); - - if (event_child == NULL) - error ("event from unknown child"); - - current_inferior = (struct thread_info *) - find_inferior_id (&all_threads, event_child->tid); - - if (using_threads) - { - /* Check for thread exit. */ - if (! WIFSTOPPED (wstat)) - { - if (debug_threads) - fprintf (stderr, "Thread %d (LWP %d) exiting\n", - event_child->tid, event_child->head.id); - - /* If the last thread is exiting, just return. */ - if (all_threads.head == all_threads.tail) - return wstat; - - dead_thread_notify (event_child->tid); - - remove_inferior (&all_processes, &event_child->head); - free (event_child); - remove_thread (current_inferior); - current_inferior = (struct thread_info *) all_threads.head; - - /* If we were waiting for this particular child to do something... - well, it did something. */ - if (child != NULL) - return wstat; - - /* Wait for a more interesting event. */ - continue; - } - - if (WIFSTOPPED (wstat) - && WSTOPSIG (wstat) == SIGSTOP - && event_child->stop_expected) - { - if (debug_threads) - fprintf (stderr, "Expected stop.\n"); - event_child->stop_expected = 0; - fbsd_resume_one_process (&event_child->head, - event_child->stepping, 0); - continue; - } - - /* FIXME drow/2002-06-09: Get signal numbers from the inferior's - thread library? */ - if (WIFSTOPPED (wstat)) - { - if (debug_threads) - fprintf (stderr, "Ignored signal %d for %d (LWP %d).\n", - WSTOPSIG (wstat), event_child->tid, - event_child->head.id); - fbsd_resume_one_process (&event_child->head, - event_child->stepping, - WSTOPSIG (wstat)); - continue; - } - } - - /* If this event was not handled above, and is not a SIGTRAP, report - it. */ - if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGTRAP) - return wstat; - - /* If this target does not support breakpoints, we simply report the - SIGTRAP; it's of no concern to us. */ - if (the_low_target.get_pc == NULL) - return wstat; - - stop_pc = get_stop_pc (); - - /* bp_reinsert will only be set if we were single-stepping. - Notice that we will resume the process after hitting - a gdbserver breakpoint; single-stepping to/over one - is not supported (yet). */ - if (event_child->bp_reinsert != 0) - { - if (debug_threads) - fprintf (stderr, "Reinserted breakpoint.\n"); - reinsert_breakpoint (event_child->bp_reinsert); - event_child->bp_reinsert = 0; - - /* Clear the single-stepping flag and SIGTRAP as we resume. */ - fbsd_resume_one_process (&event_child->head, 0, 0); - continue; - } - - if (debug_threads) - fprintf (stderr, "Hit a (non-reinsert) breakpoint.\n"); - - if (check_breakpoints (stop_pc) != 0) - { - /* We hit one of our own breakpoints. We mark it as a pending - breakpoint, so that check_removed_breakpoint () will do the PC - adjustment for us at the appropriate time. */ - event_child->pending_is_breakpoint = 1; - event_child->pending_stop_pc = stop_pc; - - /* Now we need to put the breakpoint back. We continue in the event - loop instead of simply replacing the breakpoint right away, - in order to not lose signals sent to the thread that hit the - breakpoint. Unfortunately this increases the window where another - thread could sneak past the removed breakpoint. For the current - use of server-side breakpoints (thread creation) this is - acceptable; but it needs to be considered before this breakpoint - mechanism can be used in more general ways. For some breakpoints - it may be necessary to stop all other threads, but that should - be avoided where possible. - - If breakpoint_reinsert_addr is NULL, that means that we can - use PT_STEP on this platform. Uninsert the breakpoint, - mark it for reinsertion, and single-step. - - Otherwise, call the target function to figure out where we need - our temporary breakpoint, create it, and continue executing this - process. */ - if (the_low_target.breakpoint_reinsert_addr == NULL) - { - event_child->bp_reinsert = stop_pc; - uninsert_breakpoint (stop_pc); - fbsd_resume_one_process (&event_child->head, 1, 0); - } - else - { - reinsert_breakpoint_by_bp - (stop_pc, (*the_low_target.breakpoint_reinsert_addr) ()); - fbsd_resume_one_process (&event_child->head, 0, 0); - } - - continue; - } - - /* If we were single-stepping, we definitely want to report the - SIGTRAP. The single-step operation has completed, so also - clear the stepping flag; in general this does not matter, - because the SIGTRAP will be reported to the client, which - will give us a new action for this thread, but clear it for - consistency anyway. It's safe to clear the stepping flag - because the only consumer of get_stop_pc () after this point - is check_removed_breakpoint, and pending_is_breakpoint is not - set. It might be wiser to use a step_completed flag instead. */ - if (event_child->stepping) - { - event_child->stepping = 0; - return wstat; - } - - /* A SIGTRAP that we can't explain. It may have been a breakpoint. - Check if it is a breakpoint, and if so mark the process information - accordingly. This will handle both the necessary fiddling with the - PC on decr_pc_after_break targets and suppressing extra threads - hitting a breakpoint if two hit it at once and then GDB removes it - after the first is reported. Arguably it would be better to report - multiple threads hitting breakpoints simultaneously, but the current - remote protocol does not allow this. */ - if ((*the_low_target.breakpoint_at) (stop_pc)) - { - event_child->pending_is_breakpoint = 1; - event_child->pending_stop_pc = stop_pc; - } - - return wstat; - } - - /* NOTREACHED */ - return 0; -} - -/* Wait for process, returns status. */ - -static unsigned char -fbsd_wait (char *status) -{ - int w; - struct thread_info *child = NULL; - -retry: - /* If we were only supposed to resume one thread, only wait for - that thread - if it's still alive. If it died, however - which - can happen if we're coming from the thread death case below - - then we need to make sure we restart the other threads. We could - pick a thread at random or restart all; restarting all is less - arbitrary. */ - if (cont_thread > 0) - { - child = (struct thread_info *) find_inferior_id (&all_threads, - cont_thread); - - /* No stepping, no signal - unless one is pending already, of course. */ - if (child == NULL) - { - struct thread_resume resume_info; - resume_info.thread = -1; - resume_info.step = resume_info.sig = resume_info.leave_stopped = 0; - fbsd_resume (&resume_info); - } - } - - enable_async_io (); - unblock_async_io (); - w = fbsd_wait_for_event (child); - stop_all_processes (); - disable_async_io (); - - /* If we are waiting for a particular child, and it exited, - fbsd_wait_for_event will return its exit status. Similarly if - the last child exited. If this is not the last child, however, - do not report it as exited until there is a 'thread exited' response - available in the remote protocol. Instead, just wait for another event. - This should be safe, because if the thread crashed we will already - have reported the termination signal to GDB; that should stop any - in-progress stepping operations, etc. - - Report the exit status of the last thread to exit. This matches - LinuxThreads' behavior. */ - - if (all_threads.head == all_threads.tail) - { - if (WIFEXITED (w)) - { - fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w)); - *status = 'W'; - clear_inferiors (); - free (all_processes.head); - all_processes.head = all_processes.tail = NULL; - return ((unsigned char) WEXITSTATUS (w)); - } - else if (!WIFSTOPPED (w)) - { - fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w)); - *status = 'X'; - clear_inferiors (); - free (all_processes.head); - all_processes.head = all_processes.tail = NULL; - return ((unsigned char) WTERMSIG (w)); - } - } - else - { - if (!WIFSTOPPED (w)) - goto retry; - } - - *status = 'T'; - return ((unsigned char) WSTOPSIG (w)); -} - -static void -send_sigstop (struct inferior_list_entry *entry) -{ - struct process_info *process = (struct process_info *) entry; - - if (process->stopped) - return; - - /* If we already have a pending stop signal for this process, don't - send another. */ - if (process->stop_expected) - { - process->stop_expected = 0; - return; - } - - if (debug_threads) - fprintf (stderr, "Sending sigstop to process %d\n", process->head.id); - - kill (process->head.id, SIGSTOP); - process->sigstop_sent = 1; -} - -static void -wait_for_sigstop (struct inferior_list_entry *entry) -{ - struct process_info *process = (struct process_info *) entry; - struct thread_info *saved_inferior, *thread; - int wstat, saved_tid; - - if (process->stopped) - return; - - saved_inferior = current_inferior; - saved_tid = ((struct inferior_list_entry *) saved_inferior)->id; - thread = (struct thread_info *) find_inferior_id (&all_threads, - process->tid); - wstat = fbsd_wait_for_event (thread); - - /* If we stopped with a non-SIGSTOP signal, save it for later - and record the pending SIGSTOP. If the process exited, just - return. */ - if (WIFSTOPPED (wstat) - && WSTOPSIG (wstat) != SIGSTOP) - { - if (debug_threads) - fprintf (stderr, "Stopped with non-sigstop signal\n"); - process->status_pending_p = 1; - process->status_pending = wstat; - process->stop_expected = 1; - } - - if (fbsd_thread_alive (saved_tid)) - current_inferior = saved_inferior; - else - { - if (debug_threads) - fprintf (stderr, "Previously current thread died.\n"); - - /* Set a valid thread as current. */ - set_desired_inferior (0); - } -} - -static void -stop_all_processes (void) -{ - stopping_threads = 1; - for_each_inferior (&all_processes, send_sigstop); - for_each_inferior (&all_processes, wait_for_sigstop); - stopping_threads = 0; -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -static void -fbsd_resume_one_process (struct inferior_list_entry *entry, - int step, int signal) -{ - struct process_info *process = (struct process_info *) entry; - struct thread_info *saved_inferior; - - if (process->stopped == 0) - return; - - /* If we have pending signals or status, and a new signal, enqueue the - signal. Also enqueue the signal if we are waiting to reinsert a - breakpoint; it will be picked up again below. */ - if (signal != 0 - && (process->status_pending_p || process->pending_signals != NULL - || process->bp_reinsert != 0)) - { - struct pending_signals *p_sig; - p_sig = malloc (sizeof (*p_sig)); - p_sig->prev = process->pending_signals; - p_sig->signal = signal; - process->pending_signals = p_sig; - } - - if (process->status_pending_p && !check_removed_breakpoint (process)) - return; - - saved_inferior = current_inferior; - current_inferior = get_process_thread (process); - - if (debug_threads) - fprintf (stderr, "Resuming process %d (%s, signal %d, stop %s)\n", inferior_pid, - step ? "step" : "continue", signal, - process->stop_expected ? "expected" : "not expected"); - - /* This bit needs some thinking about. If we get a signal that - we must report while a single-step reinsert is still pending, - we often end up resuming the thread. It might be better to - (ew) allow a stack of pending events; then we could be sure that - the reinsert happened right away and not lose any signals. - - Making this stack would also shrink the window in which breakpoints are - uninserted (see comment in fbsd_wait_for_process) but not enough for - complete correctness, so it won't solve that problem. It may be - worthwhile just to solve this one, however. */ - if (process->bp_reinsert != 0) - { - if (debug_threads) - fprintf (stderr, " pending reinsert at %08lx", (long)process->bp_reinsert); - if (step == 0) - fprintf (stderr, "BAD - reinserting but not stepping.\n"); - step = 1; - - /* Postpone any pending signal. It was enqueued above. */ - signal = 0; - } - - check_removed_breakpoint (process); - - if (debug_threads && the_low_target.get_pc != NULL) - { - fprintf (stderr, " "); - (long) (*the_low_target.get_pc) (); - } - - /* If we have pending signals, consume one unless we are trying to reinsert - a breakpoint. */ - if (process->pending_signals != NULL && process->bp_reinsert == 0) - { - struct pending_signals **p_sig; - - p_sig = &process->pending_signals; - while ((*p_sig)->prev != NULL) - p_sig = &(*p_sig)->prev; - - signal = (*p_sig)->signal; - free (*p_sig); - *p_sig = NULL; - } - - regcache_invalidate_one ((struct inferior_list_entry *) - get_process_thread (process)); - errno = 0; - process->stopped = 0; - process->stepping = step; - ptrace (step ? PT_STEP : PT_CONTINUE, process->lwpid, (PTRACE_ARG3_TYPE) 1, signal); - - current_inferior = saved_inferior; - if (errno) - perror_with_name ("ptrace"); -} - -static struct thread_resume *resume_ptr; - -/* This function is called once per thread. We look up the thread - in RESUME_PTR, and mark the thread with a pointer to the appropriate - resume request. - - This algorithm is O(threads * resume elements), but resume elements - is small (and will remain small at least until GDB supports thread - suspension). */ -static void -fbsd_set_resume_request (struct inferior_list_entry *entry) -{ - struct process_info *process; - struct thread_info *thread; - int ndx; - - thread = (struct thread_info *) entry; - process = get_thread_process (thread); - - ndx = 0; - while (resume_ptr[ndx].thread != -1 && resume_ptr[ndx].thread != entry->id) - ndx++; - - process->resume = &resume_ptr[ndx]; -} - -/* This function is called once per thread. We check the thread's resume - request, which will tell us whether to resume, step, or leave the thread - stopped; and what signal, if any, it should be sent. For threads which - we aren't explicitly told otherwise, we preserve the stepping flag; this - is used for stepping over gdbserver-placed breakpoints. */ - -static void -fbsd_continue_one_thread (struct inferior_list_entry *entry) -{ - struct process_info *process; - struct thread_info *thread; - int step; - - thread = (struct thread_info *) entry; - process = get_thread_process (thread); - - if (process->resume->leave_stopped) - return; - - if (process->resume->thread == -1) - step = process->stepping || process->resume->step; - else - step = process->resume->step; - - fbsd_resume_one_process (&process->head, step, process->resume->sig); - - process->resume = NULL; -} - -/* This function is called once per thread. We check the thread's resume - request, which will tell us whether to resume, step, or leave the thread - stopped; and what signal, if any, it should be sent. We queue any needed - signals, since we won't actually resume. We already have a pending event - to report, so we don't need to preserve any step requests; they should - be re-issued if necessary. */ - -static void -fbsd_queue_one_thread (struct inferior_list_entry *entry) -{ - struct process_info *process; - struct thread_info *thread; - - thread = (struct thread_info *) entry; - process = get_thread_process (thread); - - if (process->resume->leave_stopped) - return; - - /* If we have a new signal, enqueue the signal. */ - if (process->resume->sig != 0) - { - struct pending_signals *p_sig; - p_sig = malloc (sizeof (*p_sig)); - p_sig->prev = process->pending_signals; - p_sig->signal = process->resume->sig; - process->pending_signals = p_sig; - } - - process->resume = NULL; -} - -/* Set DUMMY if this process has an interesting status pending. */ -static int -resume_status_pending_p (struct inferior_list_entry *entry, void *flag_p) -{ - struct process_info *process = (struct process_info *) entry; - - /* Processes which will not be resumed are not interesting, because - we might not wait for them next time through fbsd_wait. */ - if (process->resume->leave_stopped) - return 0; - - /* If this thread has a removed breakpoint, we won't have any - events to report later, so check now. check_removed_breakpoint - may clear status_pending_p. We avoid calling check_removed_breakpoint - for any thread that we are not otherwise going to resume - this - lets us preserve stopped status when two threads hit a breakpoint. - GDB removes the breakpoint to single-step a particular thread - past it, then re-inserts it and resumes all threads. We want - to report the second thread without resuming it in the interim. */ - if (process->status_pending_p) - check_removed_breakpoint (process); - - if (process->status_pending_p) - * (int *) flag_p = 1; - - return 0; -} - -static void -fbsd_resume (struct thread_resume *resume_info) -{ - int pending_flag; - - /* Yes, the use of a global here is rather ugly. */ - resume_ptr = resume_info; - - for_each_inferior (&all_threads, fbsd_set_resume_request); - - /* If there is a thread which would otherwise be resumed, which - has a pending status, then don't resume any threads - we can just - report the pending status. Make sure to queue any signals - that would otherwise be sent. */ - pending_flag = 0; - find_inferior (&all_processes, resume_status_pending_p, &pending_flag); - - if (debug_threads) - { - if (pending_flag) - fprintf (stderr, "Not resuming, pending status\n"); - else - fprintf (stderr, "Resuming, no pending status\n"); - } - - if (pending_flag) - for_each_inferior (&all_threads, fbsd_queue_one_thread); - else - { - block_async_io (); - enable_async_io (); - for_each_inferior (&all_threads, fbsd_continue_one_thread); - } -} - - -static int -regsets_fetch_inferior_registers () -{ - struct regset_info *regset; - - regset = target_regsets; - - while (regset->size >= 0) - { - void *buf; - int res; - - if (regset->size == 0) - { - regset ++; - continue; - } - - buf = malloc (regset->size); - res = ptrace (regset->get_request, inferior_pid, (PTRACE_ARG3_TYPE) buf, 0); - if (res < 0) - { - char s[256]; - sprintf (s, "ptrace(regsets_fetch_inferior_registers) PID=%d", - inferior_pid); - perror (s); - } - regset->store_function (buf); - regset ++; - } - return 0; -} - -static int -regsets_store_inferior_registers () -{ - struct regset_info *regset; - - regset = target_regsets; - - while (regset->size >= 0) - { - void *buf; - int res; - - if (regset->size == 0) - { - regset ++; - continue; - } - - buf = malloc (regset->size); - regset->fill_function (buf); - res = ptrace (regset->set_request, inferior_pid, (PTRACE_ARG3_TYPE) buf, 0); - if (res < 0) - { - perror ("Warning: ptrace(regsets_store_inferior_registers)"); - } - regset ++; - free (buf); - } - return 0; -} - -void -fbsd_fetch_registers (int regno) -{ - regsets_fetch_inferior_registers (); -} - -void -fbsd_store_registers (int regno) -{ - regsets_store_inferior_registers (); -} - - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. */ - -static int -fbsd_read_memory (CORE_ADDR memaddr, char *myaddr, int len) -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) - / sizeof (PTRACE_XFER_TYPE); - /* Allocate buffer of that many longwords. */ - register PTRACE_XFER_TYPE *buffer - = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE)); - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) - { - errno = 0; - buffer[i] = ptrace (PT_READ_D, inferior_pid, (PTRACE_ARG3_TYPE) (intptr_t)addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), len); - - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -static int -fbsd_write_memory (CORE_ADDR memaddr, const char *myaddr, int len) -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) / sizeof (PTRACE_XFER_TYPE); - /* Allocate buffer of that many longwords. */ - register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE)); - extern int errno; - - if (debug_threads) - { - fprintf (stderr, "Writing %02x to %08lx\n", (unsigned)myaddr[0], (long)memaddr); - } - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - buffer[0] = ptrace (PT_READ_D, inferior_pid, - (PTRACE_ARG3_TYPE) (intptr_t)addr, 0); - - if (count > 1) - { - buffer[count - 1] - = ptrace (PT_READ_D, inferior_pid, - (PTRACE_ARG3_TYPE) (intptr_t) (addr + (count - 1) - * sizeof (PTRACE_XFER_TYPE)), - 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), myaddr, len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) - { - errno = 0; - ptrace (PT_WRITE_D, inferior_pid, (PTRACE_ARG3_TYPE) (intptr_t)addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -static void -fbsd_look_up_symbols (void) -{ -#ifdef USE_THREAD_DB - if (using_threads) - return; - - using_threads = thread_db_init (); -#endif -} - -static void -fbsd_send_signal (int signum) -{ - extern int signal_pid; - - if (cont_thread > 0) - { - struct process_info *process; - - process = get_thread_process (current_inferior); - kill (process->lwpid, signum); - } - else - kill (signal_pid, signum); -} - -/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET - to debugger memory starting at MYADDR. */ - -static int -fbsd_read_auxv (CORE_ADDR offset, char *myaddr, unsigned int len) -{ - char filename[PATH_MAX]; - int fd, n; - - snprintf (filename, sizeof filename, "/proc/%d/auxv", inferior_pid); - - fd = open (filename, O_RDONLY); - if (fd < 0) - return -1; - - if (offset != (CORE_ADDR) 0 - && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset) - n = -1; - else - n = read (fd, myaddr, len); - - close (fd); - - return n; -} - - -static struct target_ops fbsd_target_ops = { - fbsd_create_inferior, - fbsd_attach, - fbsd_kill, - fbsd_detach, - fbsd_thread_alive, - fbsd_resume, - fbsd_wait, - fbsd_fetch_registers, - fbsd_store_registers, - fbsd_read_memory, - fbsd_write_memory, - fbsd_look_up_symbols, - fbsd_send_signal, - fbsd_read_auxv, -}; - -static void -fbsd_init_signals () -{ -} - -void -initialize_low (void) -{ - using_threads = 0; - set_target_ops (&fbsd_target_ops); - set_breakpoint_data (the_low_target.breakpoint, - the_low_target.breakpoint_len); - init_registers (); - fbsd_init_signals (); -} diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-low.h b/gnu/usr.bin/gdb/gdbserver/fbsd-low.h deleted file mode 100644 index 310368c9b2c..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/fbsd-low.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Internal interfaces for the GNU/Linux specific target code for gdbserver. - Copyright 2002, 2004 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - * $FreeBSD$ - */ - -typedef void (*regset_fill_func) (void *); -typedef void (*regset_store_func) (const void *); -enum regset_type { - GENERAL_REGS, - FP_REGS, - EXTENDED_REGS, -}; - -struct regset_info -{ - int get_request, set_request; - int size; - enum regset_type type; - regset_fill_func fill_function; - regset_store_func store_function; -}; -extern struct regset_info target_regsets[]; - -struct fbsd_target_ops -{ - int num_regs; - int *regmap; - int (*cannot_fetch_register) (int); - - /* Returns 0 if we can store the register, 1 if we can not - store the register, and 2 if failure to store the register - is acceptable. */ - int (*cannot_store_register) (int); - CORE_ADDR (*get_pc) (void); - void (*set_pc) (CORE_ADDR newpc); - const char *breakpoint; - int breakpoint_len; - CORE_ADDR (*breakpoint_reinsert_addr) (void); - - - int decr_pc_after_break; - int (*breakpoint_at) (CORE_ADDR pc); -}; - -extern struct fbsd_target_ops the_low_target; - -#define get_process(inf) ((struct process_info *)(inf)) -#define get_thread_process(thr) (get_process (inferior_target_data (thr))) -#define get_process_thread(proc) ((struct thread_info *) \ - find_inferior_id (&all_threads, \ - get_process (proc)->tid)) - -struct process_info -{ - struct inferior_list_entry head; - int thread_known; - int lwpid; - int tid; - - /* If this flag is set, the next SIGSTOP will be ignored (the process will - be immediately resumed). */ - int stop_expected; - - /* If this flag is set, the process is known to be stopped right now (stop - event already received in a wait()). */ - int stopped; - - /* If this flag is set, we have sent a SIGSTOP to this process and are - waiting for it to stop. */ - int sigstop_sent; - - /* If this flag is set, STATUS_PENDING is a waitstatus that has not yet - been reported. */ - int status_pending_p; - int status_pending; - - /* If this flag is set, the pending status is a (GDB-placed) breakpoint. */ - int pending_is_breakpoint; - CORE_ADDR pending_stop_pc; - - /* If this is non-zero, it is a breakpoint to be reinserted at our next - stop (SIGTRAP stops only). */ - CORE_ADDR bp_reinsert; - - /* If this flag is set, the last continue operation on this process - was a single-step. */ - int stepping; - - /* If this is non-zero, it points to a chain of signals which need to - be delivered to this process. */ - struct pending_signals *pending_signals; - - /* A link used when resuming. It is initialized from the resume request, - and then processed and cleared in fbsd_resume_one_process. */ - - struct thread_resume *resume; -}; - -extern struct inferior_list all_processes; - -void fbsd_attach_lwp (int pid, int tid); - -int thread_db_init (void); diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-powerpc-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-powerpc-low.c deleted file mode 100644 index 35f7ac65092..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/fbsd-powerpc-low.c +++ /dev/null @@ -1,156 +0,0 @@ -/* FreeBSD/PowerPC specific low level interface, for the remote server for - GDB. - Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 - Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "server.h" -#include "fbsd-low.h" - -#include -#include - -#define ppc_num_regs 71 - -/* Currently, don't check/send MQ. */ -static int ppc_regmap[] = - { 0, 4, 8, 12, 16, 20, 24, 28, - 32, 36, 40, 44, 48, 52, 56, 60, - 64, 68, 72, 76, 80, 84, 88, 92, - 96, 100, 104, 108, 112, 116, 120, 124, -#if 0 - /* - * XXX on FreeBSD the gdbserver for PowerPC was only tested with FPU-less - * cores i.e. e500. Let's leave the original FPR references around in case - * someone picks up and brings support for AIM-like FPU machines. - */ - PT_FPR0*4, PT_FPR0*4 + 8, PT_FPR0*4+16, PT_FPR0*4+24, - PT_FPR0*4+32, PT_FPR0*4+40, PT_FPR0*4+48, PT_FPR0*4+56, - PT_FPR0*4+64, PT_FPR0*4+72, PT_FPR0*4+80, PT_FPR0*4+88, - PT_FPR0*4+96, PT_FPR0*4+104, PT_FPR0*4+112, PT_FPR0*4+120, - PT_FPR0*4+128, PT_FPR0*4+136, PT_FPR0*4+144, PT_FPR0*4+152, - PT_FPR0*4+160, PT_FPR0*4+168, PT_FPR0*4+176, PT_FPR0*4+184, - PT_FPR0*4+192, PT_FPR0*4+200, PT_FPR0*4+208, PT_FPR0*4+216, - PT_FPR0*4+224, PT_FPR0*4+232, PT_FPR0*4+240, PT_FPR0*4+248, -#endif - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - 144, -1, 132, 128, 140, 136, -1 - }; - -static int -ppc_cannot_store_register (int regno) -{ - /* Some kernels do not allow us to store fpscr. */ - if (regno == find_regno ("fpscr")) - return 2; - - return 0; -} - -static int -ppc_cannot_fetch_register (int regno) -{ - return 0; -} - -static CORE_ADDR -ppc_get_pc (void) -{ - unsigned long pc; - - collect_register_by_name ("pc", &pc); - return (CORE_ADDR) pc; -} - -static void -ppc_set_pc (CORE_ADDR pc) -{ - unsigned long newpc = pc; - - supply_register_by_name ("pc", &newpc); -} - -/* Correct in either endianness. Note that this file is - for PowerPC only, not PowerPC64. - This instruction is "twge r2, r2", which GDB uses as a software - breakpoint. */ -static const unsigned long ppc_breakpoint = 0x7d821008; -#define ppc_breakpoint_len 4 - -static int -ppc_breakpoint_at (CORE_ADDR where) -{ - unsigned long insn; - - (*the_target->read_memory) (where, (char *) &insn, 4); - if (insn == ppc_breakpoint) - return 1; - /* If necessary, recognize more trap instructions here. GDB only uses the - one. */ - return 0; -} - -static void -ppc_fill_gregset (void *buf) -{ - int i; - - for (i = 0; i < ppc_num_regs; i++) - if (ppc_regmap[i] != -1) - collect_register (i, ((char *) buf) + ppc_regmap[i]); - -} - -static void -ppc_store_gregset (const void *buf) -{ - int i; - - for (i = 0; i < ppc_num_regs; i++) - if (ppc_regmap[i] != -1) - supply_register (i, ((char *) buf) + ppc_regmap[i]); - -} - -struct regset_info target_regsets[] = { - { PT_GETREGS, PT_SETREGS, sizeof (struct reg), - GENERAL_REGS, - ppc_fill_gregset, ppc_store_gregset }, - { 0, 0, -1, -1, NULL, NULL } -}; - -struct fbsd_target_ops the_low_target = { - ppc_num_regs, - ppc_regmap, - ppc_cannot_fetch_register, - ppc_cannot_store_register, - ppc_get_pc, - ppc_set_pc, - (const char *) &ppc_breakpoint, - ppc_breakpoint_len, - NULL, - 0, - ppc_breakpoint_at, -}; diff --git a/gnu/usr.bin/gdb/gdbserver/reg-amd64.c b/gnu/usr.bin/gdb/gdbserver/reg-amd64.c deleted file mode 100644 index 7b0534f0d56..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/reg-amd64.c +++ /dev/null @@ -1,99 +0,0 @@ -/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ - -/* A register protocol for GDB, the GNU debugger. - Copyright 2001, 2002 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-x86-64.dat''. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "regdef.h" -#include "regcache.h" - -struct reg regs_x86_64[] = { - { "rax", 0, 64 }, - { "rbx", 64, 64 }, - { "rcx", 128, 64 }, - { "rdx", 192, 64 }, - { "rsi", 256, 64 }, - { "rdi", 320, 64 }, - { "rbp", 384, 64 }, - { "rsp", 448, 64 }, - { "r8", 512, 64 }, - { "r9", 576, 64 }, - { "r10", 640, 64 }, - { "r11", 704, 64 }, - { "r12", 768, 64 }, - { "r13", 832, 64 }, - { "r14", 896, 64 }, - { "r15", 960, 64 }, - { "rip", 1024, 64 }, - { "eflags", 1088, 32 }, - { "cs", 1120, 32 }, - { "ss", 1152, 32 }, - { "ds", 1184, 32 }, - { "es", 1216, 32 }, - { "fs", 1248, 32 }, - { "gs", 1280, 32 }, - { "st0", 1312, 80 }, - { "st1", 1392, 80 }, - { "st2", 1472, 80 }, - { "st3", 1552, 80 }, - { "st4", 1632, 80 }, - { "st5", 1712, 80 }, - { "st6", 1792, 80 }, - { "st7", 1872, 80 }, - { "fctrl", 1952, 32 }, - { "fstat", 1984, 32 }, - { "ftag", 2016, 32 }, - { "fiseg", 2048, 32 }, - { "fioff", 2080, 32 }, - { "foseg", 2112, 32 }, - { "fooff", 2144, 32 }, - { "fop", 2176, 32 }, - { "xmm0", 2208, 128 }, - { "xmm1", 2336, 128 }, - { "xmm2", 2464, 128 }, - { "xmm3", 2592, 128 }, - { "xmm4", 2720, 128 }, - { "xmm5", 2848, 128 }, - { "xmm6", 2976, 128 }, - { "xmm7", 3104, 128 }, - { "xmm8", 3232, 128 }, - { "xmm9", 3360, 128 }, - { "xmm10", 3488, 128 }, - { "xmm11", 3616, 128 }, - { "xmm12", 3744, 128 }, - { "xmm13", 3872, 128 }, - { "xmm14", 4000, 128 }, - { "xmm15", 4128, 128 }, - { "mxcsr", 4256, 32 }, -}; - -const char *expedite_regs_x86_64[] = { "rbp", "rsp", "rip", 0 }; - -void -init_registers () -{ - set_register_cache (regs_x86_64, - sizeof (regs_x86_64) / sizeof (regs_x86_64[0])); - gdbserver_expedite_regs = expedite_regs_x86_64; -} diff --git a/gnu/usr.bin/gdb/gdbserver/reg-arm.c b/gnu/usr.bin/gdb/gdbserver/reg-arm.c deleted file mode 100644 index 50379bfed75..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/reg-arm.c +++ /dev/null @@ -1,68 +0,0 @@ -/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ - -/* A register protocol for GDB, the GNU debugger. - Copyright 2001, 2002 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* This file was created with the aid of ``regdat.sh'' and ``reg-arm.dat''. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "regdef.h" -#include "regcache.h" - -struct reg regs_arm[] = { - { "r0", 0, 32 }, - { "r1", 32, 32 }, - { "r2", 64, 32 }, - { "r3", 96, 32 }, - { "r4", 128, 32 }, - { "r5", 160, 32 }, - { "r6", 192, 32 }, - { "r7", 224, 32 }, - { "r8", 256, 32 }, - { "r9", 288, 32 }, - { "r10", 320, 32 }, - { "r11", 352, 32 }, - { "r12", 384, 32 }, - { "sp", 416, 32 }, - { "lr", 448, 32 }, - { "pc", 480, 32 }, - { "f0", 512, 96 }, - { "f1", 608, 96 }, - { "f2", 704, 96 }, - { "f3", 800, 96 }, - { "f4", 896, 96 }, - { "f5", 992, 96 }, - { "f6", 1088, 96 }, - { "f7", 1184, 96 }, - { "fps", 1280, 32 }, - { "cpsr", 1312, 32 }, -}; - -const char *expedite_regs_arm[] = { "r11", "sp", "pc", 0 }; - -void -init_registers () -{ - set_register_cache (regs_arm, - sizeof (regs_arm) / sizeof (regs_arm[0])); - gdbserver_expedite_regs = expedite_regs_arm; -} diff --git a/gnu/usr.bin/gdb/gdbserver/reg-i386.c b/gnu/usr.bin/gdb/gdbserver/reg-i386.c deleted file mode 100644 index 3307ea933c4..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/reg-i386.c +++ /dev/null @@ -1,63 +0,0 @@ -/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ - -/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-i386.dat''. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "regdef.h" -#include "regcache.h" - -struct reg regs_i386[] = { - { "eax", 0, 32 }, - { "ecx", 32, 32 }, - { "edx", 64, 32 }, - { "ebx", 96, 32 }, - { "esp", 128, 32 }, - { "ebp", 160, 32 }, - { "esi", 192, 32 }, - { "edi", 224, 32 }, - { "eip", 256, 32 }, - { "eflags", 288, 32 }, - { "cs", 320, 32 }, - { "ss", 352, 32 }, - { "ds", 384, 32 }, - { "es", 416, 32 }, - { "fs", 448, 32 }, - { "gs", 480, 32 }, - { "st0", 512, 80 }, - { "st1", 592, 80 }, - { "st2", 672, 80 }, - { "st3", 752, 80 }, - { "st4", 832, 80 }, - { "st5", 912, 80 }, - { "st6", 992, 80 }, - { "st7", 1072, 80 }, - { "fctrl", 1152, 32 }, - { "fstat", 1184, 32 }, - { "ftag", 1216, 32 }, - { "fiseg", 1248, 32 }, - { "fioff", 1280, 32 }, - { "foseg", 1312, 32 }, - { "fooff", 1344, 32 }, - { "fop", 1376, 32 }, - { "xmm0", 1408, 128 }, - { "xmm1", 1536, 128 }, - { "xmm2", 1664, 128 }, - { "xmm3", 1792, 128 }, - { "xmm4", 1920, 128 }, - { "xmm5", 2048, 128 }, - { "xmm6", 2176, 128 }, - { "xmm7", 2304, 128 }, - { "mxcsr", 2432, 32 }, -}; - -const char *expedite_regs_i386[] = { "ebp", "esp", "eip", 0 }; - -void -init_registers () -{ - set_register_cache (regs_i386, - sizeof (regs_i386) / sizeof (regs_i386[0])); - gdbserver_expedite_regs = expedite_regs_i386; -} diff --git a/gnu/usr.bin/gdb/gdbserver/reg-powerpc.c b/gnu/usr.bin/gdb/gdbserver/reg-powerpc.c deleted file mode 100644 index 47046631d52..00000000000 --- a/gnu/usr.bin/gdb/gdbserver/reg-powerpc.c +++ /dev/null @@ -1,113 +0,0 @@ -/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ - -/* A register protocol for GDB, the GNU debugger. - Copyright 2001, 2002 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-ppc.dat''. */ - -#include -__FBSDID("$FreeBSD$"); - -#include "regdef.h" -#include "regcache.h" - -struct reg regs_ppc[] = { - { "r0", 0, 32 }, - { "r1", 32, 32 }, - { "r2", 64, 32 }, - { "r3", 96, 32 }, - { "r4", 128, 32 }, - { "r5", 160, 32 }, - { "r6", 192, 32 }, - { "r7", 224, 32 }, - { "r8", 256, 32 }, - { "r9", 288, 32 }, - { "r10", 320, 32 }, - { "r11", 352, 32 }, - { "r12", 384, 32 }, - { "r13", 416, 32 }, - { "r14", 448, 32 }, - { "r15", 480, 32 }, - { "r16", 512, 32 }, - { "r17", 544, 32 }, - { "r18", 576, 32 }, - { "r19", 608, 32 }, - { "r20", 640, 32 }, - { "r21", 672, 32 }, - { "r22", 704, 32 }, - { "r23", 736, 32 }, - { "r24", 768, 32 }, - { "r25", 800, 32 }, - { "r26", 832, 32 }, - { "r27", 864, 32 }, - { "r28", 896, 32 }, - { "r29", 928, 32 }, - { "r30", 960, 32 }, - { "r31", 992, 32 }, - { "f0", 1024, 64 }, - { "f1", 1088, 64 }, - { "f2", 1152, 64 }, - { "f3", 1216, 64 }, - { "f4", 1280, 64 }, - { "f5", 1344, 64 }, - { "f6", 1408, 64 }, - { "f7", 1472, 64 }, - { "f8", 1536, 64 }, - { "f9", 1600, 64 }, - { "f10", 1664, 64 }, - { "f11", 1728, 64 }, - { "f12", 1792, 64 }, - { "f13", 1856, 64 }, - { "f14", 1920, 64 }, - { "f15", 1984, 64 }, - { "f16", 2048, 64 }, - { "f17", 2112, 64 }, - { "f18", 2176, 64 }, - { "f19", 2240, 64 }, - { "f20", 2304, 64 }, - { "f21", 2368, 64 }, - { "f22", 2432, 64 }, - { "f23", 2496, 64 }, - { "f24", 2560, 64 }, - { "f25", 2624, 64 }, - { "f26", 2688, 64 }, - { "f27", 2752, 64 }, - { "f28", 2816, 64 }, - { "f29", 2880, 64 }, - { "f30", 2944, 64 }, - { "f31", 3008, 64 }, - { "pc", 3072, 32 }, - { "ps", 3104, 32 }, - { "cr", 3136, 32 }, - { "lr", 3168, 32 }, - { "ctr", 3200, 32 }, - { "xer", 3232, 32 }, - { "fpscr", 3264, 32 }, -}; - -const char *expedite_regs_ppc[] = { "r1", "pc", 0 }; - -void -init_registers () -{ - set_register_cache (regs_ppc, - sizeof (regs_ppc) / sizeof (regs_ppc[0])); - gdbserver_expedite_regs = expedite_regs_ppc; -} diff --git a/gnu/usr.bin/gdb/kgdb/Makefile b/gnu/usr.bin/gdb/kgdb/Makefile deleted file mode 100644 index 8fb781eca91..00000000000 --- a/gnu/usr.bin/gdb/kgdb/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD$ - -PROG= kgdb${GDB_SUFFIX} -SRCS= main.c kld.c kthr.c trgt.c trgt_${TARGET_CPUARCH}.c -WARNS?= 2 - -BULIBS= ${OBJ_BU}/libbfd/libbfd${PIE_SUFFIX}.a \ - ${OBJ_BU}/libopcodes/libopcodes${PIE_SUFFIX}.a \ - ${OBJ_BU}/libiberty/libiberty${PIE_SUFFIX}.a -GDBLIBS= ${OBJ_GDB}/libgdb/libgdb${PIE_SUFFIX}.a - -DPADD= ${GDBLIBS} ${BULIBS} -LDADD= ${GDBLIBS} ${BULIBS} -LIBADD+= m edit ncursesw gnuregex kvm - -.include diff --git a/gnu/usr.bin/gdb/kgdb/Makefile.depend b/gnu/usr.bin/gdb/kgdb/Makefile.depend deleted file mode 100644 index ed1b03ca732..00000000000 --- a/gnu/usr.bin/gdb/kgdb/Makefile.depend +++ /dev/null @@ -1,27 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libreadline/readline \ - gnu/lib/libregex \ - gnu/usr.bin/binutils/libbfd \ - gnu/usr.bin/binutils/libiberty \ - gnu/usr.bin/binutils/libopcodes \ - gnu/usr.bin/gdb/libgdb \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libelf \ - lib/libkvm \ - lib/msun \ - lib/ncurses/ncursesw \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.1 b/gnu/usr.bin/gdb/kgdb/kgdb.1 deleted file mode 100644 index 8ebfbf55ce9..00000000000 --- a/gnu/usr.bin/gdb/kgdb/kgdb.1 +++ /dev/null @@ -1,150 +0,0 @@ -.\" Copyright (c) 2004 Marcel Moolenaar -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd July 5, 2017 -.Dt KGDB 1 -.Os -.Sh NAME -.Nm kgdb -.Nd "kernel debugger" -.Sh SYNOPSIS -.Nm -.Op Fl a | Fl f | Fl fullname -.Op Fl b Ar rate -.Op Fl q | Fl quiet -.Op Fl v -.Op Fl w -.Op Fl d Ar crashdir -.Op Fl c Ar core | Fl n Ar dumpnr | Fl r Ar device -.Op Ar kernel Op Ar core -.Sh DEPRECATION NOTICE -This version of -.Nm -is deprecated and will be removed from future versions of the -.Fx -base system. -A newer version of -.Nm -is available from ports or packages -(devel/gdb). -.Sh DESCRIPTION -The -.Nm -utility is a debugger based on -.Xr gdb 1 -that allows debugging of kernel core files. -.Pp -The options are as follows: -.Bl -tag -width ".Fl d Ar crashdir" -.It Fl a -Increase the annotation level. -An annotation level of 1 features the historical -.Fl fullname -option of -.Xr gdb 1 . -This is useful when running -.Nm -in Emacs. -The -.Fl f -or -.Fl fullname -options are supported for backward compatibility as well. -.It Fl b Ar rate -Set the baudrate to -.Ar rate . -.It Fl q -Suppress printing of the banner when the debugger starts. -The -.Fl quiet -form is supported for compatibility as well. -.It Fl v -Increase verbosity. -.It Fl w -Opens kmem-based targets in read-write mode. -(This is identical to what -.Fl -wcore -used to do in previous -gdb versions for -.Fx . ) -.It Fl d Ar crashdir -Use -.Ar crashdir -instead of the default, -.Pa /var/crash -to locate kernel core dump files in. -The name -.Pa vmcore. -plus the dump number will be appended to determine -the actual dump file name. -.It Fl c Ar core -Explicitly use -.Ar core -as the core dump file. -.It Fl n Ar dumpnr -Use the kernel core dump file numbered -.Ar dumpnr -for debugging. -.It Fl r Ar device -Use -.Ar device -to connect -.Nm -to for a remote debugging session. -.El -.Pp -The -.Fl c , n , -and -.Fl r -options are mutually exclusive. -.Pp -Optionally, the name of the kernel symbol file and -the name of the core dump file can be supplied on the -command-line as positional arguments. -If no kernel symbol file name has been given, the -symbol file of the currently running kernel will be -used. -If no core dump file has been specified through either -of the options or the last command-line argument, -.Pa /dev/mem -will be opened to allow debugging the currently running -kernel. -.Sh FILES -.Bl -tag -width ".Pa /var/crash" -.It Pa /dev/mem -Default memory image to open if no core dump file -has been specified. -.It Pa /var/crash -Default directory to locate kernel core dump files. -.El -.Sh SEE ALSO -.Xr gdb 1 -.Sh HISTORY -The -.Nm -utility first appeared in its current form in -.Fx 5.3 . diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.h b/gnu/usr.bin/gdb/kgdb/kgdb.h deleted file mode 100644 index 8e5d2baf40b..00000000000 --- a/gnu/usr.bin/gdb/kgdb/kgdb.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _KGDB_H_ -#define _KGDB_H_ - -struct thread_info; - -extern kvm_t *kvm; - -struct kthr { - struct kthr *next; - uintptr_t paddr; - uintptr_t kaddr; - uintptr_t kstack; - uintptr_t pcb; - int tid; - int pid; - int cpu; -}; - -extern struct kthr *curkthr; - -void initialize_kld_target(void); -void initialize_kgdb_target(void); -void kgdb_dmesg(void); -CORE_ADDR kgdb_trgt_core_pcb(u_int); -CORE_ADDR kgdb_trgt_stop_pcb(u_int, u_int); -void kgdb_trgt_new_objfile(struct objfile *); -void kgdb_trgt_fetch_registers(int); -void kgdb_trgt_store_registers(int); -void kld_init(void); -void kld_new_objfile(struct objfile *); - -frame_unwind_sniffer_ftype kgdb_trgt_trapframe_sniffer; - -struct kthr *kgdb_thr_first(void); -struct kthr *kgdb_thr_init(void); -struct kthr *kgdb_thr_lookup_tid(int); -struct kthr *kgdb_thr_lookup_pid(int); -struct kthr *kgdb_thr_lookup_paddr(uintptr_t); -struct kthr *kgdb_thr_lookup_taddr(uintptr_t); -struct kthr *kgdb_thr_next(struct kthr *); -struct kthr *kgdb_thr_select(struct kthr *); -char *kgdb_thr_extra_thread_info(int); - -CORE_ADDR kgdb_lookup(const char *sym); -CORE_ADDR kgdb_parse_1(const char *, int); - -#define kgdb_parse(exp) kgdb_parse_1((exp), 0) -#define kgdb_parse_quiet(exp) kgdb_parse_1((exp), 1) - -extern int (*arm_tdep_pc_fixup)(CORE_ADDR *pc); -int kgdb_trgt_pc_fixup(CORE_ADDR *pc); - -#endif /* _KGDB_H_ */ diff --git a/gnu/usr.bin/gdb/kgdb/kld.c b/gnu/usr.bin/gdb/kgdb/kld.c deleted file mode 100644 index 50f0797c4cf..00000000000 --- a/gnu/usr.bin/gdb/kgdb/kld.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -struct lm_info { - CORE_ADDR base_address; -}; - -/* Offsets of fields in linker_file structure. */ -static CORE_ADDR off_address, off_filename, off_pathname, off_next; - -/* KVA of 'linker_path' which corresponds to the kern.module_path sysctl .*/ -static CORE_ADDR module_path_addr; -static CORE_ADDR linker_files_addr; -static CORE_ADDR kernel_file_addr; - -static struct target_so_ops kld_so_ops; - -static int -kld_ok (char *path) -{ - struct stat sb; - - if (stat(path, &sb) == 0 && S_ISREG(sb.st_mode)) - return (1); - return (0); -} - -/* - * Look for a matching file checking for debug suffixes before the raw file: - * - filename + ".debug" (e.g. foo.ko.debug) - * - filename (e.g. foo.ko) - */ -static const char *kld_suffixes[] = { - ".debug", - ".symbols", - "", - NULL -}; - -static int -check_kld_path (char *path, size_t path_size) -{ - const char **suffix; - char *ep; - - ep = path + strlen(path); - suffix = kld_suffixes; - while (*suffix != NULL) { - if (strlcat(path, *suffix, path_size) < path_size) { - if (kld_ok(path)) - return (1); - } - - /* Restore original path to remove suffix. */ - *ep = '\0'; - suffix++; - } - return (0); -} - -/* - * Try to find the path for a kld by looking in the kernel's directory and - * in the various paths in the module path. - */ -static int -find_kld_path (char *filename, char *path, size_t path_size) -{ - char *module_path; - char *kernel_dir, *module_dir, *cp; - int error; - - if (exec_bfd) { - kernel_dir = dirname(bfd_get_filename(exec_bfd)); - if (kernel_dir != NULL) { - snprintf(path, path_size, "%s/%s", kernel_dir, - filename); - if (check_kld_path(path, path_size)) - return (1); - } - } - if (module_path_addr != 0) { - target_read_string(module_path_addr, &module_path, PATH_MAX, - &error); - if (error == 0) { - make_cleanup(xfree, module_path); - cp = module_path; - while ((module_dir = strsep(&cp, ";")) != NULL) { - snprintf(path, path_size, "%s/%s", module_dir, - filename); - if (check_kld_path(path, path_size)) - return (1); - } - } - } - return (0); -} - -/* - * Read a kernel pointer given a KVA in 'address'. - */ -static CORE_ADDR -read_pointer (CORE_ADDR address) -{ - CORE_ADDR value; - - if (target_read_memory(address, (char *)&value, TARGET_PTR_BIT / 8) != - 0) - return (0); - return (extract_unsigned_integer(&value, TARGET_PTR_BIT / 8)); -} - -/* - * Try to find this kld in the kernel linker's list of linker files. - */ -static int -find_kld_address (char *arg, CORE_ADDR *address) -{ - CORE_ADDR kld; - char *kld_filename; - char *filename; - int error; - - if (linker_files_addr == 0 || off_address == 0 || off_filename == 0 || - off_next == 0) - return (0); - - filename = basename(arg); - for (kld = read_pointer(linker_files_addr); kld != 0; - kld = read_pointer(kld + off_next)) { - /* Try to read this linker file's filename. */ - target_read_string(read_pointer(kld + off_filename), - &kld_filename, PATH_MAX, &error); - if (error) - continue; - - /* Compare this kld's filename against our passed in name. */ - if (strcmp(kld_filename, filename) != 0) { - xfree(kld_filename); - continue; - } - xfree(kld_filename); - - /* - * We found a match, use its address as the base - * address if we can read it. - */ - *address = read_pointer(kld + off_address); - if (*address == 0) - return (0); - return (1); - } - return (0); -} - -static void -adjust_section_address (struct section_table *sec, CORE_ADDR *curr_base) -{ - struct bfd_section *asect = sec->the_bfd_section; - bfd *abfd = sec->bfd; - - if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) { - sec->addr += *curr_base; - sec->endaddr += *curr_base; - return; - } - - *curr_base = align_power(*curr_base, - bfd_get_section_alignment(abfd, asect)); - sec->addr = *curr_base; - sec->endaddr = sec->addr + bfd_section_size(abfd, asect); - *curr_base = sec->endaddr; -} - -static void -load_kld (char *path, CORE_ADDR base_addr, int from_tty) -{ - struct section_addr_info *sap; - struct section_table *sections = NULL, *sections_end = NULL, *s; - struct cleanup *cleanup; - bfd *bfd; - CORE_ADDR curr_addr; - int i; - - /* Open the kld. */ - bfd = bfd_openr(path, gnutarget); - if (bfd == NULL) - error("\"%s\": can't open: %s", path, - bfd_errmsg(bfd_get_error())); - cleanup = make_cleanup_bfd_close(bfd); - - if (!bfd_check_format(bfd, bfd_object)) - error("\%s\": not an object file", path); - - /* Make sure we have a .text section. */ - if (bfd_get_section_by_name (bfd, ".text") == NULL) - error("\"%s\": can't find text section", path); - - /* Build a section table from the bfd and relocate the sections. */ - if (build_section_table (bfd, §ions, §ions_end)) - error("\"%s\": can't find file sections", path); - cleanup = make_cleanup(xfree, sections); - curr_addr = base_addr; - for (s = sections; s < sections_end; s++) - adjust_section_address(s, &curr_addr); - - /* Build a section addr info to pass to symbol_file_add(). */ - sap = build_section_addr_info_from_section_table (sections, - sections_end); - cleanup = make_cleanup((make_cleanup_ftype *)free_section_addr_info, - sap); - - printf_unfiltered("add symbol table from file \"%s\" at\n", path); - for (i = 0; i < sap->num_sections; i++) - printf_unfiltered("\t%s_addr = %s\n", sap->other[i].name, - local_hex_string(sap->other[i].addr)); - - if (from_tty && (!query("%s", ""))) - error("Not confirmed."); - - symbol_file_add(path, from_tty, sap, 0, OBJF_USERLOADED); - - do_cleanups(cleanup); -} - -static void -kgdb_add_kld_cmd (char *arg, int from_tty) -{ - char path[PATH_MAX]; - CORE_ADDR base_addr; - - if (!exec_bfd) - error("No kernel symbol file"); - - /* Try to open the raw path to handle absolute paths first. */ - snprintf(path, sizeof(path), "%s", arg); - if (!check_kld_path(path, sizeof(path))) { - - /* - * If that didn't work, look in the various possible - * paths for the module. - */ - if (!find_kld_path(arg, path, sizeof(path))) { - error("Unable to locate kld"); - return; - } - } - - if (!find_kld_address(arg, &base_addr)) { - error("Unable to find kld in kernel"); - return; - } - - load_kld(path, base_addr, from_tty); - - reinit_frame_cache(); -} - -static void -kld_relocate_section_addresses (struct so_list *so, struct section_table *sec) -{ - static CORE_ADDR curr_addr; - - if (sec == so->sections) - curr_addr = so->lm_info->base_address; - - adjust_section_address(sec, &curr_addr); -} - -static void -kld_free_so (struct so_list *so) -{ - - xfree(so->lm_info); -} - -static void -kld_clear_solib (void) -{ -} - -static void -kld_solib_create_inferior_hook (void) -{ -} - -static void -kld_special_symbol_handling (void) -{ -} - -static struct so_list * -kld_current_sos (void) -{ - struct so_list *head, **prev, *new; - CORE_ADDR kld, kernel; - char *path; - int error; - - if (linker_files_addr == 0 || kernel_file_addr == 0 || - off_address == 0 || off_filename == 0 || off_next == 0) - return (NULL); - - head = NULL; - prev = &head; - - /* - * Walk the list of linker files creating so_list entries for - * each non-kernel file. - */ - kernel = read_pointer(kernel_file_addr); - for (kld = read_pointer(linker_files_addr); kld != 0; - kld = read_pointer(kld + off_next)) { - /* Skip the main kernel file. */ - if (kld == kernel) - continue; - - new = xmalloc(sizeof(*new)); - memset(new, 0, sizeof(*new)); - - new->lm_info = xmalloc(sizeof(*new->lm_info)); - new->lm_info->base_address = 0; - - /* Read the base filename and store it in so_original_name. */ - target_read_string(read_pointer(kld + off_filename), - &path, sizeof(new->so_original_name), &error); - if (error != 0) { - warning("kld_current_sos: Can't read filename: %s\n", - safe_strerror(error)); - free_so(new); - continue; - } - strlcpy(new->so_original_name, path, - sizeof(new->so_original_name)); - xfree(path); - - /* - * Try to read the pathname (if it exists) and store - * it in so_name. - */ - if (find_kld_path(new->so_original_name, new->so_name, - sizeof(new->so_name))) { - /* we found the kld */; - } else if (off_pathname != 0) { - target_read_string(read_pointer(kld + off_pathname), - &path, sizeof(new->so_name), &error); - if (error != 0) { - warning( - "kld_current_sos: Can't read pathname for \"%s\": %s\n", - new->so_original_name, - safe_strerror(error)); - strlcpy(new->so_name, new->so_original_name, - sizeof(new->so_name)); - } else { - strlcpy(new->so_name, path, - sizeof(new->so_name)); - xfree(path); - } - } else - strlcpy(new->so_name, new->so_original_name, - sizeof(new->so_name)); - - /* Read this kld's base address. */ - new->lm_info->base_address = read_pointer(kld + off_address); - if (new->lm_info->base_address == 0) { - warning( - "kld_current_sos: Invalid address for kld \"%s\"", - new->so_original_name); - free_so(new); - continue; - } - - /* Append to the list. */ - *prev = new; - prev = &new->next; - } - - return (head); -} - -static int -kld_open_symbol_file_object (void *from_ttyp) -{ - - return (0); -} - -static int -kld_in_dynsym_resolve_code (CORE_ADDR pc) -{ - - return (0); -} - -static int -kld_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname) -{ - char path[PATH_MAX]; - int fd; - - *temp_pathname = NULL; - if (!find_kld_path(solib, path, sizeof(path))) { - errno = ENOENT; - return (-1); - } - fd = open(path, o_flags, 0); - if (fd >= 0) - *temp_pathname = xstrdup(path); - return (fd); -} - -void -kld_new_objfile (struct objfile *objfile) -{ - - if (!have_partial_symbols()) - return; - - /* - * Compute offsets of relevant members in struct linker_file - * and the addresses of global variables. Don't warn about - * kernels that don't have 'pathname' in the linker_file - * struct since 6.x kernels don't have it. - */ - off_address = kgdb_parse("&((struct linker_file *)0)->address"); - off_filename = kgdb_parse("&((struct linker_file *)0)->filename"); - off_pathname = kgdb_parse_quiet("&((struct linker_file *)0)->pathname"); - off_next = kgdb_parse("&((struct linker_file *)0)->link.tqe_next"); - module_path_addr = kgdb_parse("linker_path"); - linker_files_addr = kgdb_parse("&linker_files.tqh_first"); - kernel_file_addr = kgdb_parse("&linker_kernel_file"); -} - -static int -load_klds_stub (void *arg) -{ - - SOLIB_ADD(NULL, 1, ¤t_target, auto_solib_add); - return (0); -} - -void -kld_init (void) -{ - - catch_errors(load_klds_stub, NULL, NULL, RETURN_MASK_ALL); -} - -void -initialize_kld_target(void) -{ - struct cmd_list_element *c; - - kld_so_ops.relocate_section_addresses = kld_relocate_section_addresses; - kld_so_ops.free_so = kld_free_so; - kld_so_ops.clear_solib = kld_clear_solib; - kld_so_ops.solib_create_inferior_hook = kld_solib_create_inferior_hook; - kld_so_ops.special_symbol_handling = kld_special_symbol_handling; - kld_so_ops.current_sos = kld_current_sos; - kld_so_ops.open_symbol_file_object = kld_open_symbol_file_object; - kld_so_ops.in_dynsym_resolve_code = kld_in_dynsym_resolve_code; - kld_so_ops.find_and_open_solib = kld_find_and_open_solib; - - current_target_so_ops = &kld_so_ops; - - c = add_com("add-kld", class_files, kgdb_add_kld_cmd, - "Usage: add-kld FILE\n\ -Load the symbols from the kernel loadable module FILE."); - set_cmd_completer(c, filename_completer); -} diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c deleted file mode 100644 index 1bc95cb18b3..00000000000 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "kgdb.h" - -static CORE_ADDR dumppcb; -static int dumptid; - -static cpuset_t stopped_cpus; - -static struct kthr *first; -struct kthr *curkthr; - -CORE_ADDR -kgdb_lookup(const char *sym) -{ - CORE_ADDR addr; - char *name; - - asprintf(&name, "&%s", sym); - addr = kgdb_parse(name); - free(name); - return (addr); -} - -struct kthr * -kgdb_thr_first(void) -{ - return (first); -} - -static void -kgdb_thr_add_procs(uintptr_t paddr) -{ - struct proc p; - struct thread td; - struct kthr *kt; - CORE_ADDR addr; - - while (paddr != 0) { - if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - break; - } - addr = (uintptr_t)TAILQ_FIRST(&p.p_threads); - while (addr != 0) { - if (kvm_read(kvm, addr, &td, sizeof(td)) != - sizeof(td)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - break; - } - kt = malloc(sizeof(*kt)); - kt->next = first; - kt->kaddr = addr; - if (td.td_tid == dumptid) - kt->pcb = dumppcb; - else if (td.td_oncpu != NOCPU && - CPU_ISSET(td.td_oncpu, &stopped_cpus)) - kt->pcb = kgdb_trgt_core_pcb(td.td_oncpu); - else - kt->pcb = (uintptr_t)td.td_pcb; - kt->kstack = td.td_kstack; - kt->tid = td.td_tid; - kt->pid = p.p_pid; - kt->paddr = paddr; - kt->cpu = td.td_oncpu; - first = kt; - addr = (uintptr_t)TAILQ_NEXT(&td, td_plist); - } - paddr = (uintptr_t)LIST_NEXT(&p, p_list); - } -} - -struct kthr * -kgdb_thr_init(void) -{ - long cpusetsize; - struct kthr *kt; - CORE_ADDR addr; - uintptr_t paddr; - - while (first != NULL) { - kt = first; - first = kt->next; - free(kt); - } - - addr = kgdb_lookup("allproc"); - if (addr == 0) - return (NULL); - kvm_read(kvm, addr, &paddr, sizeof(paddr)); - - dumppcb = kgdb_lookup("dumppcb"); - if (dumppcb == 0) - return (NULL); - - addr = kgdb_lookup("dumptid"); - if (addr != 0) - kvm_read(kvm, addr, &dumptid, sizeof(dumptid)); - else - dumptid = -1; - - addr = kgdb_lookup("stopped_cpus"); - CPU_ZERO(&stopped_cpus); - cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize != -1 && (u_long)cpusetsize <= sizeof(cpuset_t) && - addr != 0) - kvm_read(kvm, addr, &stopped_cpus, cpusetsize); - - kgdb_thr_add_procs(paddr); - addr = kgdb_lookup("zombproc"); - if (addr != 0) { - kvm_read(kvm, addr, &paddr, sizeof(paddr)); - kgdb_thr_add_procs(paddr); - } - curkthr = kgdb_thr_lookup_tid(dumptid); - if (curkthr == NULL) - curkthr = first; - return (first); -} - -struct kthr * -kgdb_thr_lookup_tid(int tid) -{ - struct kthr *kt; - - kt = first; - while (kt != NULL && kt->tid != tid) - kt = kt->next; - return (kt); -} - -struct kthr * -kgdb_thr_lookup_taddr(uintptr_t taddr) -{ - struct kthr *kt; - - kt = first; - while (kt != NULL && kt->kaddr != taddr) - kt = kt->next; - return (kt); -} - -struct kthr * -kgdb_thr_lookup_pid(int pid) -{ - struct kthr *kt; - - kt = first; - while (kt != NULL && kt->pid != pid) - kt = kt->next; - return (kt); -} - -struct kthr * -kgdb_thr_lookup_paddr(uintptr_t paddr) -{ - struct kthr *kt; - - kt = first; - while (kt != NULL && kt->paddr != paddr) - kt = kt->next; - return (kt); -} - -struct kthr * -kgdb_thr_next(struct kthr *kt) -{ - return (kt->next); -} - -struct kthr * -kgdb_thr_select(struct kthr *kt) -{ - struct kthr *pcur; - - pcur = curkthr; - curkthr = kt; - return (pcur); -} - -char * -kgdb_thr_extra_thread_info(int tid) -{ - char comm[MAXCOMLEN + 1]; - char td_name[MAXCOMLEN + 1]; - struct kthr *kt; - struct proc *p; - struct thread *t; - static char buf[64]; - - kt = kgdb_thr_lookup_tid(tid); - if (kt == NULL) - return (NULL); - snprintf(buf, sizeof(buf), "PID=%d", kt->pid); - p = (struct proc *)kt->paddr; - if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) != - sizeof(comm)) - return (buf); - strlcat(buf, ": ", sizeof(buf)); - strlcat(buf, comm, sizeof(buf)); - t = (struct thread *)kt->kaddr; - if (kvm_read(kvm, (uintptr_t)&t->td_name[0], &td_name, - sizeof(td_name)) == sizeof(td_name) && - strcmp(comm, td_name) != 0) { - strlcat(buf, "/", sizeof(buf)); - strlcat(buf, td_name, sizeof(buf)); - } - return (buf); -} diff --git a/gnu/usr.bin/gdb/kgdb/main.c b/gnu/usr.bin/gdb/kgdb/main.c deleted file mode 100644 index a1da89314a0..00000000000 --- a/gnu/usr.bin/gdb/kgdb/main.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* libgdb stuff. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern frame_unwind_sniffer_ftype *kgdb_sniffer_kluge; - -#include "kgdb.h" - -static int dumpnr; -static int quiet; -static int verbose; - -static char crashdir[PATH_MAX]; -static char *kernel; -static char *remote; -static char *vmcore; -static struct ui_file *parse_gdberr; - -static void (*kgdb_new_objfile_chain)(struct objfile * objfile); - -static void -usage(void) -{ - - fprintf(stderr, - "usage: %s [-afqvw] [-b rate] [-d crashdir] [-c core | -n dumpnr | -r device]\n" - "\t[kernel [core]]\n", getprogname()); - exit(1); -} - -static void -kernel_from_dumpnr(int nr) -{ - char path[PATH_MAX]; - FILE *info; - char *s; - struct stat st; - int l; - - /* - * If there's a kernel image right here in the crash directory, then - * use it. The kernel image is either called kernel. or is in a - * subdirectory kernel. and called kernel. The latter allows us - * to collect the modules in the same place. - */ - snprintf(path, sizeof(path), "%s/kernel.%d", crashdir, nr); - if (stat(path, &st) == 0) { - if (S_ISREG(st.st_mode)) { - kernel = strdup(path); - return; - } - if (S_ISDIR(st.st_mode)) { - snprintf(path, sizeof(path), "%s/kernel.%d/kernel", - crashdir, nr); - if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { - kernel = strdup(path); - return; - } - } - } - - /* - * No kernel image here. Parse the dump header. The kernel object - * directory can be found there and we probably have the kernel - * image still in it. The object directory may also have a kernel - * with debugging info (called kernel.debug). If we have a debug - * kernel, use it. - */ - snprintf(path, sizeof(path), "%s/info.%d", crashdir, nr); - info = fopen(path, "r"); - if (info == NULL) { - warn("%s", path); - return; - } - while (fgets(path, sizeof(path), info) != NULL) { - l = strlen(path); - if (l > 0 && path[l - 1] == '\n') - path[--l] = '\0'; - if (strncmp(path, " ", 4) == 0) { - s = strchr(path, ':'); - s = (s == NULL) ? path + 4 : s + 1; - l = snprintf(path, sizeof(path), "%s/kernel.debug", s); - if (stat(path, &st) == -1 || !S_ISREG(st.st_mode)) { - path[l - 6] = '\0'; - if (stat(path, &st) == -1 || - !S_ISREG(st.st_mode)) - break; - } - kernel = strdup(path); - break; - } - } - fclose(info); -} - -static void -kgdb_new_objfile(struct objfile *objfile) -{ - static int once = 1; - - kld_new_objfile(objfile); - kgdb_trgt_new_objfile(objfile); - - if (kgdb_new_objfile_chain != NULL) - kgdb_new_objfile_chain(objfile); - - if (once && objfile != NULL && objfile == symfile_objfile) { - /* - * The initial kernel has just been loaded. Start the - * remote target if we have one. - */ - once = 0; - if (remote != NULL) - push_remote_target (remote, 0); - } -} - -/* - * Parse an expression and return its value. If 'quiet' is true, then - * any error messages from the parser are masked. - */ -CORE_ADDR -kgdb_parse_1(const char *exp, int quiet) -{ - struct ui_file *old_stderr; - struct cleanup *old_chain; - struct expression *expr; - struct value *val; - char *s; - CORE_ADDR n; - - old_stderr = gdb_stderr; - if (quiet) - gdb_stderr = parse_gdberr; - n = 0; - s = xstrdup(exp); - old_chain = make_cleanup(xfree, s); - if (gdb_parse_exp_1(&s, NULL, 0, &expr) && *s == '\0') { - make_cleanup(free_current_contents, &expr); - if (gdb_evaluate_expression(expr, &val)) - n = value_as_address(val); - } - do_cleanups(old_chain); - gdb_stderr = old_stderr; - return (n); -} - -#define MSGBUF_SEQ_TO_POS(size, seq) ((seq) % (size)) - -void -kgdb_dmesg(void) -{ - CORE_ADDR bufp; - int size, rseq, wseq; - char c; - - /* - * Display the unread portion of the message buffer. This gives the - * user a some initial data to work from. - */ - if (quiet) - return; - bufp = kgdb_parse("msgbufp->msg_ptr"); - size = (int)kgdb_parse("msgbufp->msg_size"); - if (bufp == 0 || size == 0) - return; - rseq = (int)kgdb_parse("msgbufp->msg_rseq"); - wseq = (int)kgdb_parse("msgbufp->msg_wseq"); - rseq = MSGBUF_SEQ_TO_POS(size, rseq); - wseq = MSGBUF_SEQ_TO_POS(size, wseq); - if (rseq == wseq) - return; - - printf("\nUnread portion of the kernel message buffer:\n"); - while (rseq < wseq) { - read_memory(bufp + rseq, &c, 1); - putchar(c); - rseq++; - if (rseq == size) - rseq = 0; - } - if (c != '\n') - putchar('\n'); - putchar('\n'); -} - -static void -kgdb_init(char *argv0 __unused) -{ - - parse_gdberr = mem_fileopen(); - set_prompt("(kgdb) "); - initialize_kgdb_target(); - initialize_kld_target(); - kgdb_new_objfile_chain = target_new_objfile_hook; - target_new_objfile_hook = kgdb_new_objfile; -} - -/* - * Remote targets can support any number of syntaxes and we want to - * support them all with one addition: we support specifying a device - * node for a serial device without the "/dev/" prefix. - * - * What we do is to stat(2) the existing remote target first. If that - * fails, we try it with "/dev/" prepended. If that succeeds we use - * the resulting path, otherwise we use the original target. If - * either stat(2) succeeds make sure the file is either a character - * device or a FIFO. - */ -static void -verify_remote(void) -{ - char path[PATH_MAX]; - struct stat st; - - if (stat(remote, &st) != 0) { - snprintf(path, sizeof(path), "/dev/%s", remote); - if (stat(path, &st) != 0) - return; - free(remote); - remote = strdup(path); - } - if (!S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) - errx(1, "%s: not a special file, FIFO or socket", remote); -} - -static void -add_arg(struct captured_main_args *args, char *arg) -{ - - args->argc++; - args->argv = reallocf(args->argv, (args->argc + 1) * sizeof(char *)); - if (args->argv == NULL) - err(1, "Out of memory building argument list"); - args->argv[args->argc] = arg; -} - -int -main(int argc, char *argv[]) -{ - char path[PATH_MAX]; - struct stat st; - struct captured_main_args args; - char *s; - int a, ch; - - dumpnr = -1; - - strlcpy(crashdir, "/var/crash", sizeof(crashdir)); - s = getenv("KGDB_CRASH_DIR"); - if (s != NULL) - strlcpy(crashdir, s, sizeof(crashdir)); - - /* Convert long options into short options. */ - for (a = 1; a < argc; a++) { - s = argv[a]; - if (s[0] == '-') { - s++; - /* Long options take either 1 or 2 dashes. */ - if (s[0] == '-') - s++; - if (strcmp(s, "quiet") == 0) - argv[a] = "-q"; - else if (strcmp(s, "fullname") == 0) - argv[a] = "-f"; - } - } - - quiet = 0; - memset (&args, 0, sizeof args); - args.use_windows = 0; - args.interpreter_p = INTERP_CONSOLE; - args.argv = malloc(sizeof(char *)); - args.argv[0] = argv[0]; - - while ((ch = getopt(argc, argv, "ab:c:d:fn:qr:vw")) != -1) { - switch (ch) { - case 'a': - annotation_level++; - break; - case 'b': { - int i; - char *p; - - i = strtol(optarg, &p, 0); - if (*p != '\0' || p == optarg) - warnx("warning: could not set baud rate to `%s'.\n", - optarg); - else - baud_rate = i; - break; - } - case 'c': /* use given core file. */ - if (vmcore != NULL) { - warnx("option %c: can only be specified once", - optopt); - usage(); - /* NOTREACHED */ - } - vmcore = strdup(optarg); - break; - case 'd': /* lookup dumps in given directory. */ - strlcpy(crashdir, optarg, sizeof(crashdir)); - break; - case 'f': - annotation_level = 1; - break; - case 'n': /* use dump with given number. */ - dumpnr = strtol(optarg, &s, 0); - if (dumpnr < 0 || *s != '\0') { - warnx("option %c: invalid kernel dump number", - optopt); - usage(); - /* NOTREACHED */ - } - break; - case 'q': - quiet = 1; - add_arg(&args, "-q"); - break; - case 'r': /* use given device for remote session. */ - if (remote != NULL) { - warnx("option %c: can only be specified once", - optopt); - usage(); - /* NOTREACHED */ - } - remote = strdup(optarg); - break; - case 'v': /* increase verbosity. */ - verbose++; - break; - case 'w': /* core file is writeable. */ - add_arg(&args, "--write"); - break; - case '?': - default: - usage(); - } - } - - if (((vmcore != NULL) ? 1 : 0) + ((dumpnr >= 0) ? 1 : 0) + - ((remote != NULL) ? 1 : 0) > 1) { - warnx("options -c, -n and -r are mutually exclusive"); - usage(); - /* NOTREACHED */ - } - - if (verbose > 1) - warnx("using %s as the crash directory", crashdir); - - if (argc > optind) - kernel = strdup(argv[optind++]); - - if (argc > optind && (dumpnr >= 0 || remote != NULL)) { - warnx("options -n and -r do not take a core file. Ignored"); - optind = argc; - } - - if (dumpnr >= 0) { - snprintf(path, sizeof(path), "%s/vmcore.%d", crashdir, dumpnr); - if (stat(path, &st) == -1) - err(1, "%s", path); - if (!S_ISREG(st.st_mode)) - errx(1, "%s: not a regular file", path); - vmcore = strdup(path); - } else if (remote != NULL) { - verify_remote(); - } else if (argc > optind) { - if (vmcore == NULL) - vmcore = strdup(argv[optind++]); - if (argc > optind) - warnx("multiple core files specified. Ignored"); - } else if (vmcore == NULL && kernel == NULL) { - vmcore = strdup(_PATH_MEM); - kernel = strdup(getbootfile()); - } - - if (verbose) { - if (vmcore != NULL) - warnx("core file: %s", vmcore); - if (remote != NULL) - warnx("device file: %s", remote); - if (kernel != NULL) - warnx("kernel image: %s", kernel); - } - - /* A remote target requires an explicit kernel argument. */ - if (remote != NULL && kernel == NULL) { - warnx("remote debugging requires a kernel"); - usage(); - /* NOTREACHED */ - } - - /* If we don't have a kernel image yet, try to find one. */ - if (kernel == NULL) { - if (dumpnr >= 0) - kernel_from_dumpnr(dumpnr); - - if (kernel == NULL) - errx(1, "couldn't find a suitable kernel image"); - if (verbose) - warnx("kernel image: %s", kernel); - } - add_arg(&args, kernel); - - if (vmcore != NULL) - add_arg(&args, vmcore); - - /* The libgdb code uses optind too. Reset it... */ - optind = 0; - - /* Terminate argv list. */ - add_arg(&args, NULL); - - init_ui_hook = kgdb_init; - frame_tdep_pc_fixup = kgdb_trgt_pc_fixup; - kgdb_sniffer_kluge = kgdb_trgt_trapframe_sniffer; - - return (gdb_main(&args)); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt.c b/gnu/usr.bin/gdb/kgdb/trgt.c deleted file mode 100644 index 56c64b8fe47..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -#ifdef CROSS_DEBUGGER -/* - * We suppress the call to add_target() of core_ops in corelow.c because if - * there are multiple core_stratum targets, the find_core_target() function - * won't know which one to return and returns none. We need it to return - * our target. We only have to do that when we're building a cross-debugger - * because fbsd-threads.c is part of a native debugger and it too defines - * coreops_suppress_target with 1 as the initializer. - */ -int coreops_suppress_target = 1; -#endif - -static CORE_ADDR stoppcbs; - -static void kgdb_core_cleanup(void *); - -static char *vmcore; -static struct target_ops kgdb_trgt_ops; - -kvm_t *kvm; -static char kvm_err[_POSIX2_LINE_MAX]; - -#define KERNOFF (kgdb_kernbase ()) -#define PINKERNEL(x) ((x) >= KERNOFF) - -static int -kgdb_resolve_symbol(const char *name, kvaddr_t *kva) -{ - struct minimal_symbol *ms; - - ms = lookup_minimal_symbol (name, NULL, NULL); - if (ms == NULL) - return (1); - - *kva = SYMBOL_VALUE_ADDRESS (ms); - return (0); -} - -static CORE_ADDR -kgdb_kernbase (void) -{ - static CORE_ADDR kernbase; - struct minimal_symbol *sym; - - if (kernbase == 0) { - sym = lookup_minimal_symbol ("kernbase", NULL, NULL); - if (sym == NULL) { - kernbase = KERNBASE; - } else { - kernbase = SYMBOL_VALUE_ADDRESS (sym); - } - } - return kernbase; -} - -static void -kgdb_trgt_open(char *filename, int from_tty) -{ - struct cleanup *old_chain; - struct thread_info *ti; - struct kthr *kt; - kvm_t *nkvm; - char *temp; - int ontop; - - target_preopen (from_tty); - if (!filename) - error ("No vmcore file specified."); - if (!exec_bfd) - error ("Can't open a vmcore without a kernel"); - - filename = tilde_expand (filename); - if (filename[0] != '/') { - temp = concat (current_directory, "/", filename, NULL); - xfree(filename); - filename = temp; - } - - old_chain = make_cleanup (xfree, filename); - - nkvm = kvm_open2(bfd_get_filename(exec_bfd), filename, - write_files ? O_RDWR : O_RDONLY, kvm_err, kgdb_resolve_symbol); - if (nkvm == NULL) - error ("Failed to open vmcore: %s", kvm_err); - - /* Don't free the filename now and close any previous vmcore. */ - discard_cleanups(old_chain); - unpush_target(&kgdb_trgt_ops); - - kvm = nkvm; - vmcore = filename; - old_chain = make_cleanup(kgdb_core_cleanup, NULL); - - ontop = !push_target (&kgdb_trgt_ops); - discard_cleanups (old_chain); - - kgdb_dmesg(); - - init_thread_list(); - kt = kgdb_thr_init(); - while (kt != NULL) { - ti = add_thread(pid_to_ptid(kt->tid)); - kt = kgdb_thr_next(kt); - } - if (curkthr != 0) - inferior_ptid = pid_to_ptid(curkthr->tid); - - if (ontop) { - /* XXX: fetch registers? */ - kld_init(); - flush_cached_frames(); - select_frame (get_current_frame()); - print_stack_frame(get_selected_frame(), - frame_relative_level(get_selected_frame()), 1); - } else - warning( - "you won't be able to access this vmcore until you terminate\n\ -your %s; do ``info files''", target_longname); -} - -static void -kgdb_trgt_close(int quitting) -{ - - if (kvm != NULL) { - inferior_ptid = null_ptid; - CLEAR_SOLIB(); - if (kvm_close(kvm) != 0) - warning("cannot close \"%s\": %s", vmcore, - kvm_geterr(kvm)); - kvm = NULL; - xfree(vmcore); - vmcore = NULL; - if (kgdb_trgt_ops.to_sections) { - xfree(kgdb_trgt_ops.to_sections); - kgdb_trgt_ops.to_sections = NULL; - kgdb_trgt_ops.to_sections_end = NULL; - } - } -} - -static void -kgdb_core_cleanup(void *arg) -{ - - kgdb_trgt_close(0); -} - -static void -kgdb_trgt_detach(char *args, int from_tty) -{ - - if (args) - error ("Too many arguments"); - unpush_target(&kgdb_trgt_ops); - reinit_frame_cache(); - if (from_tty) - printf_filtered("No vmcore file now.\n"); -} - -static char * -kgdb_trgt_extra_thread_info(struct thread_info *ti) -{ - - return (kgdb_thr_extra_thread_info(ptid_get_pid(ti->ptid))); -} - -static void -kgdb_trgt_files_info(struct target_ops *target) -{ - - printf_filtered ("\t`%s', ", vmcore); - wrap_here (" "); - printf_filtered ("file type %s.\n", "FreeBSD kernel vmcore"); -} - -static void -kgdb_trgt_find_new_threads(void) -{ - struct target_ops *tb; - - if (kvm != NULL) - return; - - tb = find_target_beneath(&kgdb_trgt_ops); - if (tb->to_find_new_threads != NULL) - tb->to_find_new_threads(); -} - -static char * -kgdb_trgt_pid_to_str(ptid_t ptid) -{ - static char buf[33]; - - snprintf(buf, sizeof(buf), "Thread %d", ptid_get_pid(ptid)); - return (buf); -} - -static int -kgdb_trgt_thread_alive(ptid_t ptid) -{ - return (kgdb_thr_lookup_tid(ptid_get_pid(ptid)) != NULL); -} - -static int -kgdb_trgt_xfer_memory(CORE_ADDR memaddr, char *myaddr, int len, int write, - struct mem_attrib *attrib, struct target_ops *target) -{ - struct target_ops *tb; - - if (kvm != NULL) { - if (len == 0) - return (0); - if (!write) - return (kvm_read2(kvm, memaddr, myaddr, len)); - else - return (kvm_write(kvm, memaddr, myaddr, len)); - } - tb = find_target_beneath(target); - return (tb->to_xfer_memory(memaddr, myaddr, len, write, attrib, tb)); -} - -static int -kgdb_trgt_ignore_breakpoints(CORE_ADDR addr, char *contents) -{ - - return 0; -} - -static void -kgdb_switch_to_thread(int tid) -{ - char buf[16]; - int thread_id; - - thread_id = pid_to_thread_id(pid_to_ptid(tid)); - if (thread_id == 0) - error ("invalid tid"); - snprintf(buf, sizeof(buf), "%d", thread_id); - gdb_thread_select(uiout, buf); -} - -static void -kgdb_set_proc_cmd (char *arg, int from_tty) -{ - CORE_ADDR addr; - struct kthr *thr; - - if (!arg) - error_no_arg ("proc address for the new context"); - - if (kvm == NULL) - error ("only supported for core file target"); - - addr = (CORE_ADDR) parse_and_eval_address (arg); - - if (!PINKERNEL (addr)) { - thr = kgdb_thr_lookup_pid((int)addr); - if (thr == NULL) - error ("invalid pid"); - } else { - thr = kgdb_thr_lookup_paddr(addr); - if (thr == NULL) - error("invalid proc address"); - } - kgdb_switch_to_thread(thr->tid); -} - -static void -kgdb_set_tid_cmd (char *arg, int from_tty) -{ - CORE_ADDR addr; - struct kthr *thr; - - if (!arg) - error_no_arg ("TID or thread address for the new context"); - - addr = (CORE_ADDR) parse_and_eval_address (arg); - - if (kvm != NULL && PINKERNEL (addr)) { - thr = kgdb_thr_lookup_taddr(addr); - if (thr == NULL) - error("invalid thread address"); - addr = thr->tid; - } - kgdb_switch_to_thread(addr); -} - -int fbsdcoreops_suppress_target = 1; - -void -initialize_kgdb_target(void) -{ - - kgdb_trgt_ops.to_magic = OPS_MAGIC; - kgdb_trgt_ops.to_shortname = "kernel"; - kgdb_trgt_ops.to_longname = "kernel core dump file"; - kgdb_trgt_ops.to_doc = - "Use a vmcore file as a target. Specify the filename of the vmcore file."; - kgdb_trgt_ops.to_stratum = core_stratum; - kgdb_trgt_ops.to_has_memory = 1; - kgdb_trgt_ops.to_has_registers = 1; - kgdb_trgt_ops.to_has_stack = 1; - - kgdb_trgt_ops.to_open = kgdb_trgt_open; - kgdb_trgt_ops.to_close = kgdb_trgt_close; - kgdb_trgt_ops.to_attach = find_default_attach; - kgdb_trgt_ops.to_detach = kgdb_trgt_detach; - kgdb_trgt_ops.to_extra_thread_info = kgdb_trgt_extra_thread_info; - kgdb_trgt_ops.to_fetch_registers = kgdb_trgt_fetch_registers; - kgdb_trgt_ops.to_files_info = kgdb_trgt_files_info; - kgdb_trgt_ops.to_find_new_threads = kgdb_trgt_find_new_threads; - kgdb_trgt_ops.to_pid_to_str = kgdb_trgt_pid_to_str; - kgdb_trgt_ops.to_store_registers = kgdb_trgt_store_registers; - kgdb_trgt_ops.to_thread_alive = kgdb_trgt_thread_alive; - kgdb_trgt_ops.to_xfer_memory = kgdb_trgt_xfer_memory; - kgdb_trgt_ops.to_insert_breakpoint = kgdb_trgt_ignore_breakpoints; - kgdb_trgt_ops.to_remove_breakpoint = kgdb_trgt_ignore_breakpoints; - - add_target(&kgdb_trgt_ops); - - add_com ("proc", class_obscure, kgdb_set_proc_cmd, - "Set current process context"); - add_com ("tid", class_obscure, kgdb_set_tid_cmd, - "Set current thread context"); -} - -CORE_ADDR -kgdb_trgt_stop_pcb(u_int cpuid, u_int pcbsz) -{ - static int once = 0; - - if (stoppcbs == 0 && !once) { - once = 1; - stoppcbs = kgdb_lookup("stoppcbs"); - } - if (stoppcbs == 0) - return 0; - - return (stoppcbs + pcbsz * cpuid); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_amd64.c b/gnu/usr.bin/gdb/kgdb/trgt_amd64.c deleted file mode 100644 index ec0ac018033..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_amd64.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ - struct kthr *kt; - struct pcb pcb; - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - - supply_register(AMD64_RBX_REGNUM, (char *)&pcb.pcb_rbx); - supply_register(AMD64_RBP_REGNUM, (char *)&pcb.pcb_rbp); - supply_register(AMD64_RSP_REGNUM, (char *)&pcb.pcb_rsp); - supply_register(AMD64_R8_REGNUM + 4, (char *)&pcb.pcb_r12); - supply_register(AMD64_R8_REGNUM + 5, (char *)&pcb.pcb_r13); - supply_register(AMD64_R8_REGNUM + 6, (char *)&pcb.pcb_r14); - supply_register(AMD64_R15_REGNUM, (char *)&pcb.pcb_r15); - supply_register(AMD64_RIP_REGNUM, (char *)&pcb.pcb_rip); -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ -} - -struct kgdb_frame_cache { - CORE_ADDR pc; - CORE_ADDR sp; -}; - -static int kgdb_trgt_frame_offset[20] = { - offsetof(struct trapframe, tf_rax), - offsetof(struct trapframe, tf_rbx), - offsetof(struct trapframe, tf_rcx), - offsetof(struct trapframe, tf_rdx), - offsetof(struct trapframe, tf_rsi), - offsetof(struct trapframe, tf_rdi), - offsetof(struct trapframe, tf_rbp), - offsetof(struct trapframe, tf_rsp), - offsetof(struct trapframe, tf_r8), - offsetof(struct trapframe, tf_r9), - offsetof(struct trapframe, tf_r10), - offsetof(struct trapframe, tf_r11), - offsetof(struct trapframe, tf_r12), - offsetof(struct trapframe, tf_r13), - offsetof(struct trapframe, tf_r14), - offsetof(struct trapframe, tf_r15), - offsetof(struct trapframe, tf_rip), - offsetof(struct trapframe, tf_rflags), - offsetof(struct trapframe, tf_cs), - offsetof(struct trapframe, tf_ss) -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - cache->pc = frame_func_unwind(next_frame); - frame_unwind_register(next_frame, SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SP_REGNUM)); - } - return (cache); -} - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - int ofs, regsz; - - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - ofs = (regnum >= AMD64_RAX_REGNUM && regnum <= AMD64_EFLAGS_REGNUM + 2) - ? kgdb_trgt_frame_offset[regnum] : -1; - if (ofs == -1) - return; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *addrp = cache->sp + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ - char *pname; - CORE_ADDR pc; - - pc = frame_pc_unwind(next_frame); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) - return (NULL); - if (strcmp(pname, "calltrap") == 0 || - strcmp(pname, "fast_syscall_common") == 0 || - strcmp(pname, "mchk_calltrap") == 0 || - strcmp(pname, "nmi_calltrap") == 0 || - (pname[0] == 'X' && pname[1] != '_')) - return (&kgdb_trgt_trapframe_unwind); - /* printf("%s: %lx =%s\n", __func__, pc, pname); */ - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) -{ - - return (-1); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_arm.c b/gnu/usr.bin/gdb/kgdb/trgt_arm.c deleted file mode 100644 index 13111bc4346..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_arm.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#ifndef CROSS_DEBUGGER -#include -#include -#include -#endif -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ -#ifndef CROSS_DEBUGGER - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -#else - return -1; -#endif -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ -#ifndef CROSS_DEBUGGER - struct kthr *kt; - struct pcb pcb; - int i; - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - for (i = ARM_A1_REGNUM + 4; i <= ARM_SP_REGNUM; i++) { - supply_register(i, (char *)&pcb.pcb_regs.sf_r4 + - (i - (ARM_A1_REGNUM + 4 )) * 4); - } - supply_register(ARM_PC_REGNUM, (char *)&pcb.pcb_regs.sf_pc); - supply_register(ARM_LR_REGNUM, (char *)&pcb.pcb_regs.sf_lr); -#endif -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ -} - -#ifndef CROSS_DEBUGGER -struct kgdb_frame_cache { - CORE_ADDR fp; - CORE_ADDR sp; - CORE_ADDR pc; -}; - -static int kgdb_trgt_frame_offset[26] = { - offsetof(struct trapframe, tf_r0), - offsetof(struct trapframe, tf_r1), - offsetof(struct trapframe, tf_r2), - offsetof(struct trapframe, tf_r3), - offsetof(struct trapframe, tf_r4), - offsetof(struct trapframe, tf_r5), - offsetof(struct trapframe, tf_r6), - offsetof(struct trapframe, tf_r7), - offsetof(struct trapframe, tf_r8), - offsetof(struct trapframe, tf_r9), - offsetof(struct trapframe, tf_r10), - offsetof(struct trapframe, tf_r11), - offsetof(struct trapframe, tf_r12), - offsetof(struct trapframe, tf_svc_sp), - offsetof(struct trapframe, tf_svc_lr), - offsetof(struct trapframe, tf_pc), - -1, -1, -1, -1, -1, -1, -1, -1, -1, - offsetof(struct trapframe, tf_spsr) -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - frame_unwind_register(next_frame, ARM_SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, ARM_SP_REGNUM)); - frame_unwind_register(next_frame, ARM_FP_REGNUM, buf); - cache->fp = extract_unsigned_integer(buf, - register_size(current_gdbarch, ARM_FP_REGNUM)); - cache->pc = frame_func_unwind(next_frame); - } - return (cache); -} - -static int is_undef; - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - int ofs, regsz; - CORE_ADDR sp; - - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - ofs = (regnum >= 0 && regnum <= ARM_PS_REGNUM) - ? kgdb_trgt_frame_offset[regnum] : -1; - if (ofs == -1) - return; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - sp = cache->sp; - - ofs = kgdb_trgt_frame_offset[regnum]; - *addrp = sp + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; -#endif - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ -#ifndef CROSS_DEBUGGER - char *pname; - CORE_ADDR pc; - - pc = frame_pc_unwind(next_frame); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) { - is_undef = 0; - return (NULL); - } - if (!strcmp(pname, "undefinedinstruction")) - is_undef = 1; - if (strcmp(pname, "Laddress_exception_entry") == 0 || - strcmp(pname, "undefined_entry") == 0 || - strcmp(pname, "exception_exit") == 0 || - strcmp(pname, "Laddress_exception_msg") == 0 || - strcmp(pname, "irq_entry") == 0) - return (&kgdb_trgt_trapframe_unwind); - if (!strcmp(pname, "undefinedinstruction")) - is_undef = 1; - else - is_undef = 0; -#endif - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc) -{ -#ifndef CROSS_DEBUGGER - struct minimal_symbol *msymbol; - int valpc; - - /* - * exception_exit and swi_exit are special. These functions - * are artificially injected into the stack to be executed - * as the last entry in calling chain when all functions exit. - * Treat them differently. - */ - msymbol = lookup_minimal_symbol_by_pc(*pc); - if (msymbol != NULL) { - if (strcmp(DEPRECATED_SYMBOL_NAME(msymbol), "exception_exit") == 0) - return (0); - if (strcmp(DEPRECATED_SYMBOL_NAME(msymbol), "swi_exit") == 0) - return (0); - } - - /* - * kdb_enter contains an invalid instruction which is supposed - * to generate a trap. BFD does not understand it and treats - * this part of function as a separate function. Move PC - * two instruction earlier to be inside kdb_enter section. - */ - target_read_memory(*pc - 4, (char*)&valpc, 4); - if (valpc == 0xe7ffffff) { - *pc = *pc - 8; - return (0); - } - - /* - * When the panic/vpanic is the last (noreturn) function, - * the bottom of the calling function looks as below. - * mov lr, pc - * b panic - * Normally, GDB is not able to detect function boundaries, - * so move the PC two instruction earlier where it can deal - * with it. - * Match this pair of instructions: mov lr, pc followed with - * non-linked branch. - */ - if ((valpc & 0xff000000) == 0xea000000) { - target_read_memory(*pc - 8, (char*)&valpc, 4); - if (valpc == 0xe1a0e00f) { - *pc -= 8; - return (0); - } - } -#endif - return (-1); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_i386.c b/gnu/usr.bin/gdb/kgdb/trgt_i386.c deleted file mode 100644 index b90eebaaf35..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_i386.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -static int ofs_fix; - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ - struct kthr *kt; - struct pcb pcb; - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - supply_register(I386_EBX_REGNUM, (char *)&pcb.pcb_ebx); - supply_register(I386_ESP_REGNUM, (char *)&pcb.pcb_esp); - supply_register(I386_EBP_REGNUM, (char *)&pcb.pcb_ebp); - supply_register(I386_ESI_REGNUM, (char *)&pcb.pcb_esi); - supply_register(I386_EDI_REGNUM, (char *)&pcb.pcb_edi); - supply_register(I386_EIP_REGNUM, (char *)&pcb.pcb_eip); -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ - - /* - * In revision 1.117 of i386/i386/exception.S trap handlers - * were changed to pass trapframes by reference rather than - * by value. Detect this by seeing if the first instruction - * at the 'calltrap' label is a "push %esp" which has the - * opcode 0x54. - */ - if (kgdb_parse("((char *)calltrap)[0]") == 0x54) - ofs_fix = 4; - else - ofs_fix = 0; -} - -struct kgdb_tss_cache { - CORE_ADDR pc; - CORE_ADDR sp; - CORE_ADDR tss; -}; - -static int kgdb_trgt_tss_offset[15] = { - offsetof(struct i386tss, tss_eax), - offsetof(struct i386tss, tss_ecx), - offsetof(struct i386tss, tss_edx), - offsetof(struct i386tss, tss_ebx), - offsetof(struct i386tss, tss_esp), - offsetof(struct i386tss, tss_ebp), - offsetof(struct i386tss, tss_esi), - offsetof(struct i386tss, tss_edi), - offsetof(struct i386tss, tss_eip), - offsetof(struct i386tss, tss_eflags), - offsetof(struct i386tss, tss_cs), - offsetof(struct i386tss, tss_ss), - offsetof(struct i386tss, tss_ds), - offsetof(struct i386tss, tss_es), - offsetof(struct i386tss, tss_fs) -}; - -/* - * If the current thread is executing on a CPU, fetch the common_tss - * for that CPU. - * - * This is painful because 'struct pcpu' is variant sized, so we can't - * use it. Instead, we lookup the GDT selector for this CPU and - * extract the base of the TSS from there. - */ -static CORE_ADDR -kgdb_trgt_fetch_tss(void) -{ - struct kthr *kt; - struct segment_descriptor sd; - uintptr_t addr, cpu0prvpage, tss; - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL || kt->cpu == NOCPU || kt->cpu < 0) - return (0); - - addr = kgdb_lookup("gdt"); - if (addr == 0) - return (0); - addr += (kt->cpu * NGDT + GPROC0_SEL) * sizeof(sd); - if (kvm_read(kvm, addr, &sd, sizeof(sd)) != sizeof(sd)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - return (0); - } - if (sd.sd_type != SDT_SYS386BSY) { - warnx("descriptor is not a busy TSS"); - return (0); - } - tss = sd.sd_hibase << 24 | sd.sd_lobase; - - /* - * In SMP kernels, the TSS is stored as part of the per-CPU - * data. On older kernels, the CPU0's private page - * is stored at an address that isn't mapped in minidumps. - * However, the data is mapped at the alternate cpu0prvpage - * address. Thus, if the TSS is at the invalid address, - * change it to be relative to cpu0prvpage instead. - */ - if (trunc_page(tss) == 0xffc00000) { - addr = kgdb_lookup("cpu0prvpage"); - if (addr == 0) - return (0); - if (kvm_read(kvm, addr, &cpu0prvpage, sizeof(cpu0prvpage)) != - sizeof(cpu0prvpage)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - return (0); - } - tss = cpu0prvpage + (tss & PAGE_MASK); - } - return ((CORE_ADDR)tss); -} - -static struct kgdb_tss_cache * -kgdb_trgt_tss_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_tss_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_tss_cache); - *this_cache = cache; - cache->pc = frame_func_unwind(next_frame); - frame_unwind_register(next_frame, SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SP_REGNUM)); - cache->tss = kgdb_trgt_fetch_tss(); - } - return (cache); -} - -static void -kgdb_trgt_dblfault_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_tss_cache *cache; - - cache = kgdb_trgt_tss_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_dblfault_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct kgdb_tss_cache *cache; - int ofs, regsz; - - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - ofs = (regnum >= I386_EAX_REGNUM && regnum <= I386_FS_REGNUM) - ? kgdb_trgt_tss_offset[regnum] : -1; - if (ofs == -1) - return; - - cache = kgdb_trgt_tss_cache(next_frame, this_cache); - if (cache->tss == 0) - return; - *addrp = cache->tss + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_dblfault_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_dblfault_this_id, - &kgdb_trgt_dblfault_prev_register -}; - -struct kgdb_frame_cache { - int frame_type; - CORE_ADDR pc; - CORE_ADDR sp; -}; -#define FT_NORMAL 1 -#define FT_INTRFRAME 2 -#define FT_INTRTRAPFRAME 3 -#define FT_TIMERFRAME 4 - -static int kgdb_trgt_frame_offset[15] = { - offsetof(struct trapframe, tf_eax), - offsetof(struct trapframe, tf_ecx), - offsetof(struct trapframe, tf_edx), - offsetof(struct trapframe, tf_ebx), - offsetof(struct trapframe, tf_esp), - offsetof(struct trapframe, tf_ebp), - offsetof(struct trapframe, tf_esi), - offsetof(struct trapframe, tf_edi), - offsetof(struct trapframe, tf_eip), - offsetof(struct trapframe, tf_eflags), - offsetof(struct trapframe, tf_cs), - offsetof(struct trapframe, tf_ss), - offsetof(struct trapframe, tf_ds), - offsetof(struct trapframe, tf_es), - offsetof(struct trapframe, tf_fs) -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - char *pname; - CORE_ADDR pcx; - uintptr_t addr, setidt_disp; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - pcx = frame_pc_unwind(next_frame); - if (pcx >= PMAP_TRM_MIN_ADDRESS) { - addr = kgdb_lookup("setidt_disp"); - if (addr != 0) { - if (kvm_read(kvm, addr, &setidt_disp, - sizeof(setidt_disp)) != - sizeof(setidt_disp)) - warnx("kvm_read: %s", kvm_geterr(kvm)); - else - pcx -= setidt_disp; - } - } - cache->pc = pcx; - find_pc_partial_function(cache->pc, &pname, NULL, NULL); - if (pname[0] != 'X') - cache->frame_type = FT_NORMAL; - else if (strcmp(pname, "Xtimerint") == 0) - cache->frame_type = FT_TIMERFRAME; - else if (strcmp(pname, "Xcpustop") == 0 || - strcmp(pname, "Xrendezvous") == 0 || - strcmp(pname, "Xipi_intr_bitmap_handler") == 0 || - strcmp(pname, "Xlazypmap") == 0) - cache->frame_type = FT_INTRTRAPFRAME; - else - cache->frame_type = FT_INTRFRAME; - frame_unwind_register(next_frame, SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SP_REGNUM)); - } - return (cache); -} - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - int ofs, regsz; - - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - ofs = (regnum >= I386_EAX_REGNUM && regnum <= I386_FS_REGNUM) - ? kgdb_trgt_frame_offset[regnum] + ofs_fix : -1; - if (ofs == -1) - return; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - switch (cache->frame_type) { - case FT_NORMAL: - break; - case FT_INTRFRAME: - ofs += 4; - break; - case FT_TIMERFRAME: - break; - case FT_INTRTRAPFRAME: - ofs -= ofs_fix; - break; - default: - fprintf_unfiltered(gdb_stderr, "Correct FT_XXX frame offsets " - "for %d\n", cache->frame_type); - break; - } - *addrp = cache->sp + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ - char *pname; - CORE_ADDR pc; - - pc = frame_pc_unwind(next_frame); - if (pc >= PMAP_TRM_MIN_ADDRESS) - return (&kgdb_trgt_trapframe_unwind); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) - return (NULL); - if (strcmp(pname, "dblfault_handler") == 0) - return (&kgdb_trgt_dblfault_unwind); - if (strcmp(pname, "calltrap") == 0 || - (pname[0] == 'X' && pname[1] != '_')) - return (&kgdb_trgt_trapframe_unwind); - /* printf("%s: %llx =%s\n", __func__, pc, pname); */ - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) -{ - - return (-1); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_mips.c b/gnu/usr.bin/gdb/kgdb/trgt_mips.c deleted file mode 100644 index 17ea6fe4ca1..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_mips.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2007 Juniper Networks, Inc. - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from: src/gnu/usr.bin/gdb/kgdb/trgt_alpha.c,v 1.2.2.1 2005/09/15 05:32:10 marcel - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifndef CROSS_DEBUGGER -#include -#endif - -#include "kgdb.h" - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ -#ifndef CROSS_DEBUGGER - struct kthr *kt; - struct pcb pcb; - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - - supply_register(MIPS_S0_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S0]); - supply_register(MIPS_S1_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S1]); - supply_register(MIPS_S2_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S2]); - supply_register(MIPS_S3_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S3]); - supply_register(MIPS_S4_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S4]); - supply_register(MIPS_S5_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S5]); - supply_register(MIPS_S6_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S6]); - supply_register(MIPS_S7_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S7]); - supply_register(MIPS_SP_REGNUM, (char *)&pcb.pcb_context[PCB_REG_SP]); - supply_register(MIPS_FP_REGNUM, (char *)&pcb.pcb_context[PCB_REG_GP]); - supply_register(MIPS_RA_REGNUM, (char *)&pcb.pcb_context[PCB_REG_RA]); - supply_register(MIPS_EMBED_PC_REGNUM, (char *)&pcb.pcb_context[PCB_REG_PC]); -#endif -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - - fprintf_unfiltered(gdb_stderr, "Unimplemented function: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ -} - -#ifndef CROSS_DEBUGGER -struct kgdb_frame_cache { - CORE_ADDR pc; - CORE_ADDR sp; -}; - -static int kgdb_trgt_frame_offset[] = { - offsetof(struct trapframe, zero), - offsetof(struct trapframe, ast), - offsetof(struct trapframe, v0), - offsetof(struct trapframe, v1), - offsetof(struct trapframe, a0), - offsetof(struct trapframe, a1), - offsetof(struct trapframe, a2), - offsetof(struct trapframe, a3), -#if defined(__mips_n32) || defined(__mips_n64) - offsetof(struct trapframe, a4), - offsetof(struct trapframe, a5), - offsetof(struct trapframe, a6), - offsetof(struct trapframe, a7), - offsetof(struct trapframe, t0), - offsetof(struct trapframe, t1), - offsetof(struct trapframe, t2), - offsetof(struct trapframe, t3), -#else - offsetof(struct trapframe, t0), - offsetof(struct trapframe, t1), - offsetof(struct trapframe, t2), - offsetof(struct trapframe, t3), - offsetof(struct trapframe, t4), - offsetof(struct trapframe, t5), - offsetof(struct trapframe, t6), - offsetof(struct trapframe, t7), -#endif - offsetof(struct trapframe, s0), - offsetof(struct trapframe, s1), - offsetof(struct trapframe, s2), - offsetof(struct trapframe, s3), - offsetof(struct trapframe, s4), - offsetof(struct trapframe, s5), - offsetof(struct trapframe, s6), - offsetof(struct trapframe, s7), - offsetof(struct trapframe, t8), - offsetof(struct trapframe, t9), - offsetof(struct trapframe, k0), - offsetof(struct trapframe, k1), - offsetof(struct trapframe, gp), - offsetof(struct trapframe, sp), - offsetof(struct trapframe, s8), - offsetof(struct trapframe, ra), -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - cache->pc = frame_func_unwind(next_frame); - frame_unwind_register(next_frame, SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SP_REGNUM)); - } - return (cache); -} - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame __unused, - void **this_cache __unused, int regnum __unused, int *optimizedp __unused, - enum lval_type *lvalp __unused, CORE_ADDR *addrp __unused, - int *realnump __unused, void *valuep __unused) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - int ofs, regsz; - - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - ofs = (regnum >= 0 && regnum <= MIPS_RA_REGNUM) ? - kgdb_trgt_frame_offset[regnum] : -1; - if (ofs == -1) - return; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *addrp = cache->sp + ofs * 8; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; -#endif - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ -#ifndef CROSS_DEBUGGER - char *pname; - CORE_ADDR pc; - - pc = frame_pc_unwind(next_frame); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) - return (NULL); - if ((strcmp(pname, "MipsKernIntr") == 0) || - (strcmp(pname, "MipsKernGenException") == 0) || - (strcmp(pname, "MipsUserIntr") == 0) || - (strcmp(pname, "MipsUserGenException") == 0)) - return (&kgdb_trgt_trapframe_unwind); -#endif - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) -{ - - return (-1); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c b/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c deleted file mode 100644 index 703cc0f716f..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * Copyright (c) 2006 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#ifdef CROSS_DEBUGGER -#include -#include -#else -#include -#include -#endif -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ - struct kthr *kt; - struct pcb pcb; - struct gdbarch_tdep *tdep; - int i; - - tdep = gdbarch_tdep (current_gdbarch); - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - - /* - * r14-r31 are saved in the pcb - */ - for (i = 14; i <= 31; i++) { - supply_register(tdep->ppc_gp0_regnum + i, - (char *)&pcb.pcb_context[i]); - } - - /* r1 is saved in the sp field */ - supply_register(tdep->ppc_gp0_regnum + 1, (char *)&pcb.pcb_sp); - - supply_register(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); - supply_register(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ -} - -struct kgdb_frame_cache { - CORE_ADDR pc; - CORE_ADDR sp; -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - cache->pc = frame_func_unwind(next_frame); - frame_unwind_register(next_frame, SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SP_REGNUM)); - } - return (cache); -} - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct gdbarch_tdep *tdep; - struct kgdb_frame_cache *cache; - int ofs, regsz; - - tdep = gdbarch_tdep(current_gdbarch); - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - if (regnum >= tdep->ppc_gp0_regnum && - regnum <= tdep->ppc_gplast_regnum) - ofs = offsetof(struct trapframe, - fixreg[regnum - tdep->ppc_gp0_regnum]); - else if (regnum == tdep->ppc_lr_regnum) - ofs = offsetof(struct trapframe, lr); - else if (regnum == tdep->ppc_cr_regnum) - ofs = offsetof(struct trapframe, cr); - else if (regnum == tdep->ppc_xer_regnum) - ofs = offsetof(struct trapframe, xer); - else if (regnum == tdep->ppc_ctr_regnum) - ofs = offsetof(struct trapframe, ctr); - else if (regnum == PC_REGNUM) - ofs = offsetof(struct trapframe, srr0); - else - return; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *addrp = cache->sp + 8 + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ - char *pname; - CORE_ADDR pc; - - pc = frame_pc_unwind(next_frame); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) - return (NULL); - if (strcmp(pname, "asttrapexit") == 0 || - strcmp(pname, "trapexit") == 0) - return (&kgdb_trgt_trapframe_unwind); - /* printf("%s: %llx =%s\n", __func__, pc, pname); */ - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) -{ - - return (-1); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c b/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c deleted file mode 100644 index bfb0d7eed87..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * Copyright (c) 2006 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ - struct kthr *kt; - struct pcb pcb; - struct gdbarch_tdep *tdep; - int i; - - tdep = gdbarch_tdep (current_gdbarch); - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - - /* - * r14-r31 are saved in the pcb - */ - for (i = 14; i <= 31; i++) { - supply_register(tdep->ppc_gp0_regnum + i, - (char *)&pcb.pcb_context[i]); - } - - /* r1 is saved in the sp field */ - supply_register(tdep->ppc_gp0_regnum + 1, (char *)&pcb.pcb_sp); - /* r2 is saved in the toc field */ - supply_register(tdep->ppc_gp0_regnum + 2, (char *)&pcb.pcb_toc); - - supply_register(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); - supply_register(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ -} - -struct kgdb_frame_cache { - CORE_ADDR pc; - CORE_ADDR sp; -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - cache->pc = frame_func_unwind(next_frame); - frame_unwind_register(next_frame, SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SP_REGNUM)); - } - return (cache); -} - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct gdbarch_tdep *tdep; - struct kgdb_frame_cache *cache; - int ofs, regsz; - - tdep = gdbarch_tdep(current_gdbarch); - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - if (regnum >= tdep->ppc_gp0_regnum && - regnum <= tdep->ppc_gplast_regnum) - ofs = offsetof(struct trapframe, - fixreg[regnum - tdep->ppc_gp0_regnum]); - else if (regnum == tdep->ppc_lr_regnum) - ofs = offsetof(struct trapframe, lr); - else if (regnum == tdep->ppc_cr_regnum) - ofs = offsetof(struct trapframe, cr); - else if (regnum == tdep->ppc_xer_regnum) - ofs = offsetof(struct trapframe, xer); - else if (regnum == tdep->ppc_ctr_regnum) - ofs = offsetof(struct trapframe, ctr); - else if (regnum == PC_REGNUM) - ofs = offsetof(struct trapframe, srr0); - else - return; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *addrp = cache->sp + 48 + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ - char *pname; - CORE_ADDR pc; - - pc = frame_pc_unwind(next_frame); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) - return (NULL); - if (strcmp(pname, "asttrapexit") == 0 || - strcmp(pname, "trapexit") == 0) - return (&kgdb_trgt_trapframe_unwind); - /* printf("%s: %llx =%s\n", __func__, pc, pname); */ - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) -{ - - return (-1); -} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c b/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c deleted file mode 100644 index b39299f4091..00000000000 --- a/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kgdb.h" - -CORE_ADDR -kgdb_trgt_core_pcb(u_int cpuid) -{ - return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); -} - -void -kgdb_trgt_fetch_registers(int regno __unused) -{ - struct kthr *kt; - struct pcb pcb; - - kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); - if (kt == NULL) - return; - if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { - warnx("kvm_read: %s", kvm_geterr(kvm)); - memset(&pcb, 0, sizeof(pcb)); - } - - supply_register(SPARC_SP_REGNUM, (char *)&pcb.pcb_sp); - sparc_supply_rwindow(current_regcache, pcb.pcb_sp, -1); - supply_register(SPARC64_PC_REGNUM, (char *)&pcb.pcb_pc); - pcb.pcb_pc += 4; - supply_register(SPARC64_NPC_REGNUM, (char *)&pcb.pcb_pc); -} - -void -kgdb_trgt_store_registers(int regno __unused) -{ - fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); -} - -void -kgdb_trgt_new_objfile(struct objfile *objfile) -{ -} - -struct kgdb_frame_cache { - CORE_ADDR pc; - CORE_ADDR sp; - CORE_ADDR fp; -}; - -static struct kgdb_frame_cache * -kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) -{ - char buf[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - - cache = *this_cache; - if (cache == NULL) { - cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); - *this_cache = cache; - cache->pc = frame_func_unwind(next_frame); - frame_unwind_register(next_frame, SPARC_SP_REGNUM, buf); - cache->sp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SPARC_SP_REGNUM)); - frame_unwind_register(next_frame, SPARC_FP_REGNUM, buf); - cache->fp = extract_unsigned_integer(buf, - register_size(current_gdbarch, SPARC_FP_REGNUM)); - cache->fp += BIAS - sizeof(struct trapframe); - } - return (cache); -} - -static void -kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, - struct frame_id *this_id) -{ - struct kgdb_frame_cache *cache; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *this_id = frame_id_build(cache->sp, cache->pc); -} - -static void -kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, - void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, - CORE_ADDR *addrp, int *realnump, void *valuep) -{ - char dummy_valuep[MAX_REGISTER_SIZE]; - struct kgdb_frame_cache *cache; - int ofs, regsz; - - regsz = register_size(current_gdbarch, regnum); - - if (valuep == NULL) - valuep = dummy_valuep; - memset(valuep, 0, regsz); - *optimizedp = 0; - *addrp = 0; - *lvalp = not_lval; - *realnump = -1; - - cache = kgdb_trgt_frame_cache(next_frame, this_cache); - - switch (regnum) { - case SPARC_SP_REGNUM: - ofs = offsetof(struct trapframe, tf_sp); - break; - case SPARC64_PC_REGNUM: - ofs = offsetof(struct trapframe, tf_tpc); - break; - case SPARC64_NPC_REGNUM: - ofs = offsetof(struct trapframe, tf_tnpc); - break; - case SPARC_O0_REGNUM: - case SPARC_O1_REGNUM: - case SPARC_O2_REGNUM: - case SPARC_O3_REGNUM: - case SPARC_O4_REGNUM: - case SPARC_O5_REGNUM: - case SPARC_O7_REGNUM: - ofs = offsetof(struct trapframe, tf_out) + - (regnum - SPARC_O0_REGNUM) * 8; - break; - default: - if (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) { - ofs = (regnum - SPARC_L0_REGNUM) * 8; - *addrp = cache->sp + BIAS + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); - } - return; - } - - *addrp = cache->fp + ofs; - *lvalp = lval_memory; - target_read_memory(*addrp, valuep, regsz); -} - -static const struct frame_unwind kgdb_trgt_trapframe_unwind = { - UNKNOWN_FRAME, - &kgdb_trgt_trapframe_this_id, - &kgdb_trgt_trapframe_prev_register -}; - -const struct frame_unwind * -kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) -{ - char *pname; - CORE_ADDR pc; - - pc = frame_func_unwind(next_frame); - pname = NULL; - find_pc_partial_function(pc, &pname, NULL, NULL); - if (pname == NULL) - return (NULL); - if (strcmp(pname, "tl0_intr") == 0 || - strcmp(pname, "tl0_trap") == 0 || - strcmp(pname, "tl1_intr") == 0 || - strcmp(pname, "tl1_trap") == 0) - return (&kgdb_trgt_trapframe_unwind); - /* printf("%s: %lx =%s\n", __func__, pc, pname); */ - return (NULL); -} - -/* - * This function ensures, that the PC is inside the - * function section which is understood by GDB. - * - * Return 0 when fixup is necessary, -1 otherwise. - */ -int -kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) -{ - - return (-1); -} diff --git a/gnu/usr.bin/gdb/libgdb/Makefile b/gnu/usr.bin/gdb/libgdb/Makefile deleted file mode 100644 index 8c27c58907e..00000000000 --- a/gnu/usr.bin/gdb/libgdb/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -# $FreeBSD$ - -# These assignments duplicate much of the functionality of -# MACHINE_CPUARCH, but there's no easy way to export make functions... - -.if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} -.else -TARGET_CPUARCH=${MACHINE_CPUARCH} -.endif -TARGET_ARCH?= ${MACHINE_ARCH} - -LIB= gdb -INTERNALLIB= -SRCS= annotate.c arch-utils.c auxv.c ax-gdb.c ax-general.c \ - bcache.c bfd-target.c block.c blockframe.c breakpoint.c \ - buildsym.c \ - c-exp.y c-lang.c c-typeprint.c c-valprint.c charset.c \ - cli-cmds.c cli-decode.c cli-dump.c cli-interp.c cli-logging.c \ - cli-out.c cli-script.c cli-setshow.c cli-utils.c coff-pe-read.c \ - coffread.c complaints.c completer.c copying.c corefile.c \ - corelow.c cp-abi.c cp-namespace.c cp-support.c cp-valprint.c \ - dbxread.c dcache.c demangle.c dictionary.c disasm.c doublest.c \ - dummy-frame.c dwarf2-frame.c dwarf2expr.c dwarf2loc.c \ - dwarf2read.c dwarfread.c \ - elfread.c environ.c eval.c event-loop.c event-top.c exec.c \ - expprint.c \ - f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c \ - ${_fork_child} frame-base.c frame-unwind.c frame.c \ - gdb-events.c gdbarch.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \ - hpacc-abi.c \ - inf-loop.c infcall.c infcmd.c inflow.c ${_infptrace} infrun.c \ - ${_inftarg} init.c interps.c \ - jv-exp.y jv-lang.c jv-typeprint.c jv-valprint.c \ - kod-cisco.c kod.c \ - language.c linespec.c \ - m2-exp.y m2-lang.c m2-typeprint.c m2-valprint.c macrocmd.c \ - macroexp.c macroscope.c macrotab.c main.c maint.c mdebugread.c \ - mem-break.c memattr.c mi-cmd-break.c mi-cmd-disas.c \ - mi-cmd-env.c mi-cmd-file.c mi-cmd-stack.c mi-cmd-var.c \ - mi-cmds.c mi-console.c mi-getopt.c mi-interp.c mi-main.c \ - mi-out.c mi-parse.c mi-symbol-cmds.c minsyms.c mipsread.c \ - nlmread.c \ - objc-exp.y objc-lang.c objfiles.c observer.c osabi.c \ - p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \ - regcache.c reggroups.c remote-fileio.c remote-utils.c remote.c \ - scm-exp.c scm-lang.c scm-valprint.c sentinel-frame.c ser-pipe.c \ - ser-tcp.c ser-unix.c serial.c signals.c source.c stabsread.c \ - stack.c std-regs.c symfile.c symmisc.c symtab.c \ - target.c thread.c top.c tracepoint.c trad-frame.c tui-command.c \ - tui-data.c tui-disasm.c tui-file.c tui-hooks.c tui-interp.c \ - tui-io.c tui-layout.c tui-out.c tui-regs.c tui-source.c \ - tui-stack.c tui-win.c tui-windata.c tui-wingeneral.c \ - tui-winsource.c tui.c typeprint.c \ - ui-file.c ui-out.c user-regs.c utils.c \ - valarith.c valops.c valprint.c values.c varobj.c \ - wrapper.c ${LIBSRCS} - -.for stupid_gnu in \ -xregcomp xre_exec xregexec xre_search xre_compile_fastmap xregerror xre_comp xre_set_syntax -CFLAGS+= -D${stupid_gnu}=${stupid_gnu:S/^x//} -.endfor - -.if ${TARGET_ARCH} == ${MACHINE_ARCH} -_fork_child= fork-child.c -_infptrace= infptrace.c -_inftarg= inftarg.c -.endif - -GENSRCS= version.c - -version.c: - echo '#include "version.h"' > ${.TARGET} - echo 'const char version[] = ${VERSION};' >> ${.TARGET} - echo 'const char host_name[] = "${MACHINE_ARCH}-${VENDOR}-freebsd";' \ - >> ${.TARGET} - echo 'const char target_name[] = "${TARGET_ARCH}-${VENDOR}-freebsd";' \ - >> ${.TARGET} - -.include diff --git a/gnu/usr.bin/gdb/libgdb/Makefile.depend b/gnu/usr.bin/gdb/libgdb/Makefile.depend deleted file mode 100644 index 80f12f7059a..00000000000 --- a/gnu/usr.bin/gdb/libgdb/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/libreadline/readline \ - include \ - include/arpa \ - include/xlocale \ - lib/libthread_db \ - lib/msun \ - lib/ncurses/ncursesw \ - usr.bin/yacc.host \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/gdb/libgdb/fbsd-threads.c b/gnu/usr.bin/gdb/libgdb/fbsd-threads.c deleted file mode 100644 index 78819a743e5..00000000000 --- a/gnu/usr.bin/gdb/libgdb/fbsd-threads.c +++ /dev/null @@ -1,1799 +0,0 @@ -/* $FreeBSD$ */ -/* FreeBSD libthread_db assisted debugging support. - Copyright 1999, 2000, 2001 Free Software Foundation, Inc. - - This file is part of GDB. - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include -#include - -#include "proc_service.h" -#include "thread_db.h" - -#include "defs.h" -#include "bfd.h" -#include "elf-bfd.h" -#include "gdb_assert.h" -#include "gdbcore.h" -#include "gdbthread.h" -#include "inferior.h" -#include "objfiles.h" -#include "regcache.h" -#include "symfile.h" -#include "symtab.h" -#include "target.h" -#include "gdbcmd.h" -#include "solib-svr4.h" - -#include "gregset.h" -#ifdef PT_GETXMMREGS -#include "i387-tdep.h" -#endif - -#define LIBTHREAD_DB_SO "libthread_db.so" - -struct ps_prochandle -{ - pid_t pid; -}; - -extern int child_suppress_run; - -extern struct target_ops child_ops; - -/* This module's target vectors. */ -static struct target_ops fbsd_thread_ops; -static struct target_ops fbsd_core_ops; - -/* Saved copy of orignal core_ops. */ -static struct target_ops orig_core_ops; -extern struct target_ops core_ops; - -/* Pointer to the next function on the objfile event chain. */ -static void (*target_new_objfile_chain) (struct objfile *objfile); - -/* Non-zero if there is a thread module */ -static int fbsd_thread_present; - -/* Non-zero if we're using this module's target vector. */ -static int fbsd_thread_active; - -/* Non-zero if core_open is called */ -static int fbsd_thread_core = 0; - -/* Non-zero if we have to keep this module's target vector active - across re-runs. */ -static int keep_thread_db; - -/* Structure that identifies the child process for the - interface. */ -static struct ps_prochandle proc_handle; - -/* Connection to the libthread_db library. */ -static td_thragent_t *thread_agent; - -/* The last thread we are single stepping */ -static ptid_t last_single_step_thread; - -/* Pointers to the libthread_db functions. */ - -static td_err_e (*td_init_p) (void); - -static td_err_e (*td_ta_new_p) (struct ps_prochandle *ps, td_thragent_t **ta); -static td_err_e (*td_ta_delete_p) (td_thragent_t *); -static td_err_e (*td_ta_map_id2thr_p) (const td_thragent_t *ta, thread_t pt, - td_thrhandle_t *__th); -static td_err_e (*td_ta_map_lwp2thr_p) (const td_thragent_t *ta, lwpid_t lwpid, - td_thrhandle_t *th); -static td_err_e (*td_ta_thr_iter_p) (const td_thragent_t *ta, - td_thr_iter_f *callback, - void *cbdata_p, td_thr_state_e state, - int ti_pri, sigset_t *ti_sigmask_p, - unsigned int ti_user_flags); -static td_err_e (*td_ta_event_addr_p) (const td_thragent_t *ta, - td_event_e event, td_notify_t *ptr); -static td_err_e (*td_ta_set_event_p) (const td_thragent_t *ta, - td_thr_events_t *event); -static td_err_e (*td_ta_event_getmsg_p) (const td_thragent_t *ta, - td_event_msg_t *msg); -static td_err_e (*td_thr_get_info_p) (const td_thrhandle_t *th, - td_thrinfo_t *infop); -#ifdef PT_GETXMMREGS -static td_err_e (*td_thr_getxmmregs_p) (const td_thrhandle_t *th, - char *regset); -#endif -static td_err_e (*td_thr_getfpregs_p) (const td_thrhandle_t *th, - prfpregset_t *regset); -static td_err_e (*td_thr_getgregs_p) (const td_thrhandle_t *th, - prgregset_t gregs); -#ifdef PT_GETXMMREGS -static td_err_e (*td_thr_setxmmregs_p) (const td_thrhandle_t *th, - const char *fpregs); -#endif -static td_err_e (*td_thr_setfpregs_p) (const td_thrhandle_t *th, - const prfpregset_t *fpregs); -static td_err_e (*td_thr_setgregs_p) (const td_thrhandle_t *th, - prgregset_t gregs); -static td_err_e (*td_thr_event_enable_p) (const td_thrhandle_t *th, int event); - -static td_err_e (*td_thr_sstep_p) (td_thrhandle_t *th, int step); - -static td_err_e (*td_ta_tsd_iter_p) (const td_thragent_t *ta, - td_key_iter_f *func, void *data); -static td_err_e (*td_thr_tls_get_addr_p) (const td_thrhandle_t *th, - void *map_address, - size_t offset, void **address); -static td_err_e (*td_thr_dbsuspend_p) (const td_thrhandle_t *); -static td_err_e (*td_thr_dbresume_p) (const td_thrhandle_t *); - -static CORE_ADDR td_create_bp_addr; - -/* Location of the thread death event breakpoint. */ -static CORE_ADDR td_death_bp_addr; - -/* Prototypes for local functions. */ -static void fbsd_thread_find_new_threads (void); -static int fbsd_thread_alive (ptid_t ptid); -static void attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, - const td_thrinfo_t *ti_p, int verbose); -static void fbsd_thread_detach (char *args, int from_tty); - -/* Building process ids. */ - -#define GET_PID(ptid) ptid_get_pid (ptid) -#define GET_LWP(ptid) ptid_get_lwp (ptid) -#define GET_THREAD(ptid) ptid_get_tid (ptid) - -#define IS_LWP(ptid) (GET_LWP (ptid) != 0) -#define IS_THREAD(ptid) (GET_THREAD (ptid) != 0) - -#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) -#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid) - -static char * -thread_db_err_str (td_err_e err) -{ - static char buf[64]; - - switch (err) - { - case TD_OK: - return "generic 'call succeeded'"; - case TD_ERR: - return "generic error"; - case TD_NOTHR: - return "no thread to satisfy query"; - case TD_NOSV: - return "no sync handle to satisfy query"; - case TD_NOLWP: - return "no LWP to satisfy query"; - case TD_BADPH: - return "invalid process handle"; - case TD_BADTH: - return "invalid thread handle"; - case TD_BADSH: - return "invalid synchronization handle"; - case TD_BADTA: - return "invalid thread agent"; - case TD_BADKEY: - return "invalid key"; - case TD_NOMSG: - return "no event message for getmsg"; - case TD_NOFPREGS: - return "FPU register set not available"; - case TD_NOLIBTHREAD: - return "application not linked with libthread"; - case TD_NOEVENT: - return "requested event is not supported"; - case TD_NOCAPAB: - return "capability not available"; - case TD_DBERR: - return "debugger service failed"; - case TD_NOAPLIC: - return "operation not applicable to"; - case TD_NOTSD: - return "no thread-specific data for this thread"; - case TD_MALLOC: - return "malloc failed"; - case TD_PARTIALREG: - return "only part of register set was written/read"; - case TD_NOXREGS: - return "X register set not available for this thread"; - default: - snprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err); - return buf; - } -} - -static char * -thread_db_state_str (td_thr_state_e state) -{ - static char buf[64]; - - switch (state) - { - case TD_THR_STOPPED: - return "stopped by debugger"; - case TD_THR_RUN: - return "runnable"; - case TD_THR_ACTIVE: - return "active"; - case TD_THR_ZOMBIE: - return "zombie"; - case TD_THR_SLEEP: - return "sleeping"; - case TD_THR_STOPPED_ASLEEP: - return "stopped by debugger AND blocked"; - default: - snprintf (buf, sizeof (buf), "unknown thread_db state %d", state); - return buf; - } -} - -/* Convert LWP to user-level thread id. */ -static ptid_t -thread_from_lwp (ptid_t ptid, td_thrhandle_t *th, td_thrinfo_t *ti) -{ - td_err_e err; - - gdb_assert (IS_LWP (ptid)); - - if (fbsd_thread_active) - { - err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), th); - if (err == TD_OK) - { - err = td_thr_get_info_p (th, ti); - if (err != TD_OK) - error ("Cannot get thread info: %s", thread_db_err_str (err)); - return BUILD_THREAD (ti->ti_tid, GET_PID (ptid)); - } - } - - /* the LWP is not mapped to user thread */ - return BUILD_LWP (GET_LWP (ptid), GET_PID (ptid)); -} - -static void -fbsd_core_get_first_lwp (bfd *abfd, asection *asect, void *obj) -{ - if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) - return; - - if (*(lwpid_t *)obj != 0) - return; - - *(lwpid_t *)obj = atoi (bfd_section_name (abfd, asect) + 5); -} - -static long -get_current_lwp (int pid) -{ - struct ptrace_lwpinfo pl; - lwpid_t lwpid; - - if (!target_has_execution) - { - lwpid = 0; - bfd_map_over_sections (core_bfd, fbsd_core_get_first_lwp, &lwpid); - return lwpid; - } - if (ptrace (PT_LWPINFO, pid, (caddr_t)&pl, sizeof(pl))) - perror_with_name("PT_LWPINFO"); - - return (long)pl.pl_lwpid; -} - -static void -get_current_thread () -{ - td_thrhandle_t th; - td_thrinfo_t ti; - long lwp; - ptid_t tmp, ptid; - - lwp = get_current_lwp (proc_handle.pid); - tmp = BUILD_LWP (lwp, proc_handle.pid); - ptid = thread_from_lwp (tmp, &th, &ti); - if (!in_thread_list (ptid)) - { - attach_thread (ptid, &th, &ti, 1); - } - inferior_ptid = ptid; -} - -static td_err_e -enable_thread_event (td_thragent_t *thread_agent, int event, CORE_ADDR *bp) -{ - td_notify_t notify; - td_err_e err; - - /* Get the breakpoint address for thread EVENT. */ - err = td_ta_event_addr_p (thread_agent, event, ¬ify); - if (err != TD_OK) - return err; - - /* Set up the breakpoint. */ - (*bp) = gdbarch_convert_from_func_ptr_addr (current_gdbarch, - extract_typed_address(¬ify.u.bptaddr, builtin_type_void_func_ptr), - ¤t_target); - create_thread_event_breakpoint ((*bp)); - - return TD_OK; -} - -static void -enable_thread_event_reporting (void) -{ - td_thr_events_t events; - td_notify_t notify; - td_err_e err; - - /* We cannot use the thread event reporting facility if these - functions aren't available. */ - if (td_ta_event_addr_p == NULL || td_ta_set_event_p == NULL - || td_ta_event_getmsg_p == NULL || td_thr_event_enable_p == NULL) - return; - - /* Set the process wide mask saying which events we're interested in. */ - td_event_emptyset (&events); - td_event_addset (&events, TD_CREATE); - td_event_addset (&events, TD_DEATH); - - err = td_ta_set_event_p (thread_agent, &events); - if (err != TD_OK) - { - warning ("Unable to set global thread event mask: %s", - thread_db_err_str (err)); - return; - } - - /* Delete previous thread event breakpoints, if any. */ - remove_thread_event_breakpoints (); - td_create_bp_addr = 0; - td_death_bp_addr = 0; - - /* Set up the thread creation event. */ - err = enable_thread_event (thread_agent, TD_CREATE, &td_create_bp_addr); - if (err != TD_OK) - { - warning ("Unable to get location for thread creation breakpoint: %s", - thread_db_err_str (err)); - return; - } - - /* Set up the thread death event. */ - err = enable_thread_event (thread_agent, TD_DEATH, &td_death_bp_addr); - if (err != TD_OK) - { - warning ("Unable to get location for thread death breakpoint: %s", - thread_db_err_str (err)); - return; - } -} - -static void -disable_thread_event_reporting (void) -{ - td_thr_events_t events; - - /* Set the process wide mask saying we aren't interested in any - events anymore. */ - td_event_emptyset (&events); - td_ta_set_event_p (thread_agent, &events); - - /* Delete thread event breakpoints, if any. */ - remove_thread_event_breakpoints (); - td_create_bp_addr = 0; - td_death_bp_addr = 0; -} - -static void -fbsd_thread_activate (void) -{ - fbsd_thread_active = 1; - init_thread_list(); - if (fbsd_thread_core == 0) - enable_thread_event_reporting (); - fbsd_thread_find_new_threads (); - get_current_thread (); -} - -static void -fbsd_thread_deactivate (void) -{ - if (fbsd_thread_core == 0) - disable_thread_event_reporting(); - td_ta_delete_p (thread_agent); - - inferior_ptid = pid_to_ptid (proc_handle.pid); - proc_handle.pid = 0; - fbsd_thread_active = 0; - fbsd_thread_present = 0; - init_thread_list (); -} - -static char * -fbsd_thread_get_name (lwpid_t lwpid) -{ - static char last_thr_name[MAXCOMLEN + 1]; - char section_name[32]; - struct ptrace_lwpinfo lwpinfo; - bfd_size_type size; - struct bfd_section *section; - - if (target_has_execution) - { - if (ptrace (PT_LWPINFO, lwpid, (caddr_t)&lwpinfo, sizeof (lwpinfo)) == -1) - goto fail; - strncpy (last_thr_name, lwpinfo.pl_tdname, sizeof (last_thr_name) - 1); - } - else - { - snprintf (section_name, sizeof (section_name), ".tname/%u", lwpid); - section = bfd_get_section_by_name (core_bfd, section_name); - if (! section) - goto fail; - - /* Section size fix-up. */ - size = bfd_section_size (core_bfd, section); - if (size > sizeof (last_thr_name)) - size = sizeof (last_thr_name); - - if (! bfd_get_section_contents (core_bfd, section, last_thr_name, - (file_ptr)0, size)) - goto fail; - if (last_thr_name[0] == '\0') - goto fail; - } - last_thr_name[sizeof (last_thr_name) - 1] = '\0'; - return last_thr_name; -fail: - strcpy (last_thr_name, ""); - return last_thr_name; -} - -static void -fbsd_thread_new_objfile (struct objfile *objfile) -{ - td_err_e err; - - if (objfile == NULL) - { - /* All symbols have been discarded. If the thread_db target is - active, deactivate it now. */ - if (fbsd_thread_active) - { - gdb_assert (proc_handle.pid == 0); - fbsd_thread_active = 0; - } - - goto quit; - } - - if (!child_suppress_run) - goto quit; - - /* Nothing to do. The thread library was already detected and the - target vector was already activated. */ - if (fbsd_thread_active) - goto quit; - - /* Initialize the structure that identifies the child process. Note - that at this point there is no guarantee that we actually have a - child process. */ - proc_handle.pid = GET_PID (inferior_ptid); - - /* Now attempt to open a connection to the thread library. */ - err = td_ta_new_p (&proc_handle, &thread_agent); - switch (err) - { - case TD_NOLIBTHREAD: - /* No thread library was detected. */ - break; - - case TD_OK: - /* The thread library was detected. Activate the thread_db target. */ - fbsd_thread_present = 1; - - /* We can only poke around if there actually is a child process. - If there is no child process alive, postpone the steps below - until one has been created. */ - if (fbsd_thread_core == 0 && proc_handle.pid != 0) - { - push_target(&fbsd_thread_ops); - fbsd_thread_activate(); - } - else - { - td_ta_delete_p(thread_agent); - thread_agent = NULL; - } - break; - - default: - warning ("Cannot initialize thread debugging library: %s", - thread_db_err_str (err)); - break; - } - - quit: - if (target_new_objfile_chain) - target_new_objfile_chain (objfile); -} - -static void -fbsd_thread_attach (char *args, int from_tty) -{ - fbsd_thread_core = 0; - - child_ops.to_attach (args, from_tty); - - /* Must get symbols from solibs before libthread_db can run! */ - SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0, auto_solib_add); - - if (fbsd_thread_present && !fbsd_thread_active) - push_target(&fbsd_thread_ops); -} - -static void -fbsd_thread_post_attach (int pid) -{ - child_ops.to_post_attach (pid); - - if (fbsd_thread_present && !fbsd_thread_active) - { - proc_handle.pid = GET_PID (inferior_ptid); - fbsd_thread_activate (); - } -} - -static void -fbsd_thread_detach (char *args, int from_tty) -{ - fbsd_thread_deactivate (); - unpush_target (&fbsd_thread_ops); - - /* Clear gdb solib information and symbol file - cache, so that after detach and re-attach, new_objfile - hook will be called */ - - clear_solib(); - symbol_file_clear(0); - proc_handle.pid = 0; - child_ops.to_detach (args, from_tty); -} - -static int -suspend_thread_callback (const td_thrhandle_t *th_p, void *data) -{ - int err = td_thr_dbsuspend_p (th_p); - if (err != 0) - fprintf_filtered(gdb_stderr, "%s %s\n", __func__, thread_db_err_str (err)); - return (err); -} - -static int -resume_thread_callback (const td_thrhandle_t *th_p, void *data) -{ - int err = td_thr_dbresume_p (th_p); - if (err != 0) - fprintf_filtered(gdb_stderr, "%s %s\n", __func__, thread_db_err_str (err)); - return (err); -} - -static void -fbsd_thread_resume (ptid_t ptid, int step, enum target_signal signo) -{ - td_thrhandle_t th; - td_thrinfo_t ti; - ptid_t work_ptid; - int resume_all, ret; - long lwp, thvalid = 0; - - if (!fbsd_thread_active) - { - child_ops.to_resume (ptid, step, signo); - return; - } - - if (GET_PID(ptid) != -1 && step != 0) - { - resume_all = 0; - work_ptid = ptid; - } - else - { - resume_all = 1; - work_ptid = inferior_ptid; - } - - lwp = GET_LWP (work_ptid); - if (lwp == 0) - { - /* check user thread */ - ret = td_ta_map_id2thr_p (thread_agent, GET_THREAD(work_ptid), &th); - if (ret) - error (thread_db_err_str (ret)); - - /* For M:N thread, we need to tell UTS to set/unset single step - flag at context switch time, the flag will be written into - thread mailbox. This becauses some architecture may not have - machine single step flag in ucontext, so we put the flag in mailbox, - when the thread switches back, kse_switchin restores the single step - state. */ - ret = td_thr_sstep_p (&th, step); - if (ret) - error (thread_db_err_str (ret)); - ret = td_thr_get_info_p (&th, &ti); - if (ret) - error (thread_db_err_str (ret)); - thvalid = 1; - lwp = ti.ti_lid; - } - - if (lwp) - { - int req = step ? PT_SETSTEP : PT_CLEARSTEP; - if (ptrace (req, (pid_t) lwp, (caddr_t) 1, target_signal_to_host(signo))) - perror_with_name ("PT_SETSTEP/PT_CLEARSTEP"); - } - - if (!ptid_equal (last_single_step_thread, null_ptid)) - { - ret = td_ta_thr_iter_p (thread_agent, resume_thread_callback, NULL, - TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, - TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); - if (ret != TD_OK) - error ("resume error: %s", thread_db_err_str (ret)); - } - - if (!resume_all) - { - ret = td_ta_thr_iter_p (thread_agent, suspend_thread_callback, NULL, - TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, - TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); - if (ret != TD_OK) - error ("suspend error: %s", thread_db_err_str (ret)); - last_single_step_thread = work_ptid; - } - else - last_single_step_thread = null_ptid; - - if (thvalid) - { - ret = td_thr_dbresume_p (&th); - if (ret != TD_OK) - error ("resume error: %s", thread_db_err_str (ret)); - } - else - { - /* it is not necessary, put it here for completness */ - ret = ptrace(PT_RESUME, lwp, 0, 0); - } - - /* now continue the process, suspended thread wont run */ - if (ptrace (PT_CONTINUE, proc_handle.pid , (caddr_t)1, - target_signal_to_host(signo))) - perror_with_name ("PT_CONTINUE"); -} - -static void -attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, - const td_thrinfo_t *ti_p, int verbose) -{ - td_err_e err; - - /* Add the thread to GDB's thread list. */ - if (!in_thread_list (ptid)) { - add_thread (ptid); - if (verbose) - printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid)); - } - - if (ti_p->ti_state == TD_THR_UNKNOWN || ti_p->ti_state == TD_THR_ZOMBIE) - return; /* A zombie thread -- do not attach. */ - - if (! IS_THREAD(ptid)) - return; - if (fbsd_thread_core != 0) - return; - /* Enable thread event reporting for this thread. */ - err = td_thr_event_enable_p (th_p, 1); - if (err != TD_OK) - error ("Cannot enable thread event reporting for %s: %s", - target_pid_to_str (ptid), thread_db_err_str (err)); -} - -static void -detach_thread (ptid_t ptid, int verbose) -{ - if (verbose) - printf_unfiltered ("[%s exited]\n", target_pid_to_str (ptid)); -} - -static void -check_event (ptid_t ptid) -{ - td_event_msg_t msg; - td_thrinfo_t ti; - td_err_e err; - CORE_ADDR stop_pc; - int loop = 0; - - /* Bail out early if we're not at a thread event breakpoint. */ - stop_pc = read_pc_pid (ptid) - DECR_PC_AFTER_BREAK; - if (stop_pc != td_create_bp_addr && stop_pc != td_death_bp_addr) - return; - loop = 1; - - do - { - err = td_ta_event_getmsg_p (thread_agent, &msg); - if (err != TD_OK) - { - if (err == TD_NOMSG) - return; - error ("Cannot get thread event message: %s", - thread_db_err_str (err)); - } - err = td_thr_get_info_p ((void *)(uintptr_t)msg.th_p, &ti); - if (err != TD_OK) - error ("Cannot get thread info: %s", thread_db_err_str (err)); - ptid = BUILD_THREAD (ti.ti_tid, GET_PID (ptid)); - switch (msg.event) - { - case TD_CREATE: - /* We may already know about this thread, for instance when the - user has issued the `info threads' command before the SIGTRAP - for hitting the thread creation breakpoint was reported. */ - attach_thread (ptid, (void *)(uintptr_t)msg.th_p, &ti, 1); - break; - case TD_DEATH: - if (!in_thread_list (ptid)) - error ("Spurious thread death event."); - detach_thread (ptid, 1); - break; - default: - error ("Spurious thread event."); - } - } - while (loop); -} - -static ptid_t -fbsd_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus) -{ - ptid_t ret; - long lwp; - CORE_ADDR stop_pc; - td_thrhandle_t th; - td_thrinfo_t ti; - - ret = child_ops.to_wait (ptid, ourstatus); - if (GET_PID(ret) >= 0 && ourstatus->kind == TARGET_WAITKIND_STOPPED) - { - lwp = get_current_lwp (GET_PID(ret)); - ret = thread_from_lwp (BUILD_LWP(lwp, GET_PID(ret)), - &th, &ti); - if (!in_thread_list(ret)) { - /* - * We have to enable event reporting for initial thread - * which was not mapped before. - */ - attach_thread(ret, &th, &ti, 1); - } - if (ourstatus->value.sig == TARGET_SIGNAL_TRAP) - check_event(ret); - /* this is a hack, if an event won't cause gdb to stop, for example, - SIGARLM, gdb resumes the process immediatly without setting - inferior_ptid to the new thread returned here, this is a bug - because inferior_ptid may already not exist there, and passing - a none existing thread to fbsd_thread_resume causes error. */ - if (!fbsd_thread_alive (inferior_ptid)) - { - delete_thread (inferior_ptid); - inferior_ptid = ret; - } - } - - return (ret); -} - -static int -fbsd_thread_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, - struct mem_attrib *attrib, struct target_ops *target) -{ - int err; - - if (target_has_execution) - err = child_ops.to_xfer_memory (memaddr, myaddr, len, write, attrib, - target); - else - err = orig_core_ops.to_xfer_memory (memaddr, myaddr, len, write, attrib, - target); - - return (err); -} - -static void -fbsd_lwp_fetch_registers (int regno) -{ - gregset_t gregs; - fpregset_t fpregs; - lwpid_t lwp; -#ifdef PT_GETXMMREGS - char xmmregs[512]; -#endif - - if (!target_has_execution) - { - orig_core_ops.to_fetch_registers (-1); - return; - } - - /* XXX: We've replaced the pid with the lwpid for GDB's benefit. */ - lwp = GET_PID (inferior_ptid); - - if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) - error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); - supply_gregset (&gregs); - -#ifdef PT_GETXMMREGS - if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == 0) - { - i387_supply_fxsave (current_regcache, -1, xmmregs); - } - else - { -#endif - if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) - error ("Cannot get lwp %d registers: %s\n ", lwp, safe_strerror (errno)); - supply_fpregset (&fpregs); -#ifdef PT_GETXMMREGS - } -#endif -} - -static void -fbsd_thread_fetch_registers (int regno) -{ - prgregset_t gregset; - prfpregset_t fpregset; - td_thrhandle_t th; - td_err_e err; -#ifdef PT_GETXMMREGS - char xmmregs[512]; -#endif - - if (!IS_THREAD (inferior_ptid)) - { - fbsd_lwp_fetch_registers (regno); - return; - } - - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); - if (err != TD_OK) - error ("Cannot find thread %d: Thread ID=%ld, %s", - pid_to_thread_id (inferior_ptid), - GET_THREAD (inferior_ptid), thread_db_err_str (err)); - - err = td_thr_getgregs_p (&th, gregset); - if (err != TD_OK) - error ("Cannot fetch general-purpose registers for thread %d: Thread ID=%ld, %s", - pid_to_thread_id (inferior_ptid), - GET_THREAD (inferior_ptid), thread_db_err_str (err)); -#ifdef PT_GETXMMREGS - err = td_thr_getxmmregs_p (&th, xmmregs); - if (err == TD_OK) - { - i387_supply_fxsave (current_regcache, -1, xmmregs); - } - else - { -#endif - err = td_thr_getfpregs_p (&th, &fpregset); - if (err != TD_OK) - error ("Cannot get floating-point registers for thread %d: Thread ID=%ld, %s", - pid_to_thread_id (inferior_ptid), - GET_THREAD (inferior_ptid), thread_db_err_str (err)); - supply_fpregset (&fpregset); -#ifdef PT_GETXMMREGS - } -#endif - - supply_gregset (gregset); -} - -static void -fbsd_lwp_store_registers (int regno) -{ - gregset_t gregs; - fpregset_t fpregs; - lwpid_t lwp; -#ifdef PT_GETXMMREGS - char xmmregs[512]; -#endif - - /* FIXME, is it possible ? */ - if (!IS_LWP (inferior_ptid)) - { - child_ops.to_store_registers (regno); - return ; - } - - lwp = GET_LWP (inferior_ptid); - if (regno != -1) - if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) - error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); - - fill_gregset (&gregs, regno); - if (ptrace (PT_SETREGS, lwp, (caddr_t) &gregs, 0) == -1) - error ("Cannot set lwp %d registers: %s\n", lwp, safe_strerror (errno)); - -#ifdef PT_GETXMMREGS - if (regno != -1) - if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == -1) - goto noxmm; - - i387_fill_fxsave (xmmregs, regno); - if (ptrace (PT_SETXMMREGS, lwp, xmmregs, 0) == -1) - goto noxmm; - - return; - -noxmm: -#endif - - if (regno != -1) - if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) - error ("Cannot get lwp %d float registers: %s\n", lwp, - safe_strerror (errno)); - - fill_fpregset (&fpregs, regno); - if (ptrace (PT_SETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) - error ("Cannot set lwp %d float registers: %s\n", lwp, - safe_strerror (errno)); -} - -static void -fbsd_thread_store_registers (int regno) -{ - prgregset_t gregset; - prfpregset_t fpregset; - td_thrhandle_t th; - td_err_e err; -#ifdef PT_GETXMMREGS - char xmmregs[512]; -#endif - - if (!IS_THREAD (inferior_ptid)) - { - fbsd_lwp_store_registers (regno); - return; - } - - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); - if (err != TD_OK) - error ("Cannot find thread %d: Thread ID=%ld, %s", - pid_to_thread_id (inferior_ptid), - GET_THREAD (inferior_ptid), - thread_db_err_str (err)); - - if (regno != -1) - { - char old_value[MAX_REGISTER_SIZE]; - - regcache_collect (regno, old_value); - err = td_thr_getgregs_p (&th, gregset); - if (err != TD_OK) - error ("%s: td_thr_getgregs %s", __func__, thread_db_err_str (err)); -#ifdef PT_GETXMMREGS - err = td_thr_getxmmregs_p (&th, xmmregs); - if (err != TD_OK) - { -#endif - err = td_thr_getfpregs_p (&th, &fpregset); - if (err != TD_OK) - error ("%s: td_thr_getfpgregs %s", __func__, thread_db_err_str (err)); -#ifdef PT_GETXMMREGS - } -#endif - supply_register (regno, old_value); - } - - fill_gregset (gregset, regno); - err = td_thr_setgregs_p (&th, gregset); - if (err != TD_OK) - error ("Cannot store general-purpose registers for thread %d: Thread ID=%d, %s", - pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), - thread_db_err_str (err)); - -#ifdef PT_GETXMMREGS - i387_fill_fxsave (xmmregs, regno); - err = td_thr_setxmmregs_p (&th, xmmregs); - if (err == TD_OK) - return; -#endif - - fill_fpregset (&fpregset, regno); - err = td_thr_setfpregs_p (&th, &fpregset); - if (err != TD_OK) - error ("Cannot store floating-point registers for thread %d: Thread ID=%d, %s", - pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), - thread_db_err_str (err)); -} - -static void -fbsd_thread_kill (void) -{ - child_ops.to_kill(); -} - -static int -fbsd_thread_can_run (void) -{ - return child_suppress_run; -} - -static void -fbsd_thread_create_inferior (char *exec_file, char *allargs, char **env) -{ - if (fbsd_thread_present && !fbsd_thread_active) - push_target(&fbsd_thread_ops); - - child_ops.to_create_inferior (exec_file, allargs, env); -} - -static void -fbsd_thread_post_startup_inferior (ptid_t ptid) -{ - if (fbsd_thread_present && !fbsd_thread_active) - { - /* The child process is now the actual multi-threaded - program. Snatch its process ID... */ - proc_handle.pid = GET_PID (ptid); - td_ta_new_p (&proc_handle, &thread_agent); - fbsd_thread_activate(); - } -} - -static void -fbsd_thread_mourn_inferior (void) -{ - if (fbsd_thread_active) - fbsd_thread_deactivate (); - - unpush_target (&fbsd_thread_ops); - - child_ops.to_mourn_inferior (); -} - -static void -fbsd_core_check_lwp (bfd *abfd, asection *asect, void *obj) -{ - lwpid_t lwp; - - if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) - return; - - /* already found */ - if (*(lwpid_t *)obj == 0) - return; - - lwp = atoi (bfd_section_name (abfd, asect) + 5); - if (*(lwpid_t *)obj == lwp) - *(lwpid_t *)obj = 0; -} - -static int -fbsd_thread_alive (ptid_t ptid) -{ - td_thrhandle_t th; - td_thrinfo_t ti; - td_err_e err; - gregset_t gregs; - lwpid_t lwp; - - if (IS_THREAD (ptid)) - { - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); - if (err != TD_OK) - return 0; - - err = td_thr_get_info_p (&th, &ti); - if (err != TD_OK) - return 0; - - /* A zombie thread. */ - if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) - return 0; - - return 1; - } - else if (GET_LWP (ptid) == 0) - { - /* we sometimes are called with lwp == 0 */ - return 1; - } - - if (fbsd_thread_active) - { - err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), &th); - - /* - * if the lwp was already mapped to user thread, don't use it - * directly, please use user thread id instead. - */ - if (err == TD_OK) - return 0; - } - - if (!target_has_execution) - { - lwp = GET_LWP (ptid); - bfd_map_over_sections (core_bfd, fbsd_core_check_lwp, &lwp); - return (lwp == 0); - } - - /* check lwp in kernel */ - return ptrace (PT_GETREGS, GET_LWP (ptid), (caddr_t)&gregs, 0) == 0; -} - -static void -fbsd_thread_files_info (struct target_ops *ignore) -{ - child_ops.to_files_info (ignore); -} - -static int -find_new_threads_callback (const td_thrhandle_t *th_p, void *data) -{ - td_thrinfo_t ti; - td_err_e err; - ptid_t ptid; - - err = td_thr_get_info_p (th_p, &ti); - if (err != TD_OK) - error ("Cannot get thread info: %s", thread_db_err_str (err)); - - /* Ignore zombie */ - if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) - return 0; - - ptid = BUILD_THREAD (ti.ti_tid, proc_handle.pid); - attach_thread (ptid, th_p, &ti, 1); - return 0; -} - -static void -fbsd_thread_find_new_threads (void) -{ - td_err_e err; - - if (!fbsd_thread_active) - return; - - /* Iterate over all user-space threads to discover new threads. */ - err = td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL, - TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, - TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); - if (err != TD_OK) - error ("Cannot find new threads: %s", thread_db_err_str (err)); -} - -static char * -fbsd_thread_pid_to_str (ptid_t ptid) -{ - static char buf[64 + MAXCOMLEN]; - - if (IS_THREAD (ptid)) - { - td_thrhandle_t th; - td_thrinfo_t ti; - td_err_e err; - - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); - if (err != TD_OK) - error ("Cannot find thread, Thread ID=%ld, %s", - GET_THREAD (ptid), thread_db_err_str (err)); - - err = td_thr_get_info_p (&th, &ti); - if (err != TD_OK) - error ("Cannot get thread info, Thread ID=%ld, %s", - GET_THREAD (ptid), thread_db_err_str (err)); - - if (ti.ti_lid != 0) - { - snprintf (buf, sizeof (buf), "Thread %llx (LWP %d/%s)", - (unsigned long long)th.th_thread, ti.ti_lid, - fbsd_thread_get_name (ti.ti_lid)); - } - else - { - snprintf (buf, sizeof (buf), "Thread %llx (%s)", - (unsigned long long)th.th_thread, - thread_db_state_str (ti.ti_state)); - } - - return buf; - } - else if (IS_LWP (ptid)) - { - snprintf (buf, sizeof (buf), "LWP %d", (int) GET_LWP (ptid)); - return buf; - } - return normal_pid_to_str (ptid); -} - -CORE_ADDR -fbsd_thread_get_local_address(ptid_t ptid, struct objfile *objfile, - CORE_ADDR offset) -{ - td_thrhandle_t th; - void *address; - CORE_ADDR lm; - void *lm2; - int ret, is_library = (objfile->flags & OBJF_SHARED); - - if (IS_THREAD (ptid)) - { - if (!td_thr_tls_get_addr_p) - error ("Cannot find thread-local interface in thread_db library."); - - /* Get the address of the link map for this objfile. */ - lm = svr4_fetch_objfile_link_map (objfile); - - /* Couldn't find link map. Bail out. */ - if (!lm) - { - if (is_library) - error ("Cannot find shared library `%s' link_map in dynamic" - " linker's module list", objfile->name); - else - error ("Cannot find executable file `%s' link_map in dynamic" - " linker's module list", objfile->name); - } - - ret = td_ta_map_id2thr_p (thread_agent, GET_THREAD(ptid), &th); - - /* get the address of the variable. */ - store_typed_address(&lm2, builtin_type_void_data_ptr, lm); - ret = td_thr_tls_get_addr_p (&th, lm2, offset, &address); - - if (ret != TD_OK) - { - if (is_library) - error ("Cannot find thread-local storage for thread %ld, " - "shared library %s:\n%s", - (long) GET_THREAD (ptid), - objfile->name, thread_db_err_str (ret)); - else - error ("Cannot find thread-local storage for thread %ld, " - "executable file %s:\n%s", - (long) GET_THREAD (ptid), - objfile->name, thread_db_err_str (ret)); - } - - /* Cast assuming host == target. */ - return extract_typed_address(&address, builtin_type_void_data_ptr); - } - return (0); -} - -static int -tsd_cb (thread_key_t key, void (*destructor)(void *), void *ignore) -{ - struct minimal_symbol *ms; - char *name; - - ms = lookup_minimal_symbol_by_pc ( - extract_typed_address(&destructor, builtin_type_void_func_ptr)); - if (!ms) - name = "???"; - else - name = DEPRECATED_SYMBOL_NAME (ms); - - printf_filtered ("Key %d, destructor %p <%s>\n", key, destructor, name); - return 0; -} - -static void -fbsd_thread_tsd_cmd (char *exp, int from_tty) -{ - if (fbsd_thread_active) - td_ta_tsd_iter_p (thread_agent, tsd_cb, NULL); -} - -static void -fbsd_print_sigset (sigset_t *set) -{ - int i; - - for (i = 1; i <= _SIG_MAXSIG; ++i) { - if (sigismember(set, i)) { - if (i < sizeof(sys_signame)/sizeof(sys_signame[0])) - printf_filtered("%s ", sys_signame[i]); - else - printf_filtered("sig%d ", i); - } - } - printf_filtered("\n"); -} - -static void -fbsd_thread_signal_cmd (char *exp, int from_tty) -{ - td_thrhandle_t th; - td_thrinfo_t ti; - td_err_e err; - const char *code; - - if (!fbsd_thread_active || !IS_THREAD(inferior_ptid)) - return; - - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); - if (err != TD_OK) - return; - - err = td_thr_get_info_p (&th, &ti); - if (err != TD_OK) - return; - - printf_filtered("signal mask:\n"); - fbsd_print_sigset(&ti.ti_sigmask); - printf_filtered("signal pending:\n"); - fbsd_print_sigset(&ti.ti_pending); - if (ti.ti_siginfo.si_signo != 0) { - printf_filtered("si_signo %d si_errno %d", ti.ti_siginfo.si_signo, - ti.ti_siginfo.si_errno); - if (ti.ti_siginfo.si_errno != 0) - printf_filtered(" (%s)", strerror(ti.ti_siginfo.si_errno)); - printf_filtered("\n"); - switch (ti.ti_siginfo.si_code) { - case SI_NOINFO: - code = "NOINFO"; - break; - case SI_USER: - code = "USER"; - break; - case SI_QUEUE: - code = "QUEUE"; - break; - case SI_TIMER: - code = "TIMER"; - break; - case SI_ASYNCIO: - code = "ASYNCIO"; - break; - case SI_MESGQ: - code = "MESGQ"; - break; - case SI_KERNEL: - code = "KERNEL"; - break; - default: - code = "UNKNOWN"; - break; - } - printf_filtered("si_code %s (%d) si_pid %d si_uid %d si_status %x " - "si_addr %p\n", - code, ti.ti_siginfo.si_code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, - ti.ti_siginfo.si_status, ti.ti_siginfo.si_addr); - } -} - -static int -ignore (CORE_ADDR addr, char *contents) -{ - return 0; -} - -static void -fbsd_core_open (char *filename, int from_tty) -{ - int err; - - fbsd_thread_core = 1; - - orig_core_ops.to_open (filename, from_tty); - - if (fbsd_thread_present) - { - err = td_ta_new_p (&proc_handle, &thread_agent); - if (err == TD_OK) - { - proc_handle.pid = elf_tdata (core_bfd)->core_pid; - fbsd_thread_activate (); - } - else - error ("fbsd_core_open: td_ta_new: %s", thread_db_err_str (err)); - } -} - -static void -fbsd_core_close (int quitting) -{ - orig_core_ops.to_close (quitting); -} - -static void -fbsd_core_detach (char *args, int from_tty) -{ - if (fbsd_thread_active) - fbsd_thread_deactivate (); - unpush_target (&fbsd_thread_ops); - orig_core_ops.to_detach (args, from_tty); - - /* Clear gdb solib information and symbol file - cache, so that after detach and re-attach, new_objfile - hook will be called */ - clear_solib(); - symbol_file_clear(0); -} - -static void -fbsd_core_files_info (struct target_ops *ignore) -{ - orig_core_ops.to_files_info (ignore); -} - -static void -init_fbsd_core_ops (void) -{ - fbsd_core_ops.to_shortname = "FreeBSD-core"; - fbsd_core_ops.to_longname = "FreeBSD multithreaded core dump file"; - fbsd_core_ops.to_doc = - "Use a core file as a target. Specify the filename of the core file."; - fbsd_core_ops.to_open = fbsd_core_open; - fbsd_core_ops.to_close = fbsd_core_close; - fbsd_core_ops.to_attach = 0; - fbsd_core_ops.to_post_attach = 0; - fbsd_core_ops.to_detach = fbsd_core_detach; - /* fbsd_core_ops.to_resume = 0; */ - /* fbsd_core_ops.to_wait = 0; */ - fbsd_core_ops.to_fetch_registers = fbsd_thread_fetch_registers; - /* fbsd_core_ops.to_store_registers = 0; */ - /* fbsd_core_ops.to_prepare_to_store = 0; */ - fbsd_core_ops.to_xfer_memory = fbsd_thread_xfer_memory; - fbsd_core_ops.to_files_info = fbsd_core_files_info; - fbsd_core_ops.to_insert_breakpoint = ignore; - fbsd_core_ops.to_remove_breakpoint = ignore; - /* fbsd_core_ops.to_lookup_symbol = 0; */ - fbsd_core_ops.to_create_inferior = fbsd_thread_create_inferior; - fbsd_core_ops.to_stratum = core_stratum; - fbsd_core_ops.to_has_all_memory = 0; - fbsd_core_ops.to_has_memory = 1; - fbsd_core_ops.to_has_stack = 1; - fbsd_core_ops.to_has_registers = 1; - fbsd_core_ops.to_has_execution = 0; - fbsd_core_ops.to_has_thread_control = tc_none; - fbsd_core_ops.to_thread_alive = fbsd_thread_alive; - fbsd_core_ops.to_pid_to_str = fbsd_thread_pid_to_str; - fbsd_core_ops.to_find_new_threads = fbsd_thread_find_new_threads; - fbsd_core_ops.to_sections = 0; - fbsd_core_ops.to_sections_end = 0; - fbsd_core_ops.to_magic = OPS_MAGIC; -} - -static void -init_fbsd_thread_ops (void) -{ - fbsd_thread_ops.to_shortname = "freebsd-threads"; - fbsd_thread_ops.to_longname = "FreeBSD multithreaded child process."; - fbsd_thread_ops.to_doc = "FreeBSD threads support."; - fbsd_thread_ops.to_attach = fbsd_thread_attach; - fbsd_thread_ops.to_detach = fbsd_thread_detach; - fbsd_thread_ops.to_post_attach = fbsd_thread_post_attach; - fbsd_thread_ops.to_resume = fbsd_thread_resume; - fbsd_thread_ops.to_wait = fbsd_thread_wait; - fbsd_thread_ops.to_fetch_registers = fbsd_thread_fetch_registers; - fbsd_thread_ops.to_store_registers = fbsd_thread_store_registers; - fbsd_thread_ops.to_xfer_memory = fbsd_thread_xfer_memory; - fbsd_thread_ops.to_files_info = fbsd_thread_files_info; - fbsd_thread_ops.to_kill = fbsd_thread_kill; - fbsd_thread_ops.to_create_inferior = fbsd_thread_create_inferior; - fbsd_thread_ops.to_post_startup_inferior = fbsd_thread_post_startup_inferior; - fbsd_thread_ops.to_mourn_inferior = fbsd_thread_mourn_inferior; - fbsd_thread_ops.to_can_run = fbsd_thread_can_run; - fbsd_thread_ops.to_thread_alive = fbsd_thread_alive; - fbsd_thread_ops.to_find_new_threads = fbsd_thread_find_new_threads; - fbsd_thread_ops.to_pid_to_str = fbsd_thread_pid_to_str; - fbsd_thread_ops.to_stratum = thread_stratum; - fbsd_thread_ops.to_has_thread_control = tc_none; - fbsd_thread_ops.to_has_all_memory = 1; - fbsd_thread_ops.to_has_memory = 1; - fbsd_thread_ops.to_has_stack = 1; - fbsd_thread_ops.to_has_registers = 1; - fbsd_thread_ops.to_has_execution = 1; - fbsd_thread_ops.to_insert_breakpoint = memory_insert_breakpoint; - fbsd_thread_ops.to_remove_breakpoint = memory_remove_breakpoint; - fbsd_thread_ops.to_get_thread_local_address = fbsd_thread_get_local_address; - fbsd_thread_ops.to_magic = OPS_MAGIC; -} - -static int -thread_db_load (void) -{ - void *handle; - td_err_e err; - - handle = dlopen (LIBTHREAD_DB_SO, RTLD_NOW); - if (handle == NULL) - return 0; - -#define resolve(X) \ - if (!(X##_p = dlsym (handle, #X))) \ - return 0; - - resolve(td_init); - resolve(td_ta_new); - resolve(td_ta_delete); - resolve(td_ta_map_id2thr); - resolve(td_ta_map_lwp2thr); - resolve(td_ta_thr_iter); - resolve(td_thr_get_info); -#ifdef PT_GETXMMREGS - resolve(td_thr_getxmmregs); -#endif - resolve(td_thr_getfpregs); - resolve(td_thr_getgregs); -#ifdef PT_GETXMMREGS - resolve(td_thr_setxmmregs); -#endif - resolve(td_thr_setfpregs); - resolve(td_thr_setgregs); - resolve(td_thr_sstep); - resolve(td_ta_tsd_iter); - resolve(td_thr_dbsuspend); - resolve(td_thr_dbresume); - resolve(td_thr_tls_get_addr); - - /* Initialize the library. */ - err = td_init_p (); - if (err != TD_OK) - { - warning ("Cannot initialize libthread_db: %s", thread_db_err_str (err)); - return 0; - } - - /* These are not essential. */ - td_ta_event_addr_p = dlsym (handle, "td_ta_event_addr"); - td_ta_set_event_p = dlsym (handle, "td_ta_set_event"); - td_ta_event_getmsg_p = dlsym (handle, "td_ta_event_getmsg"); - td_thr_event_enable_p = dlsym (handle, "td_thr_event_enable"); - td_thr_tls_get_addr_p = dlsym (handle, "td_thr_tls_get_addr"); - - return 1; -} - -/* we suppress the call to add_target of core_ops in corelow because - if there are two targets in the stratum core_stratum, find_core_target - won't know which one to return. see corelow.c for an additonal - comment on coreops_suppress_target. */ - -int coreops_suppress_target = 1; - -/* similarly we allow this target to be completely skipped. This is used - by kgdb which uses its own core target. */ - -int fbsdcoreops_suppress_target; - -void -_initialize_thread_db (void) -{ - - if (fbsdcoreops_suppress_target) - return; - init_fbsd_thread_ops (); - init_fbsd_core_ops (); - - if (thread_db_load ()) - { - add_target (&fbsd_thread_ops); - - /* "thread tsd" command */ - add_cmd ("tsd", class_run, fbsd_thread_tsd_cmd, - "Show the thread-specific data keys and destructors " - "for the process.\n", - &thread_cmd_list); - - add_cmd ("signal", class_run, fbsd_thread_signal_cmd, - "Show the thread signal info.\n", - &thread_cmd_list); - - memcpy (&orig_core_ops, &core_ops, sizeof (struct target_ops)); - memcpy (&core_ops, &fbsd_core_ops, sizeof (struct target_ops)); - add_target (&core_ops); - - /* Add ourselves to objfile event chain. */ - target_new_objfile_chain = target_new_objfile_hook; - target_new_objfile_hook = fbsd_thread_new_objfile; - - child_suppress_run = 1; - } - else - { - fprintf_unfiltered (gdb_stderr, - "[GDB will not be able to debug user-mode threads: %s]\n", dlerror()); - - /* allow the user to debug non-threaded core files */ - add_target (&core_ops); - } -} - -/* proc service functions */ -void -ps_plog (const char *fmt, ...) -{ - va_list args; - - va_start (args, fmt); - vfprintf_filtered (gdb_stderr, fmt, args); - va_end (args); -} - -ps_err_e -ps_pglobal_lookup (struct ps_prochandle *ph, const char *obj, - const char *name, psaddr_t *sym_addr) -{ - struct minimal_symbol *ms; - CORE_ADDR addr; - - ms = lookup_minimal_symbol (name, NULL, NULL); - if (ms == NULL) - return PS_NOSYM; - - addr = SYMBOL_VALUE_ADDRESS (ms); - store_typed_address(sym_addr, builtin_type_void_data_ptr, addr); - return PS_OK; -} - -ps_err_e -ps_pread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t len) -{ - int err = target_read_memory ( - extract_typed_address(&addr, builtin_type_void_data_ptr), buf, len); - return (err == 0 ? PS_OK : PS_ERR); -} - -ps_err_e -ps_pwrite (struct ps_prochandle *ph, psaddr_t addr, const void *buf, - size_t len) -{ - int err = target_write_memory ( - extract_typed_address(&addr, builtin_type_void_data_ptr), (void *)buf, len); - return (err == 0 ? PS_OK : PS_ERR); -} - -ps_err_e -ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset) -{ - struct cleanup *old_chain; - - old_chain = save_inferior_ptid (); - - /* XXX: Target operation isn't lwp aware: replace pid with lwp */ - inferior_ptid = BUILD_LWP (0, lwpid); - - target_fetch_registers (-1); - fill_gregset (gregset, -1); - do_cleanups (old_chain); - return PS_OK; -} - -ps_err_e -ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid, const prgregset_t gregset) -{ - struct cleanup *old_chain; - - old_chain = save_inferior_ptid (); - inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); - supply_gregset ((gdb_gregset_t *) gregset); - target_store_registers (-1); - do_cleanups (old_chain); - return PS_OK; -} - -ps_err_e -ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, prfpregset_t *fpregset) -{ - struct cleanup *old_chain; - - old_chain = save_inferior_ptid (); - inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); - target_fetch_registers (-1); - fill_fpregset (fpregset, -1); - do_cleanups (old_chain); - return PS_OK; -} - -ps_err_e -ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, - const prfpregset_t *fpregset) -{ - struct cleanup *old_chain; - - old_chain = save_inferior_ptid (); - inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); - supply_fpregset ((gdb_fpregset_t *) fpregset); - target_store_registers (-1); - do_cleanups (old_chain); - return PS_OK; -} - -#ifdef PT_GETXMMREGS -ps_err_e -ps_lgetxmmregs (struct ps_prochandle *ph, lwpid_t lwpid, char *xmmregs) -{ - struct cleanup *old_chain; - - old_chain = save_inferior_ptid (); - inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); - target_fetch_registers (-1); - i387_fill_fxsave (xmmregs, -1); - do_cleanups (old_chain); - return PS_OK; -} - -ps_err_e -ps_lsetxmmregs (struct ps_prochandle *ph, lwpid_t lwpid, - const char *xmmregs) -{ - struct cleanup *old_chain; - - old_chain = save_inferior_ptid (); - inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); - i387_supply_fxsave (current_regcache, -1, xmmregs); - target_store_registers (-1); - do_cleanups (old_chain); - return PS_OK; -} -#endif - -ps_err_e -ps_lstop(struct ps_prochandle *ph, lwpid_t lwpid) -{ - if (ptrace (PT_SUSPEND, lwpid, 0, 0) == -1) - return PS_ERR; - return PS_OK; -} - -ps_err_e -ps_lcontinue(struct ps_prochandle *ph, lwpid_t lwpid) -{ - if (ptrace (PT_RESUME, lwpid, 0, 0) == -1) - return PS_ERR; - return PS_OK; -} - -ps_err_e -ps_linfo(struct ps_prochandle *ph, lwpid_t lwpid, void *info) -{ - if (fbsd_thread_core) { - /* XXX should verify lwpid and make a pseudo lwp info */ - memset(info, 0, sizeof(struct ptrace_lwpinfo)); - return PS_OK; - } - - if (ptrace (PT_LWPINFO, lwpid, info, sizeof(struct ptrace_lwpinfo)) == -1) - return PS_ERR; - return PS_OK; -} diff --git a/gnu/usr.bin/gperf/Makefile b/gnu/usr.bin/gperf/Makefile deleted file mode 100644 index aeb4b95f65e..00000000000 --- a/gnu/usr.bin/gperf/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -.include -GPERFDIR= ${SRCTOP}/contrib/gperf - -.PATH: ${GPERFDIR}/src ${GPERFDIR}/lib ${GPERFDIR}/doc - -PROG_CXX= gperf -SRCS= bool-array.cc hash-table.cc input.cc keyword-list.cc keyword.cc \ - main.cc options.cc output.cc positions.cc search.cc version.cc \ - getline.cc hash.cc -WARNS?= 1 -MAN= gperf.1 gperf.7 - -CXXFLAGS+= -I${GPERFDIR}/lib -I${.CURDIR} - -.include diff --git a/gnu/usr.bin/gperf/Makefile.depend b/gnu/usr.bin/gperf/Makefile.depend deleted file mode 100644 index ea8bba31ec0..00000000000 --- a/gnu/usr.bin/gperf/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libc++ \ - lib/libcompiler_rt \ - lib/libcxxrt \ - lib/msun \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/gperf/config.h b/gnu/usr.bin/gperf/config.h deleted file mode 100644 index 91c1236ec1c..00000000000 --- a/gnu/usr.bin/gperf/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ -/* $FreeBSD$ */ - -/* Define if the C++ compiler supports stack-allocated variable-size arrays. - */ -#define HAVE_DYNAMIC_ARRAY 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" diff --git a/gnu/usr.bin/grep/AUTHORS b/gnu/usr.bin/grep/AUTHORS deleted file mode 100644 index e08a38cf24e..00000000000 --- a/gnu/usr.bin/grep/AUTHORS +++ /dev/null @@ -1,44 +0,0 @@ -Mike Haertel wrote the main program and the dfa and kwset matchers. - -Arthur David Olson contributed the heuristics for finding fixed substrings -at the end of dfa.c. - -Richard Stallman and Karl Berry wrote the regex backtracking matcher. - -Henry Spencer wrote the original test suite from which grep's was derived. - -Scott Anderson invented the Khadafy test. - -David MacKenzie wrote the automatic configuration software use to -produce the configure script. - -Authors of the replacements for standard library routines are identified -in the corresponding source files. - -The idea of using Boyer-Moore type algorithms to quickly filter out -non-matching text before calling the regexp matcher was originally due -to James Woods. He also contributed some code to early versions of -GNU grep. - -Mike Haertel would like to thank Andrew Hume for many fascinating discussions -of string searching issues over the years. Hume & Sunday's excellent -paper on fast string searching (AT&T Bell Laboratories CSTR #156) -describes some of the history of the subject, as well as providing -exhaustive performance analysis of various implementation alternatives. -The inner loop of GNU grep is similar to Hume & Sunday's recommended -"Tuned Boyer Moore" inner loop. - -More work was done on regex.[ch] by Ulrich Drepper and Arnold -Robbins. Regex is now part of GNU C library, see this package -for complete details and credits. - -Arnold Robbins contributed to improve dfa.[ch]. In fact -it came straight from gawk-3.0.3 with small editing and fixes. - -Many folks contributed see THANKS, if I omited someone please -send me email. - -Alain Magloire maintained GNU grep until version 2.5e. - -Bernhard "Bero" Rosenkränzer is the current maintainer. - diff --git a/gnu/usr.bin/grep/COPYING b/gnu/usr.bin/grep/COPYING deleted file mode 100644 index 60549be514a..00000000000 --- a/gnu/usr.bin/grep/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program 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 2 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, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/gnu/usr.bin/grep/ChangeLog b/gnu/usr.bin/grep/ChangeLog deleted file mode 100644 index aa50e78c1f4..00000000000 --- a/gnu/usr.bin/grep/ChangeLog +++ /dev/null @@ -1,2477 +0,0 @@ -2002-03-26 Bernhard Rosenkraenzer - * src/grep.c: Don't fail if we don't have an stdout fd and -q - is used (happens e.g. on calls from hotplug scripts) - * src/grep.c: Don't hang forever if fed with an empty string to - grep for and --color enabled - * src/grep.c: Fix infinite loop on - echo "1 one" | grep -E "[0-9]*" -o - echo "1 one" | grep -E "[0-9]*" --color - * po/*: Sync wiith translation project - * src/grep.c, src/Makefile.am, configure.in: Add patch from - Paul Eggert to comply with ridiculous - guidelines (don't act differently if invoked as egrep or fgrep) - * configure.in: Bump version number, require a recent autoconf - -2002-03-14 Bernhard Rosenkraenzer - * src/Makefile.am, po/Makefile.in.in: Support DESTDIR properly - * tests/bre.tests: Add fix from - Peter Breitenlohner - -2002-03-13 Bernhard Rosenkraenzer - * configure.in, m4/regex.m4, m4/malloc.m4, m4/realloc.m4: - Don't set LIBOBJS directly, autoconf 2.53 doesn't like it - * intl/*: Sync with gettext 0.11 - * po/*: Sync with translation project - * configure.in, src/Makefile.am: Don't duplicate code - make - egrep and fgrep links to grep and set matcher based on - application name, suggestion from - Guillaume Cottenceau - * src/grep.c: (prline) Add fix for -i --color from - Jim Meyering - * configure.in: Version 2.5; release - -2002-01-23 Bernhard Rosenkraenzer - * configure.in: Version 2.5g - * Makefile.cvs, grep.spec: Add packaging tools - Merge djgpp changes from Andrew Cottrell : - * src/grep.c: Added conditional compilation for DJGPP - * djgpp: remove directory as it is no longer required with DJGPP 2.03 - (or 2.04 when released) - * README.DOS: Moved djgpp/readme to readme.dos - * PATCHES.AC, PATCHES.AM: delete files - redundant - * configure.in, Makefile.am: remove djgpp directory from list - -2002-01-22 Bernhard Rosenkraenzer - * doc/grep.texi, doc/grep.1, NEWS: Document --label - * po/ru.po: Sync with translation project - * po/grep.pot: Sync with source - -2002-01-18 Bernhard Rosenkraenzer - * src/grep.c: Add --label, based on patch from Stepan Koltsov - -2001-11-20 Bernhard Rosenkraenzer - * autogen.sh: Don't hardcode aclocal dir - -2001-11-19 Bernhard Rosenkraenzer - * src/grep.c: Add --only-matching (-o) switch (see NEWS) - * doc/grep.texi, doc/grep.1, NEWS: Document changes - * configure.in, lib/Makefile.am: Don't use internal getopt if - we're on a system that provides a working getopt function - -2001-09-25 Bernhard Rosenkraenzer - * configure.in: Detect pcre correctly even when it's in - non-standard locations, using pcre-config - * src/grep.c: Add --color={always,never,tty} argument (like in ls) - * src/grep.c: Turn off blinking in the default colorization - * src/grep.c: Add --devices (-D) switch (analogous to --directories) - * src/dfa.c: Fix an i18n bug: echo "A" | grep '[A-Z0-9]' wouldn't work - in non-C-Locales on systems using current versions of glibc. - * AUTHORS: Change maintainer, credit Alain for his work until now - * configure.in, m4/decl.m4, m4/dosfile.m4, m4/gettext.m4, - m4/init.m4, m4/install.m4, m4/largefile.m4, m4/lcmessage.m4, - m4/header.m4, m4/isc-posix.m4, m4/missing.m4, m4/progtest.m4, - m4/sanity.m4: - Fix build with autoconf 2.5x, retain 2.1x compatibility for now - * autogen.sh: Add some crude hacks to make it possible to build with - both autoconf 2.5x and 2.1x - * acconfig.h: removed (no longer required) - * Makefile.am: add cvs-clean target - * doc/grep.texi, doc/grep.1, NEWS: Document changes - (--color, --devices, -D) - * src/dfa.c, src/grep.c: Add vim modelines - -2001-08-30 Alain Magloire - - * configure.in: Add gl in ALL_LINGUAS. - -2001-08-30 Kurt D Schwehr - - * doc/grep.1: Warn that grep insert a "--" between groups of matches, - when using the context options. - * doc/grep.texi: Likewised. - -2001-08-25 Heikki Korpela - - * doc/grep.texi: Point out that some Platforms do not support - reading of directories and silently ignore them. - -2001-08-21 Alain Magloire - - * lib/malloc.c: New file: - * lib/realloc.c: New file: - * lib/Makefile.am: Add malloc.c and realloc.c in EXTRA_DIST. - -2001-07-31 Alain Magloire - - * po/*.po: New files from the translation team: - grep-2.5e.de.po grep-2.5e.el.po grep-2.5e.eo.po grep-2.5e.es.po - grep-2.5e.et.po grep-2.5e.fr.po grep-2.5e.gl.po grep-2.5e.it.po - grep-2.5e.pl.po grep-2.5e.sl.po - -2001-07-31 Andreas Schwab - - * src/grep.c: Fix all uses of error to pass a proper format - string. - -2001-07-29 Alain Magloire - - * grep/src/grep.c (usage): Typos corrected. - Patches from Santiago Vila. - -2001-07-29 Alain Magloire - - David Clissold, wrote: - a small bug in the GNU grep 2.4.2, which may have gone unnoticed - because it only causes a failure if building on a system with large - files enabled (e.g. an "off_t" is a "long long" rather than a "long"). - savedir() takes on off_t argument, but in grepdir() the parameter - is cast to an (unsigned). Well, if an off_t is larger than an int, - the value gets truncated. This would not normally have an effect on a - little-endian platform (unless the file is >2GB), but on a big-endian - system it will always fail. The external effect is that - "grep -r foo dir_name" fails with ENOMEM (from malloc() within - savedir()). - - * grep/src/grep.c (grepdir): Remove the (unsigned) cast when calling - savedir(). - Patch from David Clissold. - -2001-07-29 Alain Magloire - - * grep/doc/grep.texi: In Bugs report use {n,m} for consistency. - * grep/doc/grep.1: Likewised. - Noted by Steven Lucy. - -2001-04-27 Isamu Hasegawa - - * dfa.c (mblen_buf) : New variable contains the amount of remain - byte of corresponding multibyte character in the input string. - (SKIP_REMAIN_MB_IF_INITIAL_STATE) : Use mblen_buf. - (match_anychar) : Use mblen_buf. - (match_mb_charset) : Use mblen_buf. - (transit_state_consume_1char) : Use mblen_buf. - (transit_state) : Use inputwcs to get current (multibyte) character. - (dfaexec) : Add initialization of mblen_buf. - -2001-04-27 Isamu Hasegawa - - * dfa.c (addtok) : Set appropriate value to multibyte_prop. - (dfastate) : Add the initialization of the variable. - (dfaexec) : Call transit_state if d->fail may transit by - multibyte characters. - (transit_state_singlebyte) : Clean up unnecessary code. - (transit_state_consume_1char) : Likewise. - (transit_state) : Add checking for word and newline. - -2001-04-19 Isamu Hasegawa - - * search.c (check_multibyte_string) : Check the case when mbclen == 0. - -2001-04-11 Isamu Hasegawa - - * search.c (check_multibyte_string) : Check the head of multibyte - characters, and optimize a bit. - (EGexecute) : Optimize a bit. - (Fexecute) : Fix the index. - -2001-04-02 Alain Magloire - - * lib/regex.c: Update from GNU lib C, with the changes - provided by Paul Eggert. - * lib/posix/regex.h: Likewise. - -2001-02-17 Paul Eggert - - Stop trying to support hosts that have nonstandard declarations for - mbrtowc and/or mbstate_t. It's not worth the portability hassle. - - * lib/quotearg.c (mbrtowc, mbsinit): Remove workaround macros - for hosts that have mbrtowc but not mbstate_t, as we now - insist on proper declarations for both before using mbrtowc. - -2001-03-18 Alain Magloire - - * configure.in: Call AC_MBSTATE_T. - * Makefile.am: Add mbstate_t.m4 - * m4/Makefile.am: Add mbstate_t.m4 - * m4/mbstate_t.m4: New m4 macro. - * lib/strtol.c: Define CHAR_BITS. - Uwe H. Steinfeld, Ruslan Ermilov, Volkert Bochert, noted - that mbstate_t was not define for certain platforms. - -2001-03-18 Paul Eggert - - * src/grep.c (fillbuf): Fix storage allocation performance - bug: buffer was doubling in size in many cases where it didn't - have to. - -2001-03-17 Paul Eggert - - * src/grep.c (fillbuf): Avoid unnecessary division by 2. - Don't check xrealloc return value; it's guaranteed to be nonzero. - (fillbuf, grepdir): Use xalloc_die rather than error; it's shorter. - -2001-03-17 Alain Magloire - - * src/grep.c (context_length_arg): error () passing wrong format. - Spotted by Jim Meyering. - -2001-03-07 Alain Magloire - - * README-alpha: Removed reference to GNU tar, add the location - of the CVSROOT. - -2001-03-06 Alain Magloire - - Only the Regex patterns should be split in an array, patterns[]. - The dfa and KWset compiled patterns should remain global and the - patterns compiled all at once. - - * src/search.c: include "error.h" and "xalloc.h" to get prototyping - of x*alloc() and error(). - (kwsinit): Reverse to previous behaviour and takes no argument. - (kwsmusts): Likewised. - (Gcompile): For the regex pattern, split them and each pattern - is put in different compiled structure patterns[]. The patterns - are given to dfacomp() and kwsmusts() as is. - (Ecompile): Likewised. - (Fcompile): Reverse to the old behaviour of compiling the enire - patterns in one shot. - (EGexecute): If falling to GNU regex for the matching, loop in the - array of compile patterns[] to find a match. - (error): Many error () were call with arguments in the wrong order. - * tests/file.sh: Simple test to check for pattern in files. - - Reaction to bug report fired by Greg Louis - -2001-03-06 Isamu Hasegawa - - In multibyte environments, handle multibyte characters as single - characters in bracket expressions. - - * src/dfa.h (mb_char_classes) : new structure. - (mbcsets): new variable. - (nmbcsets): new variable. - (mbcsets_alloc) : new variable. - * src/dfa.c (prtok) : handle MBCSET. - (fetch_wc): new function to fetch a wide character. - (parse_bracket_exp_mb) : new function to handle multibyte character - in lex(). - (lex): invoke parse_bracket_exp_mb() for multibyte bracket expression. - (atom): handle MBCSET. - (epsclosure): likewise. - (dfaanalyze): likewise. - (dfastate): likewise. - (match_mb_charset): new function to judge whether a bracket match - with a multibyte character. - (check_matching_with_multibyte_ops) : handle MBCSET. - (dfainit): initialize new variables. - (dfafree): free new variables. - -2001-03-04 Alain Magloire - - To get more in sync with other GNU utilities like GNU tar and fetish - all the supporting functions are now under lib. - Thanks to Jim Meyering, Volkert Bochert and Paul Eggert for - the code and the reminders. - - * src/grep.c (fatal): Function removed, using error () from - lib/error.c instead. - (usage): Copyright updated. - (error): Function removed, using error () from lib/error.c instead, - adjust prototypes. - (prog): Global variable rename to program_name, to work with new - lib/error.c. - (xrealloc): Removed using lib/xmalloc.c. - (xmalloc): Removed using lib/xmalloc.c - (main): Register with atexit() to check for error on stdout. - * configure.in: Check for atexit(), call jm_MALLOC, jm_RELLOC and - jm_PREREQ_ERROR. - * tests/bre.awk: Removed the hack to drain the buffer since we - always fclose(stdout) atexit. - * tests/ere.awk: Likewise. - * tests/spencer1.awk: Likewise. - * bootstrap/Makefile.try: Update the Makefile to reflect the changes - in the new hierarchy. - - * README-alpha: New File. - * m4/realloc.m4: New File. - * m4/malloc.m4: New File. - * m4/error.m4: New File. - * m4/Makefile.am: Updated. - * lib: New directory. - * lib/Makefile.am: New file. - * lib/closeout.c: New file. - * lib/closeout.h: New file. - * lib/fnmatch.c: New file. - * lib/fnmatch.h: New file. - * lib/atexit.c: New file. - * lib/error.c: New file. - * lib/error.h: New file. - * lib/quotearg.h: New file. - * lib/quotearg.c: New file. - * lib/xmalloc.c: New file. - * lib/posix: New directory. - * lib/posix/Makefile.am: New file. - * src/getopt.c: Moved to lib. - * src/getopt1.c: Moved to lib. - * src/getopt.h: Moved to lib. - * src/alloca.c: Moved to lib. - * src/exclude.c: Moved to lib. - * src/exclude.h: Moved to lib. - * src/hard-locale.h: Moved to lib. - * src/hard-locale.c: Moved to lib. - * src/isdir.c: Moved to lib. - * src/mechr.c: Moved to lib. - * src/obstack.c: Moved to lib. - * src/obstack.h: Moved to lib. - * src/regex.c: Moved to lib. - * src/regex.h: Moved to lib. - * src/posix: Moved to lib. - * src/posix/regex.h: Moved to lib. - * src/savedir.h: Moved to lib. - * src/savedir.c: Moved to lib. - * src/stpcpy.c: Moved to lib. - * src/strtoul.c: Moved to lib. - * src/strtol.c: Moved to lib. - * src/strtoull.c: Moved to lib. - * src/strtoumax.c: Moved to lib. - * src/xstrtol.c: Moved to lib. - * src/xstrtol.h: Moved to lib. - * src/xstrtoumax.c: Moved to lib. - -2001-03-01 Isamu Hasegawa - - Implement the mechanism to match with multibyte characters, - and use it for `period' in multibyte environments. - - * dfa.h (mbps): new variable. - * dfa.c (prtok): handle ANYCHAR. - (lex): use ANYCHAR for `period' in multibyte environments. - (atom): handle ANYCHAR. - (state_index): initialize mbps in multibyte environments. - (epsclosure): handle ANYCHAR. - (dfaanalyze): handle ANYCHAR. - (dfastate): handle ANYCHAR. - (realloc_trans_if_necessary): new function. - (transit_state_singlebyte): new function. - (match_anychar): new function. - (check_matching_with_multibyte_ops): new function. - (transit_state_consume_1char): new function. - (transit_state): new function. - (dfaexec): invoke transit_state if expression can match with - a multibyte character in multibyte environments. - (dfamust): handle ANYCHAR. - -2001-03-01 Alain Magloire - - * src/exclude.c: New file. - * src/exclude.h: New file. - * src/grep.c (main): Took the GNU tar code to handle - the option --include, --exclude, --exclude-from. - Files are check for a match, with exlude_filename (). - New option --exclude-from. - * src/savedir.c: Call exclude_filename() to check for - file pattern exclusion or inclusion. - * configure.in: --disable-pcre rename to --disable-perl-regexp. - - -2001-02-25 Alain Magloire - - * src/dfa.c: Typo corrected. - Noted by Isamu Hasegawa. - * src/savedir.c: Typos corrected. - -2001-02-22 Alain Magloire - - * src/savedir.c (isdir1): New function, calling isdir with - the correct pathname. - -2001-02-19 Isamu Hasegawa - - Avoid incorrect state transition in multibyte environments. - - * dfa.h (nmultibyte_prop): new variable. - (multibyte_prop): new variable. - * dfa.c (addtok): set inputwcs. - (dfastate): avoid incorrect state transition in multibyte - environments. - (dfaexec): likewise. - (dfainit): init multibyte_prop. - (dfafree): free multibyte_prop. - (inputwcs): new variable. - -2001-02-19 Isamu Hasegawa - - Handle a multibyte character followed by '*', '+', and '{n,m}' - correctly. - - * dfa.c (update_mb_len_index): new function. - Support for multibyte string. - (FETCH): call update_mb_len_index. - (lex): check cur_mb_index not to misunderstand multibyte characters. - (atom): make a tree from a multibyte character. - (dfaparse): initialize new variables. - (mbs): new variable. - (cur_mb_len): new variable. - (cur_mb_index): new variable. - -2001-02-18 Jim Meyering - - * m4/dosfile.m4 (AC_DOSFILE): Move AC_DEFINEs out of AC_CACHE_CHECK. - -2001-02-17 Alain Malgoire - - * doc/grep.texi: Document the new options and the new behaviour - back-references are local. Use excerpt from Karl Berry regex - texinfo. - - * bootstrap/Makefile.try: Added xstrtoumax.o xstrtoul.o hard-local.o - -2001-02-17 Alain Magloire - - From Guglielmo 'bond' Bondioni : - The bug was that using a multi line file that contained REs (one per - line), backreferences in the REs were considered global (to the file) - and not local (to the line). - That is, \1 in line n refers to the first \(.\) in the whole file, - rather than in the line itself. - - From Tapani Tarvainen : - # Re: grep -e '\(a\)\1' -e '\(b\)\1' - That's not the way it should work: multiple -e arguments - should be treated as independent patterns and back references - should not refer to previous ones. - - From Paul Eggert : - GNU grep currently does not issue - diagnostics for the following two cases, both of which are erroneous: - grep -e '[' -e ']' - grep '[ - ]' - POSIX requires a diagnostic in both cases because '[' is not a valid - regular expression. - - To overcome those problems, grep no longer pass the concatenate - patterns to GNU regex but rather compile each patterns separately - and keep the result in an array. - - * src/search.c (patterns): New global variable; a structure array - holding the compiled patterns. - Declare function prototypes to minimize error. - (dfa, kswset, regexbuf, regs): Removed, no longer static globals, but - rather fields in patterns[] structure per motif. - (Fcompile): Alloc an entry in patterns[] to hold the regex. - (Ecompile): Alloc an entry per motif in the patterns[] array. - (Gcompile): Likewise. - (EGexecute): Loop through of array of patterns[] for a match. - -2001-02-17 Alain Magloire - - From Bernd Strieder : - # tail -f logfile | grep important | do_something_urgent - # tail -f logfile | grep important | do_something_taking_very_long - If grep does full buffering in these cases then the urgent operation - does not happen as it should in the first case, and in the second case - time is lost due to waiting for the buffer to be filled. - This is clearly spoken not grep's fault in the first place, but libc's. - There is a heuristic in libc that make a stream line-buffered only if a - terminal is on the other end. This doesn't take care of the cases where - this connection is somehow indirect. - - * src/grep.c (line_buffered): new option variable. - (prline): if line_buffered is set fflush() is call. - (usage): line_buffered new option. - Input from Paul Eggert, doing setvbuf() may not be portable - and breaks grep -z. - -2001-02-16 Alain Magloire - - Patch from Isamu Hasegawa, for multibyte support. - This patch prevent kwset_matcher from following problems. - For example, in SJIS encoding, one character has the codepoint 0x895c. - So the second byte of the character can match with '\' incorrectly. - And in eucJP encoding, there are the characters whose codepoints are - 0xa5b9, 0xa5c8. On the other hand, there is one character whose - codepoint is 0xb9a5. So 0xb9a5 can match with 2nd byte of 0xa5b9 - and 1st byte of 0xa5c8. - - * configure.in: Add check for mbrtowc. - * src/search.c (check_multibyte_string): new function. - Support for multibyte string. - (EGexecute): call check_multibyte_string when kwset is set. - (Fexecute): call to check_multibyte_string. - (MBS_SUPPORT): new macro. - (MB_CUR_MAX): new macro. - -2001-02-16 Alain Magloire - - * djgpp/config.bat: Fix for 4dos.com. - * m4/dosfile.m4 (HAVE_DOS_FILE_CONTENTS): Was not set. - Bugs noted and patched by Juan Manuel Guerrero. - -2001-02-16 Alain Magloire - - A much requested feature, the possibility to select - files when doing recurse : - # find . -name "*.c" | xargs grep main {} - # grep --include=*.c main . - # find . -not -name "*.c" | xargs grep main {} - # grep --exclude=*.c main . - - * src/grep.c (short_options): -R equivalent to -r. - (#ifdef) : Fix some inconsistencies in the use of #ifdefs, prefer - #if defined() wen possible. - (long_options): Add --color, --include and exclude. - (Usage): Description of new options. - (color): Rename color variable to color_option. - Removed 'always|never|auto' arguments, not necessary for grep. - (exclude_pattern): new variable, holder for the file pattern. - (include_pattern): new variable, hoder for the file pattern. - * src/savedir.c: Signature change, take two new argmuments. - * doc/grep.texi: Document, new options. - * doc/grep.man: Document, new options. - -2001-02-09 Alain Magloire - - * src/grep.c (long_options): Added equivalent to -r with -R. - * src/grep.c (usage): added --color and --colour. - Noted with patch from, H.Merijn Brand and Wichert Akkerman. - -2001-02-09 Alain Magloire - - Patch from Ulrich Drepper to provide hilighting. - - * src/grep.c: New option --color. - (color): New static var. - (COLOR_OPTION): new constant. - (grep_color): new static var. - (prline): Now when color is set prline() will call the current matcher - to find the offset of the matching string. - * src/savedir.c: Take advantage of _DIRENT_HAVE_TYPE if supported. - * src/search.c (EGexecute, Fexecute, Pexecute): Take a new argument - when doing exact match for the color hiligting. - -2000-09-01 Brian Youmans - - * doc/grep.texi: Typo fixes. - -2000-08-30 Paul Eggert - - * doc/grep.texi (Usage): Talk about what "grep -r hello *.c" - means. - -2000-08-20 Paul Eggert - - Handle range expressions correctly even when they match - strings with two or more characters. - - * src/dfa.h (CRANGE): New enum value. Comment fix. - - * src/dfa.c: Include if HAVE_SETLOCALE. - Include "hard-locale.h". - (prtok): Print CRANGE. - (hard_LC_COLLATE): New static var. - (lex): Return CRANGE when parsing a character range in a hard locale. - Don't use strcoll; it's no longer needed and wasn't correct anyway. - Use unsigned rather than token to hold unsigned chars. - (addtok): Comment fix. - (atom): Treat a CRANGE as if it were (.\1), approximately. - (dfaparse): Initialize hard_LC_COLLATE. - - * src/Makefile.am (base_sources): Add hard-locale.c, hard-locale.h. - - * src/hard-locale.c, src/hard-locale.h: New files, taken from - textutils. - -2000-08-20 Paul Eggert - - * tests/Makefile.am (TESTS_ENVIRONMENT): Add LC_ALL=C, since - some of the tests assume the C locale. - -2000-08-16 Paul Eggert - - * src/search.c (Gcompile, Ecompile): -x overrides -w, for - consistency with fgrep. Don't assume that sizes fit in 'int'. - Fix comments to match code. - -2000-06-06 Paul Eggert - - * src/grep.c (grepdir): Don't look at st_dev when testing for - Mingw32 bug. - -2000-06-05 Paul Eggert - - Port to Mingw32, based on suggestions from Christian Groessler - . - - * src/isdir.c: New file, taken from fileutils. - - * src/Makefile.am (base_sources): Add isdir.c. - - * src/grep.c (grepfile): Use isdir instead of doing it inline. - (grepdir): Suppress ancestor check if the directory's inode and device - are both zero, as that occurs only on Mingw32 which doesn't support - inode or device. - - * src/system.h (isdir): New decl. - (is_EISDIR): Depend on HAVE_DIR_EACCES_BUG, not D_OK. - Use isdir, not access. - -2000-06-02 Paul Eggert - - Problen noted by Gerald Stoller - - * src/grep.c (main): POSIX.2 says that -q overrides -l, which - in turn overrides the other output options. Fix grep to - behave that way. - -2000-05-27 Paul Eggert - - Simplify and tune the buffer allocation strategy. Do not reserve a - large save area: reserve only enough bytes to hold the residue, plus - page alignment. Put a newline sentinel before the buffer, for speed - when searching backwards for newline. - - * src/grep.c (ubuffer, bufsalloc, PREFERRED_SAVE_FACTOR, page_alloc): - Remove. All uses changed. - (INITIAL_BUFSIZE): New macro. - (reset, fillbuf): Use simpler buffer allocation strategy. - (reset): Check for preposterously large pagesize that would cause - later calculations to overflow. - (fillbuf): Do not resize buffer if there's room at the end for - at least one more page. This greatly increases performance when - reading from non-regular files that contain no newlines. - When growing the buffer, double its size instead of using a - more complicated algorithm. - (prtext, grep): Speed up by relying on the newline sentinel before the - start of the buffer. - (grep): When looking backwards for the last newline in a buffer, - stop when we hit the residue, since it can't contain a newline. - This avoids an O(N**2) algorithm when reading binary data from - a pipe. Use a sentinel to speed up the backward search for newline. - (nlscan): Undo previous change; it wasn't needed and just complicates - and slows down the code a tad. - -2000-05-24 Paul Eggert - - Handle very large input counts better. Bug noted by Jim Meyering. - - * src/grep.c (totalcc, totalnl): Use uintmax_t, not off_t. - (add_count): New function. - (nlscan, prline, grep): Use it to check line and byte count overflows. - (nlscan, grep): Don't keep track of counts when not asked to; this - avoids unnecessary overflow diagnostics. - (print_offset_sep): Now takes args of type uintmax_t and char, - not off_t and int. - -2000-05-16 Paul Eggert - - Problem reported by Bob Proulx , this patch - is base on his finding, with appropiate corrections. - - * src/grep.c (main): Fix bug: -x and -w matched even when no - patterns were specified. - * tests/empty.sh: Test for -x and -w bug in grep 2.4.2. - -2000-04-24 Paul Eggert - - POSIX.2 conformance fixes: grep -q now exits with status zero - if an input line is selected, even if an error also occurs. - grep -s no longer affects exit status. - - * src/grep.c (suppress_errors): Move definition earlier so - that suppressible_error can use it. - (suppressible_error): New function. - (exit_on_match): New var. - (grepbuf): If exit_on_match is nonzero, exit with status zero - immediately. - (grep, grepfile, grepdir): Invoke suppressible_error. - (main): -q sets exit_on_match. - - * doc/grep.1, doc/grep.texi, NEWS: - Document -q's behavior as required by POSIX.2. - - * tests/status.sh: - Test for -q and -s behavior as conforming to POSIX.2. - -2000-04-20 Paul Eggert - - * tests/Makefile.am (TESTS_ENVIRONMENT): - Set GREP_OPTIONS to the empty string. - -2000-04-20 Paul Eggert - - * tests/status.sh: Fix typo: test -b -> test -r. - -2000-04-20 Paul Eggert - - * src/dfa.c (lex): - Do not assume that [c] is equivalent to [c-c]; this isn't true - if LC_COLLATE specifies that some characters are equivalent. - (setbit_case_fold): New function. - (lex): Use it to simplify the code a bit. - -2000-04-17 Paul Eggert - - Do CRLF munging only if HAVE_DOS_FILE_CONTENTS, instead of - having it depend on O_BINARY (which leads to incorrect results - on BeOS, VMS, and MacOS). - - * bootstrap/Makefile.try (DEFS): Add -DHAVE_DOS_FILE_CONTENTS. - * src/system.h (SET_BINARY): Define only if HAVE_DOS_FILE_CONTENTS. - (O_BINARY): Do not define. - - * m4/dosfile.m4: Define HAVE_DOS_FILE_CONTENTS if it appears we're - using DOS. - - * src/grep.c (undossify_input, fillbuf, dosbuf.c, prline, main): - Depend on HAVE_DOS_FILE_CONTENTS, not O_BINARY, when handling CRLF - matters. - (grepfile, main): Depend on SET_BINARY, not O_BINARY, when - handling binary files on hosts that care about text versus binary. - -2000-04-17 Paul Eggert - - * lib/getpagesize.h (getpagesize): Define to B_PAGE_SIZE if - __BEOS__ is defined. Based on a fix by Bruno Haible - . - -2000-04-17 Bruno Haible - - * src/system.h [BeOS]: Ignore O_BINARY. - * src/getpagesize.h [BeOS]: Define getpagesize() as B_PAGE_SIZE. - -2000-04-10 Paul Eggert - - * doc/grep.1, doc/grep.texi, NEWS: -C now requires an operand. - * src/grep.c (short_options, long_options, main, usage): Likewise. - (context_length_arg): Renamed from ck_atoi. Now reports an error - and exits if the number is out of range for a context length. - (get_nondigit_option): New function, which checks for overflow - correctly, and which does not parse nonadjacent strings of digits - into a single number. - (main): Use get_nondigit_option instead of doing the code inline. - With -A, -B, and -C, optarg is now guaranteed to be nonzero. - -2000-04-08 Paul Eggert - - Now that we know that the input is always terminated by a - newline before the matching algorithms see it, clean up the - matching algorithms so that they no longer need to modify the - input by inserting a sentinel newline, and no longer worry - about running off the end of the buffer due to a missing sentinel. - - * src/grep.c (nlscan, prpending, prtext, grepbuf): Do not - worry about running off the end of the input buffer, since - it's now guaranteed to end in the sentinel newline. - * src/search.c (EGexecute, Pexecute): Likewise. - - * src/dfa.c (prtok, dfasyntax, dfaparse, copy, merge, state_index, - epsclosure, dfaexec, dfacomp): - Change many instances of "T *" to "T const *", to catch - any inadvertent programming errors made during this conversion. - * src/dfa.h (dfacomp, dfaexec, dfaparse): Likewise. - * src/grep.c (struct stats.parent, long_options, grepdir, - compile, execute, fillbuf, lastnl, lastout, nlscan, prline, - prpending, prtext, grepbuf, grep, grepfile, grepdir): Likewise. - * src/grep.h (struct matcher.compile, struct matcher.execute): - Likewise. - * src/kwset.c (struct kwset.trans, kwsalloc, kwsincr, treefails, - treedelta, hasevery, treenext, bmexec, cwexec, kwsexec): Likewise. - * src/kwset.h (kwsalloc, kwsincr, kwsexec): Likewise. - * src/search.c (kwsmusts, Gcompile, Ecompile, EGexecute, Pcompile, - Pexecute): Likewise. - - * src/dfa.c (dfaexec): - Use size_t, not char *, to avoid worrisome casts to convert - char const * to char *. - * src/dfa.h (dfaexec): Likewise. - * src/grep.c (execute): Likewise. - * src/grep.h (execute): Likewise. - * src/kwset.c (bmexec, cwexec, kwsexec): Likewise. - * src/kwset.h (struct kwsmatch.offset, kwsalloc, kwsincr, - kwsexec): Likewise. - * src/search.c (EGexecute, Fexecute, Pexecute): Likewise. - - * src/dfa.h (_PTR_T): Depend on defined __STDC__, not __STDC__. - (PARAMS): Depend on PROTOTYPES, not __STDC__. - - * src/dfa.c (dfasyntax): Last arg is unsigned char, not int. - * src/dfa.h (dfasyntax): Likewise. - - * src/dfa.h (struct dfa): Remove member newlines; no longer needed. - * src/dfa.c (build_state, dfaexec, dfafree): Do not worry - about special newline state. - - * src/search.c (matchers): Move definition to end of file, so - that we don't need forward decls. - (lastexact): Remove. - (kwset_exact_matches): New var; subsumes old lastexact var. - All uses changed. - - * src/dfa.c (index): Remove macro. - (REALLOC_IF_NECESSARY): Skip unnecessary test. - (tstbit, setbit, clrbit): Declare arg to be unsigned, to help compiler. - (copyset, zeroset, equal): Use C builtin primitives, to help compiler. - (dfaexec): Do not modify input string. - Remove newline parameter; no longer needed. - (comsubs): Use strchr, not index. - - * src/grep.h (matchers): Use fixed name size, not pointer (as - there's no need for the extra flexibility). All uses changed. - - * src/kwset.h (struct kwsmatch.offset): Renamed from beg, with - change of type to size_t. All uses changed. - - * src/grep.c (reset): No longer need kludge for dfaexec. Simplify. - (reset, grepbuf): Adjust to new interface for 'execute'. - (install_matcher): List is now terminated by null compile, - not null name. - Do not invoke setrlimit if that wouldn't change the limit. - - * src/dfa.c (xcalloc, xmalloc, xrealloc, prtok, tstbit, setbit, - clrbit, copyset, zeroset, notset, equal, charclass_index, - looking_at, lex, addtok, atom, nsubtoks, copytoks, closure, - branch, regexp, copy, insert, merge, delete, state_index, - build_state, build_state_zero, icatalloc, icpyalloc, istrstr, - ifree, freelist, enlist, comsubs, addlists, inboth): - Remove forward decls; no longer needed. - * src/grep.c (ck_atoi, usage, error, setmatcher, - install_matcher, prepend_args, prepend_default_options, - page_alloc, reset, fillbuf, grepbuf, prtext, prpending, prline, - print_offset_sep, nlscan, grep, grepfile): Likewise. - * src/kwset.c (enqueue, treefails, treedelta, hasevery, - treenext, bmexec, cwexec): Likewise. - * src/search.c (Gcompile, Ecompile, EGexecute, Fcompile, Fexecute, - Pcompile, Pexecute, kwsinit): Likewise. - - * src/search.c (Pcompile): Do not assume newly allocated - storage is zeroed. - -2000-04-06 Paul Eggert - - * doc/grep.1, doc/grep.texi, NEWS: Improve the explanation of - locale-dependent behavior of range expressions. Mention - LC_COLLATE, since this affects range expressions. - -2000-03-26 Paul Eggert - - * Makefile.am (ACINCLUDE_INPUTS): Add decl.m4, inttypes_h.m4, - uintmax_t.m4, ulonglong.m4, xstrtoumax.m4. - * m4/Makefile.am (EXTRA_DIST): Likewise. - - * src/Makefile.am (base_sources): - Add xstrtol.c, xstrtol.h, xstrtoumax.c. - (EXTRA_DIST): Add strtol.c. - - * configure.in (jm_AC_TYPE_UINTMAX_T, jm_AC_PREREQ_XSTRTOUMAX, - HAVE_DECL_STRTOUL, HAVE_DECL_STRTOULL): Add. - (AC_REPLACE_FUNCS): Add strtoul. - - * src/grep.c: Include xstrtol.h. - (ck_atio): Use xstrtoumax and do proper overflow checking. - (max_count, outleft): Now off_t, not int. - (main): Likewise. Use xstrtoumax to convert max_count from string. - - * acconfig.h (HAVE_DECL_STRTOUL, HAVE_DECL_STRTOULL): New #undefs. - (HAVE_STPCPY, ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, - HAVE_LC_MESSAGES): Remove. - - * m4/decl.m4, m4/inttypes_h.m4, m4/uintmax_t.m4, m4/ulonglong.m4, - m4/xstrtoumax.m4, src/strtol.c, src/strtoul.c, src/strtoull.c, - src/strtoumax.c, src/xstrtol.c, src/xstrtol.h, src/xstrtoumax.c: - New files, taken unchanged from textutils, fileutils, sh-utils - and/or tar. - -2000-03-23 Paul Eggert - - * src/search.c (Pcompile): Add support for NUL bytes in - Perl regular expressions. - -2000-03-23 Paul Eggert - - * NEWS, doc/grep.1, doc/grep.texi: Change --pcre to --perl-regexp. - * src/grep.c (long_options, usage): Likewise. - - * doc/grep.1, doc/grep.texi: Remove pgrep program. - * src/Makefile.am (bin_PROGRAMS): Likewise. - (pgrep_SOURCES): Remove. - - * src/grep.c (main): Rename matcher from "pgrep" to "perl". - * src/search.c (matchers): Likewise. - - * src/search.c: Do not include stdio.h; no longer needed. - (NILP): Remove. - (sub): No longer static. - (n_pcre): Remove. - (cre): No longer an array. Present only if HAVE_LIBPCRE. - (extra): New variable. - (Pcompile): Use fatal to report errors. - This also removes a possible core dump. - Add checks (marked FIXME) for restrictions in pcre. - Use pcre_maketables for proper localized behavior. - (Pcompile, Pexecute): Use GNU coding style. - The argument is a single pattern, not a list of patterns separated - by newlines; this is for consistency with grep and egrep. - Use pcre_study for speed. - (Pexecute): Abort if we lack pcre. - Abort if pcre_exec reports an impossible error. - Use code similar to the rest of search.c - to narrow down to the line we've found. - -2000-03-21 Alain Magloire - - * configure.in: added AC_CHECK_LIB(pcre, pcre_exec) - * ChangeLog: Typos corrected. - * src/search.c: new MACRO HAVE_LIBPCRE - -2000-03-21 H.Merijn Brand - - * src/Makefile.am(bin_PROGRAMS): added pgrep and new macro - pgrep_SOURCES. - * src/search.c: new functions Pcompile() and Pexecute() - to support PCRE. Update matcher[] array for pgrep. - * src/grep.c: new short and long option --pcre and -P. - usage() updated. - -2000-03-21 Bastiaan Stougie - - Improvement of the -m or --max-count option. Now works for NUM > 1 and - prints trailing context for the last matching line. - - * src/grep.c - (after_last_match): Is a new off_t variable that replaces inputhwm - to retain the correct input offset even after a call to fillbuf. Note - that after_last_match has a different meaning than inputhwm: - it always points to the offset in the input of the first byte after - the last matching line, and is 0 if no matching line has been found - yet. - (grep): Print trailing context after the NUMth match when the -m NUM - option is used. - (grep): Added comment. Should have been commented already. - (grepbuf): Now updates outleft correctly. This fixes the bug that the - -m NUM option did not stop after NUM lines for NUM greater than 1. - (grepbuf, prtext): Now update after_last_match instead of inputhwm. - (fillbuf): No longer updates inputhwm. - (prpending): When outputting trailing context of the max_count-th - matching line, stop at the first matching line. - (grepfile): Seek to after_last_match or eof, depending on the values - of outleft and bufmapped. - (usage): added the -m or --max-count option to the help message. - * doc/grep.texi, doc/grep.1: Document the change of the -m option. - -2000-03-17 Paul Eggert - - Add new -m or --max-count option, based on a suggestion by - Bastiaan Stougie. - - * doc/grep.texi, doc/grep.1: Document it. - * src/grep.c (short_options, long_options, main): Add it. - (inputhwm): New variable. - (fillbuf, prtext, grepbuf): Set it. - (bufmapped): Now a macro (defined to zero) if HAVE_MMAP is not defined. - (max_count, outleft): New variables. - (prtext, grepbuf, grep): Don't output more than outleft lines. - (grepfile): If grepping standard input, seek to the limit of what - we've read before exiting. This fixes a bug with mmapped input, - and is needed for proper -m support. - (main): Exit immediately if -m 0 is specified. - -2000-03-08 Alain Magloire - - * configure.in: version 2.4.2 - -2000-03-07 Paul Eggert - - * Make intl subdirectory match fileutils, tar, etc.; - see intl/ChangeLog for details. - - * src/getpagesize.h: Reformat to match latest fileutils. - - * src/savedir.c (savedir): Work even if directory size is - negative; this can happen with some NFS screwups. - -2000-03-03 Jim Meyering - - * regex.m4: Make sure re_compile_pattern accepts patterns like `{1'. - -2000-03-02 Alain Magloire - - * 2.4.1 Release - -2000-02-25 Paul Eggert - - * configure.in (LIBOBJS): Work around automake 1.4 bug: - regex.c wasn't being passed through ansi2knr on pre-ANSI hosts. - (ac_use_included_regex): Fix typo in warning. - * src/Makefile.am (EXTRA_DIST): Remove regex.c, as the LIBOBJS - workaround means that automake now puts regex.c into DIST_COMMON. - -2000-02-25 Alain Magloire - - * po/*.po: update of the PO files. - -2000-02-22 Eli Zaretskii - - * doc/grep.1: Two small glitches(typos). - -2000-02-18 Eli Zaretskii - - * djgpp/config.site (prefix, INSTALL): Use /dev/env/DJDIR instead - of ${DJDIR}, so that the produced Makefile's work on any DJGPP - installation. - -2000-01-30 Alain Magloire - - * doc/grep.1: corrected typo. - Noted by Ruslan Ermilov. - -2000-01-30 Alain Magloire - - * vms/Makefile.am: added config_vms.h to EXTRA_DIST. - * vms/config_vms.h: New File, contains macros specific to VMS and - avoid namespace collision with operating system supplied C library. - * vms/make.com: Better compiler auto-detection; information for builds - on pre-OpenVMS 7.x systems; general overhaul. - * src/getpagesize.h: Reinstate support for different pagesizes on - VAX and Alpha. Work around problem with DEC C compiler. - * src/vms_fab.c: Cast to some assigments; fixed typo argcp vs. argp. - * src/vms_fab.h: Added new include files to avoid warnings about - undefined function prototypes. - Those patches were provided by Martin P.J. Zinser (zinser@decus.de). - -2000-01-30 Paul Eggert - - * src/grep.c (main): Update copyright notice. - -2000-01-28 Alain Magloire - - * src/grep.c (usage): The example "%s -i 'hello.*world' could - lead to confusion when progname is 'fgrep. - Noted by Akim Demaille. - - * configure.in: Reenable, jm_INCLUDE_REGEX() since we now - track GNU lib C. - * src/Makefile.am: EXTRA_DIST new macros with regex.c regex.h. - Requested By Ulrich Drepper. - -2000-01-25 Paul Eggert - - * src/grep.c (grep): If the final byte of an input file is not - a newline, grep now silently supplies one. - * doc/grep.texi, NEWS: Likewise. - -2000-01-25 Paul Eggert - - * NEWS, doc/grep.1, doc/grep.texi: Add -I option. - * src/grep.c (short_options, usage, main): Likewise. - - * doc/grep.texi: Fix some incorrect references to ASCII. - -2000-01-25 Paul Eggert - - * doc/grep.1: Simplify synopsis; sort options; mention - environment variables; clean up some minor gaffes. - -2000-01-25 Paul Eggert - - * doc/grep.texi: - Fix some errors in description of [:print:] and the like. - -2000-01-23 Paul Eggert - - * src/dfa.c (FETCH, lex): Put brackets around if-body to avoid - GCC warning about ambiguous if-then-else. - -2000-01-23 Paul Eggert - - * src/regex.c (GET_UNSIGNED_NUMBER): Allow only ASCII digits. - * src/dfa.c (ISASCIIDIGIT): New macro. - (lex): Use it instead of ISDIGIT. - -2000-01-23 Paul Eggert - - The bug is that regular expression ranges like [a-z] compare raw - byte codes to the range boundaries, whereas POSIX says that they - should use the current collating sequence instead. For example, - in Solaris 7 with LC_ALL=en_US, the command - echo x | grep '[ -~]' - outputs 'x', but it shouldn't output anything since ' ' and '~' - sort before all letters in that locale. - - * src/regex.c (compile_range): When matching a character - range, use the current collating sequence, as POSIX requires. - * src/dfa.c (lex): Likewise. - -2000-01-20 Alain Magloire - - * tests/Makefile.am (dist-hook): Added new rule to make sure - that the shell scripts have the right permissions. - * src/posix/Makefile.am (EXTRA_DIST): added regex.h in the - distribution. - * THANKS: updated. - -2000-01-18 Alain Magloire - - * Rectification the initial patch to add --binary-file option - was done by Ruslan Ermilov. - -2000-01-17 Paul Eggert - - Sync with sources of fileutils 4.0n, tar 1.13.17, glibc 2.1.3a1. - Convert to ANSI C prototypes (using ansi2knr for backwards - compatibility), as this makes it easier to sync. - - * configure.in (AC_OBJEXT): Spell in a funny way, to work around - a bug in automake 1.4 with ansi2knr. - (LIBOBJS): Add assignment so that .o files in LIBOBJS are also built - via the ANSI2KNR-filtering rules. - (AC_OUTPUT): Add src/posix/Makefile. - * src/Makefile.am (AUTOMAKE_OPTIONS): Add ansi2knr. - (SUBDIRS): New macro. - * src/ansi2knr.1, src/ansi2knr.c, src/posix/Makefile.am: New files. - * src/dfa.c, src/dosbuf.c, src/grep.c, src/kwset.c, src/search.c, - src/vms_fab.c: - Use prototypes for function definitions. - * src/grep.c (main): Use int counter for default context, - fixing an ANSI portability bug uncovered by the above changes. - - * config.guess, config.sub, install-sh, missing, src/alloca.c, - src/getpagesize.h, src/memchr.c, src/savedir.c, src/savedir.h, - src/stpcpy.c: - Upgrade to latest version from fileutils 4.0n. - - * src/getopt.c, src/getopt.h, src/getopt1.c: Upgrade to latest - version from tar 1.13.17. - - * src/obstack.c, src/obstack.h, src/regex.c, src/regex.h: - Upgrade to glibc 2.1.3 alpha 1, with K&R C portability fix. - * src/posix/regex.h: New file, from glibc 2.1.3 alpha 1. - -2000-01-04 Paul Eggert - - Initial patch by Ruslan Ermilov. - - Add --binary-files option. - * NEWS, doc/grep.1, doc/grep.texi: Document it. - * src/grep.c (BINARY_FILES_OPTION): New constant. - (long_options, grep, usage, main): New --binary-files option. - (binary_files): New var. - * src/system.h (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM, CHAR_MAX): - New macros. - (INT_MAX, UCHAR_MAX): Define in terms of TYPE_MAXIMUM. - -2000-01-04 Paul Eggert - - * savedir.c (savedir): Don't store past the end of an array if - name_size is zero and the directory is empty. - Reported by Dima Barsky . - -1999-12-03 Alain Magloire - - * 2.4 Release. - -1999-11-18 Paul Eggert - - * m4/largefile.m4 (AC_SYS_LARGEFILE_FLAGS): Work around a - problem with the QNX 4.25 shell, which doesn't propagate exit - status of failed commands inside shell assignments. - -1999-11-13 Eli Zaretskii - - * doc/grep.texi: Minor markup and spelling corrections. Use - @noindent where appropriate. - - * PATCHES-{AM,AC}: rename to PATCHES.{AM,AC} - -1999-11-12 Eli Zaretskii - - doc/grep.texi: Minor fixes and typos corrected. - djgpp/README: Updated version. - -1999-11-07 Paul Eggert - - * src/grep.c (usage): Fix misspelling. - -1999-11-07 Paul Eggert - - Don't assume that the C library has re_set_syntax and friends. - * src/Makefile.am (base_sources): Add regex.c, regex.h. - (EXTRA_DIST): Remove regex.c, regex.h. - - * src/grep.c (prtext): Use out_quiet, not not_text, to decide - whether to set pending to zero at the end. - (not_text): Remove static variable, undoing latest change. - (grep): Likewise. - - * doc/grep.texi: Tighten up the text, and fix some minor - spelling and usage errors. Use @enumerate rather than @table - @samp, since it's better for Q&A format. Add cross - references. - -1999-11-01 Alain Magloire - - * src/search.c: Use the more portable [[:alnum:]] - to define a word instead of Ascii dependent [0-9A-Za-z] - * src/grep.c: make not_text global to not display text when - the context switches -A/-B/-C are use on binary files. - * make grep-2.3g available for testing. - * configure.in: drop support for --without-included-regex. - This was generating bogus bug reports, since many GNU/Linux - users have different version of glibc. And glibc maintainers - decided to drop k&r support. - -1999-11-01 Arnold D. Robbins - - * regex.c (init_syntax_once): move below definition of - ISALNUM etc., then use ISALNUM to init the table, so that - the word ops will work if i18n'ed. - (SYNTAX): And subscript with 0xFF for Latin-1 characters. - -1999-10-26 Alain Magloire - - * src/regex.c: Merge changes from GNU lib C. - * Updated the *.po files - -1999-10-26 Paul Eggert - - * src/grep.c (fillbuf): Don't report buffer size overflow if - newalloc == save and maxalloc == save. This can happen - e.g. when reading a large page-aligned file that contains - no newlines. - -1999-10-21 Paul Eggert - - * src/grep.c (usage): Give example. Clarify -F. - Explain exit status more clearly. - -1999-10-12 Paul Eggert - - * doc/grep.texi: Shorten the commentary about egrep and {. - "BSD grep" -> "traditional grep". - * doc/grep.1: Match recent changes to grep.texi. - -1999-10-11 Paul Eggert - - * NEWS, doc/grep.1, doc/grep.texi: New option --mmap. - * src/grep.c (mmap_option): New variable. - (long_options, reset, usage): Add --mmap. - Default is now read, not mmap. - - * doc/grep.1: Document -Z or --null. - -1999-10-11 Paul Eggert - - * doc/grep.texi: Fix texinfo glitches. POSIX -> POSIX.2 where - appropriate. - -1999-10-11 Paul Eggert - - * acconfig.h (ssize_t): New #undef. - - * configure.in (AC_CHECK_TYPE): Add ssize_t. - - * src/grep.c (PREFERRED_SAVE_FACTOR): New macro. - (reset): If the buffer has already been allocated, set bufsalloc to - be bufalloc / PREFERRED_SAVE_FACTOR. This avoids problems when - bufsalloc == bufalloc (possible after reading a large binary file). - (reset): Use PREFERRED_SAVE_FACTOR instead of magic constant. - Do not set bufbeg; nobody uses it. - Always set buflim. - Check for lseek error. - Use SEEK_CUR, not a magic constant. - (fillbuf): Return an error indication, not a count. - All callers changed. - Do not assume ssize_t fits in int. - Use PREFERRED_SAVE_FACTOR instead of magic constant. - Clean up mmap code. - Do not attempt to mmap zero bytes. - Check for lseek error. - Use SEEK_SET, not a magic constant. - Work correctly if read is interrupted. - (grepfile): Work correctly if open or close is interrupted. - - * src/system.h (SEEK_SET, SEEK_CUR): New macros. - -1999-10-02 Alain Magloire - - * src/regex.[ch]: upgrade from GNU lib C source tree. - - * make beta 2.3f available. - -1999-10-02 Paul Eggert - - * NEWS: egrep is now equivalent to `grep -E'. - The lower bound of an interval is not optional. - You can specify a matcher multiple types without error. - -u and -U are now allowed on non-DOS hosts, and have no effect. - * doc/grep.texi: Likewise. - * doc/grep.1: Likewise. - Fix some troff bugs that prevented `groff' from rendering the page. - - * src/egrepmat.c, src/fgrepmat.c, src/grepmat.c (default_matcher): - Remove. - (matcher): Add. - * src/grep.h (default_matcher): Remove. - (matcher): Now exported from ?grepmat.c, not grep.c. - - * src/dfa.c (lex): If { would start an invalid interval specification, - treat it as a normal character. - Remove (broken) support for {,M} meaning {0,M}. - Diagnose bogus intervals like {1,0}. - (closure): maxrep is now -1 to indicate no limit, not zero; - zero is a valid value for maxrep, meaning an upper bound of zero. - - * src/grep.c (short_options): New constant. - (long_options, main): -u and -U are now supported on Unix, - with no effect. - (matcher): Removed; now defined by ?grepmat.c. - (install_matcher): Renamed from setmatcher. - (setmatcher): New function. - (usage): Report new, more uniform option scheme. - (main): Do not initialize matcher; ?grepmat.c now does this. - Rely on setmatcher to catch matcher conflicts. - Default matcher is "grep". - - * src/search.c (matchers): - Remove "posix-egrep" matcher; no longer needed. - (Ecompile): Likewise. - The egrep matcher now has POSIX behavior. - - * tests/bre.tests: grep '\{' is no longer an error. - Fix test for interval too large, and enable it. - * tests/ere.tests: grep -E {1 is no longer an error - Likewise for a{1, a{1a, a{1a}, a{1,x}. - -1999-09-22 Paul Eggert - - * largefile.m4 (AC_SYS_LARGEFILE_FLAGS): Work around GCC - 2.95.1 bug with HP-UX 10.20. - -1999-09-12 Paul Eggert - - * src/grep.c (fillbuf): Fix typo: we sometimes reported - arithmetic overflow even when there wasn't any. - -1999-09-12 Paul Eggert - - * configure.in (AC_CHECK_FUNCS): Add memmove. - - * src/system.h (S_ISREG): New macro. - (memmove): Define if ! defined HAVE_MEMMOVE && ! defined memmove, - not if !defined STDC_HEADERS. This is needed for SunOS 4.1.4, - which defines STDC_HEADERS but lacks memmove. - - * src/grep.c (bufoffset): Needed even if !defined HAVE_MMAP. - (reset): Always fstat the file, since we always need its size if it is - regular. - Similarly, get the buffer offset of every regular file. - Set bufmapped to 0 if the file's initial offset is not a multiple - of the page size. - (fillbuf): Calculate an upper bound on how much memory we should - allocate only for regular files, since we don't know the sizes of - other files. - Don't bother to check whether the file offset is a multiple of the page - size, since we now do that just once in `reset'. - When an mmapped area would fall past the end of the file, trim it to - just before instead of giving up immediately and doing a `read'; - that avoids a worst-case behavior that could read half an mmapped file. - Fix bug when computing offsets on hosts that don't have mmap. - -1999-08-27 Paul Eggert - - * src/system.h (memmove): New macro. - - * src/grep.c (page_alloc): Reallocate the old buffer instead - of having both old and new buffers active simultaneously. - Remove valloc debugging variant, which no longer applies. - - (fillbuf): Rejigger the buffer allocation mechanism. The old - mechanism could allocate more than 10*N bytes for an N-byte - file, which was excessive. Check for arithmetic overflow a - bit more carefully. - -1999-08-25 Paul Eggert - - * src/grep.c (grepdir): - Don't assume that st_ino and st_dev must be integers; - POSIX.1 allows them to be floating-point (!). - - * src/vms_fab.h (arr_ptr): `:' -> `;' to fix typo. - -1999-08-18 Alain Magloire - - * 2.3e snapshot. - -1999-08-18 Alain Magloire - - * src/search.c: On a CRAY J90 system running UNICOS 8.0. - Compilation of ./src/search.c failed because the declaration of - the variable "regex": - static struct re_pattern_buffer regex; - conflicted with a previous declaration search.c #includes "system.h", - which #includes , which declares : - extern char *regex __((char *_Re, char *_Subject, ...)); - The declaration in search.c is local to that one source file. - I just changed its name to something less likely to conflict. - (I called it "regexbuf", but you could pick any name you want.) - Excerpt email from Dean Kopesky. - -1999-08-16 Paul Eggert - - Upgrade large-file support to the version used in tar and - textutils. - - * Makefile.am (ACLOCAL_AMFLAGS): Define to be empty. - (M4DIR, ACINCLUDE_INPUTS): New macros. - ($(srcdir)/acinclude.m4): New rule. - - * configure.in (AC_CANONICAL_HOST, AM_C_PROTOTYPES): Add. - (AC_SYS_LARGEFILE): Renamed from AC_LFS, for compatibility - with what should appear in the next autoconf release. - - * m4/largefile.m4: Renamed from m4/lfs.m4. - - * src/ansi2knr.1, src/ansi2knr.c, config.guess, config.sub: - New files. config.guess and config.sub ar needed by the new - AC_SYS_LARGEFILE. ansi2knr is needed by AM_C_PROTOTYPES, - which in turn is needed by the new AC_SYS_LARGEFILE. - -1999-08-16 Alain Magloire - - * 2.3d snapshot on ftp server. - -1999-07-26 Paul Eggert - -Several GNU tools have options to process arbitrary file names, even -file names that contain newline characters. These include `find --print0', `perl -0', `sort -z', and `xargs -0'. It'd be handy if GNU -grep also processed such file names. Here's a proposed patch to do -this, relative to grep 2.3c. This patch introduces two options, one -for the data, and one for the file names. (Sometimes one wants -null-terminated file names in the output, and sometimes one wants to -process lists of null-terminated strings, and these are orthogonal -axes.) - - * NEWS, doc/grep.texi: New -z or --null-data and -Z or --null options. - * src/grep.c (long_options, usage, main): Likewise. - - * src/dfa.h (dfasyntax): New eol parameter. - * src/dfa.c (eolbyte): New var. - (dfasyntax): Set it from new parameter. - (lex, dfastat, build_state, dfaexec): Use it instead of '\n'. - - * src/grep.h (eolbyte): New decl. - * src/grep.c (eolbyte): New var. - (nlscan, prpending, prtext, grepbuf, grep): Use it instead of '\n'. - (filename_mask): New var. - (prline, grepfile): Output NUL separator if filename_mask is zero. - (grep): Look for '\200' as the hallmark of a binary file, not '\0', - if -z or --null-data is specified, since it implies that '\0' is - expected as text. - - * src/search.c (Gcompile, Ecompile): Pass eolbyte to dfasyntax. - (EGexecute, Fexecute): Use eolbyte instead of '\n'. - -1999-06-15 Alain Magloire - - * src/grep.c, doc/grep{1,texi} : - --revert-match should be --invert-match. - Correction proposed by Karl Berry. - -1999-06-12 Alain Magloire - - * doc/grep.{1,texi}: add description for --with-filename. - Noted missing by UEBAYASHI Masao. - -1999-03-17 Paul Eggert - - * NEWS: Add GREP_OPTIONS. - - * doc/grep.texi: Document GREP_OPTIONS, and the other - environment variables. Fix doc for [:blank:], [:cntrl:], [:punct:]. - - * src/grep.c (prepend_args, prepend_default_options): New functions. - (main): Use them to implement GREP_OPTIONS. - * src/system.h (getenv): New decl. - -1999-03-16 Volker Borchert - - * configure.in: Use case case ... esac for checking Visual C++. - When ${CC} contains options it was not recognize. - -1999-03-07 Paul Eggert - - * src/grep.c (usage): Don't report -E, -F, and -G unless we're grep. - (main): Don't match options -E, -F, and -G unless we're grep. - Remove after-the-fact check for options -E, -F, and -G, since - they're no longer needed. - -1999-03-05 Eli Zaretskii - - * src/grep.c (main): Print the name of the default matcher instead - of just "grep". - -1999-02-06 Alain Magloire - - * tests/*.awk : Linux users are seeing "Broken Pipe" on make check. - The problem is that grep does not drain its stdin, thus the previous - process in the pipeline receives a SIGPIPE. Other shells are silent - about this. There is actually no failure, since the broken pipe is - expected. You can work around it by changing the pipeline, so that - the input is drained, like this: - status=`echo 'check' | { ${GREP} -E -e pattern >/dev/null 2>&1; - echo $?; cat >/dev/null; }`; if test $status -ne $errnu then ... fi - Excerpt email from Andreas Schwab. - -1999-02-23 Alain Magloire - - * src/grep.c : Restrict the use of -E, -F, -G - to only grep driver, Posix behaviour. {f,e}grep - the matcher is already set. This change may brake - scripts, warn in NEWS. - - * doc/grep.{1,texi} : -C takes arguments, upgrade manual. - - * beta 2.3a - -1999-02-23 Alain Magloire - - * configure.in : Change the configure VC test from - 'test x$ac_cv_prog_CC = xcl;' to 'test x"$ac_cv_prog_CC" = xcl;' - Email from Joshua R. Poulson. - -1999-02-23 Paul Eggert - - Fix porting bug reported by Amakawa Shuhei for SunOS 4.1.4-JL. - The btowc.c shipped with grep 2.3 is incorrect for Solaris - 2.5.1 and earlier, as it assumes UTF8, which these OSes do not - support. Solaris 7 supports btowc, so there's no need to ship - a substitute for it. The only questionable case is Solaris - 2.6, which lacks btowc but does support UTF8. However, 2.6 - supports UTF8 but only as a demonstration (for an English - locale!); Japanese Solaris 2.6 users typically use EUC, or - sometimes shift-JIS, but they cannot use UTF8 since Japanese - UTF8 is not supported. Hence there's no point to having grep - substitute a btowc that uses UTF8, as it is either redundant, - or it will almost invariably have incorrect behavior. - - * configure.in (AC_CHECK_HEADERS): Don't set USE_WCHAR. - (AC_CHECK_FUNCS): Add btowc, wctype. - (AC_REPLACE_FUNCS): Don't replace btowc; our replacement is - invariably doing the wrong thing anyway, at least on SunOS/Solaris. - Don't bother to check for wctype in -lw, as we don't support - wide characters on Solaris 2.5.1 or earlier anyway. - - * bootstrap/Makefile.try (OBJS): Remove btowc.$(OBJEXT). - - * src/btowc.c: Removed; no longer needed. - -1999-02-19 Paul Eggert - - * NEWS: Fix typo when talking about the old behavior of - silently skipping directories; it was grep 2.1, not grep 2.2. - -1999-02-15 Alain Magloire - - * bootstrap/Makefile.try : add DJGPP DEFS. - Done by Elie Zaretsckii. - -1999-02-14 Alain Magloire - - * m4/gettext.m4 : Guard [] with changequote. - From Elie Zaretskii. - - * djgpp/config.bat : Makefile.in.in --> Makefile.in-in - From Elie Zaretskii. - - * src/dosbuf: k&r function parameter. - - * release of 2.3. - -1999-02-10 Alain Magloire - - * bootstrap/{Makefile{try,am},REAMDE} : skeleton - provided for system lacking the tools to autoconfigure. - - * src/{e,f,}grepmat.c: added guard [HAVE_CONFIG_H] - -1999-02-10 Alain Magloire - - * PATCHES-AC, PATCHES-AM: updated. - - * m4/regex.m4 : updated. - -1999-02-05 Eli Zaretskii - - * m4/gettext.m4 : Support DOS-style D:/foo/bar absolute file - names. - - * aclocal.m4 (DJGPP) : Use $DJ_GPP instead, since changing the - latter prevents GCC from finding headers and libraries. - - * djgpp/config.bat: Make building from another directory work - - * djgpp/config.sed: Remove redundant command wich edited path - separator: now done by configure. - - * src/grep.c [O_BINARY]: Add prototype for undossify_input. - - * doc/grep.texi (Introduction): Typo fixed. - -1999-02-03 Alain Magloire - - * grep-2.2f beta release. - -1999-02-02 Alain Magloire - - * m4/{djgpp,envsep,glibc,regex,dosfile,isc-posix}.m4 : - New files to aid configuration and unload configure.in. - * m4/Makefile.am : updated. - * src/btowc.c : protect for wchar.h - -1999-01-28 Alain Magloire - - * intl/Makefile.in: Replace .o with .${ac_objext} where necessary. - Work around a limitation of Visual C++ on Cygwin32. - * acconfig.h configure.in: Define `alloca' as `_alloca' when CC=cl. - This little hack was suggested by Ian Roxborough . - Patch forwarded by Ben Elliston. - -1999-01-28 Alain Magloire - - * PATCHES-AM: New file. A small patch for automake-1.4, use $(sep) - as the path separator base on @SEP@. - * PATCHES-AC configure.in : updated for autoconf-13. - -1999-01-27 Volker Borchert - - * grep.c: fgrep -NUM not working correctly. - add the argument number to digit_args_val. - -1999-01-22 Paul Eggert - - Prevent grep -r from recursing infinitely through directory loops via - symbolic links. - - * grep.c (struct stats): New type. - (stats_base): New var. - (bufstat): Remove; subsumed by stats->stat. - (reset, fillbuf, grep, grepdir, grepfile): Pass struct stats * arg, - for directory loop checking; use this instead of the bufstat global. - All callers changed. - (grepfile): Stat the file before invoking grepdir. - (grepdir): Assume that the argument has already been statted. - No longer a need for a directory size argument, since it - can be gotten from the struct stats * argument. - Check for directory loops. - Create linked list of directories currently being visited, - to detect loops. - -1998-12-29 Kaveh R. Ghazi - - intl/localealias.c: When building grep-2.2e using cc on Irix4, - I needed the following patch to intl/localealias.c. - (Its the same patch used by fileutils-4.0.) The patch resolves - conflicts between char* and unsigned char* in the i18n code. - -1998-12-10 Alain Magloire - - * src/grep.c : Typo in contex -->context - Noted by Vladimir Michl. - -1998-12-01 Alain Magloire - - * doc/Makefile.am djgpp/Makefile.am m4/Makefile.am vms/Makefile.am: - New files. - - * m4/progtest.m4: proctect '[]' from m4. - Noted by Eli Z. - - * PATCHES-AC: New file, add the patch for autoconf in the dist. - - * acconfig.h: (HAVE_DOS_FILENAME) - - * TODO: updated. - - * src/search.c: remove obsolete 'gegrep,ggrep,gnugrep' - matchers. grep no longer depend on argv[0]. - - * grep-2.2e beta to test DJGPP port. - -1998-11-28 Paul Eggert - - Various portability enhancements: - - Don't assume that O_BINARY implies DOS. Use separate - macros D_OK (for DOS-like directory access) and - HAVE_DOS_FILE_NAMES (for DOS-like file names). - - Don't assume that off_t fits into long; it doesn't on Solaris 2.6. - - Have is_EISDIR set errno properly on hosts with screwed-up EISDIR. - - Treat ':' specially in DOS file names only if it's the end of a - drive specifier. - - Protect against errno < 0. - - * src/grep.c (is_EISDIR): Move defn to system.h. - (print_offset_sep): New function. - (fillbuf): Remove redundant test of O_BINARY. - (totalcc, totalnl): Now of type off_t. - (prline): Use print_offset_sep to print file offsets. - (grepfile): Don't set e to EISDIR; that's is_EISDIR's responsibility - on machines that don't work properly with EISDIR. - (grepdir): Don't assume ':' means slash on all DOS filenames; - it means it only in the file prefix. - - * src/system.h (strerror): Check for negative error numbers. - (is_EISDIR): Depend on D_OK, not O_BINARY. - (SET_BINARY): Depend on HAVE_SETMODE, not __DJGPP__. - (IS_SLASH, FILESYSTEM_PREFIX_LEN): Depend on HAVE_DOS_FILE_NAMES, - not O_BINARY. - (CHAR_BIT): New macro. - - * src/dosbuf.c (struct dos_map): - pos and add members are now of type off_t. - (dos_stripped_crs): Now of type off_t. - (dossified_pos): Now accepts arg and returns value of type off_t. - - * configure.in (AC_CHECK_FUNCS): Add setmode. - (HAVE_DOS_FILENAMES): New macro - -1998-11-27 Eli Zaretskii - - * djgpp/config.sed: New file, a Sed script to edit configure - script before running it on DOS/Windows. - * djgpp/config.bat: Updated to handle po2tbl.sed.in and - po/Makefile.in.in on DOS filesystems, and to run config.sed. - -1998-11-24 Jim Meyering - - * src/grep.c : Typo s/infalid/invalid/ - Also noted by Stanislav Brabec. - -1998-11-24 Eli Zaretskii - - * doc/grep.texi: I found and corrected several typos. - I believe the GNU standards require the section that describes the - options to the programs to be called ``Invoking'' or ``Invoking - ''. This is so users and programs can easily find - that node in any Info file. So I changed the name of the - `Options' chapter to `Invoking', and corrected the - cross-references accordingly. - I added some markup to things like file names and options. - I added some additional index entries where that seemed useful. - I also corrected some index entries, such as "@cindex [:alnum:]", - which used a colon in them (the colons confuse Info readers). - -1998-11-24 Alain Magloire - - * grep/doc/grep.texi : -h is not use for help. - Nit spotted by Jim Meyering. - -1998-11-23 Alain Magloire - - * doc: New directory, grep.1, {e,f}grep.man move here - * doc/grep.texi: New info manual - * doc/version.texi: New - * doc/Makefile.am: New - * tests/{ere,bre}.*: New files. The spencer2 test is split - in two ere/bre. - * config.hin: New, config.h.in rename to config.hin for OS - with limited file system aka DOS. - - * grep-2.2d release for beta. - -1998-11-18 Alain Magloire - - * src/regex.[ch] : Updated from GLibc, previous patches were - integrate by Ulrich Drepper and some added ones. - -1998-11-16 Paul Eggert - - * grep.h (__attribute__): New macro, if not GCC. - (fatal): Add __attribute__((noreturn)). - * grep.c (usage): Add __attribute__((noreturn)). - -1998-11-16 Paul Eggert - - Remove memory leak with valloced buffers, by invoking malloc instead. - - * configure.in (AC_CHECK_FUNCS), src/system.h (valloc): Remove. - * src/grep.c (page_alloc): New function. - (ubuffer, pagesize): New vars. - (ALIGN_TO): New macro. - (reset): Initialize new vars. Check for overflow in buffer size calc. - Use page_alloc instead of valloc. - (fillbuf): Likewise. Use memcpy to copy saved area. - -1998-11-15 Paul Eggert - - * dfa.c (dfacomp), search.c (EGexecute): Don't assume char is unsigned. - -1998-11-14 Paul Eggert - - * src/grep.c (grepdir): Fix bug: memory freed twice. - - * src/search.c (Gcompile, Ecompile): Don't invoke dfainit, - since dfacomp does it for us, and if we also do it then we - leak memory. - -1998-11-13 Eli Zaretskii - - * djgpp/config.bat: Rewrite to run the configure script via Bash. - * djgpp/config.site, djgpp/getconf: New files. - * djgpp/config.h, djgpp/*.mak, djgpp/po2tbl.sed: Remove. - * djgpp/README: Update instructions. - - * Makefile.am (EXTRA_DIST): Update the list of DJGPP files. - - * src/system.h (IS_SLASH): New macro. - (is_EISDIR): Define it here for DOS and Windows. - - * src/grep.c (main) [O_BINARY]: Set stdout to binary mode, so the - EOL formats of the input and output files match, unless stdout is - the console device. - (is_EISDIR): Don't define if already defined. Accept a second - argument, the file name; all callers changed. - (grepdir): Don't free `file', inside the loop. Use IS_SLASH to - check whether `dir' needs a slash. - (grepfile): If file is a directory, set e to EISDIR. - -1998-11-10 Alain Magloire - - * src/vms_fab.{c,h}: New file for VMS wildcard expansion - Written by Phillip C. Brisco. - - * vms/make.com : add line to compile vms_fab.c and - {e,f,}grepmat.c with link for each grep/fgrep/egrep. - Base on patch send by Phillib C. Brisco. - -1998-11-09 Alain Magloire - - * grep-2.2c on alpha for testing. - -1998-11-09 Paul Eggert - - * src/grep.1: Fix `Last Change' of output by generating the date - from the RCS Id. - - * src/grep.c (is_EISDIR): New macro. - (grep): If -s, suppress errors from trying to read directories. - (grepfile): Use is_EISDIR to simplify code. - (grepdir): If -s, suppress errors from trying to read directories. - - * src/grep.1: Fix -q -r -s problems; describe BSD grep better. - - * src/grep.c (main): Update copyright. - - Specify default matcher with default_matcher extern var, not - DEFAULT_MATCHER macro. This is more straightforward and means - we need to compile grep.c just once. - - * src/egrepmat.c, src/fgrepmat.c, src/grepmat.c: New files. - - * src/Makefile.am (base_sources): New macro. - (egrep_SOURCES, fgrep_SOURCES, grep_SOURCES): Now consist of - $(base_sources) plus the single tailoring file. - (grep_LDADD, egrep_LDADD, fgrep_LDADD): Remove. - (EXTRA_DIST): Remove grep.c, regex.c. - (fgrep.o, egrep.o): Remove. - - * src/grep.h (matcher): Now char const *. - (default_matcher): New decl. - - * src/grep.c (matcher): Now char const *. - (setmatcher): Now accepts char const *. - (main): Default the matcher from default_matcher (linked externally) - rather than DEFAULT_MATCHER (a macro). - -1998-11-08 Alain Magloire - - * src/grep.1: `prep.ai.mit.edu' should be replaced with `gnu.org'. - Nit from Paul Eggert. - -1998-11-06 Alain Magloire - - * src/grep.c: The Matcher is not set to argv[0] but - explicitly by a #define MATCHER at compile time default is "grep". - - * aclocal/: NEW dir. provides our own *.m4 - - * configure.in: Move Paul's Large Files to AC_LFS.(aclocal/lfs.m4) - Taken from Jim Meyering fileutils. - -1998-11-05 Alain Magloire - - * src/grep.1: update the man pages according to the - changes make by Miles. - - * po/*.po: updated. - - * first beta release for 2.3 (2.2a). - -1998-11-04 Miles Bader - - * src/grep.c (main): Rationalize interaction of -C/-NUM/-A/-B - options, and allow -C to have an optional argument. -NUM can - now be mixed with -C, and -A, -B always take precedence over - -C/-NUM, regardless of order. - (long_options): Let -C/--context take an optional argument. - -1998-11-03 Alain Magloire - - * src/dfa.c: HP-UX define clrbit/setbit as macros in - #undef if defined. - Fixed by Andreas Ley and Philippe Defert. - - * src/grep.1 : mention that -s follows POSIX.2 behavior. - Noted by Paul Eggert and others. - - * tests/khadafy.sh: a typo in failure(s). - Spotted By Sotiris Vassilopoulos. - -1998-11-01 Paul Eggert - - * src/system.h (IN_CTYPE_DOMAIN): New macro. - (ISALPHA, ISUPPER, ISLOWER, ISDIGIT, ISXDIGIT, ISSPACE, - ISPUNCT, ISALNUM, ISPRINT, ISGRAPH, ISCNTRL): Use - IN_CTYPE_DOMAIN instead of isascii. - -1998-08-18 Paul Eggert - - Add support for new -r or --recursive (or -d recurse or - --directories=recurse) option. - - * src/Makefile.am (grep_SOURCES): Add savedir.c, savedir.h, stpcpy.c. - - * src/grep.1: Describe new options. - - * src/grep.c: Include "savedir.h". - (long_options): Add -r or --recursive. - (RECURSE_DIRECTORIES): New enum value. - (IS_DIRECTORY_ERRNO): Remove. - (reset, grep): Add file name arg. - (grepdir, grepfile): New functions. - (initial_bufoffset): New var. - (reset): Initialize it. - (fillbuf): Use it. - (count_matches, list_files, no_filenames, suppress_errors): New static - vars; formerly were local to `main'. - (grep): Recurse through directories if the user asks for this. - (usage, main): Add new options. - (main): Change some local vars to be static, as described above. - Move most of the guts into grepfile function. - so that it can be recursed through. - - * configure.in (AC_HEADER_DIRENT, AC_FUNC_CLOSEDIR_VOID): Add. - (AC_REPLACE_FUNCS): Add stpcpy. - - * src/savedir.c, src/savedir.h, src/stpcpy.c: New files; - taken from fileutils 3.16u. - -1998-08-11 Paul Eggert - - * src/system.h (initialize_main): New macro. - * src/grep.c (main): Invoke initialize_main first thing. - -1998-04-29 Paul Eggert - - * NEWS, src/grep.1: Describe new -a and -d options. - - * src/grep.c (long_options, usage, main): - New options -d or --directories and -a or --text. - (directories, always_text): New variables. - (IS_DIRECTORY_ERRNO): New macro. - (reset): Now returns value specifying whether to skip this file. - Stat the file if either mmap or directory-skipping is possible. - Skip the file if it's a directory and we're skipping directories. - (grep): Skip the file if `reset' tells us to. - (main): If open fails because the file is a directory, and if we're - skipping directories, don't report an error. - Remove special case for DOS and Windows. - - * src/dosbuf.c (guess_type): Use the same method for guessing whether a - file is binary as grep.c's grep does. - There's no longer any need to declare `bp' to be unsigned. - -1998-04-26 Alain Magloire - - * grep-2.2 release. - - * src/dfa.c: Wrong revision was pulled out - for beta 2.1.1d. - * src/search.c: Wrong revision was pulled out - for beta 2.1.1d. - - * src/grep.c: ck_atoi () added instead of atoi (). - Suggestion from Jim Meyering. - ck_atoi () pulled from diffutils-2.7, maintained by Paul Eggert. - - * AUTHORS: Rephrase of some sentences. - * README: Rewording. - Noted and patched by Joel N. Weber II. - -1998-04-17 Kaveh R. Ghazi - - * src/dfa.h: Don't define `const', trust autoconf to handle it. - -1998-04-16 Alain Magloire - - * tests/{status,empty}.sh: wrong return status. - - * src/grep.c: Remove the REGEX part in usage (), it was - consider overkill by most. - -1998-04-14 Eli Zaretskii - - * djgpp/config.bat: Support file names with multiple dots on all - platforms. - - * djgpp/README: Add instructions about file names illegal on - MS-DOS. - -1998-04-13 Alain Magloire - - * src/dfa.c: by "popular" demand reverse - back to '_' not word-constituent. - - * grep-2.1.1c available for testing. - -1998-04-13 Karl Heuer - - * src/grep.c: (a) The directory check is done too early: - logically, if the argument is "-", then it refers to standard - input, regardless of whether there's something in the file - system answering to "-". - (b) The sh command "grep -l root /etc/passwd /etc/group 0<&-" - prints "(standard input)" instead of "/etc/passwd", because it - mistakenly believes that a named file will never be opened on fd - 0. The string "(standard input)" should be based on the file - having been originally specified as "-", rather than making - assumptions about the fd. - (c) the code that calls close(fd) is being done outside of the - test for a bad fd. Thus, if the open failed, this code will - attempt to close(-1). It should be done inside the "fd != -1" - branch. - This patch addresses all three of these problems. - -1998-04-13 Alain Magloire - - * configure.in: remove the deprecated AC_ISC_POSIX macro. - Spotted by Karl Heuer. - -1998-04-03 Eli Zaretskii - - * djgpp/main.mak, djgpp/src.mak, djgpp/tests.mak: Updated from the - relevant Makefile.in files. - - * djgpp/config.bat: Create files in intl directory like the - configure script does. - -1998-03-28 Eli Zaretskii - - * djgpp/main.mak, djgpp/src.mak, djgpp/tests.mak: Updated to track - changes in respective Makefile.in files. - - * src/dosbuf.c (guess_type): Avoid running off the end of the - buffer. Spotted by Paul Eggert. - -1998-03-27 Alain Magloire - - * grep-2.1.1b.tar.gz available. - - * src/regex.c: CLASS_CHAR_MAX set to 256 instead of 6 - when WCTYPE and WCHAR are not defined. When class names - where bigger then 6, it will not detect an error. - example '[[:alphabet:]]'. - - * Updated the copyright of the files with emacs. - With emacs Jim :). - -1998-03-26 Jim Meyering - - * src/dfa.c (IS_WORD_CONSTITUENT): Define. - (lex): Use IS_WORD_CONSTITUENT, not ISALNUM. - Don't special-case '_'. - (dfastate): Use IS_WORD_CONSTITUENT, not ISALNUM. - (dfaexec): Likewise. - -1998-03-25 Alain Magloire - - * tests/warning.sh: typos and replace the echos with - a simple cat. - Noted By Jim Meyering. - - * src/regex.c: #undef ISASCII and ISPRINT before defining - them(On Solaris it was define). - Pattern 'a[[:]:]]b' is an invalid char class and the error - from regex was 1(REG_NOMATCH) instead of 2 (REG_ECTYPE). - Fix with help from Ulrich Drepper. - - * src/grep.c (usage): Ulrich wrote: "A single printf should - not have more than 900 bytes. For translation reasons the - text shouldn't be split in too many pieces since this is - tiresome and also does not help to generate a consistent picture." - Noted by Ulrich Drepper. - * src/grep.c (usage): Dig out and old patch from - Franc,ois to explain the regex in usage(). - Ideas from Franc,ois Pinard. - -1998-03-23 Alain Magloire - - * testing: grep-2.1.1a for testing. - - * configure.in: Solaris needs '-lw' if we use wchar/wctype - functions. - * src/btowc.c: New file from GNU libc. Solaris 2.5 don't - have it define. - * configure.in : check for btowc (). - - * regex.c: Include before , to work around - a Solaris 2.5 bug. - Patch provided by Paul Eggert. - - * tests/status.sh: new file to check return status code. - * tests/empty.sh: new file to check for empty pattern. - * tests/warning.sh: new file to tell where to report errors. - - * configure.in: If available, prefer support for large files - unless the user specified one of the CPPFLAGS, LDFLAGS, or LIBS - variables. - Done by Paul Eggert. - - * src/grep.c (usage): change prep.ai.mit.edu for gnu.org. - -1998-03-18 Alain Magloire - - * src/grep.c (usage): Formating the --help message a bit off. - Noted by William Bader. - - * src/grep.c (main): When checking conflicting matcher for option -E the - matcher was to "egrep" instead of "posix-egrep". - Reported by kwzh@gnu.org. - - * src/grep.c: Typos and rewording the --help message. - Reported by Karl Heuer. - - * src/grep.1: The man page wording : - A regular expression matching a single character may be - followed by one of several repetition operators: - is unclear since 'x(yz)*z' is a valid regex. - Remove the "matching a single character". - Suggested by Harald Hanche-Olsen. - - * src/grep.c (main): `-f /dev/null' now specifies no patterns - and therfore matches nothing. - Reported by Jorge Stolfi. - Patched by Paul Eggert. - -1998-03-10 Alain Magloire - - * Ice storm 98(el nino). Lost grep repository disk, - and my $HOME directory, etc .. - Trying to get the emails/patch from dejanews.com - and start from grep-2.1. - sigh .... - -1997-11-01 Alain Magloire - - * src/grep.c: For the long options, the problems are: - --file appears in the option table as 'no_argument' - instead of 'required_argument'. - --files-with-matches is missing from the option table. - The help lists '--fixed-strings' as the long option for -F, - the table has '--fixed-regexp'. - --regexp appears in the option table as 'no_argument' - instead of 'required_argument'. - --with-filename is missing from the option table. - Reported by Grant McDorman and Krishna Sethuraman. - -1997-10-19 Alain Magloire - - * src/grep.c: the option "with-filename was not in the arg table. - Corrected by Jim Hand. - - * GNU gettext library from gettext-0.10.32. - - * src/grep.c: reverse back to greping directories, - One could skip the error message by defining - SKIP_DIR_ERROR. There is no clear way of doing - things, I hope to setle this on the next majore release - Thanks Paul Eggert, Eli Zaretskii and gnits for the - exchange. - - * tests/status.sh: add this check to make sure - That the return status code is ok. - -1997-10-10 Andreas Schwab - - * src/grep.1: Fix formatting. - - * configure.in: Check for wctype.h, wchar.h, libintl.h and - isascii, which are needed for regex.c. - -1997-10-01 Paul Eggert - - * src/grep.c (fillbuf): Don't warn about mmap failures. - -1997-09-7 Alain Magloire - - * src/grep.c: added code for -H --with-filename. - - * djgpp/*: patch wrongly apply - duplication of text in djgpp/{README,config.h}. - Filter djgpp/config.bat with unix2dos. - - * djgpp/make.mak: beautify - From Eli Zaretskii. - - * grep-2.1 release. - -1997-09-01 Alain Magloire - - * grep-2.0f out for testing. - - * update to GNU gettext library from gettext-0.10.31 - - * grep.c : have a nicer format for --version. - Noted by Ulrich Drepper. - - * obstack.[ch]: updated from GNU C library - * configure.in: look for stdlib.h [HAVE_STDLIB_H] - Comments from Ulrich Drepper. - -1997-08-25 Philippe De Muyter - - * src/dfa.c (sys/types.h): File included unconditionnaly. - -1997-08-16 Eli Zaretskii - - * grep.c (long_options) [O_BINARY]: Add DOS-specific options. - (fillbuf) [O_BINARY]: For DOS-style text files, strip CR - characters at end of line. - (prline) [O_BINARY]: Report correct byte offsets, even though CR - characters were stripped when reading the file. - (usage) [O_BINARY]: Add DOS-specific options. - (setmatcher) [HAVE_SETRLIMIT]: Set re_max_failures so that the - matcher won't ever overflow the stack. - (main) [__MSDOS__, _WIN32]: Handle backslashes and drive letters - in argv[0], remove the .exe suffix, and downcase the prgram name. - [O_BINARY]: Pass additional DOS-specific options to getopt_long - and handle them. Call stat before attempting to open the file, in - case it is a directory (DOS will fail the open call for - directories). Switch the input descriptor to binary mode, unless - it is a terminal device. - - * system.h [O_BINARY]: Define macros to switch a handle to binary - mode, so binary files could be grep'ed on MS-DOS and MS-Windows. - [HAVE_SETLOCALE]: Test for HAVE_SETLOCALE instead of - HAVE_LC_MESSAGES, to prevent compilation error in grep.c on - systems which don't define HAVE_LC_MESSAGES, but have setlocale. - - * dosbuf.c: New file, functions specific for MS-DOS/MS-Windows. - (guess_type, undossify_input, dossified_pos): New functions. - - * djgpp/config.h, djgpp/config.bat, djgpp/main.mak, djgpp/src.mak, - djgpp/po.mak, djgpp/intl.mak, djgpp/tests.mak, djgpp/po2tbl.sed: - New files, for building Grep with DJGPP tools for MS-DOS and - MS-Windows. - - * grep.1: Document DOS-specific switches. - -1997-08-08 Alain Magloire - - * grep-2.0e: available for testing - - * grep.c: change LC_MESSAGE to LC_ALL for (LC_CTYPE). - Suggested by Jochen Hein. - - * ABOUT-NLS: updated. - * grep.c: --version: more verbosity (COPYRIGHT). - * grep.c: --help: PATTERN, FILE instead of , . - * INSTALL.grep: not necessary removed. - * configure.in: --disable-regex rename --without-include-regex. - * THANKS: format: first row name, second email. - * ChangeLog: format ISO 8601. - Reported by Franc,ois Pinard. - - * grep.c: move dcl of struct stat st into "else" where it's used. - Reported by Jim Meyering. - - * grep.c: totalnl should be %u in printf. - Reported by Michael Aichlmay - Corrected with guidance from Ulrich Drepper - -1997-07-24 Alain Magloire - - * Makefile.am: corrected an error when installing {f,e}grep.1. - From Kaveh R. Ghazi . - From Ulrich Drepper . - - * Many files: use PARAMS instead of __STDC__ for prototypes. - From Jim Meyering . - Patch provided by Kaveh R. Ghazi . - - * dfa.[ch]: uses the one in gawk-3.0.3 with the patch from - Arnold (see Changelog: July 12 1997) - - * grep.1: a note to say -l, -L, -q stop on first match. - Noted by Andrew Beattie . - - * grep.c: refuse to scan if the file is a directory. - This was causing problems on SUNs. If the directory contains - a file that could match the pattern, garbage was display. - - * tests directory: added new set of tests from Henry Spencer - regex package. Change the way the tests were done to be more - conformant to automake. - - * configure.in: added --disable-regex for folks with their own fuctions. - - * grep-20d : available for testing - -1997-07-18 Alain Magloire - - * grep-2.0c: available for testing - -1997-07-17 Alain Magloire - - * src/grep.c: Cause grep to fail if `fclose (stdout)' fails. - From Jim Meyering . - - * grep.c:usage() more consistency in the --help. - - * egrep, fgrep were links This is in violation of GNU standards: - "Please don't make the behavior of a utility depend on the name used - to invoke it. It is useful sometimes to make a link to a utility with - a different name, and that should not change what it does." - For now egrep and fgrep will be copies of grep. A better scheme - should be found later. - After discussion with Tom Tromey . - - * fgrep.man and egrep.man included: They are stubs that call grep.1. - * Makefile.am: modified to install {f,e,}grep[,.1]. - - * speed hack for -l, -L: bail out on first match. - From Scott Weikart . - - * *.[ch]: provided prototypes for strict argument checking - With the help of Stewart Levin . - -1997-07-16 Alain Magloire - - * configure.in: typo in the creation of po/Makefile - Noted by Volker Borchert bt@teknon.de. - - * grep-2.0b: make it available for testing. - -1997-07-15 Alain Magloire - - * src/grep.c usage(): cut the --help in smaller printf()'s - Noted by Ulrich Drepper . - -1997-07-14 Alain Magloire - - * grep-2.0a: make an alpha available for testing. - -1997-07-12 Alain Magloire - - * run gettextize: added the po directory filled with *.po files. - - * check.sh, scriptgen.awk: fix grep paths. - - * change the directory strucure: grep is now in src to comply with - gettext.m4. - - * grep.c version.c [VERSION]: got rid of version.c, - it is now define via config.h. - - * dfa.c: patch to speed up initialization. - Arnold Robbins (arnold@gnu.ai.mit.edu). - -1997-07-09 Alain Magloire - - * *.c [HAVE_CONFIG_H]: Macro defined. - - * support for I18N in Makefile.am and configure.in. - - * update all the string to use gettext(I18N). - Help from Franc,ois Pinard previous patch . - -1997-07-04 Alain Magloire - - * obstack.[ch]: updated from glibc. - Work of Ulrich Drepper . - - * regex.[ch]: updated from glibc. - Work of Ulrich Drepper . - - * grep.c: for option -e not counting '\n' for new keys. - From Mark Waite . - - * grep.c: for option -f allocating the right count. - From Andreas Schwab . - Mike Heartel (mike@cs.uoregon.edu). - - * kwset.c (bmexec): Cast tp[-2] to unsigned char before comparing. - From Jim Meyering . - - * grep.1: various typos. - From Keith Bostic . - Mike Heartel (mike@cs.uoregon.edu). - -1997-06-17 Alain Magloire - - * grep.c: support for long options. - patch done by Franc,ois Pinard . - - * add getopt1.c in Makefile.am. - Noted by Franc,ois Pinard - - * replace getopt.[ch] and add getopt1.c. - - * kwset.c: undef malloc before define it. - Franc,ois Pinard . - -1997-06-07 Alain Magloire - - * grep.c: format incorrect in - fprintf("%s: warning: %s: %s...", filename, strerror(errno)). - Mike Heartel (mike@cs.uoregon.edu). - -1996-11-19 David J MacKenzie - - * make.com: Set the logical SYS. From rdb@cocamrd.oz.au (Rodney Brown). - - * grep.c (S_ISREG): Define if not defined already, for e.g. - SunOS 4.0.3. - - * dfa.c (test_bit, set_bit, clear_bit): Renamed from tstbit, - setbit, clrbit to avoid conflict with HP-UX sys/param.h macros. - - * memchr.c: New file, from GNU libc. - * grep.c (memchr): Remove definition. - * configure.in: Use AC_REPLACE_FUNCS for memchr. - - * configure.in: Remove unused checks for memalign and unsigned char. - * grep.c: HAVE_WORKING_MMAP -> HAVE_MMAP. - - * system.h: New file. - * dfa.c, kwset.c, grep.c, search.c: Use it instead of duplicating - portability boilerplate. - - * grep.c: Include sys/types.h once, instead of three times - conditionally. - * dfa.c, kwset.c, search.c: Include sys/types.h unconditionally, - to always try to get size_t (needed on some old SysV's). - - * dfa.c: Define strchr in terms of index, not the other way around. - * search.c: Use memcpy instead of bcopy. - -1996-11-15 David J MacKenzie - - * Many files: Update FSF address. - Update configuration to use autoconf v2 and automake. - -1993-05-22 Mike Haertel - - * Version 2.0 released. diff --git a/gnu/usr.bin/grep/Makefile b/gnu/usr.bin/grep/Makefile deleted file mode 100644 index b24b1ea292e..00000000000 --- a/gnu/usr.bin/grep/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# $FreeBSD$ - -.include - -GREP_LIBZ=YES - -.if ${MK_BSD_GREP} != "yes" -PROG= grep -.else -PROG= gnugrep -.endif -SRCS= closeout.c dfa.c error.c exclude.c grep.c grepmat.c hard-locale.c \ - isdir.c kwset.c obstack.c quotearg.c savedir.c search.c xmalloc.c \ - xstrtoumax.c -CLEANFILES+= gnugrep.1 - -CFLAGS+=-I${.CURDIR} -I${SYSROOT:U${DESTDIR}}/usr/include/gnu -DHAVE_CONFIG_H - -.if ${MK_BSD_GREP} != "yes" -LINKS+= ${BINDIR}/grep ${BINDIR}/egrep \ - ${BINDIR}/grep ${BINDIR}/fgrep -MLINKS= grep.1 egrep.1 grep.1 fgrep.1 -.endif - -LIBADD= gnuregex bz2 - -.if defined(GREP_LIBZ) && !empty(GREP_LIBZ) -LIBADD+= z -CFLAGS+=-DHAVE_LIBZ=1 -.endif - -gnugrep.1: grep.1 - ${CP} ${.ALLSRC} ${.TARGET} - -check: all - @failed=0; total=0; \ - for tst in ${TESTS}; do \ - total=$$(($$total+1)); \ - if GREP=${.OBJDIR}/${PROG} srcdir=${.CURDIR}/tests \ - ${.CURDIR}/tests/$$tst; then \ - echo "PASS: $$tst"; \ - else \ - failed=$$(($$failed+1)); \ - echo "FAIL: $$tst"; \ - fi; \ - done; \ - if [ "$$failed" -eq 0 ]; then \ - echo "All $$total tests passed"; \ - else \ - echo "$$failed of $$total tests failed"; \ - fi - -TESTS= warning.sh khadafy.sh spencer1.sh bre.sh ere.sh status.sh empty.sh \ - options.sh backref.sh file.sh - -.include diff --git a/gnu/usr.bin/grep/Makefile.depend b/gnu/usr.bin/grep/Makefile.depend deleted file mode 100644 index bdea82e9f7c..00000000000 --- a/gnu/usr.bin/grep/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libregex \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libbz2 \ - lib/libc \ - lib/libcompiler_rt \ - lib/libz \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/grep/NEWS b/gnu/usr.bin/grep/NEWS deleted file mode 100644 index 9bb821937eb..00000000000 --- a/gnu/usr.bin/grep/NEWS +++ /dev/null @@ -1,238 +0,0 @@ -Version 2.5.1 - - This is a bugfix release. No new features. - -Version 2.5 - - The new option --label allows to specify a different name for input - from stdin. See the man or info pages for details. - - - The internal lib/getopt* files are no longer used on systems providing - getopt functionality in their libc (e.g. glibc 2.2.x). - If you need the old getopt files, use --with-included-getopt. - - - The new option --only-matching (-o) will print only the part of matching - lines that matches the pattern. This is useful, for example, to extract - IP addresses from log files. - - - i18n bug fixed ([A-Z0-9] wouldn't match A in locales other than C on - systems using recent glibc builds - - - GNU grep can now be built with autoconf 2.52. - - - The new option --devices controls how grep handles device files. Its usage - is analogous to --directories. - - - The new option --line-buffered fflush on everyline. There is a noticeable - slow down when forcing line buffering. - - - Back references are now local to the regex. - grep -e '\(a\)\1' -e '\(b\)\1' - The last backref \1 in the second expression refer to \(b\) - - - The new option --include=PATTERN will only search matching files - when recursing in directories - - - The new option --exclude=PATTERN will skip matching files when - recursing in directories. - - - The new option --color will use the environment variable GREP_COLOR - (default is red) to highlight the matching string. - --color takes an optional argument specifying when to colorize a line: - --color=always, --color=tty, --color=never - - - The following changes are for POSIX.2 conformance: - - . The -q or --quiet or --silent option now causes grep to exit - with zero status when a input line is selected, even if an error - also occurs. - - . The -s or --no-messages option no longer affects the exit status. - - . Bracket regular expressions like [a-z] are now locale-dependent. - For example, many locales sort characters in dictionary order, - and in these locales the regular expression [a-d] is not - equivalent to [abcd]; it might be equivalent to [aBbCcDd], for - example. To obtain the traditional interpretation of bracket - expressions, you can use the C locale by setting the LC_ALL - environment variable to the value "C". - - - The -C or --context option now requires an argument, partly for - consistency, and partly because POSIX.2 recommends against - optional arguments. - - - The new -P or --perl-regexp option tells grep to interpert the pattern as - a Perl regular expression. - - - The new option --max-count=num makes grep stop reading a file after num - matching lines. - New option -m; equivalent to --max-count. - - - Translations for bg, ca, da, nb and tr have been added. - -Version 2.4.2 - - - Added more check in configure to default the grep-${version}/src/regex.c - instead of the one in GNU Lib C. - -Version 2.4.1 - - - If the final byte of an input file is not a newline, grep now silently - supplies one. - - - The new option --binary-files=TYPE makes grep assume that a binary input - file is of type TYPE. - --binary-files='binary' (the default) outputs a 1-line summary of matches. - --binary-files='without-match' assumes binary files do not match. - --binary-files='text' treats binary files as text - (equivalent to the -a or --text option). - - - New option -I; equivalent to --binary-files='without-match'. - -Version 2.4: - - - egrep is now equivalent to `grep -E' as required by POSIX, - removing a longstanding source of confusion and incompatibility. - `grep' is now more forgiving about stray `{'s, for backward - compatibility with traditional egrep. - - - The lower bound of an interval is not optional. - You must use an explicit zero, e.g. `x{0,10}' instead of `x{,10}'. - (The old documentation incorrectly claimed that it was optional.) - - - The --revert-match option has been renamed to --invert-match. - - - The --fixed-regexp option has been renamed to --fixed-string. - - - New option -H or --with-filename. - - - New option --mmap. By default, GNU grep now uses read instead of mmap. - This is faster on some hosts, and is safer on all. - - - The new option -z or --null-data causes `grep' to treat a zero byte - (the ASCII NUL character) as a line terminator in input data, and - to treat newlines as ordinary data. - - - The new option -Z or --null causes `grep' to output a zero byte - instead of the normal separator after a file name. - - - These two options can be used with commands like `find -print0', - `perl -0', `sort -z', and `xargs -0' to process arbitrary file names, - even those that contain newlines. - - - The environment variable GREP_OPTIONS specifies default options; - e.g. GREP_OPTIONS='--directories=skip' reestablishes grep 2.1's - behavior of silently skipping directories. - - - You can specify a matcher multiple times without error, e.g. - `grep -E -E' or `fgrep -F'. It is still an error to specify - conflicting matchers. - - - -u and -U are now allowed on non-DOS hosts, and have no effect. - - - Modifications of the tests scripts to go around the "Broken Pipe" - errors from bash. See Bash FAQ. - - - New option -r or --recursive or --directories=recurse. - (This option was also in grep 2.3, but wasn't announced here.) - - - --without-included-regex disable, was causing bogus reports .i.e - doing more harm then good. - -Version 2.3: - - - When searching a binary file FOO, grep now just reports - `Binary file FOO matches' instead of outputting binary data. - This is typically more useful than the old behavior, - and it is also more consistent with other utilities like `diff'. - A file is considered to be binary if it contains a NUL (i.e. zero) byte. - - The new -a or --text option causes `grep' to assume that all - input is text. (This option has the same meaning as with `diff'.) - Use it if you want binary data in your output. - - - `grep' now searches directories just like ordinary files; it no longer - silently skips directories. This is the traditional behavior of - Unix text utilities (in particular, of traditional `grep'). - Hence `grep PATTERN DIRECTORY' should report - `grep: DIRECTORY: Is a directory' on hosts where the operating system - does not permit programs to read directories directly, and - `grep: DIRECTORY: Binary file matches' (or nothing) otherwise. - - The new -d ACTION or --directories=ACTION option affects directory handling. - `-d skip' causes `grep' to silently skip directories, as in grep 2.1; - `-d read' (the default) causes `grep' to read directories if possible, - as in earlier versions of grep. - - - The MS-DOS and Microsoft Windows ports now behave identically to the - GNU and Unix ports with respect to binary files and directories. - -Version 2.2: - -Bug fix release. - - - Status error number fix. - - Skipping directories removed. - - Many typos fix. - - -f /dev/null fix(not to consider as an empty pattern). - - Checks for wctype/wchar. - - -E was using the wrong matcher fix. - - bug in regex char class fix - - Fixes for DJGPP - -Version 2.1: - -This is a bug fix release(see Changelog) i.e. no new features. - - - More compliance to GNU standard. - - Long options. - - Internationalisation. - - Use automake/autoconf. - - Directory hierarchy change. - - Sigvec with -e on Linux corrected. - - Sigvec with -f on Linux corrected. - - Sigvec with the mmap() corrected. - - Bug in kwset corrected. - - -q, -L and -l stop on first match. - - New and improve regex.[ch] from Ulrich Drepper. - - New and improve dfa.[ch] from Arnold Robbins. - - Prototypes for over zealous C compiler. - - Not scanning a file, if it's a directory - (cause problems on Sun). - - Ported to MS-DOS/MS-Windows with DJGPP tools. - -See Changelog for the full story and proper credits. - -Version 2.0: - -The most important user visible change is that egrep and fgrep have -disappeared as separate programs into the single grep program mandated -by POSIX 1003.2. New options -G, -E, and -F have been added, -selecting grep, egrep, and fgrep behavior respectively. For -compatibility with historical practice, hard links named egrep and -fgrep are also provided. See the manual page for details. - -In addition, the regular expression facilities described in Posix -draft 11.2 are now supported, except for internationalization features -related to locale-dependent collating sequence information. - -There is a new option, -L, which is like -l except it lists -files which don't contain matches. The reason this option was -added is because '-l -v' doesn't do what you expect. - -Performance has been improved; the amount of improvement is platform -dependent, but (for example) grep 2.0 typically runs at least 30% faster -than grep 1.6 on a DECstation using the MIPS compiler. Where possible, -grep now uses mmap() for file input; on a Sun 4 running SunOS 4.1 this -may cut system time by as much as half, for a total reduction in running -time by nearly 50%. On machines that don't use mmap(), the buffering -code has been rewritten to choose more favorable alignments and buffer -sizes for read(). - -Portability has been substantially cleaned up, and an automatic -configure script is now provided. - -The internals have changed in ways too numerous to mention. -People brave enough to reuse the DFA matcher in other programs -will now have their bravery amply "rewarded", for the interface -to that file has been completely changed. Some changes were -necessary to track the evolution of the regex package, and since -I was changing it anyway I decided to do a general cleanup. diff --git a/gnu/usr.bin/grep/README b/gnu/usr.bin/grep/README deleted file mode 100644 index 66c1bb2ba78..00000000000 --- a/gnu/usr.bin/grep/README +++ /dev/null @@ -1,26 +0,0 @@ -This is GNU grep, the "fastest grep in the west" (we hope). All -bugs reported in previous releases have been fixed. Many exciting new -bugs have probably been introduced in this revision. - -GNU grep is provided "as is" with no warranty. The exact terms -under which you may use and (re)distribute this program are detailed -in the GNU General Public License, in the file COPYING. - -GNU grep is based on a fast lazy-state deterministic matcher (about -twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper -search for a fixed string that eliminates impossible text from being -considered by the full regexp matcher without necessarily having to -look at every character. The result is typically many times faster -than Unix grep or egrep. (Regular expressions containing backreferencing -will run more slowly, however.) - -See the files AUTHORS and THANKS for a list of authors and other contributors. - -See the file INSTALL for compilation and installation instructions. - -See the file NEWS for a description of major changes in this release. - -See the file TODO for ideas on how you could help us improve grep. - -Send bug reports to bug-gnu-utils@gnu.org. Be sure to -include the word "grep" in your Subject: header field. diff --git a/gnu/usr.bin/grep/THANKS b/gnu/usr.bin/grep/THANKS deleted file mode 100644 index 93dd31c1b06..00000000000 --- a/gnu/usr.bin/grep/THANKS +++ /dev/null @@ -1,72 +0,0 @@ -Aharon Robbins -Akim Demaille -Alain Magloire -Andreas Schwab -Andreas Ley -Bastiaan "Darquan" Stougie -Ben Elliston -Bernd Strieder -Bernhard Rosenkraenzer -Bob Proulx -Brian Youmans <3diff@gnu.org> -Bruno Haible -Christian Groessler -David Clissold -David J MacKenzie -David O'Brien -Eli Zaretskii -Florian La Roche -Franc,ois Pinard -Gerald Stoller -Grant McDorman -Greg Louis -Guglielmo 'bond' Bondioni -H. Merijn Brand -Harald Hanche-Olsen -Hans-Bernhard Broeker -Heikki Korpela -Isamu Hasegawa -Jeff Bailey -Jim Hand -Jim Meyering -Jochen Hein -Joel N. Weber II -John Hughes -Jorge Stolfi -Juan Manuel Guerrero -Karl Berry -Karl Heuer -Kaveh R. Ghazi -Kazuro Furukawa -Keith Bostic -Krishna Sethuraman -Kurt D Schwehr -Mark Waite -Martin P.J. Zinser -Martin Rex -Michael Aichlmayr -Miles Bader -Olaf Kirch -Paul Eggert -Paul Kimoto -Phillip C. Brisco -Philippe Defert -Philippe De Muyter -Philip Hazel -Roland Roberts -Ruslan Ermilov -Santiago Vila -Shannon Hill -Sotiris Vassilopoulos -Stewart Levin -Sydoruk Stepan -Tapani Tarvainen -Tom 'moof' Spindler -Tom Tromey -Ulrich Drepper -UEBAYASHI Masao -Uwe H. Steinfeld -Volker Borchert -Wichert Akkerman -William Bader -Wolfgang Schludi diff --git a/gnu/usr.bin/grep/closeout.c b/gnu/usr.bin/grep/closeout.c deleted file mode 100644 index 4fdac32b2e8..00000000000 --- a/gnu/usr.bin/grep/closeout.c +++ /dev/null @@ -1,121 +0,0 @@ -/* closeout.c - close standard output - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if HAVE_CONFIG_H -# include -#endif - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - -#if HAVE_STDLIB_H -# include -#endif -#ifndef EXIT_FAILURE -# define EXIT_FAILURE 1 -#endif - -#include - -#include -#ifndef errno -extern int errno; -#endif - -#include "closeout.h" -#include "error.h" -#include "quotearg.h" -#if 0 -#include "__fpending.h" -#endif - -static int default_exit_status = EXIT_FAILURE; -static const char *file_name; - -/* Set the value to be used for the exit status when close_stdout is called. - This is useful when it is not convenient to call close_stdout_status, - e.g., when close_stdout is called via atexit. */ -void -close_stdout_set_status (int status) -{ - default_exit_status = status; -} - -/* Set the file name to be reported in the event an error is detected - by close_stdout_status. */ -void -close_stdout_set_file_name (const char *file) -{ - file_name = file; -} - -/* Close standard output, exiting with status STATUS on failure. - If a program writes *anything* to stdout, that program should `fflush' - stdout and make sure that it succeeds before exiting. Otherwise, - suppose that you go to the extreme of checking the return status - of every function that does an explicit write to stdout. The last - printf can succeed in writing to the internal stream buffer, and yet - the fclose(stdout) could still fail (due e.g., to a disk full error) - when it tries to write out that buffered data. Thus, you would be - left with an incomplete output file and the offending program would - exit successfully. - - FIXME: note the fflush suggested above is implicit in the fclose - we actually do below. Consider doing only the fflush and/or using - setvbuf to inhibit buffering. - - Besides, it's wasteful to check the return value from every call - that writes to stdout -- just let the internal stream state record - the failure. That's what the ferror test is checking below. - - It's important to detect such failures and exit nonzero because many - tools (most notably `make' and other build-management systems) depend - on being able to detect failure in other tools via their exit status. */ - -void -close_stdout_status (int status) -{ - int e = ferror (stdout) ? 0 : -1; - -#if 0 - if (__fpending (stdout) == 0) - return; -#endif - - if (fclose (stdout) != 0) - e = errno; - - if (0 < e) - { - char const *write_error = _("write error"); - if (file_name) - error (status, e, "%s: %s", quotearg_colon (file_name), write_error); - else - error (status, e, "%s", write_error); - } -} - -/* Close standard output, exiting with status EXIT_FAILURE on failure. */ -void -close_stdout (void) -{ - close_stdout_status (default_exit_status); -} diff --git a/gnu/usr.bin/grep/closeout.h b/gnu/usr.bin/grep/closeout.h deleted file mode 100644 index 80f24e45f9d..00000000000 --- a/gnu/usr.bin/grep/closeout.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CLOSEOUT_H -# define CLOSEOUT_H 1 - -# ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -# endif - -void close_stdout_set_status PARAMS ((int status)); -void close_stdout_set_file_name PARAMS ((const char *file)); -void close_stdout PARAMS ((void)); -void close_stdout_status PARAMS ((int status)); - -#endif diff --git a/gnu/usr.bin/grep/config.h b/gnu/usr.bin/grep/config.h deleted file mode 100644 index 339b084f327..00000000000 --- a/gnu/usr.bin/grep/config.h +++ /dev/null @@ -1,341 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.hin. Generated from configure.in by autoheader. */ - -/* Define to 1 if the `closedir' function returns void instead of `int'. */ -/* #undef CLOSEDIR_VOID */ - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -/* #undef ENABLE_NLS */ - -/* We are building grep */ -#define GREP 1 - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -/* #undef HAVE_ALLOCA_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ARGZ_H */ - -/* Define to 1 if you have the `atexit' function. */ -#define HAVE_ATEXIT 1 - -/* Define to 1 if you have the `btowc' function. */ -#define HAVE_BTOWC 1 - -/* Define to 1 if you have the `dcgettext' function. */ -/* #undef HAVE_DCGETTEXT */ - -/* Define to 1 if strerror_r is declared. */ -#define HAVE_DECL_STRERROR_R 1 - -/* Define if declares strtoul. */ -#define HAVE_DECL_STRTOUL 1 - -/* Define if declares strtoull. */ -#define HAVE_DECL_STRTOULL 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define if the malloc check has been performed. */ -#define HAVE_DONE_WORKING_MALLOC_CHECK 1 - -/* Define if the realloc check has been performed. */ -#define HAVE_DONE_WORKING_REALLOC_CHECK 1 - -/* Define to 1 if you have the `doprnt' function. */ -/* #undef HAVE_DOPRNT */ - -/* Define if text file lines end in CRLF. */ -/* #undef HAVE_DOS_FILE_CONTENTS */ - -/* Define if your OS uses backslashes as directory separators */ -/* #undef HAVE_DOS_FILE_NAMES */ - -/* Define to 1 if you have the `feof_unlocked' function. */ -#define HAVE_FEOF_UNLOCKED 1 - -/* Define to 1 if you have the `fgets_unlocked' function. */ -/* #undef HAVE_FGETS_UNLOCKED */ - -/* Define to 1 if you have the `fnmatch' function. */ -#define HAVE_FNMATCH 1 - -/* Define to 1 if you have the `getcwd' function. */ -#define HAVE_GETCWD 1 - -/* Define to 1 if you have the `getegid' function. */ -#define HAVE_GETEGID 1 - -/* Define to 1 if you have the `geteuid' function. */ -#define HAVE_GETEUID 1 - -/* Define to 1 if you have the `getgid' function. */ -#define HAVE_GETGID 1 - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if the GNU gettext() function is already present or preinstalled. */ -/* #undef HAVE_GETTEXT */ - -/* Define to 1 if you have the `getuid' function. */ -#define HAVE_GETUID 1 - -/* Define if you have the iconv() function. */ -#define HAVE_ICONV 1 - -/* Define if exists, doesn't clash with , and - declares uintmax_t. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `isascii' function. */ -#define HAVE_ISASCII 1 - -/* Define if you have and nl_langinfo(CODESET). */ -#define HAVE_LANGINFO_CODESET 1 - -/* Define if your file defines LC_MESSAGES. */ -#define HAVE_LC_MESSAGES 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBINTL_H */ - -/* Define to 1 if you have the `pcre' library (-lpcre). */ -/* #undef HAVE_LIBPCRE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define to 1 if you have the `mbrtowc' function. */ -#define HAVE_MBRTOWC 1 - -/* Define to 1 if you have the `memchr' function. */ -#define HAVE_MEMCHR 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mempcpy' function. */ -/* #undef HAVE_MEMPCPY */ - -/* Define to 1 if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 - -/* Define to 1 if you have the `munmap' function. */ -#define HAVE_MUNMAP 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NL_TYPES_H 1 - -/* Define to 1 if you have the `putenv' function. */ -#define HAVE_PUTENV 1 - -/* Define to 1 if you have the `setenv' function. */ -#define HAVE_SETENV 1 - -/* Define to 1 if you have the `setlocale' function. */ -#define HAVE_SETLOCALE 1 - -/* Define to 1 if you have the `setmode' function. */ -#define HAVE_SETMODE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `stpcpy' function. */ -#define HAVE_STPCPY 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the `strerror_r' function. */ -#define HAVE_STRERROR_R 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - -/* Define to 1 if you have the `strtoull' function. */ -/* #undef HAVE_STRTOULL */ - -/* Define to 1 if you have the `strtoumax' function. */ -#define HAVE_STRTOUMAX 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the `tsearch' function. */ -#define HAVE_TSEARCH 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the unsigned long long type. */ -#define HAVE_UNSIGNED_LONG_LONG 1 - -/* Define to 1 if you have the `vprintf' function. */ -#define HAVE_VPRINTF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_WCHAR_H 1 - -/* Define to 1 if you have the `wctype' function. */ -#define HAVE_WCTYPE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_WCTYPE_H 1 - -/* Define to 1 if strerror_r returns a string. */ -/* #undef HAVE_WORKING_STRERROR_R */ - -/* Define to 1 if you have the `__argz_count' function. */ -/* #undef HAVE___ARGZ_COUNT */ - -/* Define to 1 if you have the `__argz_next' function. */ -/* #undef HAVE___ARGZ_NEXT */ - -/* Define to 1 if you have the `__argz_stringify' function. */ -/* #undef HAVE___ARGZ_STRINGIFY */ - -/* Define as const if the declaration of iconv() needs const. */ -#define ICONV_CONST - -/* Name of package */ -#define PACKAGE "grep" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define if compiler has function prototypes */ -#define PROTOTYPES 1 - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "2.5.1-MidnightBSD" - -/* Number of bits in a file offset, on hosts where this is settable. */ -/* #undef _FILE_OFFSET_BITS */ - -/* Define to make fseeko etc. visible, on some hosts. */ -/* #undef _LARGEFILE_SOURCE */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define if your compiler is broken */ -/* #undef alloca */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ -/* #undef inline */ - -/* Define to rpl_malloc if the replacement function should be used. */ -/* #undef malloc */ - -/* Define to a type if does not define. */ -/* #undef mbstate_t */ - -/* Define to `long' if does not define. */ -/* #undef off_t */ - -/* Define to rpl_realloc if the replacement function should be used. */ -/* #undef realloc */ - -/* Define to `unsigned' if does not define. */ -/* #undef size_t */ - -/* Define to `int' if does not define. */ -/* #undef ssize_t */ - -/* Define to unsigned long or unsigned long long if doesn't - define. */ -/* #undef uintmax_t */ diff --git a/gnu/usr.bin/grep/dfa.c b/gnu/usr.bin/grep/dfa.c deleted file mode 100644 index a8b88275caa..00000000000 --- a/gnu/usr.bin/grep/dfa.c +++ /dev/null @@ -1,3586 +0,0 @@ -/* dfa.c - deterministic extended regexp routines for GNU - Copyright 1988, 1998, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ - -/* Written June, 1988 by Mike Haertel - Modified July, 1988 by Arthur David Olson to assist BMG speedups */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/dfa.c 250823 2013-05-20 03:15:25Z pfg $ */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#ifdef STDC_HEADERS -#include -#else -extern char *calloc(), *malloc(), *realloc(); -extern void free(); -#endif - -#if defined(HAVE_STRING_H) || defined(STDC_HEADERS) -#include -#else -#include -#endif - -#if HAVE_SETLOCALE -# include -#endif - -#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC -/* We can handle multibyte string. */ -# define MBS_SUPPORT -#endif - -#ifdef MBS_SUPPORT -# include -# include -#endif - -#ifndef DEBUG /* use the same approach as regex.c */ -#undef assert -#define assert(e) -#endif /* DEBUG */ - -#ifndef isgraph -#define isgraph(C) (isprint(C) && !isspace(C)) -#endif - -#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) -#define ISALPHA(C) isalpha(C) -#define ISUPPER(C) isupper(C) -#define ISLOWER(C) islower(C) -#define ISDIGIT(C) isdigit(C) -#define ISXDIGIT(C) isxdigit(C) -#define ISSPACE(C) isspace(C) -#define ISPUNCT(C) ispunct(C) -#define ISALNUM(C) isalnum(C) -#define ISPRINT(C) isprint(C) -#define ISGRAPH(C) isgraph(C) -#define ISCNTRL(C) iscntrl(C) -#else -#define ISALPHA(C) (isascii(C) && isalpha(C)) -#define ISUPPER(C) (isascii(C) && isupper(C)) -#define ISLOWER(C) (isascii(C) && islower(C)) -#define ISDIGIT(C) (isascii(C) && isdigit(C)) -#define ISXDIGIT(C) (isascii(C) && isxdigit(C)) -#define ISSPACE(C) (isascii(C) && isspace(C)) -#define ISPUNCT(C) (isascii(C) && ispunct(C)) -#define ISALNUM(C) (isascii(C) && isalnum(C)) -#define ISPRINT(C) (isascii(C) && isprint(C)) -#define ISGRAPH(C) (isascii(C) && isgraph(C)) -#define ISCNTRL(C) (isascii(C) && iscntrl(C)) -#endif - -/* ISASCIIDIGIT differs from ISDIGIT, as follows: - - Its arg may be any int or unsigned int; it need not be an unsigned char. - - It's guaranteed to evaluate its argument exactly once. - - It's typically faster. - Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that - only '0' through '9' are digits. Prefer ISASCIIDIGIT to ISDIGIT unless - it's important to use the locale's definition of `digit' even when the - host does not conform to Posix. */ -#define ISASCIIDIGIT(c) ((unsigned) (c) - '0' <= 9) - -/* If we (don't) have I18N. */ -/* glibc defines _ */ -#ifndef _ -# ifdef HAVE_LIBINTL_H -# include -# ifndef _ -# define _(Str) gettext (Str) -# endif -# else -# define _(Str) (Str) -# endif -#endif - -#include "regex.h" -#include "dfa.h" -#include "hard-locale.h" - -/* HPUX, define those as macros in sys/param.h */ -#ifdef setbit -# undef setbit -#endif -#ifdef clrbit -# undef clrbit -#endif - -static void dfamust PARAMS ((struct dfa *dfa)); -static void regexp PARAMS ((int toplevel)); - -static ptr_t -xcalloc (size_t n, size_t s) -{ - ptr_t r = calloc(n, s); - - if (!r) - dfaerror(_("Memory exhausted")); - return r; -} - -static ptr_t -xmalloc (size_t n) -{ - ptr_t r = malloc(n); - - assert(n != 0); - if (!r) - dfaerror(_("Memory exhausted")); - return r; -} - -static ptr_t -xrealloc (ptr_t p, size_t n) -{ - ptr_t r = realloc(p, n); - - assert(n != 0); - if (!r) - dfaerror(_("Memory exhausted")); - return r; -} - -#define CALLOC(p, t, n) ((p) = (t *) xcalloc((size_t)(n), sizeof (t))) -#define MALLOC(p, t, n) ((p) = (t *) xmalloc((n) * sizeof (t))) -#define REALLOC(p, t, n) ((p) = (t *) xrealloc((ptr_t) (p), (n) * sizeof (t))) - -/* Reallocate an array of type t if nalloc is too small for index. */ -#define REALLOC_IF_NECESSARY(p, t, nalloc, index) \ - if ((index) >= (nalloc)) \ - { \ - do \ - (nalloc) *= 2; \ - while ((index) >= (nalloc)); \ - REALLOC(p, t, nalloc); \ - } - -#ifdef DEBUG - -static void -prtok (token t) -{ - char const *s; - - if (t < 0) - fprintf(stderr, "END"); - else if (t < NOTCHAR) - fprintf(stderr, "%c", t); - else - { - switch (t) - { - case EMPTY: s = "EMPTY"; break; - case BACKREF: s = "BACKREF"; break; - case BEGLINE: s = "BEGLINE"; break; - case ENDLINE: s = "ENDLINE"; break; - case BEGWORD: s = "BEGWORD"; break; - case ENDWORD: s = "ENDWORD"; break; - case LIMWORD: s = "LIMWORD"; break; - case NOTLIMWORD: s = "NOTLIMWORD"; break; - case QMARK: s = "QMARK"; break; - case STAR: s = "STAR"; break; - case PLUS: s = "PLUS"; break; - case CAT: s = "CAT"; break; - case OR: s = "OR"; break; - case ORTOP: s = "ORTOP"; break; - case LPAREN: s = "LPAREN"; break; - case RPAREN: s = "RPAREN"; break; - case CRANGE: s = "CRANGE"; break; -#ifdef MBS_SUPPORT - case ANYCHAR: s = "ANYCHAR"; break; - case MBCSET: s = "MBCSET"; break; -#endif /* MBS_SUPPORT */ - default: s = "CSET"; break; - } - fprintf(stderr, "%s", s); - } -} -#endif /* DEBUG */ - -/* Stuff pertaining to charclasses. */ - -static int -tstbit (unsigned b, charclass c) -{ - return c[b / INTBITS] & 1 << b % INTBITS; -} - -static void -setbit (unsigned b, charclass c) -{ - c[b / INTBITS] |= 1 << b % INTBITS; -} - -static void -clrbit (unsigned b, charclass c) -{ - c[b / INTBITS] &= ~(1 << b % INTBITS); -} - -static void -copyset (charclass src, charclass dst) -{ - memcpy (dst, src, sizeof (charclass)); -} - -static void -zeroset (charclass s) -{ - memset (s, 0, sizeof (charclass)); -} - -static void -notset (charclass s) -{ - int i; - - for (i = 0; i < CHARCLASS_INTS; ++i) - s[i] = ~s[i]; -} - -static int -equal (charclass s1, charclass s2) -{ - return memcmp (s1, s2, sizeof (charclass)) == 0; -} - -/* A pointer to the current dfa is kept here during parsing. */ -static struct dfa *dfa; - -/* Find the index of charclass s in dfa->charclasses, or allocate a new charclass. */ -static int -charclass_index (charclass s) -{ - int i; - - for (i = 0; i < dfa->cindex; ++i) - if (equal(s, dfa->charclasses[i])) - return i; - REALLOC_IF_NECESSARY(dfa->charclasses, charclass, dfa->calloc, dfa->cindex); - ++dfa->cindex; - copyset(s, dfa->charclasses[i]); - return i; -} - -/* Syntax bits controlling the behavior of the lexical analyzer. */ -static reg_syntax_t syntax_bits, syntax_bits_set; - -/* Flag for case-folding letters into sets. */ -static int case_fold; - -/* End-of-line byte in data. */ -static unsigned char eolbyte; - -/* Entry point to set syntax options. */ -void -dfasyntax (reg_syntax_t bits, int fold, unsigned char eol) -{ - syntax_bits_set = 1; - syntax_bits = bits; - case_fold = fold; - eolbyte = eol; -} - -/* Like setbit, but if case is folded, set both cases of a letter. */ -static void -setbit_case_fold (unsigned b, charclass c) -{ - setbit (b, c); - if (case_fold) - { - if (ISUPPER (b)) - setbit (tolower (b), c); - else if (ISLOWER (b)) - setbit (toupper (b), c); - } -} - -/* Lexical analyzer. All the dross that deals with the obnoxious - GNU Regex syntax bits is located here. The poor, suffering - reader is referred to the GNU Regex documentation for the - meaning of the @#%!@#%^!@ syntax bits. */ - -static char const *lexstart; /* Pointer to beginning of input string. */ -static char const *lexptr; /* Pointer to next input character. */ -static int lexleft; /* Number of characters remaining. */ -static token lasttok; /* Previous token returned; initially END. */ -static int laststart; /* True if we're separated from beginning or (, | - only by zero-width characters. */ -static int parens; /* Count of outstanding left parens. */ -static int minrep, maxrep; /* Repeat counts for {m,n}. */ -static int hard_LC_COLLATE; /* Nonzero if LC_COLLATE is hard. */ - -#ifdef MBS_SUPPORT -/* These variables are used only if (MB_CUR_MAX > 1). */ -static mbstate_t mbs; /* Mbstate for mbrlen(). */ -static ssize_t cur_mb_len; /* Byte length of the current scanning - multibyte character. Must also handle - negative result from mbrlen(). */ -static ssize_t cur_mb_index; /* Byte index of the current scanning multibyte - character. - - singlebyte character : cur_mb_index = 0 - multibyte character - 1st byte : cur_mb_index = 1 - 2nd byte : cur_mb_index = 2 - ... - nth byte : cur_mb_index = n */ -static unsigned char *mblen_buf;/* Correspond to the input buffer in dfaexec(). - Each element store the amount of remain - byte of corresponding multibyte character - in the input string. A element's value - is 0 if corresponding character is a - singlebyte chracter. - e.g. input : 'a', , , - mblen_buf : 0, 3, 2, 1 - */ -static wchar_t *inputwcs; /* Wide character representation of input - string in dfaexec(). - The length of this array is same as - the length of input string(char array). - inputstring[i] is a single-byte char, - or 1st byte of a multibyte char. - And inputwcs[i] is the codepoint. */ -static unsigned char const *buf_begin;/* refference to begin in dfaexec(). */ -static unsigned char const *buf_end; /* refference to end in dfaexec(). */ -#endif /* MBS_SUPPORT */ - -#ifdef MBS_SUPPORT -/* This function update cur_mb_len, and cur_mb_index. - p points current lexptr, len is the remaining buffer length. */ -static void -update_mb_len_index (unsigned char const *p, size_t len) -{ - /* If last character is a part of a multibyte character, - we update cur_mb_index. */ - if (cur_mb_index) - cur_mb_index = (cur_mb_index >= cur_mb_len)? 0 - : cur_mb_index + 1; - - /* If last character is a single byte character, or the - last portion of a multibyte character, we check whether - next character is a multibyte character or not. */ - if (! cur_mb_index) - { - cur_mb_len = mbrlen(p, len, &mbs); - if (cur_mb_len > 1) - /* It is a multibyte character. - cur_mb_len was already set by mbrlen(). */ - cur_mb_index = 1; - else if (cur_mb_len < 1) - /* Invalid sequence. We treat it as a singlebyte character. - cur_mb_index is aleady 0. */ - cur_mb_len = 1; - /* Otherwise, cur_mb_len == 1, it is a singlebyte character. - cur_mb_index is aleady 0. */ - } -} -#endif /* MBS_SUPPORT */ - -#ifdef MBS_SUPPORT -/* Note that characters become unsigned here. */ -# define FETCH(c, eoferr) \ - { \ - if (! lexleft) \ - { \ - if (eoferr != 0) \ - dfaerror (eoferr); \ - else \ - return lasttok = END; \ - } \ - if (MB_CUR_MAX > 1) \ - update_mb_len_index(lexptr, lexleft); \ - (c) = (unsigned char) *lexptr++; \ - --lexleft; \ - } - -/* This function fetch a wide character, and update cur_mb_len, - used only if the current locale is a multibyte environment. */ -static wint_t -fetch_wc (char const *eoferr) -{ - wchar_t wc; - if (! lexleft) - { - if (eoferr != 0) - dfaerror (eoferr); - else - return WEOF; - } - - cur_mb_len = mbrtowc(&wc, lexptr, lexleft, &mbs); - if (cur_mb_len <= 0) - { - cur_mb_len = 1; - wc = *lexptr; - } - lexptr += cur_mb_len; - lexleft -= cur_mb_len; - return wc; -} -#else -/* Note that characters become unsigned here. */ -# define FETCH(c, eoferr) \ - { \ - if (! lexleft) \ - { \ - if (eoferr != 0) \ - dfaerror (eoferr); \ - else \ - return lasttok = END; \ - } \ - (c) = (unsigned char) *lexptr++; \ - --lexleft; \ - } -#endif /* MBS_SUPPORT */ - -#ifdef MBS_SUPPORT -/* Multibyte character handling sub-routin for lex. - This function parse a bracket expression and build a struct - mb_char_classes. */ -static void -parse_bracket_exp_mb () -{ - wint_t wc, wc1, wc2; - - /* Work area to build a mb_char_classes. */ - struct mb_char_classes *work_mbc; - int chars_al, range_sts_al, range_ends_al, ch_classes_al, - equivs_al, coll_elems_al; - - REALLOC_IF_NECESSARY(dfa->mbcsets, struct mb_char_classes, - dfa->mbcsets_alloc, dfa->nmbcsets + 1); - /* dfa->multibyte_prop[] hold the index of dfa->mbcsets. - We will update dfa->multibyte_prop in addtok(), because we can't - decide the index in dfa->tokens[]. */ - - /* Initialize work are */ - work_mbc = &(dfa->mbcsets[dfa->nmbcsets++]); - - chars_al = 1; - range_sts_al = range_ends_al = 0; - ch_classes_al = equivs_al = coll_elems_al = 0; - MALLOC(work_mbc->chars, wchar_t, chars_al); - - work_mbc->nchars = work_mbc->nranges = work_mbc->nch_classes = 0; - work_mbc->nequivs = work_mbc->ncoll_elems = 0; - work_mbc->chars = work_mbc->ch_classes = NULL; - work_mbc->range_sts = work_mbc->range_ends = NULL; - work_mbc->equivs = work_mbc->coll_elems = NULL; - - wc = fetch_wc(_("Unbalanced [")); - if (wc == L'^') - { - wc = fetch_wc(_("Unbalanced [")); - work_mbc->invert = 1; - } - else - work_mbc->invert = 0; - do - { - wc1 = WEOF; /* mark wc1 is not initialized". */ - - /* Note that if we're looking at some other [:...:] construct, - we just treat it as a bunch of ordinary characters. We can do - this because we assume regex has checked for syntax errors before - dfa is ever called. */ - if (wc == L'[' && (syntax_bits & RE_CHAR_CLASSES)) - { -#define BRACKET_BUFFER_SIZE 128 - char str[BRACKET_BUFFER_SIZE]; - wc1 = wc; - wc = fetch_wc(_("Unbalanced [")); - - /* If pattern contains `[[:', `[[.', or `[[='. */ - if (cur_mb_len == 1 && (wc == L':' || wc == L'.' || wc == L'=')) - { - unsigned char c; - unsigned char delim = (unsigned char)wc; - int len = 0; - for (;;) - { - if (! lexleft) - dfaerror (_("Unbalanced [")); - c = (unsigned char) *lexptr++; - --lexleft; - - if ((c == delim && *lexptr == ']') || lexleft == 0) - break; - if (len < BRACKET_BUFFER_SIZE) - str[len++] = c; - else - /* This is in any case an invalid class name. */ - str[0] = '\0'; - } - str[len] = '\0'; - - if (lexleft == 0) - { - REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al, - work_mbc->nchars + 2); - work_mbc->chars[work_mbc->nchars++] = L'['; - work_mbc->chars[work_mbc->nchars++] = delim; - break; - } - - if (--lexleft, *lexptr++ != ']') - dfaerror (_("Unbalanced [")); - if (delim == ':') - /* build character class. */ - { - wctype_t wt; - /* Query the character class as wctype_t. */ - wt = wctype (str); - - if (ch_classes_al == 0) - MALLOC(work_mbc->ch_classes, wchar_t, ++ch_classes_al); - REALLOC_IF_NECESSARY(work_mbc->ch_classes, wctype_t, - ch_classes_al, - work_mbc->nch_classes + 1); - work_mbc->ch_classes[work_mbc->nch_classes++] = wt; - - } - else if (delim == '=' || delim == '.') - { - char *elem; - MALLOC(elem, char, len + 1); - strncpy(elem, str, len + 1); - - if (delim == '=') - /* build equivalent class. */ - { - if (equivs_al == 0) - MALLOC(work_mbc->equivs, char*, ++equivs_al); - REALLOC_IF_NECESSARY(work_mbc->equivs, char*, - equivs_al, - work_mbc->nequivs + 1); - work_mbc->equivs[work_mbc->nequivs++] = elem; - } - - if (delim == '.') - /* build collating element. */ - { - if (coll_elems_al == 0) - MALLOC(work_mbc->coll_elems, char*, ++coll_elems_al); - REALLOC_IF_NECESSARY(work_mbc->coll_elems, char*, - coll_elems_al, - work_mbc->ncoll_elems + 1); - work_mbc->coll_elems[work_mbc->ncoll_elems++] = elem; - } - } - wc1 = wc = WEOF; - } - else - /* We treat '[' as a normal character here. */ - { - wc2 = wc1; wc1 = wc; wc = wc2; /* swap */ - } - } - else - { - if (wc == L'\\' && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) - wc = fetch_wc(("Unbalanced [")); - } - - if (wc1 == WEOF) - wc1 = fetch_wc(_("Unbalanced [")); - - if (wc1 == L'-') - /* build range characters. */ - { - wc2 = fetch_wc(_("Unbalanced [")); - if (wc2 == L']') - { - /* In the case [x-], the - is an ordinary hyphen, - which is left in c1, the lookahead character. */ - lexptr -= cur_mb_len; - lexleft += cur_mb_len; - wc2 = wc; - } - else - { - if (wc2 == L'\\' - && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) - wc2 = fetch_wc(_("Unbalanced [")); - wc1 = fetch_wc(_("Unbalanced [")); - } - - if (range_sts_al == 0) - { - MALLOC(work_mbc->range_sts, wchar_t, ++range_sts_al); - MALLOC(work_mbc->range_ends, wchar_t, ++range_ends_al); - } - REALLOC_IF_NECESSARY(work_mbc->range_sts, wchar_t, - range_sts_al, work_mbc->nranges + 1); - work_mbc->range_sts[work_mbc->nranges] = (wchar_t)wc; - REALLOC_IF_NECESSARY(work_mbc->range_ends, wchar_t, - range_ends_al, work_mbc->nranges + 1); - work_mbc->range_ends[work_mbc->nranges++] = (wchar_t)wc2; - } - else if (wc != WEOF) - /* build normal characters. */ - { - REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al, - work_mbc->nchars + 1); - work_mbc->chars[work_mbc->nchars++] = (wchar_t)wc; - } - } - while ((wc = wc1) != L']'); -} -#endif /* MBS_SUPPORT */ - -#ifdef __STDC__ -#define FUNC(F, P) static int F(int c) { return P(c); } -#else -#define FUNC(F, P) static int F(c) int c; { return P(c); } -#endif - -FUNC(is_alpha, ISALPHA) -FUNC(is_upper, ISUPPER) -FUNC(is_lower, ISLOWER) -FUNC(is_digit, ISDIGIT) -FUNC(is_xdigit, ISXDIGIT) -FUNC(is_space, ISSPACE) -FUNC(is_punct, ISPUNCT) -FUNC(is_alnum, ISALNUM) -FUNC(is_print, ISPRINT) -FUNC(is_graph, ISGRAPH) -FUNC(is_cntrl, ISCNTRL) - -static int -is_blank (int c) -{ - return (c == ' ' || c == '\t'); -} - -/* The following list maps the names of the Posix named character classes - to predicate functions that determine whether a given character is in - the class. The leading [ has already been eaten by the lexical analyzer. */ -static struct { - const char *name; - int (*pred) PARAMS ((int)); -} const prednames[] = { - { ":alpha:]", is_alpha }, - { ":upper:]", is_upper }, - { ":lower:]", is_lower }, - { ":digit:]", is_digit }, - { ":xdigit:]", is_xdigit }, - { ":space:]", is_space }, - { ":punct:]", is_punct }, - { ":alnum:]", is_alnum }, - { ":print:]", is_print }, - { ":graph:]", is_graph }, - { ":cntrl:]", is_cntrl }, - { ":blank:]", is_blank }, - { 0 } -}; - -/* Return non-zero if C is a `word-constituent' byte; zero otherwise. */ -#define IS_WORD_CONSTITUENT(C) (ISALNUM(C) || (C) == '_') - -static int -looking_at (char const *s) -{ - size_t len; - - len = strlen(s); - if (lexleft < len) - return 0; - return strncmp(s, lexptr, len) == 0; -} - -static token -lex (void) -{ - unsigned c, c1, c2; - int backslash = 0, invert; - charclass ccl; - int i; - - /* Basic plan: We fetch a character. If it's a backslash, - we set the backslash flag and go through the loop again. - On the plus side, this avoids having a duplicate of the - main switch inside the backslash case. On the minus side, - it means that just about every case begins with - "if (backslash) ...". */ - for (i = 0; i < 2; ++i) - { - FETCH(c, 0); -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1 && cur_mb_index) - /* If this is a part of a multi-byte character, we must treat - this byte data as a normal character. - e.g. In case of SJIS encoding, some character contains '\', - but they must not be backslash. */ - goto normal_char; -#endif /* MBS_SUPPORT */ - switch (c) - { - case '\\': - if (backslash) - goto normal_char; - if (lexleft == 0) - dfaerror(_("Unfinished \\ escape")); - backslash = 1; - break; - - case '^': - if (backslash) - goto normal_char; - if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS - || lasttok == END - || lasttok == LPAREN - || lasttok == OR) - return lasttok = BEGLINE; - goto normal_char; - - case '$': - if (backslash) - goto normal_char; - if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS - || lexleft == 0 - || (syntax_bits & RE_NO_BK_PARENS - ? lexleft > 0 && *lexptr == ')' - : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == ')') - || (syntax_bits & RE_NO_BK_VBAR - ? lexleft > 0 && *lexptr == '|' - : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == '|') - || ((syntax_bits & RE_NEWLINE_ALT) - && lexleft > 0 && *lexptr == '\n')) - return lasttok = ENDLINE; - goto normal_char; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (backslash && !(syntax_bits & RE_NO_BK_REFS)) - { - laststart = 0; - return lasttok = BACKREF; - } - goto normal_char; - - case '`': - if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) - return lasttok = BEGLINE; /* FIXME: should be beginning of string */ - goto normal_char; - - case '\'': - if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) - return lasttok = ENDLINE; /* FIXME: should be end of string */ - goto normal_char; - - case '<': - if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) - return lasttok = BEGWORD; - goto normal_char; - - case '>': - if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) - return lasttok = ENDWORD; - goto normal_char; - - case 'b': - if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) - return lasttok = LIMWORD; - goto normal_char; - - case 'B': - if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) - return lasttok = NOTLIMWORD; - goto normal_char; - - case '?': - if (syntax_bits & RE_LIMITED_OPS) - goto normal_char; - if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0)) - goto normal_char; - if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) - goto normal_char; - return lasttok = QMARK; - - case '*': - if (backslash) - goto normal_char; - if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) - goto normal_char; - return lasttok = STAR; - - case '+': - if (syntax_bits & RE_LIMITED_OPS) - goto normal_char; - if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0)) - goto normal_char; - if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) - goto normal_char; - return lasttok = PLUS; - - case '{': - if (!(syntax_bits & RE_INTERVALS)) - goto normal_char; - if (backslash != ((syntax_bits & RE_NO_BK_BRACES) == 0)) - goto normal_char; - if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) - goto normal_char; - - if (syntax_bits & RE_NO_BK_BRACES) - { - /* Scan ahead for a valid interval; if it's not valid, - treat it as a literal '{'. */ - int lo = -1, hi = -1; - char const *p = lexptr; - char const *lim = p + lexleft; - for (; p != lim && ISASCIIDIGIT (*p); p++) - lo = (lo < 0 ? 0 : lo * 10) + *p - '0'; - if (p != lim && *p == ',') - while (++p != lim && ISASCIIDIGIT (*p)) - hi = (hi < 0 ? 0 : hi * 10) + *p - '0'; - else - hi = lo; - if (p == lim || *p != '}' - || lo < 0 || RE_DUP_MAX < hi || (0 <= hi && hi < lo)) - goto normal_char; - } - - minrep = 0; - /* Cases: - {M} - exact count - {M,} - minimum count, maximum is infinity - {M,N} - M through N */ - FETCH(c, _("unfinished repeat count")); - if (ISASCIIDIGIT (c)) - { - minrep = c - '0'; - for (;;) - { - FETCH(c, _("unfinished repeat count")); - if (! ISASCIIDIGIT (c)) - break; - minrep = 10 * minrep + c - '0'; - } - } - else - dfaerror(_("malformed repeat count")); - if (c == ',') - { - FETCH (c, _("unfinished repeat count")); - if (! ISASCIIDIGIT (c)) - maxrep = -1; - else - { - maxrep = c - '0'; - for (;;) - { - FETCH (c, _("unfinished repeat count")); - if (! ISASCIIDIGIT (c)) - break; - maxrep = 10 * maxrep + c - '0'; - } - if (0 <= maxrep && maxrep < minrep) - dfaerror (_("malformed repeat count")); - } - } - else - maxrep = minrep; - if (!(syntax_bits & RE_NO_BK_BRACES)) - { - if (c != '\\') - dfaerror(_("malformed repeat count")); - FETCH(c, _("unfinished repeat count")); - } - if (c != '}') - dfaerror(_("malformed repeat count")); - laststart = 0; - return lasttok = REPMN; - - case '|': - if (syntax_bits & RE_LIMITED_OPS) - goto normal_char; - if (backslash != ((syntax_bits & RE_NO_BK_VBAR) == 0)) - goto normal_char; - laststart = 1; - return lasttok = OR; - - case '\n': - if (syntax_bits & RE_LIMITED_OPS - || backslash - || !(syntax_bits & RE_NEWLINE_ALT)) - goto normal_char; - laststart = 1; - return lasttok = OR; - - case '(': - if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0)) - goto normal_char; - ++parens; - laststart = 1; - return lasttok = LPAREN; - - case ')': - if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0)) - goto normal_char; - if (parens == 0 && syntax_bits & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_char; - --parens; - laststart = 0; - return lasttok = RPAREN; - - case '.': - if (backslash) - goto normal_char; -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - /* In multibyte environment period must match with a single - character not a byte. So we use ANYCHAR. */ - laststart = 0; - return lasttok = ANYCHAR; - } -#endif /* MBS_SUPPORT */ - zeroset(ccl); - notset(ccl); - if (!(syntax_bits & RE_DOT_NEWLINE)) - clrbit(eolbyte, ccl); - if (syntax_bits & RE_DOT_NOT_NULL) - clrbit('\0', ccl); - laststart = 0; - return lasttok = CSET + charclass_index(ccl); - - case 'w': - case 'W': - if (!backslash || (syntax_bits & RE_NO_GNU_OPS)) - goto normal_char; - zeroset(ccl); - for (c2 = 0; c2 < NOTCHAR; ++c2) - if (IS_WORD_CONSTITUENT(c2)) - setbit(c2, ccl); - if (c == 'W') - notset(ccl); - laststart = 0; - return lasttok = CSET + charclass_index(ccl); - - case '[': - if (backslash) - goto normal_char; - laststart = 0; -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - /* In multibyte environment a bracket expression may contain - multibyte characters, which must be treated as characters - (not bytes). So we parse it by parse_bracket_exp_mb(). */ - parse_bracket_exp_mb(); - return lasttok = MBCSET; - } -#endif - zeroset(ccl); - FETCH(c, _("Unbalanced [")); - if (c == '^') - { - FETCH(c, _("Unbalanced [")); - invert = 1; - } - else - invert = 0; - do - { - /* Nobody ever said this had to be fast. :-) - Note that if we're looking at some other [:...:] - construct, we just treat it as a bunch of ordinary - characters. We can do this because we assume - regex has checked for syntax errors before - dfa is ever called. */ - if (c == '[' && (syntax_bits & RE_CHAR_CLASSES)) - for (c1 = 0; prednames[c1].name; ++c1) - if (looking_at(prednames[c1].name)) - { - int (*pred) PARAMS ((int)) = prednames[c1].pred; - - for (c2 = 0; c2 < NOTCHAR; ++c2) - if ((*pred)(c2)) - setbit_case_fold (c2, ccl); - lexptr += strlen(prednames[c1].name); - lexleft -= strlen(prednames[c1].name); - FETCH(c1, _("Unbalanced [")); - goto skip; - } - if (c == '\\' && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) - FETCH(c, _("Unbalanced [")); - FETCH(c1, _("Unbalanced [")); - if (c1 == '-') - { - FETCH(c2, _("Unbalanced [")); - if (c2 == ']') - { - /* In the case [x-], the - is an ordinary hyphen, - which is left in c1, the lookahead character. */ - --lexptr; - ++lexleft; - } - else - { - if (c2 == '\\' - && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) - FETCH(c2, _("Unbalanced [")); - FETCH(c1, _("Unbalanced [")); - if (!hard_LC_COLLATE) { - for (; c <= c2; c++) - setbit_case_fold (c, ccl); - } else { - /* POSIX locales are painful - leave the decision to libc */ - char expr[6] = { '[', c, '-', c2, ']', '\0' }; - regex_t re; - if (regcomp (&re, expr, case_fold ? REG_ICASE : 0) == REG_NOERROR) { - for (c = 0; c < NOTCHAR; ++c) { - char buf[2] = { c, '\0' }; - regmatch_t mat; - if (regexec (&re, buf, 1, &mat, 0) == REG_NOERROR - && mat.rm_so == 0 && mat.rm_eo == 1) - setbit_case_fold (c, ccl); - } - regfree (&re); - } - } - continue; - } - } - - setbit_case_fold (c, ccl); - - skip: - ; - } - while ((c = c1) != ']'); - if (invert) - { - notset(ccl); - if (syntax_bits & RE_HAT_LISTS_NOT_NEWLINE) - clrbit(eolbyte, ccl); - } - return lasttok = CSET + charclass_index(ccl); - - default: - normal_char: - laststart = 0; - if (case_fold && ISALPHA(c)) - { - zeroset(ccl); - setbit_case_fold (c, ccl); - return lasttok = CSET + charclass_index(ccl); - } - return c; - } - } - - /* The above loop should consume at most a backslash - and some other character. */ - abort(); - return END; /* keeps pedantic compilers happy. */ -} - -/* Recursive descent parser for regular expressions. */ - -static token tok; /* Lookahead token. */ -static int depth; /* Current depth of a hypothetical stack - holding deferred productions. This is - used to determine the depth that will be - required of the real stack later on in - dfaanalyze(). */ - -/* Add the given token to the parse tree, maintaining the depth count and - updating the maximum depth if necessary. */ -static void -addtok (token t) -{ -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - REALLOC_IF_NECESSARY(dfa->multibyte_prop, int, dfa->nmultibyte_prop, - dfa->tindex); - /* Set dfa->multibyte_prop. See struct dfa in dfa.h. */ - if (t == MBCSET) - dfa->multibyte_prop[dfa->tindex] = ((dfa->nmbcsets - 1) << 2) + 3; - else if (t < NOTCHAR) - dfa->multibyte_prop[dfa->tindex] - = (cur_mb_len == 1)? 3 /* single-byte char */ - : (((cur_mb_index == 1)? 1 : 0) /* 1st-byte of multibyte char */ - + ((cur_mb_index == cur_mb_len)? 2 : 0)); /* last-byte */ - else - /* It may be unnecesssary, but it is safer to treat other - symbols as singlebyte characters. */ - dfa->multibyte_prop[dfa->tindex] = 3; - } -#endif - - REALLOC_IF_NECESSARY(dfa->tokens, token, dfa->talloc, dfa->tindex); - dfa->tokens[dfa->tindex++] = t; - - switch (t) - { - case QMARK: - case STAR: - case PLUS: - break; - - case CAT: - case OR: - case ORTOP: - --depth; - break; - - default: - ++dfa->nleaves; - case EMPTY: - ++depth; - break; - } - if (depth > dfa->depth) - dfa->depth = depth; -} - -/* The grammar understood by the parser is as follows. - - regexp: - regexp OR branch - branch - - branch: - branch closure - closure - - closure: - closure QMARK - closure STAR - closure PLUS - closure REPMN - atom - - atom: - - - ANYCHAR - MBCSET - CSET - BACKREF - BEGLINE - ENDLINE - BEGWORD - ENDWORD - LIMWORD - NOTLIMWORD - CRANGE - LPAREN regexp RPAREN - - - The parser builds a parse tree in postfix form in an array of tokens. */ - -static void -atom (void) -{ - if ((tok >= 0 && tok < NOTCHAR) || tok >= CSET || tok == BACKREF - || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD -#ifdef MBS_SUPPORT - || tok == ANYCHAR || tok == MBCSET /* MB_CUR_MAX > 1 */ -#endif /* MBS_SUPPORT */ - || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD) - { - addtok(tok); - tok = lex(); -#ifdef MBS_SUPPORT - /* We treat a multibyte character as a single atom, so that DFA - can treat a multibyte character as a single expression. - - e.g. We construct following tree from "". - - - */ - if (MB_CUR_MAX > 1) - { - while (cur_mb_index > 1 && tok >= 0 && tok < NOTCHAR) - { - addtok(tok); - addtok(CAT); - tok = lex(); - } - } -#endif /* MBS_SUPPORT */ - } - else if (tok == CRANGE) - { - /* A character range like "[a-z]" in a locale other than "C" or - "POSIX". This range might any sequence of one or more - characters. Unfortunately the POSIX locale primitives give - us no practical way to find what character sequences might be - matched. Treat this approximately like "(.\1)" -- i.e. match - one character, and then punt to the full matcher. */ - charclass ccl; - zeroset (ccl); - notset (ccl); - addtok (CSET + charclass_index (ccl)); - addtok (BACKREF); - addtok (CAT); - tok = lex (); - } - else if (tok == LPAREN) - { - tok = lex(); - regexp(0); - if (tok != RPAREN) - dfaerror(_("Unbalanced (")); - tok = lex(); - } - else - addtok(EMPTY); -} - -/* Return the number of tokens in the given subexpression. */ -static int -nsubtoks (int tindex) -{ - int ntoks1; - - switch (dfa->tokens[tindex - 1]) - { - default: - return 1; - case QMARK: - case STAR: - case PLUS: - return 1 + nsubtoks(tindex - 1); - case CAT: - case OR: - case ORTOP: - ntoks1 = nsubtoks(tindex - 1); - return 1 + ntoks1 + nsubtoks(tindex - 1 - ntoks1); - } -} - -/* Copy the given subexpression to the top of the tree. */ -static void -copytoks (int tindex, int ntokens) -{ - int i; - - for (i = 0; i < ntokens; ++i) - addtok(dfa->tokens[tindex + i]); -} - -static void -closure (void) -{ - int tindex, ntokens, i; - - atom(); - while (tok == QMARK || tok == STAR || tok == PLUS || tok == REPMN) - if (tok == REPMN) - { - ntokens = nsubtoks(dfa->tindex); - tindex = dfa->tindex - ntokens; - if (maxrep < 0) - addtok(PLUS); - if (minrep == 0) - addtok(QMARK); - for (i = 1; i < minrep; ++i) - { - copytoks(tindex, ntokens); - addtok(CAT); - } - for (; i < maxrep; ++i) - { - copytoks(tindex, ntokens); - addtok(QMARK); - addtok(CAT); - } - tok = lex(); - } - else - { - addtok(tok); - tok = lex(); - } -} - -static void -branch (void) -{ - closure(); - while (tok != RPAREN && tok != OR && tok >= 0) - { - closure(); - addtok(CAT); - } -} - -static void -regexp (int toplevel) -{ - branch(); - while (tok == OR) - { - tok = lex(); - branch(); - if (toplevel) - addtok(ORTOP); - else - addtok(OR); - } -} - -/* Main entry point for the parser. S is a string to be parsed, len is the - length of the string, so s can include NUL characters. D is a pointer to - the struct dfa to parse into. */ -void -dfaparse (char const *s, size_t len, struct dfa *d) -{ - dfa = d; - lexstart = lexptr = s; - lexleft = len; - lasttok = END; - laststart = 1; - parens = 0; - hard_LC_COLLATE = hard_locale (LC_COLLATE); -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - cur_mb_index = 0; - cur_mb_len = 0; - memset(&mbs, 0, sizeof(mbstate_t)); - } -#endif /* MBS_SUPPORT */ - - if (! syntax_bits_set) - dfaerror(_("No syntax specified")); - - tok = lex(); - depth = d->depth; - - regexp(1); - - if (tok != END) - dfaerror(_("Unbalanced )")); - - addtok(END - d->nregexps); - addtok(CAT); - - if (d->nregexps) - addtok(ORTOP); - - ++d->nregexps; -} - -/* Some primitives for operating on sets of positions. */ - -/* Copy one set to another; the destination must be large enough. */ -static void -copy (position_set const *src, position_set *dst) -{ - int i; - - for (i = 0; i < src->nelem; ++i) - dst->elems[i] = src->elems[i]; - dst->nelem = src->nelem; -} - -/* Insert a position in a set. Position sets are maintained in sorted - order according to index. If position already exists in the set with - the same index then their constraints are logically or'd together. - S->elems must point to an array large enough to hold the resulting set. */ -static void -insert (position p, position_set *s) -{ - int i; - position t1, t2; - - for (i = 0; i < s->nelem && p.index < s->elems[i].index; ++i) - continue; - if (i < s->nelem && p.index == s->elems[i].index) - s->elems[i].constraint |= p.constraint; - else - { - t1 = p; - ++s->nelem; - while (i < s->nelem) - { - t2 = s->elems[i]; - s->elems[i++] = t1; - t1 = t2; - } - } -} - -/* Merge two sets of positions into a third. The result is exactly as if - the positions of both sets were inserted into an initially empty set. */ -static void -merge (position_set const *s1, position_set const *s2, position_set *m) -{ - int i = 0, j = 0; - - m->nelem = 0; - while (i < s1->nelem && j < s2->nelem) - if (s1->elems[i].index > s2->elems[j].index) - m->elems[m->nelem++] = s1->elems[i++]; - else if (s1->elems[i].index < s2->elems[j].index) - m->elems[m->nelem++] = s2->elems[j++]; - else - { - m->elems[m->nelem] = s1->elems[i++]; - m->elems[m->nelem++].constraint |= s2->elems[j++].constraint; - } - while (i < s1->nelem) - m->elems[m->nelem++] = s1->elems[i++]; - while (j < s2->nelem) - m->elems[m->nelem++] = s2->elems[j++]; -} - -/* Delete a position from a set. */ -static void -delete (position p, position_set *s) -{ - int i; - - for (i = 0; i < s->nelem; ++i) - if (p.index == s->elems[i].index) - break; - if (i < s->nelem) - for (--s->nelem; i < s->nelem; ++i) - s->elems[i] = s->elems[i + 1]; -} - -/* Find the index of the state corresponding to the given position set with - the given preceding context, or create a new state if there is no such - state. Newline and letter tell whether we got here on a newline or - letter, respectively. */ -static int -state_index (struct dfa *d, position_set const *s, int newline, int letter) -{ - int hash = 0; - int constraint; - int i, j; - - newline = newline ? 1 : 0; - letter = letter ? 1 : 0; - - for (i = 0; i < s->nelem; ++i) - hash ^= s->elems[i].index + s->elems[i].constraint; - - /* Try to find a state that exactly matches the proposed one. */ - for (i = 0; i < d->sindex; ++i) - { - if (hash != d->states[i].hash || s->nelem != d->states[i].elems.nelem - || newline != d->states[i].newline || letter != d->states[i].letter) - continue; - for (j = 0; j < s->nelem; ++j) - if (s->elems[j].constraint - != d->states[i].elems.elems[j].constraint - || s->elems[j].index != d->states[i].elems.elems[j].index) - break; - if (j == s->nelem) - return i; - } - - /* We'll have to create a new state. */ - REALLOC_IF_NECESSARY(d->states, dfa_state, d->salloc, d->sindex); - d->states[i].hash = hash; - MALLOC(d->states[i].elems.elems, position, s->nelem); - copy(s, &d->states[i].elems); - d->states[i].newline = newline; - d->states[i].letter = letter; - d->states[i].backref = 0; - d->states[i].constraint = 0; - d->states[i].first_end = 0; -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - d->states[i].mbps.nelem = 0; -#endif - for (j = 0; j < s->nelem; ++j) - if (d->tokens[s->elems[j].index] < 0) - { - constraint = s->elems[j].constraint; - if (SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 0) - || SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 1) - || SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 0) - || SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 1)) - d->states[i].constraint |= constraint; - if (! d->states[i].first_end) - d->states[i].first_end = d->tokens[s->elems[j].index]; - } - else if (d->tokens[s->elems[j].index] == BACKREF) - { - d->states[i].constraint = NO_CONSTRAINT; - d->states[i].backref = 1; - } - - ++d->sindex; - - return i; -} - -/* Find the epsilon closure of a set of positions. If any position of the set - contains a symbol that matches the empty string in some context, replace - that position with the elements of its follow labeled with an appropriate - constraint. Repeat exhaustively until no funny positions are left. - S->elems must be large enough to hold the result. */ -static void -epsclosure (position_set *s, struct dfa const *d) -{ - int i, j; - int *visited; - position p, old; - - MALLOC(visited, int, d->tindex); - for (i = 0; i < d->tindex; ++i) - visited[i] = 0; - - for (i = 0; i < s->nelem; ++i) - if (d->tokens[s->elems[i].index] >= NOTCHAR - && d->tokens[s->elems[i].index] != BACKREF -#ifdef MBS_SUPPORT - && d->tokens[s->elems[i].index] != ANYCHAR - && d->tokens[s->elems[i].index] != MBCSET -#endif - && d->tokens[s->elems[i].index] < CSET) - { - old = s->elems[i]; - p.constraint = old.constraint; - delete(s->elems[i], s); - if (visited[old.index]) - { - --i; - continue; - } - visited[old.index] = 1; - switch (d->tokens[old.index]) - { - case BEGLINE: - p.constraint &= BEGLINE_CONSTRAINT; - break; - case ENDLINE: - p.constraint &= ENDLINE_CONSTRAINT; - break; - case BEGWORD: - p.constraint &= BEGWORD_CONSTRAINT; - break; - case ENDWORD: - p.constraint &= ENDWORD_CONSTRAINT; - break; - case LIMWORD: - p.constraint &= LIMWORD_CONSTRAINT; - break; - case NOTLIMWORD: - p.constraint &= NOTLIMWORD_CONSTRAINT; - break; - default: - break; - } - for (j = 0; j < d->follows[old.index].nelem; ++j) - { - p.index = d->follows[old.index].elems[j].index; - insert(p, s); - } - /* Force rescan to start at the beginning. */ - i = -1; - } - - free(visited); -} - -/* Perform bottom-up analysis on the parse tree, computing various functions. - Note that at this point, we're pretending constructs like \< are real - characters rather than constraints on what can follow them. - - Nullable: A node is nullable if it is at the root of a regexp that can - match the empty string. - * EMPTY leaves are nullable. - * No other leaf is nullable. - * A QMARK or STAR node is nullable. - * A PLUS node is nullable if its argument is nullable. - * A CAT node is nullable if both its arguments are nullable. - * An OR node is nullable if either argument is nullable. - - Firstpos: The firstpos of a node is the set of positions (nonempty leaves) - that could correspond to the first character of a string matching the - regexp rooted at the given node. - * EMPTY leaves have empty firstpos. - * The firstpos of a nonempty leaf is that leaf itself. - * The firstpos of a QMARK, STAR, or PLUS node is the firstpos of its - argument. - * The firstpos of a CAT node is the firstpos of the left argument, union - the firstpos of the right if the left argument is nullable. - * The firstpos of an OR node is the union of firstpos of each argument. - - Lastpos: The lastpos of a node is the set of positions that could - correspond to the last character of a string matching the regexp at - the given node. - * EMPTY leaves have empty lastpos. - * The lastpos of a nonempty leaf is that leaf itself. - * The lastpos of a QMARK, STAR, or PLUS node is the lastpos of its - argument. - * The lastpos of a CAT node is the lastpos of its right argument, union - the lastpos of the left if the right argument is nullable. - * The lastpos of an OR node is the union of the lastpos of each argument. - - Follow: The follow of a position is the set of positions that could - correspond to the character following a character matching the node in - a string matching the regexp. At this point we consider special symbols - that match the empty string in some context to be just normal characters. - Later, if we find that a special symbol is in a follow set, we will - replace it with the elements of its follow, labeled with an appropriate - constraint. - * Every node in the firstpos of the argument of a STAR or PLUS node is in - the follow of every node in the lastpos. - * Every node in the firstpos of the second argument of a CAT node is in - the follow of every node in the lastpos of the first argument. - - Because of the postfix representation of the parse tree, the depth-first - analysis is conveniently done by a linear scan with the aid of a stack. - Sets are stored as arrays of the elements, obeying a stack-like allocation - scheme; the number of elements in each set deeper in the stack can be - used to determine the address of a particular set's array. */ -void -dfaanalyze (struct dfa *d, int searchflag) -{ - int *nullable; /* Nullable stack. */ - int *nfirstpos; /* Element count stack for firstpos sets. */ - position *firstpos; /* Array where firstpos elements are stored. */ - int *nlastpos; /* Element count stack for lastpos sets. */ - position *lastpos; /* Array where lastpos elements are stored. */ - int *nalloc; /* Sizes of arrays allocated to follow sets. */ - position_set tmp; /* Temporary set for merging sets. */ - position_set merged; /* Result of merging sets. */ - int wants_newline; /* True if some position wants newline info. */ - int *o_nullable; - int *o_nfirst, *o_nlast; - position *o_firstpos, *o_lastpos; - int i, j; - position *pos; - -#ifdef DEBUG - fprintf(stderr, "dfaanalyze:\n"); - for (i = 0; i < d->tindex; ++i) - { - fprintf(stderr, " %d:", i); - prtok(d->tokens[i]); - } - putc('\n', stderr); -#endif - - d->searchflag = searchflag; - - MALLOC(nullable, int, d->depth); - o_nullable = nullable; - MALLOC(nfirstpos, int, d->depth); - o_nfirst = nfirstpos; - MALLOC(firstpos, position, d->nleaves); - o_firstpos = firstpos, firstpos += d->nleaves; - MALLOC(nlastpos, int, d->depth); - o_nlast = nlastpos; - MALLOC(lastpos, position, d->nleaves); - o_lastpos = lastpos, lastpos += d->nleaves; - MALLOC(nalloc, int, d->tindex); - for (i = 0; i < d->tindex; ++i) - nalloc[i] = 0; - MALLOC(merged.elems, position, d->nleaves); - - CALLOC(d->follows, position_set, d->tindex); - - for (i = 0; i < d->tindex; ++i) -#ifdef DEBUG - { /* Nonsyntactic #ifdef goo... */ -#endif - switch (d->tokens[i]) - { - case EMPTY: - /* The empty set is nullable. */ - *nullable++ = 1; - - /* The firstpos and lastpos of the empty leaf are both empty. */ - *nfirstpos++ = *nlastpos++ = 0; - break; - - case STAR: - case PLUS: - /* Every element in the firstpos of the argument is in the follow - of every element in the lastpos. */ - tmp.nelem = nfirstpos[-1]; - tmp.elems = firstpos; - pos = lastpos; - for (j = 0; j < nlastpos[-1]; ++j) - { - merge(&tmp, &d->follows[pos[j].index], &merged); - REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems, position, - nalloc[pos[j].index], merged.nelem - 1); - copy(&merged, &d->follows[pos[j].index]); - } - - case QMARK: - /* A QMARK or STAR node is automatically nullable. */ - if (d->tokens[i] != PLUS) - nullable[-1] = 1; - break; - - case CAT: - /* Every element in the firstpos of the second argument is in the - follow of every element in the lastpos of the first argument. */ - tmp.nelem = nfirstpos[-1]; - tmp.elems = firstpos; - pos = lastpos + nlastpos[-1]; - for (j = 0; j < nlastpos[-2]; ++j) - { - merge(&tmp, &d->follows[pos[j].index], &merged); - REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems, position, - nalloc[pos[j].index], merged.nelem - 1); - copy(&merged, &d->follows[pos[j].index]); - } - - /* The firstpos of a CAT node is the firstpos of the first argument, - union that of the second argument if the first is nullable. */ - if (nullable[-2]) - nfirstpos[-2] += nfirstpos[-1]; - else - firstpos += nfirstpos[-1]; - --nfirstpos; - - /* The lastpos of a CAT node is the lastpos of the second argument, - union that of the first argument if the second is nullable. */ - if (nullable[-1]) - nlastpos[-2] += nlastpos[-1]; - else - { - pos = lastpos + nlastpos[-2]; - for (j = nlastpos[-1] - 1; j >= 0; --j) - pos[j] = lastpos[j]; - lastpos += nlastpos[-2]; - nlastpos[-2] = nlastpos[-1]; - } - --nlastpos; - - /* A CAT node is nullable if both arguments are nullable. */ - nullable[-2] = nullable[-1] && nullable[-2]; - --nullable; - break; - - case OR: - case ORTOP: - /* The firstpos is the union of the firstpos of each argument. */ - nfirstpos[-2] += nfirstpos[-1]; - --nfirstpos; - - /* The lastpos is the union of the lastpos of each argument. */ - nlastpos[-2] += nlastpos[-1]; - --nlastpos; - - /* An OR node is nullable if either argument is nullable. */ - nullable[-2] = nullable[-1] || nullable[-2]; - --nullable; - break; - - default: - /* Anything else is a nonempty position. (Note that special - constructs like \< are treated as nonempty strings here; - an "epsilon closure" effectively makes them nullable later. - Backreferences have to get a real position so we can detect - transitions on them later. But they are nullable. */ - *nullable++ = d->tokens[i] == BACKREF; - - /* This position is in its own firstpos and lastpos. */ - *nfirstpos++ = *nlastpos++ = 1; - --firstpos, --lastpos; - firstpos->index = lastpos->index = i; - firstpos->constraint = lastpos->constraint = NO_CONSTRAINT; - - /* Allocate the follow set for this position. */ - nalloc[i] = 1; - MALLOC(d->follows[i].elems, position, nalloc[i]); - break; - } -#ifdef DEBUG - /* ... balance the above nonsyntactic #ifdef goo... */ - fprintf(stderr, "node %d:", i); - prtok(d->tokens[i]); - putc('\n', stderr); - fprintf(stderr, nullable[-1] ? " nullable: yes\n" : " nullable: no\n"); - fprintf(stderr, " firstpos:"); - for (j = nfirstpos[-1] - 1; j >= 0; --j) - { - fprintf(stderr, " %d:", firstpos[j].index); - prtok(d->tokens[firstpos[j].index]); - } - fprintf(stderr, "\n lastpos:"); - for (j = nlastpos[-1] - 1; j >= 0; --j) - { - fprintf(stderr, " %d:", lastpos[j].index); - prtok(d->tokens[lastpos[j].index]); - } - putc('\n', stderr); - } -#endif - - /* For each follow set that is the follow set of a real position, replace - it with its epsilon closure. */ - for (i = 0; i < d->tindex; ++i) - if (d->tokens[i] < NOTCHAR || d->tokens[i] == BACKREF -#ifdef MBS_SUPPORT - || d->tokens[i] == ANYCHAR - || d->tokens[i] == MBCSET -#endif - || d->tokens[i] >= CSET) - { -#ifdef DEBUG - fprintf(stderr, "follows(%d:", i); - prtok(d->tokens[i]); - fprintf(stderr, "):"); - for (j = d->follows[i].nelem - 1; j >= 0; --j) - { - fprintf(stderr, " %d:", d->follows[i].elems[j].index); - prtok(d->tokens[d->follows[i].elems[j].index]); - } - putc('\n', stderr); -#endif - copy(&d->follows[i], &merged); - epsclosure(&merged, d); - if (d->follows[i].nelem < merged.nelem) - REALLOC(d->follows[i].elems, position, merged.nelem); - copy(&merged, &d->follows[i]); - } - - /* Get the epsilon closure of the firstpos of the regexp. The result will - be the set of positions of state 0. */ - merged.nelem = 0; - for (i = 0; i < nfirstpos[-1]; ++i) - insert(firstpos[i], &merged); - epsclosure(&merged, d); - - /* Check if any of the positions of state 0 will want newline context. */ - wants_newline = 0; - for (i = 0; i < merged.nelem; ++i) - if (PREV_NEWLINE_DEPENDENT(merged.elems[i].constraint)) - wants_newline = 1; - - /* Build the initial state. */ - d->salloc = 1; - d->sindex = 0; - MALLOC(d->states, dfa_state, d->salloc); - state_index(d, &merged, wants_newline, 0); - - free(o_nullable); - free(o_nfirst); - free(o_firstpos); - free(o_nlast); - free(o_lastpos); - free(nalloc); - free(merged.elems); -} - -/* Find, for each character, the transition out of state s of d, and store - it in the appropriate slot of trans. - - We divide the positions of s into groups (positions can appear in more - than one group). Each group is labeled with a set of characters that - every position in the group matches (taking into account, if necessary, - preceding context information of s). For each group, find the union - of the its elements' follows. This set is the set of positions of the - new state. For each character in the group's label, set the transition - on this character to be to a state corresponding to the set's positions, - and its associated backward context information, if necessary. - - If we are building a searching matcher, we include the positions of state - 0 in every state. - - The collection of groups is constructed by building an equivalence-class - partition of the positions of s. - - For each position, find the set of characters C that it matches. Eliminate - any characters from C that fail on grounds of backward context. - - Search through the groups, looking for a group whose label L has nonempty - intersection with C. If L - C is nonempty, create a new group labeled - L - C and having the same positions as the current group, and set L to - the intersection of L and C. Insert the position in this group, set - C = C - L, and resume scanning. - - If after comparing with every group there are characters remaining in C, - create a new group labeled with the characters of C and insert this - position in that group. */ -void -dfastate (int s, struct dfa *d, int trans[]) -{ - position_set grps[NOTCHAR]; /* As many as will ever be needed. */ - charclass labels[NOTCHAR]; /* Labels corresponding to the groups. */ - int ngrps = 0; /* Number of groups actually used. */ - position pos; /* Current position being considered. */ - charclass matches; /* Set of matching characters. */ - int matchesf; /* True if matches is nonempty. */ - charclass intersect; /* Intersection with some label set. */ - int intersectf; /* True if intersect is nonempty. */ - charclass leftovers; /* Stuff in the label that didn't match. */ - int leftoversf; /* True if leftovers is nonempty. */ - static charclass letters; /* Set of characters considered letters. */ - static charclass newline; /* Set of characters that aren't newline. */ - position_set follows; /* Union of the follows of some group. */ - position_set tmp; /* Temporary space for merging sets. */ - int state; /* New state. */ - int wants_newline; /* New state wants to know newline context. */ - int state_newline; /* New state on a newline transition. */ - int wants_letter; /* New state wants to know letter context. */ - int state_letter; /* New state on a letter transition. */ - static int initialized; /* Flag for static initialization. */ -#ifdef MBS_SUPPORT - int next_isnt_1st_byte = 0; /* Flag If we can't add state0. */ -#endif - int i, j, k; - - /* Initialize the set of letters, if necessary. */ - if (! initialized) - { - initialized = 1; - for (i = 0; i < NOTCHAR; ++i) - if (IS_WORD_CONSTITUENT(i)) - setbit(i, letters); - setbit(eolbyte, newline); - } - - zeroset(matches); - - for (i = 0; i < d->states[s].elems.nelem; ++i) - { - pos = d->states[s].elems.elems[i]; - if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR) - setbit(d->tokens[pos.index], matches); - else if (d->tokens[pos.index] >= CSET) - copyset(d->charclasses[d->tokens[pos.index] - CSET], matches); -#ifdef MBS_SUPPORT - else if (d->tokens[pos.index] == ANYCHAR - || d->tokens[pos.index] == MBCSET) - /* MB_CUR_MAX > 1 */ - { - /* ANYCHAR and MBCSET must match with a single character, so we - must put it to d->states[s].mbps, which contains the positions - which can match with a single character not a byte. */ - if (d->states[s].mbps.nelem == 0) - { - MALLOC(d->states[s].mbps.elems, position, - d->states[s].elems.nelem); - } - insert(pos, &(d->states[s].mbps)); - continue; - } -#endif /* MBS_SUPPORT */ - else - continue; - - /* Some characters may need to be eliminated from matches because - they fail in the current context. */ - if (pos.constraint != 0xFF) - { - if (! MATCHES_NEWLINE_CONTEXT(pos.constraint, - d->states[s].newline, 1)) - clrbit(eolbyte, matches); - if (! MATCHES_NEWLINE_CONTEXT(pos.constraint, - d->states[s].newline, 0)) - for (j = 0; j < CHARCLASS_INTS; ++j) - matches[j] &= newline[j]; - if (! MATCHES_LETTER_CONTEXT(pos.constraint, - d->states[s].letter, 1)) - for (j = 0; j < CHARCLASS_INTS; ++j) - matches[j] &= ~letters[j]; - if (! MATCHES_LETTER_CONTEXT(pos.constraint, - d->states[s].letter, 0)) - for (j = 0; j < CHARCLASS_INTS; ++j) - matches[j] &= letters[j]; - - /* If there are no characters left, there's no point in going on. */ - for (j = 0; j < CHARCLASS_INTS && !matches[j]; ++j) - continue; - if (j == CHARCLASS_INTS) - continue; - } - - for (j = 0; j < ngrps; ++j) - { - /* If matches contains a single character only, and the current - group's label doesn't contain that character, go on to the - next group. */ - if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR - && !tstbit(d->tokens[pos.index], labels[j])) - continue; - - /* Check if this group's label has a nonempty intersection with - matches. */ - intersectf = 0; - for (k = 0; k < CHARCLASS_INTS; ++k) - (intersect[k] = matches[k] & labels[j][k]) ? (intersectf = 1) : 0; - if (! intersectf) - continue; - - /* It does; now find the set differences both ways. */ - leftoversf = matchesf = 0; - for (k = 0; k < CHARCLASS_INTS; ++k) - { - /* Even an optimizing compiler can't know this for sure. */ - int match = matches[k], label = labels[j][k]; - - (leftovers[k] = ~match & label) ? (leftoversf = 1) : 0; - (matches[k] = match & ~label) ? (matchesf = 1) : 0; - } - - /* If there were leftovers, create a new group labeled with them. */ - if (leftoversf) - { - copyset(leftovers, labels[ngrps]); - copyset(intersect, labels[j]); - MALLOC(grps[ngrps].elems, position, d->nleaves); - copy(&grps[j], &grps[ngrps]); - ++ngrps; - } - - /* Put the position in the current group. Note that there is no - reason to call insert() here. */ - grps[j].elems[grps[j].nelem++] = pos; - - /* If every character matching the current position has been - accounted for, we're done. */ - if (! matchesf) - break; - } - - /* If we've passed the last group, and there are still characters - unaccounted for, then we'll have to create a new group. */ - if (j == ngrps) - { - copyset(matches, labels[ngrps]); - zeroset(matches); - MALLOC(grps[ngrps].elems, position, d->nleaves); - grps[ngrps].nelem = 1; - grps[ngrps].elems[0] = pos; - ++ngrps; - } - } - - MALLOC(follows.elems, position, d->nleaves); - MALLOC(tmp.elems, position, d->nleaves); - - /* If we are a searching matcher, the default transition is to a state - containing the positions of state 0, otherwise the default transition - is to fail miserably. */ - if (d->searchflag) - { - wants_newline = 0; - wants_letter = 0; - for (i = 0; i < d->states[0].elems.nelem; ++i) - { - if (PREV_NEWLINE_DEPENDENT(d->states[0].elems.elems[i].constraint)) - wants_newline = 1; - if (PREV_LETTER_DEPENDENT(d->states[0].elems.elems[i].constraint)) - wants_letter = 1; - } - copy(&d->states[0].elems, &follows); - state = state_index(d, &follows, 0, 0); - if (wants_newline) - state_newline = state_index(d, &follows, 1, 0); - else - state_newline = state; - if (wants_letter) - state_letter = state_index(d, &follows, 0, 1); - else - state_letter = state; - for (i = 0; i < NOTCHAR; ++i) - trans[i] = (IS_WORD_CONSTITUENT(i)) ? state_letter : state; - trans[eolbyte] = state_newline; - } - else - for (i = 0; i < NOTCHAR; ++i) - trans[i] = -1; - - for (i = 0; i < ngrps; ++i) - { - follows.nelem = 0; - - /* Find the union of the follows of the positions of the group. - This is a hideously inefficient loop. Fix it someday. */ - for (j = 0; j < grps[i].nelem; ++j) - for (k = 0; k < d->follows[grps[i].elems[j].index].nelem; ++k) - insert(d->follows[grps[i].elems[j].index].elems[k], &follows); - -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - /* If a token in follows.elems is not 1st byte of a multibyte - character, or the states of follows must accept the bytes - which are not 1st byte of the multibyte character. - Then, if a state of follows encounter a byte, it must not be - a 1st byte of a multibyte character nor singlebyte character. - We cansel to add state[0].follows to next state, because - state[0] must accept 1st-byte - - For example, we assume is a certain singlebyte - character, is a certain multibyte character, and the - codepoint of equals the 2nd byte of the codepoint of - . - When state[0] accepts , state[i] transit to state[i+1] - by accepting accepts 1st byte of , and state[i+1] - accepts 2nd byte of , if state[i+1] encounter the - codepoint of , it must not be but 2nd byte of - , so we can not add state[0]. */ - - next_isnt_1st_byte = 0; - for (j = 0; j < follows.nelem; ++j) - { - if (!(d->multibyte_prop[follows.elems[j].index] & 1)) - { - next_isnt_1st_byte = 1; - break; - } - } - } -#endif - - /* If we are building a searching matcher, throw in the positions - of state 0 as well. */ -#ifdef MBS_SUPPORT - if (d->searchflag && (MB_CUR_MAX == 1 || !next_isnt_1st_byte)) -#else - if (d->searchflag) -#endif - for (j = 0; j < d->states[0].elems.nelem; ++j) - insert(d->states[0].elems.elems[j], &follows); - - /* Find out if the new state will want any context information. */ - wants_newline = 0; - if (tstbit(eolbyte, labels[i])) - for (j = 0; j < follows.nelem; ++j) - if (PREV_NEWLINE_DEPENDENT(follows.elems[j].constraint)) - wants_newline = 1; - - wants_letter = 0; - for (j = 0; j < CHARCLASS_INTS; ++j) - if (labels[i][j] & letters[j]) - break; - if (j < CHARCLASS_INTS) - for (j = 0; j < follows.nelem; ++j) - if (PREV_LETTER_DEPENDENT(follows.elems[j].constraint)) - wants_letter = 1; - - /* Find the state(s) corresponding to the union of the follows. */ - state = state_index(d, &follows, 0, 0); - if (wants_newline) - state_newline = state_index(d, &follows, 1, 0); - else - state_newline = state; - if (wants_letter) - state_letter = state_index(d, &follows, 0, 1); - else - state_letter = state; - - /* Set the transitions for each character in the current label. */ - for (j = 0; j < CHARCLASS_INTS; ++j) - for (k = 0; k < INTBITS; ++k) - if (labels[i][j] & 1 << k) - { - int c = j * INTBITS + k; - - if (c == eolbyte) - trans[c] = state_newline; - else if (IS_WORD_CONSTITUENT(c)) - trans[c] = state_letter; - else if (c < NOTCHAR) - trans[c] = state; - } - } - - for (i = 0; i < ngrps; ++i) - free(grps[i].elems); - free(follows.elems); - free(tmp.elems); -} - -/* Some routines for manipulating a compiled dfa's transition tables. - Each state may or may not have a transition table; if it does, and it - is a non-accepting state, then d->trans[state] points to its table. - If it is an accepting state then d->fails[state] points to its table. - If it has no table at all, then d->trans[state] is NULL. - TODO: Improve this comment, get rid of the unnecessary redundancy. */ - -static void -build_state (int s, struct dfa *d) -{ - int *trans; /* The new transition table. */ - int i; - - /* Set an upper limit on the number of transition tables that will ever - exist at once. 1024 is arbitrary. The idea is that the frequently - used transition tables will be quickly rebuilt, whereas the ones that - were only needed once or twice will be cleared away. */ - if (d->trcount >= 1024) - { - for (i = 0; i < d->tralloc; ++i) - if (d->trans[i]) - { - free((ptr_t) d->trans[i]); - d->trans[i] = NULL; - } - else if (d->fails[i]) - { - free((ptr_t) d->fails[i]); - d->fails[i] = NULL; - } - d->trcount = 0; - } - - ++d->trcount; - - /* Set up the success bits for this state. */ - d->success[s] = 0; - if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 1, d->states[s].letter, 0, - s, *d)) - d->success[s] |= 4; - if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 0, d->states[s].letter, 1, - s, *d)) - d->success[s] |= 2; - if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 0, d->states[s].letter, 0, - s, *d)) - d->success[s] |= 1; - - MALLOC(trans, int, NOTCHAR); - dfastate(s, d, trans); - - /* Now go through the new transition table, and make sure that the trans - and fail arrays are allocated large enough to hold a pointer for the - largest state mentioned in the table. */ - for (i = 0; i < NOTCHAR; ++i) - if (trans[i] >= d->tralloc) - { - int oldalloc = d->tralloc; - - while (trans[i] >= d->tralloc) - d->tralloc *= 2; - REALLOC(d->realtrans, int *, d->tralloc + 1); - d->trans = d->realtrans + 1; - REALLOC(d->fails, int *, d->tralloc); - REALLOC(d->success, int, d->tralloc); - while (oldalloc < d->tralloc) - { - d->trans[oldalloc] = NULL; - d->fails[oldalloc++] = NULL; - } - } - - /* Newline is a sentinel. */ - trans[eolbyte] = -1; - - if (ACCEPTING(s, *d)) - d->fails[s] = trans; - else - d->trans[s] = trans; -} - -static void -build_state_zero (struct dfa *d) -{ - d->tralloc = 1; - d->trcount = 0; - CALLOC(d->realtrans, int *, d->tralloc + 1); - d->trans = d->realtrans + 1; - CALLOC(d->fails, int *, d->tralloc); - MALLOC(d->success, int, d->tralloc); - build_state(0, d); -} - -#ifdef MBS_SUPPORT -/* Multibyte character handling sub-routins for dfaexec. */ - -/* Initial state may encounter the byte which is not a singlebyte character - nor 1st byte of a multibyte character. But it is incorrect for initial - state to accept such a byte. - For example, in sjis encoding the regular expression like "\\" accepts - the codepoint 0x5c, but should not accept the 2nd byte of the codepoint - 0x815c. Then Initial state must skip the bytes which are not a singlebyte - character nor 1st byte of a multibyte character. */ -#define SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p) \ - if (s == 0) \ - { \ - while (inputwcs[p - buf_begin] == 0 \ - && mblen_buf[p - buf_begin] > 0 \ - && p < buf_end) \ - ++p; \ - if (p >= end) \ - { \ - free(mblen_buf); \ - free(inputwcs); \ - return (size_t) -1; \ - } \ - } - -static void -realloc_trans_if_necessary(struct dfa *d, int new_state) -{ - /* Make sure that the trans and fail arrays are allocated large enough - to hold a pointer for the new state. */ - if (new_state >= d->tralloc) - { - int oldalloc = d->tralloc; - - while (new_state >= d->tralloc) - d->tralloc *= 2; - REALLOC(d->realtrans, int *, d->tralloc + 1); - d->trans = d->realtrans + 1; - REALLOC(d->fails, int *, d->tralloc); - REALLOC(d->success, int, d->tralloc); - while (oldalloc < d->tralloc) - { - d->trans[oldalloc] = NULL; - d->fails[oldalloc++] = NULL; - } - } -} - -/* Return values of transit_state_singlebyte(), and - transit_state_consume_1char. */ -typedef enum -{ - TRANSIT_STATE_IN_PROGRESS, /* State transition has not finished. */ - TRANSIT_STATE_DONE, /* State transition has finished. */ - TRANSIT_STATE_END_BUFFER /* Reach the end of the buffer. */ -} status_transit_state; - -/* Consume a single byte and transit state from 's' to '*next_state'. - This function is almost same as the state transition routin in dfaexec(). - But state transition is done just once, otherwise matching succeed or - reach the end of the buffer. */ -static status_transit_state -transit_state_singlebyte (struct dfa *d, int s, unsigned char const *p, - int *next_state) -{ - int *t; - int works = s; - - status_transit_state rval = TRANSIT_STATE_IN_PROGRESS; - - while (rval == TRANSIT_STATE_IN_PROGRESS) - { - if ((t = d->trans[works]) != NULL) - { - works = t[*p]; - rval = TRANSIT_STATE_DONE; - if (works < 0) - works = 0; - } - else if (works < 0) - { - if (p == buf_end) - /* At the moment, it must not happen. */ - return TRANSIT_STATE_END_BUFFER; - works = 0; - } - else if (d->fails[works]) - { - works = d->fails[works][*p]; - rval = TRANSIT_STATE_DONE; - } - else - { - build_state(works, d); - } - } - *next_state = works; - return rval; -} - -/* Check whether period can match or not in the current context. If it can, - return the amount of the bytes with which period can match, otherwise - return 0. - `pos' is the position of the period. `index' is the index from the - buf_begin, and it is the current position in the buffer. */ -static int -match_anychar (struct dfa *d, int s, position pos, int index) -{ - int newline = 0; - int letter = 0; - wchar_t wc; - int mbclen; - - wc = inputwcs[index]; - mbclen = (mblen_buf[index] == 0)? 1 : mblen_buf[index]; - - /* Check context. */ - if (wc == (wchar_t)eolbyte) - { - if (!(syntax_bits & RE_DOT_NEWLINE)) - return 0; - newline = 1; - } - else if (wc == (wchar_t)'\0') - { - if (syntax_bits & RE_DOT_NOT_NULL) - return 0; - newline = 1; - } - - if (iswalnum(wc) || wc == L'_') - letter = 1; - - if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].newline, - newline, d->states[s].letter, letter)) - return 0; - - return mbclen; -} - -/* Check whether bracket expression can match or not in the current context. - If it can, return the amount of the bytes with which expression can match, - otherwise return 0. - `pos' is the position of the bracket expression. `index' is the index - from the buf_begin, and it is the current position in the buffer. */ -int -match_mb_charset (struct dfa *d, int s, position pos, int index) -{ - int i; - int match; /* Flag which represent that matching succeed. */ - int match_len; /* Length of the character (or collating element) - with which this operator match. */ - size_t op_len; /* Length of the operator. */ - char buffer[128]; - wchar_t wcbuf[6]; - - /* Pointer to the structure to which we are currently reffering. */ - struct mb_char_classes *work_mbc; - - int newline = 0; - int letter = 0; - wchar_t wc; /* Current reffering character. */ - - wc = inputwcs[index]; - - /* Check context. */ - if (wc == (wchar_t)eolbyte) - { - if (!(syntax_bits & RE_DOT_NEWLINE)) - return 0; - newline = 1; - } - else if (wc == (wchar_t)'\0') - { - if (syntax_bits & RE_DOT_NOT_NULL) - return 0; - newline = 1; - } - if (iswalnum(wc) || wc == L'_') - letter = 1; - if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].newline, - newline, d->states[s].letter, letter)) - return 0; - - /* Assign the current reffering operator to work_mbc. */ - work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]); - match = !work_mbc->invert; - match_len = (mblen_buf[index] == 0)? 1 : mblen_buf[index]; - - /* match with a character class? */ - for (i = 0; inch_classes; i++) - { - if (iswctype((wint_t)wc, work_mbc->ch_classes[i])) - goto charset_matched; - } - - strncpy(buffer, buf_begin + index, match_len); - buffer[match_len] = '\0'; - - /* match with an equivalent class? */ - for (i = 0; inequivs; i++) - { - op_len = strlen(work_mbc->equivs[i]); - strncpy(buffer, buf_begin + index, op_len); - buffer[op_len] = '\0'; - if (strcoll(work_mbc->equivs[i], buffer) == 0) - { - match_len = op_len; - goto charset_matched; - } - } - - /* match with a collating element? */ - for (i = 0; incoll_elems; i++) - { - op_len = strlen(work_mbc->coll_elems[i]); - strncpy(buffer, buf_begin + index, op_len); - buffer[op_len] = '\0'; - - if (strcoll(work_mbc->coll_elems[i], buffer) == 0) - { - match_len = op_len; - goto charset_matched; - } - } - - wcbuf[0] = wc; - wcbuf[1] = wcbuf[3] = wcbuf[5] = '\0'; - - /* match with a range? */ - for (i = 0; inranges; i++) - { - wcbuf[2] = work_mbc->range_sts[i]; - wcbuf[4] = work_mbc->range_ends[i]; - - if (wcscoll(wcbuf, wcbuf+2) >= 0 && - wcscoll(wcbuf+4, wcbuf) >= 0) - goto charset_matched; - } - - /* match with a character? */ - if (case_fold) - wc = towlower (wc); - for (i = 0; inchars; i++) - { - if (wc == work_mbc->chars[i]) - goto charset_matched; - } - - match = !match; - - charset_matched: - return match ? match_len : 0; -} - -/* Check each of `d->states[s].mbps.elem' can match or not. Then return the - array which corresponds to `d->states[s].mbps.elem' and each element of - the array contains the amount of the bytes with which the element can - match. - `index' is the index from the buf_begin, and it is the current position - in the buffer. - Caller MUST free the array which this function return. */ -static int* -check_matching_with_multibyte_ops (struct dfa *d, int s, int index) -{ - int i; - int* rarray; - - MALLOC(rarray, int, d->states[s].mbps.nelem); - for (i = 0; i < d->states[s].mbps.nelem; ++i) - { - position pos = d->states[s].mbps.elems[i]; - switch(d->tokens[pos.index]) - { - case ANYCHAR: - rarray[i] = match_anychar(d, s, pos, index); - break; - case MBCSET: - rarray[i] = match_mb_charset(d, s, pos, index); - break; - default: - break; /* can not happen. */ - } - } - return rarray; -} - -/* Consume a single character and enumerate all of the positions which can - be next position from the state `s'. - `match_lens' is the input. It can be NULL, but it can also be the output - of check_matching_with_multibyte_ops() for optimization. - `mbclen' and `pps' are the output. `mbclen' is the length of the - character consumed, and `pps' is the set this function enumerate. */ -static status_transit_state -transit_state_consume_1char (struct dfa *d, int s, unsigned char const **pp, - int *match_lens, int *mbclen, position_set *pps) -{ - int i, j; - int s1, s2; - int* work_mbls; - status_transit_state rs = TRANSIT_STATE_DONE; - - /* Calculate the length of the (single/multi byte) character - to which p points. */ - *mbclen = (mblen_buf[*pp - buf_begin] == 0)? 1 - : mblen_buf[*pp - buf_begin]; - - /* Calculate the state which can be reached from the state `s' by - consuming `*mbclen' single bytes from the buffer. */ - s1 = s; - for (i = 0; i < *mbclen; i++) - { - s2 = s1; - rs = transit_state_singlebyte(d, s2, (*pp)++, &s1); - } - /* Copy the positions contained by `s1' to the set `pps'. */ - copy(&(d->states[s1].elems), pps); - - /* Check (inputed)match_lens, and initialize if it is NULL. */ - if (match_lens == NULL && d->states[s].mbps.nelem != 0) - work_mbls = check_matching_with_multibyte_ops(d, s, *pp - buf_begin); - else - work_mbls = match_lens; - - /* Add all of the positions which can be reached from `s' by consuming - a single character. */ - for (i = 0; i < d->states[s].mbps.nelem ; i++) - { - if (work_mbls[i] == *mbclen) - for (j = 0; j < d->follows[d->states[s].mbps.elems[i].index].nelem; - j++) - insert(d->follows[d->states[s].mbps.elems[i].index].elems[j], - pps); - } - - if (match_lens == NULL && work_mbls != NULL) - free(work_mbls); - return rs; -} - -/* Transit state from s, then return new state and update the pointer of the - buffer. This function is for some operator which can match with a multi- - byte character or a collating element(which may be multi characters). */ -static int -transit_state (struct dfa *d, int s, unsigned char const **pp) -{ - int s1; - int mbclen; /* The length of current input multibyte character. */ - int maxlen = 0; - int i, j; - int *match_lens = NULL; - int nelem = d->states[s].mbps.nelem; /* Just a alias. */ - position_set follows; - unsigned char const *p1 = *pp; - status_transit_state rs; - wchar_t wc; - - if (nelem > 0) - /* This state has (a) multibyte operator(s). - We check whether each of them can match or not. */ - { - /* Note: caller must free the return value of this function. */ - match_lens = check_matching_with_multibyte_ops(d, s, *pp - buf_begin); - - for (i = 0; i < nelem; i++) - /* Search the operator which match the longest string, - in this state. */ - { - if (match_lens[i] > maxlen) - maxlen = match_lens[i]; - } - } - - if (nelem == 0 || maxlen == 0) - /* This state has no multibyte operator which can match. - We need to check only one singlebyte character. */ - { - status_transit_state rs; - rs = transit_state_singlebyte(d, s, *pp, &s1); - - /* We must update the pointer if state transition succeeded. */ - if (rs == TRANSIT_STATE_DONE) - ++*pp; - - if (match_lens != NULL) - free(match_lens); - return s1; - } - - /* This state has some operators which can match a multibyte character. */ - follows.nelem = 0; - MALLOC(follows.elems, position, d->nleaves); - - /* `maxlen' may be longer than the length of a character, because it may - not be a character but a (multi character) collating element. - We enumerate all of the positions which `s' can reach by consuming - `maxlen' bytes. */ - rs = transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows); - - wc = inputwcs[*pp - mbclen - buf_begin]; - s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); - realloc_trans_if_necessary(d, s1); - - while (*pp - p1 < maxlen) - { - follows.nelem = 0; - rs = transit_state_consume_1char(d, s1, pp, NULL, &mbclen, &follows); - - for (i = 0; i < nelem ; i++) - { - if (match_lens[i] == *pp - p1) - for (j = 0; - j < d->follows[d->states[s1].mbps.elems[i].index].nelem; j++) - insert(d->follows[d->states[s1].mbps.elems[i].index].elems[j], - &follows); - } - - wc = inputwcs[*pp - mbclen - buf_begin]; - s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); - realloc_trans_if_necessary(d, s1); - } - free(match_lens); - free(follows.elems); - return s1; -} - -#endif - -/* Search through a buffer looking for a match to the given struct dfa. - Find the first occurrence of a string matching the regexp in the buffer, - and the shortest possible version thereof. Return the offset of the first - character after the match, or (size_t) -1 if none is found. BEGIN points to - the beginning of the buffer, and SIZE is the size of the buffer. If SIZE - is nonzero, BEGIN[SIZE - 1] must be a newline. BACKREF points to a place - where we're supposed to store a 1 if backreferencing happened and the - match needs to be verified by a backtracking matcher. Otherwise - we store a 0 in *backref. */ -size_t -dfaexec (struct dfa *d, char const *begin, size_t size, int *backref) -{ - register int s; /* Current state. */ - register unsigned char const *p; /* Current input character. */ - register unsigned char const *end; /* One past the last input character. */ - register int **trans, *t; /* Copy of d->trans so it can be optimized - into a register. */ - register unsigned char eol = eolbyte; /* Likewise for eolbyte. */ - static int sbit[NOTCHAR]; /* Table for anding with d->success. */ - static int sbit_init; - - if (! sbit_init) - { - int i; - - sbit_init = 1; - for (i = 0; i < NOTCHAR; ++i) - sbit[i] = (IS_WORD_CONSTITUENT(i)) ? 2 : 1; - sbit[eol] = 4; - } - - if (! d->tralloc) - build_state_zero(d); - - s = 0; - p = (unsigned char const *) begin; - end = p + size; - trans = d->trans; - -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - int remain_bytes, i; - buf_begin = begin; - buf_end = end; - - /* initialize mblen_buf, and inputwcs. */ - MALLOC(mblen_buf, unsigned char, end - (unsigned char const *)begin + 2); - MALLOC(inputwcs, wchar_t, end - (unsigned char const *)begin + 2); - memset(&mbs, 0, sizeof(mbstate_t)); - remain_bytes = 0; - for (i = 0; i < end - (unsigned char const *)begin + 1; i++) - { - if (remain_bytes == 0) - { - remain_bytes - = mbrtowc(inputwcs + i, begin + i, - end - (unsigned char const *)begin - i + 1, &mbs); - if (remain_bytes <= 1) - { - remain_bytes = 0; - inputwcs[i] = (wchar_t)begin[i]; - mblen_buf[i] = 0; - } - else - { - mblen_buf[i] = remain_bytes; - remain_bytes--; - } - } - else - { - mblen_buf[i] = remain_bytes; - inputwcs[i] = 0; - remain_bytes--; - } - } - mblen_buf[i] = 0; - inputwcs[i] = 0; /* sentinel */ - } -#endif /* MBS_SUPPORT */ - - for (;;) - { -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - while ((t = trans[s])) - { - if (d->states[s].mbps.nelem != 0) - { - /* Can match with a multibyte character( and multi character - collating element). */ - unsigned char const *nextp; - - SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); - - nextp = p; - s = transit_state(d, s, &nextp); - p = nextp; - - /* Trans table might be updated. */ - trans = d->trans; - } - else - { - SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); - s = t[*p++]; - } - } - else -#endif /* MBS_SUPPORT */ - while ((t = trans[s])) - s = t[*p++]; - - if (s < 0) - { - if (p == end) - { -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - free(mblen_buf); - free(inputwcs); - } -#endif /* MBS_SUPPORT */ - return (size_t) -1; - } - s = 0; - } - else if ((t = d->fails[s])) - { - if (d->success[s] & sbit[*p]) - { - if (backref) - *backref = (d->states[s].backref != 0); -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - free(mblen_buf); - free(inputwcs); - } -#endif /* MBS_SUPPORT */ - return (char const *) p - begin; - } - -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); - if (d->states[s].mbps.nelem != 0) - { - /* Can match with a multibyte character( and multi - character collating element). */ - unsigned char const *nextp; - nextp = p; - s = transit_state(d, s, &nextp); - p = nextp; - - /* Trans table might be updated. */ - trans = d->trans; - } - else - s = t[*p++]; - } - else -#endif /* MBS_SUPPORT */ - s = t[*p++]; - } - else - { - build_state(s, d); - trans = d->trans; - } - } -} - -/* Initialize the components of a dfa that the other routines don't - initialize for themselves. */ -void -dfainit (struct dfa *d) -{ - d->calloc = 1; - MALLOC(d->charclasses, charclass, d->calloc); - d->cindex = 0; - - d->talloc = 1; - MALLOC(d->tokens, token, d->talloc); - d->tindex = d->depth = d->nleaves = d->nregexps = 0; -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - d->nmultibyte_prop = 1; - MALLOC(d->multibyte_prop, int, d->nmultibyte_prop); - d->nmbcsets = 0; - d->mbcsets_alloc = 1; - MALLOC(d->mbcsets, struct mb_char_classes, d->mbcsets_alloc); - } -#endif - - d->searchflag = 0; - d->tralloc = 0; - - d->musts = 0; -} - -/* Parse and analyze a single string of the given length. */ -void -dfacomp (char const *s, size_t len, struct dfa *d, int searchflag) -{ - if (case_fold) /* dummy folding in service of dfamust() */ - { - char *lcopy; - int i; - - lcopy = malloc(len); - if (!lcopy) - dfaerror(_("out of memory")); - - /* This is a kludge. */ - case_fold = 0; - for (i = 0; i < len; ++i) - if (ISUPPER ((unsigned char) s[i])) - lcopy[i] = tolower ((unsigned char) s[i]); - else - lcopy[i] = s[i]; - - dfainit(d); - dfaparse(lcopy, len, d); - free(lcopy); - dfamust(d); - d->cindex = d->tindex = d->depth = d->nleaves = d->nregexps = 0; - case_fold = 1; - dfaparse(s, len, d); - dfaanalyze(d, searchflag); - } - else - { - dfainit(d); - dfaparse(s, len, d); - dfamust(d); - dfaanalyze(d, searchflag); - } -} - -/* Free the storage held by the components of a dfa. */ -void -dfafree (struct dfa *d) -{ - int i; - struct dfamust *dm, *ndm; - - free((ptr_t) d->charclasses); - free((ptr_t) d->tokens); - -#ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1) - { - free((ptr_t) d->multibyte_prop); - for (i = 0; i < d->nmbcsets; ++i) - { - int j; - struct mb_char_classes *p = &(d->mbcsets[i]); - if (p->chars != NULL) - free(p->chars); - if (p->ch_classes != NULL) - free(p->ch_classes); - if (p->range_sts != NULL) - free(p->range_sts); - if (p->range_ends != NULL) - free(p->range_ends); - - for (j = 0; j < p->nequivs; ++j) - free(p->equivs[j]); - if (p->equivs != NULL) - free(p->equivs); - - for (j = 0; j < p->ncoll_elems; ++j) - free(p->coll_elems[j]); - if (p->coll_elems != NULL) - free(p->coll_elems); - } - free((ptr_t) d->mbcsets); - } -#endif /* MBS_SUPPORT */ - - for (i = 0; i < d->sindex; ++i) - free((ptr_t) d->states[i].elems.elems); - free((ptr_t) d->states); - for (i = 0; i < d->tindex; ++i) - if (d->follows[i].elems) - free((ptr_t) d->follows[i].elems); - free((ptr_t) d->follows); - for (i = 0; i < d->tralloc; ++i) - if (d->trans[i]) - free((ptr_t) d->trans[i]); - else if (d->fails[i]) - free((ptr_t) d->fails[i]); - if (d->realtrans) free((ptr_t) d->realtrans); - if (d->fails) free((ptr_t) d->fails); - if (d->success) free((ptr_t) d->success); - for (dm = d->musts; dm; dm = ndm) - { - ndm = dm->next; - free(dm->must); - free((ptr_t) dm); - } -} - -/* Having found the postfix representation of the regular expression, - try to find a long sequence of characters that must appear in any line - containing the r.e. - Finding a "longest" sequence is beyond the scope here; - we take an easy way out and hope for the best. - (Take "(ab|a)b"--please.) - - We do a bottom-up calculation of sequences of characters that must appear - in matches of r.e.'s represented by trees rooted at the nodes of the postfix - representation: - sequences that must appear at the left of the match ("left") - sequences that must appear at the right of the match ("right") - lists of sequences that must appear somewhere in the match ("in") - sequences that must constitute the match ("is") - - When we get to the root of the tree, we use one of the longest of its - calculated "in" sequences as our answer. The sequence we find is returned in - d->must (where "d" is the single argument passed to "dfamust"); - the length of the sequence is returned in d->mustn. - - The sequences calculated for the various types of node (in pseudo ANSI c) - are shown below. "p" is the operand of unary operators (and the left-hand - operand of binary operators); "q" is the right-hand operand of binary - operators. - - "ZERO" means "a zero-length sequence" below. - - Type left right is in - ---- ---- ----- -- -- - char c # c # c # c # c - - ANYCHAR ZERO ZERO ZERO ZERO - - MBCSET ZERO ZERO ZERO ZERO - - CSET ZERO ZERO ZERO ZERO - - STAR ZERO ZERO ZERO ZERO - - QMARK ZERO ZERO ZERO ZERO - - PLUS p->left p->right ZERO p->in - - CAT (p->is==ZERO)? (q->is==ZERO)? (p->is!=ZERO && p->in plus - p->left : q->right : q->is!=ZERO) ? q->in plus - p->is##q->left p->right##q->is p->is##q->is : p->right##q->left - ZERO - - OR longest common longest common (do p->is and substrings common to - leading trailing q->is have same p->in and q->in - (sub)sequence (sub)sequence length and - of p->left of p->right content) ? - and q->left and q->right p->is : NULL - - If there's anything else we recognize in the tree, all four sequences get set - to zero-length sequences. If there's something we don't recognize in the tree, - we just return a zero-length sequence. - - Break ties in favor of infrequent letters (choosing 'zzz' in preference to - 'aaa')? - - And. . .is it here or someplace that we might ponder "optimizations" such as - egrep 'psi|epsilon' -> egrep 'psi' - egrep 'pepsi|epsilon' -> egrep 'epsi' - (Yes, we now find "epsi" as a "string - that must occur", but we might also - simplify the *entire* r.e. being sought) - grep '[c]' -> grep 'c' - grep '(ab|a)b' -> grep 'ab' - grep 'ab*' -> grep 'a' - grep 'a*b' -> grep 'b' - - There are several issues: - - Is optimization easy (enough)? - - Does optimization actually accomplish anything, - or is the automaton you get from "psi|epsilon" (for example) - the same as the one you get from "psi" (for example)? - - Are optimizable r.e.'s likely to be used in real-life situations - (something like 'ab*' is probably unlikely; something like is - 'psi|epsilon' is likelier)? */ - -static char * -icatalloc (char *old, char *new) -{ - char *result; - size_t oldsize, newsize; - - newsize = (new == NULL) ? 0 : strlen(new); - if (old == NULL) - oldsize = 0; - else if (newsize == 0) - return old; - else oldsize = strlen(old); - if (old == NULL) - result = (char *) malloc(newsize + 1); - else - result = (char *) realloc((void *) old, oldsize + newsize + 1); - if (result != NULL && new != NULL) - (void) strcpy(result + oldsize, new); - return result; -} - -static char * -icpyalloc (char *string) -{ - return icatalloc((char *) NULL, string); -} - -static char * -istrstr (char *lookin, char *lookfor) -{ - char *cp; - size_t len; - - len = strlen(lookfor); - for (cp = lookin; *cp != '\0'; ++cp) - if (strncmp(cp, lookfor, len) == 0) - return cp; - return NULL; -} - -static void -ifree (char *cp) -{ - if (cp != NULL) - free(cp); -} - -static void -freelist (char **cpp) -{ - int i; - - if (cpp == NULL) - return; - for (i = 0; cpp[i] != NULL; ++i) - { - free(cpp[i]); - cpp[i] = NULL; - } -} - -static char ** -enlist (char **cpp, char *new, size_t len) -{ - int i, j; - - if (cpp == NULL) - return NULL; - if ((new = icpyalloc(new)) == NULL) - { - freelist(cpp); - return NULL; - } - new[len] = '\0'; - /* Is there already something in the list that's new (or longer)? */ - for (i = 0; cpp[i] != NULL; ++i) - if (istrstr(cpp[i], new) != NULL) - { - free(new); - return cpp; - } - /* Eliminate any obsoleted strings. */ - j = 0; - while (cpp[j] != NULL) - if (istrstr(new, cpp[j]) == NULL) - ++j; - else - { - free(cpp[j]); - if (--i == j) - break; - cpp[j] = cpp[i]; - cpp[i] = NULL; - } - /* Add the new string. */ - cpp = (char **) realloc((char *) cpp, (i + 2) * sizeof *cpp); - if (cpp == NULL) - return NULL; - cpp[i] = new; - cpp[i + 1] = NULL; - return cpp; -} - -/* Given pointers to two strings, return a pointer to an allocated - list of their distinct common substrings. Return NULL if something - seems wild. */ -static char ** -comsubs (char *left, char *right) -{ - char **cpp; - char *lcp; - char *rcp; - size_t i, len; - - if (left == NULL || right == NULL) - return NULL; - cpp = (char **) malloc(sizeof *cpp); - if (cpp == NULL) - return NULL; - cpp[0] = NULL; - for (lcp = left; *lcp != '\0'; ++lcp) - { - len = 0; - rcp = strchr (right, *lcp); - while (rcp != NULL) - { - for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i) - continue; - if (i > len) - len = i; - rcp = strchr (rcp + 1, *lcp); - } - if (len == 0) - continue; - if ((cpp = enlist(cpp, lcp, len)) == NULL) - break; - } - return cpp; -} - -static char ** -addlists (char **old, char **new) -{ - int i; - - if (old == NULL || new == NULL) - return NULL; - for (i = 0; new[i] != NULL; ++i) - { - old = enlist(old, new[i], strlen(new[i])); - if (old == NULL) - break; - } - return old; -} - -/* Given two lists of substrings, return a new list giving substrings - common to both. */ -static char ** -inboth (char **left, char **right) -{ - char **both; - char **temp; - int lnum, rnum; - - if (left == NULL || right == NULL) - return NULL; - both = (char **) malloc(sizeof *both); - if (both == NULL) - return NULL; - both[0] = NULL; - for (lnum = 0; left[lnum] != NULL; ++lnum) - { - for (rnum = 0; right[rnum] != NULL; ++rnum) - { - temp = comsubs(left[lnum], right[rnum]); - if (temp == NULL) - { - freelist(both); - return NULL; - } - both = addlists(both, temp); - freelist(temp); - free(temp); - if (both == NULL) - return NULL; - } - } - return both; -} - -typedef struct -{ - char **in; - char *left; - char *right; - char *is; -} must; - -static void -resetmust (must *mp) -{ - mp->left[0] = mp->right[0] = mp->is[0] = '\0'; - freelist(mp->in); -} - -static void -dfamust (struct dfa *dfa) -{ - must *musts; - must *mp; - char *result; - int ri; - int i; - int exact; - token t; - static must must0; - struct dfamust *dm; - static char empty_string[] = ""; - - result = empty_string; - exact = 0; - musts = (must *) malloc((dfa->tindex + 1) * sizeof *musts); - if (musts == NULL) - return; - mp = musts; - for (i = 0; i <= dfa->tindex; ++i) - mp[i] = must0; - for (i = 0; i <= dfa->tindex; ++i) - { - mp[i].in = (char **) malloc(sizeof *mp[i].in); - mp[i].left = malloc(2); - mp[i].right = malloc(2); - mp[i].is = malloc(2); - if (mp[i].in == NULL || mp[i].left == NULL || - mp[i].right == NULL || mp[i].is == NULL) - goto done; - mp[i].left[0] = mp[i].right[0] = mp[i].is[0] = '\0'; - mp[i].in[0] = NULL; - } -#ifdef DEBUG - fprintf(stderr, "dfamust:\n"); - for (i = 0; i < dfa->tindex; ++i) - { - fprintf(stderr, " %d:", i); - prtok(dfa->tokens[i]); - } - putc('\n', stderr); -#endif - for (ri = 0; ri < dfa->tindex; ++ri) - { - switch (t = dfa->tokens[ri]) - { - case LPAREN: - case RPAREN: - goto done; /* "cannot happen" */ - case EMPTY: - case BEGLINE: - case ENDLINE: - case BEGWORD: - case ENDWORD: - case LIMWORD: - case NOTLIMWORD: - case BACKREF: - resetmust(mp); - break; - case STAR: - case QMARK: - if (mp <= musts) - goto done; /* "cannot happen" */ - --mp; - resetmust(mp); - break; - case OR: - case ORTOP: - if (mp < &musts[2]) - goto done; /* "cannot happen" */ - { - char **new; - must *lmp; - must *rmp; - int j, ln, rn, n; - - rmp = --mp; - lmp = --mp; - /* Guaranteed to be. Unlikely, but. . . */ - if (strcmp(lmp->is, rmp->is) != 0) - lmp->is[0] = '\0'; - /* Left side--easy */ - i = 0; - while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i]) - ++i; - lmp->left[i] = '\0'; - /* Right side */ - ln = strlen(lmp->right); - rn = strlen(rmp->right); - n = ln; - if (n > rn) - n = rn; - for (i = 0; i < n; ++i) - if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1]) - break; - for (j = 0; j < i; ++j) - lmp->right[j] = lmp->right[(ln - i) + j]; - lmp->right[j] = '\0'; - new = inboth(lmp->in, rmp->in); - if (new == NULL) - goto done; - freelist(lmp->in); - free((char *) lmp->in); - lmp->in = new; - } - break; - case PLUS: - if (mp <= musts) - goto done; /* "cannot happen" */ - --mp; - mp->is[0] = '\0'; - break; - case END: - if (mp != &musts[1]) - goto done; /* "cannot happen" */ - for (i = 0; musts[0].in[i] != NULL; ++i) - if (strlen(musts[0].in[i]) > strlen(result)) - result = musts[0].in[i]; - if (strcmp(result, musts[0].is) == 0) - exact = 1; - goto done; - case CAT: - if (mp < &musts[2]) - goto done; /* "cannot happen" */ - { - must *lmp; - must *rmp; - - rmp = --mp; - lmp = --mp; - /* In. Everything in left, plus everything in - right, plus catenation of - left's right and right's left. */ - lmp->in = addlists(lmp->in, rmp->in); - if (lmp->in == NULL) - goto done; - if (lmp->right[0] != '\0' && - rmp->left[0] != '\0') - { - char *tp; - - tp = icpyalloc(lmp->right); - if (tp == NULL) - goto done; - tp = icatalloc(tp, rmp->left); - if (tp == NULL) - goto done; - lmp->in = enlist(lmp->in, tp, - strlen(tp)); - free(tp); - if (lmp->in == NULL) - goto done; - } - /* Left-hand */ - if (lmp->is[0] != '\0') - { - lmp->left = icatalloc(lmp->left, - rmp->left); - if (lmp->left == NULL) - goto done; - } - /* Right-hand */ - if (rmp->is[0] == '\0') - lmp->right[0] = '\0'; - lmp->right = icatalloc(lmp->right, rmp->right); - if (lmp->right == NULL) - goto done; - /* Guaranteed to be */ - if (lmp->is[0] != '\0' && rmp->is[0] != '\0') - { - lmp->is = icatalloc(lmp->is, rmp->is); - if (lmp->is == NULL) - goto done; - } - else - lmp->is[0] = '\0'; - } - break; - default: - if (t < END) - { - /* "cannot happen" */ - goto done; - } - else if (t == '\0') - { - /* not on *my* shift */ - goto done; - } - else if (t >= CSET -#ifdef MBS_SUPPORT - || t == ANYCHAR - || t == MBCSET -#endif /* MBS_SUPPORT */ - ) - { - /* easy enough */ - resetmust(mp); - } - else - { - /* plain character */ - resetmust(mp); - mp->is[0] = mp->left[0] = mp->right[0] = t; - mp->is[1] = mp->left[1] = mp->right[1] = '\0'; - mp->in = enlist(mp->in, mp->is, (size_t)1); - if (mp->in == NULL) - goto done; - } - break; - } -#ifdef DEBUG - fprintf(stderr, " node: %d:", ri); - prtok(dfa->tokens[ri]); - fprintf(stderr, "\n in:"); - for (i = 0; mp->in[i]; ++i) - fprintf(stderr, " \"%s\"", mp->in[i]); - fprintf(stderr, "\n is: \"%s\"\n", mp->is); - fprintf(stderr, " left: \"%s\"\n", mp->left); - fprintf(stderr, " right: \"%s\"\n", mp->right); -#endif - ++mp; - } - done: - if (strlen(result)) - { - dm = (struct dfamust *) malloc(sizeof (struct dfamust)); - dm->exact = exact; - dm->must = malloc(strlen(result) + 1); - strcpy(dm->must, result); - dm->next = dfa->musts; - dfa->musts = dm; - } - mp = musts; - for (i = 0; i <= dfa->tindex; ++i) - { - freelist(mp[i].in); - ifree((char *) mp[i].in); - ifree(mp[i].left); - ifree(mp[i].right); - ifree(mp[i].is); - } - free((char *) mp); -} -/* vim:set shiftwidth=2: */ diff --git a/gnu/usr.bin/grep/dfa.h b/gnu/usr.bin/grep/dfa.h deleted file mode 100644 index 68a60eab77d..00000000000 --- a/gnu/usr.bin/grep/dfa.h +++ /dev/null @@ -1,434 +0,0 @@ -/* dfa.h - declarations for GNU deterministic regexp compiler - Copyright (C) 1988, 1998 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ - -/* Written June, 1988 by Mike Haertel */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/dfa.h 146199 2005-05-14 03:02:22Z tjr $ */ - -/* FIXME: - 2. We should not export so much of the DFA internals. - In addition to clobbering modularity, we eat up valuable - name space. */ - -#ifdef __STDC__ -# ifndef _PTR_T -# define _PTR_T - typedef void * ptr_t; -# endif -#else -# ifndef _PTR_T -# define _PTR_T - typedef char * ptr_t; -# endif -#endif - -#ifdef PARAMS -# undef PARAMS -#endif -#if PROTOTYPES -# define PARAMS(x) x -#else -# define PARAMS(x) () -#endif - -/* Number of bits in an unsigned char. */ -#ifndef CHARBITS -#define CHARBITS 8 -#endif - -/* First integer value that is greater than any character code. */ -#define NOTCHAR (1 << CHARBITS) - -/* INTBITS need not be exact, just a lower bound. */ -#ifndef INTBITS -#define INTBITS (CHARBITS * sizeof (int)) -#endif - -/* Number of ints required to hold a bit for every character. */ -#define CHARCLASS_INTS ((NOTCHAR + INTBITS - 1) / INTBITS) - -/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */ -typedef int charclass[CHARCLASS_INTS]; - -/* The regexp is parsed into an array of tokens in postfix form. Some tokens - are operators and others are terminal symbols. Most (but not all) of these - codes are returned by the lexical analyzer. */ - -typedef enum -{ - END = -1, /* END is a terminal symbol that matches the - end of input; any value of END or less in - the parse tree is such a symbol. Accepting - states of the DFA are those that would have - a transition on END. */ - - /* Ordinary character values are terminal symbols that match themselves. */ - - EMPTY = NOTCHAR, /* EMPTY is a terminal symbol that matches - the empty string. */ - - BACKREF, /* BACKREF is generated by \; it - it not completely handled. If the scanner - detects a transition on backref, it returns - a kind of "semi-success" indicating that - the match will have to be verified with - a backtracking matcher. */ - - BEGLINE, /* BEGLINE is a terminal symbol that matches - the empty string if it is at the beginning - of a line. */ - - ENDLINE, /* ENDLINE is a terminal symbol that matches - the empty string if it is at the end of - a line. */ - - BEGWORD, /* BEGWORD is a terminal symbol that matches - the empty string if it is at the beginning - of a word. */ - - ENDWORD, /* ENDWORD is a terminal symbol that matches - the empty string if it is at the end of - a word. */ - - LIMWORD, /* LIMWORD is a terminal symbol that matches - the empty string if it is at the beginning - or the end of a word. */ - - NOTLIMWORD, /* NOTLIMWORD is a terminal symbol that - matches the empty string if it is not at - the beginning or end of a word. */ - - QMARK, /* QMARK is an operator of one argument that - matches zero or one occurences of its - argument. */ - - STAR, /* STAR is an operator of one argument that - matches the Kleene closure (zero or more - occurrences) of its argument. */ - - PLUS, /* PLUS is an operator of one argument that - matches the positive closure (one or more - occurrences) of its argument. */ - - REPMN, /* REPMN is a lexical token corresponding - to the {m,n} construct. REPMN never - appears in the compiled token vector. */ - - CAT, /* CAT is an operator of two arguments that - matches the concatenation of its - arguments. CAT is never returned by the - lexical analyzer. */ - - OR, /* OR is an operator of two arguments that - matches either of its arguments. */ - - ORTOP, /* OR at the toplevel in the parse tree. - This is used for a boyer-moore heuristic. */ - - LPAREN, /* LPAREN never appears in the parse tree, - it is only a lexeme. */ - - RPAREN, /* RPAREN never appears in the parse tree. */ - - CRANGE, /* CRANGE never appears in the parse tree. - It stands for a character range that can - match a string of one or more characters. - For example, [a-z] can match "ch" in - a Spanish locale. */ - -#ifdef MBS_SUPPORT - ANYCHAR, /* ANYCHAR is a terminal symbol that matches - any multibyte(or singlebyte) characters. - It is used only if MB_CUR_MAX > 1. */ - - MBCSET, /* MBCSET is similar to CSET, but for - multibyte characters. */ -#endif /* MBS_SUPPORT */ - - CSET /* CSET and (and any value greater) is a - terminal symbol that matches any of a - class of characters. */ -} token; - -/* Sets are stored in an array in the compiled dfa; the index of the - array corresponding to a given set token is given by SET_INDEX(t). */ -#define SET_INDEX(t) ((t) - CSET) - -/* Sometimes characters can only be matched depending on the surrounding - context. Such context decisions depend on what the previous character - was, and the value of the current (lookahead) character. Context - dependent constraints are encoded as 8 bit integers. Each bit that - is set indicates that the constraint succeeds in the corresponding - context. - - bit 7 - previous and current are newlines - bit 6 - previous was newline, current isn't - bit 5 - previous wasn't newline, current is - bit 4 - neither previous nor current is a newline - bit 3 - previous and current are word-constituents - bit 2 - previous was word-constituent, current isn't - bit 1 - previous wasn't word-constituent, current is - bit 0 - neither previous nor current is word-constituent - - Word-constituent characters are those that satisfy isalnum(). - - The macro SUCCEEDS_IN_CONTEXT determines whether a a given constraint - succeeds in a particular context. Prevn is true if the previous character - was a newline, currn is true if the lookahead character is a newline. - Prevl and currl similarly depend upon whether the previous and current - characters are word-constituent letters. */ -#define MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \ - ((constraint) & 1 << (((prevn) ? 2 : 0) + ((currn) ? 1 : 0) + 4)) -#define MATCHES_LETTER_CONTEXT(constraint, prevl, currl) \ - ((constraint) & 1 << (((prevl) ? 2 : 0) + ((currl) ? 1 : 0))) -#define SUCCEEDS_IN_CONTEXT(constraint, prevn, currn, prevl, currl) \ - (MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \ - && MATCHES_LETTER_CONTEXT(constraint, prevl, currl)) - -/* The following macros give information about what a constraint depends on. */ -#define PREV_NEWLINE_DEPENDENT(constraint) \ - (((constraint) & 0xc0) >> 2 != ((constraint) & 0x30)) -#define PREV_LETTER_DEPENDENT(constraint) \ - (((constraint) & 0x0c) >> 2 != ((constraint) & 0x03)) - -/* Tokens that match the empty string subject to some constraint actually - work by applying that constraint to determine what may follow them, - taking into account what has gone before. The following values are - the constraints corresponding to the special tokens previously defined. */ -#define NO_CONSTRAINT 0xff -#define BEGLINE_CONSTRAINT 0xcf -#define ENDLINE_CONSTRAINT 0xaf -#define BEGWORD_CONSTRAINT 0xf2 -#define ENDWORD_CONSTRAINT 0xf4 -#define LIMWORD_CONSTRAINT 0xf6 -#define NOTLIMWORD_CONSTRAINT 0xf9 - -/* States of the recognizer correspond to sets of positions in the parse - tree, together with the constraints under which they may be matched. - So a position is encoded as an index into the parse tree together with - a constraint. */ -typedef struct -{ - unsigned index; /* Index into the parse array. */ - unsigned constraint; /* Constraint for matching this position. */ -} position; - -/* Sets of positions are stored as arrays. */ -typedef struct -{ - position *elems; /* Elements of this position set. */ - int nelem; /* Number of elements in this set. */ -} position_set; - -/* A state of the dfa consists of a set of positions, some flags, - and the token value of the lowest-numbered position of the state that - contains an END token. */ -typedef struct -{ - int hash; /* Hash of the positions of this state. */ - position_set elems; /* Positions this state could match. */ - char newline; /* True if previous state matched newline. */ - char letter; /* True if previous state matched a letter. */ - char backref; /* True if this state matches a \. */ - unsigned char constraint; /* Constraint for this state to accept. */ - int first_end; /* Token value of the first END in elems. */ -#ifdef MBS_SUPPORT - position_set mbps; /* Positions which can match multibyte - characters. e.g. period. - These staff are used only if - MB_CUR_MAX > 1. */ -#endif -} dfa_state; - -/* Element of a list of strings, at least one of which is known to - appear in any R.E. matching the DFA. */ -struct dfamust -{ - int exact; - char *must; - struct dfamust *next; -}; - -#ifdef MBS_SUPPORT -/* A bracket operator. - e.g. [a-c], [[:alpha:]], etc. */ -struct mb_char_classes -{ - int invert; - wchar_t *chars; /* Normal characters. */ - int nchars; - wctype_t *ch_classes; /* Character classes. */ - int nch_classes; - wchar_t *range_sts; /* Range characters (start of the range). */ - wchar_t *range_ends; /* Range characters (end of the range). */ - int nranges; - char **equivs; /* Equivalent classes. */ - int nequivs; - char **coll_elems; - int ncoll_elems; /* Collating elements. */ -}; -#endif - -/* A compiled regular expression. */ -struct dfa -{ - /* Stuff built by the scanner. */ - charclass *charclasses; /* Array of character sets for CSET tokens. */ - int cindex; /* Index for adding new charclasses. */ - int calloc; /* Number of charclasses currently allocated. */ - - /* Stuff built by the parser. */ - token *tokens; /* Postfix parse array. */ - int tindex; /* Index for adding new tokens. */ - int talloc; /* Number of tokens currently allocated. */ - int depth; /* Depth required of an evaluation stack - used for depth-first traversal of the - parse tree. */ - int nleaves; /* Number of leaves on the parse tree. */ - int nregexps; /* Count of parallel regexps being built - with dfaparse(). */ -#ifdef MBS_SUPPORT - /* These stuff are used only if MB_CUR_MAX > 1 or multibyte environments. */ - int nmultibyte_prop; - int *multibyte_prop; - /* The value of multibyte_prop[i] is defined by following rule. - if tokens[i] < NOTCHAR - bit 1 : tokens[i] is a singlebyte character, or the last-byte of - a multibyte character. - bit 0 : tokens[i] is a singlebyte character, or the 1st-byte of - a multibyte character. - if tokens[i] = MBCSET - ("the index of mbcsets correspnd to this operator" << 2) + 3 - - e.g. - tokens - = 'single_byte_a', 'multi_byte_A', single_byte_b' - = 'sb_a', 'mb_A(1st byte)', 'mb_A(2nd byte)', 'mb_A(3rd byte)', 'sb_b' - multibyte_prop - = 3 , 1 , 0 , 2 , 3 - */ - - /* Array of the bracket expressoin in the DFA. */ - struct mb_char_classes *mbcsets; - int nmbcsets; - int mbcsets_alloc; -#endif - - /* Stuff owned by the state builder. */ - dfa_state *states; /* States of the dfa. */ - int sindex; /* Index for adding new states. */ - int salloc; /* Number of states currently allocated. */ - - /* Stuff built by the structure analyzer. */ - position_set *follows; /* Array of follow sets, indexed by position - index. The follow of a position is the set - of positions containing characters that - could conceivably follow a character - matching the given position in a string - matching the regexp. Allocated to the - maximum possible position index. */ - int searchflag; /* True if we are supposed to build a searching - as opposed to an exact matcher. A searching - matcher finds the first and shortest string - matching a regexp anywhere in the buffer, - whereas an exact matcher finds the longest - string matching, but anchored to the - beginning of the buffer. */ - - /* Stuff owned by the executor. */ - int tralloc; /* Number of transition tables that have - slots so far. */ - int trcount; /* Number of transition tables that have - actually been built. */ - int **trans; /* Transition tables for states that can - never accept. If the transitions for a - state have not yet been computed, or the - state could possibly accept, its entry in - this table is NULL. */ - int **realtrans; /* Trans always points to realtrans + 1; this - is so trans[-1] can contain NULL. */ - int **fails; /* Transition tables after failing to accept - on a state that potentially could do so. */ - int *success; /* Table of acceptance conditions used in - dfaexec and computed in build_state. */ - struct dfamust *musts; /* List of strings, at least one of which - is known to appear in any r.e. matching - the dfa. */ -}; - -/* Some macros for user access to dfa internals. */ - -/* ACCEPTING returns true if s could possibly be an accepting state of r. */ -#define ACCEPTING(s, r) ((r).states[s].constraint) - -/* ACCEPTS_IN_CONTEXT returns true if the given state accepts in the - specified context. */ -#define ACCEPTS_IN_CONTEXT(prevn, currn, prevl, currl, state, dfa) \ - SUCCEEDS_IN_CONTEXT((dfa).states[state].constraint, \ - prevn, currn, prevl, currl) - -/* FIRST_MATCHING_REGEXP returns the index number of the first of parallel - regexps that a given state could accept. Parallel regexps are numbered - starting at 1. */ -#define FIRST_MATCHING_REGEXP(state, dfa) (-(dfa).states[state].first_end) - -/* Entry points. */ - -/* dfasyntax() takes three arguments; the first sets the syntax bits described - earlier in this file, the second sets the case-folding flag, and the - third specifies the line terminator. */ -extern void dfasyntax PARAMS ((reg_syntax_t, int, unsigned char)); - -/* Compile the given string of the given length into the given struct dfa. - Final argument is a flag specifying whether to build a searching or an - exact matcher. */ -extern void dfacomp PARAMS ((char const *, size_t, struct dfa *, int)); - -/* Execute the given struct dfa on the buffer of characters. The - last byte of the buffer must equal the end-of-line byte. - The final argument points to a flag that will - be set if further examination by a backtracking matcher is needed in - order to verify backreferencing; otherwise the flag will be cleared. - Returns (size_t) -1 if no match is found, or the offset of the first - character after the first & shortest matching string in the buffer. */ -extern size_t dfaexec PARAMS ((struct dfa *, char const *, size_t, int *)); - -/* Free the storage held by the components of a struct dfa. */ -extern void dfafree PARAMS ((struct dfa *)); - -/* Entry points for people who know what they're doing. */ - -/* Initialize the components of a struct dfa. */ -extern void dfainit PARAMS ((struct dfa *)); - -/* Incrementally parse a string of given length into a struct dfa. */ -extern void dfaparse PARAMS ((char const *, size_t, struct dfa *)); - -/* Analyze a parsed regexp; second argument tells whether to build a searching - or an exact matcher. */ -extern void dfaanalyze PARAMS ((struct dfa *, int)); - -/* Compute, for each possible character, the transitions out of a given - state, storing them in an array of integers. */ -extern void dfastate PARAMS ((int, struct dfa *, int [])); - -/* Error handling. */ - -/* dfaerror() is called by the regexp routines whenever an error occurs. It - takes a single argument, a NUL-terminated string describing the error. - The user must supply a dfaerror. */ -extern void dfaerror PARAMS ((const char *)); diff --git a/gnu/usr.bin/grep/doc/Makefile b/gnu/usr.bin/grep/doc/Makefile deleted file mode 100644 index fcb1f2e372f..00000000000 --- a/gnu/usr.bin/grep/doc/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD: src/gnu/usr.bin/grep/doc/Makefile,v 1.3 1999/11/22 08:56:30 obrien Exp $ - -INFO= grep -INFOSECTION= "System Utilities" - -.include diff --git a/gnu/usr.bin/grep/doc/grep.texi b/gnu/usr.bin/grep/doc/grep.texi deleted file mode 100644 index 32b27c41992..00000000000 --- a/gnu/usr.bin/grep/doc/grep.texi +++ /dev/null @@ -1,2090 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename grep.info -@settitle grep, print lines matching a pattern -@c %**end of header - -@c This file has the new style title page commands. -@c Run `makeinfo' rather than `texinfo-format-buffer'. - -@c smallbook - -@c tex -@c \overfullrule=0pt -@c end tex - -@include version.texi - -@c Combine indices. -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp - -@defcodeindex op -@syncodeindex op fn -@syncodeindex vr fn - -@ifinfo -@direntry -* grep: (grep). print lines matching a pattern. -@end direntry -This file documents @command{grep}, a pattern matching engine. - - -Published by the Free Software Foundation, -59 Temple Place - Suite 330 -Boston, MA 02111-1307, USA - -@c man begin COPYRIGHT -Copyright @copyright{} 2000, 2001 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``GNU General Public License'' and ``GNU Free -Documentation License'', with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the section -entitled ``GNU Free Documentation License'' (@pxref{Copying}). -@c man end -@end ifinfo - -@setchapternewpage off - -@titlepage -@title grep, searching for a pattern -@subtitle version @value{VERSION}, @value{UPDATED} -@author Alain Magloire et al. - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 2000, 2001 Free Software Foundation, Inc. - -@sp 2 -Published by the Free Software Foundation, @* -59 Temple Place - Suite 330, @* -Boston, MA 02111-1307, USA - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``GNU General Public License'' and ``GNU Free -Documentation License'', with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the section -entitled ``GNU Free Documentation License''. -@end titlepage - - -@ifnottex -@node Top -@top Grep - -@command{grep} searches for lines matching a pattern. - -This document was produced for version @value{VERSION} of @sc{gnu} -@command{grep}. -@end ifnottex - -@menu -* Introduction:: Introduction. -* Invoking:: Invoking @command{grep}; description of options. -* Diagnostics:: Exit status returned by @command{grep}. -* Grep Programs:: @command{grep} programs. -* Regular Expressions:: Regular Expressions. -* Usage:: Examples. -* Reporting Bugs:: Reporting Bugs. -* Copying:: License terms. -* Concept Index:: A menu with all the topics in this manual. -* Index:: A menu with all @command{grep} commands - and command-line options. -@end menu - - -@node Introduction, Invoking, Top, Top -@chapter Introduction - -@cindex Searching for a pattern. - -@command{grep} searches the input files -for lines containing a match to a given -pattern list. When it finds a match in a line, it copies the line to standard -output (by default), or does whatever other sort of output you have requested -with options. - -Though @command{grep} expects to do the matching on text, -it has no limits on input line length other than available memory, -and it can match arbitrary characters within a line. -If the final byte of an input file is not a newline, -@command{grep} silently supplies one. -Since newline is also a separator for the list of patterns, there -is no way to match newline characters in a text. - -@node Invoking -@chapter Invoking @command{grep} - -@command{grep} comes with a rich set of options from @sc{posix.2} and @sc{gnu} -extensions. - -@table @samp - -@item -c -@itemx --count -@opindex -c -@opindex --count -@cindex counting lines -Suppress normal output; instead print a count of matching -lines for each input file. With the @samp{-v}, @samp{--invert-match} option, -count non-matching lines. - -@item -e @var{pattern} -@itemx --regexp=@var{pattern} -@opindex -e -@opindex --regexp=@var{pattern} -@cindex pattern list -Use @var{pattern} as the pattern; useful to protect patterns -beginning with a @samp{-}. - -@item -f @var{file} -@itemx --file=@var{file} -@opindex -f -@opindex --file -@cindex pattern from file -Obtain patterns from @var{file}, one per line. The empty -file contains zero patterns, and therefore matches nothing. - -@item -i -@itemx --ignore-case -@opindex -i -@opindex --ignore-case -@cindex case insensitive search -Ignore case distinctions in both the pattern and the input files. - -@item -l -@itemx --files-with-matches -@opindex -l -@opindex --files-with-matches -@cindex names of matching files -Suppress normal output; instead print the name of each input -file from which output would normally have been printed. -The scanning of every file will stop on the first match. - -@item -n -@itemx --line-number -@opindex -n -@opindex --line-number -@cindex line numbering -Prefix each line of output with the line number within its input file. - -@item -o -@itemx --only-matching -@opindex -o -@opindex --only-matching -@cindex only matching -Print only the part of matching lines that actually matches @var{pattern}. - -@item -q -@itemx --quiet -@itemx --silent -@opindex -q -@opindex --quiet -@opindex --silent -@cindex quiet, silent -Quiet; do not write anything to standard output. Exit immediately with -zero status if any match is found, even if an error was detected. Also -see the @samp{-s} or @samp{--no-messages} option. - -@item -s -@itemx --no-messages -@opindex -s -@opindex --no-messages -@cindex suppress error messages -Suppress error messages about nonexistent or unreadable files. -Portability note: unlike @sc{gnu} @command{grep}, traditional -@command{grep} did not conform to @sc{posix.2}, because traditional -@command{grep} lacked a @samp{-q} option and its @samp{-s} option behaved -like @sc{gnu} @command{grep}'s @samp{-q} option. Shell scripts intended -to be portable to traditional @command{grep} should avoid both -@samp{-q} and @samp{-s} and should redirect -output to @file{/dev/null} instead. - -@item -v -@itemx --invert-match -@opindex -v -@opindex --invert-match -@cindex invert matching -@cindex print non-matching lines -Invert the sense of matching, to select non-matching lines. - -@item -x -@itemx --line-regexp -@opindex -x -@opindex --line-regexp -@cindex match the whole line -Select only those matches that exactly match the whole line. - -@end table - -@section @sc{gnu} Extensions - -@table @samp - -@item -A @var{num} -@itemx --after-context=@var{num} -@opindex -A -@opindex --after-context -@cindex after context -@cindex context lines, after match -Print @var{num} lines of trailing context after matching lines. - -@item -B @var{num} -@itemx --before-context=@var{num} -@opindex -B -@opindex --before-context -@cindex before context -@cindex context lines, before match -Print @var{num} lines of leading context before matching lines. - -@item -C @var{num} -@itemx --context=@var{num} -@opindex -C -@opindex --context -@cindex context -Print @var{num} lines of output context. - -@item --colour[=@var{WHEN}] -@itemx --color[=@var{WHEN}] -@opindex --colour -@cindex highlight, color, colour -The matching string is surrounded by the marker specify in @var{GREP_COLOR}. -@var{WHEN} may be `never', `always', or `auto'. - -@item -@var{num} -@opindex -NUM -Same as @samp{--context=@var{num}} lines of leading and trailing -context. However, grep will never print any given line more than once. - - -@item -V -@itemx --version -@opindex -V -@opindex --version -@cindex Version, printing -Print the version number of @command{grep} to the standard output stream. -This version number should be included in all bug reports. - -@item --help -@opindex --help -@cindex Usage summary, printing -Print a usage message briefly summarizing these command-line options -and the bug-reporting address, then exit. - -@itemx --binary-files=@var{type} -@opindex --binary-files -@cindex binary files -If the first few bytes of a file indicate that the file contains binary -data, assume that the file is of type @var{type}. By default, -@var{type} is @samp{binary}, and @command{grep} normally outputs either -a one-line message saying that a binary file matches, or no message if -there is no match. If @var{type} is @samp{without-match}, -@command{grep} assumes that a binary file does not match; -this is equivalent to the @samp{-I} option. If @var{type} -is @samp{text}, @command{grep} processes a binary file as if it were -text; this is equivalent to the @samp{-a} option. -@emph{Warning:} @samp{--binary-files=text} might output binary garbage, -which can have nasty side effects if the output is a terminal and if the -terminal driver interprets some of it as commands. - -@item -b -@itemx --byte-offset -@opindex -b -@opindex --byte-offset -@cindex byte offset -Print the byte offset within the input file before each line of output. -When @command{grep} runs on @sc{ms-dos} or MS-Windows, the printed -byte offsets -depend on whether the @samp{-u} (@samp{--unix-byte-offsets}) option is -used; see below. - -@item -D @var{action} -@itemx --devices=@var{action} -@opindex -D -@opindex --devices -@cindex device search -If an input file is a device, FIFO or socket, use @var{action} to process it. -By default, @var{action} is @samp{read}, which means that devices are -read just as if they were ordinary files. -If @var{action} is @samp{skip}, devices, FIFOs and sockets are silently -skipped. - -@item -d @var{action} -@itemx --directories=@var{action} -@opindex -d -@opindex --directories -@cindex directory search -If an input file is a directory, use @var{action} to process it. -By default, @var{action} is @samp{read}, which means that directories are -read just as if they were ordinary files (some operating systems -and filesystems disallow this, and will cause @command{grep} to print error -messages for every directory or silently skip them). If @var{action} is -@samp{skip}, directories are silently skipped. If @var{action} is -@samp{recurse}, @command{grep} reads all files under each directory, -recursively; this is equivalent to the @samp{-r} option. - -@item -H -@itemx --with-filename -@opindex -H -@opindex --With-filename -@cindex with filename prefix -Print the filename for each match. - -@item -h -@itemx --no-filename -@opindex -h -@opindex --no-filename -@cindex no filename prefix -Suppress the prefixing of filenames on output when multiple files are searched. - -@item --line-buffered -@opindex --line-buffered -@cindex line buffering -Set the line buffering policy, this can be a performance penality. - -@item --label=@var{LABEL} -@opindex --label -@cindex changing name of standard input -Displays input actually coming from standard input as input coming from file -@var{LABEL}. This is especially useful for tools like zgrep, e.g. -@command{gzip -cd foo.gz |grep --label=foo something} - -@item -L -@itemx --files-without-match -@opindex -L -@opindex --files-without-match -@cindex files which don't match -Suppress normal output; instead print the name of each input -file from which no output would normally have been printed. -The scanning of every file will stop on the first match. - -@item -a -@itemx --text -@opindex -a -@opindex --text -@cindex suppress binary data -@cindex binary files -Process a binary file as if it were text; this is equivalent to the -@samp{--binary-files=text} option. - -@item -I -Process a binary file as if it did not contain matching data; this is -equivalent to the @samp{--binary-files=without-match} option. - -@item -w -@itemx --word-regexp -@opindex -w -@opindex --word-regexp -@cindex matching whole words -Select only those lines containing matches that form -whole words. The test is that the matching substring -must either be at the beginning of the line, or preceded -by a non-word constituent character. Similarly, -it must be either at the end of the line or followed by -a non-word constituent character. Word-constituent -characters are letters, digits, and the underscore. - -@item -r -@itemx -R -@itemx --recursive -@opindex -r -@opindex --recursive -@cindex recursive search -@cindex searching directory trees -For each directory mentioned in the command line, read and process all -files in that directory, recursively. This is the same as the -@samp{--directories=recurse} option. - -@item --include=@var{file_pattern} -@opindex --include -@cindex include files -@cindex searching directory trees -When processing directories recursively, only files matching @var{file_pattern} -will be search. - -@item --exclude=@var{file_pattern} -@opindex --exclude -@cindex exclude files -@cindex searching directory trees -When processing directories recursively, skip files matching @var{file_pattern}. - -@item -m @var{num} -@itemx --max-count=@var{num} -@opindex -m -@opindex --max-count -@cindex max-count -Stop reading a file after @var{num} matching lines. If the input is -standard input from a regular file, and @var{num} matching lines are -output, @command{grep} ensures that the standard input is positioned to -just after the last matching line before exiting, regardless of the -presence of trailing context lines. This enables a calling process -to resume a search. For example, the following shell script makes use -of it: - -@example -while grep -m 1 PATTERN -do - echo xxxx -done < FILE -@end example - -But the following probably will not work because a pipe is not a regular -file: - -@example -# This probably will not work. -cat FILE | -while grep -m 1 PATTERN -do - echo xxxx -done -@end example - -When @command{grep} stops after NUM matching lines, it outputs -any trailing context lines. Since context does not include matching -lines, @command{grep} will stop when it encounters another matching line. -When the @samp{-c} or @samp{--count} option is also used, -@command{grep} does not output a count greater than @var{num}. -When the @samp{-v} or @samp{--invert-match} option is -also used, @command{grep} stops after outputting @var{num} -non-matching lines. - -@item -y -@opindex -y -@cindex case insensitive search, obsolete option -Obsolete synonym for @samp{-i}. - -@item -U -@itemx --binary -@opindex -U -@opindex --binary -@cindex DOS/Windows binary files -@cindex binary files, DOS/Windows -Treat the file(s) as binary. By default, under @sc{ms-dos} -and MS-Windows, @command{grep} guesses the file type by looking -at the contents of the first 32kB read from the file. -If @command{grep} decides the file is a text file, it strips the -@code{CR} characters from the original file contents (to make -regular expressions with @code{^} and @code{$} work correctly). -Specifying @samp{-U} overrules this guesswork, causing all -files to be read and passed to the matching mechanism -verbatim; if the file is a text file with @code{CR/LF} pairs -at the end of each line, this will cause some regular -expressions to fail. This option has no effect on platforms other than -@sc{ms-dos} and MS-Windows. - -@item -u -@itemx --unix-byte-offsets -@opindex -u -@opindex --unix-byte-offsets -@cindex DOS byte offsets -@cindex byte offsets, on DOS/Windows -Report Unix-style byte offsets. This switch causes -@command{grep} to report byte offsets as if the file were Unix style -text file, i.e., the byte offsets ignore the @code{CR} characters which were -stripped. This will produce results identical to running @command{grep} on -a Unix machine. This option has no effect unless @samp{-b} -option is also used; it has no effect on platforms other than @sc{ms-dos} and -MS-Windows. - -@item --mmap -@opindex --mmap -@cindex memory mapped input -If possible, use the @code{mmap} system call to read input, instead of -the default @code{read} system call. In some situations, @samp{--mmap} -yields better performance. However, @samp{--mmap} can cause undefined -behavior (including core dumps) if an input file shrinks while -@command{grep} is operating, or if an I/O error occurs. - -@item -Z -@itemx --null -@opindex -Z -@opindex --null -@cindex zero-terminated file names -Output a zero byte (the @sc{ascii} @code{NUL} character) instead of the -character that normally follows a file name. For example, @samp{grep --lZ} outputs a zero byte after each file name instead of the usual -newline. This option makes the output unambiguous, even in the presence -of file names containing unusual characters like newlines. This option -can be used with commands like @samp{find -print0}, @samp{perl -0}, -@samp{sort -z}, and @samp{xargs -0} to process arbitrary file names, -even those that contain newline characters. - -@item -z -@itemx --null-data -@opindex -z -@opindex --null-data -@cindex zero-terminated lines -Treat the input as a set of lines, each terminated by a zero byte (the -@sc{ascii} @code{NUL} character) instead of a newline. Like the @samp{-Z} -or @samp{--null} option, this option can be used with commands like -@samp{sort -z} to process arbitrary file names. - -@end table - -Several additional options control which variant of the @command{grep} -matching engine is used. @xref{Grep Programs}. - -@section Environment Variables - -Grep's behavior is affected by the following environment variables. - -A locale @code{LC_@var{foo}} is specified by examining the three -environment variables @env{LC_ALL}, @env{LC_@var{foo}}, and @env{LANG}, -in that order. The first of these variables that is set specifies the -locale. For example, if @env{LC_ALL} is not set, but @env{LC_MESSAGES} -is set to @samp{pt_BR}, then Brazilian Portuguese is used for the -@code{LC_MESSAGES} locale. The C locale is used if none of these -environment variables are set, or if the locale catalog is not -installed, or if @command{grep} was not compiled with national language -support (@sc{nls}). - -@cindex environment variables - -@table @env - -@item GREP_OPTIONS -@vindex GREP_OPTIONS -@cindex default options environment variable -This variable specifies default options to be placed in front of any -explicit options. For example, if @code{GREP_OPTIONS} is -@samp{--binary-files=without-match --directories=skip}, @command{grep} -behaves as if the two options @samp{--binary-files=without-match} and -@samp{--directories=skip} had been specified before -any explicit options. Option specifications are separated by -whitespace. A backslash escapes the next character, so it can be used to -specify an option containing whitespace or a backslash. - -@item GREP_COLOR -@vindex GREP_COLOR -@cindex highlight markers -This variable specifies the surrounding markers use to highlight the matching -text. The default is control ascii red. - -@item LC_ALL -@itemx LC_COLLATE -@itemx LANG -@vindex LC_ALL -@vindex LC_COLLATE -@vindex LANG -@cindex character type -@cindex national language support -@cindex NLS -These variables specify the @code{LC_COLLATE} locale, which determines -the collating sequence used to interpret range expressions like -@samp{[a-z]}. - -@item LC_ALL -@itemx LC_CTYPE -@itemx LANG -@vindex LC_ALL -@vindex LC_CTYPE -@vindex LANG -@cindex character type -@cindex national language support -@cindex NLS -These variables specify the @code{LC_CTYPE} locale, which determines the -type of characters, e.g., which characters are whitespace. - -@item LC_ALL -@itemx LC_MESSAGES -@itemx LANG -@vindex LC_ALL -@vindex LC_MESSAGES -@vindex LANG -@cindex language of messages -@cindex message language -@cindex national language support -@cindex NLS -@cindex translation of message language -These variables specify the @code{LC_MESSAGES} locale, which determines -the language that @command{grep} uses for messages. The default C -locale uses American English messages. - -@item POSIXLY_CORRECT -@vindex POSIXLY_CORRECT -If set, @command{grep} behaves as @sc{posix.2} requires; otherwise, -@command{grep} behaves more like other @sc{gnu} programs. @sc{posix.2} -requires that options that -follow file names must be treated as file names; by default, such -options are permuted to the front of the operand list and are treated as -options. Also, @sc{posix.2} requires that unrecognized options be -diagnosed as -``illegal'', but since they are not really against the law the default -is to diagnose them as ``invalid''. @code{POSIXLY_CORRECT} also -disables @code{_@var{N}_GNU_nonoption_argv_flags_}, described below. - -@item _@var{N}_GNU_nonoption_argv_flags_ -@vindex _@var{N}_GNU_nonoption_argv_flags_ -(Here @code{@var{N}} is @command{grep}'s numeric process ID.) If the -@var{i}th character of this environment variable's value is @samp{1}, do -not consider the @var{i}th operand of @command{grep} to be an option, even if -it appears to be one. A shell can put this variable in the environment -for each command it runs, specifying which operands are the results of -file name wildcard expansion and therefore should not be treated as -options. This behavior is available only with the @sc{gnu} C library, and -only when @code{POSIXLY_CORRECT} is not set. - -@end table - -@node Diagnostics -@chapter Diagnostics - -Normally, exit status is 0 if selected lines are found and 1 otherwise. -But the exit status is 2 if an error occurred, unless the @option{-q} or -@option{--quiet} or @option{--silent} option is used and a selected line -is found. - -@node Grep Programs -@chapter @command{grep} programs - -@command{grep} searches the named input files (or standard input if no -files are named, or the file name @file{-} is given) for lines containing -a match to the given pattern. By default, @command{grep} prints the -matching lines. There are four major variants of @command{grep}, -controlled by the following options. - -@table @samp - -@item -G -@itemx --basic-regexp -@opindex -G -@opindex --basic-regexp -@cindex matching basic regular expressions -Interpret the pattern as a basic regular expression. This is the default. - -@item -E -@itemx --extended-regexp -@opindex -E -@opindex --extended-regexp -@cindex matching extended regular expressions -Interpret the pattern as an extended regular expression. - -@item -F -@itemx --fixed-strings -@opindex -F -@opindex --fixed-strings -@cindex matching fixed strings -Interpret the pattern as a list of fixed strings, separated -by newlines, any of which is to be matched. - -@item -P -@itemx --perl-regexp -@opindex -P -@opindex --perl-regexp -@cindex matching Perl regular expressions -Interpret the pattern as a Perl regular expression. - -@end table - -In addition, two variant programs @sc{egrep} and @sc{fgrep} are available. -@sc{egrep} is the same as @samp{grep -E}. @sc{fgrep} is the -same as @samp{grep -F}. - -@node Regular Expressions -@chapter Regular Expressions -@cindex regular expressions - -A @dfn{regular expression} is a pattern that describes a set of strings. -Regular expressions are constructed analogously to arithmetic expressions, -by using various operators to combine smaller expressions. -@command{grep} understands two different versions of regular expression -syntax: ``basic''(BRE) and ``extended''(ERE). In @sc{gnu} @command{grep}, -there is no difference in available functionality using either syntax. -In other implementations, basic regular expressions are less powerful. -The following description applies to extended regular expressions; -differences for basic regular expressions are summarized afterwards. - -The fundamental building blocks are the regular expressions that match -a single character. Most characters, including all letters and digits, -are regular expressions that match themselves. Any metacharacter -with special meaning may be quoted by preceding it with a backslash. - -A regular expression may be followed by one of several -repetition operators: - -@table @samp - -@item . -@opindex . -@cindex dot -@cindex period -The period @samp{.} matches any single character. - -@item ? -@opindex ? -@cindex question mark -@cindex match sub-expression at most once -The preceding item is optional and will be matched at most once. - -@item * -@opindex * -@cindex asterisk -@cindex match sub-expression zero or more times -The preceding item will be matched zero or more times. - -@item + -@opindex + -@cindex plus sign -The preceding item will be matched one or more times. - -@item @{@var{n}@} -@opindex @{n@} -@cindex braces, one argument -@cindex match sub-expression n times -The preceding item is matched exactly @var{n} times. - -@item @{@var{n},@} -@opindex @{n,@} -@cindex braces, second argument omitted -@cindex match sub-expression n or more times -The preceding item is matched n or more times. - -@item @{@var{n},@var{m}@} -@opindex @{n,m@} -@cindex braces, two arguments -The preceding item is matched at least @var{n} times, but not more than -@var{m} times. - -@end table - -Two regular expressions may be concatenated; the resulting regular -expression matches any string formed by concatenating two substrings -that respectively match the concatenated subexpressions. - -Two regular expressions may be joined by the infix operator @samp{|}; the -resulting regular expression matches any string matching either subexpression. - -Repetition takes precedence over concatenation, which in turn -takes precedence over alternation. A whole subexpression may be -enclosed in parentheses to override these precedence rules. - -@section Character Class - -@cindex bracket expression -@cindex character class -A @dfn{bracket expression} is a list of characters enclosed by @samp{[} and -@samp{]}. It matches any single character in that list; if the first -character of the list is the caret @samp{^}, then it matches any character -@strong{not} in the list. For example, the regular expression -@samp{[0123456789]} matches any single digit. - -@cindex range expression -Within a bracket expression, a @dfn{range expression} consists of two -characters separated by a hyphen. It matches any single character that -sorts between the two characters, inclusive, using the locale's -collating sequence and character set. For example, in the default C -locale, @samp{[a-d]} is equivalent to @samp{[abcd]}. Many locales sort -characters in dictionary order, and in these locales @samp{[a-d]} is -typically not equivalent to @samp{[abcd]}; it might be equivalent to -@samp{[aBbCcDd]}, for example. To obtain the traditional interpretation -of bracket expressions, you can use the C locale by setting the -@env{LC_ALL} environment variable to the value @samp{C}. - -Finally, certain named classes of characters are predefined within -bracket expressions, as follows. -Their interpretation depends on the @code{LC_CTYPE} locale; the -interpretation below is that of the C locale, which is the default -if no @code{LC_CTYPE} locale is specified. - -@cindex classes of characters -@cindex character classes -@table @samp - -@item [:alnum:] -@opindex alnum -@cindex alphanumeric characters -Alphanumeric characters: -@samp{[:alpha:]} and @samp{[:digit:]}. - -@item [:alpha:] -@opindex alpha -@cindex alphabetic characters -Alphabetic characters: -@samp{[:lower:]} and @samp{[:upper:]}. - -@item [:blank:] -@opindex blank -@cindex blank characters -Blank characters: -space and tab. - -@item [:cntrl:] -@opindex cntrl -@cindex control characters -Control characters. In @sc{ascii}, these characters have octal codes 000 -through 037, and 177 (@code{DEL}). In other character sets, these are -the equivalent characters, if any. - -@item [:digit:] -@opindex digit -@cindex digit characters -@cindex numeric characters -Digits: @code{0 1 2 3 4 5 6 7 8 9}. - -@item [:graph:] -@opindex graph -@cindex graphic characters -Graphical characters: -@samp{[:alnum:]} and @samp{[:punct:]}. - -@item [:lower:] -@opindex lower -@cindex lower-case letters -Lower-case letters: -@code{a b c d e f g h i j k l m n o p q r s t u v w x y z}. - -@item [:print:] -@opindex print -@cindex printable characters -Printable characters: -@samp{[:alnum:]}, @samp{[:punct:]}, and space. - -@item [:punct:] -@opindex punct -@cindex punctuation characters -Punctuation characters: -@code{!@: " # $ % & ' ( ) * + , - .@: / : ; < = > ?@: @@ [ \ ] ^ _ ` @{ | @} ~}. - -@item [:space:] -@opindex space -@cindex space characters -@cindex whitespace characters -Space characters: -tab, newline, vertical tab, form feed, carriage return, and space. - -@item [:upper:] -@opindex upper -@cindex upper-case letters -Upper-case letters: -@code{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}. - -@item [:xdigit:] -@opindex xdigit -@cindex xdigit class -@cindex hexadecimal digits -Hexadecimal digits: -@code{0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f}. - -@end table -For example, @samp{[[:alnum:]]} means @samp{[0-9A-Za-z]}, except the latter -depends upon the C locale and the @sc{ascii} character -encoding, whereas the former is independent of locale and character set. -(Note that the brackets in these class names are -part of the symbolic names, and must be included in addition to -the brackets delimiting the bracket list.) - -Most metacharacters lose their special meaning inside lists. - -@table @samp -@item ] -ends the list if it's not the first list item. So, if you want to make -the @samp{]} character a list item, you must put it first. - -@item [. -represents the open collating symbol. - -@item .] -represents the close collating symbol. - -@item [= -represents the open equivalence class. - -@item =] -represents the close equivalence class. - -@item [: -represents the open character class followed by a valid character class name. - -@item :] -represents the close character class followed by a valid character class name. - -@item - -represents the range if it's not first or last in a list or the ending point -of a range. - -@item ^ -represents the characters not in the list. If you want to make the @samp{^} -character a list item, place it anywhere but first. - -@end table - -@section Backslash Character -@cindex backslash - -The @samp{\} when followed by certain ordinary characters take a special -meaning : - -@table @samp - -@item @samp{\b} -Match the empty string at the edge of a word. - -@item @samp{\B} -Match the empty string provided it's not at the edge of a word. - -@item @samp{\<} -Match the empty string at the beginning of word. - -@item @samp{\>} -Match the empty string at the end of word. - -@item @samp{\w} -Match word constituent, it is a synonym for @samp{[[:alnum:]]}. - -@item @samp{\W} -Match non word constituent, it is a synonym for @samp{[^[:alnum:]]}. - -@end table - -For example , @samp{\brat\b} matches the separate word @samp{rat}, -@samp{c\Brat\Be} matches @samp{crate}, but @samp{dirty \Brat} doesn't -match @samp{dirty rat}. - -@section Anchoring -@cindex anchoring - -The caret @samp{^} and the dollar sign @samp{$} are metacharacters that -respectively match the empty string at the beginning and end of a line. - -@section Back-reference -@cindex back-reference - -The back-reference @samp{\@var{n}}, where @var{n} is a single digit, matches -the substring previously matched by the @var{n}th parenthesized subexpression -of the regular expression. For example, @samp{(a)\1} matches @samp{aa}. -When use with alternation if the group does not participate in the match, then -the back-reference makes the whole match fail. For example, @samp{a(.)|b\1} -will not match @samp{ba}. When multiple regular expressions are given with -@samp{-e} or from a file @samp{-f file}, the back-referecences are local to -each expression. - -@section Basic vs Extended -@cindex basic regular expressions - -In basic regular expressions the metacharacters @samp{?}, @samp{+}, -@samp{@{}, @samp{|}, @samp{(}, and @samp{)} lose their special meaning; -instead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{}, -@samp{\|}, @samp{\(}, and @samp{\)}. - -@cindex interval specifications -Traditional @command{egrep} did not support the @samp{@{} metacharacter, -and some @command{egrep} implementations support @samp{\@{} instead, so -portable scripts should avoid @samp{@{} in @samp{egrep} patterns and -should use @samp{[@{]} to match a literal @samp{@{}. - -@sc{gnu} @command{egrep} attempts to support traditional usage by -assuming that @samp{@{} is not special if it would be the start of an -invalid interval specification. For example, the shell command -@samp{egrep '@{1'} searches for the two-character string @samp{@{1} -instead of reporting a syntax error in the regular expression. -@sc{posix.2} allows this behavior as an extension, but portable scripts -should avoid it. - -@node Usage -@chapter Usage - -@cindex Usage, examples -Here is an example shell command that invokes @sc{gnu} @command{grep}: - -@example -grep -i 'hello.*world' menu.h main.c -@end example - -@noindent -This lists all lines in the files @file{menu.h} and @file{main.c} that -contain the string @samp{hello} followed by the string @samp{world}; -this is because @samp{.*} matches zero or more characters within a line. -@xref{Regular Expressions}. The @samp{-i} option causes @command{grep} -to ignore case, causing it to match the line @samp{Hello, world!}, which -it would not otherwise match. @xref{Invoking}, for more details about -how to invoke @command{grep}. - -@cindex Using @command{grep}, Q&A -@cindex FAQ about @command{grep} usage -Here are some common questions and answers about @command{grep} usage. - -@enumerate - -@item -How can I list just the names of matching files? - -@example -grep -l 'main' *.c -@end example - -@noindent -lists the names of all C files in the current directory whose contents -mention @samp{main}. - -@item -How do I search directories recursively? - -@example -grep -r 'hello' /home/gigi -@end example - -@noindent -searches for @samp{hello} in all files under the directory -@file{/home/gigi}. For more control of which files are searched, use -@command{find}, @command{grep} and @command{xargs}. For example, -the following command searches only C files: - -@smallexample -find /home/gigi -name '*.c' -print | xargs grep 'hello' /dev/null -@end smallexample - -This differs from the command: - -@example -grep -r 'hello' *.c -@end example - -which merely looks for @samp{hello} in all files in the current -directory whose names end in @samp{.c}. Here the @option{-r} is -probably unnecessary, as recursion occurs only in the unlikely event -that one of @samp{.c} files is a directory. - -@item -What if a pattern has a leading @samp{-}? - -@example -grep -e '--cut here--' * -@end example - -@noindent -searches for all lines matching @samp{--cut here--}. Without @samp{-e}, -@command{grep} would attempt to parse @samp{--cut here--} as a list of -options. - -@item -Suppose I want to search for a whole word, not a part of a word? - -@example -grep -w 'hello' * -@end example - -@noindent -searches only for instances of @samp{hello} that are entire words; it -does not match @samp{Othello}. For more control, use @samp{\<} and -@samp{\>} to match the start and end of words. For example: - -@example -grep 'hello\>' * -@end example - -@noindent -searches only for words ending in @samp{hello}, so it matches the word -@samp{Othello}. - -@item -How do I output context around the matching lines? - -@example -grep -C 2 'hello' * -@end example - -@noindent -prints two lines of context around each matching line. - -@item -How do I force grep to print the name of the file? - -Append @file{/dev/null}: - -@example -grep 'eli' /etc/passwd /dev/null -@end example - -gets you: - -@smallexample -/etc/passwd:eli:DNGUTF58.IMe.:98:11:Eli Smith:/home/do/eli:/bin/bash -@end smallexample - -@item -Why do people use strange regular expressions on @command{ps} output? - -@example -ps -ef | grep '[c]ron' -@end example - -If the pattern had been written without the square brackets, it would -have matched not only the @command{ps} output line for @command{cron}, -but also the @command{ps} output line for @command{grep}. -Note that some platforms @command{ps} limit the ouput to the width -of the screen, grep does not have any limit on the length of a line -except the available memory. - -@item -Why does @command{grep} report ``Binary file matches''? - -If @command{grep} listed all matching ``lines'' from a binary file, it -would probably generate output that is not useful, and it might even -muck up your display. So @sc{gnu} @command{grep} suppresses output from -files that appear to be binary files. To force @sc{gnu} @command{grep} -to output lines even from files that appear to be binary, use the -@samp{-a} or @samp{--binary-files=text} option. To eliminate the -``Binary file matches'' messages, use the @samp{-I} or -@samp{--binary-files=without-match} option. - -@item -Why doesn't @samp{grep -lv} print nonmatching file names? - -@samp{grep -lv} lists the names of all files containing one or more -lines that do not match. To list the names of all files that contain no -matching lines, use the @samp{-L} or @samp{--files-without-match} -option. - -@item -I can do @sc{or} with @samp{|}, but what about @sc{and}? - -@example -grep 'paul' /etc/motd | grep 'franc,ois' -@end example - -@noindent -finds all lines that contain both @samp{paul} and @samp{franc,ois}. - -@item -How can I search in both standard input and in files? - -Use the special file name @samp{-}: - -@example -cat /etc/passwd | grep 'alain' - /etc/motd -@end example - -@item -@cindex palindromes -How to express palindromes in a regular expression? - -It can be done by using the back referecences, for example a palindrome -of 4 chararcters can be written in BRE. - -@example -grep -w -e '\(.\)\(.\).\2\1' file -@end example - -It matches the word "radar" or "civic". - -Guglielmo Bondioni proposed a single RE that finds all the palindromes up to 19 -characters long. - -@example -egrep -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file -@end example - -Note this is done by using GNU ERE extensions, it might not be portable on -other greps. - -@item -Why are my expressions whith the vertical bar fail? - -@example -/bin/echo "ba" | egrep '(a)\1|(b)\1' -@end example - -The first alternate branch fails then the first group was not in the match -this will make the second alternate branch fails. For example, "aaba" will -match, the first group participate in the match and can be reuse in the -second branch. - -@item -What do @command{grep, fgrep, egrep} stand for ? - -grep comes from the way line editing was done on Unix. For example, -@command{ed} uses this syntax to print a list of matching lines on the screen. - -@example -global/regular expression/print -g/re/p -@end example - -@command{fgrep} stands for Fixed @command{grep}, @command{egrep} Extended -@command{grep}. - -@end enumerate - -@node Reporting Bugs, Copying, Usage, Top -@chapter Reporting bugs - -@cindex Bugs, reporting -Email bug reports to @email{bug-gnu-utils@@gnu.org}. -Be sure to include the word ``grep'' somewhere in the ``Subject:'' field. - -Large repetition counts in the @samp{@{n,m@}} construct may cause -@command{grep} to use lots of memory. In addition, certain other -obscure regular expressions require exponential time and -space, and may cause grep to run out of memory. -Back-references are very slow, and may require exponential time. - -@node Copying, GNU General Public License, Reporting Bugs, Top -@chapter Copying -@cindex Copying -GNU grep is licensed under the GNU GPL, which makes it @dfn{free -software}. - -Please note that ``free'' in ``free software'' refers to liberty, not -price. As some GNU project advocates like to point out, think of ``free -speech'' rather than ``free beer''. The exact and legally binding -distribution terms are spelled out below; in short, you have the right -(freedom) to run and change grep and distribute it to other people, and -even---if you want---charge money for doing either. The important -restriction is that you have to grant your recipients the same rights -and impose the same restrictions. - -This method of licensing software is also known as @dfn{open source} -because, among other things, it makes sure that all recipients will -receive the source code along with the program, and be able to improve -it. The GNU project prefers the term ``free software'' for reasons -outlined at -@url{http://www.gnu.org/philosophy/free-software-for-freedom.html}. - -The exact license terms are defined by this paragraph and the GNU -General Public License it refers to: - -@quotation -GNU grep 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 2 of the License, or (at your -option) any later version. - -GNU grep 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. - -A copy of the GNU General Public License is included as part of this -manual; if you did not receive it, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -@end quotation - -In addition to this, this manual is free in the same sense: - -@quotation -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``GNU General Public License'' and ``GNU Free -Documentation License'', with no Front-Cover Texts, and with no -Back-Cover Texts. A copy of the license is included in the section -entitled ``GNU Free Documentation License''. -@end quotation - -@c #### Maybe we should wrap these licenses in ifinfo? Stallman says -@c that the GFDL needs to be present in the manual, and to me it would -@c suck to include the license for the manual and not the license for -@c the program. - -The full texts of the GNU General Public License and of the GNU Free -Documentation License are available below. - -@menu -* GNU General Public License:: GNU GPL -* GNU Free Documentation License:: GNU FDL -@end menu - -@node GNU General Public License, GNU Free Documentation License, Copying, Copying -@section GNU General Public License -@center Version 2, June 1991 -@cindex GPL, GNU General Public License - -@display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -@item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) -@end enumerate - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -@enumerate a -@item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -@item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -@item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) -@end enumerate - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -@item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -@item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo -@cindex no warranty - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the ``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and an idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -This program 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 2 -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, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@smallexample -@group -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end group -@end smallexample - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - -@node GNU Free Documentation License, Concept Index, GNU General Public License, Copying -@section GNU Free Documentation License -@center Version 1.1, March 2000 -@cindex FDL, GNU Free Documentation License - -@display -Copyright (C) 2000 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display -@sp 1 -@enumerate 0 -@item -PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -written document ``free'' in the sense of freedom: to assure everyone -the effective freedom to copy and redistribute it, with or without -modifying it, either commercially or noncommercially. Secondarily, -this License preserves for the author and publisher a way to get -credit for their work, while not being considered responsible for -modifications made by others. - -This License is a kind of ``copyleft'', which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - -@sp 1 -@item -APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work that contains a -notice placed by the copyright holder saying it can be distributed -under the terms of this License. The ``Document'', below, refers to any -such manual or work. Any member of the public is a licensee, and is -addressed as ``you''. - -A ``Modified Version'' of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A ``Secondary Section'' is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (For example, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The ``Invariant Sections'' are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. - -The ``Cover Texts'' are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. - -A ``Transparent'' copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, whose contents can be viewed and edited directly and -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup has been designed to thwart or discourage -subsequent modification by readers is not Transparent. A copy that is -not ``Transparent'' is called ``Opaque''. - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML designed for human modification. Opaque formats include -PostScript, PDF, proprietary formats that can be read and edited only -by proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML produced by some word processors for output -purposes only. - -The ``Title Page'' means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, ``Title Page'' means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. -@sp 1 -@item -VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. -@sp 1 -@item -COPYING IN QUANTITY - -If you publish printed copies of the Document numbering more than 100, -and the Document's license notice requires Cover Texts, you must enclose -the copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a publicly-accessible computer-network location containing a complete -Transparent copy of the Document, free of added material, which the -general network-using public has access to download anonymously at no -charge using public-standard network protocols. If you use the latter -option, you must take reasonably prudent steps, when you begin -distribution of Opaque copies in quantity, to ensure that this -Transparent copy will remain thus accessible at the stated location -until at least one year after the last time you distribute an Opaque -copy (directly or through your agents or retailers) of that edition to -the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. -@sp 1 -@item -MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission.@* -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has less than five).@* -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher.@* -D. Preserve all the copyright notices of the Document.@* -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices.@* -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below.@* -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice.@* -H. Include an unaltered copy of this License.@* -I. Preserve the section entitled ``History'', and its title, and add to - it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section entitled ``History'' in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence.@* -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the ``History'' section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission.@* -K. In any section entitled ``Acknowledgements'' or ``Dedications'', - preserve the section's title, and preserve in the section all the - substance and tone of each of the contributor acknowledgements - and/or dedications given therein.@* -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles.@* -M. Delete any section entitled ``Endorsements''. Such a section - may not be included in the Modified Version.@* -N. Do not retitle any existing section as ``Endorsements'' - or to conflict in title with any Invariant Section.@* -@sp 1 -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section entitled ``Endorsements'', provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. -@sp 1 -@item -COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections entitled ``History'' -in the various original documents, forming one section entitled -``History''; likewise combine any sections entitled ``Acknowledgements'', -and any sections entitled ``Dedications''. You must delete all sections -entitled ``Endorsements.'' -@sp 1 -@item -COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. -@sp 1 -@item -AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, does not as a whole count as a Modified Version -of the Document, provided no compilation copyright is claimed for the -compilation. Such a compilation is called an ``aggregate'', and this -License does not apply to the other self-contained works thus compiled -with the Document, on account of their being thus compiled, if they -are not themselves derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one quarter -of the entire aggregate, the Document's Cover Texts may be placed on -covers that surround only the Document within the aggregate. -Otherwise they must appear on covers around the whole aggregate. -@sp 1 -@item -TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License provided that you also include the -original English version of this License. In case of a disagreement -between the translation and the original English version of this -License, the original English version will prevail. -@sp 1 -@item -TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. -@sp 1 -@item -FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License ``or any later version'' applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - -@end enumerate - -@unnumberedsec ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - -@smallexample -@group - - Copyright (C) @var{year} @var{your name}. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.1 - or any later version published by the Free Software Foundation; - with the Invariant Sections being @var{list their titles}, with the - Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}. - A copy of the license is included in the section entitled ``GNU - Free Documentation License''. -@end group -@end smallexample -If you have no Invariant Sections, write ``with no Invariant Sections'' -instead of saying which ones are invariant. If you have no -Front-Cover Texts, write ``no Front-Cover Texts'' instead of -``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. - -@page -@node Concept Index, Index, GNU Free Documentation License, Top -@unnumbered Concept Index - -This is a general index of all issues discussed in this manual, with the -exception of the @command{grep} commands and command-line options. - -@printindex cp - -@page -@node Index,, Concept Index, Top -@unnumbered Index - -This is an alphabetical list of all @command{grep} commands, command-line -options, and environment variables. - -@printindex fn - -@contents -@bye diff --git a/gnu/usr.bin/grep/doc/version.texi b/gnu/usr.bin/grep/doc/version.texi deleted file mode 100644 index 4350a83ba1f..00000000000 --- a/gnu/usr.bin/grep/doc/version.texi +++ /dev/null @@ -1,4 +0,0 @@ -@set UPDATED 23 January 2002 -@set UPDATED-MONTH January 2002 -@set EDITION 2.5.1 -@set VERSION 2.5.1 diff --git a/gnu/usr.bin/grep/error.c b/gnu/usr.bin/grep/error.c deleted file mode 100644 index c78b6cffb94..00000000000 --- a/gnu/usr.bin/grep/error.c +++ /dev/null @@ -1,276 +0,0 @@ -/* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000 Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* Written by David MacKenzie . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#if HAVE_LIBINTL_H -# include -#endif - -#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC -# if __STDC__ -# include -# define VA_START(args, lastarg) va_start(args, lastarg) -# else -# include -# define VA_START(args, lastarg) va_start(args) -# endif -#else -# define va_alist a1, a2, a3, a4, a5, a6, a7, a8 -# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; -#endif - -#if STDC_HEADERS || _LIBC -# include -# include -#else -void exit (); -#endif - -#include "error.h" - -#ifndef HAVE_DECL_STRERROR_R -"this configure-time declaration test was not run" -#endif -#if !HAVE_DECL_STRERROR_R -char *strerror_r (); -#endif - -#ifndef _ -# define _(String) String -#endif - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -void (*error_print_progname) ( -#if __STDC__ - 0 - void -#endif - ); - -/* This variable is incremented each time `error' is called. */ -unsigned int error_message_count; - -#ifdef _LIBC -/* In the GNU C library, there is a predefined variable for this. */ - -# define program_name program_invocation_name -# include - -/* In GNU libc we want do not want to use the common name `error' directly. - Instead make it a weak alias. */ -# define error __error -# define error_at_line __error_at_line - -# ifdef USE_IN_LIBIO -# include -# define fflush(s) _IO_fflush (s) -# endif - -#else /* not _LIBC */ - -/* The calling program should define program_name and set it to the - name of the executing program. */ -extern char *program_name; - -# ifdef HAVE_STRERROR_R -# define __strerror_r strerror_r -# else -# if HAVE_STRERROR -# ifndef strerror /* On some systems, strerror is a macro */ -char *strerror (); -# endif -# else -static char * -private_strerror (errnum) - int errnum; -{ - extern char *sys_errlist[]; - extern int sys_nerr; - - if (errnum > 0 && errnum <= sys_nerr) - return _(sys_errlist[errnum]); - return _("Unknown system error"); -} -# define strerror private_strerror -# endif /* HAVE_STRERROR */ -# endif /* HAVE_STRERROR_R */ -#endif /* not _LIBC */ - -/* Print the program name and error message MESSAGE, which is a printf-style - format string with optional args. - If ERRNUM is nonzero, print its corresponding system error message. - Exit with status STATUS if it is nonzero. */ -/* VARARGS */ - -void -#if defined VA_START && __STDC__ -error (int status, int errnum, const char *message, ...) -#else -error (status, errnum, message, va_alist) - int status; - int errnum; - char *message; - va_dcl -#endif -{ -#ifdef VA_START - va_list args; -#endif - - if (error_print_progname) - (*error_print_progname) (); - else - { - fflush (stdout); - fprintf (stderr, "%s: ", program_name); - } - -#ifdef VA_START - VA_START (args, message); -# if HAVE_VPRINTF || _LIBC - vfprintf (stderr, message, args); -# else - _doprnt (message, args, stderr); -# endif - va_end (args); -#else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); -#endif - - ++error_message_count; - if (errnum) - { -#if defined HAVE_STRERROR_R || _LIBC - char errbuf[1024]; -# if HAVE_WORKING_STRERROR_R || _LIBC - fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf)); -# else - /* Don't use __strerror_r's return value because on some systems - (at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */ - __strerror_r (errnum, errbuf, sizeof errbuf); - fprintf (stderr, ": %s", errbuf); -# endif -#else - fprintf (stderr, ": %s", strerror (errnum)); -#endif - } - putc ('\n', stderr); - fflush (stderr); - if (status) - exit (status); -} - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -int error_one_per_line; - -void -#if defined VA_START && __STDC__ -error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, ...) -#else -error_at_line (status, errnum, file_name, line_number, message, va_alist) - int status; - int errnum; - const char *file_name; - unsigned int line_number; - char *message; - va_dcl -#endif -{ -#ifdef VA_START - va_list args; -#endif - - if (error_one_per_line) - { - static const char *old_file_name; - static unsigned int old_line_number; - - if (old_line_number == line_number && - (file_name == old_file_name || !strcmp (old_file_name, file_name))) - /* Simply return and print nothing. */ - return; - - old_file_name = file_name; - old_line_number = line_number; - } - - if (error_print_progname) - (*error_print_progname) (); - else - { - fflush (stdout); - fprintf (stderr, "%s:", program_name); - } - - if (file_name != NULL) - fprintf (stderr, "%s:%d: ", file_name, line_number); - -#ifdef VA_START - VA_START (args, message); -# if HAVE_VPRINTF || _LIBC - vfprintf (stderr, message, args); -# else - _doprnt (message, args, stderr); -# endif - va_end (args); -#else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); -#endif - - ++error_message_count; - if (errnum) - { -#if defined HAVE_STRERROR_R || _LIBC - char errbuf[1024]; -# if HAVE_WORKING_STRERROR_R || _LIBC - fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf)); -# else - /* Don't use __strerror_r's return value because on some systems - (at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */ - __strerror_r (errnum, errbuf, sizeof errbuf); - fprintf (stderr, ": %s", errbuf); -# endif -#else - fprintf (stderr, ": %s", strerror (errnum)); -#endif - } - putc ('\n', stderr); - fflush (stderr); - if (status) - exit (status); -} - -#ifdef _LIBC -/* Make the weak alias. */ -# undef error -# undef error_at_line -weak_alias (__error, error) -weak_alias (__error_at_line, error_at_line) -#endif diff --git a/gnu/usr.bin/grep/error.h b/gnu/usr.bin/grep/error.h deleted file mode 100644 index 20f75824d61..00000000000 --- a/gnu/usr.bin/grep/error.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Declaration for error-reporting function - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. - - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#ifndef _ERROR_H -#define _ERROR_H 1 - -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __format__ format -# define __printf__ printf -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__STDC__) && __STDC__ - -/* Print a message with `fprintf (stderr, FORMAT, ...)'; - if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). - If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ - -extern void error (int status, int errnum, const char *format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); - -extern void error_at_line (int status, int errnum, const char *fname, - unsigned int lineno, const char *format, ...) - __attribute__ ((__format__ (__printf__, 5, 6))); - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -extern void (*error_print_progname) (void); - -#else -void error (); -void error_at_line (); -extern void (*error_print_progname) (); -#endif - -/* This variable is incremented each time `error' is called. */ -extern unsigned int error_message_count; - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -extern int error_one_per_line; - -#ifdef __cplusplus -} -#endif - -#endif /* error.h */ diff --git a/gnu/usr.bin/grep/exclude.c b/gnu/usr.bin/grep/exclude.c deleted file mode 100644 index 1925a398a01..00000000000 --- a/gnu/usr.bin/grep/exclude.c +++ /dev/null @@ -1,128 +0,0 @@ -/* exclude.c -- exclude file names - Copyright 1992, 1993, 1994, 1997, 1999, 2000 Free Software Foundation, Inc. - - This program 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 2, 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; see the file COPYING. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Paul Eggert */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#ifndef errno -extern int errno; -#endif -#include -#include -#include -#include - -void *xmalloc PARAMS ((size_t)); -void *xrealloc PARAMS ((void *, size_t)); - -/* Keep track of excluded file name patterns. */ - -struct exclude - { - char const **exclude; - int exclude_alloc; - int exclude_count; - }; - -struct exclude * -new_exclude (void) -{ - struct exclude *ex = (struct exclude *) xmalloc (sizeof (struct exclude)); - ex->exclude_count = 0; - ex->exclude_alloc = 64; - ex->exclude = (char const **) xmalloc (ex->exclude_alloc * sizeof (char *)); - return ex; -} - -int -excluded_filename (struct exclude const *ex, char const *f, int options) -{ - char const * const *exclude = ex->exclude; - int exclude_count = ex->exclude_count; - int i; - - for (i = 0; i < exclude_count; i++) - if (fnmatch (exclude[i], f, options) == 0) - return 1; - - return 0; -} - -void -add_exclude (struct exclude *ex, char const *pattern) -{ - if (ex->exclude_alloc <= ex->exclude_count) - ex->exclude = (char const **) xrealloc (ex->exclude, - ((ex->exclude_alloc *= 2) - * sizeof (char *))); - - ex->exclude[ex->exclude_count++] = pattern; -} - -int -add_exclude_file (void (*add_func) PARAMS ((struct exclude *, char const *)), - struct exclude *ex, char const *filename, char line_end) -{ - int use_stdin = filename[0] == '-' && !filename[1]; - FILE *in; - char *buf; - char *p; - char const *pattern; - char const *lim; - size_t buf_alloc = 1024; - size_t buf_count = 0; - int c; - int e = 0; - - if (use_stdin) - in = stdin; - else if (! (in = fopen (filename, "r"))) - return -1; - - buf = xmalloc (buf_alloc); - - while ((c = getc (in)) != EOF) - { - buf[buf_count++] = c; - if (buf_count == buf_alloc) - buf = xrealloc (buf, buf_alloc *= 2); - } - - buf = xrealloc (buf, buf_count + 1); - - if (ferror (in)) - e = errno; - - if (!use_stdin && fclose (in) != 0) - e = errno; - - for (pattern = p = buf, lim = buf + buf_count; p <= lim; p++) - if (p < lim ? *p == line_end : buf < p && p[-1]) - { - *p = '\0'; - (*add_func) (ex, pattern); - pattern = p + 1; - } - - errno = e; - return e ? -1 : 0; -} diff --git a/gnu/usr.bin/grep/exclude.h b/gnu/usr.bin/grep/exclude.h deleted file mode 100644 index 8a48a00ecea..00000000000 --- a/gnu/usr.bin/grep/exclude.h +++ /dev/null @@ -1,35 +0,0 @@ -/* exclude.h -- declarations for excluding file names - Copyright 1992, 1993, 1994, 1997, 1999 Free Software Foundation, Inc. - - This program 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 2, 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; see the file COPYING. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Paul Eggert */ - -#ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -#endif - -struct exclude; - -struct exclude *new_exclude PARAMS ((void)); -void add_exclude PARAMS ((struct exclude *, char const *)); -int add_exclude_file PARAMS ((void (*) (struct exclude *, char const *), - struct exclude *, char const *, char)); -int excluded_filename PARAMS ((struct exclude const *, char const *, int)); diff --git a/gnu/usr.bin/grep/getpagesize.h b/gnu/usr.bin/grep/getpagesize.h deleted file mode 100644 index 9c5789b78f0..00000000000 --- a/gnu/usr.bin/grep/getpagesize.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Emulate getpagesize on systems that lack it. */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/getpagesize.h 131557 2004-07-04 10:02:03Z tjr $ */ - -#ifndef HAVE_GETPAGESIZE - -#if !defined getpagesize && defined __BEOS__ -# include -# define getpagesize() B_PAGE_SIZE -#endif - -#ifdef HAVE_UNISTD_H -# include -#endif - -#if !defined getpagesize && defined _SC_PAGESIZE -# if !(defined VMS && __VMS_VER < 70000000) -# define getpagesize() sysconf (_SC_PAGESIZE) -# endif -#endif - -#if !defined getpagesize && defined VMS -# ifdef __ALPHA -# define getpagesize() 8192 -# else -# define getpagesize() 512 -# endif -#endif - -#ifndef getpagesize -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define CLSIZE 1 -# endif -# define getpagesize() (NBPG * CLSIZE) -# else -# ifdef NBPC -# define getpagesize() NBPC -# endif -# endif -# endif -#endif - -#endif /* not HAVE_GETPAGESIZE */ diff --git a/gnu/usr.bin/grep/grep.1 b/gnu/usr.bin/grep/grep.1 deleted file mode 100644 index a740ddba49e..00000000000 --- a/gnu/usr.bin/grep/grep.1 +++ /dev/null @@ -1,780 +0,0 @@ -.\" grep man page -.\" $FreeBSD: stable/11/gnu/usr.bin/grep/grep.1 163231 2006-10-11 09:52:32Z trhodes $ -.if !\n(.g \{\ -. if !\w|\*(lq| \{\ -. ds lq `` -. if \w'\(lq' .ds lq "\(lq -. \} -. if !\w|\*(rq| \{\ -. ds rq '' -. if \w'\(rq' .ds rq "\(rq -. \} -.\} -.de Id -.ds Dt \\$4 -.. -.Id $Id: grep.1,v 1.23 2002/01/22 13:20:04 bero Exp $ -.TH GREP 1 \*(Dt "GNU Project" -.SH NAME -grep, egrep, fgrep, zgrep, zegrep, zfgrep, -bzgrep, bzegrep, bzfgrep \- print lines matching a pattern -.SH SYNOPSIS -.B grep -.RI [ options ] -.I PATTERN -.RI [ FILE .\|.\|.] -.br -.B grep -.RI [ options ] -.RB [ \-e -.I PATTERN -| -.B \-f -.IR FILE ] -.RI [ FILE .\|.\|.] -.SH DESCRIPTION -.B grep -searches the named input -.IR FILE s -(or standard input if no files are named, or -the file name -.B \- -is given) -for lines containing a match to the given -.IR PATTERN . -By default, -.B grep -prints the matching lines. -.PP -In addition, two variant programs -.B egrep -and -.B fgrep -are available. -.B egrep -is the same as -.BR "grep\ \-E" . -.B fgrep -is the same as -.BR "grep\ \-F" . -.B zgrep -is the same as -.BR "grep\ \-Z" . -.B zegrep -is the same as -.BR "grep\ \-EZ" . -.B zfgrep -is the same as -.BR "grep\ \-FZ" . -.SH OPTIONS -.TP -.BI \-A " NUM" "\fR,\fP \-\^\-after-context=" NUM -Print -.I NUM -lines of trailing context after matching lines. -Places a line containing -.B \-\^\- -between contiguous groups of matches. -.TP -.BR \-a ", " \-\^\-text -Process a binary file as if it were text; this is equivalent to the -.B \-\^\-binary-files=text -option. -.TP -.BI \-B " NUM" "\fR,\fP \-\^\-before-context=" NUM -Print -.I NUM -lines of leading context before matching lines. -Places a line containing -.B \-\^\- -between contiguous groups of matches. -.TP -.BI \-C " NUM" "\fR,\fP \-\^\-context=" NUM -Print -.I NUM -lines of output context. -Places a line containing -.B \-\^\- -between contiguous groups of matches. -.TP -.BR \-b ", " \-\^\-byte-offset -Print the byte offset within the input file before -each line of output. -.TP -.BI \-\^\-binary-files= TYPE -If the first few bytes of a file indicate that the file contains binary -data, assume that the file is of type -.IR TYPE . -By default, -.I TYPE -is -.BR binary , -and -.B grep -normally outputs either -a one-line message saying that a binary file matches, or no message if -there is no match. -If -.I TYPE -is -.BR without-match , -.B grep -assumes that a binary file does not match; this is equivalent to the -.B \-I -option. -If -.I TYPE -is -.BR text , -.B grep -processes a binary file as if it were text; this is equivalent to the -.B \-a -option. -.I Warning: -.B "grep \-\^\-binary-files=text" -might output binary garbage, -which can have nasty side effects if the output is a terminal and if the -terminal driver interprets some of it as commands. -.TP -.BI \-\^\-colour[=\fIWHEN\fR] ", " \-\^\-color[=\fIWHEN\fR] -Surround the matching string with the marker find in -.B GREP_COLOR -environment variable. WHEN may be `never', `always', or `auto' -.TP -.BR \-c ", " \-\^\-count -Suppress normal output; instead print a count of -matching lines for each input file. -With the -.BR \-v ", " \-\^\-invert-match -option (see below), count non-matching lines. -.TP -.BI \-D " ACTION" "\fR,\fP \-\^\-devices=" ACTION -If an input file is a device, FIFO or socket, use -.I ACTION -to process it. By default, -.I ACTION -is -.BR read , -which means that devices are read just as if they were ordinary files. -If -.I ACTION -is -.BR skip , -devices are silently skipped. -.TP -.BI \-d " ACTION" "\fR,\fP \-\^\-directories=" ACTION -If an input file is a directory, use -.I ACTION -to process it. By default, -.I ACTION -is -.BR read , -which means that directories are read just as if they were ordinary files. -If -.I ACTION -is -.BR skip , -directories are silently skipped. -If -.I ACTION -is -.BR recurse , -.B grep -reads all files under each directory, recursively; -this is equivalent to the -.B \-r -option. -.TP -.BR \-E ", " \-\^\-extended-regexp -Interpret -.I PATTERN -as an extended regular expression (see below). -.TP -.BI \-e " PATTERN" "\fR,\fP \-\^\-regexp=" PATTERN -Use -.I PATTERN -as the pattern; useful to protect patterns beginning with -.BR \- . -.TP -.BR \-F ", " \-\^\-fixed-strings -Interpret -.I PATTERN -as a list of fixed strings, separated by newlines, -any of which is to be matched. -.TP -.BR \-P ", " \-\^\-perl-regexp -Interpret -.I PATTERN -as a Perl regular expression. -This option is not supported in FreeBSD. -.TP -.BI \-f " FILE" "\fR,\fP \-\^\-file=" FILE -Obtain patterns from -.IR FILE , -one per line. -The empty file contains zero patterns, and therefore matches nothing. -.TP -.BR \-G ", " \-\^\-basic-regexp -Interpret -.I PATTERN -as a basic regular expression (see below). This is the default. -.TP -.BR \-H ", " \-\^\-with-filename -Print the filename for each match. -.TP -.BR \-h ", " \-\^\-no-filename -Suppress the prefixing of filenames on output -when multiple files are searched. -.TP -.B \-\^\-help -Output a brief help message. -.TP -.BR \-I -Process a binary file as if it did not contain matching data; this is -equivalent to the -.B \-\^\-binary-files=without-match -option. -.TP -.BR \-i ", " \-\^\-ignore-case -Ignore case distinctions in both the -.I PATTERN -and the input files. -.TP -.BR \-L ", " \-\^\-files-without-match -Suppress normal output; instead print the name -of each input file from which no output would -normally have been printed. The scanning will stop -on the first match. -.TP -.BR \-l ", " \-\^\-files-with-matches -Suppress normal output; instead print -the name of each input file from which output -would normally have been printed. The scanning will -stop on the first match. -.TP -.BI \-m " NUM" "\fR,\fP \-\^\-max-count=" NUM -Stop reading a file after -.I NUM -matching lines. If the input is standard input from a regular file, -and -.I NUM -matching lines are output, -.B grep -ensures that the standard input is positioned to just after the last -matching line before exiting, regardless of the presence of trailing -context lines. This enables a calling process to resume a search. -When -.B grep -stops after -.I NUM -matching lines, it outputs any trailing context lines. When the -.B \-c -or -.B \-\^\-count -option is also used, -.B grep -does not output a count greater than -.IR NUM . -When the -.B \-v -or -.B \-\^\-invert-match -option is also used, -.B grep -stops after outputting -.I NUM -non-matching lines. -.TP -.B \-\^\-mmap -If possible, use the -.BR mmap (2) -system call to read input, instead of -the default -.BR read (2) -system call. In some situations, -.B \-\^\-mmap -yields better performance. However, -.B \-\^\-mmap -can cause undefined behavior (including core dumps) -if an input file shrinks while -.B grep -is operating, or if an I/O error occurs. -.TP -.BR \-n ", " \-\^\-line-number -Prefix each line of output with the line number -within its input file. -.TP -.BR \-o ", " \-\^\-only-matching -Show only the part of a matching line that matches -.I PATTERN. -.TP -.BI \-\^\-label= LABEL -Displays input actually coming from standard input as input coming from file -.I LABEL. -This is especially useful for tools like zgrep, e.g. -.B "gzip -cd foo.gz |grep --label=foo something" -.TP -.BR \-\^\-line-buffered -Flush output on every line. -Note that this incurs a performance penalty. -.TP -.BR \-q ", " \-\^\-quiet ", " \-\^\-silent -Quiet; do not write anything to standard output. -Exit immediately with zero status if any match is found, -even if an error was detected. -Also see the -.B \-s -or -.B \-\^\-no-messages -option. -.TP -.BR \-R ", " \-r ", " \-\^\-recursive -Read all files under each directory, recursively; -this is equivalent to the -.B "\-d recurse" -option. -.TP -.BR "\fR \fP \-\^\-include=" PATTERN -Recurse in directories only searching file matching -.I PATTERN. -.TP -.BR "\fR \fP \-\^\-exclude=" PATTERN -Recurse in directories skip file matching -.I PATTERN. -.TP -.BR \-s ", " \-\^\-no-messages -Suppress error messages about nonexistent or unreadable files. -Portability note: unlike \s-1GNU\s0 -.BR grep , -traditional -.B grep -did not conform to \s-1POSIX.2\s0, because traditional -.B grep -lacked a -.B \-q -option and its -.B \-s -option behaved like \s-1GNU\s0 -.BR grep 's -.B \-q -option. -Shell scripts intended to be portable to traditional -.B grep -should avoid both -.B \-q -and -.B \-s -and should redirect output to /dev/null instead. -.TP -.BR \-U ", " \-\^\-binary -Treat the file(s) as binary. By default, under MS-DOS and MS-Windows, -.BR grep -guesses the file type by looking at the contents of the first 32KB -read from the file. If -.BR grep -decides the file is a text file, it strips the CR characters from the -original file contents (to make regular expressions with -.B ^ -and -.B $ -work correctly). Specifying -.B \-U -overrules this guesswork, causing all files to be read and passed to the -matching mechanism verbatim; if the file is a text file with CR/LF -pairs at the end of each line, this will cause some regular -expressions to fail. -This option has no effect on platforms other than MS-DOS and -MS-Windows. -.TP -.BR \-u ", " \-\^\-unix-byte-offsets -Report Unix-style byte offsets. This switch causes -.B grep -to report byte offsets as if the file were Unix-style text file, i.e. with -CR characters stripped off. This will produce results identical to running -.B grep -on a Unix machine. This option has no effect unless -.B \-b -option is also used; -it has no effect on platforms other than MS-DOS and MS-Windows. -.TP -.BR \-V ", " \-\^\-version -Print the version number of -.B grep -to standard error. This version number should -be included in all bug reports (see below). -.TP -.BR \-v ", " \-\^\-invert-match -Invert the sense of matching, to select non-matching lines. -.TP -.BR \-w ", " \-\^\-word-regexp -Select only those lines containing matches that form whole words. -The test is that the matching substring must either be at the -beginning of the line, or preceded by a non-word constituent -character. Similarly, it must be either at the end of the line -or followed by a non-word constituent character. Word-constituent -characters are letters, digits, and the underscore. -.TP -.BR \-x ", " \-\^\-line-regexp -Select only those matches that exactly match the whole line. -.TP -.B \-y -Obsolete synonym for -.BR \-i . -.TP -.B \-\^\-null -Output a zero byte (the \s-1ASCII\s0 -.B NUL -character) instead of the character that normally follows a file name. -For example, -.B "grep \-l \-\^\-null" -outputs a zero byte after each file name instead of the usual newline. -This option makes the output unambiguous, even in the presence of file -names containing unusual characters like newlines. This option can be -used with commands like -.BR "find \-print0" , -.BR "perl \-0" , -.BR "sort \-z" , -and -.B "xargs \-0" -to process arbitrary file names, -even those that contain newline characters. -.TP -.BR \-Z ", " \-\^\-decompress -Decompress the input data before searching. -This option is only available if compiled with -.BR zlib (3) -library. -.TP -.BR \-J ", " \-\^\-bz2decompress -Decompress the -.BR bzip2 (1) -compressed input data before searching. -.SH "REGULAR EXPRESSIONS" -A regular expression is a pattern that describes a set of strings. -Regular expressions are constructed analogously to arithmetic -expressions, by using various operators to combine smaller expressions. -.PP -.B grep -understands two different versions of regular expression syntax: -\*(lqbasic\*(rq and \*(lqextended.\*(rq In -.RB "\s-1GNU\s0\ " grep , -there is no difference in available functionality using either syntax. -In other implementations, basic regular expressions are less powerful. -The following description applies to extended regular expressions; -differences for basic regular expressions are summarized afterwards. -.PP -The fundamental building blocks are the regular expressions that match -a single character. Most characters, including all letters and digits, -are regular expressions that match themselves. Any metacharacter with -special meaning may be quoted by preceding it with a backslash. -.PP -A -.I "bracket expression" -is a list of characters enclosed by -.B [ -and -.BR ] . -It matches any single -character in that list; if the first character of the list -is the caret -.B ^ -then it matches any character -.I not -in the list. -For example, the regular expression -.B [0123456789] -matches any single digit. -.PP -Within a bracket expression, a -.I "range expression" -consists of two characters separated by a hyphen. -It matches any single character that sorts between the two characters, -inclusive, using the locale's collating sequence and character set. -For example, in the default C locale, -.B [a\-d] -is equivalent to -.BR [abcd] . -Many locales sort characters in dictionary order, and in these locales -.B [a\-d] -is typically not equivalent to -.BR [abcd] ; -it might be equivalent to -.BR [aBbCcDd] , -for example. -To obtain the traditional interpretation of bracket expressions, -you can use the C locale by setting the -.B LC_ALL -environment variable to the value -.BR C . -.PP -Finally, certain named classes of characters are predefined within -bracket expressions, as follows. -Their names are self explanatory, and they are -.BR [:alnum:] , -.BR [:alpha:] , -.BR [:blank:] , -.BR [:cntrl:] , -.BR [:digit:] , -.BR [:graph:] , -.BR [:lower:] , -.BR [:print:] , -.BR [:punct:] , -.BR [:space:] , -.BR [:upper:] , -and -.BR [:xdigit:]. -For example, -.B [[:alnum:]] -means -.BR [0\-9A\-Za\-z] , -except the latter form depends upon the C locale and the -\s-1ASCII\s0 character encoding, whereas the former is independent -of locale and character set. -(Note that the brackets in these class names are part of the symbolic -names, and must be included in addition to the brackets delimiting -the bracket list.) Most metacharacters lose their special meaning -inside lists. To include a literal -.B ] -place it first in the list. Similarly, to include a literal -.B ^ -place it anywhere but first. Finally, to include a literal -.B \- -place it last. -.PP -The period -.B . -matches any single character. -The symbol -.B \ew -is a synonym for -.B [[:alnum:]] -and -.B \eW -is a synonym for -.BR [^[:alnum:]] . -.PP -The caret -.B ^ -and the dollar sign -.B $ -are metacharacters that respectively match the empty string at the -beginning and end of a line. -The symbols -.B \e< -and -.B \e> -respectively match the empty string at the beginning and end of a word. -The symbol -.B \eb -matches the empty string at the edge of a word, -and -.B \eB -matches the empty string provided it's -.I not -at the edge of a word. -.PP -A regular expression may be followed by one of several repetition operators: -.PD 0 -.TP -.B ? -The preceding item is optional and matched at most once. -.TP -.B * -The preceding item will be matched zero or more times. -.TP -.B + -The preceding item will be matched one or more times. -.TP -.BI { n } -The preceding item is matched exactly -.I n -times. -.TP -.BI { n ,} -The preceding item is matched -.I n -or more times. -.TP -.BI { n , m } -The preceding item is matched at least -.I n -times, but not more than -.I m -times. -.PD -.PP -Two regular expressions may be concatenated; the resulting -regular expression matches any string formed by concatenating -two substrings that respectively match the concatenated -subexpressions. -.PP -Two regular expressions may be joined by the infix operator -.BR | ; -the resulting regular expression matches any string matching -either subexpression. -.PP -Repetition takes precedence over concatenation, which in turn -takes precedence over alternation. A whole subexpression may be -enclosed in parentheses to override these precedence rules. -.PP -The backreference -.BI \e n\c -\&, where -.I n -is a single digit, matches the substring -previously matched by the -.IR n th -parenthesized subexpression of the regular expression. -.PP -In basic regular expressions the metacharacters -.BR ? , -.BR + , -.BR { , -.BR | , -.BR ( , -and -.BR ) -lose their special meaning; instead use the backslashed -versions -.BR \e? , -.BR \e+ , -.BR \e{ , -.BR \e| , -.BR \e( , -and -.BR \e) . -.PP -Traditional -.B egrep -did not support the -.B { -metacharacter, and some -.B egrep -implementations support -.B \e{ -instead, so portable scripts should avoid -.B { -in -.B egrep -patterns and should use -.B [{] -to match a literal -.BR { . -.PP -\s-1GNU\s0 -.B egrep -attempts to support traditional usage by assuming that -.B { -is not special if it would be the start of an invalid interval -specification. For example, the shell command -.B "egrep '{1'" -searches for the two-character string -.B {1 -instead of reporting a syntax error in the regular expression. -\s-1POSIX.2\s0 allows this behavior as an extension, but portable scripts -should avoid it. -.SH "ENVIRONMENT VARIABLES" -Grep's behavior is affected by the following environment variables. -.PP -A locale -.BI LC_ foo -is specified by examining the three environment variables -.BR LC_ALL , -.BR LC_\fIfoo\fP , -.BR LANG , -in that order. -The first of these variables that is set specifies the locale. -For example, if -.B LC_ALL -is not set, but -.B LC_MESSAGES -is set to -.BR pt_BR , -then Brazilian Portuguese is used for the -.B LC_MESSAGES -locale. -The C locale is used if none of these environment variables are set, -or if the locale catalog is not installed, or if -.B grep -was not compiled with national language support (\s-1NLS\s0). -.TP -.B GREP_OPTIONS -This variable specifies default options to be placed in front of any -explicit options. For example, if -.B GREP_OPTIONS -is -.BR "'\-\^\-binary-files=without-match \-\^\-directories=skip'" , -.B grep -behaves as if the two options -.B \-\^\-binary-files=without-match -and -.B \-\^\-directories=skip -had been specified before any explicit options. -Option specifications are separated by whitespace. -A backslash escapes the next character, -so it can be used to specify an option containing whitespace or a backslash. -.TP -.B GREP_COLOR -Specifies the marker for highlighting. -.TP -\fBLC_ALL\fP, \fBLC_COLLATE\fP, \fBLANG\fP -These variables specify the -.B LC_COLLATE -locale, which determines the collating sequence used to interpret -range expressions like -.BR [a\-z] . -.TP -\fBLC_ALL\fP, \fBLC_CTYPE\fP, \fBLANG\fP -These variables specify the -.B LC_CTYPE -locale, which determines the type of characters, e.g., which -characters are whitespace. -.TP -\fBLC_ALL\fP, \fBLC_MESSAGES\fP, \fBLANG\fP -These variables specify the -.B LC_MESSAGES -locale, which determines the language that -.B grep -uses for messages. -The default C locale uses American English messages. -.TP -.B POSIXLY_CORRECT -If set, -.B grep -behaves as \s-1POSIX.2\s0 requires; otherwise, -.B grep -behaves more like other \s-1GNU\s0 programs. -\s-1POSIX.2\s0 requires that options that follow file names must be -treated as file names; by default, such options are permuted to the -front of the operand list and are treated as options. -Also, \s-1POSIX.2\s0 requires that unrecognized options be diagnosed as -\*(lqillegal\*(rq, but since they are not really against the law the default -is to diagnose them as \*(lqinvalid\*(rq. -.SH DIAGNOSTICS -.PP -Normally, exit status is 0 if selected lines are found and 1 otherwise. -But the exit status is 2 if an error occurred, unless the -.B \-q -or -.B \-\^\-quiet -or -.B \-\^\-silent -option is used and a selected line is found. -.SH BUGS -Email bug reports to -.BR bug-gnu-utils@gnu.org . -Be sure to include the word \*(lqgrep\*(rq somewhere in the -\*(lqSubject:\*(rq field. -.PP -Large repetition counts in the -.BI { n , m } -construct may cause grep to use lots of memory. -In addition, -certain other obscure regular expressions require exponential time -and space, and may cause -.B grep -to run out of memory. -.PP -Backreferences are very slow, and may require exponential time. -.\" Work around problems with some troff -man implementations. -.br diff --git a/gnu/usr.bin/grep/grep.c b/gnu/usr.bin/grep/grep.c deleted file mode 100644 index a377c594413..00000000000 --- a/gnu/usr.bin/grep/grep.c +++ /dev/null @@ -1,1867 +0,0 @@ -/* grep.c - main driver file for grep. - Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* Written July 1992 by Mike Haertel. */ -/* Builtin decompression 1997 by Wolfram Schneider . */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/grep.c 254093 2013-08-08 11:53:47Z ache $ */ - -#ifdef HAVE_CONFIG_H -# include -#endif -#include -#include -#if defined(HAVE_MMAP) -# include -#endif -#if defined(HAVE_SETRLIMIT) -# include -# include -#endif -#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC -/* We can handle multibyte string. */ -# define MBS_SUPPORT -# include -# include -#endif -#include -#include "system.h" -#include "getopt.h" -#include "getpagesize.h" -#include "grep.h" -#include "savedir.h" -#include "xstrtol.h" -#include "xalloc.h" -#include "error.h" -#include "exclude.h" -#include "closeout.h" - -#undef MAX -#define MAX(A,B) ((A) > (B) ? (A) : (B)) - -struct stats -{ - struct stats const *parent; - struct stat stat; -}; - -/* base of chain of stat buffers, used to detect directory loops */ -static struct stats stats_base; - -/* if non-zero, display usage information and exit */ -static int show_help; - -/* If non-zero, print the version on standard output and exit. */ -static int show_version; - -/* If nonzero, suppress diagnostics for nonexistent or unreadable files. */ -static int suppress_errors; - -/* If nonzero, use mmap if possible. */ -static int mmap_option; - -/* If zero, output nulls after filenames. */ -static int filename_mask; - -/* If nonzero, use grep_color marker. */ -static int color_option; - -/* If nonzero, show only the part of a line matching the expression. */ -static int only_matching; - -/* The color string used. The user can overwrite it using the environment - variable GREP_COLOR. The default is to print red. */ -static const char *grep_color = "01;31"; - -static struct exclude *excluded_patterns; -static struct exclude *included_patterns; -/* Short options. */ -static char const short_options[] = -"0123456789A:B:C:D:EFGHIJPUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz"; - -/* Non-boolean long options that have no corresponding short equivalents. */ -enum -{ - BINARY_FILES_OPTION = CHAR_MAX + 1, - COLOR_OPTION, - INCLUDE_OPTION, - EXCLUDE_OPTION, - EXCLUDE_FROM_OPTION, - LINE_BUFFERED_OPTION, - LABEL_OPTION -}; - -/* Long options equivalences. */ -static struct option const long_options[] = -{ - {"after-context", required_argument, NULL, 'A'}, - {"basic-regexp", no_argument, NULL, 'G'}, - {"before-context", required_argument, NULL, 'B'}, - {"binary-files", required_argument, NULL, BINARY_FILES_OPTION}, - {"byte-offset", no_argument, NULL, 'b'}, - {"context", required_argument, NULL, 'C'}, - {"color", optional_argument, NULL, COLOR_OPTION}, - {"colour", optional_argument, NULL, COLOR_OPTION}, - {"count", no_argument, NULL, 'c'}, - {"devices", required_argument, NULL, 'D'}, - {"directories", required_argument, NULL, 'd'}, - {"extended-regexp", no_argument, NULL, 'E'}, - {"exclude", required_argument, NULL, EXCLUDE_OPTION}, - {"exclude-from", required_argument, NULL, EXCLUDE_FROM_OPTION}, - {"file", required_argument, NULL, 'f'}, - {"files-with-matches", no_argument, NULL, 'l'}, - {"files-without-match", no_argument, NULL, 'L'}, - {"fixed-regexp", no_argument, NULL, 'F'}, - {"fixed-strings", no_argument, NULL, 'F'}, - {"help", no_argument, &show_help, 1}, - {"include", required_argument, NULL, INCLUDE_OPTION}, - {"ignore-case", no_argument, NULL, 'i'}, - {"label", required_argument, NULL, LABEL_OPTION}, - {"line-buffered", no_argument, NULL, LINE_BUFFERED_OPTION}, - {"line-number", no_argument, NULL, 'n'}, - {"line-regexp", no_argument, NULL, 'x'}, - {"max-count", required_argument, NULL, 'm'}, - {"mmap", no_argument, &mmap_option, 1}, - {"no-filename", no_argument, NULL, 'h'}, - {"no-messages", no_argument, NULL, 's'}, - {"bz2decompress", no_argument, NULL, 'J'}, -#if HAVE_LIBZ > 0 - {"decompress", no_argument, NULL, 'Z'}, - {"null", no_argument, &filename_mask, 0}, -#else - {"null", no_argument, NULL, 'Z'}, -#endif - {"null-data", no_argument, NULL, 'z'}, - {"only-matching", no_argument, NULL, 'o'}, - {"perl-regexp", no_argument, NULL, 'P'}, - {"quiet", no_argument, NULL, 'q'}, - {"recursive", no_argument, NULL, 'r'}, - {"recursive", no_argument, NULL, 'R'}, - {"regexp", required_argument, NULL, 'e'}, - {"invert-match", no_argument, NULL, 'v'}, - {"silent", no_argument, NULL, 'q'}, - {"text", no_argument, NULL, 'a'}, - {"binary", no_argument, NULL, 'U'}, - {"unix-byte-offsets", no_argument, NULL, 'u'}, - {"version", no_argument, NULL, 'V'}, - {"with-filename", no_argument, NULL, 'H'}, - {"word-regexp", no_argument, NULL, 'w'}, - {0, 0, 0, 0} -}; - -/* Define flags declared in grep.h. */ -int match_icase; -int match_words; -int match_lines; -unsigned char eolbyte; - -/* For error messages. */ -/* The name the program was run with, stripped of any leading path. */ -char *program_name; -static char const *filename; -static int errseen; - -/* How to handle directories. */ -static enum - { - READ_DIRECTORIES, - RECURSE_DIRECTORIES, - SKIP_DIRECTORIES - } directories = READ_DIRECTORIES; - -/* How to handle devices. */ -static enum - { - READ_DEVICES, - SKIP_DEVICES - } devices = READ_DEVICES; - -static int grepdir PARAMS ((char const *, struct stats const *)); -#if defined(HAVE_DOS_FILE_CONTENTS) -static inline int undossify_input PARAMS ((register char *, size_t)); -#endif - -/* Functions we'll use to search. */ -static void (*compile) PARAMS ((char const *, size_t)); -static size_t (*execute) PARAMS ((char const *, size_t, size_t *, int)); - -/* Like error, but suppress the diagnostic if requested. */ -static void -suppressible_error (char const *mesg, int errnum) -{ - if (! suppress_errors) - error (0, errnum, "%s", mesg); - errseen = 1; -} - -/* Convert STR to a positive integer, storing the result in *OUT. - STR must be a valid context length argument; report an error if it - isn't. */ -static void -context_length_arg (char const *str, int *out) -{ - uintmax_t value; - if (! (xstrtoumax (str, 0, 10, &value, "") == LONGINT_OK - && 0 <= (*out = value) - && *out == value)) - { - error (2, 0, "%s: %s\n", str, _("invalid context length argument")); - } -} - - -/* Hairy buffering mechanism for grep. The intent is to keep - all reads aligned on a page boundary and multiples of the - page size, unless a read yields a partial page. */ - -static char *buffer; /* Base of buffer. */ -static size_t bufalloc; /* Allocated buffer size, counting slop. */ -#define INITIAL_BUFSIZE 32768 /* Initial buffer size, not counting slop. */ -static int bufdesc; /* File descriptor. */ -static char *bufbeg; /* Beginning of user-visible stuff. */ -static char *buflim; /* Limit of user-visible stuff. */ -static size_t pagesize; /* alignment of memory pages */ -static off_t bufoffset; /* Read offset; defined on regular files. */ -static off_t after_last_match; /* Pointer after last matching line that - would have been output if we were - outputting characters. */ - -#if defined(HAVE_MMAP) -static int bufmapped; /* True if buffer is memory-mapped. */ -static off_t initial_bufoffset; /* Initial value of bufoffset. */ -#else -# define bufmapped 0 -#endif - -#include -static BZFILE* bzbufdesc; /* libbz2 file handle. */ -static int BZflag; /* uncompress before searching. */ -#if HAVE_LIBZ > 0 -#include -static gzFile gzbufdesc; /* zlib file descriptor. */ -static int Zflag; /* uncompress before searching. */ -#endif - -/* Return VAL aligned to the next multiple of ALIGNMENT. VAL can be - an integer or a pointer. Both args must be free of side effects. */ -#define ALIGN_TO(val, alignment) \ - ((size_t) (val) % (alignment) == 0 \ - ? (val) \ - : (val) + ((alignment) - (size_t) (val) % (alignment))) - -/* Reset the buffer for a new file, returning zero if we should skip it. - Initialize on the first time through. */ -static int -reset (int fd, char const *file, struct stats *stats) -{ - if (! pagesize) - { - pagesize = getpagesize (); - if (pagesize == 0 || 2 * pagesize + 1 <= pagesize) - abort (); - bufalloc = ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + 1; - buffer = xmalloc (bufalloc); - } - if (BZflag) - { - bzbufdesc = BZ2_bzdopen(fd, "r"); - if (bzbufdesc == NULL) - error(2, 0, _("memory exhausted")); - } -#if HAVE_LIBZ > 0 - if (Zflag) - { - gzbufdesc = gzdopen(fd, "r"); - if (gzbufdesc == NULL) - error(2, 0, _("memory exhausted")); - } -#endif - - bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize); - bufbeg[-1] = eolbyte; - bufdesc = fd; - - if (fstat (fd, &stats->stat) != 0) - { - error (0, errno, "fstat"); - return 0; - } - if (fd != STDIN_FILENO) { - if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) - return 0; -#ifndef DJGPP - if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode))) -#else - if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode))) -#endif - return 0; - } - if ( - BZflag || -#if HAVE_LIBZ > 0 - Zflag || -#endif - S_ISREG (stats->stat.st_mode)) - { - if (file) - bufoffset = 0; - else - { - bufoffset = lseek (fd, 0, SEEK_CUR); - if (bufoffset < 0) - { - error (0, errno, "lseek"); - return 0; - } - } -#if defined(HAVE_MMAP) - initial_bufoffset = bufoffset; - bufmapped = mmap_option && bufoffset % pagesize == 0; -#endif - } - else - { -#if defined(HAVE_MMAP) - bufmapped = 0; -#endif - } - return 1; -} - -/* Read new stuff into the buffer, saving the specified - amount of old stuff. When we're done, 'bufbeg' points - to the beginning of the buffer contents, and 'buflim' - points just after the end. Return zero if there's an error. */ -static int -fillbuf (size_t save, struct stats const *stats) -{ - size_t fillsize = 0; - int cc = 1; - char *readbuf; - size_t readsize; - - /* Offset from start of buffer to start of old stuff - that we want to save. */ - size_t saved_offset = buflim - save - buffer; - - if (pagesize <= buffer + bufalloc - buflim) - { - readbuf = buflim; - bufbeg = buflim - save; - } - else - { - size_t minsize = save + pagesize; - size_t newsize; - size_t newalloc; - char *newbuf; - - /* Grow newsize until it is at least as great as minsize. */ - for (newsize = bufalloc - pagesize - 1; newsize < minsize; newsize *= 2) - if (newsize * 2 < newsize || newsize * 2 + pagesize + 1 < newsize * 2) - xalloc_die (); - - /* Try not to allocate more memory than the file size indicates, - as that might cause unnecessary memory exhaustion if the file - is large. However, do not use the original file size as a - heuristic if we've already read past the file end, as most - likely the file is growing. */ - if (S_ISREG (stats->stat.st_mode)) - { - off_t to_be_read = stats->stat.st_size - bufoffset; - off_t maxsize_off = save + to_be_read; - if (0 <= to_be_read && to_be_read <= maxsize_off - && maxsize_off == (size_t) maxsize_off - && minsize <= (size_t) maxsize_off - && (size_t) maxsize_off < newsize) - newsize = maxsize_off; - } - - /* Add enough room so that the buffer is aligned and has room - for byte sentinels fore and aft. */ - newalloc = newsize + pagesize + 1; - - newbuf = bufalloc < newalloc ? xmalloc (bufalloc = newalloc) : buffer; - readbuf = ALIGN_TO (newbuf + 1 + save, pagesize); - bufbeg = readbuf - save; - memmove (bufbeg, buffer + saved_offset, save); - bufbeg[-1] = eolbyte; - if (newbuf != buffer) - { - free (buffer); - buffer = newbuf; - } - } - - readsize = buffer + bufalloc - readbuf; - readsize -= readsize % pagesize; - -#if defined(HAVE_MMAP) - if (bufmapped) - { - size_t mmapsize = readsize; - - /* Don't mmap past the end of the file; some hosts don't allow this. - Use `read' on the last page. */ - if (stats->stat.st_size - bufoffset < mmapsize) - { - mmapsize = stats->stat.st_size - bufoffset; - mmapsize -= mmapsize % pagesize; - } - - if (mmapsize - && (mmap ((caddr_t) readbuf, mmapsize, - PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, - bufdesc, bufoffset) - != (caddr_t) -1)) - { - /* Do not bother to use madvise with MADV_SEQUENTIAL or - MADV_WILLNEED on the mmapped memory. One might think it - would help, but it slows us down about 30% on SunOS 4.1. */ - fillsize = mmapsize; - } - else - { - /* Stop using mmap on this file. Synchronize the file - offset. Do not warn about mmap failures. On some hosts - (e.g. Solaris 2.5) mmap can fail merely because some - other process has an advisory read lock on the file. - There's no point alarming the user about this misfeature. */ - bufmapped = 0; - if (bufoffset != initial_bufoffset - && lseek (bufdesc, bufoffset, SEEK_SET) < 0) - { - error (0, errno, "lseek"); - cc = 0; - } - } - } -#endif /*HAVE_MMAP*/ - - if (! fillsize) - { - ssize_t bytesread; - do - if (BZflag && bzbufdesc) - { - int bzerr; - bytesread = BZ2_bzRead (&bzerr, bzbufdesc, readbuf, readsize); - - switch (bzerr) - { - case BZ_OK: - case BZ_STREAM_END: - /* ok */ - break; - case BZ_DATA_ERROR_MAGIC: - BZ2_bzReadClose (&bzerr, bzbufdesc); bzbufdesc = NULL; - lseek (bufdesc, 0, SEEK_SET); - bytesread = read (bufdesc, readbuf, readsize); - break; - default: - bytesread = 0; - break; - } - } - else -#if HAVE_LIBZ > 0 - if (Zflag) - bytesread = gzread (gzbufdesc, readbuf, readsize); - else -#endif - bytesread = read (bufdesc, readbuf, readsize); - while (bytesread < 0 && errno == EINTR); - if (bytesread < 0) - cc = 0; - else - fillsize = bytesread; - } - - bufoffset += fillsize; -#if defined(HAVE_DOS_FILE_CONTENTS) - if (fillsize) - fillsize = undossify_input (readbuf, fillsize); -#endif - buflim = readbuf + fillsize; - return cc; -} - -/* Flags controlling the style of output. */ -static enum -{ - BINARY_BINARY_FILES, - TEXT_BINARY_FILES, - WITHOUT_MATCH_BINARY_FILES -} binary_files; /* How to handle binary files. */ - -static int filename_mask; /* If zero, output nulls after filenames. */ -static int out_quiet; /* Suppress all normal output. */ -static int out_invert; /* Print nonmatching stuff. */ -static int out_file; /* Print filenames. */ -static int out_line; /* Print line numbers. */ -static int out_byte; /* Print byte offsets. */ -static int out_before; /* Lines of leading context. */ -static int out_after; /* Lines of trailing context. */ -static int count_matches; /* Count matching lines. */ -static int list_files; /* List matching files. */ -static int no_filenames; /* Suppress file names. */ -static off_t max_count; /* Stop after outputting this many - lines from an input file. */ -static int line_buffered; /* If nonzero, use line buffering, i.e. - fflush everyline out. */ -static char *label = NULL; /* Fake filename for stdin */ - - -/* Internal variables to keep track of byte count, context, etc. */ -static uintmax_t totalcc; /* Total character count before bufbeg. */ -static char const *lastnl; /* Pointer after last newline counted. */ -static char const *lastout; /* Pointer after last character output; - NULL if no character has been output - or if it's conceptually before bufbeg. */ -static uintmax_t totalnl; /* Total newline count before lastnl. */ -static off_t outleft; /* Maximum number of lines to be output. */ -static int pending; /* Pending lines of output. - Always kept 0 if out_quiet is true. */ -static int done_on_match; /* Stop scanning file on first match. */ -static int exit_on_match; /* Exit on first match. */ - -#if defined(HAVE_DOS_FILE_CONTENTS) -# include "dosbuf.c" -#endif - -/* Add two numbers that count input bytes or lines, and report an - error if the addition overflows. */ -static uintmax_t -add_count (uintmax_t a, uintmax_t b) -{ - uintmax_t sum = a + b; - if (sum < a) - error (2, 0, _("input is too large to count")); - return sum; -} - -static void -nlscan (char const *lim) -{ - size_t newlines = 0; - char const *beg; - for (beg = lastnl; beg != lim; beg = memchr (beg, eolbyte, lim - beg), beg++) - newlines++; - totalnl = add_count (totalnl, newlines); - lastnl = lim; -} - -/* Print a byte offset, followed by a character separator. */ -static void -print_offset_sep (uintmax_t pos, char sep) -{ - /* Do not rely on printf to print pos, since uintmax_t may be longer - than long, and long long is not portable. */ - - char buf[sizeof pos * CHAR_BIT]; - char *p = buf + sizeof buf - 1; - *p = sep; - - do - *--p = '0' + pos % 10; - while ((pos /= 10) != 0); - - fwrite (p, 1, buf + sizeof buf - p, stdout); -} - -static void -prline (char const *beg, char const *lim, int sep) -{ - if (out_file) - printf ("%s%c", filename, sep & filename_mask); - if (out_line) - { - nlscan (beg); - totalnl = add_count (totalnl, 1); - print_offset_sep (totalnl, sep); - lastnl = lim; - } - if (out_byte) - { - uintmax_t pos = add_count (totalcc, beg - bufbeg); -#if defined(HAVE_DOS_FILE_CONTENTS) - pos = dossified_pos (pos); -#endif - print_offset_sep (pos, sep); - } - if (only_matching) - { - size_t match_size; - size_t match_offset; - while ((match_offset = (*execute) (beg, lim - beg, &match_size, 1)) - != (size_t) -1) - { - char const *b = beg + match_offset; - if (b == lim) - break; - if (match_size == 0) - break; - if(color_option) - printf("\33[%sm", grep_color); - fwrite(b, sizeof (char), match_size, stdout); - if(color_option) - fputs("\33[00m", stdout); - fputs("\n", stdout); - beg = b + match_size; - } - lastout = lim; - if(line_buffered) - fflush(stdout); - return; - } - if (color_option) - { - size_t match_size; - size_t match_offset; - while (lim-beg && (match_offset = (*execute) (beg, lim - beg, &match_size, 1)) - != (size_t) -1) - { - char const *b = beg + match_offset; - /* Avoid matching the empty line at the end of the buffer. */ - if (b == lim) - break; - /* Avoid hanging on grep --color "" foo */ - if (match_size == 0) - break; - fwrite (beg, sizeof (char), match_offset, stdout); - printf ("\33[%sm", grep_color); - fwrite (b, sizeof (char), match_size, stdout); - fputs ("\33[00m", stdout); - beg = b + match_size; - } - fputs ("\33[K", stdout); - } - fwrite (beg, 1, lim - beg, stdout); - if (ferror (stdout)) - error (0, errno, _("writing output")); - lastout = lim; - if (line_buffered) - fflush (stdout); -} - -/* Print pending lines of trailing context prior to LIM. Trailing context ends - at the next matching line when OUTLEFT is 0. */ -static void -prpending (char const *lim) -{ - if (!lastout) - lastout = bufbeg; - while (pending > 0 && lastout < lim) - { - char const *nl = memchr (lastout, eolbyte, lim - lastout); - size_t match_size; - --pending; - if (outleft - || (((*execute) (lastout, nl - lastout, &match_size, 0) == (size_t) -1) - == !out_invert)) - prline (lastout, nl + 1, '-'); - else - pending = 0; - } -} - -/* Print the lines between BEG and LIM. Deal with context crap. - If NLINESP is non-null, store a count of lines between BEG and LIM. */ -static void -prtext (char const *beg, char const *lim, int *nlinesp) -{ - static int used; /* avoid printing "--" before any output */ - char const *bp, *p; - char eol = eolbyte; - int i, n; - - if (!out_quiet && pending > 0) - prpending (beg); - - p = beg; - - if (!out_quiet) - { - /* Deal with leading context crap. */ - - bp = lastout ? lastout : bufbeg; - for (i = 0; i < out_before; ++i) - if (p > bp) - do - --p; - while (p[-1] != eol); - - /* We only print the "--" separator if our output is - discontiguous from the last output in the file. */ - if ((out_before || out_after) && used && p != lastout) - puts ("--"); - - while (p < beg) - { - char const *nl = memchr (p, eol, beg - p); - nl++; - prline (p, nl, '-'); - p = nl; - } - } - - if (nlinesp) - { - /* Caller wants a line count. */ - for (n = 0; p < lim && n < outleft; n++) - { - char const *nl = memchr (p, eol, lim - p); - nl++; - if (!out_quiet) - prline (p, nl, ':'); - p = nl; - } - *nlinesp = n; - - /* relying on it that this function is never called when outleft = 0. */ - after_last_match = bufoffset - (buflim - p); - } - else - if (!out_quiet) - prline (beg, lim, ':'); - - pending = out_quiet ? 0 : out_after; - used = 1; -} - -/* Scan the specified portion of the buffer, matching lines (or - between matching lines if OUT_INVERT is true). Return a count of - lines printed. */ -static int -grepbuf (char const *beg, char const *lim) -{ - int nlines, n; - register char const *p; - size_t match_offset; - size_t match_size; - - nlines = 0; - p = beg; - while ((match_offset = (*execute) (p, lim - p, &match_size, 0)) != (size_t) -1) - { - char const *b = p + match_offset; - char const *endp = b + match_size; - /* Avoid matching the empty line at the end of the buffer. */ - if (b == lim) - break; - if (!out_invert) - { - prtext (b, endp, (int *) 0); - nlines++; - outleft--; - if (!outleft || done_on_match) - { - if (exit_on_match) - exit (0); - after_last_match = bufoffset - (buflim - endp); - return nlines; - } - } - else if (p < b) - { - prtext (p, b, &n); - nlines += n; - outleft -= n; - if (!outleft) - return nlines; - } - p = endp; - } - if (out_invert && p < lim) - { - prtext (p, lim, &n); - nlines += n; - outleft -= n; - } - return nlines; -} - -/* Search a given file. Normally, return a count of lines printed; - but if the file is a directory and we search it recursively, then - return -2 if there was a match, and -1 otherwise. */ -static int -grep (int fd, char const *file, struct stats *stats) -{ - int nlines, i; - int not_text; - size_t residue, save; - char oldc; - char *beg; - char *lim; - char eol = eolbyte; - - if (!reset (fd, file, stats)) - return 0; - - if (file && directories == RECURSE_DIRECTORIES - && S_ISDIR (stats->stat.st_mode)) - { - /* Close fd now, so that we don't open a lot of file descriptors - when we recurse deeply. */ - if (BZflag && bzbufdesc) - BZ2_bzclose(bzbufdesc); - else -#if HAVE_LIBZ > 0 - if (Zflag) - gzclose(gzbufdesc); - else -#endif - if (close (fd) != 0) - error (0, errno, "%s", file); - return grepdir (file, stats) - 2; - } - - totalcc = 0; - lastout = 0; - totalnl = 0; - outleft = max_count; - after_last_match = 0; - pending = 0; - - nlines = 0; - residue = 0; - save = 0; - - if (! fillbuf (save, stats)) - { - if (! is_EISDIR (errno, file)) - suppressible_error (filename, errno); - return 0; - } - - not_text = (((binary_files == BINARY_BINARY_FILES && !out_quiet) - || binary_files == WITHOUT_MATCH_BINARY_FILES) - && memchr (bufbeg, eol ? '\0' : '\200', buflim - bufbeg)); - if (not_text && binary_files == WITHOUT_MATCH_BINARY_FILES) - return 0; - done_on_match += not_text; - out_quiet += not_text; - - for (;;) - { - lastnl = bufbeg; - if (lastout) - lastout = bufbeg; - - beg = bufbeg + save; - - /* no more data to scan (eof) except for maybe a residue -> break */ - if (beg == buflim) - break; - - /* Determine new residue (the length of an incomplete line at the end of - the buffer, 0 means there is no incomplete last line). */ - oldc = beg[-1]; - beg[-1] = eol; - for (lim = buflim; lim[-1] != eol; lim--) - continue; - beg[-1] = oldc; - if (lim == beg) - lim = beg - residue; - beg -= residue; - residue = buflim - lim; - - if (beg < lim) - { - if (outleft) - nlines += grepbuf (beg, lim); - if (pending) - prpending (lim); - if((!outleft && !pending) || (nlines && done_on_match && !out_invert)) - goto finish_grep; - } - - /* The last OUT_BEFORE lines at the end of the buffer will be needed as - leading context if there is a matching line at the begin of the - next data. Make beg point to their begin. */ - i = 0; - beg = lim; - while (i < out_before && beg > bufbeg && beg != lastout) - { - ++i; - do - --beg; - while (beg[-1] != eol); - } - - /* detect if leading context is discontinuous from last printed line. */ - if (beg != lastout) - lastout = 0; - - /* Handle some details and read more data to scan. */ - save = residue + lim - beg; - if (out_byte) - totalcc = add_count (totalcc, buflim - bufbeg - save); - if (out_line) - nlscan (beg); - if (! fillbuf (save, stats)) - { - if (! is_EISDIR (errno, file)) - suppressible_error (filename, errno); - goto finish_grep; - } - } - if (residue) - { - *buflim++ = eol; - if (outleft) - nlines += grepbuf (bufbeg + save - residue, buflim); - if (pending) - prpending (buflim); - } - - finish_grep: - done_on_match -= not_text; - out_quiet -= not_text; - if ((not_text & ~out_quiet) && nlines != 0) - printf (_("Binary file %s matches\n"), filename); - return nlines; -} - -static int -grepfile (char const *file, struct stats *stats) -{ - int desc; - int count; - int status; - int flags; - - if (! file) - { - desc = 0; - filename = label ? label : _("(standard input)"); - } - else - { - while ((desc = open (file, O_RDONLY | O_NONBLOCK)) < 0 && errno == EINTR) - continue; - - if (desc < 0) - { - int e = errno; - - if (is_EISDIR (e, file) && directories == RECURSE_DIRECTORIES) - { - if (stat (file, &stats->stat) != 0) - { - error (0, errno, "%s", file); - return 1; - } - - return grepdir (file, stats); - } - - if (!suppress_errors) - { - if (directories == SKIP_DIRECTORIES) - switch (e) - { -#if defined(EISDIR) - case EISDIR: - return 1; -#endif - case EACCES: - /* When skipping directories, don't worry about - directories that can't be opened. */ - if (isdir (file)) - return 1; - break; - } - } - - suppressible_error (file, e); - return 1; - } - - flags = fcntl(desc, F_GETFL); - flags &= ~O_NONBLOCK; - fcntl(desc, F_SETFL, flags); - filename = file; - } - -#if defined(SET_BINARY) - /* Set input to binary mode. Pipes are simulated with files - on DOS, so this includes the case of "foo | grep bar". */ - if (!isatty (desc)) - SET_BINARY (desc); -#endif - - count = grep (desc, file, stats); - if (count < 0) - status = count + 2; - else - { - if (count_matches) - { - if (out_file) - printf ("%s%c", filename, ':' & filename_mask); - printf ("%d\n", count); - } - - status = !count; - if (list_files == 1 - 2 * status) - printf ("%s%c", filename, '\n' & filename_mask); - - if (BZflag && bzbufdesc) - BZ2_bzclose(bzbufdesc); - else -#if HAVE_LIBZ > 0 - if (Zflag) - gzclose(gzbufdesc); - else -#endif - if (! file) - { - off_t required_offset = outleft ? bufoffset : after_last_match; - if ((bufmapped || required_offset != bufoffset) - && lseek (desc, required_offset, SEEK_SET) < 0 - && S_ISREG (stats->stat.st_mode)) - error (0, errno, "%s", filename); - } - else - while (close (desc) != 0) - if (errno != EINTR) - { - error (0, errno, "%s", file); - break; - } - } - - return status; -} - -static int -grepdir (char const *dir, struct stats const *stats) -{ - int status = 1; - struct stats const *ancestor; - char *name_space; - - /* Mingw32 does not support st_ino. No known working hosts use zero - for st_ino, so assume that the Mingw32 bug applies if it's zero. */ - if (stats->stat.st_ino) - for (ancestor = stats; (ancestor = ancestor->parent) != 0; ) - if (ancestor->stat.st_ino == stats->stat.st_ino - && ancestor->stat.st_dev == stats->stat.st_dev) - { - if (!suppress_errors) - error (0, 0, _("warning: %s: %s"), dir, - _("recursive directory loop")); - return 1; - } - - name_space = savedir (dir, stats->stat.st_size, included_patterns, - excluded_patterns); - - if (! name_space) - { - if (errno) - suppressible_error (dir, errno); - else - xalloc_die (); - } - else - { - size_t dirlen = strlen (dir); - int needs_slash = ! (dirlen == FILESYSTEM_PREFIX_LEN (dir) - || IS_SLASH (dir[dirlen - 1])); - char *file = NULL; - char const *namep = name_space; - struct stats child; - child.parent = stats; - out_file += !no_filenames; - while (*namep) - { - size_t namelen = strlen (namep); - file = xrealloc (file, dirlen + 1 + namelen + 1); - strcpy (file, dir); - file[dirlen] = '/'; - strcpy (file + dirlen + needs_slash, namep); - namep += namelen + 1; - status &= grepfile (file, &child); - } - out_file -= !no_filenames; - if (file) - free (file); - free (name_space); - } - - return status; -} - -static void -usage (int status) -{ - if (status != 0) - { - fprintf (stderr, _("Usage: %s [OPTION]... PATTERN [FILE]...\n"), - program_name); - fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); - } - else - { - printf (_("Usage: %s [OPTION]... PATTERN [FILE] ...\n"), program_name); - printf (_("\ -Search for PATTERN in each FILE or standard input.\n\ -Example: %s -i 'hello world' menu.h main.c\n\ -\n\ -Regexp selection and interpretation:\n"), program_name); - printf (_("\ - -E, --extended-regexp PATTERN is an extended regular expression\n\ - -F, --fixed-strings PATTERN is a set of newline-separated strings\n\ - -G, --basic-regexp PATTERN is a basic regular expression\n\ - -P, --perl-regexp PATTERN is a Perl regular expression\n")); - printf (_("\ - -e, --regexp=PATTERN use PATTERN as a regular expression\n\ - -f, --file=FILE obtain PATTERN from FILE\n\ - -i, --ignore-case ignore case distinctions\n\ - -w, --word-regexp force PATTERN to match only whole words\n\ - -x, --line-regexp force PATTERN to match only whole lines\n\ - -z, --null-data a data line ends in 0 byte, not newline\n")); - printf (_("\ -\n\ -Miscellaneous:\n\ - -s, --no-messages suppress error messages\n\ - -v, --invert-match select non-matching lines\n\ - -V, --version print version information and exit\n\ - --help display this help and exit\n\ - -J, --bz2decompress decompress bzip2'ed input before searching\n\ - -Z, --decompress decompress input before searching (HAVE_LIBZ=1)\n\ - --mmap use memory-mapped input if possible\n")); - printf (_("\ -\n\ -Output control:\n\ - -m, --max-count=NUM stop after NUM matches\n\ - -b, --byte-offset print the byte offset with output lines\n\ - -n, --line-number print line number with output lines\n\ - --line-buffered flush output on every line\n\ - -H, --with-filename print the filename for each match\n\ - -h, --no-filename suppress the prefixing filename on output\n\ - --label=LABEL print LABEL as filename for standard input\n\ - -o, --only-matching show only the part of a line matching PATTERN\n\ - -q, --quiet, --silent suppress all normal output\n\ - --binary-files=TYPE assume that binary files are TYPE\n\ - TYPE is 'binary', 'text', or 'without-match'\n\ - -a, --text equivalent to --binary-files=text\n\ - -I equivalent to --binary-files=without-match\n\ - -d, --directories=ACTION how to handle directories\n\ - ACTION is 'read', 'recurse', or 'skip'\n\ - -D, --devices=ACTION how to handle devices, FIFOs and sockets\n\ - ACTION is 'read' or 'skip'\n\ - -R, -r, --recursive equivalent to --directories=recurse\n\ - --include=PATTERN files that match PATTERN will be examined\n\ - --exclude=PATTERN files that match PATTERN will be skipped.\n\ - --exclude-from=FILE files that match PATTERN in FILE will be skipped.\n\ - -L, --files-without-match only print FILE names containing no match\n\ - -l, --files-with-matches only print FILE names containing matches\n\ - -c, --count only print a count of matching lines per FILE\n\ - --null print 0 byte after FILE name\n")); - printf (_("\ -\n\ -Context control:\n\ - -B, --before-context=NUM print NUM lines of leading context\n\ - -A, --after-context=NUM print NUM lines of trailing context\n\ - -C, --context=NUM print NUM lines of output context\n\ - -NUM same as --context=NUM\n\ - --color[=WHEN],\n\ - --colour[=WHEN] use markers to distinguish the matching string\n\ - WHEN may be `always', `never' or `auto'.\n\ - -U, --binary do not strip CR characters at EOL (MSDOS)\n\ - -u, --unix-byte-offsets report offsets as if CRs were not there (MSDOS)\n\ -\n\ -`egrep' means `grep -E'. `fgrep' means `grep -F'.\n\ -With no FILE, or when FILE is -, read standard input. If less than\n\ -two FILEs given, assume -h. Exit status is 0 if match, 1 if no match,\n\ -and 2 if trouble.\n")); - printf (_("\nReport bugs to .\n")); - } - exit (status); -} - -/* Set the matcher to M, reporting any conflicts. */ -static void -setmatcher (char const *m) -{ - if (matcher && strcmp (matcher, m) != 0) - error (2, 0, _("conflicting matchers specified")); - matcher = m; -} - -/* Go through the matchers vector and look for the specified matcher. - If we find it, install it in compile and execute, and return 1. */ -static int -install_matcher (char const *name) -{ - int i; -#if defined(HAVE_SETRLIMIT) - struct rlimit rlim; -#endif - - for (i = 0; matchers[i].compile; i++) - if (strcmp (name, matchers[i].name) == 0) - { - compile = matchers[i].compile; - execute = matchers[i].execute; -#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) - /* I think every platform needs to do this, so that regex.c - doesn't oveflow the stack. The default value of - `re_max_failures' is too large for some platforms: it needs - more than 3MB-large stack. - - The test for HAVE_SETRLIMIT should go into `configure'. */ - if (!getrlimit (RLIMIT_STACK, &rlim)) - { - long newlim; - extern long int re_max_failures; /* from regex.c */ - - /* Approximate the amount regex.c needs, plus some more. */ - newlim = re_max_failures * 2 * 20 * sizeof (char *); - if (newlim > rlim.rlim_max) - { - newlim = rlim.rlim_max; - re_max_failures = newlim / (2 * 20 * sizeof (char *)); - } - if (rlim.rlim_cur < newlim) - { - rlim.rlim_cur = newlim; - setrlimit (RLIMIT_STACK, &rlim); - } - } -#endif - return 1; - } - return 0; -} - -/* Find the white-space-separated options specified by OPTIONS, and - using BUF to store copies of these options, set ARGV[0], ARGV[1], - etc. to the option copies. Return the number N of options found. - Do not set ARGV[N] to NULL. If ARGV is NULL, do not store ARGV[0] - etc. Backslash can be used to escape whitespace (and backslashes). */ -static int -prepend_args (char const *options, char *buf, char **argv) -{ - char const *o = options; - char *b = buf; - int n = 0; - - for (;;) - { - while (ISSPACE ((unsigned char) *o)) - o++; - if (!*o) - return n; - if (argv) - argv[n] = b; - n++; - - do - if ((*b++ = *o++) == '\\' && *o) - b[-1] = *o++; - while (*o && ! ISSPACE ((unsigned char) *o)); - - *b++ = '\0'; - } -} - -/* Prepend the whitespace-separated options in OPTIONS to the argument - vector of a main program with argument count *PARGC and argument - vector *PARGV. */ -static void -prepend_default_options (char const *options, int *pargc, char ***pargv) -{ - if (options) - { - char *buf = xmalloc (strlen (options) + 1); - int prepended = prepend_args (options, buf, (char **) NULL); - int argc = *pargc; - char * const *argv = *pargv; - char **pp = (char **) xmalloc ((prepended + argc + 1) * sizeof *pp); - *pargc = prepended + argc; - *pargv = pp; - *pp++ = *argv++; - pp += prepend_args (options, buf, pp); - while ((*pp++ = *argv++)) - continue; - } -} - -/* Get the next non-digit option from ARGC and ARGV. - Return -1 if there are no more options. - Process any digit options that were encountered on the way, - and store the resulting integer into *DEFAULT_CONTEXT. */ -static int -get_nondigit_option (int argc, char *const *argv, int *default_context) -{ - int opt; - char buf[sizeof (uintmax_t) * CHAR_BIT + 4]; - char *p = buf; - - /* Set buf[0] to anything but '0', for the leading-zero test below. */ - buf[0] = '\0'; - - while (opt = getopt_long (argc, argv, short_options, long_options, NULL), - '0' <= opt && opt <= '9') - { - /* Suppress trivial leading zeros, to avoid incorrect - diagnostic on strings like 00000000000. */ - p -= buf[0] == '0'; - - *p++ = opt; - if (p == buf + sizeof buf - 4) - { - /* Too many digits. Append "..." to make context_length_arg - complain about "X...", where X contains the digits seen - so far. */ - strcpy (p, "..."); - p += 3; - break; - } - } - if (p != buf) - { - *p = '\0'; - context_length_arg (buf, default_context); - } - - return opt; -} - -int -main (int argc, char **argv) -{ - char *keys; - size_t cc, keycc, oldcc, keyalloc; - int with_filenames; - int opt, status; - int default_context; - FILE *fp; - extern char *optarg; - extern int optind; - - initialize_main (&argc, &argv); - program_name = argv[0]; - if (program_name && strrchr (program_name, '/')) - program_name = strrchr (program_name, '/') + 1; - - if (program_name[0] == 'b' && program_name[1] == 'z') { - BZflag = 1; - program_name += 2; - } -#if HAVE_LIBZ > 0 - else if (program_name[0] == 'z') { - Zflag = 1; - ++program_name; - } -#endif - -#if defined(__MSDOS__) || defined(_WIN32) - /* DOS and MS-Windows use backslashes as directory separators, and usually - have an .exe suffix. They also have case-insensitive filesystems. */ - if (program_name) - { - char *p = program_name; - char *bslash = strrchr (argv[0], '\\'); - - if (bslash && bslash >= program_name) /* for mixed forward/backslash case */ - program_name = bslash + 1; - else if (program_name == argv[0] - && argv[0][0] && argv[0][1] == ':') /* "c:progname" */ - program_name = argv[0] + 2; - - /* Collapse the letter-case, so `strcmp' could be used hence. */ - for ( ; *p; p++) - if (*p >= 'A' && *p <= 'Z') - *p += 'a' - 'A'; - - /* Remove the .exe extension, if any. */ - if ((p = strrchr (program_name, '.')) && strcmp (p, ".exe") == 0) - *p = '\0'; - } -#endif - - keys = NULL; - keycc = 0; - with_filenames = 0; - eolbyte = '\n'; - filename_mask = ~0; - - max_count = TYPE_MAXIMUM (off_t); - - /* The value -1 means to use DEFAULT_CONTEXT. */ - out_after = out_before = -1; - /* Default before/after context: chaged by -C/-NUM options */ - default_context = 0; - /* Changed by -o option */ - only_matching = 0; - - /* Internationalization. */ -#if defined(HAVE_SETLOCALE) - setlocale (LC_ALL, ""); -#endif -#if defined(ENABLE_NLS) - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); -#endif - - atexit (close_stdout); - - prepend_default_options (getenv ("GREP_OPTIONS"), &argc, &argv); - - while ((opt = get_nondigit_option (argc, argv, &default_context)) != -1) - switch (opt) - { - case 'A': - context_length_arg (optarg, &out_after); - break; - - case 'B': - context_length_arg (optarg, &out_before); - break; - - case 'C': - /* Set output match context, but let any explicit leading or - trailing amount specified with -A or -B stand. */ - context_length_arg (optarg, &default_context); - break; - - case 'D': - if (strcmp (optarg, "read") == 0) - devices = READ_DEVICES; - else if (strcmp (optarg, "skip") == 0) - devices = SKIP_DEVICES; - else - error (2, 0, _("unknown devices method")); - break; - - case 'E': - setmatcher ("egrep"); - break; - - case 'F': - setmatcher ("fgrep"); - break; - - case 'P': - setmatcher ("perl"); - break; - - case 'G': - setmatcher ("grep"); - break; - - case 'H': - with_filenames = 1; - break; - - case 'I': - binary_files = WITHOUT_MATCH_BINARY_FILES; - break; - case 'J': - if (Zflag) - { - printf (_("Cannot mix -Z and -J.\n")); - usage (2); - } - BZflag = 1; - break; - - case 'U': -#if defined(HAVE_DOS_FILE_CONTENTS) - dos_use_file_type = DOS_BINARY; -#endif - break; - - case 'u': -#if defined(HAVE_DOS_FILE_CONTENTS) - dos_report_unix_offset = 1; -#endif - break; - - case 'V': - show_version = 1; - break; - - case 'X': - setmatcher (optarg); - break; - - case 'a': - binary_files = TEXT_BINARY_FILES; - break; - - case 'b': - out_byte = 1; - break; - - case 'c': - count_matches = 1; - break; - - case 'd': - if (strcmp (optarg, "read") == 0) - directories = READ_DIRECTORIES; - else if (strcmp (optarg, "skip") == 0) - directories = SKIP_DIRECTORIES; - else if (strcmp (optarg, "recurse") == 0) - directories = RECURSE_DIRECTORIES; - else - error (2, 0, _("unknown directories method")); - break; - - case 'e': - cc = strlen (optarg); - keys = xrealloc (keys, keycc + cc + 1); - strcpy (&keys[keycc], optarg); - keycc += cc; - keys[keycc++] = '\n'; - break; - - case 'f': - fp = strcmp (optarg, "-") != 0 ? fopen (optarg, "r") : stdin; - if (!fp) - error (2, errno, "%s", optarg); - for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2) - ; - keys = xrealloc (keys, keyalloc); - oldcc = keycc; - while (!feof (fp) - && (cc = fread (keys + keycc, 1, keyalloc - 1 - keycc, fp)) > 0) - { - keycc += cc; - if (keycc == keyalloc - 1) - keys = xrealloc (keys, keyalloc *= 2); - } - if (fp != stdin) - fclose(fp); - /* Append final newline if file ended in non-newline. */ - if (oldcc != keycc && keys[keycc - 1] != '\n') - keys[keycc++] = '\n'; - break; - - case 'h': - no_filenames = 1; - break; - - case 'i': - case 'y': /* For old-timers . . . */ - match_icase = 1; - break; - - case 'L': - /* Like -l, except list files that don't contain matches. - Inspired by the same option in Hume's gre. */ - list_files = -1; - break; - - case 'l': - list_files = 1; - break; - - case 'm': - { - uintmax_t value; - switch (xstrtoumax (optarg, 0, 10, &value, "")) - { - case LONGINT_OK: - max_count = value; - if (0 <= max_count && max_count == value) - break; - /* Fall through. */ - case LONGINT_OVERFLOW: - max_count = TYPE_MAXIMUM (off_t); - break; - - default: - error (2, 0, _("invalid max count")); - } - } - break; - - case 'n': - out_line = 1; - break; - - case 'o': - only_matching = 1; - break; - - case 'q': - exit_on_match = 1; - close_stdout_set_status(0); - break; - - case 'R': - case 'r': - directories = RECURSE_DIRECTORIES; - break; - - case 's': - suppress_errors = 1; - break; - - case 'v': - out_invert = 1; - break; - - case 'w': - match_words = 1; - break; - - case 'x': - match_lines = 1; - break; - - case 'Z': -#if HAVE_LIBZ > 0 - if (BZflag) - { - printf (_("Cannot mix -J and -Z.\n")); - usage (2); - } - Zflag = 1; -#else - filename_mask = 0; -#endif - break; - - case 'z': - eolbyte = '\0'; - break; - - case BINARY_FILES_OPTION: - if (strcmp (optarg, "binary") == 0) - binary_files = BINARY_BINARY_FILES; - else if (strcmp (optarg, "text") == 0) - binary_files = TEXT_BINARY_FILES; - else if (strcmp (optarg, "without-match") == 0) - binary_files = WITHOUT_MATCH_BINARY_FILES; - else - error (2, 0, _("unknown binary-files type")); - break; - - case COLOR_OPTION: - if(optarg) { - if(!strcasecmp(optarg, "always") || !strcasecmp(optarg, "yes") || - !strcasecmp(optarg, "force")) - color_option = 1; - else if(!strcasecmp(optarg, "never") || !strcasecmp(optarg, "no") || - !strcasecmp(optarg, "none")) - color_option = 0; - else if(!strcasecmp(optarg, "auto") || !strcasecmp(optarg, "tty") || - !strcasecmp(optarg, "if-tty")) - color_option = 2; - else - show_help = 1; - } else - color_option = 2; - if(color_option == 2) { - if(isatty(STDOUT_FILENO) && getenv("TERM") && - strcmp(getenv("TERM"), "dumb")) - color_option = 1; - else - color_option = 0; - } - break; - - case EXCLUDE_OPTION: - if (!excluded_patterns) - excluded_patterns = new_exclude (); - add_exclude (excluded_patterns, optarg); - break; - - case EXCLUDE_FROM_OPTION: - if (!excluded_patterns) - excluded_patterns = new_exclude (); - if (add_exclude_file (add_exclude, excluded_patterns, optarg, '\n') - != 0) - { - error (2, errno, "%s", optarg); - } - break; - - case INCLUDE_OPTION: - if (!included_patterns) - included_patterns = new_exclude (); - add_exclude (included_patterns, optarg); - break; - - case LINE_BUFFERED_OPTION: - line_buffered = 1; - break; - - case LABEL_OPTION: - label = optarg; - break; - - case 0: - /* long options */ - break; - - default: - usage (2); - break; - - } - - /* POSIX.2 says that -q overrides -l, which in turn overrides the - other output options. */ - if (exit_on_match) - list_files = 0; - if (exit_on_match | list_files) - { - count_matches = 0; - done_on_match = 1; - } - out_quiet = count_matches | done_on_match; - - if (out_after < 0) - out_after = default_context; - if (out_before < 0) - out_before = default_context; - - if (color_option) - { - char *userval = getenv ("GREP_COLOR"); - if (userval != NULL && *userval != '\0') - grep_color = userval; - } - - if (! matcher) - matcher = program_name; - - if (show_version) - { - printf (_("%s (GNU grep) %s\n"), matcher, VERSION); - printf ("\n"); - printf (_("\ -Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.\n")); - printf (_("\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n")); - printf ("\n"); - exit (0); - } - - if (show_help) - usage (0); - - if (keys) - { - if (keycc == 0) - { - /* No keys were specified (e.g. -f /dev/null). Match nothing. */ - out_invert ^= 1; - match_lines = match_words = 0; - } - else - /* Strip trailing newline. */ - --keycc; - } - else - if (optind < argc) - { - keys = argv[optind++]; - keycc = strlen (keys); - } - else - usage (2); - - if (!install_matcher (matcher) && !install_matcher ("default")) - abort (); - -#ifdef MBS_SUPPORT - if (MB_CUR_MAX != 1 && match_icase) - { - wchar_t wc; - mbstate_t cur_state, prev_state; - int i, len = strlen(keys); - - memset(&cur_state, 0, sizeof(mbstate_t)); - for (i = 0; i <= len ;) - { - size_t mbclen; - mbclen = mbrtowc(&wc, keys + i, len - i, &cur_state); - if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) - { - /* An invalid sequence, or a truncated multibyte character. - We treat it as a singlebyte character. */ - mbclen = 1; - } - else - { - if (iswupper((wint_t)wc)) - { - wc = towlower((wint_t)wc); - wcrtomb(keys + i, wc, &cur_state); - } - } - i += mbclen; - } - } -#endif /* MBS_SUPPORT */ - - (*compile)(keys, keycc); - - if ((argc - optind > 1 && !no_filenames) || with_filenames) - out_file = 1; - -#ifdef SET_BINARY - /* Output is set to binary mode because we shouldn't convert - NL to CR-LF pairs, especially when grepping binary files. */ - if (!isatty (1)) - SET_BINARY (1); -#endif - - if (max_count == 0) - exit (1); - - if (optind < argc) - { - status = 1; - do - { - char *file = argv[optind]; - if ((included_patterns || excluded_patterns) - && !isdir (file)) - { - if (included_patterns && - ! excluded_filename (included_patterns, file, 0)) - continue; - if (excluded_patterns && - excluded_filename (excluded_patterns, file, 0)) - continue; - } - status &= grepfile (strcmp (file, "-") == 0 ? (char *) NULL : file, - &stats_base); - } - while ( ++optind < argc); - } - else - status = grepfile ((char *) NULL, &stats_base); - - /* We register via atexit() to test stdout. */ - exit (errseen ? 2 : status); -} -/* vim:set shiftwidth=2: */ diff --git a/gnu/usr.bin/grep/grep.h b/gnu/usr.bin/grep/grep.h deleted file mode 100644 index ad542eddae7..00000000000 --- a/gnu/usr.bin/grep/grep.h +++ /dev/null @@ -1,44 +0,0 @@ -/* grep.h - interface to grep driver for searching subroutines. - Copyright (C) 1992, 1998, 2001 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/grep.h 146199 2005-05-14 03:02:22Z tjr $ */ - -#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__ -# define __attribute__(x) -#endif - -/* Grep.c expects the matchers vector to be terminated - by an entry with a NULL compile, and to contain at least - an entry named "default". */ - -extern struct matcher -{ - char name[8]; - void (*compile) PARAMS ((char const *, size_t)); - size_t (*execute) PARAMS ((char const *, size_t, size_t *, int)); -} const matchers[]; - -/* Exported from fgrepmat.c, egrepmat.c, grepmat.c. */ -extern char const *matcher; - -/* The following flags are exported from grep for the matchers - to look at. */ -extern int match_icase; /* -i */ -extern int match_words; /* -w */ -extern int match_lines; /* -x */ -extern unsigned char eolbyte; /* -z */ diff --git a/gnu/usr.bin/grep/grepmat.c b/gnu/usr.bin/grep/grepmat.c deleted file mode 100644 index 7947a657445..00000000000 --- a/gnu/usr.bin/grep/grepmat.c +++ /dev/null @@ -1,6 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif -#include "system.h" -#include "grep.h" -char const *matcher; diff --git a/gnu/usr.bin/grep/hard-locale.c b/gnu/usr.bin/grep/hard-locale.c deleted file mode 100644 index 75175d08e4a..00000000000 --- a/gnu/usr.bin/grep/hard-locale.c +++ /dev/null @@ -1,87 +0,0 @@ -/* hard-locale.c -- Determine whether a locale is hard. - Copyright 1997, 1998, 1999 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/hard-locale.c 131560 2004-07-04 10:22:50Z tjr $ */ - -#if HAVE_CONFIG_H -# include -#endif - -#ifndef __GNUC__ -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - # pragma alloca -# else -# ifdef _WIN32 -# include -# include -# else -# ifndef alloca -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -#if HAVE_LOCALE_H -# include -#endif - -#if HAVE_STRING_H -# include -#endif - -/* Return nonzero if the current CATEGORY locale is hard, i.e. if you - can't get away with assuming traditional C or POSIX behavior. */ -int -hard_locale (int category) -{ -#if ! HAVE_SETLOCALE - return 0; -#else - - int hard = 1; - char const *p = setlocale (category, 0); - - if (p) - { -# if defined(__MidnightBSD__) || defined(__FreeBSD__) || (defined __GLIBC__ && __GLIBC__ >= 2) - if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) - hard = 0; -# else - char *locale = alloca (strlen (p) + 1); - strcpy (locale, p); - - /* Temporarily set the locale to the "C" and "POSIX" locales to - find their names, so that we can determine whether one or the - other is the caller's locale. */ - if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0) - || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0)) - hard = 0; - - /* Restore the caller's locale. */ - setlocale (category, locale); -# endif - } - - return hard; - -#endif -} diff --git a/gnu/usr.bin/grep/hard-locale.h b/gnu/usr.bin/grep/hard-locale.h deleted file mode 100644 index 5b054d9a5cb..00000000000 --- a/gnu/usr.bin/grep/hard-locale.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef HARD_LOCALE_H_ -# define HARD_LOCALE_H_ 1 - -# if HAVE_CONFIG_H -# include -# endif - -# ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -# endif - -int hard_locale PARAMS ((int)); - -#endif /* HARD_LOCALE_H_ */ diff --git a/gnu/usr.bin/grep/isdir.c b/gnu/usr.bin/grep/isdir.c deleted file mode 100644 index 01cf8d5e4af..00000000000 --- a/gnu/usr.bin/grep/isdir.c +++ /dev/null @@ -1,42 +0,0 @@ -/* isdir.c -- determine whether a directory exists - Copyright (C) 1990, 1998 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include - -#if STAT_MACROS_BROKEN -# undef S_ISDIR -#endif - -#if !defined S_ISDIR && defined S_IFDIR -# define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR) -#endif - -/* If PATH is an existing directory or symbolic link to a directory, - return nonzero, else 0. */ - -int -isdir (const char *path) -{ - struct stat stats; - - return stat (path, &stats) == 0 && S_ISDIR (stats.st_mode); -} diff --git a/gnu/usr.bin/grep/kwset.c b/gnu/usr.bin/grep/kwset.c deleted file mode 100644 index 6393a1a8040..00000000000 --- a/gnu/usr.bin/grep/kwset.c +++ /dev/null @@ -1,773 +0,0 @@ -/* kwset.c - search for any of a set of keywords. - Copyright 1989, 1998, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/kwset.c 131557 2004-07-04 10:02:03Z tjr $ */ - -/* Written August 1989 by Mike Haertel. - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -/* The algorithm implemented by these routines bears a startling resemblence - to one discovered by Beate Commentz-Walter, although it is not identical. - See "A String Matching Algorithm Fast on the Average," Technical Report, - IBM-Germany, Scientific Center Heidelberg, Tiergartenstrasse 15, D-6900 - Heidelberg, Germany. See also Aho, A.V., and M. Corasick, "Efficient - String Matching: An Aid to Bibliographic Search," CACM June 1975, - Vol. 18, No. 6, which describes the failure function used below. */ - -#ifdef HAVE_CONFIG_H -# include -#endif -#include -#include "system.h" -#include "kwset.h" -#include "obstack.h" - -#ifdef GREP -extern char *xmalloc(); -# undef malloc -# define malloc xmalloc -#endif - -#define NCHAR (UCHAR_MAX + 1) -#define obstack_chunk_alloc malloc -#define obstack_chunk_free free - -/* Balanced tree of edges and labels leaving a given trie node. */ -struct tree -{ - struct tree *llink; /* Left link; MUST be first field. */ - struct tree *rlink; /* Right link (to larger labels). */ - struct trie *trie; /* Trie node pointed to by this edge. */ - unsigned char label; /* Label on this edge. */ - char balance; /* Difference in depths of subtrees. */ -}; - -/* Node of a trie representing a set of reversed keywords. */ -struct trie -{ - unsigned int accepting; /* Word index of accepted word, or zero. */ - struct tree *links; /* Tree of edges leaving this node. */ - struct trie *parent; /* Parent of this node. */ - struct trie *next; /* List of all trie nodes in level order. */ - struct trie *fail; /* Aho-Corasick failure function. */ - int depth; /* Depth of this node from the root. */ - int shift; /* Shift function for search failures. */ - int maxshift; /* Max shift of self and descendents. */ -}; - -/* Structure returned opaquely to the caller, containing everything. */ -struct kwset -{ - struct obstack obstack; /* Obstack for node allocation. */ - int words; /* Number of words in the trie. */ - struct trie *trie; /* The trie itself. */ - int mind; /* Minimum depth of an accepting node. */ - int maxd; /* Maximum depth of any node. */ - unsigned char delta[NCHAR]; /* Delta table for rapid search. */ - struct trie *next[NCHAR]; /* Table of children of the root. */ - char *target; /* Target string if there's only one. */ - int mind2; /* Used in Boyer-Moore search for one string. */ - char const *trans; /* Character translation table. */ -}; - -/* Allocate and initialize a keyword set object, returning an opaque - pointer to it. Return NULL if memory is not available. */ -kwset_t -kwsalloc (char const *trans) -{ - struct kwset *kwset; - - kwset = (struct kwset *) malloc(sizeof (struct kwset)); - if (!kwset) - return 0; - - obstack_init(&kwset->obstack); - kwset->words = 0; - kwset->trie - = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie)); - if (!kwset->trie) - { - kwsfree((kwset_t) kwset); - return 0; - } - kwset->trie->accepting = 0; - kwset->trie->links = 0; - kwset->trie->parent = 0; - kwset->trie->next = 0; - kwset->trie->fail = 0; - kwset->trie->depth = 0; - kwset->trie->shift = 0; - kwset->mind = INT_MAX; - kwset->maxd = -1; - kwset->target = 0; - kwset->trans = trans; - - return (kwset_t) kwset; -} - -/* Add the given string to the contents of the keyword set. Return NULL - for success, an error message otherwise. */ -char * -kwsincr (kwset_t kws, char const *text, size_t len) -{ - struct kwset *kwset; - register struct trie *trie; - register unsigned char label; - register struct tree *link; - register int depth; - struct tree *links[12]; - enum { L, R } dirs[12]; - struct tree *t, *r, *l, *rl, *lr; - - kwset = (struct kwset *) kws; - trie = kwset->trie; - text += len; - - /* Descend the trie (built of reversed keywords) character-by-character, - installing new nodes when necessary. */ - while (len--) - { - label = kwset->trans ? kwset->trans[(unsigned char) *--text] : *--text; - - /* Descend the tree of outgoing links for this trie node, - looking for the current character and keeping track - of the path followed. */ - link = trie->links; - links[0] = (struct tree *) &trie->links; - dirs[0] = L; - depth = 1; - - while (link && label != link->label) - { - links[depth] = link; - if (label < link->label) - dirs[depth++] = L, link = link->llink; - else - dirs[depth++] = R, link = link->rlink; - } - - /* The current character doesn't have an outgoing link at - this trie node, so build a new trie node and install - a link in the current trie node's tree. */ - if (!link) - { - link = (struct tree *) obstack_alloc(&kwset->obstack, - sizeof (struct tree)); - if (!link) - return _("memory exhausted"); - link->llink = 0; - link->rlink = 0; - link->trie = (struct trie *) obstack_alloc(&kwset->obstack, - sizeof (struct trie)); - if (!link->trie) - return _("memory exhausted"); - link->trie->accepting = 0; - link->trie->links = 0; - link->trie->parent = trie; - link->trie->next = 0; - link->trie->fail = 0; - link->trie->depth = trie->depth + 1; - link->trie->shift = 0; - link->label = label; - link->balance = 0; - - /* Install the new tree node in its parent. */ - if (dirs[--depth] == L) - links[depth]->llink = link; - else - links[depth]->rlink = link; - - /* Back up the tree fixing the balance flags. */ - while (depth && !links[depth]->balance) - { - if (dirs[depth] == L) - --links[depth]->balance; - else - ++links[depth]->balance; - --depth; - } - - /* Rebalance the tree by pointer rotations if necessary. */ - if (depth && ((dirs[depth] == L && --links[depth]->balance) - || (dirs[depth] == R && ++links[depth]->balance))) - { - switch (links[depth]->balance) - { - case (char) -2: - switch (dirs[depth + 1]) - { - case L: - r = links[depth], t = r->llink, rl = t->rlink; - t->rlink = r, r->llink = rl; - t->balance = r->balance = 0; - break; - case R: - r = links[depth], l = r->llink, t = l->rlink; - rl = t->rlink, lr = t->llink; - t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl; - l->balance = t->balance != 1 ? 0 : -1; - r->balance = t->balance != (char) -1 ? 0 : 1; - t->balance = 0; - break; - default: - abort (); - } - break; - case 2: - switch (dirs[depth + 1]) - { - case R: - l = links[depth], t = l->rlink, lr = t->llink; - t->llink = l, l->rlink = lr; - t->balance = l->balance = 0; - break; - case L: - l = links[depth], r = l->rlink, t = r->llink; - lr = t->llink, rl = t->rlink; - t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl; - l->balance = t->balance != 1 ? 0 : -1; - r->balance = t->balance != (char) -1 ? 0 : 1; - t->balance = 0; - break; - default: - abort (); - } - break; - default: - abort (); - } - - if (dirs[depth - 1] == L) - links[depth - 1]->llink = t; - else - links[depth - 1]->rlink = t; - } - } - - trie = link->trie; - } - - /* Mark the node we finally reached as accepting, encoding the - index number of this word in the keyword set so far. */ - if (!trie->accepting) - trie->accepting = 1 + 2 * kwset->words; - ++kwset->words; - - /* Keep track of the longest and shortest string of the keyword set. */ - if (trie->depth < kwset->mind) - kwset->mind = trie->depth; - if (trie->depth > kwset->maxd) - kwset->maxd = trie->depth; - - return 0; -} - -/* Enqueue the trie nodes referenced from the given tree in the - given queue. */ -static void -enqueue (struct tree *tree, struct trie **last) -{ - if (!tree) - return; - enqueue(tree->llink, last); - enqueue(tree->rlink, last); - (*last) = (*last)->next = tree->trie; -} - -/* Compute the Aho-Corasick failure function for the trie nodes referenced - from the given tree, given the failure function for their parent as - well as a last resort failure node. */ -static void -treefails (register struct tree const *tree, struct trie const *fail, - struct trie *recourse) -{ - register struct tree *link; - - if (!tree) - return; - - treefails(tree->llink, fail, recourse); - treefails(tree->rlink, fail, recourse); - - /* Find, in the chain of fails going back to the root, the first - node that has a descendent on the current label. */ - while (fail) - { - link = fail->links; - while (link && tree->label != link->label) - if (tree->label < link->label) - link = link->llink; - else - link = link->rlink; - if (link) - { - tree->trie->fail = link->trie; - return; - } - fail = fail->fail; - } - - tree->trie->fail = recourse; -} - -/* Set delta entries for the links of the given tree such that - the preexisting delta value is larger than the current depth. */ -static void -treedelta (register struct tree const *tree, - register unsigned int depth, - unsigned char delta[]) -{ - if (!tree) - return; - treedelta(tree->llink, depth, delta); - treedelta(tree->rlink, depth, delta); - if (depth < delta[tree->label]) - delta[tree->label] = depth; -} - -/* Return true if A has every label in B. */ -static int -hasevery (register struct tree const *a, register struct tree const *b) -{ - if (!b) - return 1; - if (!hasevery(a, b->llink)) - return 0; - if (!hasevery(a, b->rlink)) - return 0; - while (a && b->label != a->label) - if (b->label < a->label) - a = a->llink; - else - a = a->rlink; - return !!a; -} - -/* Compute a vector, indexed by character code, of the trie nodes - referenced from the given tree. */ -static void -treenext (struct tree const *tree, struct trie *next[]) -{ - if (!tree) - return; - treenext(tree->llink, next); - treenext(tree->rlink, next); - next[tree->label] = tree->trie; -} - -/* Compute the shift for each trie node, as well as the delta - table and next cache for the given keyword set. */ -char * -kwsprep (kwset_t kws) -{ - register struct kwset *kwset; - register int i; - register struct trie *curr, *fail; - register char const *trans; - unsigned char delta[NCHAR]; - struct trie *last, *next[NCHAR]; - - kwset = (struct kwset *) kws; - - /* Initial values for the delta table; will be changed later. The - delta entry for a given character is the smallest depth of any - node at which an outgoing edge is labeled by that character. */ - if (kwset->mind < 256) - for (i = 0; i < NCHAR; ++i) - delta[i] = kwset->mind; - else - for (i = 0; i < NCHAR; ++i) - delta[i] = 255; - - /* Check if we can use the simple boyer-moore algorithm, instead - of the hairy commentz-walter algorithm. */ - if (kwset->words == 1 && kwset->trans == 0) - { - /* Looking for just one string. Extract it from the trie. */ - kwset->target = obstack_alloc(&kwset->obstack, kwset->mind); - for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i) - { - kwset->target[i] = curr->links->label; - curr = curr->links->trie; - } - /* Build the Boyer Moore delta. Boy that's easy compared to CW. */ - for (i = 0; i < kwset->mind; ++i) - delta[(unsigned char) kwset->target[i]] = kwset->mind - (i + 1); - kwset->mind2 = kwset->mind; - /* Find the minimal delta2 shift that we might make after - a backwards match has failed. */ - for (i = 0; i < kwset->mind - 1; ++i) - if (kwset->target[i] == kwset->target[kwset->mind - 1]) - kwset->mind2 = kwset->mind - (i + 1); - } - else - { - /* Traverse the nodes of the trie in level order, simultaneously - computing the delta table, failure function, and shift function. */ - for (curr = last = kwset->trie; curr; curr = curr->next) - { - /* Enqueue the immediate descendents in the level order queue. */ - enqueue(curr->links, &last); - - curr->shift = kwset->mind; - curr->maxshift = kwset->mind; - - /* Update the delta table for the descendents of this node. */ - treedelta(curr->links, curr->depth, delta); - - /* Compute the failure function for the decendents of this node. */ - treefails(curr->links, curr->fail, kwset->trie); - - /* Update the shifts at each node in the current node's chain - of fails back to the root. */ - for (fail = curr->fail; fail; fail = fail->fail) - { - /* If the current node has some outgoing edge that the fail - doesn't, then the shift at the fail should be no larger - than the difference of their depths. */ - if (!hasevery(fail->links, curr->links)) - if (curr->depth - fail->depth < fail->shift) - fail->shift = curr->depth - fail->depth; - - /* If the current node is accepting then the shift at the - fail and its descendents should be no larger than the - difference of their depths. */ - if (curr->accepting && fail->maxshift > curr->depth - fail->depth) - fail->maxshift = curr->depth - fail->depth; - } - } - - /* Traverse the trie in level order again, fixing up all nodes whose - shift exceeds their inherited maxshift. */ - for (curr = kwset->trie->next; curr; curr = curr->next) - { - if (curr->maxshift > curr->parent->maxshift) - curr->maxshift = curr->parent->maxshift; - if (curr->shift > curr->maxshift) - curr->shift = curr->maxshift; - } - - /* Create a vector, indexed by character code, of the outgoing links - from the root node. */ - for (i = 0; i < NCHAR; ++i) - next[i] = 0; - treenext(kwset->trie->links, next); - - if ((trans = kwset->trans) != 0) - for (i = 0; i < NCHAR; ++i) - kwset->next[i] = next[(unsigned char) trans[i]]; - else - for (i = 0; i < NCHAR; ++i) - kwset->next[i] = next[i]; - } - - /* Fix things up for any translation table. */ - if ((trans = kwset->trans) != 0) - for (i = 0; i < NCHAR; ++i) - kwset->delta[i] = delta[(unsigned char) trans[i]]; - else - for (i = 0; i < NCHAR; ++i) - kwset->delta[i] = delta[i]; - - return 0; -} - -#define U(C) ((unsigned char) (C)) - -/* Fast boyer-moore search. */ -static size_t -bmexec (kwset_t kws, char const *text, size_t size) -{ - struct kwset const *kwset; - register unsigned char const *d1; - register char const *ep, *sp, *tp; - register int d, gc, i, len, md2; - - kwset = (struct kwset const *) kws; - len = kwset->mind; - - if (len == 0) - return 0; - if (len > size) - return -1; - if (len == 1) - { - tp = memchr (text, kwset->target[0], size); - return tp ? tp - text : -1; - } - - d1 = kwset->delta; - sp = kwset->target + len; - gc = U(sp[-2]); - md2 = kwset->mind2; - tp = text + len; - - /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */ - if (size > 12 * len) - /* 11 is not a bug, the initial offset happens only once. */ - for (ep = text + size - 11 * len;;) - { - while (tp <= ep) - { - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - if (d == 0) - goto found; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - if (d == 0) - goto found; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - if (d == 0) - goto found; - d = d1[U(tp[-1])], tp += d; - d = d1[U(tp[-1])], tp += d; - } - break; - found: - if (U(tp[-2]) == gc) - { - for (i = 3; i <= len && U(tp[-i]) == U(sp[-i]); ++i) - ; - if (i > len) - return tp - len - text; - } - tp += md2; - } - - /* Now we have only a few characters left to search. We - carefully avoid ever producing an out-of-bounds pointer. */ - ep = text + size; - d = d1[U(tp[-1])]; - while (d <= ep - tp) - { - d = d1[U((tp += d)[-1])]; - if (d != 0) - continue; - if (U(tp[-2]) == gc) - { - for (i = 3; i <= len && U(tp[-i]) == U(sp[-i]); ++i) - ; - if (i > len) - return tp - len - text; - } - d = md2; - } - - return -1; -} - -/* Hairy multiple string search. */ -static size_t -cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch) -{ - struct kwset const *kwset; - struct trie * const *next; - struct trie const *trie; - struct trie const *accept; - char const *beg, *lim, *mch, *lmch; - register unsigned char c; - register unsigned char const *delta; - register int d; - register char const *end, *qlim; - register struct tree const *tree; - register char const *trans; - -#ifdef lint - accept = NULL; -#endif - - /* Initialize register copies and look for easy ways out. */ - kwset = (struct kwset *) kws; - if (len < kwset->mind) - return -1; - next = kwset->next; - delta = kwset->delta; - trans = kwset->trans; - lim = text + len; - end = text; - if ((d = kwset->mind) != 0) - mch = 0; - else - { - mch = text, accept = kwset->trie; - goto match; - } - - if (len >= 4 * kwset->mind) - qlim = lim - 4 * kwset->mind; - else - qlim = 0; - - while (lim - end >= d) - { - if (qlim && end <= qlim) - { - end += d - 1; - while ((d = delta[c = *end]) && end < qlim) - { - end += d; - end += delta[(unsigned char) *end]; - end += delta[(unsigned char) *end]; - } - ++end; - } - else - d = delta[c = (end += d)[-1]]; - if (d) - continue; - beg = end - 1; - trie = next[c]; - if (trie->accepting) - { - mch = beg; - accept = trie; - } - d = trie->shift; - while (beg > text) - { - c = trans ? trans[(unsigned char) *--beg] : *--beg; - tree = trie->links; - while (tree && c != tree->label) - if (c < tree->label) - tree = tree->llink; - else - tree = tree->rlink; - if (tree) - { - trie = tree->trie; - if (trie->accepting) - { - mch = beg; - accept = trie; - } - } - else - break; - d = trie->shift; - } - if (mch) - goto match; - } - return -1; - - match: - /* Given a known match, find the longest possible match anchored - at or before its starting point. This is nearly a verbatim - copy of the preceding main search loops. */ - if (lim - mch > kwset->maxd) - lim = mch + kwset->maxd; - lmch = 0; - d = 1; - while (lim - end >= d) - { - if ((d = delta[c = (end += d)[-1]]) != 0) - continue; - beg = end - 1; - if (!(trie = next[c])) - { - d = 1; - continue; - } - if (trie->accepting && beg <= mch) - { - lmch = beg; - accept = trie; - } - d = trie->shift; - while (beg > text) - { - c = trans ? trans[(unsigned char) *--beg] : *--beg; - tree = trie->links; - while (tree && c != tree->label) - if (c < tree->label) - tree = tree->llink; - else - tree = tree->rlink; - if (tree) - { - trie = tree->trie; - if (trie->accepting && beg <= mch) - { - lmch = beg; - accept = trie; - } - } - else - break; - d = trie->shift; - } - if (lmch) - { - mch = lmch; - goto match; - } - if (!d) - d = 1; - } - - if (kwsmatch) - { - kwsmatch->index = accept->accepting / 2; - kwsmatch->offset[0] = mch - text; - kwsmatch->size[0] = accept->depth; - } - return mch - text; -} - -/* Search through the given text for a match of any member of the - given keyword set. Return a pointer to the first character of - the matching substring, or NULL if no match is found. If FOUNDLEN - is non-NULL store in the referenced location the length of the - matching substring. Similarly, if FOUNDIDX is non-NULL, store - in the referenced location the index number of the particular - keyword matched. */ -size_t -kwsexec (kwset_t kws, char const *text, size_t size, - struct kwsmatch *kwsmatch) -{ - struct kwset const *kwset = (struct kwset *) kws; - if (kwset->words == 1 && kwset->trans == 0) - { - size_t ret = bmexec (kws, text, size); - if (kwsmatch != 0 && ret != (size_t) -1) - { - kwsmatch->index = 0; - kwsmatch->offset[0] = ret; - kwsmatch->size[0] = kwset->mind; - } - return ret; - } - else - return cwexec(kws, text, size, kwsmatch); -} - -/* Free the components of the given keyword set. */ -void -kwsfree (kwset_t kws) -{ - struct kwset *kwset; - - kwset = (struct kwset *) kws; - obstack_free(&kwset->obstack, 0); - free(kws); -} diff --git a/gnu/usr.bin/grep/kwset.h b/gnu/usr.bin/grep/kwset.h deleted file mode 100644 index ca085445ef4..00000000000 --- a/gnu/usr.bin/grep/kwset.h +++ /dev/null @@ -1,59 +0,0 @@ -/* kwset.h - header declaring the keyword set library. - Copyright (C) 1989, 1998 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* Written August 1989 by Mike Haertel. - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/kwset.h 131557 2004-07-04 10:02:03Z tjr $ */ - -struct kwsmatch -{ - int index; /* Index number of matching keyword. */ - size_t offset[1]; /* Offset of each submatch. */ - size_t size[1]; /* Length of each submatch. */ -}; - -typedef ptr_t kwset_t; - -/* Return an opaque pointer to a newly allocated keyword set, or NULL - if enough memory cannot be obtained. The argument if non-NULL - specifies a table of character translations to be applied to all - pattern and search text. */ -extern kwset_t kwsalloc PARAMS((char const *)); - -/* Incrementally extend the keyword set to include the given string. - Return NULL for success, or an error message. Remember an index - number for each keyword included in the set. */ -extern char *kwsincr PARAMS((kwset_t, char const *, size_t)); - -/* When the keyword set has been completely built, prepare it for - use. Return NULL for success, or an error message. */ -extern char *kwsprep PARAMS((kwset_t)); - -/* Search through the given buffer for a member of the keyword set. - Return a pointer to the leftmost longest match found, or NULL if - no match is found. If foundlen is non-NULL, store the length of - the matching substring in the integer it points to. Similarly, - if foundindex is non-NULL, store the index of the particular - keyword found therein. */ -extern size_t kwsexec PARAMS((kwset_t, char const *, size_t, struct kwsmatch *)); - -/* Deallocate the given keyword set and all its associated storage. */ -extern void kwsfree PARAMS((kwset_t)); - diff --git a/gnu/usr.bin/grep/obstack.c b/gnu/usr.bin/grep/obstack.c deleted file mode 100644 index 17c63134315..00000000000 --- a/gnu/usr.bin/grep/obstack.c +++ /dev/null @@ -1,598 +0,0 @@ -/* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988-1994,96,97,98,99 Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "obstack.h" - -/* NOTE BEFORE MODIFYING THIS FILE: This version number must be - incremented whenever callers compiled using an old obstack.h can no - longer properly call the functions in this obstack.c. */ -#define OBSTACK_INTERFACE_VERSION 1 - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself, and the installed library - supports the same library interface we do. This code is part of the GNU - C Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object - files, it is simpler to just do this in the source for each such file. */ - -#include /* Random thing to get __GNU_LIBRARY__. */ -#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -#include -#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - - -#ifndef ELIDE_CODE - - -#if defined (__STDC__) && __STDC__ -#define POINTER void * -#else -#define POINTER char * -#endif - -/* Determine default alignment. */ -struct fooalign {char x; double d;}; -#define DEFAULT_ALIGNMENT \ - ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0)) -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; -#define DEFAULT_ROUNDING (sizeof (union fooround)) - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to `long' (if that works) - or `char' as a last resort. */ -#ifndef COPYING_UNIT -#define COPYING_UNIT int -#endif - - -/* The functions allocating more room by calling `obstack_chunk_alloc' - jump to the handler pointed to by `obstack_alloc_failed_handler'. - This can be set to a user defined function which should either - abort gracefully or use longjump - but shouldn't return. This - variable by default points to the internal function - `print_and_abort'. */ -#if defined (__STDC__) && __STDC__ -static void print_and_abort (void); -void (*obstack_alloc_failed_handler) (void) = print_and_abort; -#else -static void print_and_abort (); -void (*obstack_alloc_failed_handler) () = print_and_abort; -#endif - -/* Exit value used when `print_and_abort' is used. */ -#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H -#include -#endif -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif -int obstack_exit_failure = EXIT_FAILURE; - -/* The non-GNU-C macros copy the obstack into this global variable - to avoid multiple evaluation. */ - -struct obstack *_obstack; - -/* Define a macro that either calls functions with the traditional malloc/free - calling interface, or calls functions with the mmalloc/mfree interface - (that adds an extra first argument), based on the state of use_extra_arg. - For free, do not use ?:, since some compilers, like the MIPS compilers, - do not allow (expr) ? void : void. */ - -#if defined (__STDC__) && __STDC__ -#define CALL_CHUNKFUN(h, size) \ - (((h) -> use_extra_arg) \ - ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ - : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size))) - -#define CALL_FREEFUN(h, old_chunk) \ - do { \ - if ((h) -> use_extra_arg) \ - (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ - else \ - (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \ - } while (0) -#else -#define CALL_CHUNKFUN(h, size) \ - (((h) -> use_extra_arg) \ - ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ - : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size))) - -#define CALL_FREEFUN(h, old_chunk) \ - do { \ - if ((h) -> use_extra_arg) \ - (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ - else \ - (*(void (*) ()) (h)->freefun) ((old_chunk)); \ - } while (0) -#endif - - -/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). - Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. - - Return nonzero if successful, calls obstack_alloc_failed_handler if - allocation fails. */ - -int -_obstack_begin (h, size, alignment, chunkfun, freefun) - struct obstack *h; - int size; - int alignment; -#if defined (__STDC__) && __STDC__ - POINTER (*chunkfun) (long); - void (*freefun) (void *); -#else - POINTER (*chunkfun) (); - void (*freefun) (); -#endif -{ - register struct _obstack_chunk *chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = (int) DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - -#if defined (__STDC__) && __STDC__ - h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; -#else - h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; - h->freefun = freefun; -#endif - h->chunk_size = size; - h->alignment_mask = alignment - 1; - h->use_extra_arg = 0; - - chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); - if (!chunk) - (*obstack_alloc_failed_handler) (); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; - /* The initial chunk now contains no empty object. */ - h->maybe_empty_object = 0; - h->alloc_failed = 0; - return 1; -} - -int -_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) - struct obstack *h; - int size; - int alignment; -#if defined (__STDC__) && __STDC__ - POINTER (*chunkfun) (POINTER, long); - void (*freefun) (POINTER, POINTER); -#else - POINTER (*chunkfun) (); - void (*freefun) (); -#endif - POINTER arg; -{ - register struct _obstack_chunk *chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = (int) DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - -#if defined(__STDC__) && __STDC__ - h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; -#else - h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; - h->freefun = freefun; -#endif - h->chunk_size = size; - h->alignment_mask = alignment - 1; - h->extra_arg = arg; - h->use_extra_arg = 1; - - chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); - if (!chunk) - (*obstack_alloc_failed_handler) (); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; - /* The initial chunk now contains no empty object. */ - h->maybe_empty_object = 0; - h->alloc_failed = 0; - return 1; -} - -/* Allocate a new current chunk for the obstack *H - on the assumption that LENGTH bytes need to be added - to the current object, or a new object of length LENGTH allocated. - Copies any partial object from the end of the old chunk - to the beginning of the new one. */ - -void -_obstack_newchunk (h, length) - struct obstack *h; - int length; -{ - register struct _obstack_chunk *old_chunk = h->chunk; - register struct _obstack_chunk *new_chunk; - register long new_size; - register long obj_size = h->next_free - h->object_base; - register long i; - long already; - - /* Compute size for new chunk. */ - new_size = (obj_size + length) + (obj_size >> 3) + 100; - if (new_size < h->chunk_size) - new_size = h->chunk_size; - - /* Allocate and initialize the new chunk. */ - new_chunk = CALL_CHUNKFUN (h, new_size); - if (!new_chunk) - (*obstack_alloc_failed_handler) (); - h->chunk = new_chunk; - new_chunk->prev = old_chunk; - new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; - - /* Move the existing object to the new chunk. - Word at a time is fast and is safe if the object - is sufficiently aligned. */ - if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) - { - for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ - already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); - } - else - already = 0; - /* Copy remaining bytes one by one. */ - for (i = already; i < obj_size; i++) - new_chunk->contents[i] = h->object_base[i]; - - /* If the object just copied was the only data in OLD_CHUNK, - free that chunk and remove it from the chain. - But not if that chunk might contain an empty object. */ - if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) - { - new_chunk->prev = old_chunk->prev; - CALL_FREEFUN (h, old_chunk); - } - - h->object_base = new_chunk->contents; - h->next_free = h->object_base + obj_size; - /* The new chunk certainly contains no empty object yet. */ - h->maybe_empty_object = 0; -} - -/* Return nonzero if object OBJ has been allocated from obstack H. - This is here for debugging. - If you use it in a program, you are probably losing. */ - -#if defined (__STDC__) && __STDC__ -/* Suppress -Wmissing-prototypes warning. We don't want to declare this in - obstack.h because it is just for debugging. */ -int _obstack_allocated_p (struct obstack *h, POINTER obj); -#endif - -int -_obstack_allocated_p (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - /* We use >= rather than > since the object cannot be exactly at - the beginning of the chunk but might be an empty object exactly - at the end of an adjacent chunk. */ - while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) - { - plp = lp->prev; - lp = plp; - } - return lp != 0; -} - -/* Free objects in obstack H, including OBJ and everything allocate - more recently than OBJ. If OBJ is zero, free everything in H. */ - -#undef obstack_free - -/* This function has two names with identical definitions. - This is the first one, called from non-ANSI code. */ - -void -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = h->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) - { - plp = lp->prev; - CALL_FREEFUN (h, lp); - lp = plp; - /* If we switch chunks, we can't tell whether the new current - chunk contains an empty object, so assume that it may. */ - h->maybe_empty_object = 1; - } - if (lp) - { - h->object_base = h->next_free = (char *) (obj); - h->chunk_limit = lp->limit; - h->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* This function is used from ANSI code. */ - -void -obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = h->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) - { - plp = lp->prev; - CALL_FREEFUN (h, lp); - lp = plp; - /* If we switch chunks, we can't tell whether the new current - chunk contains an empty object, so assume that it may. */ - h->maybe_empty_object = 1; - } - if (lp) - { - h->object_base = h->next_free = (char *) (obj); - h->chunk_limit = lp->limit; - h->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -int -_obstack_memory_used (h) - struct obstack *h; -{ - register struct _obstack_chunk* lp; - register int nbytes = 0; - - for (lp = h->chunk; lp != 0; lp = lp->prev) - { - nbytes += lp->limit - (char *) lp; - } - return nbytes; -} - -/* Define the error handler. */ -#ifndef _ -# ifdef HAVE_LIBINTL_H -# include -# ifndef _ -# define _(Str) gettext (Str) -# endif -# else -# define _(Str) (Str) -# endif -#endif -#if defined _LIBC && defined USE_IN_LIBIO -# include -# define fputs(s, f) _IO_fputs (s, f) -#endif - -static void -print_and_abort () -{ - fputs (_("memory exhausted"), stderr); - fputc ('\n', stderr); - exit (obstack_exit_failure); -} - -#if 0 -/* These are now turned off because the applications do not use it - and it uses bcopy via obstack_grow, which causes trouble on sysV. */ - -/* Now define the functional versions of the obstack macros. - Define them to simply use the corresponding macros to do the job. */ - -#if defined (__STDC__) && __STDC__ -/* These function definitions do not work with non-ANSI preprocessors; - they won't pass through the macro names in parentheses. */ - -/* The function names appear in parentheses in order to prevent - the macro-definitions of the names from being expanded there. */ - -POINTER (obstack_base) (obstack) - struct obstack *obstack; -{ - return obstack_base (obstack); -} - -POINTER (obstack_next_free) (obstack) - struct obstack *obstack; -{ - return obstack_next_free (obstack); -} - -int (obstack_object_size) (obstack) - struct obstack *obstack; -{ - return obstack_object_size (obstack); -} - -int (obstack_room) (obstack) - struct obstack *obstack; -{ - return obstack_room (obstack); -} - -int (obstack_make_room) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_make_room (obstack, length); -} - -void (obstack_grow) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow (obstack, pointer, length); -} - -void (obstack_grow0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow0 (obstack, pointer, length); -} - -void (obstack_1grow) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow (obstack, character); -} - -void (obstack_blank) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank (obstack, length); -} - -void (obstack_1grow_fast) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow_fast (obstack, character); -} - -void (obstack_blank_fast) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank_fast (obstack, length); -} - -POINTER (obstack_finish) (obstack) - struct obstack *obstack; -{ - return obstack_finish (obstack); -} - -POINTER (obstack_alloc) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_alloc (obstack, length); -} - -POINTER (obstack_copy) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy (obstack, pointer, length); -} - -POINTER (obstack_copy0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy0 (obstack, pointer, length); -} - -#endif /* __STDC__ */ - -#endif /* 0 */ - -#endif /* !ELIDE_CODE */ diff --git a/gnu/usr.bin/grep/obstack.h b/gnu/usr.bin/grep/obstack.h deleted file mode 100644 index 4d49ce024b1..00000000000 --- a/gnu/usr.bin/grep/obstack.h +++ /dev/null @@ -1,593 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc. - - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" ---Gosper's immortal quote from HAKMEM item 154, out of context--you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' an obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef _OBSTACK_H -#define _OBSTACK_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* We use subtraction of (char *) 0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -# define __PTR_TO_INT(P) ((P) - (char *) 0) -#endif - -#ifndef __INT_TO_PTR -# define __INT_TO_PTR(P) ((P) + (char *) 0) -#endif - -/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is - defined, as with GNU C, use that; that way we don't pollute the - namespace with 's symbols. Otherwise, if is - available, include it and use ptrdiff_t. In traditional C, long is - the best that we can do. */ - -#ifdef __PTRDIFF_TYPE__ -# define PTR_INT_TYPE __PTRDIFF_TYPE__ -#else -# ifdef HAVE_STDDEF_H -# include -# define PTR_INT_TYPE ptrdiff_t -# else -# define PTR_INT_TYPE long -# endif -#endif - -#if defined _LIBC || defined HAVE_STRING_H -# include -# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) -#else -# ifdef memcpy -# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) -# else -# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N)) -# endif -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - PTR_INT_TYPE temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ -#if defined __STDC__ && __STDC__ - /* These prototypes vary based on `use_extra_arg', and we use - casts to the prototypeless function type in all assignments, - but having prototypes here quiets -Wstrict-prototypes. */ - struct _obstack_chunk *(*chunkfun) (void *, long); - void (*freefun) (void *, struct _obstack_chunk *); - void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ -#else - struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ - void (*freefun) (); /* User's function to free a chunk. */ - char *extra_arg; /* first arg for chunk alloc/dealloc funcs */ -#endif - unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ - unsigned maybe_empty_object:1;/* There is a possibility that the current - chunk contains a zero-length object. This - prevents freeing the chunk if we allocate - a bigger chunk to replace it. */ - unsigned alloc_failed:1; /* No longer used, as we now call the failed - handler on error, but retained for binary - compatibility. */ -}; - -/* Declare the external functions we use; they are in obstack.c. */ - -#if defined __STDC__ && __STDC__ -extern void _obstack_newchunk (struct obstack *, int); -extern void _obstack_free (struct obstack *, void *); -extern int _obstack_begin (struct obstack *, int, int, - void *(*) (long), void (*) (void *)); -extern int _obstack_begin_1 (struct obstack *, int, int, - void *(*) (void *, long), - void (*) (void *, void *), void *); -extern int _obstack_memory_used (struct obstack *); -#else -extern void _obstack_newchunk (); -extern void _obstack_free (); -extern int _obstack_begin (); -extern int _obstack_begin_1 (); -extern int _obstack_memory_used (); -#endif - -#if defined __STDC__ && __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_make_room (struct obstack *obstack, int size); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); -int obstack_memory_used (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Error handler called when `obstack_chunk_alloc' failed to allocate - more memory. This can be set to a user defined function which - should either abort gracefully or use longjump - but shouldn't - return. The default action is to print a message and abort. */ -#if defined __STDC__ && __STDC__ -extern void (*obstack_alloc_failed_handler) (void); -#else -extern void (*obstack_alloc_failed_handler) (); -#endif - -/* Exit value used when `print_and_abort' is used. */ -extern int obstack_exit_failure; - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -/* To prevent prototype warnings provide complete argument list in - standard C version. */ -#if defined __STDC__ && __STDC__ - -# define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) - -# define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) - -# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun)) - -# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) (void *, long)) (chunkfun), \ - (void (*) (void *, void *)) (freefun), (arg)) - -# define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) - -# define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) - -#else - -# define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) - -# define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) - -# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) ()) (chunkfun), (void (*) ()) (freefun)) - -# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg)) - -# define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) - -# define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)()) (newfreefun)) - -#endif - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#define obstack_memory_used(h) _obstack_memory_used (h) - -#if defined __GNUC__ && defined __STDC__ && __STDC__ -/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and - does not implement __extension__. But that compiler doesn't define - __GNUC_MINOR__. */ -# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) -# define __extension__ -# endif - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -# define obstack_object_size(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -# define obstack_room(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -# define obstack_make_room(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - (void) 0; }) - -# define obstack_empty_p(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); }) - -# define obstack_grow(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len > __o->chunk_limit) \ - _obstack_newchunk (__o, __len); \ - _obstack_memcpy (__o->next_free, (char *) (where), __len); \ - __o->next_free += __len; \ - (void) 0; }) - -# define obstack_grow0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, __len + 1); \ - _obstack_memcpy (__o->next_free, (char *) (where), __len); \ - __o->next_free += __len; \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -# define obstack_1grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, 1); \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -# define obstack_ptr_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (void *)); \ - *((void **)__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -# define obstack_int_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (int) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (int)); \ - *((int *)__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr) -# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) - -# define obstack_blank(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -# define obstack_alloc(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -# define obstack_copy(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -# define obstack_copy0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -/* The local variable is named __o1 to avoid a name conflict - when obstack_blank is called. */ -# define obstack_finish(OBSTACK) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *value; \ - value = (void *) __o1->object_base; \ - if (__o1->next_free == value) \ - __o1->maybe_empty_object = 1; \ - __o1->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ - & ~ (__o1->alignment_mask)); \ - if (__o1->next_free - (char *)__o1->chunk \ - > __o1->chunk_limit - (char *)__o1->chunk) \ - __o1->next_free = __o1->chunk_limit; \ - __o1->object_base = __o1->next_free; \ - value; }) - -# define obstack_free(OBSTACK, OBJ) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = (char *)__obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -# define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) - -# define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) - -# define obstack_empty_p(h) \ - ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0) - -/* Note that the call to _obstack_newchunk is enclosed in (..., 0) - so that we can avoid having void expressions - in the arms of the conditional expression. - Casting the third operand to void was tried before, - but some compilers won't accept it. */ - -# define obstack_make_room(h,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0)) - -# define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ - (h)->next_free += (h)->temp) - -# define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ - _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -# define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), 1), 0) : 0), \ - (*((h)->next_free)++ = (datum))) - -# define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ - (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum))) - -# define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ - (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum))) - -# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr) -# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) - -# define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - ((h)->next_free += (h)->temp)) - -# define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -# define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -# define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -# define obstack_finish(h) \ -( ((h)->next_free == (h)->object_base \ - ? (((h)->maybe_empty_object = 1), 0) \ - : 0), \ - (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *) (h)->chunk \ - > (h)->chunk_limit - (char *) (h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -# if defined __STDC__ && __STDC__ -# define obstack_free(h,obj) \ -( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ - (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) -# else -# define obstack_free(h,obj) \ -( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ - (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) -# endif - -#endif /* not __GNUC__ or not __STDC__ */ - -#ifdef __cplusplus -} /* C++ */ -#endif - -#endif /* obstack.h */ diff --git a/gnu/usr.bin/grep/quotearg.c b/gnu/usr.bin/grep/quotearg.c deleted file mode 100644 index 2a7ba4c445b..00000000000 --- a/gnu/usr.bin/grep/quotearg.c +++ /dev/null @@ -1,613 +0,0 @@ -/* quotearg.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Paul Eggert */ - -#if HAVE_CONFIG_H -# include -#endif - -#if HAVE_STDDEF_H -# include /* For the definition of size_t on windows w/MSVC. */ -#endif -#include -#include -#include - -#include - -#if ENABLE_NLS -# include -# define _(text) gettext (text) -#else -# define _(text) text -#endif -#define N_(text) text - -#if HAVE_LIMITS_H -# include -#endif -#ifndef CHAR_BIT -# define CHAR_BIT 8 -#endif -#ifndef UCHAR_MAX -# define UCHAR_MAX ((unsigned char) -1) -#endif - -#if HAVE_C_BACKSLASH_A -# define ALERT_CHAR '\a' -#else -# define ALERT_CHAR '\7' -#endif - -#if HAVE_STDLIB_H -# include -#endif - -#if HAVE_STRING_H -# include -#endif - -#if HAVE_WCHAR_H -# include -#endif - -#if !HAVE_MBRTOWC -/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the - other macros are defined only for documentation and to satisfy C - syntax. */ -# undef MB_CUR_MAX -# define MB_CUR_MAX 1 -# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0) -# define mbsinit(ps) 1 -# define iswprint(wc) ISPRINT ((unsigned char) (wc)) -#endif - -#ifndef iswprint -# if HAVE_WCTYPE_H -# include -# endif -# if !defined iswprint && !HAVE_ISWPRINT -# define iswprint(wc) 1 -# endif -#endif - -#define INT_BITS (sizeof (int) * CHAR_BIT) - -#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) -# define IN_CTYPE_DOMAIN(c) 1 -#else -# define IN_CTYPE_DOMAIN(c) isascii(c) -#endif - -/* Undefine to protect against the definition in wctype.h of solaris2.6. */ -#undef ISPRINT -#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) - -struct quoting_options -{ - /* Basic quoting style. */ - enum quoting_style style; - - /* Quote the characters indicated by this bit vector even if the - quoting style would not normally require them to be quoted. */ - int quote_these_too[(UCHAR_MAX / INT_BITS) + 1]; -}; - -/* Names of quoting styles. */ -char const *const quoting_style_args[] = -{ - "literal", - "shell", - "shell-always", - "c", - "escape", - "locale", - "clocale", - 0 -}; - -/* Correspondences to quoting style names. */ -enum quoting_style const quoting_style_vals[] = -{ - literal_quoting_style, - shell_quoting_style, - shell_always_quoting_style, - c_quoting_style, - escape_quoting_style, - locale_quoting_style, - clocale_quoting_style -}; - -/* The default quoting options. */ -static struct quoting_options default_quoting_options; - -/* Allocate a new set of quoting options, with contents initially identical - to O if O is not null, or to the default if O is null. - It is the caller's responsibility to free the result. */ -struct quoting_options * -clone_quoting_options (struct quoting_options *o) -{ - struct quoting_options *p - = (struct quoting_options *) xmalloc (sizeof (struct quoting_options)); - *p = *(o ? o : &default_quoting_options); - return p; -} - -/* Get the value of O's quoting style. If O is null, use the default. */ -enum quoting_style -get_quoting_style (struct quoting_options *o) -{ - return (o ? o : &default_quoting_options)->style; -} - -/* In O (or in the default if O is null), - set the value of the quoting style to S. */ -void -set_quoting_style (struct quoting_options *o, enum quoting_style s) -{ - (o ? o : &default_quoting_options)->style = s; -} - -/* In O (or in the default if O is null), - set the value of the quoting options for character C to I. - Return the old value. Currently, the only values defined for I are - 0 (the default) and 1 (which means to quote the character even if - it would not otherwise be quoted). */ -int -set_char_quoting (struct quoting_options *o, char c, int i) -{ - unsigned char uc = c; - int *p = (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS; - int shift = uc % INT_BITS; - int r = (*p >> shift) & 1; - *p ^= ((i & 1) ^ r) << shift; - return r; -} - -/* MSGID approximates a quotation mark. Return its translation if it - has one; otherwise, return either it or "\"", depending on S. */ -static char const * -gettext_quote (char const *msgid, enum quoting_style s) -{ - char const *translation = _(msgid); - if (translation == msgid && s == clocale_quoting_style) - translation = "\""; - return translation; -} - -/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of - argument ARG (of size ARGSIZE), using QUOTING_STYLE and the - non-quoting-style part of O to control quoting. - Terminate the output with a null character, and return the written - size of the output, not counting the terminating null. - If BUFFERSIZE is too small to store the output string, return the - value that would have been returned had BUFFERSIZE been large enough. - If ARGSIZE is -1, use the string length of the argument for ARGSIZE. - - This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG, - ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting - style specified by O, and O may not be null. */ - -static size_t -quotearg_buffer_restyled (char *buffer, size_t buffersize, - char const *arg, size_t argsize, - enum quoting_style quoting_style, - struct quoting_options const *o) -{ - size_t i; - size_t len = 0; - char const *quote_string = 0; - size_t quote_string_len = 0; - int backslash_escapes = 0; - int unibyte_locale = MB_CUR_MAX == 1; - -#define STORE(c) \ - do \ - { \ - if (len < buffersize) \ - buffer[len] = (c); \ - len++; \ - } \ - while (0) - - switch (quoting_style) - { - case c_quoting_style: - STORE ('"'); - backslash_escapes = 1; - quote_string = "\""; - quote_string_len = 1; - break; - - case escape_quoting_style: - backslash_escapes = 1; - break; - - case locale_quoting_style: - case clocale_quoting_style: - { - /* Get translations for open and closing quotation marks. - - The message catalog should translate "`" to a left - quotation mark suitable for the locale, and similarly for - "'". If the catalog has no translation, - locale_quoting_style quotes `like this', and - clocale_quoting_style quotes "like this". - - For example, an American English Unicode locale should - translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and - should translate "'" to U+201D (RIGHT DOUBLE QUOTATION - MARK). A British English Unicode locale should instead - translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and - U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. */ - - char const *left = gettext_quote (N_("`"), quoting_style); - char const *right = gettext_quote (N_("'"), quoting_style); - for (quote_string = left; *quote_string; quote_string++) - STORE (*quote_string); - backslash_escapes = 1; - quote_string = right; - quote_string_len = strlen (quote_string); - } - break; - - case shell_always_quoting_style: - STORE ('\''); - quote_string = "'"; - quote_string_len = 1; - break; - - default: - break; - } - - for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++) - { - unsigned char c; - unsigned char esc; - - if (backslash_escapes - && quote_string_len - && i + quote_string_len <= argsize - && memcmp (arg + i, quote_string, quote_string_len) == 0) - STORE ('\\'); - - c = arg[i]; - switch (c) - { - case '?': - switch (quoting_style) - { - case shell_quoting_style: - goto use_shell_always_quoting_style; - - case c_quoting_style: - if (i + 2 < argsize && arg[i + 1] == '?') - switch (arg[i + 2]) - { - case '!': case '\'': - case '(': case ')': case '-': case '/': - case '<': case '=': case '>': - /* Escape the second '?' in what would otherwise be - a trigraph. */ - i += 2; - c = arg[i + 2]; - STORE ('?'); - STORE ('\\'); - STORE ('?'); - break; - } - break; - - default: - break; - } - break; - - case ALERT_CHAR: esc = 'a'; goto c_escape; - case '\b': esc = 'b'; goto c_escape; - case '\f': esc = 'f'; goto c_escape; - case '\n': esc = 'n'; goto c_and_shell_escape; - case '\r': esc = 'r'; goto c_and_shell_escape; - case '\t': esc = 't'; goto c_and_shell_escape; - case '\v': esc = 'v'; goto c_escape; - case '\\': esc = c; goto c_and_shell_escape; - - c_and_shell_escape: - if (quoting_style == shell_quoting_style) - goto use_shell_always_quoting_style; - c_escape: - if (backslash_escapes) - { - c = esc; - goto store_escape; - } - break; - - case '#': case '~': - if (i != 0) - break; - /* Fall through. */ - case ' ': - case '!': /* special in bash */ - case '"': case '$': case '&': - case '(': case ')': case '*': case ';': - case '<': case '>': case '[': - case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ - case '`': case '|': - /* A shell special character. In theory, '$' and '`' could - be the first bytes of multibyte characters, which means - we should check them with mbrtowc, but in practice this - doesn't happen so it's not worth worrying about. */ - if (quoting_style == shell_quoting_style) - goto use_shell_always_quoting_style; - break; - - case '\'': - switch (quoting_style) - { - case shell_quoting_style: - goto use_shell_always_quoting_style; - - case shell_always_quoting_style: - STORE ('\''); - STORE ('\\'); - STORE ('\''); - break; - - default: - break; - } - break; - - case '%': case '+': case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': case ':': case '=': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': - case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': - case 'o': case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': - case '{': case '}': - /* These characters don't cause problems, no matter what the - quoting style is. They cannot start multibyte sequences. */ - break; - - default: - /* If we have a multibyte sequence, copy it until we reach - its end, find an error, or come back to the initial shift - state. For C-like styles, if the sequence has - unprintable characters, escape the whole sequence, since - we can't easily escape single characters within it. */ - { - /* Length of multibyte sequence found so far. */ - size_t m; - - int printable; - - if (unibyte_locale) - { - m = 1; - printable = ISPRINT (c); - } - else - { - mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); - - m = 0; - printable = 1; - if (argsize == (size_t) -1) - argsize = strlen (arg); - - do - { - wchar_t w; - size_t bytes = mbrtowc (&w, &arg[i + m], - argsize - (i + m), &mbstate); - if (bytes == 0) - break; - else if (bytes == (size_t) -1) - { - printable = 0; - break; - } - else if (bytes == (size_t) -2) - { - printable = 0; - while (i + m < argsize && arg[i + m]) - m++; - break; - } - else - { - if (! iswprint (w)) - printable = 0; - m += bytes; - } - } - while (! mbsinit (&mbstate)); - } - - if (1 < m || (backslash_escapes && ! printable)) - { - /* Output a multibyte sequence, or an escaped - unprintable unibyte character. */ - size_t ilim = i + m; - - for (;;) - { - if (backslash_escapes && ! printable) - { - STORE ('\\'); - STORE ('0' + (c >> 6)); - STORE ('0' + ((c >> 3) & 7)); - c = '0' + (c & 7); - } - if (ilim <= i + 1) - break; - STORE (c); - c = arg[++i]; - } - - goto store_c; - } - } - } - - if (! (backslash_escapes - && o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))) - goto store_c; - - store_escape: - STORE ('\\'); - - store_c: - STORE (c); - } - - if (quote_string) - for (; *quote_string; quote_string++) - STORE (*quote_string); - - if (len < buffersize) - buffer[len] = '\0'; - return len; - - use_shell_always_quoting_style: - return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, - shell_always_quoting_style, o); -} - -/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of - argument ARG (of size ARGSIZE), using O to control quoting. - If O is null, use the default. - Terminate the output with a null character, and return the written - size of the output, not counting the terminating null. - If BUFFERSIZE is too small to store the output string, return the - value that would have been returned had BUFFERSIZE been large enough. - If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */ -size_t -quotearg_buffer (char *buffer, size_t buffersize, - char const *arg, size_t argsize, - struct quoting_options const *o) -{ - struct quoting_options const *p = o ? o : &default_quoting_options; - return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, - p->style, p); -} - -/* Use storage slot N to return a quoted version of the string ARG. - OPTIONS specifies the quoting options. - The returned value points to static storage that can be - reused by the next call to this function with the same value of N. - N must be nonnegative. N is deliberately declared with type "int" - to allow for future extensions (using negative values). */ -static char * -quotearg_n_options (int n, char const *arg, - struct quoting_options const *options) -{ - /* Preallocate a slot 0 buffer, so that the caller can always quote - one small component of a "memory exhausted" message in slot 0. */ - static char slot0[256]; - static unsigned int nslots = 1; - struct slotvec - { - size_t size; - char *val; - }; - static struct slotvec slotvec0 = {sizeof slot0, slot0}; - static struct slotvec *slotvec = &slotvec0; - - if (nslots <= n) - { - int n1 = n + 1; - size_t s = n1 * sizeof (struct slotvec); - if (! (0 < n1 && n1 == s / sizeof (struct slotvec))) - abort (); - if (slotvec == &slotvec0) - { - slotvec = (struct slotvec *) xmalloc (sizeof (struct slotvec)); - *slotvec = slotvec0; - } - slotvec = (struct slotvec *) xrealloc (slotvec, s); - memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec)); - nslots = n; - } - - { - size_t size = slotvec[n].size; - char *val = slotvec[n].val; - size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options); - - if (size <= qsize) - { - slotvec[n].size = size = qsize + 1; - slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size); - quotearg_buffer (val, size, arg, (size_t) -1, options); - } - - return val; - } -} - -char * -quotearg_n (unsigned int n, char const *arg) -{ - return quotearg_n_options (n, arg, &default_quoting_options); -} - -char * -quotearg (char const *arg) -{ - return quotearg_n (0, arg); -} - -char * -quotearg_n_style (unsigned int n, enum quoting_style s, char const *arg) -{ - struct quoting_options o; - o.style = s; - memset (o.quote_these_too, 0, sizeof o.quote_these_too); - return quotearg_n_options (n, arg, &o); -} - -char * -quotearg_style (enum quoting_style s, char const *arg) -{ - return quotearg_n_style (0, s, arg); -} - -char * -quotearg_char (char const *arg, char ch) -{ - struct quoting_options options; - options = default_quoting_options; - set_char_quoting (&options, ch, 1); - return quotearg_n_options (0, arg, &options); -} - -char * -quotearg_colon (char const *arg) -{ - return quotearg_char (arg, ':'); -} diff --git a/gnu/usr.bin/grep/quotearg.h b/gnu/usr.bin/grep/quotearg.h deleted file mode 100644 index f6463b1aa3b..00000000000 --- a/gnu/usr.bin/grep/quotearg.h +++ /dev/null @@ -1,110 +0,0 @@ -/* quotearg.h - quote arguments for output - Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Paul Eggert */ - -/* Basic quoting styles. */ -enum quoting_style - { - literal_quoting_style, /* --quoting-style=literal */ - shell_quoting_style, /* --quoting-style=shell */ - shell_always_quoting_style, /* --quoting-style=shell-always */ - c_quoting_style, /* --quoting-style=c */ - escape_quoting_style, /* --quoting-style=escape */ - locale_quoting_style, /* --quoting-style=locale */ - clocale_quoting_style /* --quoting-style=clocale */ - }; - -/* For now, --quoting-style=literal is the default, but this may change. */ -#ifndef DEFAULT_QUOTING_STYLE -# define DEFAULT_QUOTING_STYLE literal_quoting_style -#endif - -/* Names of quoting styles and their corresponding values. */ -extern char const *const quoting_style_args[]; -extern enum quoting_style const quoting_style_vals[]; - -struct quoting_options; - -#ifndef PARAMS -# if defined PROTOTYPES || defined __STDC__ -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -#endif - -/* The functions listed below set and use a hidden variable - that contains the default quoting style options. */ - -/* Allocate a new set of quoting options, with contents initially identical - to O if O is not null, or to the default if O is null. - It is the caller's responsibility to free the result. */ -struct quoting_options *clone_quoting_options - PARAMS ((struct quoting_options *o)); - -/* Get the value of O's quoting style. If O is null, use the default. */ -enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o)); - -/* In O (or in the default if O is null), - set the value of the quoting style to S. */ -void set_quoting_style PARAMS ((struct quoting_options *o, - enum quoting_style s)); - -/* In O (or in the default if O is null), - set the value of the quoting options for character C to I. - Return the old value. Currently, the only values defined for I are - 0 (the default) and 1 (which means to quote the character even if - it would not otherwise be quoted). */ -int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i)); - -/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of - argument ARG (of size ARGSIZE), using O to control quoting. - If O is null, use the default. - Terminate the output with a null character, and return the written - size of the output, not counting the terminating null. - If BUFFERSIZE is too small to store the output string, return the - value that would have been returned had BUFFERSIZE been large enough. - If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */ -size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize, - char const *arg, size_t argsize, - struct quoting_options const *o)); - -/* Use storage slot N to return a quoted version of the string ARG. - Use the default quoting options. - The returned value points to static storage that can be - reused by the next call to this function with the same value of N. - N must be nonnegative. */ -char *quotearg_n PARAMS ((unsigned int n, char const *arg)); - -/* Equivalent to quotearg_n (0, ARG). */ -char *quotearg PARAMS ((char const *arg)); - -/* Use style S and storage slot N to return a quoted version of the string ARG. - This is like quotearg_n (N, ARG), except that it uses S with no other - options to specify the quoting method. */ -char *quotearg_n_style PARAMS ((unsigned int n, enum quoting_style s, - char const *arg)); - -/* Equivalent to quotearg_n_style (0, S, ARG). */ -char *quotearg_style PARAMS ((enum quoting_style s, char const *arg)); - -/* Like quotearg (ARG), except also quote any instances of CH. */ -char *quotearg_char PARAMS ((char const *arg, char ch)); - -/* Equivalent to quotearg_char (ARG, ':'). */ -char *quotearg_colon PARAMS ((char const *arg)); diff --git a/gnu/usr.bin/grep/savedir.c b/gnu/usr.bin/grep/savedir.c deleted file mode 100644 index 9b37894f1dd..00000000000 --- a/gnu/usr.bin/grep/savedir.c +++ /dev/null @@ -1,183 +0,0 @@ -/* savedir.c -- save the list of files in a directory in a string - Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by David MacKenzie . */ - -#include -__FBSDID("$FreeBSD: stable/11/gnu/usr.bin/grep/savedir.c 290350 2015-11-04 05:38:08Z rodrigc $"); - -#if HAVE_CONFIG_H -# include -#endif - -#include - -#if HAVE_UNISTD_H -# include -#endif - -#if HAVE_DIRENT_H -# include -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -# define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen -# if HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -#endif - -#ifdef CLOSEDIR_VOID -/* Fake a return value. */ -# define CLOSEDIR(d) (closedir (d), 0) -#else -# define CLOSEDIR(d) closedir (d) -#endif - -#ifdef STDC_HEADERS -# include -# include -#else -char *malloc (); -char *realloc (); -#endif -#ifndef NULL -# define NULL 0 -#endif - -#ifndef stpcpy -char *stpcpy (); -#endif - -#include -#include "savedir.h" -#include "system.h" - -char *path; -size_t pathlen; - -static int -isdir1 (const char *dir, const char *file) -{ - int status; - int slash; - size_t dirlen = strlen (dir); - size_t filelen = strlen (file); - if ((dirlen + filelen + 2) > pathlen) - { - path = calloc (dirlen + 1 + filelen + 1, sizeof (*path)); - pathlen = dirlen + filelen + 2; - } - strcpy (path, dir); - slash = (path[dirlen] != '/'); - path[dirlen] = '/'; - strcpy (path + dirlen + slash , file); - status = isdir (path); - return status; -} - -/* Return a freshly allocated string containing the filenames - in directory DIR, separated by '\0' characters; - the end is marked by two '\0' characters in a row. - NAME_SIZE is the number of bytes to initially allocate - for the string; it will be enlarged as needed. - Return NULL if DIR cannot be opened or if out of memory. */ -char * -savedir (const char *dir, off_t name_size, struct exclude *included_patterns, - struct exclude *excluded_patterns) -{ - DIR *dirp; - struct dirent *dp; - char *name_space; - char *namep; - - dirp = opendir (dir); - if (dirp == NULL) - return NULL; - - /* Be sure name_size is at least `1' so there's room for - the final NUL byte. */ - if (name_size <= 0) - name_size = 1; - - name_space = (char *) malloc (name_size); - if (name_space == NULL) - { - closedir (dirp); - return NULL; - } - namep = name_space; - - while ((dp = readdir (dirp)) != NULL) - { - /* Skip "." and ".." (some NFS filesystems' directories lack them). */ - if (dp->d_name[0] != '.' - || (dp->d_name[1] != '\0' - && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) - { - off_t size_needed = (namep - name_space) + NAMLEN (dp) + 2; - - if ((included_patterns || excluded_patterns) - && !isdir1 (dir, dp->d_name)) - { - if (included_patterns - && !excluded_filename (included_patterns, path, 0)) - continue; - if (excluded_patterns - && excluded_filename (excluded_patterns, path, 0)) - continue; - } - - if (size_needed > name_size) - { - char *new_name_space; - - while (size_needed > name_size) - name_size += 1024; - - new_name_space = realloc (name_space, name_size); - if (new_name_space == NULL) - { - closedir (dirp); - return NULL; - } - namep += new_name_space - name_space; - name_space = new_name_space; - } - namep = stpcpy (namep, dp->d_name) + 1; - } - } - *namep = '\0'; - if (CLOSEDIR (dirp)) - { - free (name_space); - return NULL; - } - if (path) - { - free (path); - path = NULL; - pathlen = 0; - } - return name_space; -} diff --git a/gnu/usr.bin/grep/savedir.h b/gnu/usr.bin/grep/savedir.h deleted file mode 100644 index 49c331b587b..00000000000 --- a/gnu/usr.bin/grep/savedir.h +++ /dev/null @@ -1,18 +0,0 @@ -#if !defined SAVEDIR_H_ -# define SAVEDIR_H_ - -#include "exclude.h" - -# ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -# endif - -extern char * -savedir PARAMS ((const char *dir, off_t name_size, - struct exclude *, struct exclude *)); - -#endif diff --git a/gnu/usr.bin/grep/search.c b/gnu/usr.bin/grep/search.c deleted file mode 100644 index dfbad2bb633..00000000000 --- a/gnu/usr.bin/grep/search.c +++ /dev/null @@ -1,1303 +0,0 @@ -/* search.c - searching subroutines using dfa, kwset and regex for grep. - Copyright 1992, 1998, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* Written August 1992 by Mike Haertel. */ - -/* $FreeBSD: stable/11/gnu/usr.bin/grep/search.c 343989 2019-02-10 23:47:37Z pfg $ */ - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif -#ifdef HAVE_CONFIG_H -# include -#endif -#include -#include -#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC -/* We can handle multibyte string. */ -# define MBS_SUPPORT -# include -# include -#endif - -#include "system.h" -#include "grep.h" -#include "regex.h" -#include "dfa.h" -#include "kwset.h" -#include "error.h" -#include "xalloc.h" -#ifdef HAVE_LIBPCRE -# include -#endif -#ifdef HAVE_LANGINFO_CODESET -# include -#endif - -#define NCHAR (UCHAR_MAX + 1) - -/* For -w, we also consider _ to be word constituent. */ -#define WCHAR(C) (ISALNUM(C) || (C) == '_') - -/* DFA compiled regexp. */ -static struct dfa dfa; - -/* The Regex compiled patterns. */ -static struct patterns -{ - /* Regex compiled regexp. */ - struct re_pattern_buffer regexbuf; - struct re_registers regs; /* This is here on account of a BRAIN-DEAD - Q@#%!# library interface in regex.c. */ -} patterns0; - -struct patterns *patterns; -size_t pcount; - -/* KWset compiled pattern. For Ecompile and Gcompile, we compile - a list of strings, at least one of which is known to occur in - any string matching the regexp. */ -static kwset_t kwset; - -/* Number of compiled fixed strings known to exactly match the regexp. - If kwsexec returns < kwset_exact_matches, then we don't need to - call the regexp matcher at all. */ -static int kwset_exact_matches; - -/* UTF-8 encoding allows some optimizations that we can't otherwise - assume in a multibyte encoding. */ -static int using_utf8; - -static void kwsinit PARAMS ((void)); -static void kwsmusts PARAMS ((void)); -static void Gcompile PARAMS ((char const *, size_t)); -static void Ecompile PARAMS ((char const *, size_t)); -static size_t EGexecute PARAMS ((char const *, size_t, size_t *, int )); -static void Fcompile PARAMS ((char const *, size_t)); -static size_t Fexecute PARAMS ((char const *, size_t, size_t *, int)); -static void Pcompile PARAMS ((char const *, size_t )); -static size_t Pexecute PARAMS ((char const *, size_t, size_t *, int)); - -void -check_utf8 (void) -{ -#ifdef HAVE_LANGINFO_CODESET - if (strcmp (nl_langinfo (CODESET), "UTF-8") == 0) - using_utf8 = 1; -#endif -} - -void -dfaerror (char const *mesg) -{ - error (2, 0, mesg); -} - -static void -kwsinit (void) -{ - static char trans[NCHAR]; - size_t i; - - if (match_icase) - for (i = 0; i < NCHAR; ++i) - trans[i] = TOLOWER (i); - - if (!(kwset = kwsalloc (match_icase ? trans : (char *) 0))) - error (2, 0, _("memory exhausted")); -} - -/* If the DFA turns out to have some set of fixed strings one of - which must occur in the match, then we build a kwset matcher - to find those strings, and thus quickly filter out impossible - matches. */ -static void -kwsmusts (void) -{ - struct dfamust const *dm; - char const *err; - - if (dfa.musts) - { - kwsinit (); - /* First, we compile in the substrings known to be exact - matches. The kwset matcher will return the index - of the matching string that it chooses. */ - for (dm = dfa.musts; dm; dm = dm->next) - { - if (!dm->exact) - continue; - ++kwset_exact_matches; - if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0) - error (2, 0, err); - } - /* Now, we compile the substrings that will require - the use of the regexp matcher. */ - for (dm = dfa.musts; dm; dm = dm->next) - { - if (dm->exact) - continue; - if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0) - error (2, 0, err); - } - if ((err = kwsprep (kwset)) != 0) - error (2, 0, err); - } -} - -static void -Gcompile (char const *pattern, size_t size) -{ - const char *err; - char const *sep; - size_t total = size; - char const *motif = pattern; - - check_utf8 (); - re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE | (match_icase ? RE_ICASE : 0)); - dfasyntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE, match_icase, eolbyte); - - /* For GNU regex compiler we have to pass the patterns separately to detect - errors like "[\nallo\n]\n". The patterns here are "[", "allo" and "]" - GNU regex should have raise a syntax error. The same for backref, where - the backref should have been local to each pattern. */ - do - { - size_t len; - sep = memchr (motif, '\n', total); - if (sep) - { - len = sep - motif; - sep++; - total -= (len + 1); - } - else - { - len = total; - total = 0; - } - - patterns = realloc (patterns, (pcount + 1) * sizeof (*patterns)); - if (patterns == NULL) - error (2, errno, _("memory exhausted")); - - patterns[pcount] = patterns0; - - if ((err = re_compile_pattern (motif, len, - &(patterns[pcount].regexbuf))) != 0) - error (2, 0, err); - pcount++; - - motif = sep; - } while (sep && total != 0); - - /* In the match_words and match_lines cases, we use a different pattern - for the DFA matcher that will quickly throw out cases that won't work. - Then if DFA succeeds we do some hairy stuff using the regex matcher - to decide whether the match should really count. */ - if (match_words || match_lines) - { - /* In the whole-word case, we use the pattern: - \(^\|[^[:alnum:]_]\)\(userpattern\)\([^[:alnum:]_]|$\). - In the whole-line case, we use the pattern: - ^\(userpattern\)$. */ - - static char const line_beg[] = "^\\("; - static char const line_end[] = "\\)$"; - static char const word_beg[] = "\\(^\\|[^[:alnum:]_]\\)\\("; - static char const word_end[] = "\\)\\([^[:alnum:]_]\\|$\\)"; - char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end); - size_t i; - strcpy (n, match_lines ? line_beg : word_beg); - i = strlen (n); - memcpy (n + i, pattern, size); - i += size; - strcpy (n + i, match_lines ? line_end : word_end); - i += strlen (n + i); - pattern = n; - size = i; - } - - dfacomp (pattern, size, &dfa, 1); - kwsmusts (); -} - -static void -Ecompile (char const *pattern, size_t size) -{ - const char *err; - const char *sep; - size_t total = size; - char const *motif = pattern; - - check_utf8 (); - if (strcmp (matcher, "awk") == 0) - { - re_set_syntax (RE_SYNTAX_AWK | (match_icase ? RE_ICASE : 0)); - dfasyntax (RE_SYNTAX_AWK, match_icase, eolbyte); - } - else - { - re_set_syntax (RE_SYNTAX_POSIX_EGREP | (match_icase ? RE_ICASE : 0)); - dfasyntax (RE_SYNTAX_POSIX_EGREP, match_icase, eolbyte); - } - - /* For GNU regex compiler we have to pass the patterns separately to detect - errors like "[\nallo\n]\n". The patterns here are "[", "allo" and "]" - GNU regex should have raise a syntax error. The same for backref, where - the backref should have been local to each pattern. */ - do - { - size_t len; - sep = memchr (motif, '\n', total); - if (sep) - { - len = sep - motif; - sep++; - total -= (len + 1); - } - else - { - len = total; - total = 0; - } - - patterns = realloc (patterns, (pcount + 1) * sizeof (*patterns)); - if (patterns == NULL) - error (2, errno, _("memory exhausted")); - patterns[pcount] = patterns0; - - if ((err = re_compile_pattern (motif, len, - &(patterns[pcount].regexbuf))) != 0) - error (2, 0, err); - pcount++; - - motif = sep; - } while (sep && total != 0); - - /* In the match_words and match_lines cases, we use a different pattern - for the DFA matcher that will quickly throw out cases that won't work. - Then if DFA succeeds we do some hairy stuff using the regex matcher - to decide whether the match should really count. */ - if (match_words || match_lines) - { - /* In the whole-word case, we use the pattern: - (^|[^[:alnum:]_])(userpattern)([^[:alnum:]_]|$). - In the whole-line case, we use the pattern: - ^(userpattern)$. */ - - static char const line_beg[] = "^("; - static char const line_end[] = ")$"; - static char const word_beg[] = "(^|[^[:alnum:]_])("; - static char const word_end[] = ")([^[:alnum:]_]|$)"; - char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end); - size_t i; - strcpy (n, match_lines ? line_beg : word_beg); - i = strlen(n); - memcpy (n + i, pattern, size); - i += size; - strcpy (n + i, match_lines ? line_end : word_end); - i += strlen (n + i); - pattern = n; - size = i; - } - - dfacomp (pattern, size, &dfa, 1); - kwsmusts (); -} - -static size_t -EGexecute (char const *buf, size_t size, size_t *match_size, int exact) -{ - register char const *buflim, *beg, *end; - char eol = eolbyte; - int backref; - ptrdiff_t start, len; - struct kwsmatch kwsm; - size_t i, ret_val; - static int use_dfa; - static int use_dfa_checked = 0; -#ifdef MBS_SUPPORT - const char *last_char = NULL; - int mb_cur_max = MB_CUR_MAX; - mbstate_t mbs; - memset (&mbs, '\0', sizeof (mbstate_t)); -#endif /* MBS_SUPPORT */ - - if (!use_dfa_checked) - { - char *grep_use_dfa = getenv ("GREP_USE_DFA"); - if (!grep_use_dfa) - { -#ifdef MBS_SUPPORT - /* Turn off DFA when processing multibyte input. */ - use_dfa = (MB_CUR_MAX == 1); -#else - use_dfa = 1; -#endif /* MBS_SUPPORT */ - } - else - { - use_dfa = atoi (grep_use_dfa); - } - - use_dfa_checked = 1; - } - - buflim = buf + size; - - for (beg = end = buf; end < buflim; beg = end) - { - if (!exact) - { - if (kwset) - { - /* Find a possible match using the KWset matcher. */ -#ifdef MBS_SUPPORT - size_t bytes_left = 0; -#endif /* MBS_SUPPORT */ - size_t offset; -#ifdef MBS_SUPPORT - /* kwsexec doesn't work with match_icase and multibyte input. */ - if (match_icase && mb_cur_max > 1) - /* Avoid kwset */ - offset = 0; - else -#endif /* MBS_SUPPORT */ - offset = kwsexec (kwset, beg, buflim - beg, &kwsm); - if (offset == (size_t) -1) - goto failure; -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && !using_utf8) - { - bytes_left = offset; - while (bytes_left) - { - size_t mlen = mbrlen (beg, bytes_left, &mbs); - - last_char = beg; - if (mlen == (size_t) -1 || mlen == 0) - { - /* Incomplete character: treat as single-byte. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - beg++; - bytes_left--; - continue; - } - - if (mlen == (size_t) -2) - { - /* Offset points inside multibyte character: - * no good. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - break; - } - - beg += mlen; - bytes_left -= mlen; - } - } - else -#endif /* MBS_SUPPORT */ - beg += offset; - /* Narrow down to the line containing the candidate, and - run it through DFA. */ - end = memchr(beg, eol, buflim - beg); - end++; -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && bytes_left) - continue; -#endif /* MBS_SUPPORT */ - while (beg > buf && beg[-1] != eol) - --beg; - if ( -#ifdef MBS_SUPPORT - !(match_icase && mb_cur_max > 1) && -#endif /* MBS_SUPPORT */ - (kwsm.index < kwset_exact_matches)) - goto success_in_beg_and_end; - if (use_dfa && - dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) - continue; - } - else - { - /* No good fixed strings; start with DFA. */ -#ifdef MBS_SUPPORT - size_t bytes_left = 0; -#endif /* MBS_SUPPORT */ - size_t offset = 0; - if (use_dfa) - offset = dfaexec (&dfa, beg, buflim - beg, &backref); - if (offset == (size_t) -1) - break; - /* Narrow down to the line we've found. */ -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && !using_utf8) - { - bytes_left = offset; - while (bytes_left) - { - size_t mlen = mbrlen (beg, bytes_left, &mbs); - - last_char = beg; - if (mlen == (size_t) -1 || mlen == 0) - { - /* Incomplete character: treat as single-byte. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - beg++; - bytes_left--; - continue; - } - - if (mlen == (size_t) -2) - { - /* Offset points inside multibyte character: - * no good. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - break; - } - - beg += mlen; - bytes_left -= mlen; - } - } - else -#endif /* MBS_SUPPORT */ - beg += offset; - end = memchr (beg, eol, buflim - beg); - end++; -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && bytes_left) - continue; -#endif /* MBS_SUPPORT */ - while (beg > buf && beg[-1] != eol) - --beg; - } - /* Successful, no backreferences encountered! */ - if (use_dfa && !backref) - goto success_in_beg_and_end; - } - else - end = beg + size; - - /* If we've made it to this point, this means DFA has seen - a probable match, and we need to run it through Regex. */ - for (i = 0; i < pcount; i++) - { - patterns[i].regexbuf.not_eol = 0; - if (0 <= (start = re_search (&(patterns[i].regexbuf), beg, - end - beg - 1, 0, - end - beg - 1, &(patterns[i].regs)))) - { - len = patterns[i].regs.end[0] - start; - if (exact && !match_words) - goto success_in_start_and_len; - if ((!match_lines && !match_words) - || (match_lines && len == end - beg - 1)) - goto success_in_beg_and_end; - /* If -w, check if the match aligns with word boundaries. - We do this iteratively because: - (a) the line may contain more than one occurence of the - pattern, and - (b) Several alternatives in the pattern might be valid at a - given point, and we may need to consider a shorter one to - find a word boundary. */ - if (match_words) - while (start >= 0) - { - int lword_match = 0; - if (start == 0) - lword_match = 1; - else - { - assert (start > 0); -#ifdef MBS_SUPPORT - if (mb_cur_max > 1) - { - const char *s; - size_t mr; - wchar_t pwc; - - /* Locate the start of the multibyte character - before the match position (== beg + start). */ - if (using_utf8) - { - /* UTF-8 is a special case: scan backwards - until we find a 7-bit character or a - lead byte. */ - s = beg + start - 1; - while (s > buf - && (unsigned char) *s >= 0x80 - && (unsigned char) *s <= 0xbf) - --s; - } - else - { - /* Scan forwards to find the start of the - last complete character before the - match position. */ - size_t bytes_left = start - 1; - s = beg; - while (bytes_left > 0) - { - mr = mbrlen (s, bytes_left, &mbs); - if (mr == (size_t) -1 || mr == 0) - { - memset (&mbs, '\0', sizeof (mbs)); - s++; - bytes_left--; - continue; - } - if (mr == (size_t) -2) - { - memset (&mbs, '\0', sizeof (mbs)); - break; - } - s += mr; - bytes_left -= mr; - } - } - mr = mbrtowc (&pwc, s, beg + start - s, &mbs); - if (mr == (size_t) -2 || mr == (size_t) -1 || - mr == 0) - { - memset (&mbs, '\0', sizeof (mbstate_t)); - lword_match = 1; - } - else if (!(iswalnum (pwc) || pwc == L'_') - && mr == beg + start - s) - lword_match = 1; - } - else -#endif /* MBS_SUPPORT */ - if (!WCHAR ((unsigned char) beg[start - 1])) - lword_match = 1; - } - - if (lword_match) - { - int rword_match = 0; - if (start + len == end - beg - 1) - rword_match = 1; - else - { -#ifdef MBS_SUPPORT - if (mb_cur_max > 1) - { - wchar_t nwc; - int mr; - - mr = mbtowc (&nwc, beg + start + len, - end - beg - start - len - 1); - if (mr <= 0) - { - memset (&mbs, '\0', sizeof (mbstate_t)); - rword_match = 1; - } - else if (!iswalnum (nwc) && nwc != L'_') - rword_match = 1; - } - else -#endif /* MBS_SUPPORT */ - if (!WCHAR ((unsigned char) beg[start + len])) - rword_match = 1; - } - - if (rword_match) - { - if (!exact) - /* Returns the whole line. */ - goto success_in_beg_and_end; - else - /* Returns just this word match. */ - goto success_in_start_and_len; - } - } - if (len > 0) - { - /* Try a shorter length anchored at the same place. */ - --len; - patterns[i].regexbuf.not_eol = 1; - len = re_match (&(patterns[i].regexbuf), beg, - start + len, start, - &(patterns[i].regs)); - } - if (len <= 0) - { - /* Try looking further on. */ - if (start == end - beg - 1) - break; - ++start; - patterns[i].regexbuf.not_eol = 0; - start = re_search (&(patterns[i].regexbuf), beg, - end - beg - 1, - start, end - beg - 1 - start, - &(patterns[i].regs)); - len = patterns[i].regs.end[0] - start; - } - } - } - } /* for Regex patterns. */ - } /* for (beg = end ..) */ - - failure: - return (size_t) -1; - - success_in_beg_and_end: - len = end - beg; - start = beg - buf; - /* FALLTHROUGH */ - - success_in_start_and_len: - *match_size = len; - return start; -} - -#ifdef MBS_SUPPORT -static int f_i_multibyte; /* whether we're using the new -Fi MB method */ -static struct -{ - wchar_t **patterns; - size_t count, maxlen; - unsigned char *match; -} Fimb; -#endif - -static void -Fcompile (char const *pattern, size_t size) -{ - int mb_cur_max = MB_CUR_MAX; - char const *beg, *lim, *err; - - check_utf8 (); -#ifdef MBS_SUPPORT - /* Support -F -i for UTF-8 input. */ - if (match_icase && mb_cur_max > 1) - { - mbstate_t mbs; - wchar_t *wcpattern = xmalloc ((size + 1) * sizeof (wchar_t)); - const char *patternend = pattern; - size_t wcsize; - kwset_t fimb_kwset = NULL; - char *starts = NULL; - wchar_t *wcbeg, *wclim; - size_t allocated = 0; - - memset (&mbs, '\0', sizeof (mbs)); -# ifdef __GNU_LIBRARY__ - wcsize = mbsnrtowcs (wcpattern, &patternend, size, size, &mbs); - if (patternend != pattern + size) - wcsize = (size_t) -1; -# else - { - char *patterncopy = xmalloc (size + 1); - - memcpy (patterncopy, pattern, size); - patterncopy[size] = '\0'; - patternend = patterncopy; - wcsize = mbsrtowcs (wcpattern, &patternend, size, &mbs); - if (patternend != patterncopy + size) - wcsize = (size_t) -1; - free (patterncopy); - } -# endif - if (wcsize + 2 <= 2) - { -fimb_fail: - free (wcpattern); - free (starts); - if (fimb_kwset) - kwsfree (fimb_kwset); - free (Fimb.patterns); - Fimb.patterns = NULL; - } - else - { - if (!(fimb_kwset = kwsalloc (NULL))) - error (2, 0, _("memory exhausted")); - - starts = xmalloc (mb_cur_max * 3); - wcbeg = wcpattern; - do - { - int i; - size_t wclen; - - if (Fimb.count >= allocated) - { - if (allocated == 0) - allocated = 128; - else - allocated *= 2; - Fimb.patterns = xrealloc (Fimb.patterns, - sizeof (wchar_t *) * allocated); - } - Fimb.patterns[Fimb.count++] = wcbeg; - for (wclim = wcbeg; - wclim < wcpattern + wcsize && *wclim != L'\n'; ++wclim) - *wclim = towlower (*wclim); - *wclim = L'\0'; - wclen = wclim - wcbeg; - if (wclen > Fimb.maxlen) - Fimb.maxlen = wclen; - if (wclen > 3) - wclen = 3; - if (wclen == 0) - { - if ((err = kwsincr (fimb_kwset, "", 0)) != 0) - error (2, 0, err); - } - else - for (i = 0; i < (1 << wclen); i++) - { - char *p = starts; - int j, k; - - for (j = 0; j < wclen; ++j) - { - wchar_t wc = wcbeg[j]; - if (i & (1 << j)) - { - wc = towupper (wc); - if (wc == wcbeg[j]) - continue; - } - k = wctomb (p, wc); - if (k <= 0) - goto fimb_fail; - p += k; - } - if ((err = kwsincr (fimb_kwset, starts, p - starts)) != 0) - error (2, 0, err); - } - if (wclim < wcpattern + wcsize) - ++wclim; - wcbeg = wclim; - } - while (wcbeg < wcpattern + wcsize); - f_i_multibyte = 1; - kwset = fimb_kwset; - free (starts); - Fimb.match = xmalloc (Fimb.count); - if ((err = kwsprep (kwset)) != 0) - error (2, 0, err); - return; - } - } -#endif /* MBS_SUPPORT */ - - - kwsinit (); - beg = pattern; - do - { - for (lim = beg; lim < pattern + size && *lim != '\n'; ++lim) - ; - if ((err = kwsincr (kwset, beg, lim - beg)) != 0) - error (2, 0, err); - if (lim < pattern + size) - ++lim; - beg = lim; - } - while (beg < pattern + size); - - if ((err = kwsprep (kwset)) != 0) - error (2, 0, err); -} - -#ifdef MBS_SUPPORT -static int -Fimbexec (const char *buf, size_t size, size_t *plen, int exact) -{ - size_t len, letter, i; - int ret = -1; - mbstate_t mbs; - wchar_t wc; - int patterns_left; - - assert (match_icase && f_i_multibyte == 1); - assert (MB_CUR_MAX > 1); - - memset (&mbs, '\0', sizeof (mbs)); - memset (Fimb.match, '\1', Fimb.count); - letter = len = 0; - patterns_left = 1; - while (patterns_left && len <= size) - { - size_t c; - - patterns_left = 0; - if (len < size) - { - c = mbrtowc (&wc, buf + len, size - len, &mbs); - if (c + 2 <= 2) - return ret; - - wc = towlower (wc); - } - else - { - c = 1; - wc = L'\0'; - } - - for (i = 0; i < Fimb.count; i++) - { - if (Fimb.match[i]) - { - if (Fimb.patterns[i][letter] == L'\0') - { - /* Found a match. */ - *plen = len; - if (!exact && !match_words) - return 0; - else - { - /* For -w or exact look for longest match. */ - ret = 0; - Fimb.match[i] = '\0'; - continue; - } - } - - if (Fimb.patterns[i][letter] == wc) - patterns_left = 1; - else - Fimb.match[i] = '\0'; - } - } - - len += c; - letter++; - } - - return ret; -} -#endif /* MBS_SUPPORT */ - -static size_t -Fexecute (char const *buf, size_t size, size_t *match_size, int exact) -{ - register char const *beg, *try, *end; - register size_t len; - char eol = eolbyte; - struct kwsmatch kwsmatch; - size_t ret_val; -#ifdef MBS_SUPPORT - int mb_cur_max = MB_CUR_MAX; - mbstate_t mbs; - memset (&mbs, '\0', sizeof (mbstate_t)); - const char *last_char = NULL; -#endif /* MBS_SUPPORT */ - - for (beg = buf; beg <= buf + size; ++beg) - { - size_t offset; - offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch); - - if (offset == (size_t) -1) - goto failure; -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && !using_utf8) - { - size_t bytes_left = offset; - while (bytes_left) - { - size_t mlen = mbrlen (beg, bytes_left, &mbs); - - last_char = beg; - if (mlen == (size_t) -1 || mlen == 0) - { - /* Incomplete character: treat as single-byte. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - beg++; - bytes_left--; - continue; - } - - if (mlen == (size_t) -2) - { - /* Offset points inside multibyte character: no good. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - break; - } - - beg += mlen; - bytes_left -= mlen; - } - - if (bytes_left) - { - beg += bytes_left; - continue; - } - } - else -#endif /* MBS_SUPPORT */ - beg += offset; -#ifdef MBS_SUPPORT - /* For f_i_multibyte, the string at beg now matches first 3 chars of - one of the search strings (less if there are shorter search strings). - See if this is a real match. */ - if (f_i_multibyte - && Fimbexec (beg, buf + size - beg, &kwsmatch.size[0], exact)) - goto next_char; -#endif /* MBS_SUPPORT */ - len = kwsmatch.size[0]; - if (exact && !match_words) - goto success_in_beg_and_len; - if (match_lines) - { - if (beg > buf && beg[-1] != eol) - goto next_char; - if (beg + len < buf + size && beg[len] != eol) - goto next_char; - goto success; - } - else if (match_words) - { - while (1) - { - int word_match = 0; - if (beg > buf) - { -#ifdef MBS_SUPPORT - if (mb_cur_max > 1) - { - const char *s; - int mr; - wchar_t pwc; - - if (using_utf8) - { - s = beg - 1; - while (s > buf - && (unsigned char) *s >= 0x80 - && (unsigned char) *s <= 0xbf) - --s; - } - else - s = last_char; - mr = mbtowc (&pwc, s, beg - s); - if (mr <= 0) - memset (&mbs, '\0', sizeof (mbstate_t)); - else if ((iswalnum (pwc) || pwc == L'_') - && mr == (int) (beg - s)) - goto next_char; - } - else -#endif /* MBS_SUPPORT */ - if (WCHAR ((unsigned char) beg[-1])) - goto next_char; - } -#ifdef MBS_SUPPORT - if (mb_cur_max > 1) - { - wchar_t nwc; - int mr; - - mr = mbtowc (&nwc, beg + len, buf + size - beg - len); - if (mr <= 0) - { - memset (&mbs, '\0', sizeof (mbstate_t)); - word_match = 1; - } - else if (!iswalnum (nwc) && nwc != L'_') - word_match = 1; - } - else -#endif /* MBS_SUPPORT */ - if (beg + len >= buf + size || !WCHAR ((unsigned char) beg[len])) - word_match = 1; - if (word_match) - { - if (!exact) - /* Returns the whole line now we know there's a word match. */ - goto success; - else - /* Returns just this word match. */ - goto success_in_beg_and_len; - } - if (len > 0) - { - /* Try a shorter length anchored at the same place. */ - --len; - offset = kwsexec (kwset, beg, len, &kwsmatch); - - if (offset == -1) - goto next_char; /* Try a different anchor. */ -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && !using_utf8) - { - size_t bytes_left = offset; - while (bytes_left) - { - size_t mlen = mbrlen (beg, bytes_left, &mbs); - - last_char = beg; - if (mlen == (size_t) -1 || mlen == 0) - { - /* Incomplete character: treat as single-byte. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - beg++; - bytes_left--; - continue; - } - - if (mlen == (size_t) -2) - { - /* Offset points inside multibyte character: - * no good. */ - memset (&mbs, '\0', sizeof (mbstate_t)); - break; - } - - beg += mlen; - bytes_left -= mlen; - } - - if (bytes_left) - { - memset (&mbs, '\0', sizeof (mbstate_t)); - goto next_char; /* Try a different anchor. */ - } - } - else -#endif /* MBS_SUPPORT */ - beg += offset; -#ifdef MBS_SUPPORT - /* The string at beg now matches first 3 chars of one of - the search strings (less if there are shorter search - strings). See if this is a real match. */ - if (f_i_multibyte - && Fimbexec (beg, len - offset, &kwsmatch.size[0], - exact)) - goto next_char; -#endif /* MBS_SUPPORT */ - len = kwsmatch.size[0]; - } - } - } - else - goto success; -next_char:; -#ifdef MBS_SUPPORT - /* Advance to next character. For MB_CUR_MAX == 1 case this is handled - by ++beg above. */ - if (mb_cur_max > 1) - { - if (using_utf8) - { - unsigned char c = *beg; - if (c >= 0xc2) - { - if (c < 0xe0) - ++beg; - else if (c < 0xf0) - beg += 2; - else if (c < 0xf8) - beg += 3; - else if (c < 0xfc) - beg += 4; - else if (c < 0xfe) - beg += 5; - } - } - else - { - size_t l = mbrlen (beg, buf + size - beg, &mbs); - - last_char = beg; - if (l + 2 >= 2) - beg += l - 1; - else - memset (&mbs, '\0', sizeof (mbstate_t)); - } - } -#endif /* MBS_SUPPORT */ - } - - failure: - return -1; - - success: -#ifdef MBS_SUPPORT - if (mb_cur_max > 1 && !using_utf8) - { - end = beg + len; - while (end < buf + size) - { - size_t mlen = mbrlen (end, buf + size - end, &mbs); - if (mlen == (size_t) -1 || mlen == (size_t) -2 || mlen == 0) - { - memset (&mbs, '\0', sizeof (mbstate_t)); - mlen = 1; - } - if (mlen == 1 && *end == eol) - break; - - end += mlen; - } - } - else -#endif /* MBS_SUPPORT */ - end = memchr (beg + len, eol, (buf + size) - (beg + len)); - - end++; - while (buf < beg && beg[-1] != eol) - --beg; - len = end - beg; - /* FALLTHROUGH */ - - success_in_beg_and_len: - *match_size = len; - return beg - buf; -} - -#if HAVE_LIBPCRE -/* Compiled internal form of a Perl regular expression. */ -static pcre *cre; - -/* Additional information about the pattern. */ -static pcre_extra *extra; -#endif - -static void -Pcompile (char const *pattern, size_t size) -{ -#if !HAVE_LIBPCRE - error (2, 0, _("The -P option is not supported")); -#else - int e; - char const *ep; - char *re = xmalloc (4 * size + 7); - int flags = PCRE_MULTILINE | (match_icase ? PCRE_CASELESS : 0); - char const *patlim = pattern + size; - char *n = re; - char const *p; - char const *pnul; - - /* FIXME: Remove this restriction. */ - if (eolbyte != '\n') - error (2, 0, _("The -P and -z options cannot be combined")); - - *n = '\0'; - if (match_lines) - strcpy (n, "^("); - if (match_words) - strcpy (n, "\\b("); - n += strlen (n); - - /* The PCRE interface doesn't allow NUL bytes in the pattern, so - replace each NUL byte in the pattern with the four characters - "\000", removing a preceding backslash if there are an odd - number of backslashes before the NUL. - - FIXME: This method does not work with some multibyte character - encodings, notably Shift-JIS, where a multibyte character can end - in a backslash byte. */ - for (p = pattern; (pnul = memchr (p, '\0', patlim - p)); p = pnul + 1) - { - memcpy (n, p, pnul - p); - n += pnul - p; - for (p = pnul; pattern < p && p[-1] == '\\'; p--) - continue; - n -= (pnul - p) & 1; - strcpy (n, "\\000"); - n += 4; - } - - memcpy (n, p, patlim - p); - n += patlim - p; - *n = '\0'; - if (match_words) - strcpy (n, ")\\b"); - if (match_lines) - strcpy (n, ")$"); - - cre = pcre_compile (re, flags, &ep, &e, pcre_maketables ()); - if (!cre) - error (2, 0, ep); - - extra = pcre_study (cre, 0, &ep); - if (ep) - error (2, 0, ep); - - free (re); -#endif -} - -static size_t -Pexecute (char const *buf, size_t size, size_t *match_size, int exact) -{ -#if !HAVE_LIBPCRE - abort (); - return -1; -#else - /* This array must have at least two elements; everything after that - is just for performance improvement in pcre_exec. */ - int sub[300]; - - int e = pcre_exec (cre, extra, buf, size, 0, 0, - sub, sizeof sub / sizeof *sub); - - if (e <= 0) - { - switch (e) - { - case PCRE_ERROR_NOMATCH: - return -1; - - case PCRE_ERROR_NOMEMORY: - error (2, 0, _("Memory exhausted")); - - default: - abort (); - } - } - else - { - /* Narrow down to the line we've found. */ - char const *beg = buf + sub[0]; - char const *end = buf + sub[1]; - char const *buflim = buf + size; - char eol = eolbyte; - if (!exact) - { - end = memchr (end, eol, buflim - end); - end++; - while (buf < beg && beg[-1] != eol) - --beg; - } - - *match_size = end - beg; - return beg - buf; - } -#endif -} - -struct matcher const matchers[] = { - { "default", Gcompile, EGexecute }, - { "grep", Gcompile, EGexecute }, - { "egrep", Ecompile, EGexecute }, - { "awk", Ecompile, EGexecute }, - { "fgrep", Fcompile, Fexecute }, - { "perl", Pcompile, Pexecute }, - { "", 0, 0 }, -}; diff --git a/gnu/usr.bin/grep/system.h b/gnu/usr.bin/grep/system.h deleted file mode 100644 index 99906d8aaf7..00000000000 --- a/gnu/usr.bin/grep/system.h +++ /dev/null @@ -1,206 +0,0 @@ -/* Portability cruft. Include after config.h and sys/types.h. - Copyright 1996, 1998, 1999, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -#undef PARAMS -#if defined (__STDC__) && __STDC__ -# ifndef _PTR_T -# define _PTR_T - typedef void * ptr_t; -# endif -# define PARAMS(x) x -#else -# ifndef _PTR_T -# define _PTR_T - typedef char * ptr_t; -# endif -# define PARAMS(x) () -#endif - -#ifdef HAVE_UNISTD_H -# include -# include -#else -# define O_RDONLY 0 -# define SEEK_SET 0 -# define SEEK_CUR 1 -int open(), read(), close(); -#endif - -#include -#ifndef errno -extern int errno; -#endif - -#ifndef HAVE_STRERROR -extern int sys_nerr; -extern char *sys_errlist[]; -# define strerror(E) (0 <= (E) && (E) < sys_nerr ? _(sys_errlist[E]) : _("Unknown system error")) -#endif - -/* Some operating systems treat text and binary files differently. */ -#ifdef __BEOS__ -# undef O_BINARY /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ -#endif -#ifdef HAVE_DOS_FILE_CONTENTS -# include -# ifdef HAVE_SETMODE -# define SET_BINARY(fd) setmode (fd, O_BINARY) -# else -# define SET_BINARY(fd) _setmode (fd, O_BINARY) -# endif -#endif - -#ifdef HAVE_DOS_FILE_NAMES -# define IS_SLASH(c) ((c) == '/' || (c) == '\\') -# define FILESYSTEM_PREFIX_LEN(f) ((f)[0] && (f)[1] == ':' ? 2 : 0) -#endif - -#ifndef IS_SLASH -# define IS_SLASH(c) ((c) == '/') -#endif - -#ifndef FILESYSTEM_PREFIX_LEN -# define FILESYSTEM_PREFIX_LEN(f) 0 -#endif - -int isdir PARAMS ((char const *)); - -#ifdef HAVE_DIR_EACCES_BUG -# ifdef EISDIR -# define is_EISDIR(e, f) \ - ((e) == EISDIR \ - || ((e) == EACCES && isdir (f) && ((e) = EISDIR, 1))) -# else -# define is_EISDIR(e, f) ((e) == EACCES && isdir (f)) -# endif -#endif - -#ifndef is_EISDIR -# ifdef EISDIR -# define is_EISDIR(e, f) ((e) == EISDIR) -# else -# define is_EISDIR(e, f) 0 -# endif -#endif - -#if STAT_MACROS_BROKEN -# undef S_ISDIR -# undef S_ISREG -#endif -#if !defined(S_ISDIR) && defined(S_IFDIR) -# define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR) -#endif -#if !defined(S_ISREG) && defined(S_IFREG) -# define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG) -#endif - -#ifdef STDC_HEADERS -# include -#else -char *getenv (); -ptr_t malloc(), realloc(), calloc(); -void free(); -#endif - -#if __STDC__ -# include -#endif -#ifdef STDC_HEADERS -# include -#endif -#ifndef CHAR_BIT -# define CHAR_BIT 8 -#endif -/* The extra casts work around common compiler bugs. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \ - : (t) 0)) -#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) -#ifndef CHAR_MAX -# define CHAR_MAX TYPE_MAXIMUM (char) -#endif -#ifndef INT_MAX -# define INT_MAX TYPE_MAXIMUM (int) -#endif -#ifndef UCHAR_MAX -# define UCHAR_MAX TYPE_MAXIMUM (unsigned char) -#endif - -#if !defined(STDC_HEADERS) && defined(HAVE_STRING_H) && defined(HAVE_MEMORY_H) -# include -#endif -#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -# include -#else -# include -# undef strchr -# define strchr index -# undef strrchr -# define strrchr rindex -# undef memcpy -# define memcpy(d, s, n) bcopy (s, d, n) -#endif -#ifndef HAVE_MEMCHR -ptr_t memchr(); -#endif -#if ! defined HAVE_MEMMOVE && ! defined memmove -# define memmove(d, s, n) bcopy (s, d, n) -#endif - -#include - -#ifndef isgraph -# define isgraph(C) (isprint(C) && !isspace(C)) -#endif - -#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) -# define IN_CTYPE_DOMAIN(c) 1 -#else -# define IN_CTYPE_DOMAIN(c) isascii(c) -#endif - -#define ISALPHA(C) (IN_CTYPE_DOMAIN (C) && isalpha (C)) -#define ISUPPER(C) (IN_CTYPE_DOMAIN (C) && isupper (C)) -#define ISLOWER(C) (IN_CTYPE_DOMAIN (C) && islower (C)) -#define ISDIGIT(C) (IN_CTYPE_DOMAIN (C) && isdigit (C)) -#define ISXDIGIT(C) (IN_CTYPE_DOMAIN (C) && isxdigit (C)) -#define ISSPACE(C) (IN_CTYPE_DOMAIN (C) && isspace (C)) -#define ISPUNCT(C) (IN_CTYPE_DOMAIN (C) && ispunct (C)) -#define ISALNUM(C) (IN_CTYPE_DOMAIN (C) && isalnum (C)) -#define ISPRINT(C) (IN_CTYPE_DOMAIN (C) && isprint (C)) -#define ISGRAPH(C) (IN_CTYPE_DOMAIN (C) && isgraph (C)) -#define ISCNTRL(C) (IN_CTYPE_DOMAIN (C) && iscntrl (C)) - -#define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C)) - -#if ENABLE_NLS -# include -# define _(String) gettext (String) -#else -# define _(String) String -#endif -#define N_(String) String - -#if HAVE_SETLOCALE -# include -#endif - -#ifndef initialize_main -#define initialize_main(argcp, argvp) -#endif diff --git a/gnu/usr.bin/grep/tests/backref.sh b/gnu/usr.bin/grep/tests/backref.sh deleted file mode 100755 index 83f6dcc9408..00000000000 --- a/gnu/usr.bin/grep/tests/backref.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Test that backrefs are local to regex. -# -# - -: ${srcdir=.} - -failures=0 - -# checking for a palindrome -echo "radar" | ${GREP} -e '\(.\)\(.\).\2\1' > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "backref: palindrome, test \#1 failed" - failures=1 -fi - -# hit hard with the `Bond' tests -echo "civic" | ${GREP} -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "Options: Bond, test \#2 failed" - failures=1 -fi - -# backref are local should be error -echo "123" | ${GREP} -e 'a\(.\)' -e 'b\1' > /dev/null 2>&1 -if test $? -ne 2 ; then - echo "Options: Backref not local, test \#3 failed" - failures=1 -fi - -# Pattern should faile -echo "123" | ${GREP} -e '[' -e ']' > /dev/null 2>&1 -if test $? -ne 2 ; then - echo "Options: Compiled not local, test \#3 failed" - failures=1 -fi - -exit $failures diff --git a/gnu/usr.bin/grep/tests/bre.awk b/gnu/usr.bin/grep/tests/bre.awk deleted file mode 100644 index 16a58147a39..00000000000 --- a/gnu/usr.bin/grep/tests/bre.awk +++ /dev/null @@ -1,27 +0,0 @@ -BEGIN { - FS="@"; - n = 0; - printf ("# Generated Spencer BRE Test\n"); - printf ("failures=0\n"); -} - -$0 ~ /^#/ { next; } - -NF == 3 { -# printf ("status=`echo '%s' | { ${GREP} -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; }`\n",$3, $2); - printf ("status=`echo '%s' | { ${GREP} -e '%s' > /dev/null 2>&1; echo $? ; }`\n",$3, $2); - printf ("if test $status -ne %s ; then\n", $1); - printf ("\techo Spencer bre test \\#%d failed\n", ++n); - printf ("\tfailures=1\n"); - printf ("fi\n"); -} - -NF == 4 { -#don't alarm users -# printf ("echo '%s' | ${GREP} -e '%s' > /dev/null 2>&1\n",$3, $2); -# printf ("if test $? -ne %s ; then\n", $1); -# printf ("\techo Expected non conformance \\#%d ... continuing\n", ++n); -# printf ("fi\n"); -} - -END { printf ("exit $failures\n"); } diff --git a/gnu/usr.bin/grep/tests/bre.sh b/gnu/usr.bin/grep/tests/bre.sh deleted file mode 100755 index e7ccf0a037c..00000000000 --- a/gnu/usr.bin/grep/tests/bre.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Regression test for GNU grep. - -: ${srcdir=.} - -failures=0 - -# . . . and the following by Henry Spencer. - -${AWK-awk} -f $srcdir/bre.awk $srcdir/bre.tests > bre.script - -sh bre.script && exit $failures -exit 1 diff --git a/gnu/usr.bin/grep/tests/bre.tests b/gnu/usr.bin/grep/tests/bre.tests deleted file mode 100644 index 33d1689b85a..00000000000 --- a/gnu/usr.bin/grep/tests/bre.tests +++ /dev/null @@ -1,62 +0,0 @@ -0@a\(b\)c@abc -0@a(@a( -2@a\(@EPAREN -2@a\(b@EPAREN -0@a(b@a(b -0@a)@a) -2@a\)@EPAREN -2@\)@EPAREN -0@a\(\)b@ab -0@a^b@a^b@TO CORRECT -0@a$b@a$b -0@\($\)\(^\)@@ -0@a*\(^b$\)c*@b -0@|@| -0@*@* -0@\(\)@abc -2@\(\{1\}a\)@BADRPT@TO CORRECT -0@^*@* -2@^\{1\}@BADRPT@TO CORRECT -0@{@{ -1@a\(b*\)c\1d@abbcbd -1@a\(b*\)c\1d@abbcbbbd -1@^\(.\)\1@abc -0@a\(\([bc]\)\2\)*d@abbccd -1@a\(\([bc]\)\2\)*d@abbcbd -0@a\(\(b\)*\2\)*d@abbbd -0@\(a\)\1bcd@aabcd -0@\(a\)\1bc*d@aabcd -0@\(a\)\1bc*d@aabd -0@\(a\)\1bc*d@aabcccd -0@\(a\)\1bc*[ce]d@aabcccd@TO CORRECT -0@^\(a\)\1b\(c\)*cd$@aabcccd -0@a\(*\)b@a*b -0@a\(**\)b@ab -2@a\(***\)b@BADRPT@TO CORRECT -0@*a@*a -0@**a@a -2@***a@BADRPT@TO CORRECT -0@a\{1\}b@ab -0@a\{1,\}b@ab -0@a\{1,2\}b@aab -2@a\{1@EBRACE -2@a\{1a@EBRACE -2@a\{1a\}@BADBR -2@a\{,2\}@BADBR -2@a\{,\}@BADBR -2@a\{1,x\}@BADBR -2@a\{1,x@EBRACE -2@a\{32768\}@BADBR -2@a\{1,0\}@BADBR -0@ab\{0,0\}c@abcac -0@ab\{0,1\}c@abcac -0@ab\{0,3\}c@abbcac -0@ab\{1,1\}c@acabc -0@ab\{1,3\}c@acabc -0@ab\{2,2\}c@abcabbc -0@ab\{2,4\}c@abcabbc -2@a\{1\}\{1\}@BADRPT@TO CORRECT -2@a*\{1\}@BADRPT@TO CORRECT -2@a\{1\}*@BADRPT@TO CORRECT -1@a\(b\)?c\1d@acd -0@-\{0,1\}[0-9]*$@-5 diff --git a/gnu/usr.bin/grep/tests/empty.sh b/gnu/usr.bin/grep/tests/empty.sh deleted file mode 100755 index d4225fecd02..00000000000 --- a/gnu/usr.bin/grep/tests/empty.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# test that the empty file means no pattern -# and an empty pattern means match all. - -: ${srcdir=.} - -failures=0 - -for options in '-E' '-E -w' '-F -x' '-G -w -x'; do - - # should return 0 found a match - echo "" | ${GREP} $options -e '' > /dev/null 2>&1 - if test $? -ne 0 ; then - echo "Status: Wrong status code, test \#1 failed ($options)" - failures=1 - fi - - # should return 1 found no match - echo "abcd" | ${GREP} $options -f /dev/null > /dev/null 2>&1 - if test $? -ne 1 ; then - echo "Status: Wrong status code, test \#2 failed ($options)" - failures=1 - fi - - # should return 0 found a match - echo "abcd" | ${GREP} $options -f /dev/null -e "abcd" > /dev/null 2>&1 - if test $? -ne 0 ; then - echo "Status: Wrong status code, test \#3 failed ($options)" - failures=1 - fi -done - -exit $failures diff --git a/gnu/usr.bin/grep/tests/ere.awk b/gnu/usr.bin/grep/tests/ere.awk deleted file mode 100644 index 234d219e848..00000000000 --- a/gnu/usr.bin/grep/tests/ere.awk +++ /dev/null @@ -1,32 +0,0 @@ -BEGIN { - FS="@"; - n = 0; - printf ("# Generated Spencer ERE Test\n"); - printf ("failures=0\n"); -} - -$0 ~ /^#/ { next; } - -NF == 3 { -# printf ("status=`echo '%s' | { ${GREP} -E -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; }`\n",$3, $2); - printf ("status=`echo '%s' | { ${GREP} -E -e '%s' > /dev/null 2>&1; echo $?; }`\n",$3, $2); - printf ("if test $status -ne %s ; then\n", $1); - printf ("\techo Spencer ere test \\#%d failed\n", ++n); - printf ("\tfailures=1\n"); - printf ("fi\n"); -} - -NF == 4 { -# don't alarm the user for now -# printf ("echo '%s'|${GREP} -E -e '%s' > /dev/null 2>&1\n",$3, $2); -# printf ("if test $? -ne %s ; then\n", $1); -# printf ("\techo Expected non conformance \\#%d ... continuing\n", ++n); -# printf ("fi\n"); -} - -NF == 5 { -# don't alarm the user for now - next; -} - -END { printf ("exit $failures\n"); } diff --git a/gnu/usr.bin/grep/tests/ere.sh b/gnu/usr.bin/grep/tests/ere.sh deleted file mode 100755 index d57e2fae5ab..00000000000 --- a/gnu/usr.bin/grep/tests/ere.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Regression test for GNU grep. - -: ${srcdir=.} - -failures=0 - -# . . . and the following by Henry Spencer. - -${AWK-awk} -f $srcdir/ere.awk $srcdir/ere.tests > ere.script - -sh ere.script && exit $failures -exit 1 diff --git a/gnu/usr.bin/grep/tests/ere.tests b/gnu/usr.bin/grep/tests/ere.tests deleted file mode 100644 index 20ef2b1b2bf..00000000000 --- a/gnu/usr.bin/grep/tests/ere.tests +++ /dev/null @@ -1,215 +0,0 @@ -0@a@a -0@abc@abc -0@abc|de@abc -0@a|b|c@abc -0@a(b)c@abc -2@a(@EPAREN -0@a\(@a( -2@a(b@EPAREN -0@a)@a)@POSIX BOTCH -0@)@)@POSIX BOTCH -0@a()b@ab -0@^abc$@abc -1@a^b@a^b -1@a$b@a$b -0@^@abc -0@$@abc -0@^$@@ -0@$^@@ -0@^^@@ -0@$$@@ -0@a*(^b$)c*@b -2@|@EMPTY@NO ALTERNATION -2@*@BADRPT@TO CORRECT -2@+@BADRPT@TO CORRECT -2@?@BADRPT@TO CORRECT -1@&C@PASS -0@()@abc -2@a||b@EMPTY@NO ALTERNATION -2@|ab@EMPTY@NO ALTERNATION -2@ab|@EMPTY@NO ALTERNATION -2@(|a)b@EMPTY@NO ALTERNATION -2@(a|)b@EMPTY@NO ALTERNATION -2@(*a)@BADRPT@TO CORRECT -2@(+a)@BADRPT@TO CORRECT -2@(?a)@BADRPT@TO CORRECT -2@({1}a)@BADRPT@TO CORRECT -2@(a|*b)@BADRPT@NO ALTERNATION -2@(a|+b)@BADRPT@NO ALTERNATION -2@(a|?b)@BADRPT@NO ALTERNATION -2@(a|{1}b)@BADRPT@NO ALTERNATION -2@^*@BADRPT@TO CORRECT -2@^+@BADRPT@TO CORRECT -2@^?@BADRPT@TO CORRECT -2@^{1}@BADRPT@TO CORRECT -0@a.c@abc -0@a[bc]d@abd -0@a\*c@a*c -0@a\\b@a\b@TO CORRECT -0@a\\\*b@a\*b@SHELL TROUBLE -0@a\bc@abc@TO CORRECT -2@a\@EESCAPE@SHELL TROUBLE -0@a\\bc@a\bc@TO CORRECT -0@a\[b@a[b -2@a[b@EBRACK -0@a$@a -1@a$@a$ -1@a\$@a@SHELL TROUBLE -0@a\$@a$@SHELL TROUBLE -1@a\\$@a -1@a\\$@a$@SHELL TROUBLE -1@a\\$@a\$@SHELL TROUBLE -0@a\\$@a\@SHEL TROUBLE -0@ab*c@abc -0@ab+c@abc -0@ab?c@abc -0@{@{@TO CORRECT -0@{abc@{abc@TO CORRECT -0@{1@{1 -2@{1}@BADRPT@TO CORRECT -0@a{b@a{b@TO CORRECT -0@a{1}b@ab -0@a{1,}b@ab -0@a{1,2}b@aab -0@a{1@a{1 -1@a{1a@aa -0@a{1a}@a{1a} -0@a{,2}@a{,2} -0@a{,}@a{,} -0@a{1,*}@a{1,,,} -2@a{1,x@EBRACE@TO CORRECT -2@a{300}@BADBR@TO CORRECT -2@a{1,0}@BADBR@TO CORRECT -0@ab{0,0}c@abcac -0@ab{0,1}c@abcac -0@ab{0,3}c@abbcac -0@ab{1,1}c@acabc -0@ab{1,3}c@acabc -0@ab{2,2}c@abcabbc -0@ab{2,4}c@abcabbc -2@a**@BADRPT@TO CORRECT -2@a++@BADRPT@TO CORRECT -2@a??@BADRPT@TO CORRECT -2@a*+@BADRPT@TO CORRECT -2@a*?@BADRPT@TO CORRECT -2@a+*@BADRPT@TO CORRECT -2@a+?@BADRPT@TO CORRECT -2@a?*@BADRPT@TO CORRECT -2@a?+@BADRPT@TO CORRECT -2@a{1}{1}@BADRPT@TO CORRECT -2@a*{1}@BADRPT@TO CORRECT -2@a+{1}@BADRPT@TO CORRECT -2@a?{1}@BADRPT@TO CORRECT -2@a{1}*@BADRPT@TO CORRECT -2@a{1}+@BADRPT@TO CORRECT -2@a{1}?@BADRPT@TO CORRECT -0@a*{b}@a{b}@TO CORRECT -0@a[b]c@abc -0@a[ab]c@abc -0@a[^ab]c@adc -0@a[]b]c@a]c -0@a[[b]c@a[c -0@a[-b]c@a-c -0@a[^]b]c@adc -0@a[^-b]c@adc -0@a[b-]c@a-c -2@a[b@EBRACK -2@a[]@EBRACK -0@a[1-3]c@a2c -2@a[3-1]c@ERANGE@TO CORRECT -2@a[1-3-5]c@ERANGE@TO CORRECT -0@a[[.-.]--]c@a-c@TO CORRECT -2@a[1-@ERANGE -2@a[[.@EBRACK -2@a[[.x@EBRACK -2@a[[.x.@EBRACK -2@a[[.x.]@EBRACK@TO CORRECT -0@a[[.x.]]@ax@TO CORRECT -2@a[[.x,.]]@ECOLLATE@TO CORRECT -0@a[[.one.]]b@a1b@TO CORRECT -2@a[[.notdef.]]b@ECOLLATE@TO CORRECT -0@a[[.].]]b@a]b@TO CORRECT -0@a[[:alpha:]]c@abc -2@a[[:notdef:]]c@ECTYPE -2@a[[:@EBRACK -2@a[[:alpha@EBRACK -2@a[[:alpha:]@EBRACK -2@a[[:alpha,:]@ECTYPE -2@a[[:]:]]b@ECTYPE -2@a[[:-:]]b@ECTYPE -2@a[[:alph:]]@ECTYPE -2@a[[:alphabet:]]@ECTYPE -0@[[:digit:]]+@a019b -0@[[:lower:]]+@AabC -0@[[:upper:]]+@aBCd -0@[[:xdigit:]]+@p0f3Cq -0@a[[=b=]]c@abc@TO CORRECT -2@a[[=@EBRACK -2@a[[=b@EBRACK -2@a[[=b=@EBRACK -2@a[[=b=]@EBRACK@TO CORRECT -2@a[[=b,=]]@ECOLLATE@TO CORRECT -0@a[[=one=]]b@a1b@TO CORRECT -0@a(((b)))c@abc -0@a(b|(c))d@abd -0@a(b*|c)d@abbd -0@a[ab]{20}@aaaaabaaaabaaaabaaaab -0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]@aaaaabaaaabaaaabaaaab -0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)@aaaaabaaaabaaaabaaaabweeknights -0@12345678901234567890123456789@a12345678901234567890123456789b -0@123456789012345678901234567890@a123456789012345678901234567890b -0@1234567890123456789012345678901@a1234567890123456789012345678901b -0@12345678901234567890123456789012@a12345678901234567890123456789012b -0@123456789012345678901234567890123@a123456789012345678901234567890123b -0@1234567890123456789012345678901234567890123456789012345678901234567890@a1234567890123456789012345678901234567890123456789012345678901234567890b -0@[ab][cd][ef][gh][ij][kl][mn]@xacegikmoq -0@[ab][cd][ef][gh][ij][kl][mn][op]@xacegikmoq -0@[ab][cd][ef][gh][ij][kl][mn][op][qr]@xacegikmoqy -0@[ab][cd][ef][gh][ij][kl][mn][op][q]@xacegikmoqy -0@abc@xabcy -0@aBc@Abc@TO CORRECT -0@a[Bc]*d@abBCcd@TO CORRECT -0@0[[:upper:]]1@0a1@TO CORRECT -0@0[[:lower:]]1@0A1@TO CORRECT -1@a[^b]c@abc -1@a[^b]c@aBc@TO CORRECT -0@a[^b]c@adc -0@[a]b[c]@abc -0@[a]b[a]@aba -0@[abc]b[abc]@abc -0@[abc]b[abd]@abd -0@a(b?c)+d@accd -0@(wee|week)(knights|night)@weeknights -0@(we|wee|week|frob)(knights|night|day)@weeknights -0@a[bc]d@xyzaaabcaababdacd -0@a[ab]c@aaabc -0@a*@b -0@/\*.*\*/@/*x*/ -0@/\*.*\*/@/*x*/y/*z*/ -0@/\*([^*]|\*[^/])*\*/@/*x*/ -0@/\*([^*]|\*[^/])*\*/@/*x*/y/*z*/ -0@/\*([^*]|\*[^/])*\*/@/*x**/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x*/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x**/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x****/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x**x*/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x***x/y/*z*/ -0@aZb@a@TO CORRECT -0@[[:<:]]a@a@TO CORRECT -1@[[:<:]]a@ba@TO CORRECT -0@[[:<:]]a@-a@TO CORRECT -0@a[[:>:]]@a@TO CORRECT -1@a[[:>:]]@ab@TO CORRECT -0@a[[:>:]]@a-@TO CORRECT -0@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc@TO CORRECT -0@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc-q@TO CORRECT -0@[[:<:]]a.c[[:>:]]@axc-dayc-dazce-abc@TO CORRECT -0@[[:<:]]b.c[[:>:]]@a_bxc-byc_d-bzc-q@TO CORRECT -0@[[:<:]].x..[[:>:]]@y_xa_-_xb_y-_xc_-axdc@TO CORRECT -1@[[:<:]]a_b[[:>:]]@x_a_b@TO CORRECT -0@(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A])@A1 -0@abcdefghijklmnop@abcdefghijklmnop -0@abcdefghijklmnopqrstuv@abcdefghijklmnopqrstuv -0@CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a@CC11 -0@a?b@ab diff --git a/gnu/usr.bin/grep/tests/file.sh b/gnu/usr.bin/grep/tests/file.sh deleted file mode 100755 index 3db95bed682..00000000000 --- a/gnu/usr.bin/grep/tests/file.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Test for POSIX.2 options for grep -# -# grep -E -f pattern_file file -# grep -F -f pattern_file file -# grep -G -f pattern_file file -# - -: ${srcdir=.} - -failures=0 - -cat <patfile -radar -MILES -GNU -EOF - -# match -echo "miles" | ${GREP} -i -E -f patfile > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "File_pattern: Wrong status code, test \#1 failed" - failures=1 -fi - -# match -echo "GNU" | ${GREP} -G -f patfile > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "File_pattern: Wrong status code, test \#2 failed" - failures=1 -fi - -# checking for no match -echo "ridar" | ${GREP} -F -f patfile > /dev/null 2>&1 -if test $? -ne 1 ; then - echo "File_pattern: Wrong status code, test \#3 failed" - failures=1 -fi - -cat <patfile - -EOF -# empty pattern : every match -echo "abbcd" | ${GREP} -F -f patfile > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "File_pattern: Wrong status code, test \#4 failed" - failures=1 -fi - -cp /dev/null patfile - -# null pattern : no match -echo "abbcd" | ${GREP} -F -f patfile > /dev/null 2>&1 -if test $? -ne 1 ; then - echo "File_pattern: Wrong status code, test \#5 failed" - failures=1 -fi - -exit $failures diff --git a/gnu/usr.bin/grep/tests/formatbre.awk b/gnu/usr.bin/grep/tests/formatbre.awk deleted file mode 100644 index 68a9c626603..00000000000 --- a/gnu/usr.bin/grep/tests/formatbre.awk +++ /dev/null @@ -1,55 +0,0 @@ -# -# Basic Regular Expression - -# kip comments -$0 ~ /^#/ { next; } - -# skip those option specific to regexec/regcomp -$2 ~ /[msnr$#p^]/ { next; } - -# skip empty lines -$0 ~ /^$/ { next; } - -# debug -#{ printf ("<%s> <%s> <%s> <%s>\n", $1, $2, $3, $4); } - -# subreg expresion -NF >= 5 { next; } - -# errors -NF == 3 { -# gsub (/@/, ","); -# it means empty lines - gsub (/\"\"/, ""); -# escapes - gsub (/\\\'/, "\\\'\'"); -# error in regex - if (index ($2, "C") != 0) - { - if (index ($2, "b") != 0) - printf ("2@%s@%s\n", $1, $3); - } -# erro no match - else - { - if (index ($2, "b") != 0) - printf ("1@%s@%s\n", $1, $3); - } - next; -} - -# ok -NF == 4 { -# skip those magic cookies can't rely on echo to gnerate them - if (match($3, /[NSTZ]/)) - next; - -# gsub (/@/, ","); -# it means empty lines - gsub (/\"\"/, ""); -# escape escapes - gsub (/\\\'/, "\\\'\'"); - - if (index ($2, "b") != 0) - printf ("0@%s@%s\n", $1, $3); -} diff --git a/gnu/usr.bin/grep/tests/formatere.awk b/gnu/usr.bin/grep/tests/formatere.awk deleted file mode 100644 index ba60439a189..00000000000 --- a/gnu/usr.bin/grep/tests/formatere.awk +++ /dev/null @@ -1,60 +0,0 @@ -# -# Extended Regular Expression - -# skip comments -$0 ~ /^#/ { next; } - -# skip specifics to regcomp/regexec -$2 ~ /[msnr$#p^]/ { next; } - -# jump empty lines -$0 ~ /^$/ { next; } - -# subreg skip -NF >= 5 { next; } - -# debug -#{ printf ("<%s> <%s> <%s> <%s>\n", $1, $2, $3, $4); } - -# errors -NF == 3 { -# nuke any remaining '@' -# gsub (/@/, ","); -# it means empty lines - gsub (/\"\"/, ""); -# escapes - gsub (/\\\'/, "\\\'\'"); -# error in regex - if (index ($2, "C") != 0) - { - if (index ($2, "b") == 0) - printf ("2@%s@%s\n", $1, $3); - } -# error not matching - else - { - if (index ($2, "b") == 0) - printf ("1@%s@%s\n", $1, $3); - } - next; -} - -# ok -NF == 4 { -# skip those magic cookies can't rely on echo to gnerate them - if (match($3, /[NSTZ]/)) - next; - -# nuke any remaining '@' -# gsub (/@/, ","); -# it means empty lines - gsub (/\"\"/, ""); -# escape escapes - gsub (/\\\'/, "\\\'\'"); - - if (index ($2, "b") == 0) - { - printf ("0@%s@%s\n", $1, $3); - } - next; -} diff --git a/gnu/usr.bin/grep/tests/khadafy.lines b/gnu/usr.bin/grep/tests/khadafy.lines deleted file mode 100644 index 57e21a17948..00000000000 --- a/gnu/usr.bin/grep/tests/khadafy.lines +++ /dev/null @@ -1,32 +0,0 @@ -1) Muammar Qaddafi -2) Mo'ammar Gadhafi -3) Muammar Kaddafi -4) Muammar Qadhafi -5) Moammar El Kadhafi -6) Muammar Gadafi -7) Mu'ammar al-Qadafi -8) Moamer El Kazzafi -9) Moamar al-Gaddafi -10) Mu'ammar Al Qathafi -11) Muammar Al Qathafi -12) Mo'ammar el-Gadhafi -13) Moamar El Kadhafi -14) Muammar al-Qadhafi -15) Mu'ammar al-Qadhdhafi -16) Mu'ammar Qadafi -17) Moamar Gaddafi -18) Mu'ammar Qadhdhafi -19) Muammar Khaddafi -20) Muammar al-Khaddafi -21) Mu'amar al-Kadafi -22) Muammar Ghaddafy -23) Muammar Ghadafi -24) Muammar Ghaddafi -25) Muamar Kaddafi -26) Muammar Quathafi -27) Muammar Gheddafi -28) Muamar Al-Kaddafi -29) Moammar Khadafy -30) Moammar Qudhafi -31) Mu'ammar al-Qaddafi -32) Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi diff --git a/gnu/usr.bin/grep/tests/khadafy.regexp b/gnu/usr.bin/grep/tests/khadafy.regexp deleted file mode 100644 index 46fe8ddd6da..00000000000 --- a/gnu/usr.bin/grep/tests/khadafy.regexp +++ /dev/null @@ -1 +0,0 @@ -M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] diff --git a/gnu/usr.bin/grep/tests/khadafy.sh b/gnu/usr.bin/grep/tests/khadafy.sh deleted file mode 100755 index e3d2cde4c08..00000000000 --- a/gnu/usr.bin/grep/tests/khadafy.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# Regression test for GNU grep. - -: ${srcdir=.} -: ${GREP=../src/grep} - -failures=0 - -# The Khadafy test is brought to you by Scott Anderson . . . - -${GREP} -E -f $srcdir/khadafy.regexp $srcdir/khadafy.lines > khadafy.out -if cmp $srcdir/khadafy.lines khadafy.out -then - : -else - echo Khadafy test failed -- output left on khadafy.out - failures=1 -fi - -exit $failures diff --git a/gnu/usr.bin/grep/tests/options.sh b/gnu/usr.bin/grep/tests/options.sh deleted file mode 100755 index 0f1852971d8..00000000000 --- a/gnu/usr.bin/grep/tests/options.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Test for POSIX.2 options for grep -# -# grep [ -E| -F][ -c| -l| -q ][-insvx] -e pattern_list -# [-f pattern_file] ... [file. ..] -# grep [ -E| -F][ -c| -l| -q ][-insvx][-e pattern_list] -# -f pattern_file ... [file ...] -# grep [ -E| -F][ -c| -l| -q ][-insvx] pattern_list [file...] -# - -: ${srcdir=.} - -failures=0 - -# checking for -E extended regex -echo "abababccccccd" | ${GREP} -E -e 'c{3}' > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "Options: Wrong status code, test \#1 failed" - failures=1 -fi - -# checking for basic regex -echo "abababccccccd" | ${GREP} -G -e 'c\{3\}' > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "Options: Wrong status code, test \#2 failed" - failures=1 -fi - -# checking for fixed string -echo "abababccccccd" | ${GREP} -F -e 'c\{3\}' > /dev/null 2>&1 -if test $? -ne 1 ; then - echo "Options: Wrong status code, test \#3 failed" - failures=1 -fi - -exit $failures diff --git a/gnu/usr.bin/grep/tests/spencer1.awk b/gnu/usr.bin/grep/tests/spencer1.awk deleted file mode 100644 index ba7aeb66af7..00000000000 --- a/gnu/usr.bin/grep/tests/spencer1.awk +++ /dev/null @@ -1,15 +0,0 @@ -BEGIN { - FS = "@"; - printf ("failures=0\n"); -} - -$0 !~ /^#/ && NF = 3 { -# printf ("status=`echo '%s'| { ${GREP} -E -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; }`\n",$3, $2); - printf ("status=`echo '%s'| { ${GREP} -E -e '%s' >/dev/null 2>&1 ; echo $?; }`\n",$3, $2); - printf ("if test $status -ne %s ; then\n", $1); - printf ("\techo Spencer test \\#%d failed\n", ++n); - printf ("\tfailures=1\n"); - printf ("fi\n"); -} - -END { printf ("exit $failures\n"); } diff --git a/gnu/usr.bin/grep/tests/spencer1.sh b/gnu/usr.bin/grep/tests/spencer1.sh deleted file mode 100755 index 2391761ab64..00000000000 --- a/gnu/usr.bin/grep/tests/spencer1.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Regression test for GNU grep. - -: ${srcdir=.} - -failures=0 - -# . . . and the following by Henry Spencer. - -${AWK-awk} -f $srcdir/spencer1.awk $srcdir/spencer1.tests > spencer1.script - -sh spencer1.script && exit $failures -exit 1 diff --git a/gnu/usr.bin/grep/tests/spencer1.tests b/gnu/usr.bin/grep/tests/spencer1.tests deleted file mode 100644 index 2a60f00c141..00000000000 --- a/gnu/usr.bin/grep/tests/spencer1.tests +++ /dev/null @@ -1,122 +0,0 @@ -0@abc@abc -1@abc@xbc -1@abc@axc -1@abc@abx -0@abc@xabcy -0@abc@ababc -0@ab*c@abc -0@ab*bc@abc -0@ab*bc@abbc -0@ab*bc@abbbbc -0@ab+bc@abbc -1@ab+bc@abc -1@ab+bc@abq -0@ab+bc@abbbbc -0@ab?bc@abbc -0@ab?bc@abc -1@ab?bc@abbbbc -0@ab?c@abc -0@^abc$@abc -1@^abc$@abcc -0@^abc@abcc -1@^abc$@aabc -0@abc$@aabc -0@^@abc -0@$@abc -0@a.c@abc -0@a.c@axc -0@a.*c@axyzc -1@a.*c@axyzd -1@a[bc]d@abc -0@a[bc]d@abd -1@a[b-d]e@abd -0@a[b-d]e@ace -0@a[b-d]@aac -0@a[-b]@a- -0@a[b-]@a- -1@a[b-a]@- -2@a[]b@- -2@a[@- -0@a]@a] -0@a[]]b@a]b -0@a[^bc]d@aed -1@a[^bc]d@abd -0@a[^-b]c@adc -1@a[^-b]c@a-c -1@a[^]b]c@a]c -0@a[^]b]c@adc -0@ab|cd@abc -0@ab|cd@abcd -0@()ef@def -0@()*@- -1@*a@- -0@^*@- -0@$*@- -1@(*)b@- -1@$b@b -2@a\@- -0@a\(b@a(b -0@a\(*b@ab -0@a\(*b@a((b -1@a\x@a\x -2@abc)@- -2@(abc@- -0@((a))@abc -0@(a)b(c)@abc -0@a+b+c@aabbabc -0@a**@- -0@a*?@- -0@(a*)*@- -0@(a*)+@- -0@(a|)*@- -0@(a*|b)*@- -0@(a+|b)*@ab -0@(a+|b)+@ab -0@(a+|b)?@ab -0@[^ab]*@cde -0@(^)*@- -0@(ab|)*@- -2@)(@- -1@abc@ -1@abc@ -0@a*@ -0@([abc])*d@abbbcd -0@([abc])*bcd@abcd -0@a|b|c|d|e@e -0@(a|b|c|d|e)f@ef -0@((a*|b))*@- -0@abcd*efg@abcdefg -0@ab*@xabyabbbz -0@ab*@xayabbbz -0@(ab|cd)e@abcde -0@[abhgefdc]ij@hij -1@^(ab|cd)e@abcde -0@(abc|)ef@abcdef -0@(a|b)c*d@abcd -0@(ab|ab*)bc@abc -0@a([bc]*)c*@abc -0@a([bc]*)(c*d)@abcd -0@a([bc]+)(c*d)@abcd -0@a([bc]*)(c+d)@abcd -0@a[bcd]*dcdcde@adcdcde -1@a[bcd]+dcdcde@adcdcde -0@(ab|a)b*c@abc -0@((a)(b)c)(d)@abcd -0@[A-Za-z_][A-Za-z0-9_]*@alpha -0@^a(bc+|b[eh])g|.h$@abh -0@(bc+d$|ef*g.|h?i(j|k))@effgz -0@(bc+d$|ef*g.|h?i(j|k))@ij -1@(bc+d$|ef*g.|h?i(j|k))@effg -1@(bc+d$|ef*g.|h?i(j|k))@bcdd -0@(bc+d$|ef*g.|h?i(j|k))@reffgz -1@((((((((((a))))))))))@- -0@(((((((((a)))))))))@a -1@multiple words of text@uh-uh -0@multiple words@multiple words, yeah -0@(.*)c(.*)@abcde -1@\((.*),@(.*)\) -1@[k]@ab -0@abcd@abcd -0@a(bc)d@abcd -0@a[-]?c@ac -0@(....).*\1@beriberi diff --git a/gnu/usr.bin/grep/tests/spencer2.sh b/gnu/usr.bin/grep/tests/spencer2.sh deleted file mode 100755 index a26869c5121..00000000000 --- a/gnu/usr.bin/grep/tests/spencer2.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Regression test for GNU grep. - -: ${srcdir=.} - -failures=0 - -# . . . and the following by Henry Spencer. - -${AWK-awk} -f $srcdir/scriptgen.awk $srcdir/spencer2.tests > tmp2.script - -sh tmp2.script && exit $failures -exit 1 diff --git a/gnu/usr.bin/grep/tests/spencer2.tests b/gnu/usr.bin/grep/tests/spencer2.tests deleted file mode 100644 index 47b61914c6e..00000000000 --- a/gnu/usr.bin/grep/tests/spencer2.tests +++ /dev/null @@ -1,317 +0,0 @@ -0@a@a -0@abc@abc -0@abc|de@abc -0@a|b|c@abc -0@a(b)c@abc -1@a\(b\)c@abc -2@a(@EPAREN -2@a(@a( -0@a\(@a( -1@a\(@EPAREN -1@a\(b@EPAREN -2@a(b@EPAREN -2@a(b@a(b -2@a)@a) -2@)@) -2@a)@a) -1@a\)@EPAREN -1@\)@EPAREN -0@a()b@ab -1@a\(\)b@ab -0@^abc$@abc -1@a^b@a^b -1@a^b@a^b -1@a$b@a$b -1@a$b@a$b -0@^@abc -0@$@abc -1@^$@"" -1@$^@"" -1@\($\)\(^\)@"" -0@^^@"" -0@$$@"" -1@b$@abNc -1@b$@abNc -1@^b$@aNbNc -1@^b$@aNbNc -1@^$@aNNb -1@^$@abc -1@^$@abcN -1@$^@aNNb -1@\($\)\(^\)@aNNb -0@^^@aNNb -0@$$@aNNb -0@^a@a -0@a$@a -0@^a@aNb -1@^b@aNb -0@a$@bNa -1@b$@bNa -0@a*(^b$)c*@b -1@a*\(^b$\)c*@b -0@|@EMPTY -0@|@| -0@*@BADRPT -0@*@* -0@+@BADRPT -0@?@BADRPT -1@""@EMPTY -0@()@abc -1@\(\)@abc -0@a||b@EMPTY -0@|ab@EMPTY -0@ab|@EMPTY -1@(|a)b@EMPTY -1@(a|)b@EMPTY -1@(*a)@BADRPT -1@(+a)@BADRPT -1@(?a)@BADRPT -1@({1}a)@BADRPT -1@\(\{1\}a\)@BADRPT -1@(a|*b)@BADRPT -1@(a|+b)@BADRPT -1@(a|?b)@BADRPT -1@(a|{1}b)@BADRPT -0@^*@BADRPT -0@^*@* -0@^+@BADRPT -0@^?@BADRPT -0@^{1}@BADRPT -1@^\{1\}@BADRPT -0@a.c@abc -0@a[bc]d@abd -0@a\*c@a*c -1@ac@abc -1@a\bc@ac -1@\{@BADRPT -0@a\[b@a[b -2@a[b@EBRACK -0@a$@a -1@a$@a$ -1@a\$@a -0@a\$@a$ -1@a\$@a -1@a\$@a\$ -2@a\(b\)\2c@ESUBREG -2@a\(b\1\)c@ESUBREG -2@a\(b*\)c\1d@abbcbd -2@a\(b*\)c\1d@abbcbbbd -2@^\(.\)\1@abc -2@a\(\([bc]\)\2\)*d@abbccd -2@a\(\([bc]\)\2\)*d@abbcbd -2@a\(\(b\)*\2\)*d@abbbd -2@\(a\)\1bcd@aabcd -2@\(a\)\1bc*d@aabcd -2@\(a\)\1bc*d@aabd -2@\(a\)\1bc*d@aabcccd -2@\(a\)\1bc*[ce]d@aabcccd -2@^\(a\)\1b\(c\)*cd$@aabcccd -0@ab*c@abc -0@ab+c@abc -0@ab?c@abc -1@a\(*\)b@a*b -1@a\(**\)b@ab -1@a\(***\)b@BADRPT -0@*a@*a -0@**a@a -1@***a@BADRPT -2@{@{ -2@{abc@{abc -2@{1@BADRPT -0@{1}@BADRPT -2@a{b@a{b -0@a{1}b@ab -1@a\{1\}b@ab -0@a{1,}b@ab -1@a\{1,\}b@ab -0@a{1,2}b@aab -1@a\{1,2\}b@aab -2@a{1@EBRACE -1@a\{1@EBRACE -2@a{1a@EBRACE -1@a\{1a@EBRACE -2@a{1a}@BADBR -1@a\{1a\}@BADBR -0@a{,2}@a{,2} -1@a\{,2\}@BADBR -0@a{,}@a{,} -1@a\{,\}@BADBR -2@a{1,x}@BADBR -1@a\{1,x\}@BADBR -2@a{1,x@EBRACE -1@a\{1,x@EBRACE -1@a{300}@BADBR -1@a\{300\}@BADBR -1@a{1,0}@BADBR -1@a\{1,0\}@BADBR -0@ab{0,0}c@abcac -1@ab\{0,0\}c@abcac -0@ab{0,1}c@abcac -1@ab\{0,1\}c@abcac -0@ab{0,3}c@abbcac -1@ab\{0,3\}c@abbcac -0@ab{1,1}c@acabc -1@ab\{1,1\}c@acabc -0@ab{1,3}c@acabc -1@ab\{1,3\}c@acabc -0@ab{2,2}c@abcabbc -1@ab\{2,2\}c@abcabbc -0@ab{2,4}c@abcabbc -1@ab\{2,4\}c@abcabbc -0@a**@BADRPT -1@a++@BADRPT -0@a??@BADRPT -0@a*+@BADRPT -0@a*?@BADRPT -0@a+*@BADRPT -0@a+?@BADRPT -0@a?*@BADRPT -0@a?+@BADRPT -1@a{1}{1}@BADRPT -0@a*{1}@BADRPT -1@a+{1}@BADRPT -0@a?{1}@BADRPT -0@a{1}*@BADRPT -1@a{1}+@BADRPT -0@a{1}?@BADRPT -2@a*{b}@a{b} -1@a\{1\}\{1\}@BADRPT -1@a*\{1\}@BADRPT -1@a\{1\}*@BADRPT -0@a[b]c@abc -0@a[ab]c@abc -0@a[^ab]c@adc -0@a[]b]c@a]c -0@a[[b]c@a[c -0@a[-b]c@a-c -0@a[^]b]c@adc -0@a[^-b]c@adc -0@a[b-]c@a-c -2@a[b@EBRACK -2@a[]@EBRACK -0@a[1-3]c@a2c -1@a[3-1]c@ERANGE -1@a[1-3-5]c@ERANGE -1@a[[.-.]--]c@a-c -2@a[1-@ERANGE -2@a[[.@EBRACK -2@a[[.x@EBRACK -2@a[[.x.@EBRACK -1@a[[.x.]@EBRACK -1@a[[.x.]]@ax -1@a[[.x,.]]@ECOLLATE -1@a[[.one.]]b@a1b -1@a[[.notdef.]]b@ECOLLATE -1@a[[.].]]b@a]b -0@a[[:alpha:]]c@abc -2@a[[:notdef:]]c@ECTYPE -2@a[[:@EBRACK -2@a[[:alpha@EBRACK -2@a[[:alpha:]@EBRACK -2@a[[:alpha,:]@ECTYPE -2@a[[:]:]]b@ECTYPE -2@a[[:-:]]b@ECTYPE -2@a[[:alph:]]@ECTYPE -2@a[[:alphabet:]]@ECTYPE -1@[[:blank:]]+@aSSTb -1@[[:cntrl:]]+@aNTb -0@[[:digit:]]+@a019b -0@[[:graph:]]+@Sa%bS -0@[[:lower:]]+@AabC -0@[[:print:]]+@NaSbN -0@[[:punct:]]+@S%-&T -1@[[:space:]]+@aSNTb -0@[[:upper:]]+@aBCd -0@[[:xdigit:]]+@p0f3Cq -1@a[[=b=]]c@abc -2@a[[=@EBRACK -2@a[[=b@EBRACK -2@a[[=b=@EBRACK -1@a[[=b=]@EBRACK -1@a[[=b,=]]@ECOLLATE -1@a[[=one=]]b@a1b -0@a(((b)))c@abc -0@a(b|(c))d@abd -0@a(b*|c)d@abbd -0@a[ab]{20}@aaaaabaaaabaaaabaaaab -0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]@aaaaabaaaabaaaabaaaab -0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)@aaaaabaaaabaaaabaaaabweeknights -0@12345678901234567890123456789@a12345678901234567890123456789b -0@123456789012345678901234567890@a123456789012345678901234567890b -0@1234567890123456789012345678901@a1234567890123456789012345678901b -0@12345678901234567890123456789012@a12345678901234567890123456789012b -0@123456789012345678901234567890123@a123456789012345678901234567890123b -0@1234567890123456789012345678901234567890123456789012345678901234567890@a1234567890123456789012345678901234567890123456789012345678901234567890b -0@[ab][cd][ef][gh][ij][kl][mn]@xacegikmoq -0@[ab][cd][ef][gh][ij][kl][mn][op]@xacegikmoq -0@[ab][cd][ef][gh][ij][kl][mn][op][qr]@xacegikmoqy -0@[ab][cd][ef][gh][ij][kl][mn][op][q]@xacegikmoqy -0@abc@xabcy -2@a\(b\)?c\1d@acd -1@aBc@Abc -1@a[Bc]*d@abBCcd -1@0[[:upper:]]1@0a1 -1@0[[:lower:]]1@0A1 -1@a[^b]c@abc -0@a[^b]c@aBc -0@a[^b]c@adc -0@[a]b[c]@abc -0@[a]b[a]@aba -0@[abc]b[abc]@abc -0@[abc]b[abd]@abd -0@a(b?c)+d@accd -0@(wee|week)(knights|night)@weeknights -0@(we|wee|week|frob)(knights|night|day)@weeknights -0@a[bc]d@xyzaaabcaababdacd -0@a[ab]c@aaabc -0@abc@abc -0@a*@b -0@/\*.*\*/@/*x*/ -0@/\*.*\*/@/*x*/y/*z*/ -0@/\*([^*]|\*[^/])*\*/@/*x*/ -0@/\*([^*]|\*[^/])*\*/@/*x*/y/*z*/ -0@/\*([^*]|\*[^/])*\*/@/*x**/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x*/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x**/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x****/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x**x*/y/*z*/ -0@/\*([^*]|\*+[^*/])*\*+/@/*x***x/y/*z*/ -0@[abc]@a(b)c -0@[abc]@a(d)c -0@[abc]@a(bc)d -0@[abc]@a(dc)d -0@.@a()c -0@b.*c@b(bc)c -0@b.*@b(bc)c -0@.*c@b(bc)c -0@abc@abc -0@abc@xabcy -1@abc@xyz -0@a*b@aba*b -0@a*b@ab -1@""@EMPTY -1@aZb@a -1@aZb@a -0@aZb@(aZb) -0@aZ*b@(ab) -0@a.b@(aZb) -0@a.*@(aZb)c -2@[[:<:]]a@a -2@[[:<:]]a@ba -2@[[:<:]]a@-a -2@a[[:>:]]@a -2@a[[:>:]]@ab -2@a[[:>:]]@a- -2@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc -2@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc-q -2@[[:<:]]a.c[[:>:]]@axc-dayc-dazce-abc -2@[[:<:]]b.c[[:>:]]@a_bxc-byc_d-bzc-q -2@[[:<:]].x..[[:>:]]@y_xa_-_xb_y-_xc_-axdc -2@[[:<:]]a_b[[:>:]]@x_a_b -0@(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A])@A1 -0@abcdefghijklmnop@abcdefghijklmnop -0@abcdefghijklmnopqrstuv@abcdefghijklmnopqrstuv -0@CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a@CC11 -0@a?b@ab -1@-\{0,1\}[0-9]*$@-5 diff --git a/gnu/usr.bin/grep/tests/status.sh b/gnu/usr.bin/grep/tests/status.sh deleted file mode 100755 index 94f59294a90..00000000000 --- a/gnu/usr.bin/grep/tests/status.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Test for status code for GNU grep. -# status code -# 0 match found -# 1 no match -# 2 file not found - -: ${srcdir=.} - -failures=0 - -# should return 0 found a match -echo "abcd" | ${GREP} -E -e 'abc' > /dev/null 2>&1 -if test $? -ne 0 ; then - echo "Status: Wrong status code, test \#1 failed" - failures=1 -fi - -# should return 1 found no match -echo "abcd" | ${GREP} -E -e 'zbc' > /dev/null 2>&1 -if test $? -ne 1 ; then - echo "Status: Wrong status code, test \#2 failed" - failures=1 -fi - -# the filename MMMMMMMM.MMM should not exist hopefully -if test -r MMMMMMMM.MMM; then - echo "Please remove MMMMMMMM.MMM to run check" -else - # should return 2 file not found - ${GREP} -E -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1 - if test $? -ne 2 ; then - echo "Status: Wrong status code, test \#3 failed" - failures=1 - fi - - # should return 2 file not found - ${GREP} -E -s -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1 - if test $? -ne 2 ; then - echo "Status: Wrong status code, test \#4 failed" - failures=1 - fi - - # should return 0 found a match - echo "abcd" | ${GREP} -E -q -s 'abc' MMMMMMMM.MMM - > /dev/null 2>&1 - if test $? -ne 0 ; then - echo "Status: Wrong status code, test \#5 failed" - failures=1 - fi -fi - -exit $failures diff --git a/gnu/usr.bin/grep/tests/tests b/gnu/usr.bin/grep/tests/tests deleted file mode 100644 index 8ed938d2d76..00000000000 --- a/gnu/usr.bin/grep/tests/tests +++ /dev/null @@ -1,475 +0,0 @@ -# regular expression test set -# Lines are at least three fields, separated by one or more tabs. "" stands -# for an empty field. First field is an RE. Second field is flags. If -# C flag given, regcomp() is expected to fail, and the third field is the -# error name (minus the leading REG_). -# -# Otherwise it is expected to succeed, and the third field is the string to -# try matching it against. If there is no fourth field, the match is -# expected to fail. If there is a fourth field, it is the substring that -# the RE is expected to match. If there is a fifth field, it is a comma- -# separated list of what the subexpressions should match, with - indicating -# no match for that one. In both the fourth and fifth fields, a (sub)field -# starting with @ indicates that the (sub)expression is expected to match -# a null string followed by the stuff after the @; this provides a way to -# test where null strings match. The character `N' in REs and strings -# is newline, `S' is space, `T' is tab, `Z' is NUL. -# -# The full list of flags: -# - placeholder, does nothing -# b RE is a BRE, not an ERE -# & try it as both an ERE and a BRE -# C regcomp() error expected, third field is error name -# i REG_ICASE -# m ("mundane") REG_NOSPEC -# s REG_NOSUB (not really testable) -# n REG_NEWLINE -# ^ REG_NOTBOL -# $ REG_NOTEOL -# # REG_STARTEND (see below) -# p REG_PEND -# -# For REG_STARTEND, the start/end offsets are those of the substring -# enclosed in (). - -# basics -a & a a -abc & abc abc -abc|de - abc abc -a|b|c - abc a - -# parentheses and perversions thereof -a(b)c - abc abc -a\(b\)c b abc abc -a( C EPAREN -a( b a( a( -a\( - a( a( -a\( bC EPAREN -a\(b bC EPAREN -a(b C EPAREN -a(b b a(b a(b -# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly) -a) - a) a) -) - ) ) -# end gagging (in a just world, those *should* give EPAREN) -a) b a) a) -a\) bC EPAREN -\) bC EPAREN -a()b - ab ab -a\(\)b b ab ab - -# anchoring and REG_NEWLINE -^abc$ & abc abc -a^b - a^b -a^b b a^b a^b -a$b - a$b -a$b b a$b a$b -^ & abc @abc -$ & abc @ -^$ & "" @ -$^ - "" @ -\($\)\(^\) b "" @ -# stop retching, those are legitimate (although disgusting) -^^ - "" @ -$$ - "" @ -##b$ & abNc -##b$ &n abNc b -##^b$ & aNbNc -##^b$ &n aNbNc b -##^$ &n aNNb @Nb -^$ n abc -##^$ n abcN @ -##$^ n aNNb @Nb -##\($\)\(^\) bn aNNb @Nb -##^^ n^ aNNb @Nb -##$$ n aNNb @NN -^a ^ a -a$ $ a -##^a ^n aNb -##^b ^n aNb b -##a$ $n bNa -##b$ $n bNa b -a*(^b$)c* - b b -a*\(^b$\)c* b b b - -# certain syntax errors and non-errors -| C EMPTY -| b | | -* C BADRPT -* b * * -+ C BADRPT -? C BADRPT -"" &C EMPTY -() - abc @abc -\(\) b abc @abc -a||b C EMPTY -|ab C EMPTY -ab| C EMPTY -(|a)b C EMPTY -(a|)b C EMPTY -(*a) C BADRPT -(+a) C BADRPT -(?a) C BADRPT -({1}a) C BADRPT -\(\{1\}a\) bC BADRPT -(a|*b) C BADRPT -(a|+b) C BADRPT -(a|?b) C BADRPT -(a|{1}b) C BADRPT -^* C BADRPT -^* b * * -^+ C BADRPT -^? C BADRPT -^{1} C BADRPT -^\{1\} bC BADRPT - -# metacharacters, backslashes -a.c & abc abc -a[bc]d & abd abd -a\*c & a*c a*c -a\\b & a\b a\b -a\\\*b & a\*b a\*b -a\bc & abc abc -a\ &C EESCAPE -a\\bc & a\bc a\bc -\{ bC BADRPT -a\[b & a[b a[b -a[b &C EBRACK -# trailing $ is a peculiar special case for the BRE code -a$ & a a -a$ & a$ -a\$ & a -a\$ & a$ a$ -a\\$ & a -a\\$ & a$ -a\\$ & a\$ -a\\$ & a\ a\ - -# back references, ugh -##a\(b\)\2c bC ESUBREG -##a\(b\1\)c bC ESUBREG -a\(b*\)c\1d b abbcbbd abbcbbd bb -a\(b*\)c\1d b abbcbd -a\(b*\)c\1d b abbcbbbd -^\(.\)\1 b abc -a\([bc]\)\1d b abcdabbd abbd b -a\(\([bc]\)\2\)*d b abbccd abbccd -a\(\([bc]\)\2\)*d b abbcbd -# actually, this next one probably ought to fail, but the spec is unclear -a\(\(b\)*\2\)*d b abbbd abbbd -# here is a case that no NFA implementation does right -\(ab*\)[ab]*\1 b ababaaa ababaaa a -# check out normal matching in the presence of back refs -\(a\)\1bcd b aabcd aabcd -\(a\)\1bc*d b aabcd aabcd -\(a\)\1bc*d b aabd aabd -\(a\)\1bc*d b aabcccd aabcccd -\(a\)\1bc*[ce]d b aabcccd aabcccd -^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd - -# ordinary repetitions -ab*c & abc abc -ab+c - abc abc -ab?c - abc abc -a\(*\)b b a*b a*b -a\(**\)b b ab ab -a\(***\)b bC BADRPT -*a b *a *a -**a b a a -***a bC BADRPT - -# the dreaded bounded repetitions -{ & { { -{abc & {abc {abc -{1 C BADRPT -{1} C BADRPT -a{b & a{b a{b -a{1}b - ab ab -a\{1\}b b ab ab -a{1,}b - ab ab -a\{1,\}b b ab ab -a{1,2}b - aab aab -a\{1,2\}b b aab aab -a{1 C EBRACE -a\{1 bC EBRACE -a{1a C EBRACE -a\{1a bC EBRACE -a{1a} C BADBR -a\{1a\} bC BADBR -a{,2} - a{,2} a{,2} -a\{,2\} bC BADBR -a{,} - a{,} a{,} -a\{,\} bC BADBR -a{1,x} C BADBR -a\{1,x\} bC BADBR -a{1,x C EBRACE -a\{1,x bC EBRACE -a{300} C BADBR -a\{300\} bC BADBR -a{1,0} C BADBR -a\{1,0\} bC BADBR -ab{0,0}c - abcac ac -ab\{0,0\}c b abcac ac -ab{0,1}c - abcac abc -ab\{0,1\}c b abcac abc -ab{0,3}c - abbcac abbc -ab\{0,3\}c b abbcac abbc -ab{1,1}c - acabc abc -ab\{1,1\}c b acabc abc -ab{1,3}c - acabc abc -ab\{1,3\}c b acabc abc -ab{2,2}c - abcabbc abbc -ab\{2,2\}c b abcabbc abbc -ab{2,4}c - abcabbc abbc -ab\{2,4\}c b abcabbc abbc -((a{1,10}){1,10}){1,10} - a a a,a - -# multiple repetitions -a** &C BADRPT -a++ C BADRPT -a?? C BADRPT -a*+ C BADRPT -a*? C BADRPT -a+* C BADRPT -a+? C BADRPT -a?* C BADRPT -a?+ C BADRPT -a{1}{1} C BADRPT -a*{1} C BADRPT -a+{1} C BADRPT -a?{1} C BADRPT -a{1}* C BADRPT -a{1}+ C BADRPT -a{1}? C BADRPT -a*{b} - a{b} a{b} -a\{1\}\{1\} bC BADRPT -a*\{1\} bC BADRPT -a\{1\}* bC BADRPT - -# brackets, and numerous perversions thereof -a[b]c & abc abc -a[ab]c & abc abc -a[^ab]c & adc adc -a[]b]c & a]c a]c -a[[b]c & a[c a[c -a[-b]c & a-c a-c -a[^]b]c & adc adc -a[^-b]c & adc adc -a[b-]c & a-c a-c -a[b &C EBRACK -a[] &C EBRACK -a[1-3]c & a2c a2c -a[3-1]c &C ERANGE -a[1-3-5]c &C ERANGE -a[[.-.]--]c & a-c a-c -a[1- &C ERANGE -a[[. &C EBRACK -a[[.x &C EBRACK -a[[.x. &C EBRACK -a[[.x.] &C EBRACK -a[[.x.]] & ax ax -a[[.x,.]] &C ECOLLATE -a[[.one.]]b & a1b a1b -a[[.notdef.]]b &C ECOLLATE -a[[.].]]b & a]b a]b -a[[:alpha:]]c & abc abc -a[[:notdef:]]c &C ECTYPE -a[[: &C EBRACK -a[[:alpha &C EBRACK -a[[:alpha:] &C EBRACK -a[[:alpha,:] &C ECTYPE -a[[:]:]]b &C ECTYPE -a[[:-:]]b &C ECTYPE -a[[:alph:]] &C ECTYPE -a[[:alphabet:]] &C ECTYPE -##[[:alnum:]]+ - -%@a0X- a0X -##[[:alpha:]]+ - -%@aX0- aX -[[:blank:]]+ - aSSTb SST -##[[:cntrl:]]+ - aNTb NT -[[:digit:]]+ - a019b 019 -##[[:graph:]]+ - Sa%bS a%b -[[:lower:]]+ - AabC ab -##[[:print:]]+ - NaSbN aSb -##[[:punct:]]+ - S%-&T %-& -[[:space:]]+ - aSNTb SNT -[[:upper:]]+ - aBCd BC -[[:xdigit:]]+ - p0f3Cq 0f3C -a[[=b=]]c & abc abc -a[[= &C EBRACK -a[[=b &C EBRACK -a[[=b= &C EBRACK -a[[=b=] &C EBRACK -a[[=b,=]] &C ECOLLATE -a[[=one=]]b & a1b a1b - -# complexities -a(((b)))c - abc abc -a(b|(c))d - abd abd -a(b*|c)d - abbd abbd -# just gotta have one DFA-buster, of course -a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab -# and an inline expansion in case somebody gets tricky -a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab -# and in case somebody just slips in an NFA... -a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights -# fish for anomalies as the number of states passes 32 -12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789 -123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890 -1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901 -12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012 -123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123 -# and one really big one, beyond any plausible word width -1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890 -# fish for problems as brackets go past 8 -[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm -[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo -[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq -[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq - -# subtleties of matching -abc & xabcy abc -a\(b\)?c\1d b acd -aBc i Abc Abc -a[Bc]*d i abBCcd abBCcd -0[[:upper:]]1 &i 0a1 0a1 -0[[:lower:]]1 &i 0A1 0A1 -a[^b]c &i abc -a[^b]c &i aBc -a[^b]c &i adc adc -[a]b[c] - abc abc -[a]b[a] - aba aba -[abc]b[abc] - abc abc -[abc]b[abd] - abd abd -a(b?c)+d - accd accd -(wee|week)(knights|night) - weeknights weeknights -(we|wee|week|frob)(knights|night|day) - weeknights weeknights -a[bc]d - xyzaaabcaababdacd abd -a[ab]c - aaabc abc -abc s abc abc -a* & b @b - -# Let's have some fun -- try to match a C comment. -# first the obvious, which looks okay at first glance... -/\*.*\*/ - /*x*/ /*x*/ -# but... -/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/ -# okay, we must not match */ inside; try to do that... -/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/ -/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/ -# but... -/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/ -# and a still fancier version, which does it right (I think)... -/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/ -/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/ -/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/ -/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/ -/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/ -/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/ - -# subexpressions -a(b)(c)d - abcd abcd b,c -a(((b)))c - abc abc b,b,b -a(b|(c))d - abd abd b,- -a(b*|c|e)d - abbd abbd bb -a(b*|c|e)d - acd acd c -a(b*|c|e)d - ad ad @d -a(b?)c - abc abc b -a(b?)c - ac ac @c -a(b+)c - abc abc b -a(b+)c - abbbc abbbc bbb -a(b*)c - ac ac @c -(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de -# the regression tester only asks for 9 subexpressions -a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j -a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k -a([bc]?)c - abc abc b -a([bc]?)c - ac ac @c -a([bc]+)c - abc abc b -a([bc]+)c - abcc abcc bc -a([bc]+)bc - abcbc abcbc bc -a(bb+|b)b - abb abb b -a(bbb+|bb+|b)b - abb abb b -a(bbb+|bb+|b)b - abbb abbb bb -a(bbb+|bb+|b)bb - abbb abbb b -(.*).* - abcdef abcdef abcdef -##(a*)* - bc @b @b - -# do we get the right subexpression when it is used more than once? -a(b|c)*d - ad ad - -a(b|c)*d - abcd abcd c -a(b|c)+d - abd abd b -a(b|c)+d - abcd abcd c -a(b|c?)+d - ad ad @d -a(b|c?)+d - abcd abcd @d -a(b|c){0,0}d - ad ad - -a(b|c){0,1}d - ad ad - -a(b|c){0,1}d - abd abd b -a(b|c){0,2}d - ad ad - -a(b|c){0,2}d - abcd abcd c -a(b|c){0,}d - ad ad - -a(b|c){0,}d - abcd abcd c -a(b|c){1,1}d - abd abd b -a(b|c){1,1}d - acd acd c -a(b|c){1,2}d - abd abd b -a(b|c){1,2}d - abcd abcd c -a(b|c){1,}d - abd abd b -a(b|c){1,}d - abcd abcd c -a(b|c){2,2}d - acbd acbd b -a(b|c){2,2}d - abcd abcd c -a(b|c){2,4}d - abcd abcd c -a(b|c){2,4}d - abcbd abcbd b -a(b|c){2,4}d - abcbcd abcbcd c -a(b|c){2,}d - abcd abcd c -a(b|c){2,}d - abcbd abcbd b -##a(b+|((c)*))+d - abd abd @d,@d,- -##a(b+|((c)*))+d - abcd abcd @d,@d,- - -# check out the STARTEND option -[abc] &# a(b)c b -[abc] &# a(d)c -[abc] &# a(bc)d b -[abc] &# a(dc)d c -. &# a()c -b.*c &# b(bc)c bc -b.* &# b(bc)c bc -.*c &# b(bc)c bc - -# plain strings, with the NOSPEC flag -abc m abc abc -abc m xabcy abc -abc m xyz -a*b m aba*b a*b -a*b m ab -"" mC EMPTY - -# cases involving NULs -aZb & a a -aZb &p a -#aZb &p# (aZb) aZb -aZ*b &p# (ab) ab -#a.b &# (aZb) aZb -#a.* &# (aZb)c aZb - -# word boundaries (ick) -[[:<:]]a & a a -[[:<:]]a & ba -[[:<:]]a & -a a -a[[:>:]] & a a -a[[:>:]] & ab -a[[:>:]] & a- a -[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc -[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc -[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc -[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc -[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_ -[[:<:]]a_b[[:>:]] & x_a_b - -# past problems, and suspected problems -(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1 -abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop -abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv -(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11 -CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11 -Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz -a?b - ab ab --\{0,1\}[0-9]*$ b -5 -5 diff --git a/gnu/usr.bin/grep/tests/warning.sh b/gnu/usr.bin/grep/tests/warning.sh deleted file mode 100755 index bfca533a967..00000000000 --- a/gnu/usr.bin/grep/tests/warning.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# -# Tell them not to be alarmed. - -: ${srcdir=.} - -failures=0 - -# -cat <<\EOF - -Please, do not be alarmed if some of the tests failed. -Report them to , -with the line number, the name of the file, -and grep version number 'grep --version'. -Make sure you have the word grep in the subject. -Thank You. - -EOF diff --git a/gnu/usr.bin/grep/xalloc.h b/gnu/usr.bin/grep/xalloc.h deleted file mode 100644 index 098a6c2e073..00000000000 --- a/gnu/usr.bin/grep/xalloc.h +++ /dev/null @@ -1,87 +0,0 @@ -/* xalloc.h -- malloc with out-of-memory checking - Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef XALLOC_H_ -# define XALLOC_H_ - -# ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -# endif - -# ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_NORETURN -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) -# endif - -/* Exit value when the requested amount of memory is not available. - It is initialized to EXIT_FAILURE, but the caller may set it to - some other value. */ -extern int xalloc_exit_failure; - -/* If this pointer is non-zero, run the specified function upon each - allocation failure. It is initialized to zero. */ -extern void (*xalloc_fail_func) PARAMS ((void)); - -/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this - message is output. It is translated via gettext. - Its value is "memory exhausted". */ -extern char const xalloc_msg_memory_exhausted[]; - -/* This function is always triggered when memory is exhausted. It is - in charge of honoring the three previous items. This is the - function to call when one wants the program to die because of a - memory allocation failure. */ -extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN; - -void *xmalloc PARAMS ((size_t n)); -void *xcalloc PARAMS ((size_t n, size_t s)); -void *xrealloc PARAMS ((void *p, size_t n)); -char *xstrdup PARAMS ((const char *str)); - -# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items))) -# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items))) -# define XREALLOC(Ptr, Type, N_items) \ - ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items))) - -/* Declare and alloc memory for VAR of type TYPE. */ -# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1) - -/* Free VAR only if non NULL. */ -# define XFREE(Var) \ - do { \ - if (Var) \ - free (Var); \ - } while (0) - -/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */ -# define CCLONE(Src, Num) \ - (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num))) - -/* Return a malloc'ed copy of SRC. */ -# define CLONE(Src) CCLONE (Src, 1) - - -#endif /* !XALLOC_H_ */ diff --git a/gnu/usr.bin/grep/xmalloc.c b/gnu/usr.bin/grep/xmalloc.c deleted file mode 100644 index 2f103d60491..00000000000 --- a/gnu/usr.bin/grep/xmalloc.c +++ /dev/null @@ -1,116 +0,0 @@ -/* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include - -#if STDC_HEADERS -# include -#else -void *calloc (); -void *malloc (); -void *realloc (); -void free (); -#endif - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define textdomain(Domain) -# define _(Text) Text -#endif -#define N_(Text) Text - -#include "error.h" -#include "xalloc.h" - -#ifndef EXIT_FAILURE -# define EXIT_FAILURE 1 -#endif - -#ifndef HAVE_DONE_WORKING_MALLOC_CHECK -"you must run the autoconf test for a properly working malloc -- see malloc.m4" -#endif - -#ifndef HAVE_DONE_WORKING_REALLOC_CHECK -"you must run the autoconf test for a properly working realloc --see realloc.m4" -#endif - -/* Exit value when the requested amount of memory is not available. - The caller may set it to some other value. */ -int xalloc_exit_failure = EXIT_FAILURE; - -/* If non NULL, call this function when memory is exhausted. */ -void (*xalloc_fail_func) PARAMS ((void)) = 0; - -/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message - before exiting when memory is exhausted. Goes through gettext. */ -char const xalloc_msg_memory_exhausted[] = N_("memory exhausted"); - -void -xalloc_die (void) -{ - if (xalloc_fail_func) - (*xalloc_fail_func) (); - error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); - /* The `noreturn' cannot be given to error, since it may return if - its first argument is 0. To help compilers understand the - xalloc_die does terminate, call exit. */ - exit (EXIT_FAILURE); -} - -/* Allocate N bytes of memory dynamically, with error checking. */ - -void * -xmalloc (size_t n) -{ - void *p; - - p = malloc (n); - if (p == 0) - xalloc_die (); - return p; -} - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. */ - -void * -xrealloc (void *p, size_t n) -{ - p = realloc (p, n); - if (p == 0) - xalloc_die (); - return p; -} - -/* Allocate memory for N elements of S bytes, with error checking. */ - -void * -xcalloc (size_t n, size_t s) -{ - void *p; - - p = calloc (n, s); - if (p == 0) - xalloc_die (); - return p; -} diff --git a/gnu/usr.bin/grep/xstrtol.c b/gnu/usr.bin/grep/xstrtol.c deleted file mode 100644 index 07023d9ffdb..00000000000 --- a/gnu/usr.bin/grep/xstrtol.c +++ /dev/null @@ -1,282 +0,0 @@ -/* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998-2000 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Jim Meyering. */ - -#if HAVE_CONFIG_H -# include -#endif - -#ifndef __strtol -# define __strtol strtol -# define __strtol_t long int -# define __xstrtol xstrtol -#endif - -/* Some pre-ANSI implementations (e.g. SunOS 4) - need stderr defined if assertion checking is enabled. */ -#include - -#if STDC_HEADERS -# include -#endif - -#if HAVE_STRING_H -# include -#else -# include -# ifndef strchr -# define strchr index -# endif -#endif - -#include -#include - -#include -#ifndef errno -extern int errno; -#endif - -#if HAVE_LIMITS_H -# include -#endif - -#ifndef CHAR_BIT -# define CHAR_BIT 8 -#endif - -/* The extra casts work around common compiler bugs. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. - It is necessary at least when t == time_t. */ -#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) -#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t)) - -#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) -# define IN_CTYPE_DOMAIN(c) 1 -#else -# define IN_CTYPE_DOMAIN(c) isascii(c) -#endif - -#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) - -#include "xstrtol.h" - -#ifndef strtol -long int strtol (); -#endif - -#ifndef strtoul -unsigned long int strtoul (); -#endif - -#ifndef strtoumax -uintmax_t strtoumax (); -#endif - -static int -bkm_scale (__strtol_t *x, int scale_factor) -{ - __strtol_t product = *x * scale_factor; - if (*x != product / scale_factor) - return 1; - *x = product; - return 0; -} - -static int -bkm_scale_by_power (__strtol_t *x, int base, int power) -{ - while (power--) - if (bkm_scale (x, base)) - return 1; - - return 0; -} - -/* FIXME: comment. */ - -strtol_error -__xstrtol (const char *s, char **ptr, int strtol_base, - __strtol_t *val, const char *valid_suffixes) -{ - char *t_ptr; - char **p; - __strtol_t tmp; - - assert (0 <= strtol_base && strtol_base <= 36); - - p = (ptr ? ptr : &t_ptr); - - if (! TYPE_SIGNED (__strtol_t)) - { - const char *q = s; - while (ISSPACE ((unsigned char) *q)) - ++q; - if (*q == '-') - return LONGINT_INVALID; - } - - errno = 0; - tmp = __strtol (s, p, strtol_base); - if (errno != 0) - return LONGINT_OVERFLOW; - if (*p == s) - return LONGINT_INVALID; - - /* Let valid_suffixes == NULL mean `allow any suffix'. */ - /* FIXME: update all callers except the ones that allow suffixes - after the number, changing last parameter NULL to `""'. */ - if (!valid_suffixes) - { - *val = tmp; - return LONGINT_OK; - } - - if (**p != '\0') - { - int base = 1024; - int suffixes = 1; - int overflow; - - if (!strchr (valid_suffixes, **p)) - { - *val = tmp; - return LONGINT_INVALID_SUFFIX_CHAR; - } - - if (strchr (valid_suffixes, '0')) - { - /* The ``valid suffix'' '0' is a special flag meaning that - an optional second suffix is allowed, which can change - the base, e.g. "100MD" for 100 megabytes decimal. */ - - switch (p[0][1]) - { - case 'B': - suffixes++; - break; - - case 'D': - base = 1000; - suffixes++; - break; - } - } - - switch (**p) - { - case 'b': - overflow = bkm_scale (&tmp, 512); - break; - - case 'B': - overflow = bkm_scale (&tmp, 1024); - break; - - case 'c': - overflow = 0; - break; - - case 'E': /* Exa */ - overflow = bkm_scale_by_power (&tmp, base, 6); - break; - - case 'G': /* Giga */ - overflow = bkm_scale_by_power (&tmp, base, 3); - break; - - case 'k': /* kilo */ - overflow = bkm_scale_by_power (&tmp, base, 1); - break; - - case 'M': /* Mega */ - case 'm': /* 'm' is undocumented; for backward compatibility only */ - overflow = bkm_scale_by_power (&tmp, base, 2); - break; - - case 'P': /* Peta */ - overflow = bkm_scale_by_power (&tmp, base, 5); - break; - - case 'T': /* Tera */ - overflow = bkm_scale_by_power (&tmp, base, 4); - break; - - case 'w': - overflow = bkm_scale (&tmp, 2); - break; - - case 'Y': /* Yotta */ - overflow = bkm_scale_by_power (&tmp, base, 8); - break; - - case 'Z': /* Zetta */ - overflow = bkm_scale_by_power (&tmp, base, 7); - break; - - default: - *val = tmp; - return LONGINT_INVALID_SUFFIX_CHAR; - break; - } - - if (overflow) - return LONGINT_OVERFLOW; - - (*p) += suffixes; - } - - *val = tmp; - return LONGINT_OK; -} - -#ifdef TESTING_XSTRTO - -# include -# include "error.h" - -char *program_name; - -int -main (int argc, char** argv) -{ - strtol_error s_err; - int i; - - program_name = argv[0]; - for (i=1; i%lu (%s)\n", argv[i], val, p); - } - else - { - STRTOL_FATAL_ERROR (argv[i], "arg", s_err); - } - } - exit (0); -} - -#endif /* TESTING_XSTRTO */ diff --git a/gnu/usr.bin/grep/xstrtol.h b/gnu/usr.bin/grep/xstrtol.h deleted file mode 100644 index 7a9a024457f..00000000000 --- a/gnu/usr.bin/grep/xstrtol.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef XSTRTOL_H_ -# define XSTRTOL_H_ 1 - -# if HAVE_INTTYPES_H -# include /* for uintmax_t */ -# endif - -# ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () -# endif -# endif - -# ifndef _STRTOL_ERROR -enum strtol_error - { - LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW - }; -typedef enum strtol_error strtol_error; -# endif - -# define _DECLARE_XSTRTOL(name, type) \ - strtol_error \ - name PARAMS ((const char *s, char **ptr, int base, \ - type *val, const char *valid_suffixes)); -_DECLARE_XSTRTOL (xstrtol, long int) -_DECLARE_XSTRTOL (xstrtoul, unsigned long int) -_DECLARE_XSTRTOL (xstrtoumax, uintmax_t) - -# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \ - do \ - { \ - switch ((Err)) \ - { \ - case LONGINT_OK: \ - abort (); \ - \ - case LONGINT_INVALID: \ - error ((Exit_code), 0, "invalid %s `%s'", \ - (Argument_type_string), (Str)); \ - break; \ - \ - case LONGINT_INVALID_SUFFIX_CHAR: \ - error ((Exit_code), 0, "invalid character following %s `%s'", \ - (Argument_type_string), (Str)); \ - break; \ - \ - case LONGINT_OVERFLOW: \ - error ((Exit_code), 0, "%s `%s' too large", \ - (Argument_type_string), (Str)); \ - break; \ - } \ - } \ - while (0) - -# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \ - _STRTOL_ERROR (2, Str, Argument_type_string, Err) - -# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \ - _STRTOL_ERROR (0, Str, Argument_type_string, Err) - -#endif /* not XSTRTOL_H_ */ diff --git a/gnu/usr.bin/grep/xstrtoumax.c b/gnu/usr.bin/grep/xstrtoumax.c deleted file mode 100644 index 04d7cf98ae4..00000000000 --- a/gnu/usr.bin/grep/xstrtoumax.c +++ /dev/null @@ -1,31 +0,0 @@ -/* xstrtoumax.c -- A more useful interface to strtoumax. - Copyright 1999 Free Software Foundation, Inc. - - This program 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 2, 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, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Paul Eggert. */ - -#if HAVE_CONFIG_H -# include -#endif - -#if HAVE_INTTYPES_H -# include -#endif - -#define __strtol strtoumax -#define __strtol_t uintmax_t -#define __xstrtol xstrtoumax -#include "xstrtol.c" diff --git a/gnu/usr.bin/rcs/CREDITS b/gnu/usr.bin/rcs/CREDITS deleted file mode 100644 index b3a5d21cde9..00000000000 --- a/gnu/usr.bin/rcs/CREDITS +++ /dev/null @@ -1,24 +0,0 @@ -RCS was designed and built by Walter F. Tichy of Purdue University. -RCS version 3 was released in 1983. - -Adam Hammer, Thomas Narten, and Daniel Trinkle of Purdue supported RCS through -version 4.3, released in 1990. Guy Harris of Sun contributed many porting -fixes. Paul Eggert of System Development Corporation contributed bug fixes -and tuneups. Jay Lepreau contributed 4.3BSD support. - -Paul Eggert of Twin Sun wrote the changes for RCS versions 5.5 and 5.6 (1991). -Rich Braun of Kronos and Andy Glew of Intel contributed ideas for new options. -Bill Hahn of Stratus contributed ideas for setuid support. -Ideas for piece tables came from Joe Berkovitz of Stratus and Walter F. Tichy. -Matt Cross of Stratus contributed test case ideas. -Adam Hammer of Purdue QAed. - -Paul Eggert wrote most of the changes for this version of RCS, -currently in beta test. K. Richard Pixley of Cygnus Support -contributed several bug fixes. Robert Lupton of Princeton -and Daniel Trinkle contributed ideas for $Name expansion. -Brendan Kehoe of Cygnus Support suggested rlog's -N option. -Paul D. Smith of Data General suggested improvements in option -and error processing. Adam Hammer of Purdue QAed. - -$FreeBSD: stable/11/gnu/usr.bin/rcs/CREDITS 50472 1999-08-27 23:37:10Z peter $ diff --git a/gnu/usr.bin/rcs/Makefile b/gnu/usr.bin/rcs/Makefile deleted file mode 100644 index 4a1371637b3..00000000000 --- a/gnu/usr.bin/rcs/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/Makefile 289393 2015-10-15 22:55:08Z bdrewery $ - -SUBDIR= lib .WAIT \ - ci co merge rcs rcsclean rcsdiff rcsmerge rlog rcsfreeze -SUBDIR_PARALLEL= - -.include diff --git a/gnu/usr.bin/rcs/Makefile.inc b/gnu/usr.bin/rcs/Makefile.inc deleted file mode 100644 index 6870321ea2b..00000000000 --- a/gnu/usr.bin/rcs/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/Makefile.inc 270168 2014-08-19 15:04:32Z bdrewery $ - -LIBRCS= ${.OBJDIR}/../lib/librcs.a diff --git a/gnu/usr.bin/rcs/NEWS b/gnu/usr.bin/rcs/NEWS deleted file mode 100644 index 0367bd7a4fc..00000000000 --- a/gnu/usr.bin/rcs/NEWS +++ /dev/null @@ -1,548 +0,0 @@ -Recent changes to RCS (and possible future changes) - - $FreeBSD: stable/11/gnu/usr.bin/rcs/NEWS 50472 1999-08-27 23:37:10Z peter $ - - Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - - This file is part of RCS. - - RCS 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 2, or (at your - option) any later version. - - RCS 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 RCS; see the file COPYING. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - - -Here is a brief summary of user-visible changes since 5.6. - - New options: - `-kb' supports binary files. - `-T' preserves the modification time of RCS files. - `-V' prints the version number. - `-zLT' causes RCS to use local time in working files and logs. - `rcsclean -n' outputs what rcsclean would do, without actually doing it. - `rlog -N' omits symbolic names. - There is a new keyword `Name'. - Inserted log lines now have the same prefix as the preceding `$Log' line. - -Most changes for RCS version 5.7 are to fix bugs and improve portability. -RCS now conforms to GNU configuration standards and to Posix 1003.1b-1993. - - -Features new to RCS version 5.7, and possibly incompatible -in minor ways with previous practice, include: - - Inserted log lines now have the same prefix as the preceding `$Log' line. - E.g. if a $Log line starts with `// $Log', log lines are prefixed with `// '. - RCS still records the (now obsolescent) comment leader inside RCS files, - but it ignores the comment leader unless it is emulating older RCS versions. - If you plan to access a file with both old and new versions of RCS, - make sure its comment leader matches its `$Log' line prefix. - For backwards compatibility with older versions of RCS, - if the log prefix is `/*' or `(*' surrounded by optional white space, - inserted log lines contain ` *' instead of `/*' or `(*'; - however, this usage is obsolescent and should not be relied on. - - $Log string `Revision' times now use the same format as other times. - - Log lines are now inserted even if -kk is specified; this simplifies merging. - - ci's -rR option (with a nonempty R) now just specifies a revision number R. - In some beta versions, it also reestablished the default behavior of - releasing a lock and removing the working file. - Now, only the bare -r option does this. - - With an empty extension, any appearance of a directory named `RCS' - in a pathname identifies the pathname as being that of an RCS file. - For example, `a/RCS/b/c' is now an RCS file with an empty extension. - Formerly, `RCS' had to be the last directory in the pathname. - - rlog's -d option by default now uses exclusive time ranges. - E.g. `rlog -d" - - for software engineering; e.g. see - . - - - - for configuration management - - - - for CVS (see below) - - -RCS and related GNU project software - - - The RCS project distribution directory also contains beta versions, - ports, and prebuilt documentation. - - - The GNU project distribution directory contains: - diffutils-N-tar.gz - the latest diffutils release; recommended for RCS - emacs-N-tar.gz - The latest Emacs release contains VC, a version-control package - that makes RCS easier to use. - make-N-tar.gz - GNU Make, which can automatically build from RCS files. - rcs-N-tar.gz - the latest RCS release - cvs-N-tar.gz - the latest official CVS release (see below) - - DOS, OS/2 ports - NT port - - -CVS - -CVS, the Concurrent Versions System, keeps tracks of source changes -made by groups of developers working on the same files concurrently, -allowing them to resync as needed. - - - - These pages have useful information about CVS. - - - CVS 1.3 is the latest released version. - - - CVS 1.4 is in alpha test, but it is recommended if you are installing CVS - for the first time, or on a recent operating system. - - DOS, OS/2 ports - NT port - - - Cyclic CVS adds network transparency to CVS; it supports efficient, - reliable, and authenticated repository access via TCP/IP. - - -Other software that uses RCS - - - Aegis manages revisions, baselines, mandatory reviews, and mandatory testing. - - - BCS, the Baseline Configuration System, - manages revisions, baselines, and staging areas. - - - ODE, the Open Software Foundation Development Environment, - manages revisions, builds, and sandboxes. - OSF uses it for their own development. - - - Odin, a `make' replacement, can build directly from arbitrary revisions - without requiring checkouts of working copies. It also handles - parallel builds on multiple remote hosts and of multiple variants. diff --git a/gnu/usr.bin/rcs/ci/Makefile b/gnu/usr.bin/rcs/ci/Makefile deleted file mode 100644 index 2fbb74f4238..00000000000 --- a/gnu/usr.bin/rcs/ci/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROG= ci -SRCS= ci.c -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/ci/Makefile.depend b/gnu/usr.bin/rcs/ci/Makefile.depend deleted file mode 100644 index 251919a3b3d..00000000000 --- a/gnu/usr.bin/rcs/ci/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/ci/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/ci/ci.1 b/gnu/usr.bin/rcs/ci/ci.1 deleted file mode 100644 index 5ed005bcf57..00000000000 --- a/gnu/usr.bin/rcs/ci/ci.1 +++ /dev/null @@ -1,898 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/ci/ci.1 50472 1999-08-27 23:37:10Z peter $ -.ds i \&\s-1ISO\s0 -.ds r \&\s-1RCS\s0 -.ds u \&\s-1UTC\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH CI 1 \*(Dt GNU -.SH NAME -ci \- check in RCS revisions -.SH SYNOPSIS -.B ci -.RI [ options ] " file " .\|.\|. -.SH DESCRIPTION -.B ci -stores new revisions into \*r files. -Each pathname matching an \*r suffix -is taken to be an \*r file. -All others -are assumed to be working files containing new revisions. -.B ci -deposits the contents of each working file -into the corresponding \*r file. -If only a working file is given, -.B ci -tries to find the corresponding \*r file in an \*r subdirectory -and then in the working file's directory. -For more details, see -.SM "FILE NAMING" -below. -.PP -For -.B ci -to work, the caller's login must be on the access list, -except if the access list is empty or the caller is the superuser or the -owner of the file. -To append a new revision to an existing branch, the tip revision on -that branch must be locked by the caller. Otherwise, only a -new branch can be created. This restriction is not enforced -for the owner of the file if non-strict locking is used -(see -.BR rcs (1)). -A lock held by someone else can be broken with the -.B rcs -command. -.PP -Unless the -.B \-f -option is given, -.B ci -checks whether the revision to be deposited differs from the preceding one. -If not, instead of creating a new revision -.B ci -reverts to the preceding one. -To revert, ordinary -.B ci -removes the working file and any lock; -.B "ci\ \-l" -keeps and -.B "ci\ \-u" -removes any lock, and then they both generate a new working file much as if -.B "co\ \-l" -or -.B "co\ \-u" -had been applied to the preceding revision. -When reverting, any -.B \-n -and -.B \-s -options apply to the preceding revision. -.PP -For each revision deposited, -.B ci -prompts for a log message. -The log message should summarize the change and must be terminated by -end-of-file or by a line containing -.BR \&. "\ by" -itself. -If several files are checked in -.B ci -asks whether to reuse the -previous log message. -If the standard input is not a terminal, -.B ci -suppresses the prompt -and uses the same log message for all files. -See also -.BR \-m . -.PP -If the \*r file does not exist, -.B ci -creates it and -deposits the contents of the working file as the initial revision -(default number: -.BR 1.1 ). -The access list is initialized to empty. -Instead of the log message, -.B ci -requests descriptive text (see -.B \-t -below). -.PP -The number -.I rev -of the deposited revision can be given by any of the options -.BR \-f , -.BR \-i , -.BR \-I , -.BR \-j , -.BR \-k , -.BR \-l , -.BR \-M , -.BR \-q , -.BR \-r , -or -.BR \-u . -.I rev -can be symbolic, numeric, or mixed. -Symbolic names in -.I rev -must already be defined; -see the -.B \-n -and -.B \-N -options for assigning names during checkin. -If -.I rev -is -.BR $ , -.B ci -determines the revision number from keyword values in the working file. -.PP -If -.I rev -begins with a period, -then the default branch (normally the trunk) is prepended to it. -If -.I rev -is a branch number followed by a period, -then the latest revision on that branch is used. -.PP -If -.I rev -is a revision number, it must be higher than the latest -one on the branch to which -.I rev -belongs, or must start a new branch. -.PP -If -.I rev -is a branch rather than a revision number, -the new revision is appended to that branch. The level number is obtained -by incrementing the tip revision number of that branch. -If -.I rev -indicates a non-existing branch, -that branch is created with the initial revision numbered -.IB rev .1\f1.\fP -.br -.ne 8 -.PP -If -.I rev -is omitted, -.B ci -tries to derive the new revision number from -the caller's last lock. If the caller has locked the tip revision of a branch, -the new revision is appended to that branch. -The new revision number is obtained -by incrementing the tip revision number. -If the caller locked a non-tip revision, a new branch is started at -that revision by incrementing the highest branch number at that revision. -The default initial branch and level numbers are -.BR 1 . -.PP -If -.I rev -is omitted and the caller has no lock, but owns -the file and locking -is not set to -.IR strict , -then the revision is appended to the -default branch (normally the trunk; see the -.B \-b -option of -.BR rcs (1)). -.PP -Exception: On the trunk, revisions can be appended to the end, but -not inserted. -.SH OPTIONS -.TP -.BI \-r rev -Check in revision -.IR rev . -.TP -.BR \-r -The bare -.B \-r -option (without any revision) has an unusual meaning in -.BR ci . -With other \*r commands, a bare -.B \-r -option specifies the most recent revision on the default branch, -but with -.BR ci , -a bare -.B \-r -option reestablishes the default behavior of releasing a lock and -removing the working file, and is used to override any default -.B \-l -or -.B \-u -options established by shell aliases or scripts. -.TP -.BR \-l [\f2rev\fP] -works like -.BR \-r , -except it performs an additional -.B "co\ \-l" -for the -deposited revision. Thus, the deposited revision is immediately -checked out again and locked. -This is useful for saving a revision although one wants to continue -editing it after the checkin. -.TP -.BR \-u [\f2rev\fP] -works like -.BR \-l , -except that the deposited revision is not locked. -This lets one read the working file -immediately after checkin. -.RS -.PP -The -.BR \-l , -bare -.BR \-r , -and -.B \-u -options are mutually exclusive and silently override each other. -For example, -.B "ci\ \-u\ \-r" -is equivalent to -.B "ci\ \-r" -because bare -.B \-r -overrides -.BR \-u . -.RE -.TP -.BR \-f [\f2rev\fP] -forces a deposit; the new revision is deposited even it is not different -from the preceding one. -.TP -.BR \-k [\f2rev\fP] -searches the working file for keyword values to determine its revision number, -creation date, state, and author (see -.BR co (1)), -and assigns these -values to the deposited revision, rather than computing them locally. -It also generates a default login message noting the login of the caller -and the actual checkin date. -This option is useful for software distribution. A revision that is sent to -several sites should be checked in with the -.B \-k -option at these sites to -preserve the original number, date, author, and state. -The extracted keyword values and the default log message can be overridden -with the options -.BR \-d , -.BR \-m , -.BR \-s , -.BR \-w , -and any option that carries a revision number. -.TP -.BR \-q [\f2rev\fP] -quiet mode; diagnostic output is not printed. -A revision that is not different from the preceding one is not deposited, -unless -.B \-f -is given. -.TP -.BR \-i [\f2rev\fP] -initial checkin; report an error if the \*r file already exists. -This avoids race conditions in certain applications. -.TP -.BR \-j [\f2rev\fP] -just checkin and do not initialize; -report an error if the \*r file does not already exist. -.TP -.BR \-I [\f2rev\fP] -interactive mode; -the user is prompted and questioned -even if the standard input is not a terminal. -.TP -.BR \-d "[\f2date\fP]" -uses -.I date -for the checkin date and time. -The -.I date -is specified in free format as explained in -.BR co (1). -This is useful for lying about the checkin date, and for -.B \-k -if no date is available. -If -.I date -is empty, the working file's time of last modification is used. -.TP -.BR \-M [\f2rev\fP] -Set the modification time on any new working file -to be the date of the retrieved revision. -For example, -.BI "ci\ \-d\ \-M\ \-u" "\ f" -does not alter -.IR f 's -modification time, even if -.IR f 's -contents change due to keyword substitution. -Use this option with care; it can confuse -.BR make (1). -.TP -.BI \-m "msg" -uses the string -.I msg -as the log message for all revisions checked in. -By convention, log messages that start with -.B # -are comments and are ignored by programs like GNU Emacs's -.B vc -package. -Also, log messages that start with -.BI { clumpname } -(followed by white space) are meant to be clumped together if possible, -even if they are associated with different files; the -.BI { clumpname } -label is used only for clumping, -and is not considered to be part of the log message itself. -.TP -.BI \-n "name" -assigns the symbolic name -.I name -to the number of the checked-in revision. -.B ci -prints an error message if -.I name -is already assigned to another -number. -.TP -.BI \-N "name" -same as -.BR \-n , -except that it overrides a previous assignment of -.IR name . -.TP -.BI \-s "state" -sets the state of the checked-in revision to the identifier -.IR state . -The default state is -.BR Exp . -.TP -.BI \-t file -writes descriptive text from the contents of the named -.I file -into the \*r file, -deleting the existing text. -The -.I file -cannot begin with -.BR \- . -.TP -.BI \-t\- string -Write descriptive text from the -.I string -into the \*r file, deleting the existing text. -.RS -.PP -The -.B \-t -option, in both its forms, has effect only during an initial checkin; -it is silently ignored otherwise. -.PP -During the initial checkin, if -.B \-t -is not given, -.B ci -obtains the text from standard input, -terminated by end-of-file or by a line containing -.BR \&. "\ by" -itself. -The user is prompted for the text if interaction is possible; see -.BR \-I . -.PP -For backward compatibility with older versions of \*r, a bare -.B \-t -option is ignored. -.RE -.TP -.B \-T -Set the \*r file's modification time to the new revision's time -if the former precedes the latter and there is a new revision; -preserve the \*r file's modification time otherwise. -If you have locked a revision, -.B ci -usually updates the \*r file's modification time to the current time, -because the lock is stored in the \*r file -and removing the lock requires changing the \*r file. -This can create an \*r file newer than the working file in one of two ways: -first, -.B "ci\ \-M" -can create a working file with a date before the current time; -second, when reverting to the previous revision -the \*r file can change while the working file remains unchanged. -These two cases can cause excessive recompilation caused by a -.BR make (1) -dependency of the working file on the \*r file. -The -.B \-T -option inhibits this recompilation by lying about the \*r file's date. -Use this option with care; it can suppress recompilation even when -a checkin of one working file should affect -another working file associated with the same \*r file. -For example, suppose the \*r file's time is 01:00, -the (changed) working file's time is 02:00, -some other copy of the working file has a time of 03:00, -and the current time is 04:00. -Then -.B "ci\ \-d\ \-T" -sets the \*r file's time to 02:00 instead of the usual 04:00; -this causes -.BR make (1) -to think (incorrectly) that the other copy is newer than the \*r file. -.TP -.BI \-w "login" -uses -.I login -for the author field of the deposited revision. -Useful for lying about the author, and for -.B \-k -if no author is available. -.TP -.BI \-V -Print \*r's version number. -.TP -.BI \-V n -Emulate \*r version -.IR n . -See -.BR co (1) -for details. -.TP -.BI \-x "suffixes" -specifies the suffixes for \*r files. -A nonempty suffix matches any pathname ending in the suffix. -An empty suffix matches any pathname of the form -.BI RCS/ path -or -.IB path1 /RCS/ path2. -The -.B \-x -option can specify a list of suffixes -separated by -.BR / . -For example, -.B \-x,v/ -specifies two suffixes: -.B ,v -and the empty suffix. -If two or more suffixes are specified, -they are tried in order when looking for an \*r file; -the first one that works is used for that file. -If no \*r file is found but an \*r file can be created, -the suffixes are tried in order -to determine the new \*r file's name. -The default for -.IR suffixes -is installation-dependent; normally it is -.B ,v/ -for hosts like Unix that permit commas in filenames, -and is empty (i.e. just the empty suffix) for other hosts. -.TP -.BI \-z zone -specifies the date output format in keyword substitution, -and specifies the default time zone for -.I date -in the -.BI \-d date -option. -The -.I zone -should be empty, a numeric \*u offset, or the special string -.B LT -for local time. -The default is an empty -.IR zone , -which uses the traditional \*r format of \*u without any time zone indication -and with slashes separating the parts of the date; -otherwise, times are output in \*i 8601 format with time zone indication. -For example, if local time is January 11, 1990, 8pm Pacific Standard Time, -eight hours west of \*u, -then the time is output as follows: -.RS -.LP -.RS -.nf -.ta \w'\f3\-z+05:30\fP 'u +\w'\f31990-01-11 09:30:00+05:30\fP 'u -.ne 4 -\f2option\fP \f2time output\fP -\f3\-z\fP \f31990/01/12 04:00:00\fP \f2(default)\fP -\f3\-zLT\fP \f31990-01-11 20:00:00\-08\fP -\f3\-z+05:30\fP \f31990-01-12 09:30:00+05:30\fP -.ta 4n +4n +4n +4n -.fi -.RE -.LP -The -.B \-z -option does not affect dates stored in \*r files, -which are always \*u. -.SH "FILE NAMING" -Pairs of \*r files and working files can be specified in three ways -(see also the -example section). -.PP -1) Both the \*r file and the working file are given. The \*r pathname is of -the form -.IB path1 / workfileX -and the working pathname is of the form -.IB path2 / workfile -where -.IB path1 / -and -.IB path2 / -are (possibly different or empty) paths, -.I workfile -is a filename, and -.I X -is an \*r suffix. -If -.I X -is empty, -.IB path1 / -must start with -.B RCS/ -or must contain -.BR /RCS/ . -.PP -2) Only the \*r file is given. Then the working file is created in the current -directory and its name is derived from the name of the \*r file -by removing -.IB path1 / -and the suffix -.IR X . -.PP -3) Only the working file is given. -Then -.B ci -considers each \*r suffix -.I X -in turn, looking for an \*r file of the form -.IB path2 /RCS/ workfileX -or (if the former is not found and -.I X -is nonempty) -.IB path2 / workfileX. -.PP -If the \*r file is specified without a path in 1) and 2), -.B ci -looks for the \*r file first in the directory -.B ./RCS -and then in the current -directory. -.PP -.B ci -reports an error if an attempt to open an \*r file fails for an unusual reason, -even if the \*r file's pathname is just one of several possibilities. -For example, to suppress use of \*r commands in a directory -.IR d , -create a regular file named -.IB d /RCS -so that casual attempts to use \*r commands in -.I d -fail because -.IB d /RCS -is not a directory. -.SH EXAMPLES -Suppose -.B ,v -is an \*r suffix and the current directory contains a subdirectory -.B RCS -with an \*r file -.BR io.c,v . -Then each of the following commands check in a copy of -.B io.c -into -.B RCS/io.c,v -as the latest revision, removing -.BR io.c . -.LP -.RS -.nf -.ft 3 -ci io.c; ci RCS/io.c,v; ci io.c,v; -ci io.c RCS/io.c,v; ci io.c io.c,v; -ci RCS/io.c,v io.c; ci io.c,v io.c; -.ft -.fi -.RE -.PP -Suppose instead that the empty suffix -is an \*r suffix and the current directory contains a subdirectory -.B RCS -with an \*r file -.BR io.c . -The each of the following commands checks in a new revision. -.LP -.RS -.nf -.ft 3 -ci io.c; ci RCS/io.c; -ci io.c RCS/io.c; -ci RCS/io.c io.c; -.ft -.fi -.RE -.SH "FILE MODES" -An \*r file created by -.B ci -inherits the read and execute permissions -from the working file. If the \*r file exists already, -.B ci -preserves its read and execute permissions. -.B ci -always turns off all write permissions of \*r files. -.SH FILES -Temporary files are created in the directory containing -the working file, and also in the temporary directory (see -.B \s-1TMPDIR\s0 -under -.BR \s-1ENVIRONMENT\s0 ). -A semaphore file or files are created in the directory containing the \*r file. -With a nonempty suffix, the semaphore names begin with -the first character of the suffix; therefore, do not specify an suffix -whose first character could be that of a working filename. -With an empty suffix, the semaphore names end with -.B _ -so working filenames should not end in -.BR _ . -.PP -.B ci -never changes an \*r or working file. -Normally, -.B ci -unlinks the file and creates a new one; -but instead of breaking a chain of one or more symbolic links to an \*r file, -it unlinks the destination file instead. -Therefore, -.B ci -breaks any hard or symbolic links to any working file it changes; -and hard links to \*r files are ineffective, -but symbolic links to \*r files are preserved. -.PP -The effective user must be able to -search and write the directory containing the \*r file. -Normally, the real user must be able to -read the \*r and working files -and to search and write the directory containing the working file; -however, some older hosts -cannot easily switch between real and effective users, -so on these hosts the effective user is used for all accesses. -The effective user is the same as the real user -unless your copies of -.B ci -and -.B co -have setuid privileges. -As described in the next section, -these privileges yield extra security if -the effective user owns all \*r files and directories, -and if only the effective user can write \*r directories. -.PP -Users can control access to \*r files by setting the permissions -of the directory containing the files; only users with write access -to the directory can use \*r commands to change its \*r files. -For example, in hosts that allow a user to belong to several groups, -one can make a group's \*r directories writable to that group only. -This approach suffices for informal projects, -but it means that any group member can arbitrarily change the group's \*r files, -and can even remove them entirely. -Hence more formal projects sometimes distinguish between an \*r administrator, -who can change the \*r files at will, and other project members, -who can check in new revisions but cannot otherwise change the \*r files. -.SH "SETUID USE" -To prevent anybody but their \*r administrator from deleting revisions, -a set of users can employ setuid privileges as follows. -.nr n \w'\(bu'+2n-1/1n -.ds n \nn -.if \n(.g .if r an-tag-sep .ds n \w'\(bu'u+\n[an-tag-sep]u -.IP \(bu \*n -Check that the host supports \*r setuid use. -Consult a trustworthy expert if there are any doubts. -It is best if the -.B seteuid -system call works as described in Posix 1003.1a Draft 5, -because \*r can switch back and forth easily -between real and effective users, even if the real user is -.BR root . -If not, the second best is if the -.B setuid -system call supports saved setuid -(the {\s-1_POSIX_SAVED_IDS\s0} behavior of Posix 1003.1-1990); -this fails only if the real or effective user is -.BR root . -If \*r detects any failure in setuid, it quits immediately. -.IP \(bu \nn -Choose a user -.I A -to serve as \*r administrator for the set of users. -Only -.I A -can invoke the -.B rcs -command on the users' \*r files. -.I A -should not be -.B root -or any other user with special powers. -Mutually suspicious sets of users should use different administrators. -.IP \(bu \nn -Choose a pathname -.I B -to be a directory of files to be executed by the users. -.IP \(bu \nn -Have -.I A -set up -.I B -to contain copies of -.B ci -and -.B co -that are setuid to -.I A -by copying the commands from their standard installation directory -.I D -as follows: -.LP -.RS -.nf -.ne 3 -\f3mkdir\fP \f2B\fP -\f3cp\fP \f2D\fP\^\f3/c[io]\fP \f2B\fP -\f3chmod go\-w,u+s\fP \f2B\fP\f3/c[io]\fP -.fi -.RE -.IP \(bu \nn -Have each user prepend -.I B -to their path as follows: -.LP -.RS -.nf -.ne 2 -\f3PATH=\fP\f2B\fP\f3:$PATH; export PATH\fP # ordinary shell -\f3set path=(\fP\f2B\fP \f3$path)\fP # C shell -.fi -.RE -.IP \(bu \nn -Have -.I A -create each \*r directory -.I R -with write access only to -.I A -as follows: -.LP -.RS -.nf -.ne 2 -\f3mkdir\fP \f2R\fP -\f3chmod go\-w\fP \f2R\fP -.fi -.RE -.IP \(bu \nn -If you want to let only certain users read the \*r files, -put the users into a group -.IR G , -and have -.I A -further protect the \*r directory as follows: -.LP -.RS -.nf -.ne 2 -\f3chgrp\fP \f2G R\fP -\f3chmod g\-w,o\-rwx\fP \f2R\fP -.fi -.RE -.IP \(bu \nn -Have -.I A -copy old \*r files (if any) into -.IR R , -to ensure that -.I A -owns them. -.IP \(bu \nn -An \*r file's access list limits who can check in and lock revisions. -The default access list is empty, -which grants checkin access to anyone who can read the \*r file. -If you want limit checkin access, -have -.I A -invoke -.B "rcs\ \-a" -on the file; see -.BR rcs (1). -In particular, -.BI "rcs\ \-e\ \-a" A -limits access to just -.IR A . -.IP \(bu \nn -Have -.I A -initialize any new \*r files with -.B "rcs\ \-i" -before initial checkin, adding the -.B \-a -option if you want to limit checkin access. -.IP \(bu \nn -Give setuid privileges only to -.BR ci , -.BR co , -and -.BR rcsclean ; -do not give them to -.B rcs -or to any other command. -.IP \(bu \nn -Do not use other setuid commands to invoke \*r commands; -setuid is trickier than you think! -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -A backslash escapes spaces within an option. -The -.B \s-1RCSINIT\s0 -options are prepended to the argument lists of most \*r commands. -Useful -.B \s-1RCSINIT\s0 -options include -.BR \-q , -.BR \-V , -.BR \-x , -and -.BR \-z . -.TP -.B \s-1TMPDIR\s0 -Name of the temporary directory. -If not set, the environment variables -.B \s-1TMP\s0 -and -.B \s-1TEMP\s0 -are inspected instead and the first value found is taken; -if none of them are set, -a host-dependent default is used, typically -.BR /tmp . -.SH DIAGNOSTICS -For each revision, -.B ci -prints the \*r file, the working file, and the number -of both the deposited and the preceding revision. -The exit status is zero if and only if all operations were successful. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH "SEE ALSO" -co(1), -ident(1), make(1), rcs(1), rcsclean(1), rcsdiff(1), -rcsintro(1), rcsmerge(1), rlog(1), setuid(2), rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.br diff --git a/gnu/usr.bin/rcs/ci/ci.c b/gnu/usr.bin/rcs/ci/ci.c deleted file mode 100644 index a9613d58f9d..00000000000 --- a/gnu/usr.bin/rcs/ci/ci.c +++ /dev/null @@ -1,1318 +0,0 @@ -/* Check in revisions of RCS files from working files. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.30 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.29 1995/06/01 16:23:43 eggert - * (main): Add -kb. - * Use `cmpdate', not `cmpnum', to compare dates. - * This is for MKS RCS's incompatible 20th-century date format. - * Don't worry about errno after ftruncate fails. - * Fix input file rewinding bug when large_memory && !maps_memory - * and checking in a branch tip. - * - * (fixwork): Fall back on chmod if fchmod fails, since it might be ENOSYS. - * - * Revision 5.28 1994/03/20 04:52:58 eggert - * Do not generate a corrupted RCS file if the user modifies the working file - * while `ci' is running. - * Do not remove the lock when `ci -l' reverts. - * Move buffer-flushes out of critical sections, since they aren't critical. - * Use ORCSerror to clean up after a fatal error. - * Specify subprocess input via file descriptor, not file name. - * - * Revision 5.27 1993/11/09 17:40:15 eggert - * -V now prints version on stdout and exits. Don't print usage twice. - * - * Revision 5.26 1993/11/03 17:42:27 eggert - * Add -z. Don't subtract from RCS file timestamp even if -T. - * Scan for and use Name keyword if -k. - * Don't discard ignored phrases. Improve quality of diagnostics. - * - * Revision 5.25 1992/07/28 16:12:44 eggert - * Add -i, -j, -V. Check that working and RCS files are distinct. - * - * Revision 5.24 1992/02/17 23:02:06 eggert - * `-rREV' now just specifies a revision REV; only bare `-r' reverts to default. - * Add -T. - * - * Revision 5.23 1992/01/27 16:42:51 eggert - * Always unlock branchpoint if caller has a lock. - * Add support for bad_chmod_close, bad_creat0. lint -> RCS_lint - * - * Revision 5.22 1992/01/06 02:42:34 eggert - * Invoke utime() before chmod() to keep some buggy systems happy. - * - * Revision 5.21 1991/11/20 17:58:07 eggert - * Don't read the delta tree from a nonexistent RCS file. - * - * Revision 5.20 1991/10/07 17:32:46 eggert - * Fix log bugs. Remove lint. - * - * Revision 5.19 1991/09/26 23:10:30 eggert - * Plug file descriptor leak. - * - * Revision 5.18 1991/09/18 07:29:10 eggert - * Work around a common ftruncate() bug. - * - * Revision 5.17 1991/09/10 22:15:46 eggert - * Fix test for redirected stdin. - * - * Revision 5.16 1991/08/19 23:17:54 eggert - * When there are no changes, revert to previous revision instead of aborting. - * Add piece tables, -M, -r$. Tune. - * - * Revision 5.15 1991/04/21 11:58:14 eggert - * Ensure that working file is newer than RCS file after ci -[lu]. - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.14 1991/02/28 19:18:47 eggert - * Don't let a setuid ci create a new RCS file; rcs -i -a must be run first. - * Fix ci -ko -l mode bug. Open work file at most once. - * - * Revision 5.13 1991/02/25 07:12:33 eggert - * getdate -> getcurdate (SVR4 name clash) - * - * Revision 5.12 1990/12/31 01:00:12 eggert - * Don't use uninitialized storage when handling -{N,n}. - * - * Revision 5.11 1990/12/04 05:18:36 eggert - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.10 1990/11/05 20:30:10 eggert - * Don't remove working file when aborting due to no changes. - * - * Revision 5.9 1990/11/01 05:03:23 eggert - * Add -I and new -t behavior. Permit arbitrary data in logs. - * - * Revision 5.8 1990/10/04 06:30:09 eggert - * Accumulate exit status across files. - * - * Revision 5.7 1990/09/25 20:11:46 hammer - * fixed another small typo - * - * Revision 5.6 1990/09/24 21:48:50 hammer - * added cleanups from Paul Eggert. - * - * Revision 5.5 1990/09/21 06:16:38 hammer - * made it handle multiple -{N,n}'s. Also, made it treat re-directed stdin - * the same as the terminal - * - * Revision 5.4 1990/09/20 02:38:51 eggert - * ci -k now checks dates more thoroughly. - * - * Revision 5.3 1990/09/11 02:41:07 eggert - * Fix revision bug with `ci -k file1 file2'. - * - * Revision 5.2 1990/09/04 08:02:10 eggert - * Permit adjacent revisions with identical time stamps (possible on fast hosts). - * Improve incomplete line handling. Standardize yes-or-no procedure. - * - * Revision 5.1 1990/08/29 07:13:44 eggert - * Expand locker value like co. Clean old log messages too. - * - * Revision 5.0 1990/08/22 08:10:00 eggert - * Don't require a final newline. - * Make lock and temp files faster and safer. - * Remove compile-time limits; use malloc instead. - * Permit dates past 1999/12/31. Switch to GMT. - * Add setuid support. Don't pass +args to diff. Check diff's output. - * Ansify and Posixate. Add -k, -V. Remove snooping. Tune. - * Check diff's output. - * - * Revision 4.9 89/05/01 15:10:54 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.8 88/11/08 13:38:23 narten - * changes from root@seismo.CSS.GOV (Super User) - * -d with no arguments uses the mod time of the file it is checking in - * - * Revision 4.7 88/08/09 19:12:07 eggert - * Make sure workfile is a regular file; use its mode if RCSfile doesn't have one. - * Use execv(), not system(); allow cc -R; remove lint. - * isatty(fileno(stdin)) -> ttystdin() - * - * Revision 4.6 87/12/18 11:34:41 narten - * lint cleanups (from Guy Harris) - * - * Revision 4.5 87/10/18 10:18:48 narten - * Updating version numbers. Changes relative to revision 1.1 are actually - * relative to 4.3 - * - * Revision 1.3 87/09/24 13:57:19 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:21:33 jenkins - * Port to suns - * - * Revision 4.3 83/12/15 12:28:54 wft - * ci -u and ci -l now set mode of working file properly. - * - * Revision 4.2 83/12/05 13:40:54 wft - * Merged with 3.9.1.1: added calls to clearerr(stdin). - * made rewriteflag external. - * - * Revision 4.1 83/05/10 17:03:06 wft - * Added option -d and -w, and updated assingment of date, etc. to new delta. - * Added handling of default branches. - * Option -k generates std. log message; fixed undef. pointer in reading of log. - * Replaced getlock() with findlock(), link--unlink with rename(), - * getpwuid() with getcaller(). - * Moved all revision number generation to new routine addelta(). - * Removed calls to stat(); now done by pairfilenames(). - * Changed most calls to catchints() with restoreints(). - * Directed all interactive messages to stderr. - * - * Revision 3.9.1.1 83/10/19 04:21:03 lepreau - * Added clearerr(stdin) to getlogmsg() for re-reading stdin. - * - * Revision 3.9 83/02/15 15:25:44 wft - * 4.2 prerelease - * - * Revision 3.9 83/02/15 15:25:44 wft - * Added call to fastcopy() to copy remainder of RCS file. - * - * Revision 3.8 83/01/14 15:34:05 wft - * Added ignoring of interrupts while new RCS file is renamed; - * Avoids deletion of RCS files by interrupts. - * - * Revision 3.7 82/12/10 16:09:20 wft - * Corrected checking of return code from diff. - * - * Revision 3.6 82/12/08 21:34:49 wft - * Using DATEFORM to prepare date of checked-in revision; - * Fixed return from addbranch(). - * - * Revision 3.5 82/12/04 18:32:42 wft - * Replaced getdelta() with gettree(), SNOOPDIR with SNOOPFILE. Updated - * field lockedby in removelock(), moved getlogmsg() before calling diff. - * - * Revision 3.4 82/12/02 13:27:13 wft - * added option -k. - * - * Revision 3.3 82/11/28 20:53:31 wft - * Added mustcheckin() to check for redundant checkins. - * Added xpandfile() to do keyword expansion for -u and -l; - * -m appends linefeed to log message if necessary. - * getlogmsg() suppresses prompt if stdin is not a terminal. - * Replaced keeplock with lockflag, fclose() with ffclose(), - * %02d with %.2d, getlogin() with getpwuid(). - * - * Revision 3.2 82/10/18 20:57:23 wft - * An RCS file inherits its mode during the first ci from the working file, - * otherwise it stays the same, except that write permission is removed. - * Fixed ci -l, added ci -u (both do an implicit co after the ci). - * Fixed call to getlogin(), added call to getfullRCSname(), added check - * for write error. - * Changed conflicting identifiers. - * - * Revision 3.1 82/10/13 16:04:59 wft - * fixed type of variables receiving from getc() (char -> int). - * added include file dbm.h for getting BYTESIZ. This is used - * to check the return code from diff portably. - */ - -#include "rcsbase.h" - -struct Symrev { - char const *ssymbol; - int override; - struct Symrev * nextsym; -}; - -static char const *getcurdate P((void)); -static int addbranch P((struct hshentry*,struct buf*,int)); -static int addelta P((void)); -static int addsyms P((char const*)); -static int fixwork P((mode_t,time_t)); -static int removelock P((struct hshentry*)); -static int xpandfile P((RILE*,struct hshentry const*,char const**,int)); -static struct cbuf getlogmsg P((void)); -static void cleanup P((void)); -static void incnum P((char const*,struct buf*)); -static void addassoclst P((int,char const*)); - -static FILE *exfile; -static RILE *workptr; /* working file pointer */ -static struct buf newdelnum; /* new revision number */ -static struct cbuf msg; -static int exitstatus; -static int forceciflag; /* forces check in */ -static int keepflag, keepworkingfile, rcsinitflag; -static struct hshentries *gendeltas; /* deltas to be generated */ -static struct hshentry *targetdelta; /* old delta to be generated */ -static struct hshentry newdelta; /* new delta to be inserted */ -static struct stat workstat; -static struct Symrev *assoclst, **nextassoc; - -mainProg(ciId, "ci", "$FreeBSD: stable/11/gnu/usr.bin/rcs/ci/ci.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const cmdusage[] = - "\nci usage: ci -{fIklMqru}[rev] -d[date] -mmsg -{nN}name -sstate -ttext -T -Vn -wwho -xsuff -zzone file ..."; - static char const default_state[] = DEFAULTSTATE; - - char altdate[datesize]; - char olddate[datesize]; - char newdatebuf[datesize + zonelenmax]; - char targetdatebuf[datesize + zonelenmax]; - char *a, **newargv, *textfile; - char const *author, *krev, *rev, *state; - char const *diffname, *expname; - char const *newworkname; - int initflag, mustread; - int lockflag, lockthis, mtimeflag, removedlock, Ttimeflag; - int r; - int changedRCS, changework, dolog, newhead; - int usestatdate; /* Use mod time of file for -d. */ - mode_t newworkmode; /* mode for working file */ - time_t mtime, wtime; - struct hshentry *workdelta; - - setrid(); - - author = rev = state = textfile = 0; - initflag = lockflag = mustread = false; - mtimeflag = false; - Ttimeflag = false; - altdate[0]= '\0'; /* empty alternate date for -d */ - usestatdate=false; - suffixes = X_DEFAULT; - nextassoc = &assoclst; - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - while (a = *++argv, 0<--argc && *a++=='-') { - switch (*a++) { - - case 'r': - if (*a) - goto revno; - keepworkingfile = lockflag = false; - break; - - case 'l': - keepworkingfile = lockflag = true; - revno: - if (*a) { - if (rev) warn("redefinition of revision number"); - rev = a; - } - break; - - case 'u': - keepworkingfile=true; lockflag=false; - goto revno; - - case 'i': - initflag = true; - goto revno; - - case 'j': - mustread = true; - goto revno; - - case 'I': - interactiveflag = true; - goto revno; - - case 'q': - quietflag=true; - goto revno; - - case 'f': - forceciflag=true; - goto revno; - - case 'k': - keepflag=true; - goto revno; - - case 'm': - if (msg.size) redefined('m'); - msg = cleanlogmsg(a, strlen(a)); - if (!msg.size) - error("missing message for -m option"); - break; - - case 'n': - if (!*a) { - error("missing symbolic name after -n"); - break; - } - checkssym(a); - addassoclst(false, a); - break; - - case 'N': - if (!*a) { - error("missing symbolic name after -N"); - break; - } - checkssym(a); - addassoclst(true, a); - break; - - case 's': - if (*a) { - if (state) redefined('s'); - checksid(a); - state = a; - } else - error("missing state for -s option"); - break; - - case 't': - if (*a) { - if (textfile) redefined('t'); - textfile = a; - } - break; - - case 'd': - if (altdate[0] || usestatdate) - redefined('d'); - altdate[0] = '\0'; - if (!(usestatdate = !*a)) - str2date(a, altdate); - break; - - case 'M': - mtimeflag = true; - goto revno; - - case 'w': - if (*a) { - if (author) redefined('w'); - checksid(a); - author = a; - } else - error("missing author for -w option"); - break; - - case 'x': - suffixes = a; - break; - - case 'V': - setRCSversion(*argv); - break; - - case 'z': - zone_set(a); - break; - - case 'T': - if (!*a) { - Ttimeflag = true; - break; - } - /* fall into */ - default: - error("unknown option: %s%s", *argv, cmdusage); - }; - } /* end processing of options */ - - /* Handle all pathnames. */ - if (nerror) cleanup(); - else if (argc < 1) faterror("no input file%s", cmdusage); - else for (; 0 < argc; cleanup(), ++argv, --argc) { - targetdelta = 0; - ffree(); - - switch (pairnames(argc, argv, rcswriteopen, mustread, false)) { - - case -1: /* New RCS file */ -# if has_setuid && has_getuid - if (euid() != ruid()) { - workerror("setuid initial checkin prohibited; use `rcs -i -a' first"); - continue; - } -# endif - rcsinitflag = true; - break; - - case 0: /* Error */ - continue; - - case 1: /* Normal checkin with prev . RCS file */ - if (initflag) { - rcserror("already exists"); - continue; - } - rcsinitflag = !Head; - } - - /* - * RCSname contains the name of the RCS file, and - * workname contains the name of the working file. - * If the RCS file exists, finptr contains the file descriptor for the - * RCS file, and RCSstat is set. The admin node is initialized. - */ - - diagnose("%s <-- %s\n", RCSname, workname); - - if (!(workptr = Iopen(workname, FOPEN_R_WORK, &workstat))) { - eerror(workname); - continue; - } - - if (finptr) { - if (same_file(RCSstat, workstat, 0)) { - rcserror("RCS file is the same as working file %s.", - workname - ); - continue; - } - if (!checkaccesslist()) - continue; - } - - krev = rev; - if (keepflag) { - /* get keyword values from working file */ - if (!getoldkeys(workptr)) continue; - if (!rev && !*(krev = prevrev.string)) { - workerror("can't find a revision number"); - continue; - } - if (!*prevdate.string && *altdate=='\0' && usestatdate==false) - workwarn("can't find a date"); - if (!*prevauthor.string && !author) - workwarn("can't find an author"); - if (!*prevstate.string && !state) - workwarn("can't find a state"); - } /* end processing keepflag */ - - /* Read the delta tree. */ - if (finptr) - gettree(); - - /* expand symbolic revision number */ - if (!fexpandsym(krev, &newdelnum, workptr)) - continue; - - /* splice new delta into tree */ - if ((removedlock = addelta()) < 0) - continue; - - newdelta.num = newdelnum.string; - newdelta.branches = 0; - newdelta.lockedby = 0; /* This might be changed by addlock(). */ - newdelta.selector = true; - newdelta.name = 0; - clear_buf(&newdelta.ig); - clear_buf(&newdelta.igtext); - /* set author */ - if (author) - newdelta.author=author; /* set author given by -w */ - else if (keepflag && *prevauthor.string) - newdelta.author=prevauthor.string; /* preserve old author if possible*/ - else newdelta.author=getcaller();/* otherwise use caller's id */ - newdelta.state = default_state; - if (state) - newdelta.state=state; /* set state given by -s */ - else if (keepflag && *prevstate.string) - newdelta.state=prevstate.string; /* preserve old state if possible */ - if (usestatdate) { - time2date(workstat.st_mtime, altdate); - } - if (*altdate!='\0') - newdelta.date=altdate; /* set date given by -d */ - else if (keepflag && *prevdate.string) { - /* Preserve old date if possible. */ - str2date(prevdate.string, olddate); - newdelta.date = olddate; - } else - newdelta.date = getcurdate(); /* use current date */ - /* now check validity of date -- needed because of -d and -k */ - if (targetdelta && - cmpdate(newdelta.date,targetdelta->date) < 0) { - rcserror("Date %s precedes %s in revision %s.", - date2str(newdelta.date, newdatebuf), - date2str(targetdelta->date, targetdatebuf), - targetdelta->num - ); - continue; - } - - - if (lockflag && addlock(&newdelta, true) < 0) continue; - - if (keepflag && *prevname.string) - if (addsymbol(newdelta.num, prevname.string, false) < 0) - continue; - if (!addsyms(newdelta.num)) - continue; - - - putadmin(); - puttree(Head,frewrite); - putdesc(false,textfile); - - changework = Expand < MIN_UNCHANGED_EXPAND; - dolog = true; - lockthis = lockflag; - workdelta = &newdelta; - - /* build rest of file */ - if (rcsinitflag) { - diagnose("initial revision: %s\n", newdelta.num); - /* get logmessage */ - newdelta.log=getlogmsg(); - putdftext(&newdelta, workptr, frewrite, false); - RCSstat.st_mode = workstat.st_mode; - RCSstat.st_nlink = 0; - changedRCS = true; - } else { - diffname = maketemp(0); - newhead = Head == &newdelta; - if (!newhead) - foutptr = frewrite; - expname = buildrevision( - gendeltas, targetdelta, (FILE*)0, false - ); - if ( - !forceciflag && - strcmp(newdelta.state, targetdelta->state) == 0 && - (changework = rcsfcmp( - workptr, &workstat, expname, targetdelta - )) <= 0 - ) { - diagnose("file is unchanged; reverting to previous revision %s\n", - targetdelta->num - ); - if (removedlock < lockflag) { - diagnose("previous revision was not locked; ignoring -l option\n"); - lockthis = 0; - } - dolog = false; - if (! (changedRCS = lockflagnum, (char*)0, (char*)0, (char*)0, - &gendeltas - ))) - continue; - workdelta->log = targetdelta->log; - if (newdelta.state != default_state) - workdelta->state = newdelta.state; - if (lockthisnum)) - continue; - if (dorewrite(true, true) != 0) - continue; - fastcopy(finptr, frewrite); - if (bad_truncate) - while (ftell(frewrite) < hwm) - /* White out any earlier mistake with '\n's. */ - /* This is unlikely. */ - afputc('\n', frewrite); - } - } else { - int wfd = Ifileno(workptr); - struct stat checkworkstat; - char const *diffv[6 + !!OPEN_O_BINARY], **diffp; -# if large_memory && !maps_memory - FILE *wfile = workptr->stream; - long wfile_off; -# endif -# if !has_fflush_input && !(large_memory && maps_memory) - off_t wfd_off; -# endif - - diagnose("new revision: %s; previous revision: %s\n", - newdelta.num, targetdelta->num - ); - newdelta.log = getlogmsg(); -# if !large_memory - Irewind(workptr); -# if has_fflush_input - if (fflush(workptr) != 0) - Ierror(); -# endif -# else -# if !maps_memory - if ( - (wfile_off = ftell(wfile)) == -1 - || fseek(wfile, 0L, SEEK_SET) != 0 -# if has_fflush_input - || fflush(wfile) != 0 -# endif - ) - Ierror(); -# endif -# endif -# if !has_fflush_input && !(large_memory && maps_memory) - wfd_off = lseek(wfd, (off_t)0, SEEK_CUR); - if (wfd_off == -1 - || (wfd_off != 0 - && lseek(wfd, (off_t)0, SEEK_SET) != 0)) - Ierror(); -# endif - diffp = diffv; - *++diffp = DIFF; - *++diffp = DIFFFLAGS; -# if OPEN_O_BINARY - if (Expand == BINARY_EXPAND) - *++diffp = "--binary"; -# endif - *++diffp = newhead ? "-" : expname; - *++diffp = newhead ? expname : "-"; - *++diffp = 0; - switch (runv(wfd, diffname, diffv)) { - case DIFF_FAILURE: case DIFF_SUCCESS: break; - default: rcsfaterror("diff failed"); - } -# if !has_fflush_input && !(large_memory && maps_memory) - if (lseek(wfd, wfd_off, SEEK_CUR) == -1) - Ierror(); -# endif -# if large_memory && !maps_memory - if (fseek(wfile, wfile_off, SEEK_SET) != 0) - Ierror(); -# endif - if (newhead) { - Irewind(workptr); - putdftext(&newdelta, workptr, frewrite, false); - if (!putdtext(targetdelta,diffname,frewrite,true)) continue; - } else - if (!putdtext(&newdelta,diffname,frewrite,true)) continue; - - /* - * Check whether the working file changed during checkin, - * to avoid producing an inconsistent RCS file. - */ - if ( - fstat(wfd, &checkworkstat) != 0 - || workstat.st_mtime != checkworkstat.st_mtime - || workstat.st_size != checkworkstat.st_size - ) { - workerror("file changed during checkin"); - continue; - } - - changedRCS = true; - } - } - - /* Deduce time_t of new revision if it is needed later. */ - wtime = (time_t)-1; - if (mtimeflag | Ttimeflag) - wtime = date2time(workdelta->date); - - if (donerewrite(changedRCS, - !Ttimeflag ? (time_t)-1 - : finptr && wtime < RCSstat.st_mtime ? RCSstat.st_mtime - : wtime - ) != 0) - continue; - - if (!keepworkingfile) { - Izclose(&workptr); - r = un_link(workname); /* Get rid of old file */ - } else { - newworkmode = WORKMODE(RCSstat.st_mode, - ! (Expand==VAL_EXPAND || lockthis < StrictLocks) - ); - mtime = mtimeflag ? wtime : (time_t)-1; - - /* Expand if it might change or if we can't fix mode, time. */ - if (changework || (r=fixwork(newworkmode,mtime)) != 0) { - Irewind(workptr); - /* Expand keywords in file. */ - locker_expansion = lockthis; - workdelta->name = - namedrev( - assoclst ? assoclst->ssymbol - : keepflag && *prevname.string ? prevname.string - : rev, - workdelta - ); - switch (xpandfile( - workptr, workdelta, &newworkname, dolog - )) { - default: - continue; - - case 0: - /* - * No expansion occurred; try to reuse working file - * unless we already tried and failed. - */ - if (changework) - if ((r=fixwork(newworkmode,mtime)) == 0) - break; - /* fall into */ - case 1: - Izclose(&workptr); - aflush(exfile); - ignoreints(); - r = chnamemod(&exfile, newworkname, - workname, 1, newworkmode, mtime - ); - keepdirtemp(newworkname); - restoreints(); - } - } - } - if (r != 0) { - eerror(workname); - continue; - } - diagnose("done\n"); - - } - - tempunlink(); - exitmain(exitstatus); -} /* end of main (ci) */ - - static void -cleanup() -{ - if (nerror) exitstatus = EXIT_FAILURE; - Izclose(&finptr); - Izclose(&workptr); - Ozclose(&exfile); - Ozclose(&fcopy); - ORCSclose(); - dirtempunlink(); -} - -#if RCS_lint -# define exiterr ciExit -#endif - void -exiterr() -{ - ORCSerror(); - dirtempunlink(); - tempunlink(); - _exit(EXIT_FAILURE); -} - -/*****************************************************************/ -/* the rest are auxiliary routines */ - - - static int -addelta() -/* Function: Appends a delta to the delta tree, whose number is - * given by newdelnum. Updates Head, newdelnum, newdelnumlength, - * and the links in newdelta. - * Return -1 on error, 1 if a lock is removed, 0 otherwise. - */ -{ - register char *tp; - register int i; - int removedlock; - int newdnumlength; /* actual length of new rev. num. */ - - newdnumlength = countnumflds(newdelnum.string); - - if (rcsinitflag) { - /* this covers non-existing RCS file and a file initialized with rcs -i */ - if (newdnumlength==0 && Dbranch) { - bufscpy(&newdelnum, Dbranch); - newdnumlength = countnumflds(Dbranch); - } - if (newdnumlength==0) bufscpy(&newdelnum, "1.1"); - else if (newdnumlength==1) bufscat(&newdelnum, ".1"); - else if (newdnumlength>2) { - rcserror("Branch point doesn't exist for revision %s.", - newdelnum.string - ); - return -1; - } /* newdnumlength == 2 is OK; */ - Head = &newdelta; - newdelta.next = 0; - return 0; - } - if (newdnumlength==0) { - /* derive new revision number from locks */ - switch (findlock(true, &targetdelta)) { - - default: - /* found two or more old locks */ - return -1; - - case 1: - /* found an old lock */ - /* check whether locked revision exists */ - if (!genrevs(targetdelta->num,(char*)0,(char*)0,(char*)0,&gendeltas)) - return -1; - if (targetdelta==Head) { - /* make new head */ - newdelta.next=Head; - Head= &newdelta; - } else if (!targetdelta->next && countnumflds(targetdelta->num)>2) { - /* new tip revision on side branch */ - targetdelta->next= &newdelta; - newdelta.next = 0; - } else { - /* middle revision; start a new branch */ - bufscpy(&newdelnum, ""); - return addbranch(targetdelta, &newdelnum, 1); - } - incnum(targetdelta->num, &newdelnum); - return 1; /* successful use of existing lock */ - - case 0: - /* no existing lock; try Dbranch */ - /* update newdelnum */ - if (StrictLocks || !myself(RCSstat.st_uid)) { - rcserror("no lock set by %s", getcaller()); - return -1; - } - if (Dbranch) { - bufscpy(&newdelnum, Dbranch); - } else { - incnum(Head->num, &newdelnum); - } - newdnumlength = countnumflds(newdelnum.string); - /* now fall into next statement */ - } - } - if (newdnumlength<=2) { - /* add new head per given number */ - if(newdnumlength==1) { - /* make a two-field number out of it*/ - if (cmpnumfld(newdelnum.string,Head->num,1)==0) - incnum(Head->num, &newdelnum); - else - bufscat(&newdelnum, ".1"); - } - if (cmpnum(newdelnum.string,Head->num) <= 0) { - rcserror("revision %s too low; must be higher than %s", - newdelnum.string, Head->num - ); - return -1; - } - targetdelta = Head; - if (0 <= (removedlock = removelock(Head))) { - if (!genrevs(Head->num,(char*)0,(char*)0,(char*)0,&gendeltas)) - return -1; - newdelta.next = Head; - Head = &newdelta; - } - return removedlock; - } else { - /* put new revision on side branch */ - /*first, get branch point */ - tp = newdelnum.string; - for (i = newdnumlength - ((newdnumlength&1) ^ 1); --i; ) - while (*tp++ != '.') - continue; - *--tp = 0; /* Kill final dot to get old delta temporarily. */ - if (!(targetdelta=genrevs(newdelnum.string,(char*)0,(char*)0,(char*)0,&gendeltas))) - return -1; - if (cmpnum(targetdelta->num, newdelnum.string) != 0) { - rcserror("can't find branch point %s", newdelnum.string); - return -1; - } - *tp = '.'; /* Restore final dot. */ - return addbranch(targetdelta, &newdelnum, 0); - } -} - - - - static int -addbranch(branchpoint, num, removedlock) - struct hshentry *branchpoint; - struct buf *num; - int removedlock; -/* adds a new branch and branch delta at branchpoint. - * If num is the null string, appends the new branch, incrementing - * the highest branch number (initially 1), and setting the level number to 1. - * the new delta and branchhead are in globals newdelta and newbranch, resp. - * the new number is placed into num. - * Return -1 on error, 1 if a lock is removed, 0 otherwise. - * If REMOVEDLOCK is 1, a lock was already removed. - */ -{ - struct branchhead *bhead, **btrail; - struct buf branchnum; - int result; - int field, numlength; - static struct branchhead newbranch; /* new branch to be inserted */ - - numlength = countnumflds(num->string); - - if (!branchpoint->branches) { - /* start first branch */ - branchpoint->branches = &newbranch; - if (numlength==0) { - bufscpy(num, branchpoint->num); - bufscat(num, ".1.1"); - } else if (numlength&1) - bufscat(num, ".1"); - newbranch.nextbranch = 0; - - } else if (numlength==0) { - /* append new branch to the end */ - bhead=branchpoint->branches; - while (bhead->nextbranch) bhead=bhead->nextbranch; - bhead->nextbranch = &newbranch; - bufautobegin(&branchnum); - getbranchno(bhead->hsh->num, &branchnum); - incnum(branchnum.string, num); - bufautoend(&branchnum); - bufscat(num, ".1"); - newbranch.nextbranch = 0; - } else { - /* place the branch properly */ - field = numlength - ((numlength&1) ^ 1); - /* field of branch number */ - btrail = &branchpoint->branches; - while (0 < (result=cmpnumfld(num->string,(*btrail)->hsh->num,field))) { - btrail = &(*btrail)->nextbranch; - if (!*btrail) { - result = -1; - break; - } - } - if (result < 0) { - /* insert/append new branchhead */ - newbranch.nextbranch = *btrail; - *btrail = &newbranch; - if (numlength&1) bufscat(num, ".1"); - } else { - /* branch exists; append to end */ - bufautobegin(&branchnum); - getbranchno(num->string, &branchnum); - targetdelta = genrevs( - branchnum.string, (char*)0, (char*)0, (char*)0, - &gendeltas - ); - bufautoend(&branchnum); - if (!targetdelta) - return -1; - if (cmpnum(num->string,targetdelta->num) <= 0) { - rcserror("revision %s too low; must be higher than %s", - num->string, targetdelta->num - ); - return -1; - } - if (!removedlock - && 0 <= (removedlock = removelock(targetdelta)) - ) { - if (numlength&1) - incnum(targetdelta->num,num); - targetdelta->next = &newdelta; - newdelta.next = 0; - } - return removedlock; - /* Don't do anything to newbranch. */ - } - } - newbranch.hsh = &newdelta; - newdelta.next = 0; - if (branchpoint->lockedby) - if (strcmp(branchpoint->lockedby, getcaller()) == 0) - return removelock(branchpoint); /* This returns 1. */ - return removedlock; -} - - static int -addsyms(num) - char const *num; -{ - register struct Symrev *p; - - for (p = assoclst; p; p = p->nextsym) - if (addsymbol(num, p->ssymbol, p->override) < 0) - return false; - return true; -} - - - static void -incnum(onum,nnum) - char const *onum; - struct buf *nnum; -/* Increment the last field of revision number onum by one and - * place the result into nnum. - */ -{ - register char *tp, *np; - register size_t l; - - l = strlen(onum); - bufalloc(nnum, l+2); - np = tp = nnum->string; - VOID strcpy(np, onum); - for (tp = np + l; np != tp; ) - if (isdigit(*--tp)) { - if (*tp != '9') { - ++*tp; - return; - } - *tp = '0'; - } else { - tp++; - break; - } - /* We changed 999 to 000; now change it to 1000. */ - *tp = '1'; - tp = np + l; - *tp++ = '0'; - *tp = 0; -} - - - - static int -removelock(delta) -struct hshentry * delta; -/* function: Finds the lock held by caller on delta, - * removes it, and returns nonzero if successful. - * Print an error message and return -1 if there is no such lock. - * An exception is if !StrictLocks, and caller is the owner of - * the RCS file. If caller does not have a lock in this case, - * return 0; return 1 if a lock is actually removed. - */ -{ - register struct rcslock *next, **trail; - char const *num; - - num=delta->num; - for (trail = &Locks; (next = *trail); trail = &next->nextlock) - if (next->delta == delta) - if (strcmp(getcaller(), next->login) == 0) { - /* We found a lock on delta by caller; delete it. */ - *trail = next->nextlock; - delta->lockedby = 0; - return 1; - } else { - rcserror("revision %s locked by %s", num, next->login); - return -1; - } - if (!StrictLocks && myself(RCSstat.st_uid)) - return 0; - rcserror("no lock set by %s for revision %s", getcaller(), num); - return -1; -} - - - - static char const * -getcurdate() -/* Return a pointer to the current date. */ -{ - static char buffer[datesize]; /* date buffer */ - - if (!buffer[0]) - time2date(now(), buffer); - return buffer; -} - - static int -#if has_prototypes -fixwork(mode_t newworkmode, time_t mtime) - /* The `#if has_prototypes' is needed because mode_t might promote to int. */ -#else - fixwork(newworkmode, mtime) - mode_t newworkmode; - time_t mtime; -#endif -{ - return - 1 < workstat.st_nlink - || (newworkmode&S_IWUSR && !myself(workstat.st_uid)) - || setmtime(workname, mtime) != 0 - ? -1 - : workstat.st_mode == newworkmode ? 0 -#if has_fchmod - : fchmod(Ifileno(workptr), newworkmode) == 0 ? 0 -#endif -#if bad_chmod_close - : -1 -#else - : chmod(workname, newworkmode) -#endif - ; -} - - static int -xpandfile(unexfile, delta, exname, dolog) - RILE *unexfile; - struct hshentry const *delta; - char const **exname; - int dolog; -/* - * Read unexfile and copy it to a - * file, performing keyword substitution with data from delta. - * Return -1 if unsuccessful, 1 if expansion occurred, 0 otherwise. - * If successful, stores the stream descriptor into *EXFILEP - * and its name into *EXNAME. - */ -{ - char const *targetname; - int e, r; - - targetname = makedirtemp(1); - if (!(exfile = fopenSafer(targetname, FOPEN_W_WORK))) { - eerror(targetname); - workerror("can't build working file"); - return -1; - } - r = 0; - if (MIN_UNEXPAND <= Expand) - fastcopy(unexfile,exfile); - else { - for (;;) { - e = expandline( - unexfile, exfile, delta, false, (FILE*)0, dolog - ); - if (e < 0) - break; - r |= e; - if (e <= 1) - break; - } - } - *exname = targetname; - return r & 1; -} - - - - -/* --------------------- G E T L O G M S G --------------------------------*/ - - - static struct cbuf -getlogmsg() -/* Obtain and yield a log message. - * If a log message is given with -m, yield that message. - * If this is the initial revision, yield a standard log message. - * Otherwise, reads a character string from the terminal. - * Stops after reading EOF or a single '.' on a - * line. getlogmsg prompts the first time it is called for the - * log message; during all later calls it asks whether the previous - * log message can be reused. - */ -{ - static char const - emptych[] = EMPTYLOG, - initialch[] = "Initial revision"; - static struct cbuf const - emptylog = { emptych, sizeof(emptych)-sizeof(char) }, - initiallog = { initialch, sizeof(initialch)-sizeof(char) }; - static struct buf logbuf; - static struct cbuf logmsg; - - register char *tp; - register size_t i; - char const *caller; - - if (msg.size) return msg; - - if (keepflag) { - /* generate std. log message */ - caller = getcaller(); - i = sizeof(ciklog)+strlen(caller)+3; - bufalloc(&logbuf, i + datesize + zonelenmax); - tp = logbuf.string; - VOID sprintf(tp, "%s%s at ", ciklog, caller); - VOID date2str(getcurdate(), tp+i); - logmsg.string = tp; - logmsg.size = strlen(tp); - return logmsg; - } - - if (!targetdelta && ( - cmpnum(newdelnum.string,"1.1")==0 || - cmpnum(newdelnum.string,"1.0")==0 - )) - return initiallog; - - if (logmsg.size) { - /*previous log available*/ - if (yesorno(true, "reuse log message of previous file? [yn](y): ")) - return logmsg; - } - - /* now read string from stdin */ - logmsg = getsstdin("m", "log message", "", &logbuf); - - /* now check whether the log message is not empty */ - if (logmsg.size) - return logmsg; - return emptylog; -} - -/* Make a linked list of Symbolic names */ - - static void -addassoclst(flag, sp) - int flag; - char const *sp; -{ - struct Symrev *pt; - - pt = talloc(struct Symrev); - pt->ssymbol = sp; - pt->override = flag; - pt->nextsym = 0; - *nextassoc = pt; - nextassoc = &pt->nextsym; -} diff --git a/gnu/usr.bin/rcs/co/Makefile b/gnu/usr.bin/rcs/co/Makefile deleted file mode 100644 index 0c73865d09f..00000000000 --- a/gnu/usr.bin/rcs/co/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROG= co -SRCS= co.c -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/co/Makefile.depend b/gnu/usr.bin/rcs/co/Makefile.depend deleted file mode 100644 index 9d13779615a..00000000000 --- a/gnu/usr.bin/rcs/co/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/co/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/co/co.1 b/gnu/usr.bin/rcs/co/co.1 deleted file mode 100644 index 565da1dc0c2..00000000000 --- a/gnu/usr.bin/rcs/co/co.1 +++ /dev/null @@ -1,736 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/co/co.1 50472 1999-08-27 23:37:10Z peter $ -.ds i \&\s-1ISO\s0 -.ds r \&\s-1RCS\s0 -.ds u \&\s-1UTC\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH CO 1 \*(Dt GNU -.SH NAME -co \- check out RCS revisions -.SH SYNOPSIS -.B co -.RI [ options ] " file " .\|.\|. -.SH DESCRIPTION -.B co -retrieves a revision from each \*r file and stores it into -the corresponding working file. -.PP -Pathnames matching an \*r suffix denote \*r files; -all others denote working files. -Names are paired as explained in -.BR ci (1). -.PP -Revisions of an \*r file can be checked out locked or unlocked. Locking a -revision prevents overlapping updates. A revision checked out for reading or -processing (e.g., compiling) need not be locked. A revision checked out -for editing and later checkin must normally be locked. Checkout with locking -fails if the revision to be checked out is currently locked by another user. -(A lock can be broken with -.BR rcs "(1).)\ \&" -Checkout with locking also requires the caller to be on the access list of -the \*r file, unless he is the owner of the -file or the superuser, or the access list is empty. -Checkout without locking is not subject to accesslist restrictions, and is -not affected by the presence of locks. -.PP -A revision is selected by options for revision or branch number, -checkin date/time, author, or state. -When the selection options -are applied in combination, -.B co -retrieves the latest revision -that satisfies all of them. -If none of the selection options -is specified, -.B co -retrieves the latest revision -on the default branch (normally the trunk, see the -.B \-b -option of -.BR rcs (1)). -A revision or branch number can be attached -to any of the options -.BR \-f , -.BR \-I , -.BR \-l , -.BR \-M , -.BR \-p , -.BR \-q , -.BR \-r , -or -.BR \-u . -The options -.B \-d -(date), -.B \-s -(state), and -.B \-w -(author) -retrieve from a single branch, the -.I selected -branch, -which is either specified by one of -.BR \-f , -\&.\|.\|., -.BR \-u , -or the default branch. -.PP -A -.B co -command applied to an \*r -file with no revisions creates a zero-length working file. -.B co -always performs keyword substitution (see below). -.SH OPTIONS -.TP -.BR \-r [\f2rev\fP] -retrieves the latest revision whose number is less than or equal to -.IR rev . -If -.I rev -indicates a branch rather than a revision, -the latest revision on that branch is retrieved. -If -.I rev -is omitted, the latest revision on the default branch -(see the -.B \-b -option of -.BR rcs (1)) -is retrieved. -If -.I rev -is -.BR $ , -.B co -determines the revision number from keyword values in the working file. -Otherwise, a revision is composed of one or more numeric or symbolic fields -separated by periods. -If -.I rev -begins with a period, -then the default branch (normally the trunk) is prepended to it. -If -.I rev -is a branch number followed by a period, -then the latest revision on that branch is used. -The numeric equivalent of a symbolic field -is specified with the -.B \-n -option of the commands -.BR ci (1) -and -.BR rcs (1). -.TP -.BR \-l [\f2rev\fP] -same as -.BR \-r , -except that it also locks the retrieved revision for -the caller. -.TP -.BR \-u [\f2rev\fP] -same as -.BR \-r , -except that it unlocks the retrieved revision if it was -locked by the caller. If -.I rev -is omitted, -.B \-u -retrieves the revision locked by the caller, if there is one; otherwise, -it retrieves the latest revision on the default branch. -.TP -.BR \-f [\f2rev\fP] -forces the overwriting of the working file; -useful in connection with -.BR \-q . -See also -.SM "FILE MODES" -below. -.TP -.B \-kkv -Generate keyword strings using the default form, e.g.\& -.B "$\&Revision: \*(Rv $" -for the -.B Revision -keyword. -A locker's name is inserted in the value of the -.BR Header , -.BR Id , -and -.B Locker -keyword strings -only as a file is being locked, -i.e. by -.B "ci\ \-l" -and -.BR "co\ \-l". -This is the default. -.TP -.B \-kkvl -Like -.BR \-kkv , -except that a locker's name is always inserted -if the given revision is currently locked. -.TP -.B \-kk -Generate only keyword names in keyword strings; omit their values. -See -.SM "KEYWORD SUBSTITUTION" -below. -For example, for the -.B Revision -keyword, generate the string -.B $\&Revision$ -instead of -.BR "$\&Revision: \*(Rv $" . -This option is useful to ignore differences due to keyword substitution -when comparing different revisions of a file. -Log messages are inserted after -.B $\&Log$ -keywords even if -.B \-kk -is specified, -since this tends to be more useful when merging changes. -.TP -.B \-ko -Generate the old keyword string, -present in the working file just before it was checked in. -For example, for the -.B Revision -keyword, generate the string -.B "$\&Revision: 1.1 $" -instead of -.B "$\&Revision: \*(Rv $" -if that is how the string appeared when the file was checked in. -This can be useful for file formats -that cannot tolerate any changes to substrings -that happen to take the form of keyword strings. -.TP -.B \-kb -Generate a binary image of the old keyword string. -This acts like -.BR \-ko , -except it performs all working file input and output in binary mode. -This makes little difference on Posix and Unix hosts, -but on DOS-like hosts one should use -.B "rcs\ \-i\ \-kb" -to initialize an \*r file intended to be used for binary files. -Also, on all hosts, -.BR rcsmerge (1) -normally refuses to merge files when -.B \-kb -is in effect. -.TP -.B \-kv -Generate only keyword values for keyword strings. -For example, for the -.B Revision -keyword, generate the string -.B \*(Rv -instead of -.BR "$\&Revision: \*(Rv $" . -This can help generate files in programming languages where it is hard to -strip keyword delimiters like -.B "$\&Revision:\ $" -from a string. -However, further keyword substitution cannot be performed once the -keyword names are removed, so this option should be used with care. -Because of this danger of losing keywords, -this option cannot be combined with -.BR \-l , -and the owner write permission of the working file is turned off; -to edit the file later, check it out again without -.BR \-kv . -.TP -.BR \-p [\f2rev\fP] -prints the retrieved revision on the standard output rather than storing it -in the working file. -This option is useful when -.B co -is part of a pipe. -.TP -.BR \-q [\f2rev\fP] -quiet mode; diagnostics are not printed. -.TP -.BR \-I [\f2rev\fP] -interactive mode; -the user is prompted and questioned -even if the standard input is not a terminal. -.TP -.BI \-d date -retrieves the latest revision on the selected branch whose checkin date/time is -less than or equal to -.IR date . -The date and time can be given in free format. -The time zone -.B LT -stands for local time; -other common time zone names are understood. -For example, the following -.IR date s -are equivalent -if local time is January 11, 1990, 8pm Pacific Standard Time, -eight hours west of Coordinated Universal Time (\*u): -.RS -.LP -.RS -.nf -.ta \w'\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP 'u -.ne 10 -\f38:00 pm lt\fP -\f34:00 AM, Jan. 12, 1990\fP default is \*u -\f31990-01-12 04:00:00+00\fP \*i 8601 (\*u) -\f31990-01-11 20:00:00\-08\fP \*i 8601 (local time) -\f31990/01/12 04:00:00\fP traditional \*r format -\f3Thu Jan 11 20:00:00 1990 LT\fP output of \f3ctime\fP(3) + \f3LT\fP -\f3Thu Jan 11 20:00:00 PST 1990\fP output of \f3date\fP(1) -\f3Fri Jan 12 04:00:00 GMT 1990\fP -\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP Internet RFC 822 -\f312-January-1990, 04:00 WET\fP -.ta 4n +4n +4n +4n -.fi -.RE -.LP -Most fields in the date and time can be defaulted. -The default time zone is normally \*u, but this can be overridden by the -.B \-z -option. -The other defaults are determined in the order year, month, day, -hour, minute, and second (most to least significant). At least one of these -fields must be provided. For omitted fields that are of higher significance -than the highest provided field, the time zone's current values are assumed. -For all other omitted fields, -the lowest possible values are assumed. -For example, without -.BR \-z , -the date -.B "20, 10:30" -defaults to -10:30:00 \*u of the 20th of the \*u time zone's current month and year. -The date/time must be quoted if it contains spaces. -.RE -.TP -.BR \-M [\f2rev\fP] -Set the modification time on the new working file -to be the date of the retrieved revision. -Use this option with care; it can confuse -.BR make (1). -.TP -.BI \-s state -retrieves the latest revision on the selected branch whose state is set to -.IR state . -.TP -.B \-T -Preserve the modification time on the \*r file -even if the \*r file changes because a lock is added or removed. -This option can suppress extensive recompilation caused by a -.BR make (1) -dependency of some other copy of the working file on the \*r file. -Use this option with care; it can suppress recompilation even when it is needed, -i.e. when the change of lock -would mean a change to keyword strings in the other working file. -.TP -.BR \-w [\f2login\fP] -retrieves the latest revision on the selected branch which was checked in -by the user with login name -.IR login . -If the argument -.I login -is -omitted, the caller's login is assumed. -.TP -.BI \-j joinlist -generates a new revision which is the join of the revisions on -.IR joinlist . -This option is largely obsoleted by -.BR rcsmerge (1) -but is retained for backwards compatibility. -.RS -.PP -The -.I joinlist -is a comma-separated list of pairs of the form -.IB rev2 : rev3, -where -.I rev2 -and -.I rev3 -are (symbolic or numeric) -revision numbers. -For the initial such pair, -.I rev1 -denotes the revision selected -by the above options -.BR \-f , -\&.\|.\|., -.BR \-w . -For all other pairs, -.I rev1 -denotes the revision generated by the previous pair. -(Thus, the output -of one join becomes the input to the next.) -.PP -For each pair, -.B co -joins revisions -.I rev1 -and -.I rev3 -with respect to -.IR rev2 . -This means that all changes that transform -.I rev2 -into -.I rev1 -are applied to a copy of -.IR rev3 . -This is particularly useful if -.I rev1 -and -.I rev3 -are the ends of two branches that have -.I rev2 -as a common ancestor. If -.IR rev1 < rev2 < rev3 -on the same branch, -joining generates a new revision which is like -.I rev3, -but with all changes that lead from -.I rev1 -to -.I rev2 -undone. -If changes from -.I rev2 -to -.I rev1 -overlap with changes from -.I rev2 -to -.I rev3, -.B co -reports overlaps as described in -.BR merge (1). -.PP -For the initial pair, -.I rev2 -can be omitted. The default is the common -ancestor. -If any of the arguments indicate branches, the latest revisions -on those branches are assumed. -The options -.B \-l -and -.B \-u -lock or unlock -.IR rev1 . -.RE -.TP -.BI \-V -Print \*r's version number. -.TP -.BI \-V n -Emulate \*r version -.I n, -where -.I n -can be -.BR 3 , -.BR 4 , -or -.BR 5 . -This can be useful when interchanging \*r files with others who are -running older versions of \*r. -To see which version of \*r your correspondents are running, have them invoke -.BR "rcs \-V" ; -this works with newer versions of \*r. -If it doesn't work, have them invoke -.B rlog -on an \*r file; -if none of the first few lines of output contain the string -.B branch: -it is version 3; -if the dates' years have just two digits, it is version 4; -otherwise, it is version 5. -An \*r file generated while emulating version 3 loses its default branch. -An \*r revision generated while emulating version 4 or earlier has -a time stamp that is off by up to 13 hours. -A revision extracted while emulating version 4 or earlier contains -abbreviated dates of the form -.IB yy / mm / dd -and can also contain different white space and line prefixes -in the substitution for -.BR $\&Log$ . -.TP -.BI \-x "suffixes" -Use -.I suffixes -to characterize \*r files. -See -.BR ci (1) -for details. -.TP -.BI \-z zone -specifies the date output format in keyword substitution, -and specifies the default time zone for -.I date -in the -.BI \-d date -option. -The -.I zone -should be empty, a numeric \*u offset, or the special string -.B LT -for local time. -The default is an empty -.IR zone , -which uses the traditional \*r format of \*u without any time zone indication -and with slashes separating the parts of the date; -otherwise, times are output in \*i 8601 format with time zone indication. -For example, if local time is January 11, 1990, 8pm Pacific Standard Time, -eight hours west of \*u, -then the time is output as follows: -.RS -.LP -.RS -.nf -.ta \w'\f3\-z+05:30\fP 'u +\w'\f31990-01-11 09:30:00+05:30\fP 'u -.ne 4 -\f2option\fP \f2time output\fP -\f3\-z\fP \f31990/01/12 04:00:00\fP \f2(default)\fP -\f3\-zLT\fP \f31990-01-11 20:00:00\-08\fP -\f3\-z+05:30\fP \f31990-01-12 09:30:00+05:30\fP -.ta 4n +4n +4n +4n -.fi -.RE -.LP -The -.B \-z -option does not affect dates stored in \*r files, -which are always \*u. -.RE -.SH "KEYWORD SUBSTITUTION" -Strings of the form -.BI $ keyword $ -and -.BI $ keyword : .\|.\|. $ -embedded in -the text are replaced -with strings of the form -.BI $ keyword : value $ -where -.I keyword -and -.I value -are pairs listed below. -Keywords can be embedded in literal strings -or comments to identify a revision. -.PP -Initially, the user enters strings of the form -.BI $ keyword $ . -On checkout, -.B co -replaces these strings with strings of the form -.BI $ keyword : value $ . -If a revision containing strings of the latter form -is checked back in, the value fields will be replaced during the next -checkout. -Thus, the keyword values are automatically updated on checkout. -This automatic substitution can be modified by the -.B \-k -options. -.PP -Keywords and their corresponding values: -.TP -.B $\&Author$ -The login name of the user who checked in the revision. -.TP -.B $\&Date$ -The date and time the revision was checked in. -With -.BI \-z zone -a numeric time zone offset is appended; otherwise, the date is \*u. -.TP -.B $\&Header$ -A standard header containing the full pathname of the \*r file, the -revision number, the date and time, the author, the state, -and the locker (if locked). -With -.BI \-z zone -a numeric time zone offset is appended to the date; otherwise, the date is \*u. -.TP -.B $\&Id$ -Same as -.BR $\&Header$ , -except that the \*r filename is without a path. -.TP -.B $\&Locker$ -The login name of the user who locked the revision (empty if not locked). -.TP -.B $\&Log$ -The log message supplied during checkin, preceded by a header -containing the \*r filename, the revision number, the author, and the date -and time. -With -.BI \-z zone -a numeric time zone offset is appended; otherwise, the date is \*u. -Existing log messages are -.I not -replaced. -Instead, the new log message is inserted after -.BR $\&Log: .\|.\|. $ . -This is useful for -accumulating a complete change log in a source file. -.RS -.LP -Each inserted line is prefixed by the string that prefixes the -.B $\&Log$ -line. For example, if the -.B $\&Log$ -line is -.RB \*(lq "//\ $\&Log: tan.cc\ $" \*(rq, -\*r prefixes each line of the log with -.RB \*(lq "//\ " \*(rq. -This is useful for languages with comments that go to the end of the line. -The convention for other languages is to use a -.RB \*(lq " \(** " \(rq -prefix inside a multiline comment. -For example, the initial log comment of a C program -conventionally is of the following form: -.RS -.LP -.nf -.ft 3 -.ne 3 -/\(** -.in +\w'/'u -\(** $\&Log$ -\(**/ -.in -.ft -.fi -.RE -.LP -For backwards compatibility with older versions of \*r, if the log prefix is -.B /\(** -or -.B (\(** -surrounded by optional white space, inserted log lines contain a space -instead of -.B / -or -.BR ( ; -however, this usage is obsolescent and should not be relied on. -.RE -.TP -.B $\&Name$ -The symbolic name used to check out the revision, if any. -For example, -.B "co\ \-rJoe" -generates -.BR "$\&Name:\ Joe\ $" . -Plain -.B co -generates just -.BR "$\&Name:\ \ $" . -.TP -.B $\&RCSfile$ -The name of the \*r file without a path. -.TP -.B $\&Revision$ -The revision number assigned to the revision. -.TP -.B $\&Source$ -The full pathname of the \*r file. -.TP -.B $\&State$ -The state assigned to the revision with the -.B \-s -option of -.BR rcs (1) -or -.BR ci (1). -.PP -The following characters in keyword values are represented by escape sequences -to keep keyword strings well-formed. -.LP -.RS -.nf -.ne 6 -.ta \w'newline 'u -\f2char escape sequence\fP -tab \f3\et\fP -newline \f3\en\fP -space \f3\e040 -$ \e044 -\e \e\e\fP -.fi -.RE -.SH "FILE MODES" -The working file inherits the read and execute permissions from the \*r -file. In addition, the owner write permission is turned on, unless -.B \-kv -is set or the file -is checked out unlocked and locking is set to strict (see -.BR rcs (1)). -.PP -If a file with the name of the working file exists already and has write -permission, -.B co -aborts the checkout, -asking beforehand if possible. -If the existing working file is -not writable or -.B \-f -is given, the working file is deleted without asking. -.SH FILES -.B co -accesses files much as -.BR ci (1) -does, except that it does not need to read the working file -unless a revision number of -.B $ -is specified. -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -See -.BR ci (1) -for details. -.SH DIAGNOSTICS -The \*r pathname, the working pathname, -and the revision number retrieved are -written to the diagnostic output. -The exit status is zero if and only if all operations were successful. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH "SEE ALSO" -rcsintro(1), ci(1), ctime(3), date(1), ident(1), make(1), -rcs(1), rcsclean(1), rcsdiff(1), rcsmerge(1), rlog(1), -rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.SH LIMITS -Links to the \*r and working files are not preserved. -.PP -There is no way to selectively suppress the expansion of keywords, except -by writing them differently. In nroff and troff, this is done by embedding the -null-character -.B \e& -into the keyword. -.br diff --git a/gnu/usr.bin/rcs/co/co.c b/gnu/usr.bin/rcs/co/co.c deleted file mode 100644 index bf797c02a78..00000000000 --- a/gnu/usr.bin/rcs/co/co.c +++ /dev/null @@ -1,826 +0,0 @@ -/* Check out working files from revisions of RCS files. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.18 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.17 1995/06/01 16:23:43 eggert - * (main, preparejoin): Pass argument instead of using `join' static variable. - * (main): Add -kb. - * - * Revision 5.16 1994/03/17 14:05:48 eggert - * Move buffer-flushes out of critical sections, since they aren't critical. - * Use ORCSerror to clean up after a fatal error. Remove lint. - * Specify subprocess input via file descriptor, not file name. - * - * Revision 5.15 1993/11/09 17:40:15 eggert - * -V now prints version on stdout and exits. Don't print usage twice. - * - * Revision 5.14 1993/11/03 17:42:27 eggert - * Add -z. Generate a value for the Name keyword. - * Don't arbitrarily limit the number of joins. - * Improve quality of diagnostics. - * - * Revision 5.13 1992/07/28 16:12:44 eggert - * Add -V. Check that working and RCS files are distinct. - * - * Revision 5.12 1992/02/17 23:02:08 eggert - * Add -T. - * - * Revision 5.11 1992/01/24 18:44:19 eggert - * Add support for bad_creat0. lint -> RCS_lint - * - * Revision 5.10 1992/01/06 02:42:34 eggert - * Update usage string. - * - * Revision 5.9 1991/10/07 17:32:46 eggert - * -k affects just working file, not RCS file. - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Warn before removing somebody else's file. - * Add -M. Fix co -j bugs. Tune. - * - * Revision 5.7 1991/04/21 11:58:15 eggert - * Ensure that working file is newer than RCS file after co -[lu]. - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.6 1990/12/04 05:18:38 eggert - * Don't checkaccesslist() unless necessary. - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.5 1990/11/01 05:03:26 eggert - * Fix -j. Add -I. - * - * Revision 5.4 1990/10/04 06:30:11 eggert - * Accumulate exit status across files. - * - * Revision 5.3 1990/09/11 02:41:09 eggert - * co -kv yields a readonly working file. - * - * Revision 5.2 1990/09/04 08:02:13 eggert - * Standardize yes-or-no procedure. - * - * Revision 5.0 1990/08/22 08:10:02 eggert - * Permit multiple locks by same user. Add setuid support. - * Remove compile-time limits; use malloc instead. - * Permit dates past 1999/12/31. Switch to GMT. - * Make lock and temp files faster and safer. - * Ansify and Posixate. Add -k, -V. Remove snooping. Tune. - * - * Revision 4.7 89/05/01 15:11:41 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.6 88/08/09 19:12:15 eggert - * Fix "co -d" core dump; rawdate wasn't always initialized. - * Use execv(), not system(); fix putchar('\0') and diagnose() botches; remove lint - * - * Revision 4.5 87/12/18 11:35:40 narten - * lint cleanups (from Guy Harris) - * - * Revision 4.4 87/10/18 10:20:53 narten - * Updating version numbers changes relative to 1.1, are actually - * relative to 4.2 - * - * Revision 1.3 87/09/24 13:58:30 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:21:38 jenkins - * Port to suns - * - * Revision 4.2 83/12/05 13:39:48 wft - * made rewriteflag external. - * - * Revision 4.1 83/05/10 16:52:55 wft - * Added option -u and -f. - * Added handling of default branch. - * Replaced getpwuid() with getcaller(). - * Removed calls to stat(); now done by pairfilenames(). - * Changed and renamed rmoldfile() to rmworkfile(). - * Replaced catchints() calls with restoreints(), unlink()--link() with rename(); - * - * Revision 3.7 83/02/15 15:27:07 wft - * Added call to fastcopy() to copy remainder of RCS file. - * - * Revision 3.6 83/01/15 14:37:50 wft - * Added ignoring of interrupts while RCS file is renamed; this avoids - * deletion of RCS files during the unlink/link window. - * - * Revision 3.5 82/12/08 21:40:11 wft - * changed processing of -d to use DATEFORM; removed actual from - * call to preparejoin; re-fixed printing of done at the end. - * - * Revision 3.4 82/12/04 18:40:00 wft - * Replaced getdelta() with gettree(), SNOOPDIR with SNOOPFILE. - * Fixed printing of "done". - * - * Revision 3.3 82/11/28 22:23:11 wft - * Replaced getlogin() with getpwuid(), flcose() with ffclose(), - * %02d with %.2d, mode generation for working file with WORKMODE. - * Fixed nil printing. Fixed -j combined with -l and -p, and exit - * for non-existing revisions in preparejoin(). - * - * Revision 3.2 82/10/18 20:47:21 wft - * Mode of working file is now maintained even for co -l, but write permission - * is removed. - * The working file inherits its mode from the RCS file, plus write permission - * for the owner. The write permission is not given if locking is strict and - * co does not lock. - * An existing working file without write permission is deleted automatically. - * Otherwise, co asks (empty answer: abort co). - * Call to getfullRCSname() added, check for write error added, call - * for getlogin() fixed. - * - * Revision 3.1 82/10/13 16:01:30 wft - * fixed type of variables receiving from getc() (char -> int). - * removed unused variables. - */ - - - - -#include "rcsbase.h" - -static char *addjoin P((char*)); -static char const *getancestor P((char const*,char const*)); -static int buildjoin P((char const*)); -static int preparejoin P((char*)); -static int rmlock P((struct hshentry const*)); -static int rmworkfile P((void)); -static void cleanup P((void)); - -static char const quietarg[] = "-q"; - -static char const *expandarg, *suffixarg, *versionarg, *zonearg; -static char const **joinlist; /* revisions to be joined */ -static int joinlength; -static FILE *neworkptr; -static int exitstatus; -static int forceflag; -static int lastjoin; /* index of last element in joinlist */ -static int lockflag; /* -1 -> unlock, 0 -> do nothing, 1 -> lock */ -static int mtimeflag; -static struct hshentries *gendeltas; /* deltas to be generated */ -static struct hshentry *targetdelta; /* final delta to be generated */ -static struct stat workstat; - -mainProg(coId, "co", "$FreeBSD: stable/11/gnu/usr.bin/rcs/co/co.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const cmdusage[] = - "\nco usage: co -{fIlMpqru}[rev] -ddate -jjoins -ksubst -sstate -T -w[who] -Vn -xsuff -zzone file ..."; - - char *a, *joinflag, **newargv; - char const *author, *date, *rev, *state; - char const *joinname, *newdate, *neworkname; - int changelock; /* 1 if a lock has been changed, -1 if error */ - int expmode, r, tostdout, workstatstat; - int Ttimeflag; - struct buf numericrev; /* expanded revision number */ - char finaldate[datesize]; -# if OPEN_O_BINARY - int stdout_mode = 0; -# endif - - setrid(); - author = date = rev = state = 0; - joinflag = 0; - bufautobegin(&numericrev); - expmode = -1; - suffixes = X_DEFAULT; - tostdout = false; - Ttimeflag = false; - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - while (a = *++argv, 0<--argc && *a++=='-') { - switch (*a++) { - - case 'r': - revno: - if (*a) { - if (rev) warn("redefinition of revision number"); - rev = a; - } - break; - - case 'f': - forceflag=true; - goto revno; - - case 'l': - if (lockflag < 0) { - warn("-u overridden by -l."); - } - lockflag = 1; - goto revno; - - case 'u': - if (0 < lockflag) { - warn("-l overridden by -u."); - } - lockflag = -1; - goto revno; - - case 'p': - tostdout = true; - goto revno; - - case 'I': - interactiveflag = true; - goto revno; - - case 'q': - quietflag=true; - goto revno; - - case 'd': - if (date) - redefined('d'); - str2date(a, finaldate); - date=finaldate; - break; - - case 'j': - if (*a) { - if (joinflag) redefined('j'); - joinflag = a; - } - break; - - case 'M': - mtimeflag = true; - goto revno; - - case 's': - if (*a) { - if (state) redefined('s'); - state = a; - } - break; - - case 'T': - if (*a) - goto unknown; - Ttimeflag = true; - break; - - case 'w': - if (author) redefined('w'); - if (*a) - author = a; - else - author = getcaller(); - break; - - case 'x': - suffixarg = *argv; - suffixes = a; - break; - - case 'V': - versionarg = *argv; - setRCSversion(versionarg); - break; - - case 'z': - zonearg = *argv; - zone_set(a); - break; - - case 'k': /* set keyword expand mode */ - expandarg = *argv; - if (0 <= expmode) redefined('k'); - if (0 <= (expmode = str2expmode(a))) - break; - /* fall into */ - default: - unknown: - error("unknown option: %s%s", *argv, cmdusage); - - }; - } /* end of option processing */ - - /* Now handle all pathnames. */ - if (nerror) cleanup(); - else if (argc < 1) faterror("no input file%s", cmdusage); - else for (; 0 < argc; cleanup(), ++argv, --argc) { - ffree(); - - if (pairnames(argc, argv, lockflag?rcswriteopen:rcsreadopen, true, false) <= 0) - continue; - - /* - * RCSname contains the name of the RCS file, and finptr - * points at it. workname contains the name of the working file. - * Also, RCSstat has been set. - */ - diagnose("%s --> %s\n", RCSname, tostdout?"standard output":workname); - - workstatstat = -1; - if (tostdout) { -# if OPEN_O_BINARY - int newmode = Expand==BINARY_EXPAND ? OPEN_O_BINARY : 0; - if (stdout_mode != newmode) { - stdout_mode = newmode; - oflush(); - VOID setmode(STDOUT_FILENO, newmode); - } -# endif - neworkname = 0; - neworkptr = workstdout = stdout; - } else { - workstatstat = stat(workname, &workstat); - if (workstatstat == 0 && same_file(RCSstat, workstat, 0)) { - rcserror("RCS file is the same as working file %s.", - workname - ); - continue; - } - neworkname = makedirtemp(1); - if (!(neworkptr = fopenSafer(neworkname, FOPEN_W_WORK))) { - if (errno == EACCES) - workerror("permission denied on parent directory"); - else - eerror(neworkname); - continue; - } - } - - gettree(); /* reads in the delta tree */ - - if (!Head) { - /* no revisions; create empty file */ - diagnose("no revisions present; generating empty revision 0.0\n"); - if (lockflag) - warn( - "no revisions, so nothing can be %slocked", - lockflag < 0 ? "un" : "" - ); - Ozclose(&fcopy); - if (workstatstat == 0) - if (!rmworkfile()) continue; - changelock = 0; - newdate = 0; - } else { - int locks = lockflag ? findlock(false, &targetdelta) : 0; - if (rev) { - /* expand symbolic revision number */ - if (!expandsym(rev, &numericrev)) - continue; - } else { - switch (locks) { - default: - continue; - case 0: - bufscpy(&numericrev, Dbranch?Dbranch:""); - break; - case 1: - bufscpy(&numericrev, targetdelta->num); - break; - } - } - /* get numbers of deltas to be generated */ - if (!(targetdelta=genrevs(numericrev.string,date,author,state,&gendeltas))) - continue; - /* check reservations */ - changelock = - lockflag < 0 ? - rmlock(targetdelta) - : lockflag == 0 ? - 0 - : - addlock(targetdelta, true); - - if ( - changelock < 0 - || (changelock && !checkaccesslist()) - || dorewrite(lockflag, changelock) != 0 - ) - continue; - - if (0 <= expmode) - Expand = expmode; - if (0 < lockflag && Expand == VAL_EXPAND) { - rcserror("cannot combine -kv and -l"); - continue; - } - - if (joinflag && !preparejoin(joinflag)) - continue; - - diagnose("revision %s%s\n",targetdelta->num, - 0name = namedrev(rev, targetdelta); - joinname = buildrevision( - gendeltas, targetdelta, - joinflag&&tostdout ? (FILE*)0 : neworkptr, - Expand < MIN_UNEXPAND - ); -# if !large_memory - if (fcopy == neworkptr) - fcopy = 0; /* Don't close it twice. */ -# endif - if_advise_access(changelock && gendeltas->first!=targetdelta, - finptr, MADV_SEQUENTIAL - ); - - if (donerewrite(changelock, - Ttimeflag ? RCSstat.st_mtime : (time_t)-1 - ) != 0) - continue; - - if (changelock) { - locks += lockflag; - if (1 < locks) - rcswarn("You now have %d locks.", locks); - } - - newdate = targetdelta->date; - if (joinflag) { - newdate = 0; - if (!joinname) { - aflush(neworkptr); - joinname = neworkname; - } - if (Expand == BINARY_EXPAND) - workerror("merging binary files"); - if (!buildjoin(joinname)) - continue; - } - } - if (!tostdout) { - mode_t m = WORKMODE(RCSstat.st_mode, - ! (Expand==VAL_EXPAND || (lockflag<=0 && StrictLocks)) - ); - time_t t = mtimeflag&&newdate ? date2time(newdate) : (time_t)-1; - aflush(neworkptr); - ignoreints(); - r = chnamemod(&neworkptr, neworkname, workname, 1, m, t); - keepdirtemp(neworkname); - restoreints(); - if (r != 0) { - eerror(workname); - error("see %s", neworkname); - continue; - } - diagnose("done\n"); - } - } - - tempunlink(); - Ofclose(workstdout); - exitmain(exitstatus); - -} /* end of main (co) */ - - static void -cleanup() -{ - if (nerror) exitstatus = EXIT_FAILURE; - Izclose(&finptr); - ORCSclose(); -# if !large_memory - if (fcopy!=workstdout) Ozclose(&fcopy); -# endif - if (neworkptr!=workstdout) Ozclose(&neworkptr); - dirtempunlink(); -} - -#if RCS_lint -# define exiterr coExit -#endif - void -exiterr() -{ - ORCSerror(); - dirtempunlink(); - tempunlink(); - _exit(EXIT_FAILURE); -} - - -/***************************************************************** - * The following routines are auxiliary routines - *****************************************************************/ - - static int -rmworkfile() -/* - * Prepare to remove workname, if it exists, and if - * it is read-only. - * Otherwise (file writable): - * if !quietmode asks the user whether to really delete it (default: fail); - * otherwise failure. - * Returns true if permission is gotten. - */ -{ - if (workstat.st_mode&(S_IWUSR|S_IWGRP|S_IWOTH) && !forceflag) { - /* File is writable */ - if (!yesorno(false, "writable %s exists%s; remove it? [ny](n): ", - workname, - myself(workstat.st_uid) ? "" : ", and you do not own it" - )) { - error(!quietflag && ttystdin() - ? "checkout aborted" - : "writable %s exists; checkout aborted", workname); - return false; - } - } - /* Actual unlink is done later by caller. */ - return true; -} - - - static int -rmlock(delta) - struct hshentry const *delta; -/* Function: removes the lock held by caller on delta. - * Returns -1 if someone else holds the lock, - * 0 if there is no lock on delta, - * and 1 if a lock was found and removed. - */ -{ register struct rcslock * next, * trail; - char const *num; - struct rcslock dummy; - int whomatch, nummatch; - - num=delta->num; - dummy.nextlock=next=Locks; - trail = &dummy; - while (next) { - whomatch = strcmp(getcaller(), next->login); - nummatch=strcmp(num,next->delta->num); - if ((whomatch==0) && (nummatch==0)) break; - /*found a lock on delta by caller*/ - if ((whomatch!=0)&&(nummatch==0)) { - rcserror("revision %s locked by %s; use co -r or rcs -u", - num, next->login - ); - return -1; - } - trail=next; - next=next->nextlock; - } - if (next) { - /*found one; delete it */ - trail->nextlock=next->nextlock; - Locks=dummy.nextlock; - next->delta->lockedby = 0; - return 1; /*success*/ - } else return 0; /*no lock on delta*/ -} - - - - -/***************************************************************** - * The rest of the routines are for handling joins - *****************************************************************/ - - - static char * -addjoin(joinrev) - char *joinrev; -/* Add joinrev's number to joinlist, yielding address of char past joinrev, - * or 0 if no such revision exists. - */ -{ - register char *j; - register struct hshentry *d; - char terminator; - struct buf numrev; - struct hshentries *joindeltas; - - j = joinrev; - for (;;) { - switch (*j++) { - default: - continue; - case 0: - case ' ': case '\t': case '\n': - case ':': case ',': case ';': - break; - } - break; - } - terminator = *--j; - *j = 0; - bufautobegin(&numrev); - d = 0; - if (expandsym(joinrev, &numrev)) - d = genrevs(numrev.string,(char*)0,(char*)0,(char*)0,&joindeltas); - bufautoend(&numrev); - *j = terminator; - if (d) { - joinlist[++lastjoin] = d->num; - return j; - } - return 0; -} - - static int -preparejoin(j) - register char *j; -/* Parse join list J and place pointers to the - * revision numbers into joinlist. - */ -{ - lastjoin= -1; - for (;;) { - while ((*j==' ')||(*j=='\t')||(*j==',')) j++; - if (*j=='\0') break; - if (lastjoin>=joinlength-2) { - joinlist = - (joinlength *= 2) == 0 - ? tnalloc(char const *, joinlength = 16) - : trealloc(char const *, joinlist, joinlength); - } - if (!(j = addjoin(j))) return false; - while ((*j==' ') || (*j=='\t')) j++; - if (*j == ':') { - j++; - while((*j==' ') || (*j=='\t')) j++; - if (*j!='\0') { - if (!(j = addjoin(j))) return false; - } else { - rcsfaterror("join pair incomplete"); - } - } else { - if (lastjoin==0) { /* first pair */ - /* common ancestor missing */ - joinlist[1]=joinlist[0]; - lastjoin=1; - /*derive common ancestor*/ - if (!(joinlist[0] = getancestor(targetdelta->num,joinlist[1]))) - return false; - } else { - rcsfaterror("join pair incomplete"); - } - } - } - if (lastjoin < 1) - rcsfaterror("empty join"); - return true; -} - - - - static char const * -getancestor(r1, r2) - char const *r1, *r2; -/* Yield the common ancestor of r1 and r2 if successful, 0 otherwise. - * Work reliably only if r1 and r2 are not branch numbers. - */ -{ - static struct buf t1, t2; - - int l1, l2, l3; - char const *r; - - l1 = countnumflds(r1); - l2 = countnumflds(r2); - if ((22 ? 2 : l1); - VOID partialno(&t2, r2, l2>2 ? 2 : l2); - r = cmpnum(t1.string,t2.string)<0 ? t1.string : t2.string; - if (cmpnum(r,r1)!=0 && cmpnum(r,r2)!=0) - return r; - } else if (cmpnumfld(r1, r2, l3+1)!=0) - return partialno(&t1,r1,l3); - } - rcserror("common ancestor of %s and %s undefined", r1, r2); - return 0; -} - - - - static int -buildjoin(initialfile) - char const *initialfile; -/* Function: merge pairs of elements in joinlist into initialfile - * If workstdout is set, copy result to stdout. - * All unlinking of initialfile, rev2, and rev3 should be done by tempunlink(). - */ -{ - struct buf commarg; - struct buf subs; - char const *rev2, *rev3; - int i; - char const *cov[10], *mergev[11]; - char const **p; - - bufautobegin(&commarg); - bufautobegin(&subs); - rev2 = maketemp(0); - rev3 = maketemp(3); /* buildrevision() may use 1 and 2 */ - - cov[1] = CO; - /* cov[2] setup below */ - p = &cov[3]; - if (expandarg) *p++ = expandarg; - if (suffixarg) *p++ = suffixarg; - if (versionarg) *p++ = versionarg; - if (zonearg) *p++ = zonearg; - *p++ = quietarg; - *p++ = RCSname; - *p = 0; - - mergev[1] = MERGE; - mergev[2] = mergev[4] = "-L"; - /* rest of mergev setup below */ - - i=0; - while (inum); - else { - bufscat(&subs, ","); - bufscat(&subs, joinlist[i-2]); - bufscat(&subs, ":"); - bufscat(&subs, joinlist[i-1]); - } - diagnose("revision %s\n",joinlist[i]); - bufscpy(&commarg, "-p"); - bufscat(&commarg, joinlist[i]); - cov[2] = commarg.string; - if (runv(-1, rev2, cov)) - goto badmerge; - diagnose("revision %s\n",joinlist[i+1]); - bufscpy(&commarg, "-p"); - bufscat(&commarg, joinlist[i+1]); - cov[2] = commarg.string; - if (runv(-1, rev3, cov)) - goto badmerge; - diagnose("merging...\n"); - mergev[3] = subs.string; - mergev[5] = joinlist[i+1]; - p = &mergev[6]; - if (quietflag) *p++ = quietarg; - if (lastjoin<=i+2 && workstdout) *p++ = "-p"; - *p++ = initialfile; - *p++ = rev2; - *p++ = rev3; - *p = 0; - switch (runv(-1, (char*)0, mergev)) { - case DIFF_FAILURE: case DIFF_SUCCESS: - break; - default: - goto badmerge; - } - i=i+2; - } - bufautoend(&commarg); - bufautoend(&subs); - return true; - - badmerge: - nerror++; - bufautoend(&commarg); - bufautoend(&subs); - return false; -} diff --git a/gnu/usr.bin/rcs/doc/rcs.ms b/gnu/usr.bin/rcs/doc/rcs.ms deleted file mode 100644 index 6de5ef9b7cf..00000000000 --- a/gnu/usr.bin/rcs/doc/rcs.ms +++ /dev/null @@ -1,1518 +0,0 @@ -.\" Format this file with: -.\" pic file | tbl | troff -ms -.\" -.\" \*s stands for $, and avoids problems when this file is checked in. -.ds s $ -.de D( -.DS -.nr VS 12p -.vs 12p -.I -.. -.de D) -.DE -.nr VS 18p -.vs 18p -.R -.. -.de Id -.ND 1 June 1995 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/doc/rcs.ms 295702 2016-02-17 14:34:01Z emaste $ -.RP -.TL -RCS\*-A System for Version Control -.sp -.AU -Walter F. Tichy -.AI -Department of Computer Sciences -Purdue University -West Lafayette, Indiana 47907 -.sp -.AB -An important problem in program development and maintenance is version control, -i.e., the task of keeping a software system consisting of many versions and -configurations well organized. -The Revision Control System (RCS) -is a software tool that assists with that task. -RCS manages revisions of text documents, in particular source programs, -documentation, and test data. -It automates the storing, retrieval, logging and identification of revisions, -and it provides selection mechanisms for composing configurations. -This paper introduces basic version control concepts and -discusses the practice of version control -using RCS. -For conserving space, RCS stores deltas, i.e., differences between -successive revisions. Several delta storage methods are discussed. -Usage statistics show that RCS's delta storage method is -space and time efficient. -The paper concludes with a detailed survey of version control tools. -.sp -\fBKeywords\fR: configuration management, history management, -version control, revisions, deltas. -.AE -.FS -An earlier version of this paper was published in -.I "Software\*-Practice & Experience" -.B 15 , -7 (July 1985), 637-654. -.FE -.nr VS 18p -.LP -.NH -Introduction -.PP -Version control is the task of keeping software -systems consisting of many versions and configurations well organized. -The Revision Control System (RCS) is a set of UNIX -commands that assist with that task. -.PP -RCS' primary function is to manage \fIrevision groups\fR. -A revision group is a set of text documents, called \fIrevisions\fR, -that evolved from each other. A new revision is -created by manually editing an existing one. -RCS organizes the revisions into an ancestral tree. The initial revision -is the root of the tree, and the tree edges indicate -from which revision a given one evolved. -Besides managing individual revision groups, RCS provides -flexible selection functions for composing configurations. -RCS may be combined with MAKE\u1\d, -resulting in a powerful package for version control. -.PP -RCS also offers facilities for -merging updates with customer modifications, -for distributed software development, and -for automatic identification. -Identification is the `stamping' -of revisions and configurations with unique markers. -These markers are akin to serial numbers, -telling software maintainers unambiguously which configuration -is before them. -.PP -RCS is designed for both production and experimental -environments. -In production environments, -access controls detect update conflicts and prevent overlapping changes. -In experimental environments, where strong controls are -counterproductive, it is possible to loosen the controls. -.PP -Although RCS was originally intended for programs, it is useful for any -text that is revised frequently and whose previous revisions must be -preserved. RCS has been applied successfully to store the source -text for drawings, VLSI layouts, documentation, specifications, -test data, form letters and articles. -.PP -This paper discusses the practice of -version control using RCS. -It also introduces basic version control concepts, -useful for clarifying current practice and designing similar systems. -Revision groups of individual components are treated in the next three sections, -and the extensions to configurations follow. -Because of its size, a survey of version control tools -appears at the end of the paper. -.NH -Getting started with RCS -.PP -Suppose a text file \fIf.c\fR is to be placed under control of RCS. -Invoking the check-in command -.D( -ci f.c -.D) -creates a new revision group with the contents of -\fIf.c\fR as the initial -revision (numbered 1.1) -and stores the group into the file \fIf.c,v\fR. -Unless told otherwise, the command deletes \fIf.c\fR. -It also asks for a description of the group. -The description should state the common purpose of all revisions in the group, -and becomes part of the group's documentation. -All later check-in commands will ask for a log entry, -which should summarize the changes made. -(The first revision is assigned a default log message, -which just records the fact that it is the initial revision.) -.PP -Files ending in \fI,v\fR -are called \fIRCS files\fR (\fIv\fR stands for \fIv\fRersions); -the others are called working files. -To get back the working file \fIf.c\fR in the previous example, -execute the check-out command: -.D( -co f.c -.D) -.R -This command extracts the latest revision from -the revision group \fIf.c,v\fR and writes -it into \fIf.c\fR. -The file \fIf.c\fR can now be edited and, when finished, -checked back in with \fIci\fR: -.D( -ci f.c -.D) -\fICi\fR assigns number 1.2 to -the new revision. -If \fIci\fR complains with the message -.D( -ci error: no lock set by -.D) -then the system administrator has decided to configure RCS for a -production environment by enabling the `strict locking feature'. -If this feature is enabled, all RCS files are initialized -such that check-in operations require a lock on the previous revision -(the one from which the current one evolved). -Locking prevents overlapping modifications if several people work on the same file. -If locking is required, the revision should -have been locked during the check-out by using -the option \fI\-l\fR: -.D( -co \-l f.c -.D) -Of course it is too late now for the check-out with locking, because -\fIf.c\fR has already been changed; checking out the file again -would overwrite the modifications. -(To prevent accidental overwrites, \fIco\fR senses the presence -of a working file and asks whether the user really intended to overwrite it. -The overwriting check-out is sometimes useful for -backing up to the previous revision.) -To be able to proceed with the check-in in the present case, first execute -.D( -rcs \-l f.c -.D) -This command retroactively locks the latest revision, unless someone -else locked it in the meantime. In this case, the two programmers -involved have to negotiate whose -modifications should take precedence. -.PP -If an RCS file is private, i.e., if only the owner of the file is expected -to deposit revisions into it, the strict locking feature is unnecessary and -may be disabled. -If strict locking is disabled, -the owner of the RCS file need not have a lock for check-in. -For safety reasons, all others -still do. Turning strict locking off and on is done with the commands: -.D( -rcs \-U f.c \fRand\fP rcs \-L f.c -.D) -These commands enable or disable the strict locking feature for each RCS file -individually. -The system administrator only decides whether strict locking is -enabled initially. -.PP -To reduce the clutter in a working directory, all RCS files can be moved -to a subdirectory with the name \fIRCS\fR. -RCS commands look first into that directory for RCS files. -All the commands presented above work -with the \fIRCS\fR subdirectory without change.\(dg -.FS \(dg -Pairs of RCS and working files can actually be specified in 3 ways: -a) both are given, b) only the working file is given, c) only the -RCS file is given. -If a pair is given, both files may have arbitrary path prefixes; -RCS commands pair them up intelligently. -.FE -.PP -It may be undesirable that \fIci\fR deletes the working file. -For instance, sometimes one would like to save the current revision, -but continue editing. -Invoking -.D( -ci \-l f.c -.D) -checks in \fIf.c\fR as usual, but performs an additional -check-out with locking afterwards. Thus, the working file does -not disappear after the check-in. -Similarly, the option -\fI\-u\fR does a check-in followed by a check-out without -locking. This option is useful if the file is needed for compilation after the check-in. -Both options update the identification markers in the working file -(see below). -.PP -Besides the operations \fIci\fR and \fIco\fR, RCS provides the following -commands: -.sp 0 -.nr VS 12p -.vs 12p -.TS -tab(%); -li l. -ident%extract identification markers -rcs%change RCS file attributes -rcsclean%remove unchanged working files (optional) -rcsdiff%compare revisions -rcsfreeze%record a configuration (optional) -rcsmerge%merge revisions -rlog%read log messages and other information in RCS files -.TE -A synopsis of these commands appears in the Appendix. -.NH 2 -Automatic Identification -.PP -RCS can stamp source and object code with special identification strings, -similar to product and serial numbers. -To obtain such identification, place the marker -.D( -\*sId\*s -.D) -into the text of a revision, for instance inside a comment. -The check-out operation will replace this marker with a string of the form -.D( -\*sId: filename revisionnumber date time author state locker \*s -.D) -This string need never be touched, because \fIco\fR keeps it -up to date automatically. -To propagate the marker into object code, simply put -it into a literal character string. In C, this is done as follows: -.D( -static char rcsid[] = \&"\*sId\*s\&"; -.D) -The command \fIident\fR extracts such markers from any file, in particular from -object code. -\fIIdent\fR helps to find out -which revisions of which modules were used in a given program. -It returns a complete and unambiguous component list, -from which a copy of the program can be reconstructed. -This facility is invaluable for program maintenance. -.PP -There are several additional identification markers, one for each component -of \*sId\*s. -The marker -.D( -\*sLog\*s -.D) -has a similar function. It accumulates -the log messages that are requested during check-in. -Thus, one can maintain the complete history of a revision directly inside it, -by enclosing it in a comment. -Figure 1 is an edited version of a log contained in revision 4.1 of -the file \fIci.c\fR. The log appears at the beginning of the file, -and makes it easy to determine what the recent modifications were. -.sp -.nr VS 12p -.vs 12p -.ne 18 -.nf -.in +0.5i -/* -.in +\w'/'u -* \*sLog: ci.c,v \*s -* Revision 4.1 1983/05/10 17:03:06 wft -* Added option \-d and \-w, and updated assignment of date, etc. to new delta. -* Added handling of default branches. -* -* Revision 3.9 1983/02/15 15:25:44 wft -* Added call to fastcopy() to copy remainder of RCS file. -* -* Revision 3.8 1983/01/14 15:34:05 wft -* Added ignoring of interrupts while new RCS file is renamed; -* avoids deletion of RCS files by interrupts. -* -* Revision 3.7 1982/12/10 16:09:20 wft -* Corrected checking of return code from diff. -* An RCS file now inherits its mode during the first ci from the working file, -* except that write permission is removed. -*/ -.in 0 -.ce 1 -Figure 1. Log entries produced by the marker \*sLog\*s. -.fi -.nr VS 18p -.vs 18p -.sp 0 -.LP -Since revisions are stored in the form of differences, -each log message is -physically stored once, -independent of the number of revisions present. -Thus, the \*sLog\*s marker incurs negligible space overhead. -.NH -The RCS Revision Tree -.PP -RCS arranges revisions in an ancestral tree. -The \fIci\fR command builds this tree; the auxiliary command \fIrcs\fR -prunes it. -The tree has a root revision, normally numbered 1.1, and successive revisions -are numbered 1.2, 1.3, etc. The first field of a revision number -is called the \fIrelease number\fR and the second one -the \fIlevel number\fR. Unless given explicitly, -the \fIci\fR command assigns a new revision number -by incrementing the level number of the previous revision. -The release number must be incremented explicitly, using the -\fI\-r\fR option of \fIci\fR. -Assuming there are revisions 1.1, 1.2, and 1.3 in the RCS file f.c,v, the command -.D( -ci \-r2.1 f.c \fRor\fP ci \-r2 f.c -.D) -assigns the number 2.1 to the new revision. -Later check-ins without the \fI\-r\fR option will assign the numbers 2.2, 2.3, -and so on. -The release number should be incremented only at major transition points -in the development, for instance when a new release of a software product has -been completed. -.NH 2 -When are branches needed? -.PP -A young revision tree is slender: -It consists of only one branch, called the trunk. -As the tree ages, side branches may form. -Branches are needed in the following 4 situations. -.IP "\fITemporary fixes\fR" -.sp 0 -Suppose a tree has 5 revisions grouped in 2 releases, -as illustrated in Figure 2. -Revision 1.3, the last one of release 1, is in operation at customer sites, -while release 2 is in active development. -.ne 4 -.PS 4i -.ps -2 -box "1.1" -arrow -box "1.2" -arrow -box "1.3" -arrow -box "2.1" -arrow -box "2.2" -arrow dashed -.ps +2 -.PE -.ce 1 -Figure 2. A slender revision tree. -.sp 0 -Now imagine a customer requesting a fix of -a problem in revision 1.3, although actual development has moved on -to release 2. RCS does not permit an extra -revision to be spliced in between 1.3 and 2.1, since that would not reflect -the actual development history. Instead, create a branch -at revision 1.3, and check in the fix on that branch. -The first branch starting at 1.3 has number 1.3.1, and -the revisions on that branch are numbered 1.3.1.1, 1.3.1.2, etc. -The double numbering is needed to allow for another -branch at 1.3, say 1.3.2. -Revisions on the second branch would be numbered -1.3.2.1, 1.3.2.2, and so on. -The following steps create -branch 1.3.1 and add revision 1.3.1.1: -.sp 0 -.I -.nr VS 12p -.vs 12p -.TS -tab(%); -l l l. - %co \-r1.3 f.c% \*- check out revision 1.3 - %edit f.c% \*- change it - %ci \-r1.3.1 f.c% \*- check it in on branch 1.3.1 -.TE -.nr VS 18p -.vs 18p -.R -This sequence of commands transforms the tree of Figure 2 into -the one in Figure 3. -Note that it may be necessary to incorporate the differences -between 1.3 and 1.3.1.1 -into a revision at level 2. The operation \fIrcsmerge\fR automates this -process (see the Appendix). -.ne 7 -.PS 4i -.ps -2 - box "1.1" - arrow - box "1.2" - arrow -R13: box "1.3" - arrow -R21: box "2.1" - arrow -R22: box "2.2" - arrow dashed - line invis down from R21.s -RB1: box "1.3.1.1" - arrow dashed right from RB1.e - arrow from R13.s to RB1.w -.ps +2 -.PE -.ce 1 -Figure 3. A revision tree with one side branch -.sp -.IP "\fIDistributed development and customer modifications\fR" -.sp 0 -Assume a situation as in Figure 2, where revision 1.3 is in operation -at several customer sites, -while release 2 is in development. -Customer sites should use RCS to store the distributed software. -However, customer modifications should not be placed on the same branch -as the distributed source; instead, they should be placed on a side branch. -When the next software distribution arrives, -it should be appended to the trunk of -the customer's RCS file, and the customer -can then merge the local modifications back into the new release. -In the above example, a -customer's RCS file would contain the following tree, assuming -that the customer has received revision 1.3, added his local modifications -as revision 1.3.1.1, then received revision 2.4, and merged -2.4 and 1.3.1.1, resulting in 2.4.1.1. -.ne 7 -.PS 4i -.ps -2 -R13: box "1.3" - line invis -R21: box invis - line invis -R22: box invis - line invis -R24: box "2.4" - line invis -R25: box invis - line invis - arrow from R13.e to R24.w - line invis down from R21.s -RB1: box "1.3.1.1" - arrow from R13.s to RB1.w - right - line invis down from R25.s -RB2: box "2.4.1.1" - arrow from R24.s to RB2.w -.ps +2 -.PE -.ce 1 -Figure 4. A customer's revision tree with local modifications. -.sp 1 -This approach is actually practiced in the CSNET project, -where several universities and a company cooperate -in developing a national computer network. -.IP "\fIParallel development\fR" -.sp 0 -Sometimes it is desirable to explore an alternate design or -a different implementation technique in parallel with the -main line development. Such development -should be carried out on a side branch. -The experimental changes may later be moved into the main line, or abandoned. -.IP "\fIConflicting updates\fR" -.sp 0 -A common occurrence is that one programmer -has checked out a revision, but cannot complete the assignment -for some reason. In the meantime, another person -must perform another modification -immediately. In that case, the second person should check-out the same revision, -modify it, and check it in on a side branch, for later merging. -.PP -Every node in a revision tree consists of the following attributes: -a revision number, a check-in date and time, the author's identification, -a log entry, a state and the actual text. All these attributes -are determined at the time the revision is checked in. -The state attribute indicates the status of a revision. -It is set automatically to `experimental' during check-in. -A revision can later be promoted to a higher status, for example -`stable' or `released'. The set of states is user-defined. -.NH 2 -Revisions are represented as deltas -.PP -For conserving space, RCS stores revisions in the form -of deltas, i.e., as differences between revisions. -The user interface completely hides this fact. -.PP -A delta is a sequence of edit commands that transforms one string -into another. The deltas employed by RCS are line-based, which means -that the only edit commands allowed are insertion and deletion of lines. -If a single character in a line is changed, the -edit scripts consider the entire line changed. -The program \fIdiff\fR\u2\d -produces a small, line-based delta between pairs of text files. -A character-based edit script would take much longer to compute, -and would not be significantly shorter. -.PP -Using deltas is a classical space-time tradeoff: deltas reduce the -space consumed, but increase access time. -However, a version control tool should impose as little delay -as possible on programmers. -Excessive delays discourage the use of version controls, -or induce programmers to take shortcuts that compromise system integrity. -To gain reasonably fast access time for both editing and compiling, -RCS arranges deltas in the following way. -The most recent revision on the trunk is stored intact. -All other revisions on the trunk are stored as reverse deltas. -A reverse delta describes how to go backward in the development history: -it produces the desired revision if applied to the successor of that revision. -This implementation has the advantage -that extraction of the latest revision is a simple and fast copy -operation. -Adding a new revision to the trunk is also fast: \fIci\fR simply -adds the new revision intact, replaces the previous -revision with a reverse delta, and keeps the rest of the old deltas. -Thus, \fIci\fR requires the computation -of only one new delta. -.PP -Branches need special treatment. The naive solution would be to -store complete copies for the tips of all branches. -Clearly, this approach would cost too much space. Instead, -RCS uses \fIforward\fR deltas for branches. Regenerating a revision -on a side branch proceeds as follows. First, extract the latest revision -on the trunk; secondly, apply reverse deltas until the fork revision for -the branch is obtained; thirdly, apply forward deltas until the desired -branch revision is reached. Figure 5 illustrates a tree with -one side branch. Triangles pointing to the left and right represent -reverse and forward deltas, respectively. -.ne 8 -.PS 4i -.ps -2 -define BD X [line invis $1 right .5; -line up .3 then left .5 down .3 then right .5 down .3 then up .3] X - -define FD X [line invis $1 right .5; -line left .5 down .3 then up .6 then right .5 down .3;] X - -right -D11: BD(" 1.1") - arrow right from D11.e -D12: BD(" 1.2") - arrow right from D12.e -D13: BD(" 1.3") - arrow right from D13.e -D21: BD(" 2.1") - arrow right from D21.e -D22: box "2.2" - line invis down from D21.s -F1: FD("1.3.1.1 ") - arrow from D13.se to F1.w - arrow from F1.e right - right -F2: FD("1.3.1.2 ") -.ps +2 -.PE -.ce 1 -Figure 5. A revision tree with reverse and forward deltas. -.sp 0 -.PP -Although implementing fast check-out for the latest trunk revision, -this arrangement has the disadvantage that generation of other revisions -takes time proportional to the number of deltas applied. For example, -regenerating the branch tip in Figure 5 requires application of five -deltas (including the initial one). Since usage statistics show that -the latest trunk revision is the one that is retrieved in 95 per cent -of all cases (see the section on usage statistics), biasing check-out time -in favor of that revision results in significant savings. -However, careful implementation of the delta application process is -necessary to provide low retrieval overhead for other revisions, in -particular for branch tips. -.PP -There are several techniques for delta application. -The naive one is to pass each delta to a general-purpose text editor. -A prototype of RCS invoked the UNIX editor \fIed\fR both -for applying deltas and for expanding the identification markers. -Although easy to implement, performance was poor, owing to the -high start-up costs and excess generality of \fIed\fR. An intermediate -version of RCS used a special-purpose, stream-oriented editor. -This technique reduced the cost of applying a delta to the cost of -checking out the latest trunk revision. The reason for this behavior -is that each delta application involves a complete pass over -the preceding revision. -.PP -However, there is a much better algorithm. Note that the deltas are -line oriented and that most of the work of a stream editor involves -copying unchanged lines from one revision to the next. A faster -algorithm avoids unnecessary copying of character strings by using -a \fIpiece table\fR. -A piece table is a one-dimensional array, specifying how a given -revision is `pieced together' from lines in the RCS file. -Suppose piece table \fIPT\dr\u\fR represents revision \fIr\fR. -Then \fIPT\dr\u[i]\fR contains the starting position of line \fIi\fR -of revision \fIr\fR. -Application of the next delta transforms piece table \fIPT\dr\u\fR -into \fIPT\dr+1\u\fR. For instance, a delete command removes a -series of entries from the piece table. An insertion command inserts -new entries, moving the entries following the insertion point further down the -array. The inserted entries point to the text lines in the delta. -Thus, no I/O is involved except for reading the delta itself. When all -deltas have been applied to the piece table, a sequential pass -through the table looks up each line in the RCS file and copies it to -the output file, updating identification markers at the same time. -Of course, the RCS file must permit random access, since the copied -lines are scattered throughout that file. Figure 6 illustrates an -RCS file with two revisions and the corresponding piece tables. -.ne 13 -.sp 6 -.ce 1 -\fIFigure 6 is not available.\fP -.sp 5 -.ce 1 -Figure 6. An RCS file and its piece tables -.sp 0 -.PP -The piece table approach has the property that the time for applying a single -delta is roughly determined by the size of the delta, and not by the -size of the revision. For example, if a delta is -10 per cent of the size of a revision, then applying it takes only -10 per cent of the time to generate the latest trunk revision. (The stream -editor would take 100 per cent.) -.PP -There is an important alternative for representing deltas that affects -performance. SCCS\u3\d, -a precursor of RCS, uses \fIinterleaved\fR deltas. -A file containing interleaved deltas is partitioned into blocks of lines. -Each block has a header that specifies to which revision(s) the block -belongs. The blocks are sorted out in such a way that a single -pass over the file can pick up all the lines belonging to a given -revision. Thus, the regeneration time for all revisions is the same: -all headers must be inspected, and the associated blocks either copied -or skipped. As the number of revisions increases, the cost of retrieving -any revision is much higher than the cost of checking out the -latest trunk revision with reverse deltas. A detailed comparison -of SCCS's interleaved deltas and RCS's reverse deltas can be found -in Reference 4. -This reference considers the version of RCS with the -stream editor only. The piece table method improves performance -further, so that RCS is always faster than SCCS, except if 10 -or more deltas are applied. -.PP -Additional speed-up for both delta methods can be obtained by caching -the most recently generated revision, as has been implemented in DSEE.\u5\d -With caching, access time to frequently used revisions can approach normal file -access time, at the cost of some additional space. -.NH -Locking: A Controversial Issue -.PP -The locking mechanism for RCS was difficult to design. -The problem and its solution are first presented in their `pure' form, -followed by a discussion of the complications -caused by `real-world' considerations. -.PP -RCS must prevent two or more persons from depositing competing changes of the -same revision. -Suppose two programmers check out revision 2.4 and -modify it. Programmer A checks in a revision before programmer B\&. -Unfortunately, programmer B has not seen A's -changes, so the effect is that A's changes are covered up by B's deposit. -A's changes are not lost since all revisions -are saved, but they are confined to a single revision.\(dd -.FS \(dd -Note that this problem is entirely different from the atomicity problem. -Atomicity means that -concurrent update operations on the same RCS file cannot be permitted, -because that may result in inconsistent data. -Atomic updates are essential (and implemented in RCS), -but do not solve the conflict discussed here. -.FE -.PP -This conflict is prevented in RCS by locking. -Whenever someone intends to edit a revision (as opposed -to reading or compiling it), the revision should be checked out -and locked, -using the \fI\-l\fR option on \fIco\fR. On subsequent check-in, -\fIci\fR tests the lock and then removes it. -At most one programmer at a time may -lock a particular revision, and only this programmer may check in -the succeeding revision. -Thus, while a revision is locked, it is the exclusive responsibility -of the locker. -.PP -An important maxim for software tools like RCS is that they must -not stand in the way of making progress with a project. -This consideration leads to several weakenings of the locking mechanism. -First of all, even if a revision is locked, it can -still be checked out. This is necessary if other people -wish to compile or inspect the locked revision -while the next one is in preparation. The only operations they -cannot do are to lock the revision or to check in the succeeding one. Secondly, -check-in operations on other branches in the RCS file are still possible; the -locking of one revision does not affect any other revision. -Thirdly, revisions are occasionally locked for a long period of time -because a programmer is absent or otherwise unable to complete -the assignment. If another programmer has to make a pressing change, -there are the following three alternatives for making progress: -a) find out who is holding the lock and ask that person to release it; -b) check out the locked revision, modify it, check it -in on a branch, and merge the changes later; -c) break the lock. Breaking a lock leaves a highly visible -trace, namely an electronic mail message that is sent automatically to the -holder of the lock, recording the breaker and a commentary requested from him. -Thus, breaking locks is tolerated under certain circumstances, -but will not go unnoticed. -Experience has shown that the automatic mail message attaches a high enough -stigma to lock breaking, -such that programmers break locks only in real emergencies, -or when a co-worker resigns and leaves locked revisions behind. -.PP -If an RCS file is private, i.e., when a programmer owns an RCS file -and does not expect anyone else to perform check-in operations, -locking is an unnecessary nuisance. -In this case, -the `strict locking feature' discussed earlier may be disabled, -provided that file protection -is set such that only the owner may write the RCS file. -This has the effect that only the owner can check-in revisions, -and that no lock is needed for doing so. -.PP -As added protection, -each RCS file contains an access list that specifies the users -who may execute update operations. If an access list is empty, -only normal UNIX file protection applies. Thus, the access list is -useful for restricting the set of people who would otherwise have update -permission. Just as with locking, the access list -has no effect on read-only operations such as \fIco\fR. This approach -is consistent with the UNIX philosophy of openness, which contributes -to a productive software development environment. -.NH -Configuration Management -.PP -The preceding sections described how RCS deals with revisions of individual -components; this section discusses how to handle configurations. -A configuration is a set of revisions, where each revision comes -from a different revision group, and the revisions are selected -according to a certain criterion. -For example, -in order to build a functioning compiler, the `right' -revisions from the scanner, the parser, the optimizer -and the code generator must be combined. -RCS, in conjunction with MAKE, -provides a number of facilities to effect a smooth selection. -.NH 2 -RCS Selection Functions -.PP -.IP "\fIDefault selection\fR" -.sp 0 -During development, the usual selection criterion is to choose -the latest revision of all components. The \fIco\fR command -makes this selection by default. For example, the command -.D( -co *,v -.D) -retrieves the latest revision on the default branch of each RCS file -in the current directory. -The default branch is usually the trunk, but may be -set to be a side branch. -Side branches as defaults are needed in distributed software development, -as discussed in the section on the RCS revision tree. -.sp -.IP "\fIRelease based selection\fR" -.sp 0 -Specifying a release or branch number selects the latest revision in -that release or branch. -For instance, -.D( -co \-r2 *,v -.D) -retrieves the latest revision with release number 2 from each RCS file. -This selection is convenient if a release has been completed and -development has moved on to the next release. -.sp -.IP "\fIState and author based selection\fR" -.sp 0 -If the highest level number within a given release number -is not the desired one, -the state attribute can help. For example, -.D( -co \-r2 \-sReleased *,v -.D) -retrieves the latest revision with release number 2 whose state attribute -is `Released'. -Of course, the state attribute has to be set appropriately, using the -\fIci\fR or \fIrcs\fR commands. -Another alternative is to select a revision by its author, -using the \fI\-w\fR option. -.sp -.IP "\fIDate based selection\fR" -.sp 0 -Revisions may also be selected by date. -Suppose a release of an entire system was -completed and current on March 4, at 1:00 p.m. local time. Then the command -.D( -co \-d'March 4, 1:00 pm LT' *,v -.D) -checks out all the components of that release, independent of the numbering. -The \fI\-d\fR option specifies a `cutoff date', i.e., -the revision selected has a check-in date that -is closest to, but not after the date given. -.IP "\fIName based selection\fR" -.sp 0 -The most powerful selection function is based on assigning symbolic -names to revisions and branches. -In large systems, a single release number or date is not sufficient -to collect the appropriate revisions from all groups. -For example, suppose one wishes to combine release 2 -of one subsystem and release 15 of another. -Most likely, the creation dates of those releases differ also. -Thus, a single revision number or date passed to the \fIco\fR command -will not suffice to select the right revisions. -Symbolic revision numbers solve this problem. -Each RCS file may contain a set of symbolic names that are mapped -to numeric revision numbers. For example, assume -the symbol \fIV3\fR is bound to release number 2 in file \fIs,v\fR, and to -revision number 15.9 in \fIt,v\fR. -Then the single command -.D( -co \-rV3 s,v t,v -.D) -retrieves the latest revision of release 2 from \fIs,v\fR, -and revision 15.9 from \fIt,v\fR. -In a large system with many modules, checking out all -revisions with one command greatly simplifies configuration management. -.PP -Judicious use of symbolic revision numbers helps with organizing -large configurations. -A special command, \fIrcsfreeze\fR, -assigns a symbolic revision number to a selected revision -in every RCS file. -\fIRcsfreeze\fR effectively freezes a configuration. -The assigned symbolic revision number selects all components -of the configuration. -If necessary, symbolic numbers -may even be intermixed with numeric ones. Thus, \fIV3.5\fR in the -above example -would select revision 2.5 in \fIs,v\fR and branch 15.9.5 in \fIt,v\fR. -.PP -The options \fI\-r\fR, \fI\-s\fR, \fI\-w\fR and \fI\-d\fR -may be combined. If a branch is given, the latest revision -on that branch satisfying all conditions is retrieved; -otherwise, the default branch is used. -.NH 2 -Combining MAKE and RCS -.PP -MAKE\u1\d -is a program that processes configurations. -It is driven by configuration specifications -recorded in a special file, called a `Makefile'. -MAKE avoids redundant processing steps -by comparing creation dates of source and processed objects. -For example, when instructed to compile all -modules of a given system, it only recompiles -those source modules that were changed -since they were processed last. -.PP -MAKE has been extended with an auto-checkout feature for RCS.* -.FS * -This auto-checkout extension is available only in some versions of MAKE, -e.g. GNU MAKE. -.FE -When a certain file to be processed is not present, -MAKE attempts a check-out operation. -If successful, MAKE performs the required processing, and then deletes -the checked out file to conserve space. -The selection parameters discussed above can be passed to MAKE -either as parameters, or directly embedded in the Makefile. -MAKE has also been extended to search the subdirectory named \fIRCS\fR -for needed files, rather than just the current working directory. -However, if a working file is present, MAKE totally ignores the corresponding -RCS file and uses the working file. -(In newer versions of MAKE distributed by AT&T and others, -auto-checkout can be -achieved with the rule DEFAULT, instead of a special extension of MAKE. -However, a file checked out by the rule DEFAULT -will not be deleted after processing. \fIRcsclean\fR can be -used for that purpose.) -.PP -With auto-checkout, RCS/MAKE can effect a selection rule -especially tuned for multi-person software development and maintenance. -In these situations, -programmers should obtain configurations that consist of -the revisions they have personally checked out plus the latest -checked in revision of all other revision groups. -This schema can be set up as follows. -.PP -Each programmer chooses a working directory -and places into it a symbolic link, named \fIRCS\fR, -to the directory containing the relevant RCS files. -The symbolic link makes sure that \fIco\fR and \fIci\fR -operations need only specify the working files, and that -the Makefile need not be changed. -The programmer then checks out the needed files and modifies them. -If MAKE is invoked, -it composes configurations by selecting those -revisions that are checked out, and the rest from the -subdirectory \fIRCS\fR. -The latter selection may be controlled by a symbolic -revision number or any of the other selection criteria. -If there are several programmers editing in separate working directories, -they are insulated from each other's changes until checking in their -modifications. -.PP -Similarly, a maintainer can recreate an older configuration -by starting to work in an empty working directory. -During the initial MAKE invocation, all revisions are selected from RCS files. -As the maintainer checks out files and modifies them, -a new configuration is gradually built up. -Every time MAKE is invoked, it substitutes the modified revisions -into the configuration being manipulated. -.PP -A final application of RCS is to use it for storing Makefiles. -Revision groups of Makefiles represent -multiple versions of configurations. -Whenever a configuration is baselined or distributed, -the best approach is to unambiguously fix -the configuration with a symbolic revision number by calling -\fIrcsfreeze\fR, -to embed that symbol into the Makefile, and to -check in the Makefile (using the same symbolic revision number). -With this approach, old configurations -can be regenerated easily and reliably. -.NH -Usage Statistics -.PP -The following usage statistics were collected on two DEC VAX-11/780 -computers of the Purdue Computer Science Department. Both machines -are mainly used for research purposes. Thus, the data -reflect an environment in which the majority of projects -involve prototyping and advanced software development, -but relatively little long-term maintenance. -.PP -For the first experiment, -the \fIci\fR and \fIco\fR operations were instrumented -to log the number of backward and forward deltas applied. -The data were collected during a 13 month period -from Dec. 1982 to Dec. 1983. -Table I summarizes the results. -.sp 0 -.nr VS 12p -.vs 12p -.TS -center,box,tab(#); -c|c|c|c|c s|c s -c|c|c|c|c s|c s -l|n|n|n|n n|n n. -Operation#Total#Total deltas#Mean deltas#Operations#Branch - #operations #applied#applied#with >1 delta#operations -_ -co # 7867# 9320#1.18#509#(6%)#203#(3%) -ci # 3468# 2207#0.64# 85#(2%)# 75#(2%) -ci & co#11335#11527#1.02#594#(5%)#278#(2%) -.TE -.ce 1 -Table I. Statistics for \fIco\fR and \fIci\fR operations. -.nr VS 18p -.vs 18p -.PP -The first two lines show statistics for check-out and check-in; -the third line shows the combination. -Recall that \fIci\fR performs an implicit check-out to obtain -a revision for computing the delta. -In all measures presented, the most recent revision (stored intact) -counts as one delta. The number of deltas applied represents -the number of passes necessary, where the first `pass' is a copying step. -.PP -Note that the check-out operation is executed more than -twice as frequently as the check-in operation. -The fourth column gives the mean number of deltas -applied in all three cases. -For \fIci\fR, the mean number of deltas applied is less -than one. -The reasons are that the initial check-in requires no delta at all, and that -the only time \fIci\fR requires more than one delta is for branches. -Column 5 shows the actual number of operations that applied more than one -delta. -The last column indicates that branches were not used often. -.PP -The last three columns demonstrate that the most recent trunk revision -is by far the most frequently accessed. -For RCS, check-out of -this revision is a simple copy operation, which is the absolute minimum -given the copy-semantics of \fIco\fR. -Access to older revisions and branches -is more common in non-academic environments, -yet even if access to older deltas were an order -of magnitude more frequent, -the combined average number of deltas applied would still be below 1.2. -Since RCS is faster than SCCS until up to 10 delta applications, -reverse deltas are clearly the method of choice. -.PP -The second experiment, conducted in March of 1984, -involved surveying the existing RCS files -on our two machines. The goal was to determine the mean number of -revisions per RCS file, as well as the space consumed by them. -Table II shows the results. (Tables I and II were produced at different -times and are unrelated.) -.sp 0 -.nr VS 12p -.vs 12p -.TS -center,box,tab(#); -c | c | c | c | c | c | c -c | c | c | c | c | c | c -l | n | n | n | n | n | n. - #Total RCS#Total#Mean#Mean size of#Mean size of#Overhead - #files#revisions#revisions#RCS files#revisions -_ -All files #8033#11133#1.39#6156#5585#1.10 -Files with#1477# 4578#3.10#8074#6041#1.34 -\(>= 2 deltas -.TE -.ce 1 -Table II. Statistics for RCS files. -.nr VS 18p -.vs 18p -.PP -The mean number of revisions per RCS file is 1.39. -Columns 5 and 6 show the mean sizes (in bytes) of an RCS file -and of the latest revision of each RCS file, respectively. -The `overhead' column contains the ratio of the mean sizes. -Assuming that all revisions in an RCS file are approximately the same size, -this ratio gives a measure of the space consumed by the extra revisions. -.PP -In our sample, over 80 per cent of the RCS files contained only a single revision. -The reason is that our -systems programmers routinely check in all source files -on the distribution tapes, even though they may never touch them again. -To get a better indication of how much space savings are possible -with deltas, all measures with those files -that contained 2 or more revisions were recomputed. Only for those files -is RCS necessary. -As shown in the second line, the average number of revisions for those files is -3.10, with an overhead of 1.34. This means that the extra 2.10 deltas -require 34 per cent extra space, or -16 per cent per extra revision. -Rochkind\u3\d -measured the space consumed by SCCS, and -reported an average of 5 revisions per group -and an overhead of 1.37 (or about 9 per cent per extra revision). -In a later paper, Glasser\u6\d -observed an average of 7 revisions per group in a single, large project, -but provided no overhead figure. -In his paper on DSEE\u5\d, -Leblang reported that delta storage combined with blank compression -results in an overhead of a mere 1\-2 per cent per revision. -Since leading blanks accounted for about 20 per cent of the surveyed Pascal -programs, a revision group with 5\-10 members was smaller -than a single cleartext copy. -.PP -The above observations demonstrate clearly that the space needed -for extra revisions is small. With delta storage, the luxury of -keeping multiple revisions online is certainly affordable. -In fact, introducing a system with delta storage may reduce -storage requirements, because programmers often save back-up copies -anyway. Since back-up copies are stored much more efficiently with deltas, -introducing a system such as RCS may -actually free a considerable amount of space. -.NH -Survey of Version Control Tools -.PP -The need to keep back-up copies of software arose when -programs and data were no longer stored on paper media, but were entered -from terminals and stored on disk. -Back-up copies are desirable for reliability, and many modern editors -automatically save a back-up copy for every file touched. -This strategy -is valuable for short-term back-ups, but not suitable for long-term -version control, since an existing back-up copy is overwritten whenever the -corresponding file is edited. -.PP -Tape archives are suitable for long-term, offline storage. -If all changed files are dumped on a back-up tape once per day, old revisions -remain accessible. However, tape archives are unsatisfactory -for version control in several ways. First, backing up the file -system every 24 hours does not capture intermediate revisions. -Secondly, the old revisions are not online, -and accessing them is tedious and time-consuming. -In particular, it is impractical to -compare several old revisions of a group, -because that may require mounting and searching several tapes. -Tape archives are important fail-safe tools in the -event of catastrophic disk failures or accidental deletions, -but they are ill-suited for version control. -Conversely, version control tools do not obviate the -need for tape archives. -.PP -A natural technique for keeping several old revisions online is -to never delete a file. -Editing a file -simply creates a new file with the same -name, but with a different sequence number. -This technique, available as an option in DEC's VMS operating system, -turns out to be inadequate for version control. -First, it is prohibitively expensive in terms of storage costs, -especially since no data compression techniques are employed. -Secondly, indiscriminately storing every change produces too many -revisions, and programmers have difficulties distinguishing them. -The proliferation of revisions forces programmers to spend much time on -finding and deleting useless files. -Thirdly, most of the support functions like locking, logging, -revision selection, -and identification described in this paper are not available. -.PP -An alternative approach is to separate editing from revision control. -The user may repeatedly edit a given revision, -until freezing it with an explicit command. -Once a revision is frozen, it is stored permanently and can no longer be modified. -(In RCS, freezing a revisions is done with \fIci\fR.) -Editing a frozen revision implicitly creates a new one, which -can again be changed repeatedly until it is frozen itself. -This approach saves exactly those revisions that the user -considers important, and keeps the number of revisions manageable. -IBM's CLEAR/CASTER\u7\d, -AT&T's SCCS\u3\d, -CMU's SDC\u8\d -and DEC's CMS\u9\d, -are examples of version control systems using this approach. -CLEAR/CASTER maintains a data base of programs, specifications, -documentation and messages, using deltas. -Its goal is to provide control over the development process from a -management viewpoint. -SCCS stores multiple revisions of source text in an ancestral tree, -records a log entry for each revision, -provides access control, and has facilities -for uniquely identifying each revision. -An efficient delta technique -reduces the space consumed by each revision group. -SDC is much simpler than SCCS because it stores not more than -two revisions. However, it maintains a complete log for all old -revisions, some of which may be on back-up tape. -CMS, like SCCS, manages tree-structured revision groups, -but offers no identification mechanism. -.PP -Tools for dealing with configurations are still in a state of flux. -SCCS, SDC and CMS can be combined with MAKE or MAKE-like programs. -Since flexible selection rules are missing from all these tools, -it is sometimes difficult -to specify precisely which revision of each group -should be passed to MAKE for building a desired configuration. -The Xerox Cedar system\u10\d -provides a `System Modeller' that can rebuild -a configuration from an arbitrary set of module revisions. -The revisions of a module are only distinguished by creation time, -and there is no tool for managing groups. -Since the selection rules are primitive, -the System Modeller appears to be somewhat tedious to use. -Apollo's DSEE\u5\d -is a sophisticated software engineering environment. -It manages revision groups in a way similar to SCCS and CMS. Configurations -are built using `configuration threads'. -A configuration thread states which revision of each group -named in a configuration should be chosen. -A configuration thread may contain dynamic specifiers -(e.g., `choose the revisions I am currently working on, -and the most recent revisions otherwise'), which are bound -automatically at build time. -It also provides a notification mechanism for alerting -maintainers about the need to rebuild a system after a change. -.PP -RCS is based on a general model for describing -multi-version/multi-configuration systems\u11\d. -The model describes systems using AND/OR graphs, where AND nodes represent -configurations, and OR nodes represent version groups. -The model gives rise to a suit of selection rules for -composing configurations, almost all of which are implemented in RCS. -The revisions selected by RCS are passed to MAKE for configuration building. -Revision group management is modelled after SCCS. -RCS retains SCCS's best features, -but offers a significantly simpler user interface, -flexible selection rules, adequate integration with MAKE -and improved identification. -A detailed comparison of RCS and SCCS appears in Reference 4. -.PP -An important component of all revision control systems -is a program for computing deltas. -SCCS and RCS use the program \fIdiff\fR\u2\d, -which first computes the longest common substring of two -revisions, and then produces the delta from that substring. -The delta is simply an edit script consisting of deletion and -insertion commands that generate one revision from the other. -.PP -A delta based on a longest common substring is not necessarily minimal, -because it does not take advantage of crossing block moves. -Crossing block moves arise if two or more blocks of lines -(e.g., procedures) -appear in a different order in two revisions. -An edit script derived from a longest common substring -first deletes the shorter of the two blocks, and then reinserts it. -Heckel\u12\d -proposed an algorithm for detecting block moves, but -since the algorithm is based on heuristics, -there are conditions -under which the generated delta is far from minimal. -DSEE uses this algorithm combined with blank compression, -apparently with satisfactory overall results. -A new algorithm that is guaranteed to produce a minimal delta based on -block moves appears in Reference 13. -A future release of RCS will use this algorithm. -.PP -\fIAcknowledgements\fR: -Many people have helped make RCS a success by contributed criticisms, suggestions, -corrections, and even whole new commands (including manual pages). -The list of people is too long to be -reproduced here, but my sincere thanks for their help and -goodwill goes to all of them. -.sp -.nr VS 12p -.vs 12p -.SH -Appendix: Synopsis of RCS Operations -.LP -.IP "\fIci\fP \fB\- check in revisions\fP" -.sp 0 -\fICi\fR stores the contents of a working file into the -corresponding RCS file as a new revision. -If the RCS file doesn't exist, \fIci\fR creates it. -\fICi\fR removes the working file, unless one of the options -\fI\-u\fR or \fI\-l\fR is present. -For each check-in, \fIci\fR asks for a commentary -describing the changes relative to the previous revision. -.sp 1 -\fICi\fR assigns the revision number given by the \fI\-r\fR option; -if that option is missing, it derives the number from the -lock held by the user; if there is no lock and locking is not strict, -\fIci\fR increments the number of the latest revision on the trunk. -A side branch can only be started by explicitly specifying its -number with the \fI\-r\fR option during check-in. -.sp 1 -\fICi\fR also determines -whether the revision to be checked in is different from the -previous one, and asks whether to proceed if not. -This facility simplifies check-in operations for large systems, -because one need not remember which files were changed. -.sp 1 -The option \fI\-k\fR searches the checked in file for identification -markers containing -the attributes -revision number, check-in date, author and state, and assigns these -to the new revision rather than computing them. This option is -useful for software distribution: Recipients of distributed software -using RCS should check in updates with the \fI\-k\fR option. -This convention guarantees that revision numbers, check-in dates, -etc., are the same at all sites. -.IP "\fIco\fP \fB\- check out revisions\fP" -.sp 0 -\fICo\fR retrieves revisions according to revision number, -date, author and state attributes. It either places the revision -into the working file, or prints it on the standard output. -\fICo\fR always expands the identification markers. -.IP "\fIident\fP \fB\- extract identification markers\fP" -.sp 0 -\fIIdent\fR extracts the identification markers expanded by \fIco\fR -from any file and prints them. -.IP "\fIrcs\fP \fB\- change RCS file attributes\fP" -.sp 0 -\fIRcs\fR is an administrative operation that changes access lists, -locks, unlocks, breaks locks, toggles the strict-locking feature, -sets state attributes and symbolic revision numbers, changes the -description, and deletes revisions. A revision can -only be deleted if it is not the fork of a side branch. -.br -.ne 10 -.IP "\fIrcsclean\fP \fB\- clean working directory\fP" -.sp 0 -\fIRcsclean\fR removes working files that were checked out but never changed.* -.FS * -The \fIrcsclean\fP and \fIrcsfreeze\fP commands -are optional and are not always installed. -.FE -.IP "\fIrcsdiff\fP \fB\- compare revisions\fP" -.sp 0 -\fIRcsdiff\fR compares two revisions and prints their -difference, using the UNIX tool \fIdiff\fR. -One of the revisions compared may be checked out. -This command is useful for finding out about changes. -.IP "\fIrcsfreeze\fP \fB\- freeze a configuration\fP" -.sp 0 -\fIRcsfreeze\fR assigns the same symbolic revision number -to a given revision in all RCS files. -This command is useful for accurately recording a configuration.* -.IP "\fIrcsmerge\fP \fB\- merge revisions\fP" -.sp 0 -\fIRcsmerge\fR merges two revisions, \fIrev1\fR and \fIrev2\fR, -with respect to a common ancestor. -A 3-way file comparison determines the segments of lines that -are (a) the same in all three revisions, or (b) the same in 2 revisions, -or (c) different in all three. For all segments of type (b) where -\fIrev1\fR is the differing revision, -the segment in \fIrev1\fR replaces the corresponding segment of \fIrev2\fR. -Type (c) indicates an overlapping change, is flagged as an error, and requires user -intervention to select the correct alternative. -.IP "\fIrlog\fP \fB\- read log messages\fP" -.sp 0 -\fIRlog\fR prints the log messages and other information in an RCS file. -.bp -.LP -.nr VS 12p -.vs 12p -.]< -.ds [F 1 -.]- -.ds [K FELD02 -.ds [K MakeArticle -.ds [A Feldman, Stuart I. -.ds [D March 1979 -.ds [T Make\*-A Program for Maintaining Computer Programs -.ds [J Software\*-Practice & Experience -.ds [V 9 -.ds [N 3 -.ds [P 255-265 -.nr [P 1 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 1 journal-article -.ds [F 2 -.]- -.ds [K HUNT01 -.ds [T An Algorithm for Differential File Comparison -.ds [A Hunt, James W. -.as [A " and McIlroy, M. D. -.ds [I Computing Science Technical Report, Bell Laboratories -.ds [R 41 -.ds [D June 1976 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 4 tech-report -.ds [F 3 -.]- -.ds [K SCCS -.ds [A Rochkind, Marc J. -.ds [D Dec. 1975 -.ds [T The Source Code Control System -.ds [J IEEE Transactions on Software Engineering -.ds [V SE-1 -.ds [N 4 -.ds [P 364-370 -.nr [P 1 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 1 journal-article -.ds [F 4 -.]- -.ds [K TICH08 -.ds [T Design, Implementation, and Evaluation of a Revision Control System -.ds [A Tichy, Walter F. -.ds [B Proceedings of the 6th International Conference on Software Engineering -.ds [I ACM, IEEE, IPS, NBS -.ds [D September 1982 -.ds [P 58-67 -.nr [P 1 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 3 article-in-book -.ds [F 5 -.]- -.ds [K LEBL01 -.ds [A Leblang, David B. -.as [A " and Chase, Robert P. -.ds [T Computer-Aided Software Engineering in a Distributed Workstation Environment -.ds [O Proceedings of the ACM SIGSOFT/SIGPLAN Software Engineering Symposium -.as [O " on Practical Software Development Environments. -.ds [J SIGPLAN Notices -.ds [V 19 -.ds [N 5 -.ds [D May 1984 -.ds [P 104-112 -.nr [P 1 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 1 journal-article -.ds [F 1 -.ds [F 3 -.ds [F 6 -.]- -.ds [K SCCSEval -.ds [A Glasser, Alan L. -.ds [D Nov. 1978 -.ds [T The Evolution of a Source Code Control System -.ds [J Software Engineering Notes -.ds [V 3 -.ds [N 5 -.ds [P 122-125 -.nr [P 1 -.ds [O Proceedings of the Software Quality and Assurance Workshop. -.nr [T 0 -.nr [A 1 -.nr [O 1 -.][ 1 journal-article -.ds [F 5 -.ds [F 7 -.]- -.ds [K IBMClearCaster -.ds [A Brown, H.B. -.ds [D 1970 -.ds [T The Clear/Caster System -.ds [J Nato Conference on Software Engineering, Rome -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 1 journal-article -.ds [F 3 -.ds [F 8 -.]- -.ds [K HabermannSDC -.ds [A Habermann, A. Nico -.ds [D Jan. 1979 -.ds [T A Software Development Control System -.ds [I Technical Report, Carnegie-Mellon University, Department of Computer Science -.nr [T 0 -.nr [A 0 -.nr [O 0 -.][ 2 book -.ds [F 9 -.]- -.ds [K CMS -.ds [A DEC -.ds [T Code Management System -.ds [I Digital Equipment Corporation -.ds [O Document No.\ EA-23134-82 -.ds [D 1982 -.nr [T 0 -.nr [A 0 -.nr [O 0 -.][ 2 book -.ds [F 10 -.]- -.ds [K LAMP01 -.ds [A Lampson, Butler W. -.as [A " and Schmidt, Eric E. -.ds [T Practical Use of a Polymorphic Applicative Language -.ds [B Proceedings of the 10th Symposium on Principles of Programming Languages -.ds [I ACM -.ds [P 237-255 -.nr [P 1 -.ds [D January 1983 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 3 article-in-book -.ds [F 5 -.ds [F 11 -.]- -.ds [K TICH07 -.ds [T A Data Model for Programming Support Environments and its Application -.ds [A Tichy, Walter F. -.ds [B Automated Tools for Information System Design and Development -.ds [E Hans-Jochen Schneider and Anthony I. Wasserman -.ds [C Amsterdam -.ds [I North-Holland Publishing Company -.ds [D 1982 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 3 article-in-book -.ds [F 4 -.ds [F 2 -.ds [F 12 -.]- -.ds [K HECK01 -.ds [T A Technique for Isolating Differences Between Files -.ds [A Heckel, Paul -.ds [J Communications of the ACM -.ds [D April 1978 -.ds [V 21 -.ds [N 4 -.ds [P 264-268 -.nr [P 1 -.nr [T 0 -.nr [A 0 -.nr [O 0 -.][ 1 journal-article -.ds [F 13 -.]- -.ds [K TICH11 -.ds [T The String-to-String Correction Problem with Block Moves -.ds [A Tichy, Walter F. -.ds [D Nov. 1984 -.ds [J ACM Transactions on Computer Systems -.ds [V 2 -.ds [N 4 -.ds [P 309-321 -.nr [P 1 -.nr [T 0 -.nr [A 1 -.nr [O 0 -.][ 1 journal-article -.]> diff --git a/gnu/usr.bin/rcs/doc/rcs_func.ms b/gnu/usr.bin/rcs/doc/rcs_func.ms deleted file mode 100644 index 9818086c3de..00000000000 --- a/gnu/usr.bin/rcs/doc/rcs_func.ms +++ /dev/null @@ -1,95 +0,0 @@ -.SH -Functions of RCS (Revision Control System) -.PP -RCS manages software libraries. It greatly increases programmer productivity -by providing the following functions. -.IP 1. -RCS stores and retrieves multiple revisions of program and other text. -Thus, one can maintain one or more releases while developing the next -release, with a minimum of space overhead. Changes no longer destroy the -original -- previous revisions remain accessible. -.RS -.IP a. -Maintains each module as a tree of revisions. -.IP b. -Project libraries can -be organized centrally, decentralized, or any way you like. -.IP c. -RCS works for any type of text: programs, documentation, memos, papers, -graphics, VLSI layouts, form letters, etc. -.RE -.IP 2. -RCS maintains a complete history of changes. -Thus, one can find out what happened to a module easily -and quickly, without having to compare source listings or -having to track down colleagues. -.RS -.IP a. -RCS performs automatic record keeping. -.IP b. -RCS logs all changes automatically. -.IP c. -RCS guarantees project continuity. -.RE -.IP 3. -RCS manages multiple lines of development. -.IP 4. -RCS can merge multiple lines of development. -Thus, when several parallel lines of development must be consolidated -into one line, the merging of changes is automatic. -.IP 5. -RCS flags coding conflicts. -If two or more lines of development modify the same section of code, -RCS can alert programmers about overlapping changes. -.IP 6. -RCS resolves access conflicts. -When two or more programmers wish to modify the same revision, -RCS alerts the programmers and makes sure that one modification won't wipe -out the other one. -.IP 7. -RCS provides high-level retrieval functions. -Revisions can be retrieved according to ranges of revision numbers, -symbolic names, dates, authors, and states. -.IP 8. -RCS provides release and configuration control. -Revisions can be marked as released, stable, experimental, etc. -Configurations of modules can be described simply and directly. -.IP 9. -RCS performs automatic identification of modules with name, revision -number, creation time, author, etc. -Thus, it is always possible to determine which revisions of which -modules make up a given configuration. -.IP 10. -Provides high-level management visibility. -Thus, it is easy to track the status of a software project. -.RS -.IP a. -RCS provides a complete change history. -.IP b. -RCS records who did what when to which revision of which module. -.RE -.IP 11. -RCS is fully compatible with existing software development tools. -RCS is unobtrusive -- its interface to the file system is such that -all your existing software tools can be used as before. -.IP 12. -RCS' basic user interface is extremely simple. The novice need to learn -only two commands. Its more sophisticated features have been -tuned towards advanced software development environments and the -experienced software professional. -.IP 13. -RCS simplifies software distribution if customers -maintain sources with RCS also. This technique assures proper -identification of versions and configurations, and tracking of customer -modifications. Customer modifications can be merged into distributed -versions locally or by the development group. -.IP 14. -RCS needs little extra space for the revisions (only the differences). -If intermediate revisions are deleted, the corresponding -differences are compressed into the shortest possible form. -.IP 15. -RCS is implemented with reverse deltas. This means that -the latest revision, which is the one that is accessed most often, -is stored intact. All others are regenerated from the latest one -by applying reverse deltas (backward differences). This -results in fast access time for the revision needed most often. diff --git a/gnu/usr.bin/rcs/ident/Makefile b/gnu/usr.bin/rcs/ident/Makefile deleted file mode 100644 index f28f8d3c5b7..00000000000 --- a/gnu/usr.bin/rcs/ident/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROG= ident -SRCS= ident.c -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/ident/ident.1 b/gnu/usr.bin/rcs/ident/ident.1 deleted file mode 100644 index 5b1240dd65f..00000000000 --- a/gnu/usr.bin/rcs/ident/ident.1 +++ /dev/null @@ -1,182 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.ds iD \\$3 \\$4 \\$5 \\$6 \\$7 -.. -.Id $FreeBSD: src/gnu/usr.bin/rcs/ident/ident.1,v 1.5 1999/08/27 23:36:42 peter Exp $ -.ds r \&\s-1RCS\s0 -.ds u \&\s-1UTC\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH IDENT 1 \*(Dt GNU -.SH NAME -ident \- identify RCS keyword strings in files -.SH SYNOPSIS -.B ident -[ -.B \-q -] [ -.B \-V -] [ -.I file -\&.\|.\|. ] -.SH DESCRIPTION -.B ident -searches for all instances of the pattern -.BI $ keyword : "\ text\ " $ -in the named files or, if no files are named, the standard input. -.PP -These patterns are normally inserted automatically by the \*r command -.BR co (1), -but can also be inserted manually. -The option -.B \-q -suppresses -the warning given if there are no patterns in a file. -The option -.B \-V -prints -.BR ident 's -version number. -.PP -.B ident -works on text files as well as object files and dumps. -For example, if the C program in -.B f.c -contains -.IP -.ft 3 -#include -.br -static char const rcsid[] = -.br - \&"$\&Id: f.c,v \*(iD $\&"; -.br -int main() { return printf(\&"%s\en\&", rcsid) == EOF; } -.ft P -.LP -and -.B f.c -is compiled into -.BR f.o , -then the command -.IP -.B "ident f.c f.o" -.LP -will output -.nf -.IP -.ft 3 -f.c: - $\&Id: f.c,v \*(iD $ -f.o: - $\&Id: f.c,v \*(iD $ -.ft -.fi -.PP -If a C program defines a string like -.B rcsid -above but does not use it, -.BR lint (1) -may complain, and some C compilers will optimize away the string. -The most reliable solution is to have the program use the -.B rcsid -string, as shown in the example above. -.PP -.B ident -finds all instances of the -.BI $ keyword : "\ text\ " $ -pattern, even if -.I keyword -is not actually an \*r-supported keyword. -This gives you information about nonstandard keywords like -.BR $\&XConsortium$ . -.SH KEYWORDS -Here is the list of keywords currently maintained by -.BR co (1). -All times are given in Coordinated Universal Time (\*u, -sometimes called \&\s-1GMT\s0) by default, but if the files -were checked out with -.BR co 's -.BI \-z zone -option, times are given with a numeric time zone indication appended. -.TP -.B $\&Author$ -The login name of the user who checked in the revision. -.TP -.B $\&Date$ -The date and time the revision was checked in. -.TP -.B $\&Header$ -A standard header containing the full pathname of the \*r file, the -revision number, the date and time, the author, the state, -and the locker (if locked). -.TP -.B $\&Id$ -Same as -.BR $\&Header$ , -except that the \*r filename is without a path. -.TP -.B $\&Locker$ -The login name of the user who locked the revision (empty if not locked). -.TP -.B $\&Log$ -The log message supplied during checkin. -For -.BR ident 's -purposes, this is equivalent to -.BR $\&RCSfile$ . -.TP -.B $\&Name$ -The symbolic name used to check out the revision, if any. -.TP -.B $\&RCSfile$ -The name of the \*r file without a path. -.TP -.B $\&Revision$ -The revision number assigned to the revision. -.TP -.B $\&Source$ -The full pathname of the \*r file. -.TP -.B $\&State$ -The state assigned to the revision with the -.B \-s -option of -.BR rcs (1) -or -.BR ci (1). -.PP -.BR co (1) -represents the following characters in keyword values by escape sequences -to keep keyword strings well-formed. -.LP -.RS -.nf -.ne 6 -.ta \w'newline 'u -\f2char escape sequence\fP -tab \f3\et\fP -newline \f3\en\fP -space \f3\e040 -$ \e044 -\e \e\e\fP -.fi -.RE -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1992, 1993 Paul Eggert. -.SH "SEE ALSO" -ci(1), co(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1), -rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. diff --git a/gnu/usr.bin/rcs/ident/ident.c b/gnu/usr.bin/rcs/ident/ident.c deleted file mode 100644 index 1057abbb552..00000000000 --- a/gnu/usr.bin/rcs/ident/ident.c +++ /dev/null @@ -1,270 +0,0 @@ -/* Identify RCS keyword strings in files. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.9 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.8 1995/06/01 16:23:43 eggert - * (exiterr, reportError): New functions, needed for DOS and OS/2 ports. - * (scanfile): Use them. - * - * Revision 5.7 1994/03/20 04:52:58 eggert - * Remove `exiting' from identExit. - * - * Revision 5.6 1993/11/09 17:40:15 eggert - * Add -V. - * - * Revision 5.5 1993/11/03 17:42:27 eggert - * Test for char == EOF, not char < 0. - * - * Revision 5.4 1992/01/24 18:44:19 eggert - * lint -> RCS_lint - * - * Revision 5.3 1991/09/10 22:15:46 eggert - * Open files with FOPEN_R, not FOPEN_R_WORK, - * because they might be executables, not working files. - * - * Revision 5.2 1991/08/19 03:13:55 eggert - * Report read errors immediately. - * - * Revision 5.1 1991/02/25 07:12:37 eggert - * Don't report empty keywords. Check for I/O errors. - * - * Revision 5.0 1990/08/22 08:12:37 eggert - * Don't limit output to known keywords. - * Remove arbitrary limits and lint. Ansify and Posixate. - * - * Revision 4.5 89/05/01 15:11:54 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 87/10/23 17:09:57 narten - * added exit(0) so exit return code would be non random - * - * Revision 4.3 87/10/18 10:23:55 narten - * Updating version numbers. Changes relative to 1.1 are actually relative - * to 4.1 - * - * Revision 1.3 87/07/09 09:20:52 trinkle - * Added check to make sure there is at least one arg before comparing argv[1] - * with "-q". This necessary on machines that don't allow dereferncing null - * pointers (i.e. Suns). - * - * Revision 1.2 87/03/27 14:21:47 jenkins - * Port to suns - * - * Revision 4.1 83/05/10 16:31:02 wft - * Added option -q and input from reading stdin. - * Marker matching is now done with trymatch() (independent of keywords). - * - * Revision 3.4 83/02/18 17:37:49 wft - * removed printing of new line after last file. - * - * Revision 3.3 82/12/04 12:48:55 wft - * Added LOCKER. - * - * Revision 3.2 82/11/28 18:24:17 wft - * removed Suffix; added ungetc to avoid skipping over trailing KDELIM. - * - * Revision 3.1 82/10/13 15:58:51 wft - * fixed type of variables receiving from getc() (char-->int). -*/ - -#include "rcsbase.h" - -static int match P((FILE*)); -static int scanfile P((FILE*,char const*,int)); -static void reportError P((char const*)); - -mainProg(identId, "ident", "$FreeBSD: src/gnu/usr.bin/rcs/ident/ident.c,v 1.8 2001/12/10 20:44:31 peter Exp $") -/* Ident searches the named files for all occurrences - * of the pattern $@: text $ where @ is a keyword. - */ - -{ - FILE *fp; - int quiet = 0; - int status = EXIT_SUCCESS; - char const *a; - - while ((a = *++argv) && *a=='-') - while (*++a) - switch (*a) { - case 'q': - quiet = 1; - break; - - case 'V': - VOID printf("RCS version %s\n", RCS_version_string); - quiet = -1; - break; - - default: - VOID fprintf(stderr, - "ident: usage: ident -{qV} [file...]\n" - ); - exitmain(EXIT_FAILURE); - break; - } - - if (0 <= quiet) - if (!a) - VOID scanfile(stdin, (char*)0, quiet); - else - do { - if (!(fp = fopen(a, FOPEN_RB))) { - reportError(a); - status = EXIT_FAILURE; - } else if ( - scanfile(fp, a, quiet) != 0 - || (argv[1] && putchar('\n') == EOF) - ) - break; - } while ((a = *++argv)); - - if (ferror(stdout) || fclose(stdout)!=0) { - reportError("standard output"); - status = EXIT_FAILURE; - } - exitmain(status); -} - -#if RCS_lint -# define exiterr identExit -#endif - void -exiterr() -{ - _exit(EXIT_FAILURE); -} - - static void -reportError(s) - char const *s; -{ - int e = errno; - VOID fprintf(stderr, "%s error: ", cmdid); - errno = e; - perror(s); -} - - - static int -scanfile(file, name, quiet) - register FILE *file; - char const *name; - int quiet; -/* Function: scan an open file with descriptor file for keywords. - * Return -1 if there's a write error; exit immediately on a read error. - */ -{ - register int c; - - if (name) { - VOID printf("%s:\n", name); - if (ferror(stdout)) - return -1; - } else - name = "standard input"; - c = 0; - while (c != EOF || ! (feof(file)|ferror(file))) { - if (c == KDELIM) { - if ((c = match(file))) - continue; - if (ferror(stdout)) - return -1; - quiet = true; - } - c = getc(file); - } - if (ferror(file) || fclose(file) != 0) { - reportError(name); - /* - * The following is equivalent to exit(EXIT_FAILURE), but we invoke - * exiterr to keep lint happy. The DOS and OS/2 ports need exiterr. - */ - VOID fflush(stderr); - VOID fflush(stdout); - exiterr(); - } - if (!quiet) - VOID fprintf(stderr, "%s warning: no id keywords in %s\n", cmdid, name); - return 0; -} - - - - static int -match(fp) /* group substring between two KDELIM's; then do pattern match */ - register FILE *fp; -{ - char line[BUFSIZ]; - register int c; - register char * tp; - - tp = line; - while ((c = getc(fp)) != VDELIM) { - if (c == EOF && feof(fp) | ferror(fp)) - return c; - switch (ctab[c]) { - case LETTER: case Letter: case DIGIT: - *tp++ = c; - if (tp < line+sizeof(line)-4) - break; - /* fall into */ - default: - return c ? c : '\n'/* anything but 0 or KDELIM or EOF */; - } - } - if (tp == line) - return c; - *tp++ = c; - if ((c = getc(fp)) != ' ') - return c ? c : '\n'; - *tp++ = c; - while( (c = getc(fp)) != KDELIM ) { - if (c == EOF && feof(fp) | ferror(fp)) - return c; - switch (ctab[c]) { - default: - *tp++ = c; - if (tp < line+sizeof(line)-2) - break; - /* fall into */ - case NEWLN: case UNKN: - return c ? c : '\n'; - } - } - if (tp[-1] != ' ') - return c; - *tp++ = c; /*append trailing KDELIM*/ - *tp = '\0'; - VOID printf(" %c%s\n", KDELIM, line); - return 0; -} diff --git a/gnu/usr.bin/rcs/lib/Makefile b/gnu/usr.bin/rcs/lib/Makefile deleted file mode 100644 index 3915bbdfbf5..00000000000 --- a/gnu/usr.bin/rcs/lib/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/lib/Makefile 136910 2004-10-24 15:33:08Z ru $ - -# Define FSYNC_ALL to get slower but safer writes in case of crashes in -# the middle of CVS/RCS changes -#CFLAGS += -DFSYNC_ALL - -LIB = rcs -SRCS = maketime.c partime.c rcsedit.c rcsfcmp.c rcsfnms.c rcsgen.c \ - rcskeep.c rcskeys.c rcslex.c rcsmap.c rcsrev.c rcssyn.c rcstime.c \ - rcsutil.c merger.c version.c - -INTERNALLIB= - -.include diff --git a/gnu/usr.bin/rcs/lib/Makefile.depend b/gnu/usr.bin/rcs/lib/Makefile.depend deleted file mode 100644 index 224027b0153..00000000000 --- a/gnu/usr.bin/rcs/lib/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/lib/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/lib/conf.h b/gnu/usr.bin/rcs/lib/conf.h deleted file mode 100644 index d6c58946071..00000000000 --- a/gnu/usr.bin/rcs/lib/conf.h +++ /dev/null @@ -1,400 +0,0 @@ -/* RCS compile-time configuration */ - - /* $FreeBSD: stable/11/gnu/usr.bin/rcs/lib/conf.h 121536 2003-10-26 04:26:52Z peter $ */ - -/* - * This file is generated automatically. - * If you edit it by hand your changes may be lost. - * Instead, please try to fix conf.sh, - * and send your fixes to rcs-bugs@cs.purdue.edu. - */ - -#define exitmain(n) return n /* how to exit from main() */ -/* #define _POSIX_C_SOURCE 2147483647L */ /* if strict C + Posix 1003.1b-1993 or later */ -/* #define _POSIX_SOURCE */ /* if strict C + Posix 1003.1-1990 */ - -#include -#include -#include - -/* Comment out #include lines below that do not work. */ -#include -#include -#include -#include -#include -/* #include */ -/* #include */ -#include -/* #include */ -#include -#include -#include -#include -#include -/* #include */ -#include -#include -/* #include */ - -/* Define boolean symbols to be 0 (false, the default), or 1 (true). */ -#define has_sys_param_h 1 /* Does #include work? */ -/* extern int errno; */ /* Uncomment if doesn't declare errno. */ -#define has_readlink 1 /* Does readlink() work? */ -#define readlink_isreg_errno EINVAL /* errno after readlink on regular file */ - -#if has_readlink && !defined(MAXSYMLINKS) -# if has_sys_param_h -# include -# endif -# ifndef MAXSYMLINKS -# define MAXSYMLINKS 20 /* BSD; not standard yet */ -# endif -#endif - -/* Comment out the typedefs below if the types are already declared. */ -/* Fix any uncommented typedefs that are wrong. */ -/* typedef int mode_t; */ -/* typedef long off_t; */ -/* typedef int pid_t; */ -/* typedef int sig_atomic_t; */ -/* typedef unsigned size_t; */ -/* typedef int ssize_t; */ -/* typedef long time_t; */ -/* typedef int uid_t; */ - -/* Comment out the keyword definitions below if the keywords work. */ -/* #define const */ -/* #define volatile */ - -/* Define boolean symbols to be 0 (false, the default), or 1 (true). */ -#define has_prototypes 1 /* Do function prototypes work? */ -#define has_stdarg 1 /* Does work? */ -/* #define has_varargs ? */ /* Does work? */ -#define va_start_args 2 /* How many args does va_start() take? */ - -#if O_BINARY - /* Text and binary i/o behave differently. */ - /* This is incompatible with Posix and Unix. */ -# define FOPEN_RB "rb" -# define FOPEN_R_WORK (Expand==BINARY_EXPAND ? "r" : "rb") -# define FOPEN_WB "wb" -# define FOPEN_W_WORK (Expand==BINARY_EXPAND ? "w" : "wb") -# define FOPEN_WPLUS_WORK (Expand==BINARY_EXPAND ? "w+" : "w+b") -# define OPEN_O_BINARY O_BINARY -#else - /* - * Text and binary i/o behave the same. - * Omit "b", since some nonstandard hosts reject it. - */ -# define FOPEN_RB "r" -# define FOPEN_R_WORK "r" -# define FOPEN_WB "w" -# define FOPEN_W_WORK "w" -# define FOPEN_WPLUS_WORK "w+" -# define OPEN_O_BINARY 0 -#endif - -/* This may need changing on non-Unix systems (notably DOS). */ -#define OPEN_CREAT_READONLY (S_IRUSR|S_IRGRP|S_IROTH) /* lock file mode */ -#define OPEN_O_LOCK 0 /* extra open flags for creating lock file */ -#define OPEN_O_WRONLY O_WRONLY /* main open flag for creating a lock file */ - -/* Define or comment out the following symbols as needed. */ -#if has_prototypes -# define P(params) params -#else -# define P(params) () -#endif -#if has_stdarg -# include -#else -# if has_varargs -# include -# else - typedef char *va_list; -# define va_dcl int va_alist; -# define va_start(ap) ((ap) = (va_list)&va_alist) -# define va_arg(ap,t) (((t*) ((ap)+=sizeof(t))) [-1]) -# define va_end(ap) -# endif -#endif -#if va_start_args == 2 -# define vararg_start va_start -#else -# define vararg_start(ap,p) va_start(ap) -#endif -#define bad_chmod_close 0 /* Can chmod() close file descriptors? */ -#define bad_creat0 0 /* Do writes fail after creat(f,0)? */ -#define bad_fopen_wplus 0 /* Does fopen(f,"w+") fail to truncate f? */ -#define getlogin_is_secure 0 /* Is getlogin() secure? Usually it's not. */ -#define has_attribute_noreturn 1 /* Does __attribute__((noreturn)) work? */ -#if has_attribute_noreturn -# define exiting __attribute__((noreturn)) -#else -# define exiting -#endif -#define has_dirent 1 /* Do opendir(), readdir(), closedir() work? */ -#define void_closedir 0 /* Does closedir() yield void? */ -#define has_fchmod 1 /* Does fchmod() work? */ -#define has_fflush_input 0 /* Does fflush() work on input files? */ -#define has_fputs 1 /* Does fputs() work? */ -#define has_ftruncate 1 /* Does ftruncate() work? */ -#define has_getuid 1 /* Does getuid() work? */ -#define has_getpwuid 1 /* Does getpwuid() work? */ -#define has_memcmp 1 /* Does memcmp() work? */ -#define has_memcpy 1 /* Does memcpy() work? */ -#define has_memmove 1 /* Does memmove() work? */ -#define has_map_fd 0 /* Does map_fd() work? */ -#define has_mmap 1 /* Does mmap() work on regular files? */ -#define has_madvise 0 /* Does madvise() work? */ -#define mmap_signal SIGBUS /* signal received if you reference nonexistent part of mmapped file */ -#define has_rename 1 /* Does rename() work? */ -#define bad_a_rename 0 /* Does rename(A,B) fail if A is unwritable? */ -#define bad_b_rename 0 /* Does rename(A,B) fail if B is unwritable? */ -#define bad_NFS_rename 0 /* Can rename(A,B) falsely report success? */ -/* typedef int void; */ /* Some ancient compilers need this. */ -#define VOID (void) /* 'VOID e;' discards the value of an expression 'e'. */ -#define has_seteuid 1 /* Does seteuid() work? See ../INSTALL.RCS. */ -#define has_setreuid 0 /* Does setreuid() work? See ../INSTALL.RCS. */ -#define has_setuid 1 /* Does setuid() exist? */ -#define has_sigaction 1 /* Does struct sigaction work? */ -#define has_sa_sigaction 1 /* Does struct sigaction have sa_sigaction? */ -#define has_signal 1 /* Does signal() work? */ -#define signal_type void /* type returned by signal handlers */ -#define sig_zaps_handler 0 /* Must a signal handler reinvoke signal()? */ -/* #define has_sigblock ? */ /* Does sigblock() work? */ -/* #define sigmask(s) (1 << ((s)-1)) */ /* Yield mask for signal number. */ -typedef size_t fread_type; /* type returned by fread() and fwrite() */ -typedef size_t freadarg_type; /* type of their size arguments */ -typedef void *malloc_type; /* type returned by malloc() */ -#define has_getcwd 1 /* Does getcwd() work? */ -/* #define has_getwd ? */ /* Does getwd() work? */ -#define needs_getabsname 0 /* Must we define getabsname? */ -#define has_mktemp 1 /* Does mktemp() work? */ -#define has_mkstemp 1 /* Does mkstemp() work? */ -#define has_NFS 1 /* Might NFS be used? */ -#define has_psiginfo 0 /* Does psiginfo() work? */ -#define has_psignal 1 /* Does psignal() work? */ -/* #define has_si_errno ? */ /* Does siginfo_t have si_errno? */ -/* #define has_sys_siglist ? */ /* Does sys_siglist[] work? */ -/* #define strchr index */ /* Use old-fashioned name for strchr()? */ -/* #define strrchr rindex */ /* Use old-fashioned name for strrchr()? */ -#define bad_unlink 0 /* Does unlink() fail on unwritable files? */ -#define has_vfork 1 /* Does vfork() work? */ -#define has_fork 1 /* Does fork() work? */ -#define has_spawn 0 /* Does spawn*() work? */ -#define has_waitpid 1 /* Does waitpid() work? */ -#define bad_wait_if_SIGCHLD_ignored 0 /* Does ignoring SIGCHLD break wait()? */ -#define RCS_SHELL "/bin/sh" /* shell to run RCS subprograms */ -#define has_printf_dot 1 /* Does "%.2d" print leading 0? */ -#define has_vfprintf 1 /* Does vfprintf() work? */ -#define has_attribute_format_printf 1 /* Does __attribute__((format(printf,N,N+1))) work? */ -#if has_attribute_format_printf -# define printf_string(m, n) __attribute__((format(printf, m, n))) -#else -# define printf_string(m, n) -#endif -#if has_attribute_format_printf && has_attribute_noreturn - /* Work around a bug in GCC 2.5.x. */ -# define printf_string_exiting(m, n) __attribute__((format(printf, m, n), noreturn)) -#else -# define printf_string_exiting(m, n) printf_string(m, n) exiting -#endif -/* #define has__doprintf ? */ /* Does _doprintf() work? */ -/* #define has__doprnt ? */ /* Does _doprnt() work? */ -/* #undef EXIT_FAILURE */ /* Uncomment this if EXIT_FAILURE is broken. */ -#define large_memory 1 /* Can main memory hold entire RCS files? */ -#ifndef LONG_MAX -#define LONG_MAX 2147483647L /* long maximum */ -#endif -/* Do struct stat s and t describe the same file? Answer d if unknown. */ -#define same_file(s,t,d) ((s).st_ino==(t).st_ino && (s).st_dev==(t).st_dev) -#define has_utimbuf 1 /* Does struct utimbuf work? */ -#define CO "/usr/bin/co" /* name of 'co' program */ -#define COMPAT2 0 /* Are version 2 files supported? */ -#define DIFF "/usr/bin/diff" /* name of 'diff' program */ -#define DIFF3 "/usr/bin/diff3" /* name of 'diff3' program */ -#define DIFF3_BIN 1 /* Is diff3 user-visible (not the /usr/lib auxiliary)? */ -#define DIFFFLAGS "-an" /* Make diff output suitable for RCS. */ -#define DIFF_L 1 /* Does diff -L work? */ -#define DIFF_SUCCESS 0 /* DIFF status if no differences are found */ -#define DIFF_FAILURE 1 /* DIFF status if differences are found */ -#define DIFF_TROUBLE 2 /* DIFF status if trouble */ -#define ED "/bin/ed" /* name of 'ed' program (used only if !DIFF3_BIN) */ -#define MERGE "/usr/bin/merge" /* name of 'merge' program */ -#define TMPDIR "/tmp" /* default directory for temporary files */ -#define SLASH '/' /* principal filename separator */ -#define SLASHes '/' /* `case SLASHes:' labels all filename separators */ -#define isSLASH(c) ((c) == SLASH) /* Is arg a filename separator? */ -#define ROOTPATH(p) isSLASH((p)[0]) /* Is p an absolute pathname? */ -#define X_DEFAULT ",v/" /* default value for -x option */ -#define SLASHSLASH_is_SLASH 1 /* Are // and / the same directory? */ -#define ALL_ABSOLUTE 1 /* Do all subprograms satisfy ROOTPATH? */ -#define DIFF_ABSOLUTE 1 /* Is ROOTPATH(DIFF) true? */ -#define SENDMAIL "/usr/sbin/sendmail" /* how to send mail */ -#define TZ_must_be_set 0 /* Must TZ be set for gmtime() to work? */ - - - -/* Adjust the following declarations as needed. */ - - -/* The rest is for the benefit of non-standard, traditional hosts. */ -/* Don't bother to declare functions that in traditional hosts do not appear, */ -/* or are declared in .h files, or return int or void. */ - - -/* traditional BSD */ - -#if has_sys_siglist && !defined(sys_siglist) - extern char const * const sys_siglist[]; -#endif - - -/* Posix (ISO/IEC 9945-1: 1990 / IEEE Std 1003.1-1990) */ - -/* */ -#ifdef O_CREAT -# define open_can_creat 1 -#else -# define open_can_creat 0 -# define O_RDONLY 0 -# define O_WRONLY 1 -# define O_RDWR 2 -# define O_CREAT 01000 -# define O_TRUNC 02000 -#endif -#ifndef O_EXCL -#define O_EXCL 0 -#endif - -/* */ -#ifndef S_IRUSR -# ifdef S_IREAD -# define S_IRUSR S_IREAD -# else -# define S_IRUSR 0400 -# endif -# ifdef S_IWRITE -# define S_IWUSR S_IWRITE -# else -# define S_IWUSR (S_IRUSR/2) -# endif -#endif -#ifndef S_IRGRP -# if has_getuid -# define S_IRGRP (S_IRUSR / 0010) -# define S_IWGRP (S_IWUSR / 0010) -# define S_IROTH (S_IRUSR / 0100) -# define S_IWOTH (S_IWUSR / 0100) -# else - /* single user OS -- not Posix or Unix */ -# define S_IRGRP 0 -# define S_IWGRP 0 -# define S_IROTH 0 -# define S_IWOTH 0 -# endif -#endif -#ifndef S_ISREG -#define S_ISREG(n) (((n) & S_IFMT) == S_IFREG) -#endif - -/* */ -#ifndef WEXITSTATUS -#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix. */ -#endif -#ifndef WIFEXITED -#define WIFEXITED(stat_val) (((stat_val) & 0377) == 0) -#endif -#ifndef WTERMSIG -#define WTERMSIG(stat_val) ((stat_val) & 0177) -#undef WIFSIGNALED /* Avoid 4.3BSD incompatibility with Posix. */ -#endif -#ifndef WIFSIGNALED -#define WIFSIGNALED(stat_val) ((unsigned)(stat_val) - 1 < 0377) -#endif - -/* */ -char *getlogin P((void)); -#ifndef STDIN_FILENO -# define STDIN_FILENO 0 -# define STDOUT_FILENO 1 -# define STDERR_FILENO 2 -#endif -#if has_fork && !has_vfork -# undef vfork -# define vfork fork -#endif -#if has_getcwd || !has_getwd - char *getcwd P((char*,size_t)); -#else - char *getwd P((char*)); -#endif -#if has_setuid && !has_seteuid -# undef seteuid -# define seteuid setuid -#endif -#if has_spawn -# if ALL_ABSOLUTE -# define spawn_RCS spawnv -# else -# define spawn_RCS spawnvp -# endif -#else -# if ALL_ABSOLUTE -# define exec_RCS execv -# else -# define exec_RCS execvp -# endif -#endif - -/* utime.h */ -#if !has_utimbuf - struct utimbuf { time_t actime, modtime; }; -#endif - - -/* Standard C library */ - -/* */ -#ifndef L_tmpnam -#define L_tmpnam 32 /* power of 2 > sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */ -#endif -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif -#if has_mktemp - char *mktemp P((char*)); /* traditional */ -#else - char *tmpnam P((char*)); -#endif - -/* */ -char *getenv P((char const*)); -void _exit P((int)) exiting; -void exit P((int)) exiting; -malloc_type malloc P((size_t)); -malloc_type realloc P((malloc_type,size_t)); -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif - -/* */ -char *strcpy P((char*,char const*)); -char *strchr P((char const*,int)); -char *strrchr P((char const*,int)); -void *memcpy P((void*,void const*,size_t)); -#if has_memmove - void *memmove P((void*,void const*,size_t)); -#endif - -/* */ -time_t time P((time_t*)); diff --git a/gnu/usr.bin/rcs/lib/maketime.c b/gnu/usr.bin/rcs/lib/maketime.c deleted file mode 100644 index 4c2bf69d95e..00000000000 --- a/gnu/usr.bin/rcs/lib/maketime.c +++ /dev/null @@ -1,344 +0,0 @@ -/* Convert struct partime into time_t. */ - -/* Copyright 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#if has_conf_h -# include "conf.h" -#else -# ifdef __STDC__ -# define P(x) x -# else -# define const -# define P(x) () -# endif -# include -# include -#endif - -#include "partime.h" -#include "maketime.h" - -char const maketId[] - = "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/maketime.c 50472 1999-08-27 23:37:10Z peter $"; - -static int isleap P((int)); -static int month_days P((struct tm const*)); -static time_t maketime P((struct partime const*,time_t)); - -/* -* For maximum portability, use only localtime and gmtime. -* Make no assumptions about the time_t epoch or the range of time_t values. -* Avoid mktime because it's not universal and because there's no easy, -* portable way for mktime to yield the inverse of gmtime. -*/ - -#define TM_YEAR_ORIGIN 1900 - - static int -isleap(y) - int y; -{ - return (y&3) == 0 && (y%100 != 0 || y%400 == 0); -} - -static int const month_yday[] = { - /* days in year before start of months 0-12 */ - 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 -}; - -/* Yield the number of days in TM's month. */ - static int -month_days(tm) - struct tm const *tm; -{ - int m = tm->tm_mon; - return month_yday[m+1] - month_yday[m] - + (m==1 && isleap(tm->tm_year + TM_YEAR_ORIGIN)); -} - -/* -* Convert UNIXTIME to struct tm form. -* Use gmtime if available and if !LOCALZONE, localtime otherwise. -*/ - struct tm * -time2tm(unixtime, localzone) - time_t unixtime; - int localzone; -{ - struct tm *tm; -# if TZ_must_be_set - static char const *TZ; - if (!TZ && !(TZ = getenv("TZ"))) - faterror("The TZ environment variable is not set; please set it to your timezone"); -# endif - if (localzone || !(tm = gmtime(&unixtime))) - tm = localtime(&unixtime); - return tm; -} - -/* Yield A - B, measured in seconds. */ - time_t -difftm(a, b) - struct tm const *a, *b; -{ - int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); - int by = b->tm_year + (TM_YEAR_ORIGIN - 1); - int difference_in_day_of_year = a->tm_yday - b->tm_yday; - int intervening_leap_days = ( - ((ay >> 2) - (by >> 2)) - - (ay/100 - by/100) - + ((ay/100 >> 2) - (by/100 >> 2)) - ); - time_t difference_in_years = ay - by; - time_t difference_in_days = ( - difference_in_years*365 - + (intervening_leap_days + difference_in_day_of_year) - ); - return - ( - ( - 24*difference_in_days - + (a->tm_hour - b->tm_hour) - )*60 + (a->tm_min - b->tm_min) - )*60 + (a->tm_sec - b->tm_sec); -} - -/* -* Adjust time T by adding SECONDS. SECONDS must be at most 24 hours' worth. -* Adjust only T's year, mon, mday, hour, min and sec members; -* plus adjust wday if it is defined. -*/ - void -adjzone(t, seconds) - register struct tm *t; - long seconds; -{ - /* - * This code can be off by a second if SECONDS is not a multiple of 60, - * if T is local time, and if a leap second happens during this minute. - * But this bug has never occurred, and most likely will not ever occur. - * Liberia, the last country for which SECONDS % 60 was nonzero, - * switched to UTC in May 1972; the first leap second was in June 1972. - */ - int leap_second = t->tm_sec == 60; - long sec = seconds + (t->tm_sec - leap_second); - if (sec < 0) { - if ((t->tm_min -= (59-sec)/60) < 0) { - if ((t->tm_hour -= (59-t->tm_min)/60) < 0) { - t->tm_hour += 24; - if (TM_DEFINED(t->tm_wday) && --t->tm_wday < 0) - t->tm_wday = 6; - if (--t->tm_mday <= 0) { - if (--t->tm_mon < 0) { - --t->tm_year; - t->tm_mon = 11; - } - t->tm_mday = month_days(t); - } - } - t->tm_min += 24 * 60; - } - sec += 24L * 60 * 60; - } else - if (60 <= (t->tm_min += sec/60)) - if (24 <= (t->tm_hour += t->tm_min/60)) { - t->tm_hour -= 24; - if (TM_DEFINED(t->tm_wday) && ++t->tm_wday == 7) - t->tm_wday = 0; - if (month_days(t) < ++t->tm_mday) { - if (11 < ++t->tm_mon) { - ++t->tm_year; - t->tm_mon = 0; - } - t->tm_mday = 1; - } - } - t->tm_min %= 60; - t->tm_sec = (int) (sec%60) + leap_second; -} - -/* -* Convert TM to time_t, using localtime if LOCALZONE and gmtime otherwise. -* Use only TM's year, mon, mday, hour, min, and sec members. -* Ignore TM's old tm_yday and tm_wday, but fill in their correct values. -* Yield -1 on failure (e.g. a member out of range). -* Posix 1003.1-1990 doesn't allow leap seconds, but some implementations -* have them anyway, so allow them if localtime/gmtime does. -*/ - time_t -tm2time(tm, localzone) - struct tm *tm; - int localzone; -{ - /* Cache the most recent t,tm pairs; 1 for gmtime, 1 for localtime. */ - static time_t t_cache[2]; - static struct tm tm_cache[2]; - - time_t d, gt; - struct tm const *gtm; - /* - * The maximum number of iterations should be enough to handle any - * combinations of leap seconds, time zone rule changes, and solar time. - * 4 is probably enough; we use a bigger number just to be safe. - */ - int remaining_tries = 8; - - /* Avoid subscript errors. */ - if (12 <= (unsigned)tm->tm_mon) - return -1; - - tm->tm_yday = month_yday[tm->tm_mon] + tm->tm_mday - - (tm->tm_mon<2 || ! isleap(tm->tm_year + TM_YEAR_ORIGIN)); - - /* Make a first guess. */ - gt = t_cache[localzone]; - gtm = gt ? &tm_cache[localzone] : time2tm(gt,localzone); - - /* Repeatedly use the error from the guess to improve the guess. */ - while ((d = difftm(tm, gtm)) != 0) { - if (--remaining_tries == 0) - return -1; - gt += d; - gtm = time2tm(gt,localzone); - } - t_cache[localzone] = gt; - tm_cache[localzone] = *gtm; - - /* - * Check that the guess actually matches; - * overflow can cause difftm to yield 0 even on differing times, - * or tm may have members out of range (e.g. bad leap seconds). - */ - if ( (tm->tm_year ^ gtm->tm_year) - | (tm->tm_mon ^ gtm->tm_mon) - | (tm->tm_mday ^ gtm->tm_mday) - | (tm->tm_hour ^ gtm->tm_hour) - | (tm->tm_min ^ gtm->tm_min) - | (tm->tm_sec ^ gtm->tm_sec)) - return -1; - - tm->tm_wday = gtm->tm_wday; - return gt; -} - -/* -* Check *PT and convert it to time_t. -* If it is incompletely specified, use DEFAULT_TIME to fill it out. -* Use localtime if PT->zone is the special value TM_LOCAL_ZONE. -* Yield -1 on failure. -* ISO 8601 day-of-year and week numbers are not yet supported. -*/ - static time_t -maketime(pt, default_time) - struct partime const *pt; - time_t default_time; -{ - int localzone, wday; - struct tm tm; - struct tm *tm0 = 0; - time_t r; - - tm0 = 0; /* Keep gcc -Wall happy. */ - localzone = pt->zone==TM_LOCAL_ZONE; - - tm = pt->tm; - - if (TM_DEFINED(pt->ymodulus) || !TM_DEFINED(tm.tm_year)) { - /* Get tm corresponding to current time. */ - tm0 = time2tm(default_time, localzone); - if (!localzone) - adjzone(tm0, pt->zone); - } - - if (TM_DEFINED(pt->ymodulus)) - tm.tm_year += - (tm0->tm_year + TM_YEAR_ORIGIN)/pt->ymodulus * pt->ymodulus; - else if (!TM_DEFINED(tm.tm_year)) { - /* Set default year, month, day from current time. */ - tm.tm_year = tm0->tm_year + TM_YEAR_ORIGIN; - if (!TM_DEFINED(tm.tm_mon)) { - tm.tm_mon = tm0->tm_mon; - if (!TM_DEFINED(tm.tm_mday)) - tm.tm_mday = tm0->tm_mday; - } - } - - /* Convert from partime year (Gregorian) to Posix year. */ - tm.tm_year -= TM_YEAR_ORIGIN; - - /* Set remaining default fields to be their minimum values. */ - if (!TM_DEFINED(tm.tm_mon)) tm.tm_mon = 0; - if (!TM_DEFINED(tm.tm_mday)) tm.tm_mday = 1; - if (!TM_DEFINED(tm.tm_hour)) tm.tm_hour = 0; - if (!TM_DEFINED(tm.tm_min)) tm.tm_min = 0; - if (!TM_DEFINED(tm.tm_sec)) tm.tm_sec = 0; - - if (!localzone) - adjzone(&tm, -pt->zone); - wday = tm.tm_wday; - - /* Convert and fill in the rest of the tm. */ - r = tm2time(&tm, localzone); - - /* Check weekday. */ - if (r != -1 && TM_DEFINED(wday) && wday != tm.tm_wday) - return -1; - - return r; -} - -/* Parse a free-format date in SOURCE, yielding a Unix format time. */ - time_t -str2time(source, default_time, default_zone) - char const *source; - time_t default_time; - long default_zone; -{ - struct partime pt; - - if (*partime(source, &pt)) - return -1; - if (pt.zone == TM_UNDEFINED_ZONE) - pt.zone = default_zone; - return maketime(&pt, default_time); -} - -#if TEST -#include - int -main(argc, argv) int argc; char **argv; -{ - time_t default_time = time((time_t *)0); - long default_zone = argv[1] ? atol(argv[1]) : 0; - char buf[1000]; - while (fgets(buf, 1000, stdin)) { - time_t t = str2time(buf, default_time, default_zone); - printf("%s", asctime(gmtime(&t))); - } - return 0; -} -#endif diff --git a/gnu/usr.bin/rcs/lib/maketime.h b/gnu/usr.bin/rcs/lib/maketime.h deleted file mode 100644 index fbe12562051..00000000000 --- a/gnu/usr.bin/rcs/lib/maketime.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Yield time_t from struct partime yielded by partime. */ - -/* Copyright 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#if defined(__STDC__) || has_prototypes -# define __MAKETIME_P(x) x -#else -# define __MAKETIME_P(x) () -#endif - -struct tm *time2tm __MAKETIME_P((time_t,int)); -time_t difftm __MAKETIME_P((struct tm const *, struct tm const *)); -time_t str2time __MAKETIME_P((char const *, time_t, long)); -time_t tm2time __MAKETIME_P((struct tm *, int)); -void adjzone __MAKETIME_P((struct tm *, long)); diff --git a/gnu/usr.bin/rcs/lib/merger.c b/gnu/usr.bin/rcs/lib/merger.c deleted file mode 100644 index f7e4c8c6c76..00000000000 --- a/gnu/usr.bin/rcs/lib/merger.c +++ /dev/null @@ -1,148 +0,0 @@ -/* three-way file merge internals */ - -/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#include "rcsbase.h" - -libId(mergerId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/merger.c 50472 1999-08-27 23:37:10Z peter $") - - static char const *normalize_arg P((char const*,char**)); - static char const * -normalize_arg(s, b) - char const *s; - char **b; -/* - * If S looks like an option, prepend ./ to it. Yield the result. - * Set *B to the address of any storage that was allocated. - */ -{ - char *t; - if (*s == '-') { - *b = t = testalloc(strlen(s) + 3); - VOID sprintf(t, ".%c%s", SLASH, s); - return t; - } else { - *b = 0; - return s; - } -} - - int -merge(tostdout, edarg, label, argv) - int tostdout; - char const *edarg; - char const *const label[3]; - char const *const argv[3]; -/* - * Do `merge [-p] EDARG -L l0 -L l1 -L l2 a0 a1 a2', - * where TOSTDOUT specifies whether -p is present, - * EDARG gives the editing type (e.g. "-A", or null for the default), - * LABEL gives l0, l1 and l2, and ARGV gives a0, a1 and a2. - * Yield DIFF_SUCCESS or DIFF_FAILURE. - */ -{ - register int i; - FILE *f; - RILE *rt; - char const *a[3], *t; - char *b[3]; - int s; -#if !DIFF3_BIN - char const *d[2]; -#endif - - for (i=3; 0<=--i; ) - a[i] = normalize_arg(argv[i], &b[i]); - - if (!edarg) - edarg = "-E"; - -#if DIFF3_BIN - t = 0; - if (!tostdout) - t = maketemp(0); - s = run( - -1, t, - DIFF3, edarg, "-am", - "-L", label[0], - "-L", label[1], - "-L", label[2], - a[0], a[1], a[2], (char*)0 - ); - switch (s) { - case DIFF_SUCCESS: - break; - case DIFF_FAILURE: - warn("conflicts during merge"); - break; - default: - exiterr(); - } - if (t) { - if (!(f = fopenSafer(argv[0], "w"))) - efaterror(argv[0]); - if (!(rt = Iopen(t, "r", (struct stat*)0))) - efaterror(t); - fastcopy(rt, f); - Ifclose(rt); - Ofclose(f); - } -#else - for (i=0; i<2; i++) - switch (run( - -1, d[i]=maketemp(i), - DIFF, a[i], a[2], (char*)0 - )) { - case DIFF_FAILURE: case DIFF_SUCCESS: break; - default: faterror("diff failed"); - } - t = maketemp(2); - s = run( - -1, t, - DIFF3, edarg, d[0], d[1], a[0], a[1], a[2], - label[0], label[2], (char*)0 - ); - if (s != DIFF_SUCCESS) { - s = DIFF_FAILURE; - warn("overlaps or other problems during merge"); - } - if (!(f = fopenSafer(t, "a+"))) - efaterror(t); - aputs(tostdout ? "1,$p\n" : "w\n", f); - Orewind(f); - aflush(f); - if (run(fileno(f), (char*)0, ED, "-", a[0], (char*)0)) - exiterr(); - Ofclose(f); -#endif - - tempunlink(); - for (i=3; 0<=--i; ) - if (b[i]) - tfree(b[i]); - return s; -} diff --git a/gnu/usr.bin/rcs/lib/partime.c b/gnu/usr.bin/rcs/lib/partime.c deleted file mode 100644 index 6a587e0efc1..00000000000 --- a/gnu/usr.bin/rcs/lib/partime.c +++ /dev/null @@ -1,701 +0,0 @@ -/* Parse a string, yielding a struct partime that describes it. */ - -/* Copyright 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#if has_conf_h -# include "conf.h" -#else -# ifdef __STDC__ -# define P(x) x -# else -# define const -# define P(x) () -# endif -# include -# include -#endif - -#include -#undef isdigit -#define isdigit(c) (((unsigned)(c)-'0') <= 9) /* faster than stock */ - -#include "partime.h" - -char const partimeId[] - = "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/partime.c 50472 1999-08-27 23:37:10Z peter $"; - - -/* Lookup tables for names of months, weekdays, time zones. */ - -#define NAME_LENGTH_MAXIMUM 4 - -struct name_val { - char name[NAME_LENGTH_MAXIMUM]; - int val; -}; - - -static char const *parse_decimal P((char const*,int,int,int,int,int*,int*)); -static char const *parse_fixed P((char const*,int,int*)); -static char const *parse_pattern_letter P((char const*,int,struct partime*)); -static char const *parse_prefix P((char const*,struct partime*,int*)); -static char const *parse_ranged P((char const*,int,int,int,int*)); -static int lookup P((char const*,struct name_val const[])); -static int merge_partime P((struct partime*, struct partime const*)); -static void undefine P((struct partime*)); - - -static struct name_val const month_names[] = { - {"jan",0}, {"feb",1}, {"mar",2}, {"apr",3}, {"may",4}, {"jun",5}, - {"jul",6}, {"aug",7}, {"sep",8}, {"oct",9}, {"nov",10}, {"dec",11}, - {"", TM_UNDEFINED} -}; - -static struct name_val const weekday_names[] = { - {"sun",0}, {"mon",1}, {"tue",2}, {"wed",3}, {"thu",4}, {"fri",5}, {"sat",6}, - {"", TM_UNDEFINED} -}; - -#define hr60nonnegative(t) ((t)/100 * 60 + (t)%100) -#define hr60(t) ((t)<0 ? -hr60nonnegative(-(t)) : hr60nonnegative(t)) -#define zs(t,s) {s, hr60(t)} -#define zd(t,s,d) zs(t, s), zs((t)+100, d) - -static struct name_val const zone_names[] = { - zs(-1000, "hst"), /* Hawaii */ - zd(-1000,"hast","hadt"),/* Hawaii-Aleutian */ - zd(- 900,"akst","akdt"),/* Alaska */ - zd(- 800, "pst", "pdt"),/* Pacific */ - zd(- 700, "mst", "mdt"),/* Mountain */ - zd(- 600, "cst", "cdt"),/* Central */ - zd(- 500, "est", "edt"),/* Eastern */ - zd(- 400, "ast", "adt"),/* Atlantic */ - zd(- 330, "nst", "ndt"),/* Newfoundland */ - zs( 000, "utc"), /* Coordinated Universal */ - zs( 000, "cut"), /* " */ - zs( 000, "ut"), /* Universal */ - zs( 000, "z"), /* Zulu (required by ISO 8601) */ - zd( 000, "gmt", "bst"),/* Greenwich Mean, British Summer */ - zs( 000, "wet"), /* Western Europe */ - zs( 100, "met"), /* Middle Europe */ - zs( 100, "cet"), /* Central Europe */ - zs( 200, "eet"), /* Eastern Europe */ - zs( 530, "ist"), /* India */ - zd( 900, "jst", "jdt"),/* Japan */ - zd( 900, "kst", "kdt"),/* Korea */ - zd( 1200,"nzst","nzdt"),/* New Zealand */ - { "lt", 1 }, -#if 0 - /* The following names are duplicates or are not well attested. */ - zs(-1100, "sst"), /* Samoa */ - zs(-1000, "tht"), /* Tahiti */ - zs(- 930, "mqt"), /* Marquesas */ - zs(- 900, "gbt"), /* Gambier */ - zd(- 900, "yst", "ydt"),/* Yukon - name is no longer used */ - zs(- 830, "pit"), /* Pitcairn */ - zd(- 500, "cst", "cdt"),/* Cuba */ - zd(- 500, "ast", "adt"),/* Acre */ - zd(- 400, "wst", "wdt"),/* Western Brazil */ - zd(- 400, "ast", "adt"),/* Andes */ - zd(- 400, "cst", "cdt"),/* Chile */ - zs(- 300, "wgt"), /* Western Greenland */ - zd(- 300, "est", "edt"),/* Eastern South America */ - zs(- 300, "mgt"), /* Middle Greenland */ - zd(- 200, "fst", "fdt"),/* Fernando de Noronha */ - zs(- 100, "egt"), /* Eastern Greenland */ - zs(- 100, "aat"), /* Atlantic Africa */ - zs(- 100, "act"), /* Azores and Canaries */ - zs( 000, "wat"), /* West Africa */ - zs( 100, "cat"), /* Central Africa */ - zd( 100, "mez","mesz"),/* Mittel-Europaeische Zeit */ - zs( 200, "sat"), /* South Africa */ - zd( 200, "ist", "idt"),/* Israel */ - zs( 300, "eat"), /* East Africa */ - zd( 300, "ast", "adt"),/* Arabia */ - zd( 300, "msk", "msd"),/* Moscow */ - zd( 330, "ist", "idt"),/* Iran */ - zs( 400, "gst"), /* Gulf */ - zs( 400, "smt"), /* Seychelles & Mascarene */ - zd( 400, "esk", "esd"),/* Yekaterinburg */ - zd( 400, "bsk", "bsd"),/* Baku */ - zs( 430, "aft"), /* Afghanistan */ - zd( 500, "osk", "osd"),/* Omsk */ - zs( 500, "pkt"), /* Pakistan */ - zd( 500, "tsk", "tsd"),/* Tashkent */ - zs( 545, "npt"), /* Nepal */ - zs( 600, "bgt"), /* Bangladesh */ - zd( 600, "nsk", "nsd"),/* Novosibirsk */ - zs( 630, "bmt"), /* Burma */ - zs( 630, "cct"), /* Cocos */ - zs( 700, "ict"), /* Indochina */ - zs( 700, "jvt"), /* Java */ - zd( 700, "isk", "isd"),/* Irkutsk */ - zs( 800, "hkt"), /* Hong Kong */ - zs( 800, "pst"), /* Philippines */ - zs( 800, "sgt"), /* Singapore */ - zd( 800, "cst", "cdt"),/* China */ - zd( 800, "ust", "udt"),/* Ulan Bator */ - zd( 800, "wst", "wst"),/* Western Australia */ - zd( 800, "ysk", "ysd"),/* Yakutsk */ - zs( 900, "blt"), /* Belau */ - zs( 900, "mlt"), /* Moluccas */ - zd( 900, "vsk", "vsd"),/* Vladivostok */ - zd( 930, "cst", "cst"),/* Central Australia */ - zs( 1000, "gst"), /* Guam */ - zd( 1000, "gsk", "gsd"),/* Magadan */ - zd( 1000, "est", "est"),/* Eastern Australia */ - zd( 1100,"lhst","lhst"),/* Lord Howe */ - zd( 1100, "psk", "psd"),/* Petropavlovsk-Kamchatski */ - zs( 1100,"ncst"), /* New Caledonia */ - zs( 1130,"nrft"), /* Norfolk */ - zd( 1200, "ask", "asd"),/* Anadyr */ - zs( 1245,"nz-chat"), /* Chatham */ - zs( 1300, "tgt"), /* Tongatapu */ -#endif - {"", -1} -}; - - static int -lookup (s, table) - char const *s; - struct name_val const table[]; -/* Look for a prefix of S in TABLE, returning val for first matching entry. */ -{ - int j; - char buf[NAME_LENGTH_MAXIMUM]; - - for (j = 0; j < NAME_LENGTH_MAXIMUM; j++) { - unsigned char c = *s++; - buf[j] = isupper (c) ? tolower (c) : c; - if (!isalpha (c)) - break; - } - for (; table[0].name[0]; table++) - for (j = 0; buf[j] == table[0].name[j]; ) - if (++j == NAME_LENGTH_MAXIMUM || !table[0].name[j]) - goto done; - done: - return table[0].val; -} - - - static void -undefine (t) struct partime *t; -/* Set *T to ``undefined'' values. */ -{ - t->tm.tm_sec = t->tm.tm_min = t->tm.tm_hour = t->tm.tm_mday = t->tm.tm_mon - = t->tm.tm_year = t->tm.tm_wday = t->tm.tm_yday - = t->ymodulus = t->yweek - = TM_UNDEFINED; - t->zone = TM_UNDEFINED_ZONE; -} - -/* -* Array of patterns to look for in a date string. -* Order is important: we look for the first matching pattern -* whose values do not contradict values that we already know about. -* See `parse_pattern_letter' below for the meaning of the pattern codes. -*/ -static char const * const patterns[] = { - /* - * These traditional patterns must come first, - * to prevent an ISO 8601 format from misinterpreting their prefixes. - */ - "E_n_y", "x", /* RFC 822 */ - "E_n", "n_E", "n", "t:m:s_A", "t:m_A", "t_A", /* traditional */ - "y/N/D$", /* traditional RCS */ - - /* ISO 8601:1988 formats, generalized a bit. */ - "y-N-D$", "4ND$", "Y-N$", - "RND$", "-R=N$", "-R$", "--N=D$", "N=DT", - "--N$", "---D$", "DT", - "Y-d$", "4d$", "R=d$", "-d$", "dT", - "y-W-X", "yWX", "y=W", - "-r-W-X", "r-W-XT", "-rWX", "rWXT", "-W=X", "W=XT", "-W", - "-w-X", "w-XT", "---X$", "XT", "4$", - "T", - "h:m:s$", "hms$", "h:m$", "hm$", "h$", "-m:s$", "-ms$", "-m$", "--s$", - "Y", "Z", - - 0 -}; - - static char const * -parse_prefix (str, t, pi) char const *str; struct partime *t; int *pi; -/* -* Parse an initial prefix of STR, setting *T accordingly. -* Return the first character after the prefix, or 0 if it couldn't be parsed. -* Start with pattern *PI; if success, set *PI to the next pattern to try. -* Set *PI to -1 if we know there are no more patterns to try; -* if *PI is initially negative, give up immediately. -*/ -{ - int i = *pi; - char const *pat; - unsigned char c; - - if (i < 0) - return 0; - - /* Remove initial noise. */ - while (!isalnum (c = *str) && c != '-' && c != '+') { - if (!c) { - undefine (t); - *pi = -1; - return str; - } - str++; - } - - /* Try a pattern until one succeeds. */ - while ((pat = patterns[i++]) != 0) { - char const *s = str; - undefine (t); - do { - if (!(c = *pat++)) { - *pi = i; - return s; - } - } while ((s = parse_pattern_letter (s, c, t)) != 0); - } - - return 0; -} - - static char const * -parse_fixed (s, digits, res) char const *s; int digits, *res; -/* -* Parse an initial prefix of S of length DIGITS; it must be a number. -* Store the parsed number into *RES. -* Return the first character after the prefix, or 0 if it couldn't be parsed. -*/ -{ - int n = 0; - char const *lim = s + digits; - while (s < lim) { - unsigned d = *s++ - '0'; - if (9 < d) - return 0; - n = 10*n + d; - } - *res = n; - return s; -} - - static char const * -parse_ranged (s, digits, lo, hi, res) char const *s; int digits, lo, hi, *res; -/* -* Parse an initial prefix of S of length DIGITS; -* it must be a number in the range LO through HI. -* Store the parsed number into *RES. -* Return the first character after the prefix, or 0 if it couldn't be parsed. -*/ -{ - s = parse_fixed (s, digits, res); - return s && lo<=*res && *res<=hi ? s : 0; -} - - static char const * -parse_decimal (s, digits, lo, hi, resolution, res, fres) - char const *s; - int digits, lo, hi, resolution, *res, *fres; -/* -* Parse an initial prefix of S of length DIGITS; -* it must be a number in the range LO through HI -* and it may be followed by a fraction that is to be computed using RESOLUTION. -* Store the parsed number into *RES; store the fraction times RESOLUTION, -* rounded to the nearest integer, into *FRES. -* Return the first character after the prefix, or 0 if it couldn't be parsed. -*/ -{ - s = parse_fixed (s, digits, res); - if (s && lo<=*res && *res<=hi) { - int f = 0; - if ((s[0]==',' || s[0]=='.') && isdigit ((unsigned char) s[1])) { - char const *s1 = ++s; - int num10 = 0, denom10 = 10, product; - while (isdigit ((unsigned char) *++s)) - denom10 *= 10; - s = parse_fixed (s1, s - s1, &num10); - product = num10*resolution; - f = (product + (denom10>>1)) / denom10; - f -= f & (product%denom10 == denom10>>1); /* round to even */ - if (f < 0 || product/resolution != num10) - return 0; /* overflow */ - } - *fres = f; - return s; - } - return 0; -} - - char * -parzone (s, zone) char const *s; long *zone; -/* -* Parse an initial prefix of S; it must denote a time zone. -* Set *ZONE to the number of seconds east of GMT, -* or to TM_LOCAL_ZONE if it is the local time zone. -* Return the first character after the prefix, or 0 if it couldn't be parsed. -*/ -{ - char sign; - int hh, mm, ss; - int minutesEastOfUTC; - long offset, z; - - /* - * The formats are LT, n, n DST, nDST, no, o - * where n is a time zone name - * and o is a time zone offset of the form [-+]hh[:mm[:ss]]. - */ - switch (*s) { - case '-': case '+': - z = 0; - break; - - default: - minutesEastOfUTC = lookup (s, zone_names); - if (minutesEastOfUTC == -1) - return 0; - - /* Don't bother to check rest of spelling. */ - while (isalpha ((unsigned char) *s)) - s++; - - /* Don't modify LT. */ - if (minutesEastOfUTC == 1) { - *zone = TM_LOCAL_ZONE; - return (char *) s; - } - - z = minutesEastOfUTC * 60L; - - /* Look for trailing " DST". */ - if ( - (s[-1]=='T' || s[-1]=='t') && - (s[-2]=='S' || s[-2]=='s') && - (s[-3]=='D' || s[-3]=='t') - ) - goto trailing_dst; - while (isspace ((unsigned char) *s)) - s++; - if ( - (s[0]=='D' || s[0]=='d') && - (s[1]=='S' || s[1]=='s') && - (s[2]=='T' || s[2]=='t') - ) { - s += 3; - trailing_dst: - *zone = z + 60*60; - return (char *) s; - } - - switch (*s) { - case '-': case '+': break; - default: return (char *) s; - } - } - sign = *s++; - - if (!(s = parse_ranged (s, 2, 0, 23, &hh))) - return 0; - mm = ss = 0; - if (*s == ':') - s++; - if (isdigit ((unsigned char) *s)) { - if (!(s = parse_ranged (s, 2, 0, 59, &mm))) - return 0; - if (*s==':' && s[-3]==':' && isdigit ((unsigned char) s[1])) { - if (!(s = parse_ranged (s + 1, 2, 0, 59, &ss))) - return 0; - } - } - if (isdigit ((unsigned char) *s)) - return 0; - offset = (hh*60 + mm)*60L + ss; - *zone = z + (sign=='-' ? -offset : offset); - /* - * ?? Are fractions allowed here? - * If so, they're not implemented. - */ - return (char *) s; -} - - static char const * -parse_pattern_letter (s, c, t) char const *s; int c; struct partime *t; -/* -* Parse an initial prefix of S, matching the pattern whose code is C. -* Set *T accordingly. -* Return the first character after the prefix, or 0 if it couldn't be parsed. -*/ -{ - switch (c) { - case '$': /* The next character must be a non-digit. */ - if (isdigit ((unsigned char) *s)) - return 0; - break; - - case '-': case '/': case ':': - /* These characters stand for themselves. */ - if (*s++ != c) - return 0; - break; - - case '4': /* 4-digit year */ - s = parse_fixed (s, 4, &t->tm.tm_year); - break; - - case '=': /* optional '-' */ - s += *s == '-'; - break; - - case 'A': /* AM or PM */ - /* - * This matches the regular expression [AaPp][Mm]?. - * It must not be followed by a letter or digit; - * otherwise it would match prefixes of strings like "PST". - */ - switch (*s++) { - case 'A': case 'a': - if (t->tm.tm_hour == 12) - t->tm.tm_hour = 0; - break; - - case 'P': case 'p': - if (t->tm.tm_hour != 12) - t->tm.tm_hour += 12; - break; - - default: return 0; - } - switch (*s) { - case 'M': case 'm': s++; break; - } - if (isalnum (*s)) - return 0; - break; - - case 'D': /* day of month [01-31] */ - s = parse_ranged (s, 2, 1, 31, &t->tm.tm_mday); - break; - - case 'd': /* day of year [001-366] */ - s = parse_ranged (s, 3, 1, 366, &t->tm.tm_yday); - t->tm.tm_yday--; - break; - - case 'E': /* extended day of month [1-9, 01-31] */ - s = parse_ranged (s, ( - isdigit ((unsigned char) s[0]) && - isdigit ((unsigned char) s[1]) - ) + 1, 1, 31, &t->tm.tm_mday); - break; - - case 'h': /* hour [00-23 followed by optional fraction] */ - { - int frac; - s = parse_decimal (s, 2, 0, 23, 60*60, &t->tm.tm_hour, &frac); - t->tm.tm_min = frac / 60; - t->tm.tm_sec = frac % 60; - } - break; - - case 'm': /* minute [00-59 followed by optional fraction] */ - s = parse_decimal (s, 2, 0, 59, 60, &t->tm.tm_min, &t->tm.tm_sec); - break; - - case 'n': /* month name [e.g. "Jan"] */ - if (!TM_DEFINED (t->tm.tm_mon = lookup (s, month_names))) - return 0; - /* Don't bother to check rest of spelling. */ - while (isalpha ((unsigned char) *s)) - s++; - break; - - case 'N': /* month [01-12] */ - s = parse_ranged (s, 2, 1, 12, &t->tm.tm_mon); - t->tm.tm_mon--; - break; - - case 'r': /* year % 10 (remainder in origin-0 decade) [0-9] */ - s = parse_fixed (s, 1, &t->tm.tm_year); - t->ymodulus = 10; - break; - - case_R: - case 'R': /* year % 100 (remainder in origin-0 century) [00-99] */ - s = parse_fixed (s, 2, &t->tm.tm_year); - t->ymodulus = 100; - break; - - case 's': /* second [00-60 followed by optional fraction] */ - { - int frac; - s = parse_decimal (s, 2, 0, 60, 1, &t->tm.tm_sec, &frac); - t->tm.tm_sec += frac; - } - break; - - case 'T': /* 'T' or 't' */ - switch (*s++) { - case 'T': case 't': break; - default: return 0; - } - break; - - case 't': /* traditional hour [1-9 or 01-12] */ - s = parse_ranged (s, ( - isdigit ((unsigned char) s[0]) && isdigit ((unsigned char) s[1]) - ) + 1, 1, 12, &t->tm.tm_hour); - break; - - case 'w': /* 'W' or 'w' only (stands for current week) */ - switch (*s++) { - case 'W': case 'w': break; - default: return 0; - } - break; - - case 'W': /* 'W' or 'w', followed by a week of year [00-53] */ - switch (*s++) { - case 'W': case 'w': break; - default: return 0; - } - s = parse_ranged (s, 2, 0, 53, &t->yweek); - break; - - case 'X': /* weekday (1=Mon ... 7=Sun) [1-7] */ - s = parse_ranged (s, 1, 1, 7, &t->tm.tm_wday); - t->tm.tm_wday--; - break; - - case 'x': /* weekday name [e.g. "Sun"] */ - if (!TM_DEFINED (t->tm.tm_wday = lookup (s, weekday_names))) - return 0; - /* Don't bother to check rest of spelling. */ - while (isalpha ((unsigned char) *s)) - s++; - break; - - case 'y': /* either R or Y */ - if ( - isdigit ((unsigned char) s[0]) && - isdigit ((unsigned char) s[1]) && - !isdigit ((unsigned char) s[2]) - ) - goto case_R; - /* fall into */ - case 'Y': /* year in full [4 or more digits] */ - { - int len = 0; - while (isdigit ((unsigned char) s[len])) - len++; - if (len < 4) - return 0; - s = parse_fixed (s, len, &t->tm.tm_year); - } - break; - - case 'Z': /* time zone */ - s = parzone (s, &t->zone); - break; - - case '_': /* possibly empty sequence of non-alphanumerics */ - while (!isalnum (*s) && *s) - s++; - break; - - default: /* bad pattern */ - return 0; - } - return s; -} - - static int -merge_partime (t, u) struct partime *t; struct partime const *u; -/* -* If there is no conflict, merge into *T the additional information in *U -* and return 0. Otherwise do nothing and return -1. -*/ -{ -# define conflict(a,b) ((a) != (b) && TM_DEFINED (a) && TM_DEFINED (b)) - if ( - conflict (t->tm.tm_sec, u->tm.tm_sec) || - conflict (t->tm.tm_min, u->tm.tm_min) || - conflict (t->tm.tm_hour, u->tm.tm_hour) || - conflict (t->tm.tm_mday, u->tm.tm_mday) || - conflict (t->tm.tm_mon, u->tm.tm_mon) || - conflict (t->tm.tm_year, u->tm.tm_year) || - conflict (t->tm.tm_wday, u->tm.tm_yday) || - conflict (t->ymodulus, u->ymodulus) || - conflict (t->yweek, u->yweek) || - ( - t->zone != u->zone && - t->zone != TM_UNDEFINED_ZONE && - u->zone != TM_UNDEFINED_ZONE - ) - ) - return -1; -# undef conflict -# define merge_(a,b) if (TM_DEFINED (b)) (a) = (b); - merge_ (t->tm.tm_sec, u->tm.tm_sec) - merge_ (t->tm.tm_min, u->tm.tm_min) - merge_ (t->tm.tm_hour, u->tm.tm_hour) - merge_ (t->tm.tm_mday, u->tm.tm_mday) - merge_ (t->tm.tm_mon, u->tm.tm_mon) - merge_ (t->tm.tm_year, u->tm.tm_year) - merge_ (t->tm.tm_wday, u->tm.tm_yday) - merge_ (t->ymodulus, u->ymodulus) - merge_ (t->yweek, u->yweek) -# undef merge_ - if (u->zone != TM_UNDEFINED_ZONE) t->zone = u->zone; - return 0; -} - - char * -partime (s, t) char const *s; struct partime *t; -/* -* Parse a date/time prefix of S, putting the parsed result into *T. -* Return the first character after the prefix. -* The prefix may contain no useful information; -* in that case, *T will contain only undefined values. -*/ -{ - struct partime p; - - undefine (t); - while (*s) { - int i = 0; - char const *s1; - do { - if (!(s1 = parse_prefix (s, &p, &i))) - return (char *) s; - } while (merge_partime (t, &p) != 0); - s = s1; - } - return (char *) s; -} diff --git a/gnu/usr.bin/rcs/lib/partime.h b/gnu/usr.bin/rcs/lib/partime.h deleted file mode 100644 index 5d3983fbb04..00000000000 --- a/gnu/usr.bin/rcs/lib/partime.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Parse a string, yielding a struct partime that describes it. */ - -/* Copyright 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#define TM_UNDEFINED (-1) -#define TM_DEFINED(x) (0 <= (x)) - -#define TM_UNDEFINED_ZONE ((long) -24 * 60 * 60) -#define TM_LOCAL_ZONE (TM_UNDEFINED_ZONE - 1) - -struct partime { - /* - * This structure describes the parsed time. - * Only the following tm_* values in it are used: - * sec, min, hour, mday, mon, year, wday, yday. - * If TM_UNDEFINED(value), the parser never found the value. - * The tm_year field is the actual year, not the year - 1900; - * but see ymodulus below. - */ - struct tm tm; - - /* - * If !TM_UNDEFINED(ymodulus), - * then tm.tm_year is actually modulo ymodulus. - */ - int ymodulus; - - /* - * Week of year, ISO 8601 style. - * If TM_UNDEFINED(yweek), the parser never found yweek. - * Weeks start on Mondays. - * Week 1 includes Jan 4. - */ - int yweek; - - /* Seconds east of UTC; or TM_LOCAL_ZONE or TM_UNDEFINED_ZONE. */ - long zone; -}; - -#if defined(__STDC__) || has_prototypes -# define __PARTIME_P(x) x -#else -# define __PARTIME_P(x) () -#endif - -char *partime __PARTIME_P((char const *, struct partime *)); -char *parzone __PARTIME_P((char const *, long *)); diff --git a/gnu/usr.bin/rcs/lib/rcsbase.h b/gnu/usr.bin/rcs/lib/rcsbase.h deleted file mode 100644 index 7c223048f60..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsbase.h +++ /dev/null @@ -1,762 +0,0 @@ -/* RCS common definitions and data structures */ - -#define RCSBASE "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsbase.h 50472 1999-08-27 23:37:10Z peter $" - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.20 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.19 1995/06/01 16:23:43 eggert - * (SIZEABLE_PATH): Don't depend on PATH_MAX: it's not worth configuring. - * (Ioffset_type,BINARY_EXPAND,MIN_UNEXPAND,MIN_UNCHANGED_EXPAND): New macros. - * (maps_memory): New macro; replaces many instances of `has_mmap'. - * (cacheptr): Renamed from cachetell. - * (struct RILE): New alternate name for RILE; the type is now recursive. - * (deallocate): New member for RILE, used for generic buffer deallocation. - * (cacheunget_): No longer take a failure arg; just call Ierror on failure. - * (struct rcslock): Renamed from struct lock, to avoid collisions with - * system headers on some hosts. All users changed. - * (basefilename): Renamed from basename, likewise. - * (dirtpname): Remove; no longer external. - * (dirlen, dateform): Remove; no longer used. - * (cmpdate, fopenSafer, fdSafer, readAccessFilenameBuffer): New functions. - * (zonelenmax): Increase to 9 for full ISO 8601 format. - * (catchmmapints): Depend on has_NFS. - * - * Revision 5.18 1994/03/17 14:05:48 eggert - * Add primitives for reading backwards from a RILE; - * this is needed to go back and find the $Log prefix. - * Specify subprocess input via file descriptor, not file name. Remove lint. - * - * Revision 5.17 1993/11/09 17:40:15 eggert - * Move RCS-specific time handling into rcstime.c. - * printf_string now takes two arguments, alas. - * - * Revision 5.16 1993/11/03 17:42:27 eggert - * Don't arbitrarily limit the number of joins. Remove `nil'. - * Add Name keyword. Don't discard ignored phrases. - * Add support for merge -A vs -E, and allow up to three labels. - * Improve quality of diagnostics and prototypes. - * - * Revision 5.15 1992/07/28 16:12:44 eggert - * Statement macro names now end in _. - * - * Revision 5.14 1992/02/17 23:02:22 eggert - * Add -T support. Work around NFS mmap SIGBUS problem. - * - * Revision 5.13 1992/01/24 18:44:19 eggert - * Add support for bad_creat0. lint -> RCS_lint - * - * Revision 5.12 1992/01/06 02:42:34 eggert - * while (E) ; -> while (E) continue; - * - * Revision 5.11 1991/10/07 17:32:46 eggert - * Support piece tables even if !has_mmap. - * - * Revision 5.10 1991/09/24 00:28:39 eggert - * Remove unexported functions. - * - * Revision 5.9 1991/08/19 03:13:55 eggert - * Add piece tables and other tuneups, and NFS workarounds. - * - * Revision 5.8 1991/04/21 11:58:20 eggert - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.7 1991/02/28 19:18:50 eggert - * Try setuid() if seteuid() doesn't work. - * - * Revision 5.6 1991/02/26 17:48:37 eggert - * Support new link behavior. Move ANSI C / Posix declarations into conf.sh. - * - * Revision 5.5 1990/12/04 05:18:43 eggert - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.4 1990/11/01 05:03:35 eggert - * Don't assume that builtins are functions; they may be macros. - * Permit arbitrary data in logs. - * - * Revision 5.3 1990/09/26 23:36:58 eggert - * Port wait() to non-Posix ANSI C hosts. - * - * Revision 5.2 1990/09/04 08:02:20 eggert - * Don't redefine NAME_MAX, PATH_MAX. - * Improve incomplete line handling. Standardize yes-or-no procedure. - * - * Revision 5.1 1990/08/29 07:13:53 eggert - * Add -kkvl. Fix type typos exposed by porting. Clean old log messages too. - * - * Revision 5.0 1990/08/22 08:12:44 eggert - * Adjust ANSI C / Posix support. Add -k, -V, setuid. Don't call access(). - * Remove compile-time limits; use malloc instead. - * Ansify and Posixate. Add support for ISO 8859. - * Remove snoop and v2 support. - * - * Revision 4.9 89/05/01 15:17:14 narten - * botched previous USG fix - * - * Revision 4.8 89/05/01 14:53:05 narten - * changed #include -> string.h for USG systems. - * - * Revision 4.7 88/11/08 15:58:45 narten - * removed defs for functions loaded from libraries - * - * Revision 4.6 88/08/09 19:12:36 eggert - * Shrink stdio code size; remove lint; permit -Dhshsize=nn. - * - * Revision 4.5 87/12/18 17:06:41 narten - * made removed BSD ifdef, now uses V4_2BSD - * - * Revision 4.4 87/10/18 10:29:49 narten - * Updating version numbers - * Changes relative to 1.1 are actually relative to 4.2 - * - * Revision 1.3 87/09/24 14:02:25 narten - * changes for lint - * - * Revision 1.2 87/03/27 14:22:02 jenkins - * Port to suns - * - * Revision 4.2 83/12/20 16:04:20 wft - * merged 3.6.1.1 and 4.1 (SMALLOG, logsize). - * moved setting of STRICT_LOCKING to Makefile. - * changed DOLLAR to UNKN (conflict with KDELIM). - * - * Revision 4.1 83/05/04 09:12:41 wft - * Added markers Id and RCSfile. - * Added Dbranch for default branches. - * - * Revision 3.6.1.1 83/12/02 21:56:22 wft - * Increased logsize, added macro SMALLOG. - * - * Revision 3.6 83/01/15 16:43:28 wft - * 4.2 prerelease - * - * Revision 3.6 83/01/15 16:43:28 wft - * Replaced dbm.h with BYTESIZ, fixed definition of rindex(). - * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD. - * Added macro DELNUMFORM to have uniform format for printing delta text nodes. - * Added macro DELETE to mark deleted deltas. - * - * Revision 3.5 82/12/10 12:16:56 wft - * Added two forms of DATEFORM, one using %02d, the other %.2d. - * - * Revision 3.4 82/12/04 20:01:25 wft - * added LOCKER, Locker, and USG (redefinition of rindex). - * - * Revision 3.3 82/12/03 12:22:04 wft - * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3, - * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength - * using NCPPN. Changed putc() to abort on write error. - * - * Revision 3.2 82/10/18 15:03:52 wft - * added macro STRICT_LOCKING, removed RCSUMASK. - * renamed JOINFILE[1,2] to JOINFIL[1,2]. - * - * Revision 3.1 82/10/11 19:41:17 wft - * removed NBPW, NBPC, NCPW. - * added typdef int void to aid compiling - */ - - -#include "conf.h" - - -#define EXIT_TROUBLE DIFF_TROUBLE - -#ifdef _POSIX_PATH_MAX -# define SIZEABLE_PATH _POSIX_PATH_MAX -#else -# define SIZEABLE_PATH 255 /* size of a large path; not a hard limit */ -#endif - -/* for traditional C hosts with unusual size arguments */ -#define Fread(p,s,n,f) fread(p, (freadarg_type)(s), (freadarg_type)(n), f) -#define Fwrite(p,s,n,f) fwrite(p, (freadarg_type)(s), (freadarg_type)(n), f) - - -/* - * Parameters - */ - -/* backwards compatibility with old versions of RCS */ -#define VERSION_min 3 /* old output RCS format supported */ -#define VERSION_max 5 /* newest output RCS format supported */ -#ifndef VERSION_DEFAULT /* default RCS output format */ -# define VERSION_DEFAULT VERSION_max -#endif -#define VERSION(n) ((n) - VERSION_DEFAULT) /* internally, 0 is the default */ - -#ifndef STRICT_LOCKING -#define STRICT_LOCKING 1 -#endif - /* 0 sets the default locking to non-strict; */ - /* used in experimental environments. */ - /* 1 sets the default locking to strict; */ - /* used in production environments. */ - -#define yearlength 16 /* (good through AD 9,999,999,999,999,999) */ -#define datesize (yearlength+16) /* size of output of time2date */ -#define RCSTMPPREFIX '_' /* prefix for temp files in working dir */ -#define KDELIM '$' /* delimiter for keywords */ -#define VDELIM ':' /* separates keywords from values */ -#define DEFAULTSTATE "Exp" /* default state of revisions */ - - - -#define true 1 -#define false 0 - - -/* - * RILE - readonly file - * declarecache; - declares local cache for RILE variable(s) - * setupcache - sets up the local RILE cache, but does not initialize it - * cache, uncache - caches and uncaches the local RILE; - * (uncache,cache) is needed around functions that advance the RILE pointer - * Igeteof_(f,c,s) - get a char c from f, executing statement s at EOF - * cachegeteof_(c,s) - Igeteof_ applied to the local RILE - * Iget_(f,c) - like Igeteof_, except EOF is an error - * cacheget_(c) - Iget_ applied to the local RILE - * cacheunget_(f,c,s) - read c backwards from cached f, executing s at BOF - * Ifileno, Ioffset_type, Irewind, Itell - analogs to stdio routines - * - * By conventions, macros whose names end in _ are statements, not expressions. - * Following such macros with `; else' results in a syntax error. - */ - -#define maps_memory (has_map_fd || has_mmap) - -#if large_memory - typedef unsigned char const *Iptr_type; - typedef struct RILE { - Iptr_type ptr, lim; - unsigned char *base; /* not Iptr_type for lint's sake */ - unsigned char *readlim; - int fd; -# if maps_memory - void (*deallocate) P((struct RILE *)); -# else - FILE *stream; -# endif - } RILE; -# if maps_memory -# define declarecache register Iptr_type ptr, lim -# define setupcache(f) (lim = (f)->lim) -# define Igeteof_(f,c,s) if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++; -# define cachegeteof_(c,s) if (ptr==lim) s else (c)= *ptr++; -# else - int Igetmore P((RILE*)); -# define declarecache register Iptr_type ptr; register RILE *rRILE -# define setupcache(f) (rRILE = (f)) -# define Igeteof_(f,c,s) if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++; -# define cachegeteof_(c,s) if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++; -# endif -# define uncache(f) ((f)->ptr = ptr) -# define cache(f) (ptr = (f)->ptr) -# define Iget_(f,c) Igeteof_(f,c,Ieof();) -# define cacheget_(c) cachegeteof_(c,Ieof();) -# define cacheunget_(f,c) (c)=(--ptr)[-1]; -# define Ioffset_type size_t -# define Itell(f) ((f)->ptr - (f)->base) -# define Irewind(f) ((f)->ptr = (f)->base) -# define cacheptr() ptr -# define Ifileno(f) ((f)->fd) -#else -# define RILE FILE -# define declarecache register FILE *ptr -# define setupcache(f) (ptr = (f)) -# define uncache(f) -# define cache(f) -# define Igeteof_(f,c,s) {if(((c)=getc(f))==EOF){testIerror(f);if(feof(f))s}} -# define cachegeteof_(c,s) Igeteof_(ptr,c,s) -# define Iget_(f,c) { if (((c)=getc(f))==EOF) testIeof(f); } -# define cacheget_(c) Iget_(ptr,c) -# define cacheunget_(f,c) if(fseek(ptr,-2L,SEEK_CUR))Ierror();else cacheget_(c) -# define Ioffset_type long -# define Itell(f) ftell(f) -# define Ifileno(f) fileno(f) -#endif - -/* Print a char, but abort on write error. */ -#define aputc_(c,o) { if (putc(c,o)==EOF) testOerror(o); } - -/* Get a character from an RCS file, perhaps copying to a new RCS file. */ -#define GETCeof_(o,c,s) { cachegeteof_(c,s) if (o) aputc_(c,o) } -#define GETC_(o,c) { cacheget_(c) if (o) aputc_(c,o) } - - -#define WORKMODE(RCSmode, writable) (((RCSmode)&(mode_t)~(S_IWUSR|S_IWGRP|S_IWOTH)) | ((writable)?S_IWUSR:0)) -/* computes mode of working file: same as RCSmode, but write permission */ -/* determined by writable */ - - -/* character classes and token codes */ -enum tokens { -/* classes */ DELIM, DIGIT, IDCHAR, NEWLN, LETTER, Letter, - PERIOD, SBEGIN, SPACE, UNKN, -/* tokens */ COLON, ID, NUM, SEMI, STRING -}; - -#define SDELIM '@' /* the actual character is needed for string handling*/ -/* SDELIM must be consistent with ctab[], so that ctab[SDELIM]==SBEGIN. - * there should be no overlap among SDELIM, KDELIM, and VDELIM - */ - -#define isdigit(c) (((unsigned)(c)-'0') <= 9) /* faster than ctab[c]==DIGIT */ - - - - - -/*************************************** - * Data structures for the symbol table - ***************************************/ - -/* Buffer of arbitrary data */ -struct buf { - char *string; - size_t size; -}; -struct cbuf { - char const *string; - size_t size; -}; - -/* Hash table entry */ -struct hshentry { - char const * num; /* pointer to revision number (ASCIZ) */ - char const * date; /* pointer to date of checkin */ - char const * author; /* login of person checking in */ - char const * lockedby; /* who locks the revision */ - char const * state; /* state of revision (Exp by default) */ - char const * name; /* name (if any) by which retrieved */ - struct cbuf log; /* log message requested at checkin */ - struct branchhead * branches; /* list of first revisions on branches*/ - struct cbuf ig; /* ignored phrases in admin part */ - struct cbuf igtext; /* ignored phrases in deltatext part */ - struct hshentry * next; /* next revision on same branch */ - struct hshentry * nexthsh; /* next revision with same hash value */ - long insertlns;/* lines inserted (computed by rlog) */ - long deletelns;/* lines deleted (computed by rlog) */ - char selector; /* true if selected, false if deleted */ -}; - -/* list of hash entries */ -struct hshentries { - struct hshentries *rest; - struct hshentry *first; -}; - -/* list element for branch lists */ -struct branchhead { - struct hshentry * hsh; - struct branchhead * nextbranch; -}; - -/* accesslist element */ -struct access { - char const * login; - struct access * nextaccess; -}; - -/* list element for locks */ -struct rcslock { - char const * login; - struct hshentry * delta; - struct rcslock * nextlock; -}; - -/* list element for symbolic names */ -struct assoc { - char const * symbol; - char const * num; - struct assoc * nextassoc; -}; - - -#define mainArgs (argc,argv) int argc; char **argv; - -#if RCS_lint -# define libId(name,rcsid) -# define mainProg(name,cmd,rcsid) int name mainArgs -#else -# define libId(name,rcsid) char const name[] = rcsid; -# define mainProg(n,c,i) char const Copyright[] = "Copyright 1982,1988,1989 Walter F. Tichy, Purdue CS\nCopyright 1990,1991,1992,1993,1994,1995 Paul Eggert", baseid[] = RCSBASE, cmdid[] = c; libId(n,i) int main P((int,char**)); int main mainArgs -#endif - -/* - * Markers for keyword expansion (used in co and ident) - * Every byte must have class LETTER or Letter. - */ -#define AUTHOR "Author" -#define DATE "Date" -#define HEADER "Header" -#define IDH "Id" -#define LOCKER "Locker" -#define LOG "Log" -#define NAME "Name" -#define RCSFILE "RCSfile" -#define REVISION "Revision" -#define SOURCE "Source" -#define STATE "State" -#define CVSHEADER "CVSHeader" -#define keylength 9 /* max length of any of the above keywords */ - -enum markers { Nomatch, Author, Date, Header, Id, - Locker, Log, Name, RCSfile, Revision, Source, State, CVSHeader, - LocalId }; - /* This must be in the same order as rcskeys.c's Keyword[] array. */ - -#define DELNUMFORM "\n\n%s\n%s\n" -/* used by putdtext and scanlogtext */ - -#define EMPTYLOG "*** empty log message ***" /* used by ci and rlog */ - -/* main program */ -extern char const cmdid[]; -void exiterr P((void)) exiting; - -/* merge */ -int merge P((int,char const*,char const*const[3],char const*const[3])); - -/* rcsedit */ -#define ciklogsize 23 /* sizeof("checked in with -k by ") */ -extern FILE *fcopy; -extern char const *resultname; -extern char const ciklog[ciklogsize]; -extern int locker_expansion; -RILE *rcswriteopen P((struct buf*,struct stat*,int)); -char const *makedirtemp P((int)); -char const *getcaller P((void)); -int addlock P((struct hshentry*,int)); -int addsymbol P((char const*,char const*,int)); -int checkaccesslist P((void)); -int chnamemod P((FILE**,char const*,char const*,int,mode_t,time_t)); -int donerewrite P((int,time_t)); -int dorewrite P((int,int)); -int expandline P((RILE*,FILE*,struct hshentry const*,int,FILE*,int)); -int findlock P((int,struct hshentry**)); -int setmtime P((char const*,time_t)); -void ORCSclose P((void)); -void ORCSerror P((void)); -void copystring P((void)); -void dirtempunlink P((void)); -void enterstring P((void)); -void finishedit P((struct hshentry const*,FILE*,int)); -void keepdirtemp P((char const*)); -void openfcopy P((FILE*)); -void snapshotedit P((FILE*)); -void xpandstring P((struct hshentry const*)); -#if has_NFS || bad_unlink - int un_link P((char const*)); -#else -# define un_link(s) unlink(s) -#endif -#if large_memory - void edit_string P((void)); -# define editstring(delta) edit_string() -#else - void editstring P((struct hshentry const*)); -#endif - -/* rcsfcmp */ -int rcsfcmp P((RILE*,struct stat const*,char const*,struct hshentry const*)); - -/* rcsfnms */ -#define bufautobegin(b) clear_buf(b) -#define clear_buf(b) (VOID ((b)->string = 0, (b)->size = 0)) -extern FILE *workstdout; -extern char *workname; -extern char const *RCSname; -extern char const *suffixes; -extern int fdlock; -extern struct stat RCSstat; -RILE *rcsreadopen P((struct buf*,struct stat*,int)); -char *bufenlarge P((struct buf*,char const**)); -char const *basefilename P((char const*)); -char const *getfullRCSname P((void)); -char const *getfullCVSname P((void)); -char const *maketemp P((int)); -char const *rcssuffix P((char const*)); -int pairnames P((int,char**,RILE*(*)P((struct buf*,struct stat*,int)),int,int)); -struct cbuf bufremember P((struct buf*,size_t)); -void bufalloc P((struct buf*,size_t)); -void bufautoend P((struct buf*)); -void bufrealloc P((struct buf*,size_t)); -void bufscat P((struct buf*,char const*)); -void bufscpy P((struct buf*,char const*)); -void tempunlink P((void)); - -/* rcsgen */ -extern int interactiveflag; -extern struct buf curlogbuf; -char const *buildrevision P((struct hshentries const*,struct hshentry*,FILE*,int)); -int getcstdin P((void)); -int putdtext P((struct hshentry const*,char const*,FILE*,int)); -int ttystdin P((void)); -int yesorno P((int,char const*,...)) printf_string(2,3); -struct cbuf cleanlogmsg P((char*,size_t)); -struct cbuf getsstdin P((char const*,char const*,char const*,struct buf*)); -void putdesc P((int,char*)); -void putdftext P((struct hshentry const*,RILE*,FILE*,int)); - -/* rcskeep */ -extern int prevkeys; -extern struct buf prevauthor, prevdate, prevname, prevrev, prevstate; -int getoldkeys P((RILE*)); - -/* rcskeys */ -extern char const *Keyword[]; -extern enum markers LocalIdMode; -enum markers trymatch P((char const*)); -void setRCSLocalId(char const *); -void setIncExc(char const *); - -/* rcslex */ -extern FILE *foutptr; -extern FILE *frewrite; -extern RILE *finptr; -extern char const *NextString; -extern enum tokens nexttok; -extern int hshenter; -extern int nerror; -extern int nextc; -extern int quietflag; -extern long rcsline; -char const *getid P((void)); -void efaterror P((char const*)) exiting; -void enfaterror P((int,char const*)) exiting; -void fatcleanup P((int)) exiting; -void faterror P((char const*,...)) printf_string_exiting(1,2); -void fatserror P((char const*,...)) printf_string_exiting(1,2); -void rcsfaterror P((char const*,...)) printf_string_exiting(1,2); -void Ieof P((void)) exiting; -void Ierror P((void)) exiting; -void Oerror P((void)) exiting; -char *checkid P((char*,int)); -char *checksym P((char*,int)); -int eoflex P((void)); -int getkeyopt P((char const*)); -int getlex P((enum tokens)); -struct cbuf getphrases P((char const*)); -struct cbuf savestring P((struct buf*)); -struct hshentry *getnum P((void)); -void Ifclose P((RILE*)); -void Izclose P((RILE**)); -void Lexinit P((void)); -void Ofclose P((FILE*)); -void Orewind P((FILE*)); -void Ozclose P((FILE**)); -void aflush P((FILE*)); -void afputc P((int,FILE*)); -void aprintf P((FILE*,char const*,...)) printf_string(2,3); -void aputs P((char const*,FILE*)); -void checksid P((char*)); -void checkssym P((char*)); -void diagnose P((char const*,...)) printf_string(1,2); -void eerror P((char const*)); -void eflush P((void)); -void enerror P((int,char const*)); -void error P((char const*,...)) printf_string(1,2); -void fvfprintf P((FILE*,char const*,va_list)); -void getkey P((char const*)); -void getkeystring P((char const*)); -void nextlex P((void)); -void oflush P((void)); -void printstring P((void)); -void readstring P((void)); -void redefined P((int)); -void rcserror P((char const*,...)) printf_string(1,2); -void rcswarn P((char const*,...)) printf_string(1,2); -void testIerror P((FILE*)); -void testOerror P((FILE*)); -void warn P((char const*,...)) printf_string(1,2); -void warnignore P((void)); -void workerror P((char const*,...)) printf_string(1,2); -void workwarn P((char const*,...)) printf_string(1,2); -#if has_madvise && has_mmap && large_memory - void advise_access P((RILE*,int)); -# define if_advise_access(p,f,advice) if (p) advise_access(f,advice) -#else -# define advise_access(f,advice) -# define if_advise_access(p,f,advice) -#endif -#if large_memory && maps_memory - RILE *I_open P((char const*,struct stat*)); -# define Iopen(f,m,s) I_open(f,s) -#else - RILE *Iopen P((char const*,char const*,struct stat*)); -#endif -#if !large_memory - void testIeof P((FILE*)); - void Irewind P((RILE*)); -#endif - -/* rcsmap */ -extern enum tokens const ctab[]; - -/* rcsrev */ -char *partialno P((struct buf*,char const*,int)); -char const *namedrev P((char const*,struct hshentry*)); -char const *tiprev P((void)); -int cmpdate P((char const*,char const*)); -int cmpnum P((char const*,char const*)); -int cmpnumfld P((char const*,char const*,int)); -int compartial P((char const*,char const*,int)); -int expandsym P((char const*,struct buf*)); -int fexpandsym P((char const*,struct buf*,RILE*)); -struct hshentry *genrevs P((char const*,char const*,char const*,char const*,struct hshentries**)); -int countnumflds P((char const*)); -void getbranchno P((char const*,struct buf*)); - -/* rcssyn */ -/* These expand modes must agree with Expand_names[] in rcssyn.c. */ -#define KEYVAL_EXPAND 0 /* -kkv `$Keyword: value $' */ -#define KEYVALLOCK_EXPAND 1 /* -kkvl `$Keyword: value locker $' */ -#define KEY_EXPAND 2 /* -kk `$Keyword$' */ -#define VAL_EXPAND 3 /* -kv `value' */ -#define OLD_EXPAND 4 /* -ko use old string, omitting expansion */ -#define BINARY_EXPAND 5 /* -kb like -ko, but use binary mode I/O */ -#define MIN_UNEXPAND OLD_EXPAND /* min value for no logical expansion */ -#define MIN_UNCHANGED_EXPAND (OPEN_O_BINARY ? BINARY_EXPAND : OLD_EXPAND) - /* min value guaranteed to yield an identical file */ -struct diffcmd { - long - line1, /* number of first line */ - nlines, /* number of lines affected */ - adprev, /* previous 'a' line1+1 or 'd' line1 */ - dafter; /* sum of previous 'd' line1 and previous 'd' nlines */ -}; -extern char const * Dbranch; -extern struct access * AccessList; -extern struct assoc * Symbols; -extern struct cbuf Comment; -extern struct cbuf Ignored; -extern struct rcslock *Locks; -extern struct hshentry * Head; -extern int Expand; -extern int StrictLocks; -extern int TotalDeltas; -extern char const *const expand_names[]; -extern char const - Kaccess[], Kauthor[], Kbranch[], Kcomment[], - Kdate[], Kdesc[], Kexpand[], Khead[], Klocks[], Klog[], - Knext[], Kstate[], Kstrict[], Ksymbols[], Ktext[]; -void unexpected_EOF P((void)) exiting; -int getdiffcmd P((RILE*,int,FILE*,struct diffcmd*)); -int str2expmode P((char const*)); -void getadmin P((void)); -void getdesc P((int)); -void gettree P((void)); -void ignorephrases P((char const*)); -void initdiffcmd P((struct diffcmd*)); -void putadmin P((void)); -void putstring P((FILE*,int,struct cbuf,int)); -void puttree P((struct hshentry const*,FILE*)); - -/* rcstime */ -#define zonelenmax 9 /* maxiumum length of time zone string, e.g. "+12:34:56" */ -char const *date2str P((char const[datesize],char[datesize + zonelenmax])); -time_t date2time P((char const[datesize])); -void str2date P((char const*,char[datesize])); -void time2date P((time_t,char[datesize])); -void zone_set P((char const*)); - -/* rcsutil */ -extern int RCSversion; -FILE *fopenSafer P((char const*,char const*)); -char *cgetenv P((char const*)); -char *fstr_save P((char const*)); -char *str_save P((char const*)); -char const *getusername P((int)); -int fdSafer P((int)); -int getRCSINIT P((int,char**,char***)); -int run P((int,char const*,...)); -int runv P((int,char const*,char const**)); -malloc_type fremember P((malloc_type)); -malloc_type ftestalloc P((size_t)); -malloc_type testalloc P((size_t)); -malloc_type testrealloc P((malloc_type,size_t)); -#define ftalloc(T) ftnalloc(T,1) -#define talloc(T) tnalloc(T,1) -#if RCS_lint - extern malloc_type lintalloc; -# define ftnalloc(T,n) (lintalloc = ftestalloc(sizeof(T)*(n)), (T*)0) -# define tnalloc(T,n) (lintalloc = testalloc(sizeof(T)*(n)), (T*)0) -# define trealloc(T,p,n) (lintalloc = testrealloc((malloc_type)0, sizeof(T)*(n)), p) -# define tfree(p) -#else -# define ftnalloc(T,n) ((T*) ftestalloc(sizeof(T)*(n))) -# define tnalloc(T,n) ((T*) testalloc(sizeof(T)*(n))) -# define trealloc(T,p,n) ((T*) testrealloc((malloc_type)(p), sizeof(T)*(n))) -# define tfree(p) free((malloc_type)(p)) -#endif -time_t now P((void)); -void awrite P((char const*,size_t,FILE*)); -void fastcopy P((RILE*,FILE*)); -void ffree P((void)); -void ffree1 P((char const*)); -void setRCSversion P((char const*)); -#if has_signal - void catchints P((void)); - void ignoreints P((void)); - void restoreints P((void)); -#else -# define catchints() -# define ignoreints() -# define restoreints() -#endif -#if has_mmap && large_memory -# if has_NFS && mmap_signal - void catchmmapints P((void)); - void readAccessFilenameBuffer P((char const*,unsigned char const*)); -# else -# define catchmmapints() -# endif -#endif -#if has_getuid - uid_t ruid P((void)); -# define myself(u) ((u) == ruid()) -#else -# define myself(u) true -#endif -#if has_setuid - uid_t euid P((void)); - void nosetid P((void)); - void seteid P((void)); - void setrid P((void)); -#else -# define nosetid() -# define seteid() -# define setrid() -#endif - -/* version */ -extern char const RCS_version_string[]; diff --git a/gnu/usr.bin/rcs/lib/rcsedit.c b/gnu/usr.bin/rcs/lib/rcsedit.c deleted file mode 100644 index 67065beb00c..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsedit.c +++ /dev/null @@ -1,1958 +0,0 @@ -/* RCS stream editor */ - -/****************************************************************************** - * edits the input file according to a - * script from stdin, generated by diff -n - * performs keyword expansion - ****************************************************************************** - */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.19 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.18 1995/06/01 16:23:43 eggert - * (dirtpname): No longer external. - * (do_link): Simplify logic. - * (finisheditline, finishedit): Replace Iseek/Itell with what they stand for. - * (fopen_update_truncate): Replace `#if' with `if'. - * (keyreplace, makedirtemp): dirlen(x) -> basefilename(x)-x. - * - * (edit_string): Fix bug: if !large_memory, a bogus trailing `@' was output - * at the end of incomplete lines. - * - * (keyreplace): Do not assume that seeking backwards - * at the start of a file will fail; on some systems it succeeds. - * Convert C- and Pascal-style comment starts to ` *' in comment leader. - * - * (rcswriteopen): Use fdSafer to get safer file descriptor. - * Open RCS file with FOPEN_RB. - * - * (chnamemod): Work around bad_NFS_rename bug; don't ignore un_link result. - * Fall back on chmod if fchmod fails, since it might be ENOSYS. - * - * (aflush): Move to rcslex.c. - * - * Revision 5.17 1994/03/20 04:52:58 eggert - * Normally calculate the $Log prefix from context, not from RCS file. - * Move setmtime here from rcsutil.c. Add ORCSerror. Remove lint. - * - * Revision 5.16 1993/11/03 17:42:27 eggert - * Add -z. Add Name keyword. If bad_unlink, ignore errno when unlink fails. - * Escape white space, $, and \ in keyword string file names. - * Don't output 2 spaces between date and time after Log. - * - * Revision 5.15 1992/07/28 16:12:44 eggert - * Some hosts have readlink but not ELOOP. Avoid `unsigned'. - * Preserve dates more systematically. Statement macro names now end in _. - * - * Revision 5.14 1992/02/17 23:02:24 eggert - * Add -T support. - * - * Revision 5.13 1992/01/24 18:44:19 eggert - * Add support for bad_chmod_close, bad_creat0. - * - * Revision 5.12 1992/01/06 02:42:34 eggert - * Add setmode parameter to chnamemod. addsymbol now reports changes. - * while (E) ; -> while (E) continue; - * - * Revision 5.11 1991/11/03 01:11:44 eggert - * Move the warning about link breaking to where they're actually being broken. - * - * Revision 5.10 1991/10/07 17:32:46 eggert - * Support piece tables even if !has_mmap. Fix rare NFS bugs. - * - * Revision 5.9 1991/09/17 19:07:40 eggert - * SGI readlink() yields ENXIO, not EINVAL, for nonlinks. - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Add piece tables, NFS bug workarounds. Catch odd filenames. Tune. - * - * Revision 5.7 1991/04/21 11:58:21 eggert - * Fix errno bugs. Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.6 1991/02/25 07:12:40 eggert - * Fix setuid bug. Support new link behavior. Work around broken "w+" fopen. - * - * Revision 5.5 1990/12/30 05:07:35 eggert - * Fix report of busy RCS files when !defined(O_CREAT) | !defined(O_EXCL). - * - * Revision 5.4 1990/11/01 05:03:40 eggert - * Permit arbitrary data in comment leaders. - * - * Revision 5.3 1990/09/11 02:41:13 eggert - * Tune expandline(). - * - * Revision 5.2 1990/09/04 08:02:21 eggert - * Count RCS lines better. Improve incomplete line handling. - * - * Revision 5.1 1990/08/29 07:13:56 eggert - * Add -kkvl. - * Fix bug when getting revisions to files ending in incomplete lines. - * Fix bug in comment leader expansion. - * - * Revision 5.0 1990/08/22 08:12:47 eggert - * Don't require final newline. - * Don't append "checked in with -k by " to logs, - * so that checking in a program with -k doesn't change it. - * Don't generate trailing white space for empty comment leader. - * Remove compile-time limits; use malloc instead. Add -k, -V. - * Permit dates past 1999/12/31. Make lock and temp files faster and safer. - * Ansify and Posixate. Check diff's output. - * - * Revision 4.8 89/05/01 15:12:35 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.7 88/11/08 13:54:14 narten - * misplaced semicolon caused infinite loop - * - * Revision 4.6 88/08/09 19:12:45 eggert - * Shrink stdio code size; allow cc -R. - * - * Revision 4.5 87/12/18 11:38:46 narten - * Changes from the 43. version. Don't know the significance of the - * first change involving "rewind". Also, additional "lint" cleanup. - * (Guy Harris) - * - * Revision 4.4 87/10/18 10:32:21 narten - * Updating version numbers. Changes relative to version 1.1 actually - * relative to 4.1 - * - * Revision 1.4 87/09/24 13:59:29 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.3 87/09/15 16:39:39 shepler - * added an initializatin of the variables editline and linecorr - * this will be done each time a file is processed. - * (there was an obscure bug where if co was used to retrieve multiple files - * it would dump) - * fix attributed to Roy Morris @FileNet Corp ...!felix!roy - * - * Revision 1.2 87/03/27 14:22:17 jenkins - * Port to suns - * - * Revision 4.1 83/05/12 13:10:30 wft - * Added new markers Id and RCSfile; added locker to Header and Id. - * Overhauled expandline completely() (problem with $01234567890123456789@). - * Moved trymatch() and marker table to rcskeys.c. - * - * Revision 3.7 83/05/12 13:04:39 wft - * Added retry to expandline to resume after failed match which ended in $. - * Fixed truncation problem for $19chars followed by@@. - * Log no longer expands full path of RCS file. - * - * Revision 3.6 83/05/11 16:06:30 wft - * added retry to expandline to resume after failed match which ended in $. - * Fixed truncation problem for $19chars followed by@@. - * - * Revision 3.5 82/12/04 13:20:56 wft - * Added expansion of keyword Locker. - * - * Revision 3.4 82/12/03 12:26:54 wft - * Added line number correction in case editing does not start at the - * beginning of the file. - * Changed keyword expansion to always print a space before closing KDELIM; - * Expansion for Header shortened. - * - * Revision 3.3 82/11/14 14:49:30 wft - * removed Suffix from keyword expansion. Replaced fclose with ffclose. - * keyreplace() gets log message from delta, not from curlogmsg. - * fixed expression overflow in while(c=putc(GETC.... - * checked nil printing. - * - * Revision 3.2 82/10/18 21:13:39 wft - * I added checks for write errors during the co process, and renamed - * expandstring() to xpandstring(). - * - * Revision 3.1 82/10/13 15:52:55 wft - * changed type of result of getc() from char to int. - * made keyword expansion loop in expandline() portable to machines - * without sign-extension. - */ - - -#include "rcsbase.h" - -libId(editId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsedit.c 76301 2001-05-06 03:07:12Z kris $") - -static void editEndsPrematurely P((void)) exiting; -static void editLineNumberOverflow P((void)) exiting; -static void escape_string P((FILE*,char const*)); -static void keyreplace P((enum markers,struct hshentry const*,int,RILE*,FILE*,int)); - -FILE *fcopy; /* result file descriptor */ -char const *resultname; /* result pathname */ -int locker_expansion; /* should the locker name be appended to Id val? */ -#if !large_memory - static RILE *fedit; /* edit file descriptor */ - static char const *editname; /* edit pathname */ -#endif -static long editline; /* edit line counter; #lines before cursor */ -static long linecorr; /* #adds - #deletes in each edit run. */ - /*used to correct editline in case file is not rewound after */ - /* applying one delta */ - -/* indexes into dirtpname */ -#define lockdirtp_index 0 -#define newRCSdirtp_index bad_creat0 -#define newworkdirtp_index (newRCSdirtp_index+1) -#define DIRTEMPNAMES (newworkdirtp_index + 1) - -enum maker {notmade, real, effective}; -static struct buf dirtpname[DIRTEMPNAMES]; /* unlink these when done */ -static enum maker volatile dirtpmaker[DIRTEMPNAMES]; /* if these are set */ -#define lockname (dirtpname[lockdirtp_index].string) -#define newRCSname (dirtpname[newRCSdirtp_index].string) - - -#if has_NFS || bad_unlink - int -un_link(s) - char const *s; -/* - * Remove S, even if it is unwritable. - * Ignore unlink() ENOENT failures; NFS generates bogus ones. - */ -{ -# if bad_unlink - if (unlink(s) == 0) - return 0; - else { - int e = errno; - /* - * Forge ahead even if errno == ENOENT; some completely - * brain-damaged hosts (e.g. PCTCP 2.2) yield ENOENT - * even for existing unwritable files. - */ - if (chmod(s, S_IWUSR) != 0) { - errno = e; - return -1; - } - } -# endif -# if has_NFS - return unlink(s)==0 || errno==ENOENT ? 0 : -1; -# else - return unlink(s); -# endif -} -#endif - -#if !has_rename -# if !has_NFS -# define do_link(s,t) link(s,t) -# else - static int do_link P((char const*,char const*)); - static int -do_link(s, t) - char const *s, *t; -/* Link S to T, ignoring bogus EEXIST problems due to NFS failures. */ -{ - int r = link(s, t); - - if (r != 0 && errno == EEXIST) { - struct stat sb, tb; - if ( - stat(s, &sb) == 0 && - stat(t, &tb) == 0 && - same_file(sb, tb, 0) - ) - r = 0; - errno = EEXIST; - } - return r; -} -# endif -#endif - - - static void -editEndsPrematurely() -{ - fatserror("edit script ends prematurely"); -} - - static void -editLineNumberOverflow() -{ - fatserror("edit script refers to line past end of file"); -} - - -#if large_memory - -#if has_memmove -# define movelines(s1, s2, n) VOID memmove(s1, s2, (n)*sizeof(Iptr_type)) -#else - static void movelines P((Iptr_type*,Iptr_type const*,long)); - static void -movelines(s1, s2, n) - register Iptr_type *s1; - register Iptr_type const *s2; - register long n; -{ - if (s1 < s2) - do { - *s1++ = *s2++; - } while (--n); - else { - s1 += n; - s2 += n; - do { - *--s1 = *--s2; - } while (--n); - } -} -#endif - -static void deletelines P((long,long)); -static void finisheditline P((RILE*,FILE*,Iptr_type,struct hshentry const*)); -static void insertline P((long,Iptr_type)); -static void snapshotline P((FILE*,Iptr_type)); - -/* - * `line' contains pointers to the lines in the currently `edited' file. - * It is a 0-origin array that represents linelim-gapsize lines. - * line[0 .. gap-1] and line[gap+gapsize .. linelim-1] hold pointers to lines. - * line[gap .. gap+gapsize-1] contains garbage. - * - * Any @s in lines are duplicated. - * Lines are terminated by \n, or (for a last partial line only) by single @. - */ -static Iptr_type *line; -static size_t gap, gapsize, linelim; - - static void -insertline(n, l) - long n; - Iptr_type l; -/* Before line N, insert line L. N is 0-origin. */ -{ - if (linelim-gapsize < n) - editLineNumberOverflow(); - if (!gapsize) - line = - !linelim ? - tnalloc(Iptr_type, linelim = gapsize = 1024) - : ( - gap = gapsize = linelim, - trealloc(Iptr_type, line, linelim <<= 1) - ); - if (n < gap) - movelines(line+n+gapsize, line+n, gap-n); - else if (gap < n) - movelines(line+gap, line+gap+gapsize, n-gap); - - line[n] = l; - gap = n + 1; - gapsize--; -} - - static void -deletelines(n, nlines) - long n, nlines; -/* Delete lines N through N+NLINES-1. N is 0-origin. */ -{ - long l = n + nlines; - if (linelim-gapsize < l || l < n) - editLineNumberOverflow(); - if (l < gap) - movelines(line+l+gapsize, line+l, gap-l); - else if (gap < n) - movelines(line+gap, line+gap+gapsize, n-gap); - - gap = n; - gapsize += nlines; -} - - static void -snapshotline(f, l) - register FILE *f; - register Iptr_type l; -{ - register int c; - do { - if ((c = *l++) == SDELIM && *l++ != SDELIM) - return; - aputc_(c, f) - } while (c != '\n'); -} - - void -snapshotedit(f) - FILE *f; -/* Copy the current state of the edits to F. */ -{ - register Iptr_type *p, *lim, *l=line; - for (p=l, lim=l+gap; pptr = l; - if (expandline(fin, fout, delta, true, (FILE*)0, true) < 0) - faterror("finisheditline internal error"); -} - - void -finishedit(delta, outfile, done) - struct hshentry const *delta; - FILE *outfile; - int done; -/* - * Doing expansion if DELTA is set, output the state of the edits to OUTFILE. - * But do nothing unless DONE is set (which means we are on the last pass). - */ -{ - if (done) { - openfcopy(outfile); - outfile = fcopy; - if (!delta) - snapshotedit(outfile); - else { - register Iptr_type *p, *lim, *l = line; - register RILE *fin = finptr; - Iptr_type here = fin->ptr; - for (p=l, lim=l+gap; pptr = here; - } - } -} - -/* Open a temporary NAME for output, truncating any previous contents. */ -# define fopen_update_truncate(name) fopenSafer(name, FOPEN_W_WORK) -#else /* !large_memory */ - static FILE * fopen_update_truncate P((char const*)); - static FILE * -fopen_update_truncate(name) - char const *name; -{ - if (bad_fopen_wplus && un_link(name) != 0) - efaterror(name); - return fopenSafer(name, FOPEN_WPLUS_WORK); -} -#endif - - - void -openfcopy(f) - FILE *f; -{ - if (!(fcopy = f)) { - if (!resultname) - resultname = maketemp(2); - if (!(fcopy = fopen_update_truncate(resultname))) - efaterror(resultname); - } -} - - -#if !large_memory - - static void swapeditfiles P((FILE*)); - static void -swapeditfiles(outfile) - FILE *outfile; -/* Function: swaps resultname and editname, assigns fedit=fcopy, - * and rewinds fedit for reading. Set fcopy to outfile if nonnull; - * otherwise, set fcopy to be resultname opened for reading and writing. - */ -{ - char const *tmpptr; - - editline = 0; linecorr = 0; - Orewind(fcopy); - fedit = fcopy; - tmpptr=editname; editname=resultname; resultname=tmpptr; - openfcopy(outfile); -} - - void -snapshotedit(f) - FILE *f; -/* Copy the current state of the edits to F. */ -{ - finishedit((struct hshentry *)0, (FILE*)0, false); - fastcopy(fedit, f); - Irewind(fedit); -} - - void -finishedit(delta, outfile, done) - struct hshentry const *delta; - FILE *outfile; - int done; -/* copy the rest of the edit file and close it (if it exists). - * if delta, perform keyword substitution at the same time. - * If DONE is set, we are finishing the last pass. - */ -{ - register RILE *fe; - register FILE *fc; - - fe = fedit; - if (fe) { - fc = fcopy; - if (delta) { - while (1 < expandline(fe,fc,delta,false,(FILE*)0,true)) - ; - } else { - fastcopy(fe,fc); - } - Ifclose(fe); - } - if (!done) - swapeditfiles(outfile); -} -#endif - - - -#if large_memory -# define copylines(upto,delta) (editline = (upto)) -#else - static void copylines P((long,struct hshentry const*)); - static void -copylines(upto, delta) - register long upto; - struct hshentry const *delta; -/* - * Copy input lines editline+1..upto from fedit to fcopy. - * If delta, keyword expansion is done simultaneously. - * editline is updated. Rewinds a file only if necessary. - */ -{ - register int c; - declarecache; - register FILE *fc; - register RILE *fe; - - if (upto < editline) { - /* swap files */ - finishedit((struct hshentry *)0, (FILE*)0, false); - /* assumes edit only during last pass, from the beginning*/ - } - fe = fedit; - fc = fcopy; - if (editline < upto) - if (delta) - do { - if (expandline(fe,fc,delta,false,(FILE*)0,true) <= 1) - editLineNumberOverflow(); - } while (++editline < upto); - else { - setupcache(fe); cache(fe); - do { - do { - cachegeteof_(c, editLineNumberOverflow();) - aputc_(c, fc) - } while (c != '\n'); - } while (++editline < upto); - uncache(fe); - } -} -#endif - - - - void -xpandstring(delta) - struct hshentry const *delta; -/* Function: Reads a string terminated by SDELIM from finptr and writes it - * to fcopy. Double SDELIM is replaced with single SDELIM. - * Keyword expansion is performed with data from delta. - * If foutptr is nonnull, the string is also copied unchanged to foutptr. - */ -{ - while (1 < expandline(finptr,fcopy,delta,true,foutptr,true)) - continue; -} - - - void -copystring() -/* Function: copies a string terminated with a single SDELIM from finptr to - * fcopy, replacing all double SDELIM with a single SDELIM. - * If foutptr is nonnull, the string also copied unchanged to foutptr. - * editline is incremented by the number of lines copied. - * Assumption: next character read is first string character. - */ -{ register c; - declarecache; - register FILE *frew, *fcop; - register int amidline; - register RILE *fin; - - fin = finptr; - setupcache(fin); cache(fin); - frew = foutptr; - fcop = fcopy; - amidline = false; - for (;;) { - GETC_(frew,c) - switch (c) { - case '\n': - ++editline; - ++rcsline; - amidline = false; - break; - case SDELIM: - GETC_(frew,c) - if (c != SDELIM) { - /* end of string */ - nextc = c; - editline += amidline; - uncache(fin); - return; - } - /* fall into */ - default: - amidline = true; - break; - } - aputc_(c,fcop) - } -} - - - void -enterstring() -/* Like copystring, except the string is put into the edit data structure. */ -{ -#if !large_memory - editname = 0; - fedit = 0; - editline = linecorr = 0; - resultname = maketemp(1); - if (!(fcopy = fopen_update_truncate(resultname))) - efaterror(resultname); - copystring(); -#else - register int c; - declarecache; - register FILE *frew; - register long e, oe; - register int amidline, oamidline; - register Iptr_type optr; - register RILE *fin; - - e = 0; - gap = 0; - gapsize = linelim; - fin = finptr; - setupcache(fin); cache(fin); - advise_access(fin, MADV_NORMAL); - frew = foutptr; - amidline = false; - for (;;) { - optr = cacheptr(); - GETC_(frew,c) - oamidline = amidline; - oe = e; - switch (c) { - case '\n': - ++e; - ++rcsline; - amidline = false; - break; - case SDELIM: - GETC_(frew,c) - if (c != SDELIM) { - /* end of string */ - nextc = c; - editline = e + amidline; - linecorr = 0; - uncache(fin); - return; - } - /* fall into */ - default: - amidline = true; - break; - } - if (!oamidline) - insertline(oe, optr); - } -#endif -} - - - - - void -#if large_memory -edit_string() -#else - editstring(delta) - struct hshentry const *delta; -#endif -/* - * Read an edit script from finptr and applies it to the edit file. -#if !large_memory - * The result is written to fcopy. - * If delta, keyword expansion is performed simultaneously. - * If running out of lines in fedit, fedit and fcopy are swapped. - * editname is the name of the file that goes with fedit. -#endif - * If foutptr is set, the edit script is also copied verbatim to foutptr. - * Assumes that all these files are open. - * resultname is the name of the file that goes with fcopy. - * Assumes the next input character from finptr is the first character of - * the edit script. Resets nextc on exit. - */ -{ - int ed; /* editor command */ - register int c; - declarecache; - register FILE *frew; -# if !large_memory - register FILE *f; - long line_lim = LONG_MAX; - register RILE *fe; -# endif - register long i; - register RILE *fin; -# if large_memory - register long j; -# endif - struct diffcmd dc; - - editline += linecorr; linecorr=0; /*correct line number*/ - frew = foutptr; - fin = finptr; - setupcache(fin); - initdiffcmd(&dc); - while (0 <= (ed = getdiffcmd(fin,true,frew,&dc))) -#if !large_memory - if (line_lim <= dc.line1) - editLineNumberOverflow(); - else -#endif - if (!ed) { - copylines(dc.line1-1, delta); - /* skip over unwanted lines */ - i = dc.nlines; - linecorr -= i; - editline += i; -# if large_memory - deletelines(editline+linecorr, i); -# else - fe = fedit; - do { - /*skip next line*/ - do { - Igeteof_(fe, c, { if (i!=1) editLineNumberOverflow(); line_lim = dc.dafter; break; } ) - } while (c != '\n'); - } while (--i); -# endif - } else { - /* Copy lines without deleting any. */ - copylines(dc.line1, delta); - i = dc.nlines; -# if large_memory - j = editline+linecorr; -# endif - linecorr += i; -#if !large_memory - f = fcopy; - if (delta) - do { - switch (expandline(fin,f,delta,true,frew,true)){ - case 0: case 1: - if (i==1) - return; - /* fall into */ - case -1: - editEndsPrematurely(); - } - } while (--i); - else -#endif - { - cache(fin); - do { -# if large_memory - insertline(j++, cacheptr()); -# endif - for (;;) { - GETC_(frew, c) - if (c==SDELIM) { - GETC_(frew, c) - if (c!=SDELIM) { - if (--i) - editEndsPrematurely(); - nextc = c; - uncache(fin); - return; - } - } -# if !large_memory - aputc_(c, f) -# endif - if (c == '\n') - break; - } - ++rcsline; - } while (--i); - uncache(fin); - } - } -} - - - -/* The rest is for keyword expansion */ - - - - int -expandline(infile, outfile, delta, delimstuffed, frewfile, dolog) - RILE *infile; - FILE *outfile, *frewfile; - struct hshentry const *delta; - int delimstuffed, dolog; -/* - * Read a line from INFILE and write it to OUTFILE. - * Do keyword expansion with data from DELTA. - * If DELIMSTUFFED is true, double SDELIM is replaced with single SDELIM. - * If FREWFILE is set, copy the line unchanged to FREWFILE. - * DELIMSTUFFED must be true if FREWFILE is set. - * Append revision history to log only if DOLOG is set. - * Yields -1 if no data is copied, 0 if an incomplete line is copied, - * 2 if a complete line is copied; adds 1 to yield if expansion occurred. - */ -{ - register c; - declarecache; - register FILE *out, *frew; - register char * tp; - register int e, ds, r; - char const *tlim; - static struct buf keyval; - enum markers matchresult; - - setupcache(infile); cache(infile); - out = outfile; - frew = frewfile; - ds = delimstuffed; - bufalloc(&keyval, keylength+3); - e = 0; - r = -1; - - for (;;) { - if (ds) - GETC_(frew, c) - else - cachegeteof_(c, goto uncache_exit;) - for (;;) { - switch (c) { - case SDELIM: - if (ds) { - GETC_(frew, c) - if (c != SDELIM) { - /* end of string */ - nextc=c; - goto uncache_exit; - } - } - /* fall into */ - default: - aputc_(c,out) - r = 0; - break; - - case '\n': - rcsline += ds; - aputc_(c,out) - r = 2; - goto uncache_exit; - - case KDELIM: - r = 0; - /* check for keyword */ - /* first, copy a long enough string into keystring */ - tp = keyval.string; - *tp++ = KDELIM; - for (;;) { - if (ds) - GETC_(frew, c) - else - cachegeteof_(c, goto keystring_eof;) - if (tp <= &keyval.string[keylength]) - switch (ctab[c]) { - case LETTER: case Letter: - *tp++ = c; - continue; - default: - break; - } - break; - } - *tp++ = c; *tp = '\0'; - matchresult = trymatch(keyval.string+1); - if (matchresult==Nomatch) { - tp[-1] = 0; - aputs(keyval.string, out); - continue; /* last c handled properly */ - } - - /* Now we have a keyword terminated with a K/VDELIM */ - if (c==VDELIM) { - /* try to find closing KDELIM, and replace value */ - tlim = keyval.string + keyval.size; - for (;;) { - if (ds) - GETC_(frew, c) - else - cachegeteof_(c, goto keystring_eof;) - if (c=='\n' || c==KDELIM) - break; - *tp++ =c; - if (tlim <= tp) - tp = bufenlarge(&keyval, &tlim); - if (c==SDELIM && ds) { /*skip next SDELIM */ - GETC_(frew, c) - if (c != SDELIM) { - /* end of string before closing KDELIM or newline */ - nextc = c; - goto keystring_eof; - } - } - } - if (c!=KDELIM) { - /* couldn't find closing KDELIM -- give up */ - *tp = 0; - aputs(keyval.string, out); - continue; /* last c handled properly */ - } - } - /* now put out the new keyword value */ - uncache(infile); - keyreplace(matchresult, delta, ds, infile, out, dolog); - cache(infile); - e = 1; - break; - } - break; - } - } - - keystring_eof: - *tp = 0; - aputs(keyval.string, out); - uncache_exit: - uncache(infile); - return r + e; -} - - - static void -escape_string(out, s) - register FILE *out; - register char const *s; -/* Output to OUT the string S, escaping chars that would break `ci -k'. */ -{ - register char c; - for (;;) - switch ((c = *s++)) { - case 0: return; - case '\t': aputs("\\t", out); break; - case '\n': aputs("\\n", out); break; - case ' ': aputs("\\040", out); break; - case KDELIM: aputs("\\044", out); break; - case '\\': if (VERSION(5)<=RCSversion) {aputs("\\\\", out); break;} - /* fall into */ - default: aputc_(c, out) break; - } -} - -char const ciklog[ciklogsize] = "checked in with -k by "; - - static void -keyreplace(marker, delta, delimstuffed, infile, out, dolog) - enum markers marker; - register struct hshentry const *delta; - int delimstuffed; - RILE *infile; - register FILE *out; - int dolog; -/* function: outputs the keyword value(s) corresponding to marker. - * Attributes are derived from delta. - */ -{ - register char const *sp, *cp, *date; - register int c; - register size_t cs, cw, ls; - char const *sp1; - char datebuf[datesize + zonelenmax]; - int RCSv; - int exp; - - sp = Keyword[(int)marker]; - exp = Expand; - date = delta->date; - RCSv = RCSversion; - - if (exp != VAL_EXPAND) - aprintf(out, "%c%s", KDELIM, sp); - if (exp != KEY_EXPAND) { - - if (exp != VAL_EXPAND) - aprintf(out, "%c%c", VDELIM, - marker==Log && RCSvauthor, out); - break; - case Date: - aputs(date2str(date,datebuf), out); - break; - case Id: - case LocalId: - case Header: - case CVSHeader: - if (marker == Id || RCSv < VERSION(4) || - (marker == LocalId && LocalIdMode == Id)) - escape_string(out, basefilename(RCSname)); - else if (marker == CVSHeader || - (marker == LocalId && LocalIdMode == CVSHeader)) - escape_string(out, getfullCVSname()); - else - escape_string(out, getfullRCSname()); - aprintf(out, " %s %s %s %s", - delta->num, - date2str(date, datebuf), - delta->author, - RCSv==VERSION(3) && delta->lockedby ? "Locked" - : delta->state - ); - if (delta->lockedby) - if (VERSION(5) <= RCSv) { - if (locker_expansion || exp==KEYVALLOCK_EXPAND) - aprintf(out, " %s", delta->lockedby); - } else if (RCSv == VERSION(4)) - aprintf(out, " Locker: %s", delta->lockedby); - break; - case Locker: - if (delta->lockedby) - if ( - locker_expansion - || exp == KEYVALLOCK_EXPAND - || RCSv <= VERSION(4) - ) - aputs(delta->lockedby, out); - break; - case Log: - case RCSfile: - escape_string(out, basefilename(RCSname)); - break; - case Name: - if (delta->name) - aputs(delta->name, out); - break; - case Revision: - aputs(delta->num, out); - break; - case Source: - escape_string(out, getfullRCSname()); - break; - case State: - aputs(delta->state, out); - break; - default: - break; - } - if (exp != VAL_EXPAND) - afputc(' ', out); - } - if (exp != VAL_EXPAND) - afputc(KDELIM, out); - - if (marker == Log && dolog) { - struct buf leader; - - sp = delta->log.string; - ls = delta->log.size; - if (sizeof(ciklog)-1<=ls && !memcmp(sp,ciklog,sizeof(ciklog)-1)) - return; - bufautobegin(&leader); - if (RCSversion < VERSION(5)) { - cp = Comment.string; - cs = Comment.size; - } else { - int kdelim_found = 0; - Ioffset_type chars_read = Itell(infile); - declarecache; - setupcache(infile); cache(infile); - - c = 0; /* Pacify `gcc -Wall'. */ - - /* - * Back up to the start of the current input line, - * setting CS to the number of characters before `$Log'. - */ - cs = 0; - for (;;) { - if (!--chars_read) - goto done_backing_up; - cacheunget_(infile, c) - if (c == '\n') - break; - if (c == SDELIM && delimstuffed) { - if (!--chars_read) - break; - cacheunget_(infile, c) - if (c != SDELIM) { - cacheget_(c) - break; - } - } - cs += kdelim_found; - kdelim_found |= c==KDELIM; - } - cacheget_(c) - done_backing_up:; - - /* Copy characters before `$Log' into LEADER. */ - bufalloc(&leader, cs); - cp = leader.string; - for (cw = 0; cw < cs; cw++) { - leader.string[cw] = c; - if (c == SDELIM && delimstuffed) - cacheget_(c) - cacheget_(c) - } - - /* Convert traditional C or Pascal leader to ` *'. */ - for (cw = 0; cw < cs; cw++) - if (ctab[(unsigned char) cp[cw]] != SPACE) - break; - if ( - cw+1 < cs - && cp[cw+1] == '*' - && (cp[cw] == '/' || cp[cw] == '(') - ) { - size_t i = cw+1; - for (;;) - if (++i == cs) { - warn( - "`%c* $Log' is obsolescent; use ` * $Log'.", - cp[cw] - ); - leader.string[cw] = ' '; - break; - } else if (ctab[(unsigned char) cp[i]] != SPACE) - break; - } - - /* Skip `$Log ... $' string. */ - do { - cacheget_(c) - } while (c != KDELIM); - uncache(infile); - } - afputc('\n', out); - awrite(cp, cs, out); - sp1 = date2str(date, datebuf); - if (VERSION(5) <= RCSv) { - aprintf(out, "Revision %s %s %s", - delta->num, sp1, delta->author - ); - } else { - /* oddity: 2 spaces between date and time, not 1 as usual */ - sp1 = strchr(sp1, ' '); - aprintf(out, "Revision %s %.*s %s %s", - delta->num, (int)(sp1-datebuf), datebuf, sp1, - delta->author - ); - } - /* Do not include state: it may change and is not updated. */ - cw = cs; - if (VERSION(5) <= RCSv) - for (; cw && (cp[cw-1]==' ' || cp[cw-1]=='\t'); --cw) - continue; - for (;;) { - afputc('\n', out); - awrite(cp, cw, out); - if (!ls) - break; - --ls; - c = *sp++; - if (c != '\n') { - awrite(cp+cw, cs-cw, out); - do { - afputc(c,out); - if (!ls) - break; - --ls; - c = *sp++; - } while (c != '\n'); - } - } - bufautoend(&leader); - } -} - -#if has_readlink - static int resolve_symlink P((struct buf*)); - static int -resolve_symlink(L) - struct buf *L; -/* - * If L is a symbolic link, resolve it to the name that it points to. - * If unsuccessful, set errno and yield -1. - * If it points to an existing file, yield 1. - * Otherwise, set errno=ENOENT and yield 0. - */ -{ - char *b, a[SIZEABLE_PATH]; - int e; - size_t s; - ssize_t r; - struct buf bigbuf; - int linkcount = MAXSYMLINKS; - - b = a; - s = sizeof(a); - bufautobegin(&bigbuf); - while ((r = readlink(L->string,b,s)) != -1) - if (r == s) { - bufalloc(&bigbuf, s<<1); - b = bigbuf.string; - s = bigbuf.size; - } else if (!linkcount--) { -# ifndef ELOOP - /* - * Some pedantic Posix 1003.1-1990 hosts have readlink - * but not ELOOP. Approximate ELOOP with EMLINK. - */ -# define ELOOP EMLINK -# endif - errno = ELOOP; - return -1; - } else { - /* Splice symbolic link into L. */ - b[r] = '\0'; - L->string[ - ROOTPATH(b) ? 0 : basefilename(L->string) - L->string - ] = '\0'; - bufscat(L, b); - } - e = errno; - bufautoend(&bigbuf); - errno = e; - switch (e) { - case readlink_isreg_errno: return 1; - case ENOENT: return 0; - default: return -1; - } -} -#endif - - RILE * -rcswriteopen(RCSbuf, status, mustread) - struct buf *RCSbuf; - struct stat *status; - int mustread; -/* - * Create the lock file corresponding to RCSBUF. - * Then try to open RCSBUF for reading and yield its RILE* descriptor. - * Put its status into *STATUS too. - * MUSTREAD is true if the file must already exist, too. - * If all goes well, discard any previously acquired locks, - * and set fdlock to the file descriptor of the RCS lockfile. - */ -{ - register char *tp; - register char const *sp, *RCSpath, *x; - RILE *f; - size_t l; - int e, exists, fdesc, fdescSafer, r, waslocked; - struct buf *dirt; - struct stat statbuf; - - waslocked = 0 <= fdlock; - exists = -# if has_readlink - resolve_symlink(RCSbuf); -# else - stat(RCSbuf->string, &statbuf) == 0 ? 1 - : errno==ENOENT ? 0 : -1; -# endif - if (exists < (mustread|waslocked)) - /* - * There's an unusual problem with the RCS file; - * or the RCS file doesn't exist, - * and we must read or we already have a lock elsewhere. - */ - return 0; - - RCSpath = RCSbuf->string; - sp = basefilename(RCSpath); - l = sp - RCSpath; - dirt = &dirtpname[waslocked]; - bufscpy(dirt, RCSpath); - tp = dirt->string + l; - x = rcssuffix(RCSpath); -# if has_readlink - if (!x) { - error("symbolic link to non RCS file `%s'", RCSpath); - errno = EINVAL; - return 0; - } -# endif - if (*sp == *x) { - error("RCS pathname `%s' incompatible with suffix `%s'", sp, x); - errno = EINVAL; - return 0; - } - /* Create a lock filename that is a function of the RCS filename. */ - if (*x) { - /* - * The suffix is nonempty. - * The lock filename is the first char of of the suffix, - * followed by the RCS filename with last char removed. E.g.: - * foo,v RCS filename with suffix ,v - * ,foo, lock filename - */ - *tp++ = *x; - while (*sp) - *tp++ = *sp++; - *--tp = 0; - } else { - /* - * The suffix is empty. - * The lock filename is the RCS filename - * with last char replaced by '_'. - */ - while ((*tp++ = *sp++)) - continue; - tp -= 2; - if (*tp == '_') { - error("RCS pathname `%s' ends with `%c'", RCSpath, *tp); - errno = EINVAL; - return 0; - } - *tp = '_'; - } - - sp = dirt->string; - - f = 0; - - /* - * good news: - * open(f, O_CREAT|O_EXCL|O_TRUNC|..., OPEN_CREAT_READONLY) - * is atomic according to Posix 1003.1-1990. - * bad news: - * NFS ignores O_EXCL and doesn't comply with Posix 1003.1-1990. - * good news: - * (O_TRUNC,OPEN_CREAT_READONLY) normally guarantees atomicity - * even with NFS. - * bad news: - * If you're root, (O_TRUNC,OPEN_CREAT_READONLY) doesn't - * guarantee atomicity. - * good news: - * Root-over-the-wire NFS access is rare for security reasons. - * This bug has never been reported in practice with RCS. - * So we don't worry about this bug. - * - * An even rarer NFS bug can occur when clients retry requests. - * This can happen in the usual case of NFS over UDP. - * Suppose client A releases a lock by renaming ",f," to "f,v" at - * about the same time that client B obtains a lock by creating ",f,", - * and suppose A's first rename request is delayed, so A reissues it. - * The sequence of events might be: - * A sends rename(",f,", "f,v") - * B sends create(",f,") - * A sends retry of rename(",f,", "f,v") - * server receives, does, and acknowledges A's first rename() - * A receives acknowledgment, and its RCS program exits - * server receives, does, and acknowledges B's create() - * server receives, does, and acknowledges A's retry of rename() - * This not only wrongly deletes B's lock, it removes the RCS file! - * Most NFS implementations have idempotency caches that usually prevent - * this scenario, but such caches are finite and can be overrun. - * This problem afflicts not only RCS, which uses open() and rename() - * to get and release locks; it also afflicts the traditional - * Unix method of using link() and unlink() to get and release locks, - * and the less traditional method of using mkdir() and rmdir(). - * There is no easy workaround. - * Any new method based on lockf() seemingly would be incompatible with - * the old methods; besides, lockf() is notoriously buggy under NFS. - * Since this problem afflicts scads of Unix programs, but is so rare - * that nobody seems to be worried about it, we won't worry either. - */ -# if !open_can_creat -# define create(f) creat(f, OPEN_CREAT_READONLY) -# else -# define create(f) open(f, OPEN_O_BINARY|OPEN_O_LOCK|OPEN_O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, OPEN_CREAT_READONLY) -# endif - - catchints(); - ignoreints(); - - /* - * Create a lock file for an RCS file. This should be atomic, i.e. - * if two processes try it simultaneously, at most one should succeed. - */ - seteid(); - fdesc = create(sp); - fdescSafer = fdSafer(fdesc); /* Do it now; setrid might use stderr. */ - e = errno; - setrid(); - - if (0 <= fdesc) - dirtpmaker[0] = effective; - - if (fdescSafer < 0) { - if (e == EACCES && stat(sp,&statbuf) == 0) - /* The RCS file is busy. */ - e = EEXIST; - } else { - e = ENOENT; - if (exists) { - f = Iopen(RCSpath, FOPEN_RB, status); - e = errno; - if (f && waslocked) { - /* Discard the previous lock in favor of this one. */ - ORCSclose(); - seteid(); - r = un_link(lockname); - e = errno; - setrid(); - if (r != 0) - enfaterror(e, lockname); - bufscpy(&dirtpname[lockdirtp_index], sp); - } - } - fdlock = fdescSafer; - } - - restoreints(); - - errno = e; - return f; -} - - void -keepdirtemp(name) - char const *name; -/* Do not unlink name, either because it's not there any more, - * or because it has already been unlinked. - */ -{ - register int i; - for (i=DIRTEMPNAMES; 0<=--i; ) - if (dirtpname[i].string == name) { - dirtpmaker[i] = notmade; - return; - } - faterror("keepdirtemp"); -} - - char const * -makedirtemp(isworkfile) - int isworkfile; -/* - * Create a unique pathname and store it into dirtpname. - * Because of storage in tpnames, dirtempunlink() can unlink the file later. - * Return a pointer to the pathname created. - * If ISWORKFILE is 1, put it into the working file's directory; - * if 0, put the unique file in RCSfile's directory. - */ -{ - register char *tp, *np; - register size_t dl; - register struct buf *bn; - register char const *name = isworkfile ? workname : RCSname; -# if has_mktemp - int fd; -# endif - - dl = basefilename(name) - name; - bn = &dirtpname[newRCSdirtp_index + isworkfile]; - bufalloc(bn, -# if has_mktemp - dl + 9 -# else - strlen(name) + 3 -# endif - ); - bufscpy(bn, name); - np = tp = bn->string; - tp += dl; - *tp++ = '_'; - *tp++ = '0'+isworkfile; - catchints(); -# if has_mktemp - VOID strcpy(tp, "XXXXXX"); - fd = mkstemp(np); - if (fd < 0 || !*np) - faterror("can't make temporary pathname `%.*s_%cXXXXXX'", - (int)dl, name, '0'+isworkfile - ); - close(fd); -# else - /* - * Posix 1003.1-1990 has no reliable way - * to create a unique file in a named directory. - * We fudge here. If the filename is abcde, - * the temp filename is _Ncde where N is a digit. - */ - name += dl; - if (*name) name++; - if (*name) name++; - VOID strcpy(tp, name); -# endif - dirtpmaker[newRCSdirtp_index + isworkfile] = real; - return np; -} - - void -dirtempunlink() -/* Clean up makedirtemp() files. May be invoked by signal handler. */ -{ - register int i; - enum maker m; - - for (i = DIRTEMPNAMES; 0 <= --i; ) - if ((m = dirtpmaker[i]) != notmade) { - if (m == effective) - seteid(); - VOID un_link(dirtpname[i].string); - if (m == effective) - setrid(); - dirtpmaker[i] = notmade; - } -} - - - int -#if has_prototypes -chnamemod( - FILE **fromp, char const *from, char const *to, - int set_mode, mode_t mode, time_t mtime -) - /* The `#if has_prototypes' is needed because mode_t might promote to int. */ -#else - chnamemod(fromp, from, to, set_mode, mode, mtime) - FILE **fromp; char const *from,*to; - int set_mode; mode_t mode; time_t mtime; -#endif -/* - * Rename a file (with stream pointer *FROMP) from FROM to TO. - * FROM already exists. - * If 0 < SET_MODE, change the mode to MODE, before renaming if possible. - * If MTIME is not -1, change its mtime to MTIME before renaming. - * Close and clear *FROMP before renaming it. - * Unlink TO if it already exists. - * Return -1 on error (setting errno), 0 otherwise. - */ -{ - mode_t mode_while_renaming = mode; - int fchmod_set_mode = 0; - -# if bad_a_rename || bad_NFS_rename - struct stat st; - if (bad_NFS_rename || (bad_a_rename && set_mode <= 0)) { - if (fstat(fileno(*fromp), &st) != 0) - return -1; - if (bad_a_rename && set_mode <= 0) - mode = st.st_mode; - } -# endif - -# if bad_a_rename - /* - * There's a short window of inconsistency - * during which the lock file is writable. - */ - mode_while_renaming = mode|S_IWUSR; - if (mode != mode_while_renaming) - set_mode = 1; -# endif - -# if has_fchmod - if (0nextlock) - if (strcmp(getcaller(), next->login) == 0) { - if (found) { - rcserror("multiple revisions locked by %s; please specify one", getcaller()); - return 2; - } - found = trail; - } - if (!found) - return 0; - next = *found; - *target = next->delta; - if (delete) { - next->delta->lockedby = 0; - *found = next->nextlock; - } - return 1; -} - - int -addlock(delta, verbose) - struct hshentry * delta; - int verbose; -/* - * Add a lock held by caller to DELTA and yield 1 if successful. - * Print an error message if verbose and yield -1 if no lock is added because - * DELTA is locked by somebody other than caller. - * Return 0 if the caller already holds the lock. - */ -{ - register struct rcslock *next; - - for (next = Locks; next; next = next->nextlock) - if (cmpnum(delta->num, next->delta->num) == 0) - if (strcmp(getcaller(), next->login) == 0) - return 0; - else { - if (verbose) - rcserror("Revision %s is already locked by %s.", - delta->num, next->login - ); - return -1; - } - next = ftalloc(struct rcslock); - delta->lockedby = next->login = getcaller(); - next->delta = delta; - next->nextlock = Locks; - Locks = next; - return 1; -} - - - int -addsymbol(num, name, rebind) - char const *num, *name; - int rebind; -/* - * Associate with revision NUM the new symbolic NAME. - * If NAME already exists and REBIND is set, associate NAME with NUM; - * otherwise, print an error message and return false; - * Return -1 if unsuccessful, 0 if no change, 1 if change. - */ -{ - register struct assoc *next; - - for (next = Symbols; next; next = next->nextassoc) - if (strcmp(name, next->symbol) == 0) - if (strcmp(next->num,num) == 0) - return 0; - else if (rebind) { - next->num = num; - return 1; - } else { - rcserror("symbolic name %s already bound to %s", - name, next->num - ); - return -1; - } - next = ftalloc(struct assoc); - next->symbol = name; - next->num = num; - next->nextassoc = Symbols; - Symbols = next; - return 1; -} - - - - char const * -getcaller() -/* Get the caller's login name. */ -{ -# if has_setuid - return getusername(euid()!=ruid()); -# else - return getusername(false); -# endif -} - - - int -checkaccesslist() -/* - * Return true if caller is the superuser, the owner of the - * file, the access list is empty, or caller is on the access list. - * Otherwise, print an error message and return false. - */ -{ - register struct access const *next; - - if (!AccessList || myself(RCSstat.st_uid) || strcmp(getcaller(),"root")==0) - return true; - - next = AccessList; - do { - if (strcmp(getcaller(), next->login) == 0) - return true; - } while ((next = next->nextaccess)); - - rcserror("user %s not on the access list", getcaller()); - return false; -} - - - int -dorewrite(lockflag, changed) - int lockflag, changed; -/* - * Do nothing if LOCKFLAG is zero. - * Prepare to rewrite an RCS file if CHANGED is positive. - * Stop rewriting if CHANGED is zero, because there won't be any changes. - * Fail if CHANGED is negative. - * Return 0 on success, -1 on failure. - */ -{ - int r = 0, e; - - if (lockflag) - if (changed) { - if (changed < 0) - return -1; - putadmin(); - puttree(Head, frewrite); - aprintf(frewrite, "\n\n%s%c", Kdesc, nextc); - foutptr = frewrite; - } else { -# if bad_creat0 - int nr = !!frewrite, ne = 0; -# endif - ORCSclose(); - seteid(); - ignoreints(); -# if bad_creat0 - if (nr) { - nr = un_link(newRCSname); - ne = errno; - keepdirtemp(newRCSname); - } -# endif - r = un_link(lockname); - e = errno; - keepdirtemp(lockname); - restoreints(); - setrid(); - if (r != 0) - enerror(e, lockname); -# if bad_creat0 - if (nr != 0) { - enerror(ne, newRCSname); - r = -1; - } -# endif - } - return r; -} - - int -donerewrite(changed, newRCStime) - int changed; - time_t newRCStime; -/* - * Finish rewriting an RCS file if CHANGED is nonzero. - * Set its mode if CHANGED is positive. - * Set its modification time to NEWRCSTIME unless it is -1. - * Return 0 on success, -1 on failure. - */ -{ - int r = 0, e = 0; -# if bad_creat0 - int lr, le; -# endif - - if (changed && !nerror) { - if (finptr) { - fastcopy(finptr, frewrite); - Izclose(&finptr); - } - if (1 < RCSstat.st_nlink) - rcswarn("breaking hard link"); - aflush(frewrite); - seteid(); - ignoreints(); - r = chnamemod( - &frewrite, newRCSname, RCSname, changed, - RCSstat.st_mode & (mode_t)~(S_IWUSR|S_IWGRP|S_IWOTH), - newRCStime - ); - e = errno; - keepdirtemp(newRCSname); -# if bad_creat0 - lr = un_link(lockname); - le = errno; - keepdirtemp(lockname); -# endif - restoreints(); - setrid(); - if (r != 0) { - enerror(e, RCSname); - error("saved in %s", newRCSname); - } -# if bad_creat0 - if (lr != 0) { - enerror(le, lockname); - r = -1; - } -# endif - } - return r; -} - - void -ORCSclose() -{ - if (0 <= fdlock) { - if (close(fdlock) != 0) - efaterror(lockname); - fdlock = -1; - } - Ozclose(&frewrite); -} - - void -ORCSerror() -/* -* Like ORCSclose, except we are cleaning up after an interrupt or fatal error. -* Do not report errors, since this may loop. This is needed only because -* some brain-damaged hosts (e.g. OS/2) cannot unlink files that are open, and -* some nearly-Posix hosts (e.g. NFS) work better if the files are closed first. -* This isn't a completely reliable away to work around brain-damaged hosts, -* because of the gap between actual file opening and setting frewrite etc., -* but it's better than nothing. -*/ -{ - if (0 <= fdlock) - VOID close(fdlock); - if (frewrite) - /* Avoid fclose, since stdio may not be reentrant. */ - VOID close(fileno(frewrite)); -} diff --git a/gnu/usr.bin/rcs/lib/rcsfcmp.c b/gnu/usr.bin/rcs/lib/rcsfcmp.c deleted file mode 100644 index 4237c40df44..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsfcmp.c +++ /dev/null @@ -1,354 +0,0 @@ -/* Compare working files, ignoring RCS keyword strings. */ - -/***************************************************************************** - * rcsfcmp() - * Testprogram: define FCMPTEST - ***************************************************************************** - */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - - - - - -/* - * Revision 5.14 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.13 1995/06/01 16:23:43 eggert - * (rcsfcmp): Add -kb support. - * - * Revision 5.12 1994/03/17 14:05:48 eggert - * Normally calculate the $Log prefix from context, not from RCS file. - * Calculate line numbers correctly even if the $Log prefix contains newlines. - * Remove lint. - * - * Revision 5.11 1993/11/03 17:42:27 eggert - * Fix yet another off-by-one error when comparing Log string expansions. - * - * Revision 5.10 1992/07/28 16:12:44 eggert - * Statement macro names now end in _. - * - * Revision 5.9 1991/10/07 17:32:46 eggert - * Count log lines correctly. - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Tune. - * - * Revision 5.7 1991/04/21 11:58:22 eggert - * Fix errno bug. Add MS-DOS support. - * - * Revision 5.6 1991/02/28 19:18:47 eggert - * Open work file at most once. - * - * Revision 5.5 1990/11/27 09:26:05 eggert - * Fix comment leader bug. - * - * Revision 5.4 1990/11/01 05:03:42 eggert - * Permit arbitrary data in logs and comment leaders. - * - * Revision 5.3 1990/09/11 02:41:15 eggert - * Don't ignore differences inside keyword strings if -ko is set. - * - * Revision 5.1 1990/08/29 07:13:58 eggert - * Clean old log messages too. - * - * Revision 5.0 1990/08/22 08:12:49 eggert - * Don't append "checked in with -k by " log to logs, - * so that checking in a program with -k doesn't change it. - * Ansify and Posixate. Remove lint. - * - * Revision 4.5 89/05/01 15:12:42 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 88/08/09 19:12:50 eggert - * Shrink stdio code size. - * - * Revision 4.3 87/12/18 11:40:02 narten - * lint cleanups (Guy Harris) - * - * Revision 4.2 87/10/18 10:33:06 narten - * updting version number. Changes relative to 1.1 actually relative to - * 4.1 - * - * Revision 1.2 87/03/27 14:22:19 jenkins - * Port to suns - * - * Revision 4.1 83/05/10 16:24:04 wft - * Marker matching now uses trymatch(). Marker pattern is now - * checked precisely. - * - * Revision 3.1 82/12/04 13:21:40 wft - * Initial revision. - * - */ - -/* -#define FCMPTEST -*/ -/* Testprogram; prints out whether two files are identical, - * except for keywords - */ - -#include "rcsbase.h" - -libId(fcmpId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsfcmp.c 50472 1999-08-27 23:37:10Z peter $") - - static int discardkeyval P((int,RILE*)); - static int -discardkeyval(c, f) - register int c; - register RILE *f; -{ - for (;;) - switch (c) { - case KDELIM: - case '\n': - return c; - default: - Igeteof_(f, c, return EOF;) - break; - } -} - - int -rcsfcmp(xfp, xstatp, uname, delta) - register RILE *xfp; - struct stat const *xstatp; - char const *uname; - struct hshentry const *delta; -/* Compare the files xfp and uname. Return zero - * if xfp has the same contents as uname and neither has keywords, - * otherwise -1 if they are the same ignoring keyword values, - * and 1 if they differ even ignoring - * keyword values. For the LOG-keyword, rcsfcmp skips the log message - * given by the parameter delta in xfp. Thus, rcsfcmp returns nonpositive - * if xfp contains the same as uname, with the keywords expanded. - * Implementation: character-by-character comparison until $ is found. - * If a $ is found, read in the marker keywords; if they are real keywords - * and identical, read in keyword value. If value is terminated properly, - * disregard it and optionally skip log message; otherwise, compare value. - */ -{ - register int xc, uc; - char xkeyword[keylength+2]; - int eqkeyvals; - register RILE *ufp; - register int xeof, ueof; - register char * tp; - register char const *sp; - register size_t leaderlen; - int result; - enum markers match1; - struct stat ustat; - - if (!(ufp = Iopen(uname, FOPEN_R_WORK, &ustat))) { - efaterror(uname); - } - xeof = ueof = false; - if (MIN_UNEXPAND <= Expand) { - if (!(result = xstatp->st_size!=ustat.st_size)) { -# if large_memory && maps_memory - result = !!memcmp(xfp->base,ufp->base,(size_t)xstatp->st_size); -# else - for (;;) { - /* get the next characters */ - Igeteof_(xfp, xc, xeof=true;) - Igeteof_(ufp, uc, ueof=true;) - if (xeof | ueof) - goto eof; - if (xc != uc) - goto return1; - } -# endif - } - } else { - xc = 0; - uc = 0; /* Keep lint happy. */ - leaderlen = 0; - result = 0; - - for (;;) { - if (xc != KDELIM) { - /* get the next characters */ - Igeteof_(xfp, xc, xeof=true;) - Igeteof_(ufp, uc, ueof=true;) - if (xeof | ueof) - goto eof; - } else { - /* try to get both keywords */ - tp = xkeyword; - for (;;) { - Igeteof_(xfp, xc, xeof=true;) - Igeteof_(ufp, uc, ueof=true;) - if (xeof | ueof) - goto eof; - if (xc != uc) - break; - switch (xc) { - default: - if (xkeyword+keylength <= tp) - break; - *tp++ = xc; - continue; - case '\n': case KDELIM: case VDELIM: - break; - } - break; - } - if ( - (xc==KDELIM || xc==VDELIM) && (uc==KDELIM || uc==VDELIM) && - (*tp = xc, (match1 = trymatch(xkeyword)) != Nomatch) - ) { -#ifdef FCMPTEST - VOID printf("found common keyword %s\n",xkeyword); -#endif - result = -1; - for (;;) { - if (xc != uc) { - xc = discardkeyval(xc, xfp); - uc = discardkeyval(uc, ufp); - if ((xeof = xc==EOF) | (ueof = uc==EOF)) - goto eof; - eqkeyvals = false; - break; - } - switch (xc) { - default: - Igeteof_(xfp, xc, xeof=true;) - Igeteof_(ufp, uc, ueof=true;) - if (xeof | ueof) - goto eof; - continue; - - case '\n': case KDELIM: - eqkeyvals = true; - break; - } - break; - } - if (xc != uc) - goto return1; - if (xc==KDELIM) { - /* Skip closing KDELIM. */ - Igeteof_(xfp, xc, xeof=true;) - Igeteof_(ufp, uc, ueof=true;) - if (xeof | ueof) - goto eof; - /* if the keyword is LOG, also skip the log message in xfp*/ - if (match1==Log) { - /* first, compute the number of line feeds in log msg */ - int lncnt; - size_t ls, ccnt; - sp = delta->log.string; - ls = delta->log.size; - if (ls31 chars) name. - * while (E) ; -> while (E) continue; - * - * Revision 5.8 1991/09/24 00:28:40 eggert - * Don't export bindex(). - * - * Revision 5.7 1991/08/19 03:13:55 eggert - * Fix messages when rcswriteopen fails. - * Look in $TMP and $TEMP if $TMPDIR isn't set. Tune. - * - * Revision 5.6 1991/04/21 11:58:23 eggert - * Fix errno bugs. Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.5 1991/02/26 17:48:38 eggert - * Fix setuid bug. Support new link behavior. - * Define more portable getcwd(). - * - * Revision 5.4 1990/11/01 05:03:43 eggert - * Permit arbitrary data in comment leaders. - * - * Revision 5.3 1990/09/14 22:56:16 hammer - * added more filename extensions and their comment leaders - * - * Revision 5.2 1990/09/04 08:02:23 eggert - * Fix typo when !RCSSEP. - * - * Revision 5.1 1990/08/29 07:13:59 eggert - * Work around buggy compilers with defective argument promotion. - * - * Revision 5.0 1990/08/22 08:12:50 eggert - * Ignore signals when manipulating the semaphore file. - * Modernize list of filename extensions. - * Permit paths of arbitrary length. Beware filenames beginning with "-". - * Remove compile-time limits; use malloc instead. - * Permit dates past 1999/12/31. Make lock and temp files faster and safer. - * Ansify and Posixate. - * Don't use access(). Fix test for non-regular files. Tune. - * - * Revision 4.8 89/05/01 15:09:41 narten - * changed getwd to not stat empty directories. - * - * Revision 4.7 88/08/09 19:12:53 eggert - * Fix troff macro comment leader bug; add Prolog; allow cc -R; remove lint. - * - * Revision 4.6 87/12/18 11:40:23 narten - * additional file types added from 4.3 BSD version, and SPARC assembler - * comment character added. Also, more lint cleanups. (Guy Harris) - * - * Revision 4.5 87/10/18 10:34:16 narten - * Updating version numbers. Changes relative to 1.1 actually relative - * to verion 4.3 - * - * Revision 1.3 87/03/27 14:22:21 jenkins - * Port to suns - * - * Revision 1.2 85/06/26 07:34:28 svb - * Comment leader '% ' for '*.tex' files added. - * - * Revision 4.3 83/12/15 12:26:48 wft - * Added check for KDELIM in filenames to pairfilenames(). - * - * Revision 4.2 83/12/02 22:47:45 wft - * Added csh, red, and sl filename suffixes. - * - * Revision 4.1 83/05/11 16:23:39 wft - * Added initialization of Dbranch to InitAdmin(). Canged pairfilenames(): - * 1. added copying of path from workfile to RCS file, if RCS file is omitted; - * 2. added getting the file status of RCS and working files; - * 3. added ignoring of directories. - * - * Revision 3.7 83/05/11 15:01:58 wft - * Added comtable[] which pairs filename suffixes with comment leaders; - * updated InitAdmin() accordingly. - * - * Revision 3.6 83/04/05 14:47:36 wft - * fixed Suffix in InitAdmin(). - * - * Revision 3.5 83/01/17 18:01:04 wft - * Added getwd() and rename(); these can be removed by defining - * V4_2BSD, since they are not needed in 4.2 bsd. - * Changed sys/param.h to sys/types.h. - * - * Revision 3.4 82/12/08 21:55:20 wft - * removed unused variable. - * - * Revision 3.3 82/11/28 20:31:37 wft - * Changed mktempfile() to store the generated filenames. - * Changed getfullRCSname() to store the file and pathname, and to - * delete leading "../" and "./". - * - * Revision 3.2 82/11/12 14:29:40 wft - * changed pairfilenames() to handle file.sfx,v; also deleted checkpathnosfx(), - * checksuffix(), checkfullpath(). Semaphore name generation updated. - * mktempfile() now checks for nil path; freefilename initialized properly. - * Added Suffix .h to InitAdmin. Added testprogram PAIRTEST. - * Moved rmsema, trysema, trydiraccess, getfullRCSname from rcsutil.c to here. - * - * Revision 3.1 82/10/18 14:51:28 wft - * InitAdmin() now initializes StrictLocks=STRICT_LOCKING (def. in rcsbase.h). - * renamed checkpath() to checkfullpath(). - */ - - -#include "rcsbase.h" - -libId(fnmsId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsfnms.c 76301 2001-05-06 03:07:12Z kris $") - -static char const *bindex P((char const*,int)); -static int fin2open P((char const*, size_t, char const*, size_t, char const*, size_t, RILE*(*)P((struct buf*,struct stat*,int)), int)); -static int finopen P((RILE*(*)P((struct buf*,struct stat*,int)), int)); -static int suffix_matches P((char const*,char const*)); -static size_t dir_useful_len P((char const*)); -static size_t suffixlen P((char const*)); -static void InitAdmin P((void)); - -char const *RCSname; -char *workname; -int fdlock; -FILE *workstdout; -struct stat RCSstat; -char const *suffixes; - -static char const rcsdir[] = "RCS"; -#define rcslen (sizeof(rcsdir)-1) - -static struct buf RCSbuf, RCSb; -static int RCSerrno; - - -/* Temp names to be unlinked when done, if they are not 0. */ -#define TEMPNAMES 5 /* must be at least DIRTEMPNAMES (see rcsedit.c) */ -static char *volatile tpnames[TEMPNAMES]; - - -struct compair { - char const *suffix, *comlead; -}; - -/* -* This table is present only for backwards compatibility. -* Normally we ignore this table, and use the prefix of the `$Log' line instead. -*/ -static struct compair const comtable[] = { - { "a" , "-- " }, /* Ada */ - { "ada" , "-- " }, - { "adb" , "-- " }, - { "ads" , "-- " }, - { "asm" , ";; " }, /* assembler (MS-DOS) */ - { "bat" , ":: " }, /* batch (MS-DOS) */ - { "body", "-- " }, /* Ada */ - { "c" , " * " }, /* C */ - { "c++" , "// " }, /* C++ in all its infinite guises */ - { "cc" , "// " }, - { "cpp" , "// " }, - { "cxx" , "// " }, - { "cl" , ";;; "}, /* Common Lisp */ - { "cmd" , ":: " }, /* command (OS/2) */ - { "cmf" , "c " }, /* CM Fortran */ - { "cs" , " * " }, /* C* */ - { "el" , "; " }, /* Emacs Lisp */ - { "f" , "c " }, /* Fortran */ - { "for" , "c " }, - { "h" , " * " }, /* C-header */ - { "hpp" , "// " }, /* C++ header */ - { "hxx" , "// " }, - { "l" , " * " }, /* lex (NOTE: franzlisp disagrees) */ - { "lisp", ";;; "}, /* Lucid Lisp */ - { "lsp" , ";; " }, /* Microsoft Lisp */ - { "m" , "// " }, /* Objective C */ - { "mac" , ";; " }, /* macro (DEC-10, MS-DOS, PDP-11, VMS, etc) */ - { "me" , ".\\\" "}, /* troff -me */ - { "ml" , "; " }, /* mocklisp */ - { "mm" , ".\\\" "}, /* troff -mm */ - { "ms" , ".\\\" "}, /* troff -ms */ - { "p" , " * " }, /* Pascal */ - { "pas" , " * " }, - { "ps" , "% " }, /* PostScript */ - { "spec", "-- " }, /* Ada */ - { "sty" , "% " }, /* LaTeX style */ - { "tex" , "% " }, /* TeX */ - { "y" , " * " }, /* yacc */ - { 0 , "# " } /* default for unknown suffix; must be last */ -}; - -#if has_mktemp - static char const *tmp P((void)); - static char const * -tmp() -/* Yield the name of the tmp directory. */ -{ - static char const *s; - if (!s - && !(s = cgetenv("TMPDIR")) /* Unix tradition */ - && !(s = cgetenv("TMP")) /* DOS tradition */ - && !(s = cgetenv("TEMP")) /* another DOS tradition */ - ) - s = TMPDIR; - return s; -} -#endif - - char const * -maketemp(n) - int n; -/* Create a unique pathname using n and the process id and store it - * into the nth slot in tpnames. - * Because of storage in tpnames, tempunlink() can unlink the file later. - * Return a pointer to the pathname created. - */ -{ - char *p; - char const *t = tpnames[n]; -# if has_mktemp - int fd; -# endif - - if (t) - return t; - - catchints(); - { -# if has_mktemp - char const *tp = tmp(); - size_t tplen = dir_useful_len(tp); - p = testalloc(tplen + 10); - VOID sprintf(p, "%.*s%cT%cXXXXXX", (int)tplen, tp, SLASH, '0'+n); - fd = mkstemp(p); - if (fd < 0 || !*p) - faterror("can't make temporary pathname `%.*s%cT%cXXXXXX'", - (int)tplen, tp, SLASH, '0'+n - ); - close(fd); -# else - static char tpnamebuf[TEMPNAMES][L_tmpnam]; - p = tpnamebuf[n]; - if (!tmpnam(p) || !*p) -# ifdef P_tmpdir - faterror("can't make temporary pathname `%s...'",P_tmpdir); -# else - faterror("can't make temporary pathname"); -# endif -# endif - } - - tpnames[n] = p; - return p; -} - - void -tempunlink() -/* Clean up maketemp() files. May be invoked by signal handler. - */ -{ - register int i; - register char *p; - - for (i = TEMPNAMES; 0 <= --i; ) - if ((p = tpnames[i])) { - VOID unlink(p); - /* - * We would tfree(p) here, - * but this might dump core if we're handing a signal. - * We're about to exit anyway, so we won't bother. - */ - tpnames[i] = 0; - } -} - - - static char const * -bindex(sp, c) - register char const *sp; - register int c; -/* Function: Finds the last occurrence of character c in string sp - * and returns a pointer to the character just beyond it. If the - * character doesn't occur in the string, sp is returned. - */ -{ - register char const *r; - r = sp; - while (*sp) { - if (*sp++ == c) r=sp; - } - return r; -} - - - - static int -suffix_matches(suffix, pattern) - register char const *suffix, *pattern; -{ - register int c; - if (!pattern) - return true; - for (;;) - switch (*suffix++ - (c = *pattern++)) { - case 0: - if (!c) - return true; - break; - - case 'A'-'a': - if (ctab[c] == Letter) - break; - /* fall into */ - default: - return false; - } -} - - - static void -InitAdmin() -/* function: initializes an admin node */ -{ - register char const *Suffix; - register int i; - - Head=0; Dbranch=0; AccessList=0; Symbols=0; Locks=0; - StrictLocks=STRICT_LOCKING; - - /* guess the comment leader from the suffix*/ - Suffix = bindex(workname, '.'); - if (Suffix==workname) Suffix= ""; /* empty suffix; will get default*/ - for (i=0; !suffix_matches(Suffix,comtable[i].suffix); i++) - continue; - Comment.string = comtable[i].comlead; - Comment.size = strlen(comtable[i].comlead); - Expand = KEYVAL_EXPAND; - clear_buf(&Ignored); - Lexinit(); /* note: if !finptr, reads nothing; only initializes */ -} - - - - void -bufalloc(b, size) - register struct buf *b; - size_t size; -/* Ensure *B is a name buffer of at least SIZE bytes. - * *B's old contents can be freed; *B's new contents are undefined. - */ -{ - if (b->size < size) { - if (b->size) - tfree(b->string); - else - b->size = sizeof(malloc_type); - while (b->size < size) - b->size <<= 1; - b->string = tnalloc(char, b->size); - } -} - - void -bufrealloc(b, size) - register struct buf *b; - size_t size; -/* like bufalloc, except *B's old contents, if any, are preserved */ -{ - if (b->size < size) { - if (!b->size) - bufalloc(b, size); - else { - while ((b->size <<= 1) < size) - continue; - b->string = trealloc(char, b->string, b->size); - } - } -} - - void -bufautoend(b) - struct buf *b; -/* Free an auto buffer at block exit. */ -{ - if (b->size) - tfree(b->string); -} - - struct cbuf -bufremember(b, s) - struct buf *b; - size_t s; -/* - * Free the buffer B with used size S. - * Yield a cbuf with identical contents. - * The cbuf will be reclaimed when this input file is finished. - */ -{ - struct cbuf cb; - - if ((cb.size = s)) - cb.string = fremember(trealloc(char, b->string, s)); - else { - bufautoend(b); /* not really auto */ - cb.string = ""; - } - return cb; -} - - char * -bufenlarge(b, alim) - register struct buf *b; - char const **alim; -/* Make *B larger. Set *ALIM to its new limit, and yield the relocated value - * of its old limit. - */ -{ - size_t s = b->size; - bufrealloc(b, s + 1); - *alim = b->string + b->size; - return b->string + s; -} - - void -bufscat(b, s) - struct buf *b; - char const *s; -/* Concatenate S to B's end. */ -{ - size_t blen = b->string ? strlen(b->string) : 0; - bufrealloc(b, blen+strlen(s)+1); - VOID strcpy(b->string+blen, s); -} - - void -bufscpy(b, s) - struct buf *b; - char const *s; -/* Copy S into B. */ -{ - bufalloc(b, strlen(s)+1); - VOID strcpy(b->string, s); -} - - - char const * -basefilename(p) - char const *p; -/* Yield the address of the base filename of the pathname P. */ -{ - register char const *b = p, *q = p; - for (;;) - switch (*q++) { - case SLASHes: b = q; break; - case 0: return b; - } -} - - - static size_t -suffixlen(x) - char const *x; -/* Yield the length of X, an RCS pathname suffix. */ -{ - register char const *p; - - p = x; - for (;;) - switch (*p) { - case 0: case SLASHes: - return p - x; - - default: - ++p; - continue; - } -} - - char const * -rcssuffix(name) - char const *name; -/* Yield the suffix of NAME if it is an RCS pathname, 0 otherwise. */ -{ - char const *x, *p, *nz; - size_t nl, xl; - - nl = strlen(name); - nz = name + nl; - x = suffixes; - do { - if ((xl = suffixlen(x))) { - if (xl <= nl && memcmp(p = nz-xl, x, xl) == 0) - return p; - } else - for (p = name; p < nz - rcslen; p++) - if ( - isSLASH(p[rcslen]) - && (p==name || isSLASH(p[-1])) - && memcmp(p, rcsdir, rcslen) == 0 - ) - return nz; - x += xl; - } while (*x++); - return 0; -} - - /*ARGSUSED*/ RILE * -rcsreadopen(RCSpath, status, mustread) - struct buf *RCSpath; - struct stat *status; - int mustread; -/* Open RCSPATH for reading and yield its FILE* descriptor. - * If successful, set *STATUS to its status. - * Pass this routine to pairnames() for read-only access to the file. */ -{ - return Iopen(RCSpath->string, FOPEN_RB, status); -} - - static int -finopen(rcsopen, mustread) - RILE *(*rcsopen)P((struct buf*,struct stat*,int)); - int mustread; -/* - * Use RCSOPEN to open an RCS file; MUSTREAD is set if the file must be read. - * Set finptr to the result and yield true if successful. - * RCSb holds the file's name. - * Set RCSbuf to the best RCS name found so far, and RCSerrno to its errno. - * Yield true if successful or if an unusual failure. - */ -{ - int interesting, preferold; - - /* - * We prefer an old name to that of a nonexisting new RCS file, - * unless we tried locking the old name and failed. - */ - preferold = RCSbuf.string[0] && (mustread||0<=fdlock); - - finptr = (*rcsopen)(&RCSb, &RCSstat, mustread); - interesting = finptr || errno!=ENOENT; - if (interesting || !preferold) { - /* Use the new name. */ - RCSerrno = errno; - bufscpy(&RCSbuf, RCSb.string); - } - return interesting; -} - - static int -fin2open(d, dlen, base, baselen, x, xlen, rcsopen, mustread) - char const *d, *base, *x; - size_t dlen, baselen, xlen; - RILE *(*rcsopen)P((struct buf*,struct stat*,int)); - int mustread; -/* - * D is a directory name with length DLEN (including trailing slash). - * BASE is a filename with length BASELEN. - * X is an RCS pathname suffix with length XLEN. - * Use RCSOPEN to open an RCS file; MUSTREAD is set if the file must be read. - * Yield true if successful. - * Try dRCS/basex first; if that fails and x is nonempty, try dbasex. - * Put these potential names in RCSb. - * Set RCSbuf to the best RCS name found so far, and RCSerrno to its errno. - * Yield true if successful or if an unusual failure. - */ -{ - register char *p; - - bufalloc(&RCSb, dlen + rcslen + 1 + baselen + xlen + 1); - - /* Try dRCS/basex. */ - VOID memcpy(p = RCSb.string, d, dlen); - VOID memcpy(p += dlen, rcsdir, rcslen); - p += rcslen; - *p++ = SLASH; - VOID memcpy(p, base, baselen); - VOID memcpy(p += baselen, x, xlen); - p[xlen] = 0; - if (xlen) { - if (finopen(rcsopen, mustread)) - return true; - - /* Try dbasex. */ - /* Start from scratch, because finopen() may have changed RCSb. */ - VOID memcpy(p = RCSb.string, d, dlen); - VOID memcpy(p += dlen, base, baselen); - VOID memcpy(p += baselen, x, xlen); - p[xlen] = 0; - } - return finopen(rcsopen, mustread); -} - - int -pairnames(argc, argv, rcsopen, mustread, quiet) - int argc; - char **argv; - RILE *(*rcsopen)P((struct buf*,struct stat*,int)); - int mustread, quiet; -/* - * Pair the pathnames pointed to by argv; argc indicates - * how many there are. - * Place a pointer to the RCS pathname into RCSname, - * and a pointer to the pathname of the working file into workname. - * If both are given, and workstdout - * is set, a warning is printed. - * - * If the RCS file exists, places its status into RCSstat. - * - * If the RCS file exists, it is RCSOPENed for reading, the file pointer - * is placed into finptr, and the admin-node is read in; returns 1. - * If the RCS file does not exist and MUSTREAD, - * print an error unless QUIET and return 0. - * Otherwise, initialize the admin node and return -1. - * - * 0 is returned on all errors, e.g. files that are not regular files. - */ -{ - static struct buf tempbuf; - - register char *p, *arg, *RCS1; - char const *base, *RCSbase, *x; - int paired; - size_t arglen, dlen, baselen, xlen; - - fdlock = -1; - - if (!(arg = *argv)) return 0; /* already paired pathname */ - if (*arg == '-') { - error("%s option is ignored after pathnames", arg); - return 0; - } - - base = basefilename(arg); - paired = false; - - /* first check suffix to see whether it is an RCS file or not */ - if ((x = rcssuffix(arg))) - { - /* RCS pathname given */ - RCS1 = arg; - RCSbase = base; - baselen = x - base; - if ( - 1 < argc && - !rcssuffix(workname = p = argv[1]) && - baselen <= (arglen = strlen(p)) && - ((p+=arglen-baselen) == workname || isSLASH(p[-1])) && - memcmp(base, p, baselen) == 0 - ) { - argv[1] = 0; - paired = true; - } else { - bufscpy(&tempbuf, base); - workname = p = tempbuf.string; - p[baselen] = 0; - } - } else { - /* working file given; now try to find RCS file */ - workname = arg; - baselen = strlen(base); - /* Derive RCS pathname. */ - if ( - 1 < argc && - (x = rcssuffix(RCS1 = argv[1])) && - baselen <= x - RCS1 && - ((RCSbase=x-baselen)==RCS1 || isSLASH(RCSbase[-1])) && - memcmp(base, RCSbase, baselen) == 0 - ) { - argv[1] = 0; - paired = true; - } else - RCSbase = RCS1 = 0; - } - /* Now we have a (tentative) RCS pathname in RCS1 and workname. */ - /* Second, try to find the right RCS file */ - if (RCSbase!=RCS1) { - /* a path for RCSfile is given; single RCS file to look for */ - bufscpy(&RCSbuf, RCS1); - finptr = (*rcsopen)(&RCSbuf, &RCSstat, mustread); - RCSerrno = errno; - } else { - bufscpy(&RCSbuf, ""); - if (RCS1) - /* RCS filename was given without path. */ - VOID fin2open(arg, (size_t)0, RCSbase, baselen, - x, strlen(x), rcsopen, mustread - ); - else { - /* No RCS pathname was given. */ - /* Try each suffix in turn. */ - dlen = base-arg; - x = suffixes; - while (! fin2open(arg, dlen, base, baselen, - x, xlen=suffixlen(x), rcsopen, mustread - )) { - x += xlen; - if (!*x++) - break; - } - } - } - RCSname = p = RCSbuf.string; - if (finptr) { - if (!S_ISREG(RCSstat.st_mode)) { - error("%s isn't a regular file -- ignored", p); - return 0; - } - Lexinit(); getadmin(); - } else { - if (RCSerrno!=ENOENT || mustread || fdlock<0) { - if (RCSerrno == EEXIST) - error("RCS file %s is in use", p); - else if (!quiet || RCSerrno!=ENOENT) - enerror(RCSerrno, p); - return 0; - } - InitAdmin(); - }; - - if (paired && workstdout) - workwarn("Working file ignored due to -p option"); - - prevkeys = false; - return finptr ? 1 : -1; -} - - - char const * -getfullRCSname() -/* - * Return a pointer to the full pathname of the RCS file. - * Remove leading `./'. - */ -{ - if (ROOTPATH(RCSname)) { - return RCSname; - } else { - static struct buf rcsbuf; -# if needs_getabsname - bufalloc(&rcsbuf, SIZEABLE_PATH + 1); - while (getabsname(RCSname, rcsbuf.string, rcsbuf.size) != 0) - if (errno == ERANGE) - bufalloc(&rcsbuf, rcsbuf.size<<1); - else - efaterror("getabsname"); -# else - static char const *wdptr; - static struct buf wdbuf; - static size_t wdlen; - - register char const *r; - register size_t dlen; - register char *d; - register char const *wd; - - if (!(wd = wdptr)) { - /* Get working directory for the first time. */ - char *PWD = cgetenv("PWD"); - struct stat PWDstat, dotstat; - if (! ( - (d = PWD) && - ROOTPATH(PWD) && - stat(PWD, &PWDstat) == 0 && - stat(".", &dotstat) == 0 && - same_file(PWDstat, dotstat, 1) - )) { - bufalloc(&wdbuf, SIZEABLE_PATH + 1); -# if has_getcwd || !has_getwd - while (!(d = getcwd(wdbuf.string, wdbuf.size))) - if (errno == ERANGE) - bufalloc(&wdbuf, wdbuf.size<<1); - else if ((d = PWD)) - break; - else - efaterror("getcwd"); -# else - d = getwd(wdbuf.string); - if (!d && !(d = PWD)) - efaterror("getwd"); -# endif - } - wdlen = dir_useful_len(d); - d[wdlen] = 0; - wdptr = wd = d; - } - /* - * Remove leading `./'s from RCSname. - * Do not try to handle `../', since removing it may yield - * the wrong answer in the presence of symbolic links. - */ - for (r = RCSname; r[0]=='.' && isSLASH(r[1]); r += 2) - /* `.////' is equivalent to `./'. */ - while (isSLASH(r[2])) - r++; - /* Build full pathname. */ - dlen = wdlen; - bufalloc(&rcsbuf, dlen + strlen(r) + 2); - d = rcsbuf.string; - VOID memcpy(d, wd, dlen); - d += dlen; - *d++ = SLASH; - VOID strcpy(d, r); -# endif - return rcsbuf.string; - } -} - -/* Derived from code from the XFree86 project */ - char const * -getfullCVSname() -/* Function: returns a pointer to the path name of the RCS file with the - * CVSROOT part stripped off, and with 'Attic/' stripped off (if present). - */ -{ - -#define ATTICDIR "/Attic" - - char const *namebuf = getfullRCSname(); - char *cvsroot = cgetenv("CVSROOT"); - int cvsrootlen; - char *c = NULL; - int alen = strlen(ATTICDIR); - - if ((c = strrchr(namebuf, '/')) != NULL) { - if (namebuf - c >= alen) { - if (!strncmp(c - alen, ATTICDIR, alen)) { - while(*c != '\0') { - *(c - alen) = *c; - c++; - } - *(c - alen) = '\0'; - } - } - } - - if (!cvsroot) - return(namebuf); - else - { - cvsrootlen = strlen(cvsroot); - if (!strncmp(namebuf, cvsroot, cvsrootlen) && - namebuf[cvsrootlen] == '/') - return(namebuf + cvsrootlen + 1); - else - return(namebuf); - } -} - - static size_t -dir_useful_len(d) - char const *d; -/* -* D names a directory; yield the number of characters of D's useful part. -* To create a file in D, append a SLASH and a file name to D's useful part. -* Ignore trailing slashes if possible; not only are they ugly, -* but some non-Posix systems misbehave unless the slashes are omitted. -*/ -{ -# ifndef SLASHSLASH_is_SLASH -# define SLASHSLASH_is_SLASH 0 -# endif - size_t dlen = strlen(d); - if (!SLASHSLASH_is_SLASH && dlen==2 && isSLASH(d[0]) && isSLASH(d[1])) - --dlen; - else - while (dlen && isSLASH(d[dlen-1])) - --dlen; - return dlen; -} - -#ifndef isSLASH - int -isSLASH(c) - int c; -{ - switch (c) { - case SLASHes: - return true; - default: - return false; - } -} -#endif - - -#if !has_getcwd && !has_getwd - - char * -getcwd(path, size) - char *path; - size_t size; -{ - static char const usrbinpwd[] = "/usr/bin/pwd"; -# define binpwd (usrbinpwd+4) - - register FILE *fp; - register int c; - register char *p, *lim; - int closeerrno, closeerror, e, fd[2], readerror, toolong, wstatus; - pid_t child; - - if (!size) { - errno = EINVAL; - return 0; - } - if (pipe(fd) != 0) - return 0; -# if bad_wait_if_SIGCHLD_ignored -# ifndef SIGCHLD -# define SIGCHLD SIGCLD -# endif - VOID signal(SIGCHLD, SIG_DFL); -# endif - if (!(child = vfork())) { - if ( - close(fd[0]) == 0 && - (fd[1] == STDOUT_FILENO || -# ifdef F_DUPFD - (VOID close(STDOUT_FILENO), - fcntl(fd[1], F_DUPFD, STDOUT_FILENO)) -# else - dup2(fd[1], STDOUT_FILENO) -# endif - == STDOUT_FILENO && - close(fd[1]) == 0 - ) - ) { - VOID close(STDERR_FILENO); - VOID execl(binpwd, binpwd, (char *)0); - VOID execl(usrbinpwd, usrbinpwd, (char *)0); - } - _exit(EXIT_FAILURE); - } - e = errno; - closeerror = close(fd[1]); - closeerrno = errno; - fp = 0; - readerror = toolong = wstatus = 0; - p = path; - if (0 <= child) { - fp = fdopen(fd[0], "r"); - e = errno; - if (fp) { - lim = p + size; - for (p = path; ; *p++ = c) { - if ((c=getc(fp)) < 0) { - if (feof(fp)) - break; - if (ferror(fp)) { - readerror = 1; - e = errno; - break; - } - } - if (p == lim) { - toolong = 1; - break; - } - } - } -# if has_waitpid - if (waitpid(child, &wstatus, 0) < 0) - wstatus = 1; -# else - { - pid_t w; - do { - if ((w = wait(&wstatus)) < 0) { - wstatus = 1; - break; - } - } while (w != child); - } -# endif - } - if (!fp) { - VOID close(fd[0]); - errno = e; - return 0; - } - if (fclose(fp) != 0) - return 0; - if (readerror) { - errno = e; - return 0; - } - if (closeerror) { - errno = closeerrno; - return 0; - } - if (toolong) { - errno = ERANGE; - return 0; - } - if (wstatus || p == path || *--p != '\n') { - errno = EACCES; - return 0; - } - *p = '\0'; - return path; -} -#endif - - -#ifdef PAIRTEST -/* test program for pairnames() and getfullRCSname() */ - -char const cmdid[] = "pair"; - -main(argc, argv) -int argc; char *argv[]; -{ - int result; - int initflag; - quietflag = initflag = false; - - while(--argc, ++argv, argc>=1 && ((*argv)[0] == '-')) { - switch ((*argv)[1]) { - - case 'p': workstdout = stdout; - break; - case 'i': initflag=true; - break; - case 'q': quietflag=true; - break; - default: error("unknown option: %s", *argv); - break; - } - } - - do { - RCSname = workname = 0; - result = pairnames(argc,argv,rcsreadopen,!initflag,quietflag); - if (result!=0) { - diagnose("RCS pathname: %s; working pathname: %s\nFull RCS pathname: %s\n", - RCSname, workname, getfullRCSname() - ); - } - switch (result) { - case 0: continue; /* already paired file */ - - case 1: if (initflag) { - rcserror("already exists"); - } else { - diagnose("RCS file %s exists\n", RCSname); - } - Ifclose(finptr); - break; - - case -1:diagnose("RCS file doesn't exist\n"); - break; - } - - } while (++argv, --argc>=1); - -} - - void -exiterr() -{ - dirtempunlink(); - tempunlink(); - _exit(EXIT_FAILURE); -} -#endif diff --git a/gnu/usr.bin/rcs/lib/rcsgen.c b/gnu/usr.bin/rcs/lib/rcsgen.c deleted file mode 100644 index 10de23cf32b..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsgen.c +++ /dev/null @@ -1,681 +0,0 @@ -/* Generate RCS revisions. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.16 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.15 1995/06/01 16:23:43 eggert - * (putadmin): Open RCS file with FOPEN_WB. - * - * Revision 5.14 1994/03/17 14:05:48 eggert - * Work around SVR4 stdio performance bug. - * Flush stderr after prompt. Remove lint. - * - * Revision 5.13 1993/11/03 17:42:27 eggert - * Don't discard ignored phrases. Improve quality of diagnostics. - * - * Revision 5.12 1992/07/28 16:12:44 eggert - * Statement macro names now end in _. - * Be consistent about pathnames vs filenames. - * - * Revision 5.11 1992/01/24 18:44:19 eggert - * Move put routines here from rcssyn.c. - * Add support for bad_creat0. - * - * Revision 5.10 1991/10/07 17:32:46 eggert - * Fix log bugs, e.g. ci -t/dev/null when has_mmap. - * - * Revision 5.9 1991/09/10 22:15:46 eggert - * Fix test for redirected stdin. - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Add piece tables. Tune. - * - * Revision 5.7 1991/04/21 11:58:24 eggert - * Add MS-DOS support. - * - * Revision 5.6 1990/12/27 19:54:26 eggert - * Fix bug: rcs -t inserted \n, making RCS file grow. - * - * Revision 5.5 1990/12/04 05:18:45 eggert - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.4 1990/11/01 05:03:47 eggert - * Add -I and new -t behavior. Permit arbitrary data in logs. - * - * Revision 5.3 1990/09/21 06:12:43 hammer - * made putdesc() treat stdin the same whether or not it was from a terminal - * by making it recognize that a single '.' was then end of the - * description always - * - * Revision 5.2 1990/09/04 08:02:25 eggert - * Fix `co -p1.1 -ko' bug. Standardize yes-or-no procedure. - * - * Revision 5.1 1990/08/29 07:14:01 eggert - * Clean old log messages too. - * - * Revision 5.0 1990/08/22 08:12:52 eggert - * Remove compile-time limits; use malloc instead. - * Ansify and Posixate. - * - * Revision 4.7 89/05/01 15:12:49 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.6 88/08/28 14:59:10 eggert - * Shrink stdio code size; allow cc -R; remove lint; isatty() -> ttystdin() - * - * Revision 4.5 87/12/18 11:43:25 narten - * additional lint cleanups, and a bug fix from the 4.3BSD version that - * keeps "ci" from sticking a '\377' into the description if you run it - * with a zero-length file as the description. (Guy Harris) - * - * Revision 4.4 87/10/18 10:35:10 narten - * Updating version numbers. Changes relative to 1.1 actually relative to - * 4.2 - * - * Revision 1.3 87/09/24 13:59:51 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:27 jenkins - * Port to suns - * - * Revision 4.2 83/12/02 23:01:39 wft - * merged 4.1 and 3.3.1.1 (clearerr(stdin)). - * - * Revision 4.1 83/05/10 16:03:33 wft - * Changed putamin() to abort if trying to reread redirected stdin. - * Fixed getdesc() to output a prompt on initial newline. - * - * Revision 3.3.1.1 83/10/19 04:21:51 lepreau - * Added clearerr(stdin) for re-reading description from stdin. - * - * Revision 3.3 82/11/28 21:36:49 wft - * 4.2 prerelease - * - * Revision 3.3 82/11/28 21:36:49 wft - * Replaced ferror() followed by fclose() with ffclose(). - * Putdesc() now suppresses the prompts if stdin - * is not a terminal. A pointer to the current log message is now - * inserted into the corresponding delta, rather than leaving it in a - * global variable. - * - * Revision 3.2 82/10/18 21:11:26 wft - * I added checks for write errors during editing, and improved - * the prompt on putdesc(). - * - * Revision 3.1 82/10/13 15:55:09 wft - * corrected type of variables assigned to by getc (char --> int) - */ - - - - -#include "rcsbase.h" - -libId(genId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsgen.c 50472 1999-08-27 23:37:10Z peter $") - -int interactiveflag; /* Should we act as if stdin is a tty? */ -struct buf curlogbuf; /* buffer for current log message */ - -enum stringwork { enter, copy, edit, expand, edit_expand }; - -static void putdelta P((struct hshentry const*,FILE*)); -static void scandeltatext P((struct hshentry*,enum stringwork,int)); - - - - - char const * -buildrevision(deltas, target, outfile, expandflag) - struct hshentries const *deltas; - struct hshentry *target; - FILE *outfile; - int expandflag; -/* Function: Generates the revision given by target - * by retrieving all deltas given by parameter deltas and combining them. - * If outfile is set, the revision is output to it, - * otherwise written into a temporary file. - * Temporary files are allocated by maketemp(). - * if expandflag is set, keyword expansion is performed. - * Return 0 if outfile is set, the name of the temporary file otherwise. - * - * Algorithm: Copy initial revision unchanged. Then edit all revisions but - * the last one into it, alternating input and output files (resultname and - * editname). The last revision is then edited in, performing simultaneous - * keyword substitution (this saves one extra pass). - * All this simplifies if only one revision needs to be generated, - * or no keyword expansion is necessary, or if output goes to stdout. - */ -{ - if (deltas->first == target) { - /* only latest revision to generate */ - openfcopy(outfile); - scandeltatext(target, expandflag?expand:copy, true); - if (outfile) - return 0; - else { - Ozclose(&fcopy); - return resultname; - } - } else { - /* several revisions to generate */ - /* Get initial revision without keyword expansion. */ - scandeltatext(deltas->first, enter, false); - while ((deltas=deltas->rest)->rest) { - /* do all deltas except last one */ - scandeltatext(deltas->first, edit, false); - } - if (expandflag || outfile) { - /* first, get to beginning of file*/ - finishedit((struct hshentry*)0, outfile, false); - } - scandeltatext(target, expandflag?edit_expand:edit, true); - finishedit( - expandflag ? target : (struct hshentry*)0, - outfile, true - ); - if (outfile) - return 0; - Ozclose(&fcopy); - return resultname; - } -} - - - - static void -scandeltatext(delta, func, needlog) - struct hshentry *delta; - enum stringwork func; - int needlog; -/* Function: Scans delta text nodes up to and including the one given - * by delta. For the one given by delta, the log message is saved into - * delta->log if needlog is set; func specifies how to handle the text. - * Similarly, if needlog, delta->igtext is set to the ignored phrases. - * Assumes the initial lexeme must be read in first. - * Does not advance nexttok after it is finished. - */ -{ - struct hshentry const *nextdelta; - struct cbuf cb; - - for (;;) { - if (eoflex()) - fatserror("can't find delta for revision %s", delta->num); - nextlex(); - if (!(nextdelta=getnum())) { - fatserror("delta number corrupted"); - } - getkeystring(Klog); - if (needlog && delta==nextdelta) { - cb = savestring(&curlogbuf); - delta->log = cleanlogmsg(curlogbuf.string, cb.size); - nextlex(); - delta->igtext = getphrases(Ktext); - } else {readstring(); - ignorephrases(Ktext); - } - getkeystring(Ktext); - - if (delta==nextdelta) - break; - readstring(); /* skip over it */ - - } - switch (func) { - case enter: enterstring(); break; - case copy: copystring(); break; - case expand: xpandstring(delta); break; - case edit: editstring((struct hshentry *)0); break; - case edit_expand: editstring(delta); break; - } -} - - struct cbuf -cleanlogmsg(m, s) - char *m; - size_t s; -{ - register char *t = m; - register char const *f = t; - struct cbuf r; - while (s) { - --s; - if ((*t++ = *f++) == '\n') - while (m < --t) - if (t[-1]!=' ' && t[-1]!='\t') { - *t++ = '\n'; - break; - } - } - while (m < t && (t[-1]==' ' || t[-1]=='\t' || t[-1]=='\n')) - --t; - r.string = m; - r.size = t - m; - return r; -} - - -int ttystdin() -{ - static int initialized; - if (!initialized) { - if (!interactiveflag) - interactiveflag = isatty(STDIN_FILENO); - initialized = true; - } - return interactiveflag; -} - - int -getcstdin() -{ - register FILE *in; - register int c; - - in = stdin; - if (feof(in) && ttystdin()) - clearerr(in); - c = getc(in); - if (c == EOF) { - testIerror(in); - if (feof(in) && ttystdin()) - afputc('\n',stderr); - } - return c; -} - -#if has_prototypes - int -yesorno(int default_answer, char const *question, ...) -#else - /*VARARGS2*/ int - yesorno(default_answer, question, va_alist) - int default_answer; char const *question; va_dcl -#endif -{ - va_list args; - register int c, r; - if (!quietflag && ttystdin()) { - oflush(); - vararg_start(args, question); - fvfprintf(stderr, question, args); - va_end(args); - eflush(); - r = c = getcstdin(); - while (c!='\n' && !feof(stdin)) - c = getcstdin(); - if (r=='y' || r=='Y') - return true; - if (r=='n' || r=='N') - return false; - } - return default_answer; -} - - - void -putdesc(textflag, textfile) - int textflag; - char *textfile; -/* Function: puts the descriptive text into file frewrite. - * if finptr && !textflag, the text is copied from the old description. - * Otherwise, if textfile, the text is read from that - * file, or from stdin, if !textfile. - * A textfile with a leading '-' is treated as a string, not a pathname. - * If finptr, the old descriptive text is discarded. - * Always clears foutptr. - */ -{ - static struct buf desc; - static struct cbuf desclean; - - register FILE *txt; - register int c; - register FILE * frew; - register char *p; - register size_t s; - char const *plim; - - frew = frewrite; - if (finptr && !textflag) { - /* copy old description */ - aprintf(frew, "\n\n%s%c", Kdesc, nextc); - foutptr = frewrite; - getdesc(false); - foutptr = 0; - } else { - foutptr = 0; - /* get new description */ - if (finptr) { - /*skip old description*/ - getdesc(false); - } - aprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM); - if (!textfile) - desclean = getsstdin( - "t-", "description", - "NOTE: This is NOT the log message!\n", &desc - ); - else if (!desclean.string) { - if (*textfile == '-') { - p = textfile + 1; - s = strlen(p); - } else { - if (!(txt = fopenSafer(textfile, "r"))) - efaterror(textfile); - bufalloc(&desc, 1); - p = desc.string; - plim = p + desc.size; - for (;;) { - if ((c=getc(txt)) == EOF) { - testIerror(txt); - if (feof(txt)) - break; - } - if (plim <= p) - p = bufenlarge(&desc, &plim); - *p++ = c; - } - if (fclose(txt) != 0) - Ierror(); - s = p - desc.string; - p = desc.string; - } - desclean = cleanlogmsg(p, s); - } - putstring(frew, false, desclean, true); - aputc_('\n', frew) - } -} - - struct cbuf -getsstdin(option, name, note, buf) - char const *option, *name, *note; - struct buf *buf; -{ - register int c; - register char *p; - register size_t i; - register int tty = ttystdin(); - - if (tty) { - aprintf(stderr, - "enter %s, terminated with single '.' or end of file:\n%s>> ", - name, note - ); - eflush(); - } else if (feof(stdin)) - rcsfaterror("can't reread redirected stdin for %s; use -%s<%s>", - name, option, name - ); - - for ( - i = 0, p = 0; - c = getcstdin(), !feof(stdin); - bufrealloc(buf, i+1), p = buf->string, p[i++] = c - ) - if (c == '\n') - if (i && p[i-1]=='.' && (i==1 || p[i-2]=='\n')) { - /* Remove trailing '.'. */ - --i; - break; - } else if (tty) { - aputs(">> ", stderr); - eflush(); - } - return cleanlogmsg(p, i); -} - - - void -putadmin() -/* Output the admin node. */ -{ - register FILE *fout; - struct assoc const *curassoc; - struct rcslock const *curlock; - struct access const *curaccess; - - if (!(fout = frewrite)) { -# if bad_creat0 - ORCSclose(); - fout = fopenSafer(makedirtemp(0), FOPEN_WB); -# else - int fo = fdlock; - fdlock = -1; - fout = fdopen(fo, FOPEN_WB); -# endif - - if (!(frewrite = fout)) - efaterror(RCSname); - } - - /* - * Output the first character with putc, not printf. - * Otherwise, an SVR4 stdio bug buffers output inefficiently. - */ - aputc_(*Khead, fout) - aprintf(fout, "%s\t%s;\n", Khead + 1, Head?Head->num:""); - if (Dbranch && VERSION(4)<=RCSversion) - aprintf(fout, "%s\t%s;\n", Kbranch, Dbranch); - - aputs(Kaccess, fout); - curaccess = AccessList; - while (curaccess) { - aprintf(fout, "\n\t%s", curaccess->login); - curaccess = curaccess->nextaccess; - } - aprintf(fout, ";\n%s", Ksymbols); - curassoc = Symbols; - while (curassoc) { - aprintf(fout, "\n\t%s:%s", curassoc->symbol, curassoc->num); - curassoc = curassoc->nextassoc; - } - aprintf(fout, ";\n%s", Klocks); - curlock = Locks; - while (curlock) { - aprintf(fout, "\n\t%s:%s", curlock->login, curlock->delta->num); - curlock = curlock->nextlock; - } - if (StrictLocks) aprintf(fout, "; %s", Kstrict); - aprintf(fout, ";\n"); - if (Comment.size) { - aprintf(fout, "%s\t", Kcomment); - putstring(fout, true, Comment, false); - aprintf(fout, ";\n"); - } - if (Expand != KEYVAL_EXPAND) - aprintf(fout, "%s\t%c%s%c;\n", - Kexpand, SDELIM, expand_names[Expand], SDELIM - ); - awrite(Ignored.string, Ignored.size, fout); - aputc_('\n', fout) -} - - - static void -putdelta(node, fout) - register struct hshentry const *node; - register FILE * fout; -/* Output the delta NODE to FOUT. */ -{ - struct branchhead const *nextbranch; - - if (!node) return; - - aprintf(fout, "\n%s\n%s\t%s;\t%s %s;\t%s %s;\nbranches", - node->num, - Kdate, node->date, - Kauthor, node->author, - Kstate, node->state?node->state:"" - ); - nextbranch = node->branches; - while (nextbranch) { - aprintf(fout, "\n\t%s", nextbranch->hsh->num); - nextbranch = nextbranch->nextbranch; - } - - aprintf(fout, ";\n%s\t%s;\n", Knext, node->next?node->next->num:""); - awrite(node->ig.string, node->ig.size, fout); -} - - - void -puttree(root, fout) - struct hshentry const *root; - register FILE *fout; -/* Output the delta tree with base ROOT in preorder to FOUT. */ -{ - struct branchhead const *nextbranch; - - if (!root) return; - - if (root->selector) - putdelta(root, fout); - - puttree(root->next, fout); - - nextbranch = root->branches; - while (nextbranch) { - puttree(nextbranch->hsh, fout); - nextbranch = nextbranch->nextbranch; - } -} - - - int -putdtext(delta, srcname, fout, diffmt) - struct hshentry const *delta; - char const *srcname; - FILE *fout; - int diffmt; -/* - * Output a deltatext node with delta number DELTA->num, log message DELTA->log, - * ignored phrases DELTA->igtext and text SRCNAME to FOUT. - * Double up all SDELIMs in both the log and the text. - * Make sure the log message ends in \n. - * Return false on error. - * If DIFFMT, also check that the text is valid diff -n output. - */ -{ - RILE *fin; - if (!(fin = Iopen(srcname, "r", (struct stat*)0))) { - eerror(srcname); - return false; - } - putdftext(delta, fin, fout, diffmt); - Ifclose(fin); - return true; -} - - void -putstring(out, delim, s, log) - register FILE *out; - struct cbuf s; - int delim, log; -/* - * Output to OUT one SDELIM if DELIM, then the string S with SDELIMs doubled. - * If LOG is set then S is a log string; append a newline if S is nonempty. - */ -{ - register char const *sp; - register size_t ss; - - if (delim) - aputc_(SDELIM, out) - sp = s.string; - for (ss = s.size; ss; --ss) { - if (*sp == SDELIM) - aputc_(SDELIM, out) - aputc_(*sp++, out) - } - if (s.size && log) - aputc_('\n', out) - aputc_(SDELIM, out) -} - - void -putdftext(delta, finfile, foutfile, diffmt) - struct hshentry const *delta; - RILE *finfile; - FILE *foutfile; - int diffmt; -/* like putdtext(), except the source file is already open */ -{ - declarecache; - register FILE *fout; - register int c; - register RILE *fin; - int ed; - struct diffcmd dc; - - fout = foutfile; - aprintf(fout, DELNUMFORM, delta->num, Klog); - - /* put log */ - putstring(fout, true, delta->log, true); - aputc_('\n', fout) - - /* put ignored phrases */ - awrite(delta->igtext.string, delta->igtext.size, fout); - - /* put text */ - aprintf(fout, "%s\n%c", Ktext, SDELIM); - - fin = finfile; - setupcache(fin); - if (!diffmt) { - /* Copy the file */ - cache(fin); - for (;;) { - cachegeteof_(c, break;) - if (c==SDELIM) aputc_(SDELIM, fout) /*double up SDELIM*/ - aputc_(c, fout) - } - } else { - initdiffcmd(&dc); - while (0 <= (ed = getdiffcmd(fin, false, fout, &dc))) - if (ed) { - cache(fin); - while (dc.nlines--) - do { - cachegeteof_(c, { if (!dc.nlines) goto OK_EOF; unexpected_EOF(); }) - if (c == SDELIM) - aputc_(SDELIM, fout) - aputc_(c, fout) - } while (c != '\n'); - uncache(fin); - } - } - OK_EOF: - aprintf(fout, "%c\n", SDELIM); -} diff --git a/gnu/usr.bin/rcs/lib/rcskeep.c b/gnu/usr.bin/rcs/lib/rcskeep.c deleted file mode 100644 index cbc9710ccef..00000000000 --- a/gnu/usr.bin/rcs/lib/rcskeep.c +++ /dev/null @@ -1,452 +0,0 @@ -/* Extract RCS keyword string values from working files. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.10 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.9 1995/06/01 16:23:43 eggert - * (getoldkeys): Don't panic if a Name: is empty. - * - * Revision 5.8 1994/03/17 14:05:48 eggert - * Remove lint. - * - * Revision 5.7 1993/11/09 17:40:15 eggert - * Use simpler timezone parsing strategy now that we're using ISO 8601 format. - * - * Revision 5.6 1993/11/03 17:42:27 eggert - * Scan for Name keyword. Improve quality of diagnostics. - * - * Revision 5.5 1992/07/28 16:12:44 eggert - * Statement macro names now end in _. - * - * Revision 5.4 1991/08/19 03:13:55 eggert - * Tune. - * - * Revision 5.3 1991/04/21 11:58:25 eggert - * Shorten names to keep them distinct on shortname hosts. - * - * Revision 5.2 1990/10/04 06:30:20 eggert - * Parse time zone offsets; future RCS versions may output them. - * - * Revision 5.1 1990/09/20 02:38:56 eggert - * ci -k now checks dates more thoroughly. - * - * Revision 5.0 1990/08/22 08:12:53 eggert - * Retrieve old log message if there is one. - * Don't require final newline. - * Remove compile-time limits; use malloc instead. Tune. - * Permit dates past 1999/12/31. Ansify and Posixate. - * - * Revision 4.6 89/05/01 15:12:56 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/08/09 19:13:03 eggert - * Remove lint and speed up by making FILE *fp local, not global. - * - * Revision 4.4 87/12/18 11:44:21 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.3 87/10/18 10:35:50 narten - * Updating version numbers. Changes relative to 1.1 actually relative - * to 4.1 - * - * Revision 1.3 87/09/24 14:00:00 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:29 jenkins - * Port to suns - * - * Revision 4.1 83/05/10 16:26:44 wft - * Added new markers Id and RCSfile; extraction added. - * Marker matching with trymatch(). - * - * Revision 3.2 82/12/24 12:08:26 wft - * added missing #endif. - * - * Revision 3.1 82/12/04 13:22:41 wft - * Initial revision. - * - */ - -#include "rcsbase.h" - -libId(keepId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcskeep.c 50472 1999-08-27 23:37:10Z peter $") - -static int badly_terminated P((void)); -static int checknum P((char const*)); -static int get0val P((int,RILE*,struct buf*,int)); -static int getval P((RILE*,struct buf*,int)); -static int keepdate P((RILE*)); -static int keepid P((int,RILE*,struct buf*)); -static int keeprev P((RILE*)); - -int prevkeys; -struct buf prevauthor, prevdate, prevname, prevrev, prevstate; - - int -getoldkeys(fp) - register RILE *fp; -/* Function: Tries to read keyword values for author, date, - * revision number, and state out of the file fp. - * If fp is null, workname is opened and closed instead of using fp. - * The results are placed into - * prevauthor, prevdate, prevname, prevrev, prevstate. - * Aborts immediately if it finds an error and returns false. - * If it returns true, it doesn't mean that any of the - * values were found; instead, check to see whether the corresponding arrays - * contain the empty string. - */ -{ - register int c; - char keyword[keylength+1]; - register char * tp; - int needs_closing; - int prevname_found; - - if (prevkeys) - return true; - - needs_closing = false; - if (!fp) { - if (!(fp = Iopen(workname, FOPEN_R_WORK, (struct stat*)0))) { - eerror(workname); - return false; - } - needs_closing = true; - } - - /* initialize to empty */ - bufscpy(&prevauthor, ""); - bufscpy(&prevdate, ""); - bufscpy(&prevname, ""); prevname_found = 0; - bufscpy(&prevrev, ""); - bufscpy(&prevstate, ""); - - c = '\0'; /* anything but KDELIM */ - for (;;) { - if ( c==KDELIM) { - do { - /* try to get keyword */ - tp = keyword; - for (;;) { - Igeteof_(fp, c, goto ok;) - switch (c) { - default: - if (keyword+keylength <= tp) - break; - *tp++ = c; - continue; - - case '\n': case KDELIM: case VDELIM: - break; - } - break; - } - } while (c==KDELIM); - if (c!=VDELIM) continue; - *tp = c; - Igeteof_(fp, c, break;) - switch (c) { - case ' ': case '\t': break; - default: continue; - } - - switch (trymatch(keyword)) { - case Author: - if (!keepid(0, fp, &prevauthor)) - return false; - c = 0; - break; - case Date: - if (!(c = keepdate(fp))) - return false; - break; - case Header: - case Id: - case LocalId: - if (!( - getval(fp, (struct buf*)0, false) && - keeprev(fp) && - (c = keepdate(fp)) && - keepid(c, fp, &prevauthor) && - keepid(0, fp, &prevstate) - )) - return false; - /* Skip either ``who'' (new form) or ``Locker: who'' (old). */ - if (getval(fp, (struct buf*)0, true) && - getval(fp, (struct buf*)0, true)) - c = 0; - else if (nerror) - return false; - else - c = KDELIM; - break; - case Locker: - (void) getval(fp, (struct buf*)0, false); - c = 0; - break; - case Log: - case RCSfile: - case Source: - if (!getval(fp, (struct buf*)0, false)) - return false; - c = 0; - break; - case Name: - if (getval(fp, &prevname, false)) { - if (*prevname.string) - checkssym(prevname.string); - prevname_found = 1; - } - c = 0; - break; - case Revision: - if (!keeprev(fp)) - return false; - c = 0; - break; - case State: - if (!keepid(0, fp, &prevstate)) - return false; - c = 0; - break; - default: - continue; - } - if (!c) - Igeteof_(fp, c, c=0;) - if (c != KDELIM) { - workerror("closing %c missing on keyword", KDELIM); - return false; - } - if (prevname_found && - *prevauthor.string && *prevdate.string && - *prevrev.string && *prevstate.string - ) - break; - } - Igeteof_(fp, c, break;) - } - - ok: - if (needs_closing) - Ifclose(fp); - else - Irewind(fp); - prevkeys = true; - return true; -} - - static int -badly_terminated() -{ - workerror("badly terminated keyword value"); - return false; -} - - static int -getval(fp, target, optional) - register RILE *fp; - struct buf *target; - int optional; -/* Reads a keyword value from FP into TARGET. - * Returns true if one is found, false otherwise. - * Does not modify target if it is 0. - * Do not report an error if OPTIONAL is set and KDELIM is found instead. - */ -{ - int c; - Igeteof_(fp, c, return badly_terminated();) - return get0val(c, fp, target, optional); -} - - static int -get0val(c, fp, target, optional) - register int c; - register RILE *fp; - struct buf *target; - int optional; -/* Reads a keyword value from C+FP into TARGET, perhaps OPTIONALly. - * Same as getval, except C is the lookahead character. - */ -{ register char * tp; - char const *tlim; - register int got1; - - if (target) { - bufalloc(target, 1); - tp = target->string; - tlim = tp + target->size; - } else - tlim = tp = 0; - got1 = false; - for (;;) { - switch (c) { - default: - got1 = true; - if (tp) { - *tp++ = c; - if (tlim <= tp) - tp = bufenlarge(target, &tlim); - } - break; - - case ' ': - case '\t': - if (tp) { - *tp = 0; -# ifdef KEEPTEST - VOID printf("getval: %s\n", target); -# endif - } - return got1; - - case KDELIM: - if (!got1 && optional) - return false; - /* fall into */ - case '\n': - case 0: - return badly_terminated(); - } - Igeteof_(fp, c, return badly_terminated();) - } -} - - - static int -keepdate(fp) - RILE *fp; -/* Function: reads a date prevdate; checks format - * Return 0 on error, lookahead character otherwise. - */ -{ - struct buf prevday, prevtime; - register int c; - - c = 0; - bufautobegin(&prevday); - if (getval(fp,&prevday,false)) { - bufautobegin(&prevtime); - if (getval(fp,&prevtime,false)) { - Igeteof_(fp, c, c=0;) - if (c) { - register char const *d = prevday.string, *t = prevtime.string; - bufalloc(&prevdate, strlen(d) + strlen(t) + 9); - VOID sprintf(prevdate.string, "%s%s %s%s", - /* Parse dates put out by old versions of RCS. */ - isdigit(d[0]) && isdigit(d[1]) && !isdigit(d[2]) - ? "19" : "", - d, t, - strchr(t,'-') || strchr(t,'+') ? "" : "+0000" - ); - } - } - bufautoend(&prevtime); - } - bufautoend(&prevday); - return c; -} - - static int -keepid(c, fp, b) - int c; - RILE *fp; - struct buf *b; -/* Get previous identifier from C+FP into B. */ -{ - if (!c) - Igeteof_(fp, c, return false;) - if (!get0val(c, fp, b, false)) - return false; - checksid(b->string); - return !nerror; -} - - static int -keeprev(fp) - RILE *fp; -/* Get previous revision from FP into prevrev. */ -{ - return getval(fp,&prevrev,false) && checknum(prevrev.string); -} - - - static int -checknum(s) - char const *s; -{ - register char const *sp; - register int dotcount = 0; - for (sp=s; ; sp++) { - switch (*sp) { - case 0: - if (dotcount & 1) - return true; - else - break; - - case '.': - dotcount++; - continue; - - default: - if (isdigit(*sp)) - continue; - break; - } - break; - } - workerror("%s is not a revision number", s); - return false; -} - - - -#ifdef KEEPTEST - -/* Print the keyword values found. */ - -char const cmdid[] ="keeptest"; - - int -main(argc, argv) -int argc; char *argv[]; -{ - while (*(++argv)) { - workname = *argv; - getoldkeys((RILE*)0); - VOID printf("%s: revision: %s, date: %s, author: %s, name: %s, state: %s\n", - *argv, prevrev.string, prevdate.string, prevauthor.string, prevname.string, prevstate.string); - } - exitmain(EXIT_SUCCESS); -} -#endif diff --git a/gnu/usr.bin/rcs/lib/rcskeys.c b/gnu/usr.bin/rcs/lib/rcskeys.c deleted file mode 100644 index 544288c0477..00000000000 --- a/gnu/usr.bin/rcs/lib/rcskeys.c +++ /dev/null @@ -1,186 +0,0 @@ -/* RCS keyword table and match operation */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.4 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.3 1993/11/03 17:42:27 eggert - * Add Name keyword. - * - * Revision 5.2 1991/08/19 03:13:55 eggert - * Say `T const' instead of `const T'; it's less confusing for pointer types. - * (This change was made in other source files too.) - * - * Revision 5.1 1991/04/21 11:58:25 eggert - * Don't put , just before } in initializer. - * - * Revision 5.0 1990/08/22 08:12:54 eggert - * Add -k. Ansify and Posixate. - * - * Revision 4.3 89/05/01 15:13:02 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.2 87/10/18 10:36:33 narten - * Updating version numbers. Changes relative to 1.1 actuallyt - * relative to 4.1 - * - * Revision 1.2 87/09/24 14:00:10 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 4.1 83/05/04 10:06:53 wft - * Initial revision. - * - */ - - -#include "rcsbase.h" - -libId(keysId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcskeys.c 90399 2002-02-08 11:57:43Z ru $") - - -char const *Keyword[] = { - /* This must be in the same order as rcsbase.h's enum markers type. */ - 0, - AUTHOR, DATE, HEADER, IDH, - LOCKER, LOG, NAME, RCSFILE, REVISION, SOURCE, STATE, CVSHEADER, - NULL -}; - -/* Expand all keywords by default */ -static int ExpandKeyword[] = { - false, - true, true, true, true, - true, true, true, true, true, true, true, true, - true -}; -enum markers LocalIdMode = Id; - - enum markers -trymatch(string) - char const *string; -/* function: Checks whether string starts with a keyword followed - * by a KDELIM or a VDELIM. - * If successful, returns the appropriate marker, otherwise Nomatch. - */ -{ - register int j; - register char const *p, *s; - for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { - if (!ExpandKeyword[j]) - continue; - /* try next keyword */ - p = Keyword[j]; - if (p == NULL) - continue; - s = string; - while (*p++ == *s++) { - if (!*p) - switch (*s) { - case KDELIM: - case VDELIM: - return (enum markers)j; - default: - return Nomatch; - } - } - } - return(Nomatch); -} - - void -setIncExc(arg) - char const *arg; -/* Sets up the ExpandKeyword table according to command-line flags */ -{ - char *key; - char *copy, *next; - int include = 0, j; - - copy = strdup(arg); - next = copy; - switch (*next++) { - case 'e': - include = false; - break; - case 'i': - include = true; - break; - default: - free(copy); - return; - } - if (include) - for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) - ExpandKeyword[j] = false; - key = strtok(next, ","); - while (key) { - for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { - if (Keyword[j] == NULL) - continue; - if (!strcmp(key, Keyword[j])) - ExpandKeyword[j] = include; - } - key = strtok(NULL, ","); - } - free(copy); - return; -} - - void -setRCSLocalId(string) - char const *string; -/* function: sets local RCS id and RCSLOCALID envariable */ -{ - static char local_id[keylength+1]; - char *copy, *next, *key; - int j; - - copy = strdup(string); - next = copy; - key = strtok(next, "="); - if (strlen(key) > keylength) - faterror("LocalId is too long"); - VOID strcpy(local_id, key); - Keyword[LocalId] = local_id; - - /* options? */ - while (key = strtok(NULL, ",")) { - if (!strcmp(key, Keyword[Id])) - LocalIdMode=Id; - else if (!strcmp(key, Keyword[Header])) - LocalIdMode=Header; - else if (!strcmp(key, Keyword[CVSHeader])) - LocalIdMode=CVSHeader; - else - error("Unknown LocalId mode"); - } - free(copy); -} diff --git a/gnu/usr.bin/rcs/lib/rcslex.c b/gnu/usr.bin/rcs/lib/rcslex.c deleted file mode 100644 index 7c7c71ceacf..00000000000 --- a/gnu/usr.bin/rcs/lib/rcslex.c +++ /dev/null @@ -1,1568 +0,0 @@ -/* lexical analysis of RCS files */ - -/****************************************************************************** - * Lexical Analysis. - * hashtable, Lexinit, nextlex, getlex, getkey, - * getid, getnum, readstring, printstring, savestring, - * checkid, fatserror, error, faterror, warn, diagnose - * Testprogram: define LEXDB - ****************************************************************************** - */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - - - -/* - * Revision 5.19 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.18 1995/06/01 16:23:43 eggert - * (map_fd_deallocate,mmap_deallocate,read_deallocate,nothing_to_deallocate): - * New functions. - * (Iclose): If large_memory and maps_memory, use them to deallocate mapping. - * (fd2RILE): Use map_fd if available. - * If one mapping method fails, try the next instead of giving up; - * if they all fail, fall back on ordinary read. - * Work around bug: root mmap over NFS succeeds, but accessing dumps core. - * Use MAP_FAILED macro for mmap failure, and `char *' instead of caddr_t. - * (advise_access): Use madvise only if this instance used mmap. - * (Iopen): Use fdSafer to get safer file descriptor. - * (aflush): Moved here from rcsedit.c. - * - * Revision 5.17 1994/03/20 04:52:58 eggert - * Don't worry if madvise fails. Add Orewind. Remove lint. - * - * Revision 5.16 1993/11/09 17:55:29 eggert - * Fix `label: }' typo. - * - * Revision 5.15 1993/11/03 17:42:27 eggert - * Improve quality of diagnostics by putting file names in them more often. - * Don't discard ignored phrases. - * - * Revision 5.14 1992/07/28 16:12:44 eggert - * Identifiers may now start with a digit and (unless they are symbolic names) - * may contain `.'. Avoid `unsigned'. Statement macro names now end in _. - * - * Revision 5.13 1992/02/17 23:02:27 eggert - * Work around NFS mmap SIGBUS problem. - * - * Revision 5.12 1992/01/06 02:42:34 eggert - * Use OPEN_O_BINARY if mode contains 'b'. - * - * Revision 5.11 1991/11/03 03:30:44 eggert - * Fix porting bug to ancient hosts lacking vfprintf. - * - * Revision 5.10 1991/10/07 17:32:46 eggert - * Support piece tables even if !has_mmap. - * - * Revision 5.9 1991/09/24 00:28:42 eggert - * Don't export errsay(). - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Add eoflex(), mmap support. Tune. - * - * Revision 5.7 1991/04/21 11:58:26 eggert - * Add MS-DOS support. - * - * Revision 5.6 1991/02/25 07:12:42 eggert - * Work around fputs bug. strsave -> str_save (DG/UX name clash) - * - * Revision 5.5 1990/12/04 05:18:47 eggert - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.4 1990/11/19 20:05:28 hammer - * no longer gives warning about unknown keywords if -q is specified - * - * Revision 5.3 1990/11/01 05:03:48 eggert - * When ignoring unknown phrases, copy them to the output RCS file. - * - * Revision 5.2 1990/09/04 08:02:27 eggert - * Count RCS lines better. - * - * Revision 5.1 1990/08/29 07:14:03 eggert - * Work around buggy compilers with defective argument promotion. - * - * Revision 5.0 1990/08/22 08:12:55 eggert - * Remove compile-time limits; use malloc instead. - * Report errno-related errors with perror(). - * Ansify and Posixate. Add support for ISO 8859. - * Use better hash function. - * - * Revision 4.6 89/05/01 15:13:07 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/08/28 15:01:12 eggert - * Don't loop when writing error messages to a full filesystem. - * Flush stderr/stdout when mixing output. - * Yield exit status compatible with diff(1). - * Shrink stdio code size; allow cc -R; remove lint. - * - * Revision 4.4 87/12/18 11:44:47 narten - * fixed to use "varargs" in "fprintf"; this is required if it is to - * work on a SPARC machine such as a Sun-4 - * - * Revision 4.3 87/10/18 10:37:18 narten - * Updating version numbers. Changes relative to 1.1 actually relative - * to version 4.1 - * - * Revision 1.3 87/09/24 14:00:17 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:33 jenkins - * Port to suns - * - * Revision 4.1 83/03/25 18:12:51 wft - * Only changed $Header to $Id. - * - * Revision 3.3 82/12/10 16:22:37 wft - * Improved error messages, changed exit status on error to 1. - * - * Revision 3.2 82/11/28 21:27:10 wft - * Renamed ctab to map and included EOFILE; ctab is now a macro in rcsbase.h. - * Added fflsbuf(), fputs(), and fprintf(), which abort the RCS operations - * properly in case there is an IO-error (e.g., file system full). - * - * Revision 3.1 82/10/11 19:43:56 wft - * removed unused label out:; - * made sure all calls to getc() return into an integer, not a char. - */ - - -/* -#define LEXDB -*/ -/* version LEXDB is for testing the lexical analyzer. The testprogram - * reads a stream of lexemes, enters the revision numbers into the - * hashtable, and prints the recognized tokens. Keywords are recognized - * as identifiers. - */ - - - -#include "rcsbase.h" - -libId(lexId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcslex.c 50472 1999-08-27 23:37:10Z peter $") - -static char *checkidentifier P((char*,int,int)); -static void errsay P((char const*)); -static void fatsay P((char const*)); -static void lookup P((char const*)); -static void startsay P((const char*,const char*)); -static void warnsay P((char const*)); - -static struct hshentry *nexthsh; /*pointer to next hash entry, set by lookup*/ - -enum tokens nexttok; /*next token, set by nextlex */ - -int hshenter; /*if true, next suitable lexeme will be entered */ - /*into the symbol table. Handle with care. */ -int nextc; /*next input character, initialized by Lexinit */ - -long rcsline; /*current line-number of input */ -int nerror; /*counter for errors */ -int quietflag; /*indicates quiet mode */ -RILE * finptr; /*input file descriptor */ - -FILE * frewrite; /*file descriptor for echoing input */ - -FILE * foutptr; /* copy of frewrite, but 0 to suppress echo */ - -static struct buf tokbuf; /* token buffer */ - -char const * NextString; /* next token */ - -/* - * Our hash algorithm is h[0] = 0, h[i+1] = 4*h[i] + c, - * so hshsize should be odd. - * See B J McKenzie, R Harries & T Bell, Selecting a hashing algorithm, - * Software--practice & experience 20, 2 (Feb 1990), 209-224. - */ -#ifndef hshsize -# define hshsize 511 -#endif - -static struct hshentry *hshtab[hshsize]; /*hashtable */ - -static int ignored_phrases; /* have we ignored phrases in this RCS file? */ - - void -warnignore() -{ - if (!ignored_phrases) { - ignored_phrases = true; - rcswarn("Unknown phrases like `%s ...;' are present.", NextString); - } -} - - - - static void -lookup(str) - char const *str; -/* Function: Looks up the character string pointed to by str in the - * hashtable. If the string is not present, a new entry for it is created. - * In any case, the address of the corresponding hashtable entry is placed - * into nexthsh. - */ -{ - register unsigned ihash; /* index into hashtable */ - register char const *sp; - register struct hshentry *n, **p; - - /* calculate hash code */ - sp = str; - ihash = 0; - while (*sp) - ihash = (ihash<<2) + *sp++; - ihash %= hshsize; - - for (p = &hshtab[ihash]; ; p = &n->nexthsh) - if (!(n = *p)) { - /* empty slot found */ - *p = n = ftalloc(struct hshentry); - n->num = fstr_save(str); - n->nexthsh = 0; -# ifdef LEXDB - VOID printf("\nEntered: %s at %u ", str, ihash); -# endif - break; - } else if (strcmp(str, n->num) == 0) - /* match found */ - break; - nexthsh = n; - NextString = n->num; -} - - - - - - - void -Lexinit() -/* Function: Initialization of lexical analyzer: - * initializes the hashtable, - * initializes nextc, nexttok if finptr != 0 - */ -{ register int c; - - for (c = hshsize; 0 <= --c; ) { - hshtab[c] = 0; - } - - nerror = 0; - if (finptr) { - foutptr = 0; - hshenter = true; - ignored_phrases = false; - rcsline = 1; - bufrealloc(&tokbuf, 2); - Iget_(finptr, nextc) - nextlex(); /*initial token*/ - } -} - - - - - - - - void -nextlex() - -/* Function: Reads the next token and sets nexttok to the next token code. - * Only if hshenter is set, a revision number is entered into the - * hashtable and a pointer to it is placed into nexthsh. - * This is useful for avoiding that dates are placed into the hashtable. - * For ID's and NUM's, NextString is set to the character string. - * Assumption: nextc contains the next character. - */ -{ register c; - declarecache; - register FILE *frew; - register char * sp; - char const *limit; - register enum tokens d; - register RILE *fin; - - fin=finptr; frew=foutptr; - setupcache(fin); cache(fin); - c = nextc; - - for (;;) { switch ((d = ctab[c])) { - - default: - fatserror("unknown character `%c'", c); - /*NOTREACHED*/ - - case NEWLN: - ++rcsline; -# ifdef LEXDB - afputc('\n',stdout); -# endif - /* Note: falls into next case */ - - case SPACE: - GETC_(frew, c) - continue; - - case IDCHAR: - case LETTER: - case Letter: - d = ID; - /* fall into */ - case DIGIT: - case PERIOD: - sp = tokbuf.string; - limit = sp + tokbuf.size; - *sp++ = c; - for (;;) { - GETC_(frew, c) - switch (ctab[c]) { - case IDCHAR: - case LETTER: - case Letter: - d = ID; - /* fall into */ - case DIGIT: - case PERIOD: - *sp++ = c; - if (limit <= sp) - sp = bufenlarge(&tokbuf, &limit); - continue; - - default: - break; - } - break; - } - *sp = 0; - if (d == DIGIT || d == PERIOD) { - d = NUM; - if (hshenter) { - lookup(tokbuf.string); - break; - } - } - NextString = fstr_save(tokbuf.string); - break; - - case SBEGIN: /* long string */ - d = STRING; - /* note: only the initial SBEGIN has been read*/ - /* read the string, and reset nextc afterwards*/ - break; - - case COLON: - case SEMI: - GETC_(frew, c) - break; - } break; } - nextc = c; - nexttok = d; - uncache(fin); -} - - int -eoflex() -/* - * Yield true if we look ahead to the end of the input, false otherwise. - * nextc becomes undefined at end of file. - */ -{ - register int c; - declarecache; - register FILE *fout; - register RILE *fin; - - c = nextc; - fin = finptr; - fout = foutptr; - setupcache(fin); cache(fin); - - for (;;) { - switch (ctab[c]) { - default: - nextc = c; - uncache(fin); - return false; - - case NEWLN: - ++rcsline; - /* fall into */ - case SPACE: - cachegeteof_(c, {uncache(fin);return true;}) - break; - } - if (fout) - aputc_(c, fout) - } -} - - -int getlex(token) -enum tokens token; -/* Function: Checks if nexttok is the same as token. If so, - * advances the input by calling nextlex and returns true. - * otherwise returns false. - * Doesn't work for strings and keywords; loses the character string for ids. - */ -{ - if (nexttok==token) { - nextlex(); - return(true); - } else return(false); -} - - int -getkeyopt(key) - char const *key; -/* Function: If the current token is a keyword identical to key, - * advances the input by calling nextlex and returns true; - * otherwise returns false. - */ -{ - if (nexttok==ID && strcmp(key,NextString) == 0) { - /* match found */ - ffree1(NextString); - nextlex(); - return(true); - } - return(false); -} - - void -getkey(key) - char const *key; -/* Check that the current input token is a keyword identical to key, - * and advance the input by calling nextlex. - */ -{ - if (!getkeyopt(key)) - fatserror("missing '%s' keyword", key); -} - - void -getkeystring(key) - char const *key; -/* Check that the current input token is a keyword identical to key, - * and advance the input by calling nextlex; then look ahead for a string. - */ -{ - getkey(key); - if (nexttok != STRING) - fatserror("missing string after '%s' keyword", key); -} - - - char const * -getid() -/* Function: Checks if nexttok is an identifier. If so, - * advances the input by calling nextlex and returns a pointer - * to the identifier; otherwise returns 0. - * Treats keywords as identifiers. - */ -{ - register char const *name; - if (nexttok==ID) { - name = NextString; - nextlex(); - return name; - } else - return 0; -} - - -struct hshentry * getnum() -/* Function: Checks if nexttok is a number. If so, - * advances the input by calling nextlex and returns a pointer - * to the hashtable entry. Otherwise returns 0. - * Doesn't work if hshenter is false. - */ -{ - register struct hshentry * num; - if (nexttok==NUM) { - num=nexthsh; - nextlex(); - return num; - } else - return 0; -} - - struct cbuf -getphrases(key) - char const *key; -/* -* Get a series of phrases that do not start with KEY. Yield resulting buffer. -* Stop when the next phrase starts with a token that is not an identifier, -* or is KEY. Copy input to foutptr if it is set. Unlike ignorephrases(), -* this routine assumes nextlex() has already been invoked before we start. -*/ -{ - declarecache; - register int c; - register char const *kn; - struct cbuf r; - register RILE *fin; - register FILE *frew; -# if large_memory -# define savech_(c) ; -# else - register char *p; - char const *limit; - struct buf b; -# define savech_(c) {if (limit<=p)p=bufenlarge(&b,&limit); *p++ =(c);} -# endif - - if (nexttok!=ID || strcmp(NextString,key) == 0) - clear_buf(&r); - else { - warnignore(); - fin = finptr; - frew = foutptr; - setupcache(fin); cache(fin); -# if large_memory - r.string = (char const*)cacheptr() - strlen(NextString) - 1; -# else - bufautobegin(&b); - bufscpy(&b, NextString); - p = b.string + strlen(b.string); - limit = b.string + b.size; -# endif - ffree1(NextString); - c = nextc; - for (;;) { - for (;;) { - savech_(c) - switch (ctab[c]) { - default: - fatserror("unknown character `%c'", c); - /*NOTREACHED*/ - case NEWLN: - ++rcsline; - /* fall into */ - case COLON: case DIGIT: case LETTER: case Letter: - case PERIOD: case SPACE: - GETC_(frew, c) - continue; - case SBEGIN: /* long string */ - for (;;) { - for (;;) { - GETC_(frew, c) - savech_(c) - switch (c) { - case '\n': - ++rcsline; - /* fall into */ - default: - continue; - - case SDELIM: - break; - } - break; - } - GETC_(frew, c) - if (c != SDELIM) - break; - savech_(c) - } - continue; - case SEMI: - cacheget_(c) - if (ctab[c] == NEWLN) { - if (frew) - aputc_(c, frew) - ++rcsline; - savech_(c) - cacheget_(c) - } -# if large_memory - r.size = (char const*)cacheptr() - 1 - r.string; -# endif - for (;;) { - switch (ctab[c]) { - case NEWLN: - ++rcsline; - /* fall into */ - case SPACE: - cacheget_(c) - continue; - - default: break; - } - break; - } - if (frew) - aputc_(c, frew) - break; - } - break; - } - if (ctab[c] == Letter) { - for (kn = key; c && *kn==c; kn++) - GETC_(frew, c) - if (!*kn) - switch (ctab[c]) { - case DIGIT: case LETTER: case Letter: - case IDCHAR: case PERIOD: - break; - default: - nextc = c; - NextString = fstr_save(key); - nexttok = ID; - uncache(fin); - goto returnit; - } -# if !large_memory - { - register char const *ki; - for (ki=key; kistring; limit = tp + target->size; - for (;;) { - GETC_(frew, c) - switch (c) { - case '\n': - ++rcsline; - break; - case SDELIM: - GETC_(frew, c) - if (c != SDELIM) { - /* end of string */ - nextc=c; - r.string = target->string; - r.size = tp - r.string; - uncache(fin); - return r; - } - break; - } - if (tp == limit) - tp = bufenlarge(target, &limit); - *tp++ = c; - } -} - - - static char * -checkidentifier(id, delimiter, dotok) - register char *id; - int delimiter; - register int dotok; -/* Function: check whether the string starting at id is an */ -/* identifier and return a pointer to the delimiter*/ -/* after the identifier. White space, delim and 0 */ -/* are legal delimiters. Aborts the program if not*/ -/* a legal identifier. Useful for checking commands*/ -/* If !delim, the only delimiter is 0. */ -/* Allow '.' in identifier only if DOTOK is set. */ -{ - register char *temp; - register char c; - register char delim = delimiter; - int isid = false; - - temp = id; - for (;; id++) { - switch (ctab[(unsigned char)(c = *id)]) { - case IDCHAR: - case LETTER: - case Letter: - isid = true; - continue; - - case DIGIT: - continue; - - case PERIOD: - if (dotok) - continue; - break; - - default: - break; - } - break; - } - if ( ! isid - || (c && (!delim || (c!=delim && c!=' ' && c!='\t' && c!='\n'))) - ) { - /* append \0 to end of id before error message */ - while ((c = *id) && c!=' ' && c!='\t' && c!='\n' && c!=delim) - id++; - *id = '\0'; - faterror("invalid %s `%s'", - dotok ? "identifier" : "symbol", temp - ); - } - return id; -} - - char * -checkid(id, delimiter) - char *id; - int delimiter; -{ - return checkidentifier(id, delimiter, true); -} - - char * -checksym(sym, delimiter) - char *sym; - int delimiter; -{ - return checkidentifier(sym, delimiter, false); -} - - void -checksid(id) - char *id; -/* Check whether the string ID is an identifier. */ -{ - VOID checkid(id, 0); -} - - void -checkssym(sym) - char *sym; -{ - VOID checksym(sym, 0); -} - - -#if !large_memory -# define Iclose(f) fclose(f) -#else -# if !maps_memory - static int Iclose P((RILE *)); - static int - Iclose(f) - register RILE *f; - { - tfree(f->base); - f->base = 0; - return fclose(f->stream); - } -# else - static int Iclose P((RILE *)); - static int - Iclose(f) - register RILE *f; - { - (* f->deallocate) (f); - f->base = 0; - return close(f->fd); - } - -# if has_map_fd - static void map_fd_deallocate P((RILE *)); - static void - map_fd_deallocate(f) - register RILE *f; - { - if (vm_deallocate( - task_self(), - (vm_address_t) f->base, - (vm_size_t) (f->lim - f->base) - ) != KERN_SUCCESS) - efaterror("vm_deallocate"); - } -# endif -# if has_mmap - static void mmap_deallocate P((RILE *)); - static void - mmap_deallocate(f) - register RILE *f; - { - if (munmap((char *) f->base, (size_t) (f->lim - f->base)) != 0) - efaterror("munmap"); - } -# endif - static void read_deallocate P((RILE *)); - static void - read_deallocate(f) - RILE *f; - { - tfree(f->base); - } - - static void nothing_to_deallocate P((RILE *)); - static void - nothing_to_deallocate(f) - RILE *f; - { - } -# endif -#endif - - -#if large_memory && maps_memory - static RILE *fd2_RILE P((int,char const*,struct stat*)); - static RILE * -fd2_RILE(fd, name, status) -#else - static RILE *fd2RILE P((int,char const*,char const*,struct stat*)); - static RILE * -fd2RILE(fd, name, type, status) - char const *type; -#endif - int fd; - char const *name; - register struct stat *status; -{ - struct stat st; - - if (!status) - status = &st; - if (fstat(fd, status) != 0) - efaterror(name); - if (!S_ISREG(status->st_mode)) { - error("`%s' is not a regular file", name); - VOID close(fd); - errno = EINVAL; - return 0; - } else { - -# if !(large_memory && maps_memory) - FILE *stream; - if (!(stream = fdopen(fd, type))) - efaterror(name); -# endif - -# if !large_memory - return stream; -# else -# define RILES 3 - { - static RILE rilebuf[RILES]; - - register RILE *f; - size_t s = status->st_size; - - if (s != status->st_size) - faterror("%s: too large", name); - for (f = rilebuf; f->base; f++) - if (f == rilebuf+RILES) - faterror("too many RILEs"); -# if maps_memory - f->deallocate = nothing_to_deallocate; -# endif - if (!s) { - static unsigned char nothing; - f->base = ¬hing; /* Any nonzero address will do. */ - } else { - f->base = 0; -# if has_map_fd - map_fd( - fd, (vm_offset_t)0, (vm_address_t*) &f->base, - TRUE, (vm_size_t)s - ); - f->deallocate = map_fd_deallocate; -# endif -# if has_mmap - if (!f->base) { - catchmmapints(); - f->base = (unsigned char *) mmap( - (char *)0, s, PROT_READ, MAP_SHARED, - fd, (off_t)0 - ); -# ifndef MAP_FAILED -# define MAP_FAILED (-1) -# endif - if (f->base == (unsigned char *) MAP_FAILED) - f->base = 0; - else { -# if has_NFS && mmap_signal - /* - * On many hosts, the superuser - * can mmap an NFS file it can't read. - * So access the first page now, and print - * a nice message if a bus error occurs. - */ - readAccessFilenameBuffer(name, f->base); -# endif - } - f->deallocate = mmap_deallocate; - } -# endif - if (!f->base) { - f->base = tnalloc(unsigned char, s); -# if maps_memory - { - /* - * We can't map the file into memory for some reason. - * Read it into main memory all at once; this is - * the simplest substitute for memory mapping. - */ - char *bufptr = (char *) f->base; - size_t bufsiz = s; - do { - ssize_t r = read(fd, bufptr, bufsiz); - switch (r) { - case -1: - efaterror(name); - - case 0: - /* The file must have shrunk! */ - status->st_size = s -= bufsiz; - bufsiz = 0; - break; - - default: - bufptr += r; - bufsiz -= r; - break; - } - } while (bufsiz); - if (lseek(fd, (off_t)0, SEEK_SET) == -1) - efaterror(name); - f->deallocate = read_deallocate; - } -# endif - } - } - f->ptr = f->base; - f->lim = f->base + s; - f->fd = fd; -# if !maps_memory - f->readlim = f->base; - f->stream = stream; -# endif - if_advise_access(s, f, MADV_SEQUENTIAL); - return f; - } -# endif - } -} - -#if !maps_memory && large_memory - int -Igetmore(f) - register RILE *f; -{ - register fread_type r; - register size_t s = f->lim - f->readlim; - - if (BUFSIZ < s) - s = BUFSIZ; - if (!(r = Fread(f->readlim, sizeof(*f->readlim), s, f->stream))) { - testIerror(f->stream); - f->lim = f->readlim; /* The file might have shrunk! */ - return 0; - } - f->readlim += r; - return 1; -} -#endif - -#if has_madvise && has_mmap && large_memory - void -advise_access(f, advice) - register RILE *f; - int advice; -{ - if (f->deallocate == mmap_deallocate) - VOID madvise((char *)f->base, (size_t)(f->lim - f->base), advice); - /* Don't worry if madvise fails; it's only advisory. */ -} -#endif - - RILE * -#if large_memory && maps_memory -I_open(name, status) -#else -Iopen(name, type, status) - char const *type; -#endif - char const *name; - struct stat *status; -/* Open NAME for reading, yield its descriptor, and set *STATUS. */ -{ - int fd = fdSafer(open(name, O_RDONLY -# if OPEN_O_BINARY - | (strchr(type,'b') ? OPEN_O_BINARY : 0) -# endif - )); - - if (fd < 0) - return 0; -# if large_memory && maps_memory - return fd2_RILE(fd, name, status); -# else - return fd2RILE(fd, name, type, status); -# endif -} - - -static int Oerrloop; - - void -Oerror() -{ - if (Oerrloop) - exiterr(); - Oerrloop = true; - efaterror("output error"); -} - -void Ieof() { fatserror("unexpected end of file"); } -void Ierror() { efaterror("input error"); } -void testIerror(f) FILE *f; { if (ferror(f)) Ierror(); } -void testOerror(o) FILE *o; { if (ferror(o)) Oerror(); } - -void Ifclose(f) RILE *f; { if (f && Iclose(f)!=0) Ierror(); } -void Ofclose(f) FILE *f; { if (f && fclose(f)!=0) Oerror(); } -void Izclose(p) RILE **p; { Ifclose(*p); *p = 0; } -void Ozclose(p) FILE **p; { Ofclose(*p); *p = 0; } - -#if !large_memory - void -testIeof(f) - FILE *f; -{ - testIerror(f); - if (feof(f)) - Ieof(); -} -void Irewind(f) FILE *f; { if (fseek(f,0L,SEEK_SET) != 0) Ierror(); } -#endif - -void Orewind(f) FILE *f; { if (fseek(f,0L,SEEK_SET) != 0) Oerror(); } - -void aflush(f) FILE *f; { if (fflush(f) != 0) Oerror(); } -void eflush() { if (fflush(stderr)!=0 && !Oerrloop) Oerror(); } -void oflush() -{ - if (fflush(workstdout ? workstdout : stdout) != 0 && !Oerrloop) - Oerror(); -} - - void -fatcleanup(already_newline) - int already_newline; -{ - VOID fprintf(stderr, already_newline+"\n%s aborted\n", cmdid); - exiterr(); -} - - static void -startsay(s, t) - const char *s, *t; -{ - oflush(); - if (s) - aprintf(stderr, "%s: %s: %s", cmdid, s, t); - else - aprintf(stderr, "%s: %s", cmdid, t); -} - - static void -fatsay(s) - char const *s; -{ - startsay(s, ""); -} - - static void -errsay(s) - char const *s; -{ - fatsay(s); - nerror++; -} - - static void -warnsay(s) - char const *s; -{ - startsay(s, "warning: "); -} - -void eerror(s) char const *s; { enerror(errno,s); } - - void -enerror(e,s) - int e; - char const *s; -{ - errsay((char const*)0); - errno = e; - perror(s); - eflush(); -} - -void efaterror(s) char const *s; { enfaterror(errno,s); } - - void -enfaterror(e,s) - int e; - char const *s; -{ - fatsay((char const*)0); - errno = e; - perror(s); - fatcleanup(true); -} - -#if has_prototypes - void -error(char const *format,...) -#else - /*VARARGS1*/ void error(format, va_alist) char const *format; va_dcl -#endif -/* non-fatal error */ -{ - va_list args; - errsay((char const*)0); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - afputc('\n',stderr); - eflush(); -} - -#if has_prototypes - void -rcserror(char const *format,...) -#else - /*VARARGS1*/ void rcserror(format, va_alist) char const *format; va_dcl -#endif -/* non-fatal RCS file error */ -{ - va_list args; - errsay(RCSname); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - afputc('\n',stderr); - eflush(); -} - -#if has_prototypes - void -workerror(char const *format,...) -#else - /*VARARGS1*/ void workerror(format, va_alist) char const *format; va_dcl -#endif -/* non-fatal working file error */ -{ - va_list args; - errsay(workname); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - afputc('\n',stderr); - eflush(); -} - -#if has_prototypes - void -fatserror(char const *format,...) -#else - /*VARARGS1*/ void - fatserror(format, va_alist) char const *format; va_dcl -#endif -/* fatal RCS file syntax error */ -{ - va_list args; - oflush(); - VOID fprintf(stderr, "%s: %s:%ld: ", cmdid, RCSname, rcsline); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - fatcleanup(false); -} - -#if has_prototypes - void -faterror(char const *format,...) -#else - /*VARARGS1*/ void faterror(format, va_alist) - char const *format; va_dcl -#endif -/* fatal error, terminates program after cleanup */ -{ - va_list args; - fatsay((char const*)0); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - fatcleanup(false); -} - -#if has_prototypes - void -rcsfaterror(char const *format,...) -#else - /*VARARGS1*/ void rcsfaterror(format, va_alist) - char const *format; va_dcl -#endif -/* fatal RCS file error, terminates program after cleanup */ -{ - va_list args; - fatsay(RCSname); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - fatcleanup(false); -} - -#if has_prototypes - void -warn(char const *format,...) -#else - /*VARARGS1*/ void warn(format, va_alist) char const *format; va_dcl -#endif -/* warning */ -{ - va_list args; - if (!quietflag) { - warnsay((char *)0); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - afputc('\n', stderr); - eflush(); - } -} - -#if has_prototypes - void -rcswarn(char const *format,...) -#else - /*VARARGS1*/ void rcswarn(format, va_alist) char const *format; va_dcl -#endif -/* RCS file warning */ -{ - va_list args; - if (!quietflag) { - warnsay(RCSname); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - afputc('\n', stderr); - eflush(); - } -} - -#if has_prototypes - void -workwarn(char const *format,...) -#else - /*VARARGS1*/ void workwarn(format, va_alist) char const *format; va_dcl -#endif -/* working file warning */ -{ - va_list args; - if (!quietflag) { - warnsay(workname); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - afputc('\n', stderr); - eflush(); - } -} - - void -redefined(c) - int c; -{ - warn("redefinition of -%c option", c); -} - -#if has_prototypes - void -diagnose(char const *format,...) -#else - /*VARARGS1*/ void diagnose(format, va_alist) char const *format; va_dcl -#endif -/* prints a diagnostic message */ -/* Unlike the other routines, it does not append a newline. */ -/* This lets some callers suppress the newline, and is faster */ -/* in implementations that flush stderr just at the end of each printf. */ -{ - va_list args; - if (!quietflag) { - oflush(); - vararg_start(args, format); - fvfprintf(stderr, format, args); - va_end(args); - eflush(); - } -} - - - - void -afputc(c, f) -/* afputc(c,f); acts like aputc_(c,f) but is smaller and slower. */ - int c; - register FILE *f; -{ - aputc_(c,f) -} - - - void -aputs(s, iop) - char const *s; - FILE *iop; -/* Function: Put string s on file iop, abort on error. - */ -{ -#if has_fputs - if (fputs(s, iop) < 0) - Oerror(); -#else - awrite(s, strlen(s), iop); -#endif -} - - - - void -#if has_prototypes -fvfprintf(FILE *stream, char const *format, va_list args) -#else - fvfprintf(stream,format,args) FILE *stream; char *format; va_list args; -#endif -/* like vfprintf, except abort program on error */ -{ -#if has_vfprintf - if (vfprintf(stream, format, args) < 0) - Oerror(); -#else -# if has__doprintf - _doprintf(stream, format, args); -# else -# if has__doprnt - _doprnt(format, args, stream); -# else - int *a = (int *)args; - VOID fprintf(stream, format, - a[0], a[1], a[2], a[3], a[4], - a[5], a[6], a[7], a[8], a[9] - ); -# endif -# endif - if (ferror(stream)) - Oerror(); -#endif -} - -#if has_prototypes - void -aprintf(FILE *iop, char const *fmt, ...) -#else - /*VARARGS2*/ void -aprintf(iop, fmt, va_alist) -FILE *iop; -char const *fmt; -va_dcl -#endif -/* Function: formatted output. Same as fprintf in stdio, - * but aborts program on error - */ -{ - va_list ap; - vararg_start(ap, fmt); - fvfprintf(iop, fmt, ap); - va_end(ap); -} - - - -#ifdef LEXDB -/* test program reading a stream of lexemes and printing the tokens. - */ - - - - int -main(argc,argv) -int argc; char * argv[]; -{ - cmdid="lextest"; - if (argc<2) { - aputs("No input file\n",stderr); - exitmain(EXIT_FAILURE); - } - if (!(finptr=Iopen(argv[1], FOPEN_R, (struct stat*)0))) { - faterror("can't open input file %s",argv[1]); - } - Lexinit(); - while (!eoflex()) { - switch (nexttok) { - - case ID: - VOID printf("ID: %s",NextString); - break; - - case NUM: - if (hshenter) - VOID printf("NUM: %s, index: %d",nexthsh->num, nexthsh-hshtab); - else - VOID printf("NUM, unentered: %s",NextString); - hshenter = !hshenter; /*alternate between dates and numbers*/ - break; - - case COLON: - VOID printf("COLON"); break; - - case SEMI: - VOID printf("SEMI"); break; - - case STRING: - readstring(); - VOID printf("STRING"); break; - - case UNKN: - VOID printf("UNKN"); break; - - default: - VOID printf("DEFAULT"); break; - } - VOID printf(" | "); - nextlex(); - } - exitmain(EXIT_SUCCESS); -} - -void exiterr() { _exit(EXIT_FAILURE); } - - -#endif diff --git a/gnu/usr.bin/rcs/lib/rcsmap.c b/gnu/usr.bin/rcs/lib/rcsmap.c deleted file mode 100644 index bc50ac3ba58..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsmap.c +++ /dev/null @@ -1,69 +0,0 @@ -/* RCS map of character types */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1995 by Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#include "rcsbase.h" - -libId(mapId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsmap.c 50472 1999-08-27 23:37:10Z peter $") - -/* map of character types */ -/* ISO 8859/1 (Latin-1) */ -enum tokens const ctab[] = { - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - SPACE, SPACE, NEWLN, SPACE, SPACE, SPACE, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - SPACE, IDCHAR, IDCHAR, IDCHAR, DELIM, IDCHAR, IDCHAR, IDCHAR, - IDCHAR, IDCHAR, IDCHAR, IDCHAR, DELIM, IDCHAR, PERIOD, IDCHAR, - DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, - DIGIT, DIGIT, COLON, SEMI, IDCHAR, IDCHAR, IDCHAR, IDCHAR, - SBEGIN, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, - IDCHAR, Letter, Letter, Letter, Letter, Letter, Letter, Letter, - Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter, - Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter, - Letter, Letter, Letter, IDCHAR, IDCHAR, IDCHAR, IDCHAR, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, - IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, - IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, - IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, IDCHAR, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, IDCHAR, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, Letter, - Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter, - Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter, - Letter, Letter, Letter, Letter, Letter, Letter, Letter, IDCHAR, - Letter, Letter, Letter, Letter, Letter, Letter, Letter, Letter -}; diff --git a/gnu/usr.bin/rcs/lib/rcsrev.c b/gnu/usr.bin/rcs/lib/rcsrev.c deleted file mode 100644 index 6728ffaca57..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsrev.c +++ /dev/null @@ -1,911 +0,0 @@ -/* Handle RCS revision numbers. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.10 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.9 1995/06/01 16:23:43 eggert - * (cmpdate, normalizeyear): New functions work around MKS RCS incompatibility. - * (cmpnum, compartial): s[d] -> *(s+d) to work around Cray compiler bug. - * (genrevs, genbranch): cmpnum -> cmpdate - * - * Revision 5.8 1994/03/17 14:05:48 eggert - * Remove lint. - * - * Revision 5.7 1993/11/09 17:40:15 eggert - * Fix format string typos. - * - * Revision 5.6 1993/11/03 17:42:27 eggert - * Revision number `.N' now stands for `D.N', where D is the default branch. - * Add -z. Improve quality of diagnostics. Add `namedrev' for Name support. - * - * Revision 5.5 1992/07/28 16:12:44 eggert - * Identifiers may now start with a digit. Avoid `unsigned'. - * - * Revision 5.4 1992/01/06 02:42:34 eggert - * while (E) ; -> while (E) continue; - * - * Revision 5.3 1991/08/19 03:13:55 eggert - * Add `-r$', `-rB.'. Remove botches like `' from messages. Tune. - * - * Revision 5.2 1991/04/21 11:58:28 eggert - * Add tiprev(). - * - * Revision 5.1 1991/02/25 07:12:43 eggert - * Avoid overflow when comparing revision numbers. - * - * Revision 5.0 1990/08/22 08:13:43 eggert - * Remove compile-time limits; use malloc instead. - * Ansify and Posixate. Tune. - * Remove possibility of an internal error. Remove lint. - * - * Revision 4.5 89/05/01 15:13:22 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 87/12/18 11:45:22 narten - * more lint cleanups. Also, the NOTREACHED comment is no longer necessary, - * since there's now a return value there with a value. (Guy Harris) - * - * Revision 4.3 87/10/18 10:38:42 narten - * Updating version numbers. Changes relative to version 1.1 actually - * relative to 4.1 - * - * Revision 1.3 87/09/24 14:00:37 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:37 jenkins - * Port to suns - * - * Revision 4.1 83/03/25 21:10:45 wft - * Only changed $Header to $Id. - * - * Revision 3.4 82/12/04 13:24:08 wft - * Replaced getdelta() with gettree(). - * - * Revision 3.3 82/11/28 21:33:15 wft - * fixed compartial() and compnum() for nil-parameters; fixed nils - * in error messages. Testprogram output shortenend. - * - * Revision 3.2 82/10/18 21:19:47 wft - * renamed compnum->cmpnum, compnumfld->cmpnumfld, - * numericrevno->numricrevno. - * - * Revision 3.1 82/10/11 19:46:09 wft - * changed expandsym() to check for source==nil; returns zero length string - * in that case. - */ - -#include "rcsbase.h" - -libId(revId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsrev.c 50472 1999-08-27 23:37:10Z peter $") - -static char const *branchtip P((char const*)); -static char const *lookupsym P((char const*)); -static char const *normalizeyear P((char const*,char[5])); -static struct hshentry *genbranch P((struct hshentry const*,char const*,int,char const*,char const*,char const*,struct hshentries**)); -static void absent P((char const*,int)); -static void cantfindbranch P((char const*,char const[datesize],char const*,char const*)); -static void store1 P((struct hshentries***,struct hshentry*)); - - - - int -countnumflds(s) - char const *s; -/* Given a pointer s to a dotted number (date or revision number), - * countnumflds returns the number of digitfields in s. - */ -{ - register char const *sp; - register int count; - if (!(sp=s) || !*sp) - return 0; - count = 1; - do { - if (*sp++ == '.') count++; - } while (*sp); - return(count); -} - - void -getbranchno(revno,branchno) - char const *revno; - struct buf *branchno; -/* Given a revision number revno, getbranchno copies the number of the branch - * on which revno is into branchno. If revno itself is a branch number, - * it is copied unchanged. - */ -{ - register int numflds; - register char *tp; - - bufscpy(branchno, revno); - numflds=countnumflds(revno); - if (!(numflds & 1)) { - tp = branchno->string; - while (--numflds) - while (*tp++ != '.') - continue; - *(tp-1)='\0'; - } -} - - - -int cmpnum(num1, num2) - char const *num1, *num2; -/* compares the two dotted numbers num1 and num2 lexicographically - * by field. Individual fields are compared numerically. - * returns <0, 0, >0 if num1num2, resp. - * omitted fields are assumed to be higher than the existing ones. -*/ -{ - register char const *s1, *s2; - register size_t d1, d2; - register int r; - - s1 = num1 ? num1 : ""; - s2 = num2 ? num2 : ""; - - for (;;) { - /* Give precedence to shorter one. */ - if (!*s1) - return (unsigned char)*s2; - if (!*s2) - return -1; - - /* Strip leading zeros, then find number of digits. */ - while (*s1=='0') ++s1; - while (*s2=='0') ++s2; - for (d1=0; isdigit(*(s1+d1)); d1++) continue; - for (d2=0; isdigit(*(s2+d2)); d2++) continue; - - /* Do not convert to integer; it might overflow! */ - if (d1 != d2) - return d1string; - while (length) { - while (*r1!='.' && *r1) - ++r1; - ++r1; - length--; - } - /* eliminate last '.'*/ - *(r1-1)='\0'; - return rev1->string; -} - - - - - static void -store1(store, next) - struct hshentries ***store; - struct hshentry *next; -/* - * Allocate a new list node that addresses NEXT. - * Append it to the list that **STORE is the end pointer of. - */ -{ - register struct hshentries *p; - - p = ftalloc(struct hshentries); - p->first = next; - **store = p; - *store = &p->rest; -} - -struct hshentry * genrevs(revno,date,author,state,store) - char const *revno, *date, *author, *state; - struct hshentries **store; -/* Function: finds the deltas needed for reconstructing the - * revision given by revno, date, author, and state, and stores pointers - * to these deltas into a list whose starting address is given by store. - * The last delta (target delta) is returned. - * If the proper delta could not be found, 0 is returned. - */ -{ - int length; - register struct hshentry * next; - int result; - char const *branchnum; - struct buf t; - char datebuf[datesize + zonelenmax]; - - bufautobegin(&t); - - if (!(next = Head)) { - rcserror("RCS file empty"); - goto norev; - } - - length = countnumflds(revno); - - if (length >= 1) { - /* at least one field; find branch exactly */ - while ((result=cmpnumfld(revno,next->num,1)) < 0) { - store1(&store, next); - next = next->next; - if (!next) { - rcserror("branch number %s too low", partialno(&t,revno,1)); - goto norev; - } - } - - if (result>0) { - absent(revno, 1); - goto norev; - } - } - if (length<=1){ - /* pick latest one on given branch */ - branchnum = next->num; /* works even for empty revno*/ - while (next && - cmpnumfld(branchnum,next->num,1) == 0 && - ( - (date && cmpdate(date,next->date) < 0) || - (author && strcmp(author,next->author) != 0) || - (state && strcmp(state,next->state) != 0) - ) - ) - { - store1(&store, next); - next=next->next; - } - if (!next || - (cmpnumfld(branchnum,next->num,1)!=0))/*overshot*/ { - cantfindbranch( - length ? revno : partialno(&t,branchnum,1), - date, author, state - ); - goto norev; - } else { - store1(&store, next); - } - *store = 0; - return next; - } - - /* length >=2 */ - /* find revision; may go low if length==2*/ - while ((result=cmpnumfld(revno,next->num,2)) < 0 && - (cmpnumfld(revno,next->num,1)==0) ) { - store1(&store, next); - next = next->next; - if (!next) - break; - } - - if (!next || cmpnumfld(revno,next->num,1) != 0) { - rcserror("revision number %s too low", partialno(&t,revno,2)); - goto norev; - } - if ((length>2) && (result!=0)) { - absent(revno, 2); - goto norev; - } - - /* print last one */ - store1(&store, next); - - if (length>2) - return genbranch(next,revno,length,date,author,state,store); - else { /* length == 2*/ - if (date && cmpdate(date,next->date)<0) { - rcserror("Revision %s has date %s.", - next->num, - date2str(next->date, datebuf) - ); - return 0; - } - if (author && strcmp(author,next->author)!=0) { - rcserror("Revision %s has author %s.", - next->num, next->author - ); - return 0; - } - if (state && strcmp(state,next->state)!=0) { - rcserror("Revision %s has state %s.", - next->num, - next->state ? next->state : "" - ); - return 0; - } - *store = 0; - return next; - } - - norev: - bufautoend(&t); - return 0; -} - - - - - static struct hshentry * -genbranch(bpoint, revno, length, date, author, state, store) - struct hshentry const *bpoint; - char const *revno; - int length; - char const *date, *author, *state; - struct hshentries **store; -/* Function: given a branchpoint, a revision number, date, author, and state, - * genbranch finds the deltas necessary to reconstruct the given revision - * from the branch point on. - * Pointers to the found deltas are stored in a list beginning with store. - * revno must be on a side branch. - * Return 0 on error. - */ -{ - int field; - register struct hshentry * next, * trail; - register struct branchhead const *bhead; - int result; - struct buf t; - char datebuf[datesize + zonelenmax]; - - field = 3; - bhead = bpoint->branches; - - do { - if (!bhead) { - bufautobegin(&t); - rcserror("no side branches present for %s", - partialno(&t,revno,field-1) - ); - bufautoend(&t); - return 0; - } - - /*find branch head*/ - /*branches are arranged in increasing order*/ - while (0 < (result=cmpnumfld(revno,bhead->hsh->num,field))) { - bhead = bhead->nextbranch; - if (!bhead) { - bufautobegin(&t); - rcserror("branch number %s too high", - partialno(&t,revno,field) - ); - bufautoend(&t); - return 0; - } - } - - if (result<0) { - absent(revno, field); - return 0; - } - - next = bhead->hsh; - if (length==field) { - /* pick latest one on that branch */ - trail = 0; - do { if ((!date || cmpdate(date,next->date)>=0) && - (!author || strcmp(author,next->author)==0) && - (!state || strcmp(state,next->state)==0) - ) trail = next; - next=next->next; - } while (next); - - if (!trail) { - cantfindbranch(revno, date, author, state); - return 0; - } else { /* print up to last one suitable */ - next = bhead->hsh; - while (next!=trail) { - store1(&store, next); - next=next->next; - } - store1(&store, next); - } - *store = 0; - return next; - } - - /* length > field */ - /* find revision */ - /* check low */ - if (cmpnumfld(revno,next->num,field+1)<0) { - bufautobegin(&t); - rcserror("revision number %s too low", - partialno(&t,revno,field+1) - ); - bufautoend(&t); - return 0; - } - do { - store1(&store, next); - trail = next; - next = next->next; - } while (next && cmpnumfld(revno,next->num,field+1)>=0); - - if ((length>field+1) && /*need exact hit */ - (cmpnumfld(revno,trail->num,field+1) !=0)){ - absent(revno, field+1); - return 0; - } - if (length == field+1) { - if (date && cmpdate(date,trail->date)<0) { - rcserror("Revision %s has date %s.", - trail->num, - date2str(trail->date, datebuf) - ); - return 0; - } - if (author && strcmp(author,trail->author)!=0) { - rcserror("Revision %s has author %s.", - trail->num, trail->author - ); - return 0; - } - if (state && strcmp(state,trail->state)!=0) { - rcserror("Revision %s has state %s.", - trail->num, - trail->state ? trail->state : "" - ); - return 0; - } - } - bhead = trail->branches; - - } while ((field+=2) <= length); - *store = 0; - return trail; -} - - - static char const * -lookupsym(id) - char const *id; -/* Function: looks up id in the list of symbolic names starting - * with pointer SYMBOLS, and returns a pointer to the corresponding - * revision number. Return 0 if not present. - */ -{ - register struct assoc const *next; - for (next = Symbols; next; next = next->nextassoc) - if (strcmp(id, next->symbol)==0) - return next->num; - return 0; -} - -int expandsym(source, target) - char const *source; - struct buf *target; -/* Function: Source points to a revision number. Expandsym copies - * the number to target, but replaces all symbolic fields in the - * source number with their numeric values. - * Expand a branch followed by `.' to the latest revision on that branch. - * Ignore `.' after a revision. Remove leading zeros. - * returns false on error; - */ -{ - return fexpandsym(source, target, (RILE*)0); -} - - int -fexpandsym(source, target, fp) - char const *source; - struct buf *target; - RILE *fp; -/* Same as expandsym, except if FP is nonzero, it is used to expand KDELIM. */ -{ - register char const *sp, *bp; - register char *tp; - char const *tlim; - int dots; - - sp = source; - bufalloc(target, 1); - tp = target->string; - if (!sp || !*sp) { /* Accept 0 pointer as a legal value. */ - *tp='\0'; - return true; - } - if (sp[0] == KDELIM && !sp[1]) { - if (!getoldkeys(fp)) - return false; - if (!*prevrev.string) { - workerror("working file lacks revision number"); - return false; - } - bufscpy(target, prevrev.string); - return true; - } - tlim = tp + target->size; - dots = 0; - - for (;;) { - register char *p = tp; - size_t s = tp - target->string; - int id = false; - for (;;) { - switch (ctab[(unsigned char)*sp]) { - case IDCHAR: - case LETTER: - case Letter: - id = true; - /* fall into */ - case DIGIT: - if (tlim <= p) - p = bufenlarge(target, &tlim); - *p++ = *sp++; - continue; - - default: - break; - } - break; - } - if (tlim <= p) - p = bufenlarge(target, &tlim); - *p = 0; - tp = target->string + s; - - if (id) { - bp = lookupsym(tp); - if (!bp) { - rcserror("Symbolic name `%s' is undefined.",tp); - return false; - } - } else { - /* skip leading zeros */ - for (bp = tp; *bp=='0' && isdigit(bp[1]); bp++) - continue; - - if (!*bp) - if (s || *sp!='.') - break; - else { - /* Insert default branch before initial `.'. */ - char const *b; - if (Dbranch) - b = Dbranch; - else if (Head) - b = Head->num; - else - break; - getbranchno(b, target); - bp = tp = target->string; - tlim = tp + target->size; - } - } - - while ((*tp++ = *bp++)) - if (tlim <= tp) - tp = bufenlarge(target, &tlim); - - switch (*sp++) { - case '\0': - return true; - - case '.': - if (!*sp) { - if (dots & 1) - break; - if (!(bp = branchtip(target->string))) - return false; - bufscpy(target, bp); - return true; - } - ++dots; - tp[-1] = '.'; - continue; - } - break; - } - - rcserror("improper revision number: %s", source); - return false; -} - - char const * -namedrev(name, delta) - char const *name; - struct hshentry *delta; -/* Yield NAME if it names DELTA, 0 otherwise. */ -{ - if (name) { - char const *id = 0, *p, *val; - for (p = name; ; p++) - switch (ctab[(unsigned char)*p]) { - case IDCHAR: - case LETTER: - case Letter: - id = name; - break; - - case DIGIT: - break; - - case UNKN: - if (!*p && id && - (val = lookupsym(id)) && - strcmp(val, delta->num) == 0 - ) - return id; - /* fall into */ - default: - return 0; - } - } - return 0; -} - - static char const * -branchtip(branch) - char const *branch; -{ - struct hshentry *h; - struct hshentries *hs; - - h = genrevs(branch, (char*)0, (char*)0, (char*)0, &hs); - return h ? h->num : (char const*)0; -} - - char const * -tiprev() -{ - return Dbranch ? branchtip(Dbranch) : Head ? Head->num : (char const*)0; -} - - - -#ifdef REVTEST - -/* -* Test the routines that generate a sequence of delta numbers -* needed to regenerate a given delta. -*/ - -char const cmdid[] = "revtest"; - - int -main(argc,argv) -int argc; char * argv[]; -{ - static struct buf numricrevno; - char symrevno[100]; /* used for input of revision numbers */ - char author[20]; - char state[20]; - char date[20]; - struct hshentries *gendeltas; - struct hshentry * target; - int i; - - if (argc<2) { - aputs("No input file\n",stderr); - exitmain(EXIT_FAILURE); - } - if (!(finptr=Iopen(argv[1], FOPEN_R, (struct stat*)0))) { - faterror("can't open input file %s", argv[1]); - } - Lexinit(); - getadmin(); - - gettree(); - - getdesc(false); - - do { - /* all output goes to stderr, to have diagnostics and */ - /* errors in sequence. */ - aputs("\nEnter revision number or or '.': ",stderr); - if (!fgets(symrevno, 100, stdin)) break; - if (*symrevno == '.') break; - aprintf(stderr,"%s;\n",symrevno); - expandsym(symrevno,&numricrevno); - aprintf(stderr,"expanded number: %s; ",numricrevno.string); - aprintf(stderr,"Date: "); - fgets(date, 20, stdin); aprintf(stderr,"%s; ",date); - aprintf(stderr,"Author: "); - fgets(author, 20, stdin); aprintf(stderr,"%s; ",author); - aprintf(stderr,"State: "); - fgets(state, 20, stdin); aprintf(stderr, "%s;\n", state); - target = genrevs(numricrevno.string, *date?date:(char *)0, *author?author:(char *)0, - *state?state:(char*)0, &gendeltas); - if (target) { - while (gendeltas) { - aprintf(stderr,"%s\n",gendeltas->first->num); - gendeltas = gendeltas->next; - } - } - } while (true); - aprintf(stderr,"done\n"); - exitmain(EXIT_SUCCESS); -} - -void exiterr() { _exit(EXIT_FAILURE); } - -#endif diff --git a/gnu/usr.bin/rcs/lib/rcssyn.c b/gnu/usr.bin/rcs/lib/rcssyn.c deleted file mode 100644 index 51f9e521829..00000000000 --- a/gnu/usr.bin/rcs/lib/rcssyn.c +++ /dev/null @@ -1,681 +0,0 @@ -/* RCS file syntactic analysis */ - -/****************************************************************************** - * Syntax Analysis. - * Keyword table - * Testprogram: define SYNTEST - * Compatibility with Release 2: define COMPAT2=1 - ****************************************************************************** - */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.15 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.14 1995/06/01 16:23:43 eggert - * (expand_names): Add "b" for -kb. - * (getdelta): Don't strip leading "19" from MKS RCS dates; see cmpdate. - * - * Revision 5.13 1994/03/20 04:52:58 eggert - * Remove lint. - * - * Revision 5.12 1993/11/03 17:42:27 eggert - * Parse MKS RCS dates; ignore \r in diff control lines. - * Don't discard ignored phrases. Improve quality of diagnostics. - * - * Revision 5.11 1992/07/28 16:12:44 eggert - * Avoid `unsigned'. Statement macro names now end in _. - * - * Revision 5.10 1992/01/24 18:44:19 eggert - * Move put routines to rcsgen.c. - * - * Revision 5.9 1992/01/06 02:42:34 eggert - * ULONG_MAX/10 -> ULONG_MAX_OVER_10 - * while (E) ; -> while (E) continue; - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Tune. - * - * Revision 5.7 1991/04/21 11:58:29 eggert - * Disambiguate names on shortname hosts. - * Fix errno bug. Add MS-DOS support. - * - * Revision 5.6 1991/02/28 19:18:51 eggert - * Fix null termination bug in reporting keyword expansion. - * - * Revision 5.5 1991/02/25 07:12:44 eggert - * Check diff output more carefully; avoid overflow. - * - * Revision 5.4 1990/11/01 05:28:48 eggert - * When ignoring unknown phrases, copy them to the output RCS file. - * Permit arbitrary data in logs and comment leaders. - * Don't check for nontext on initial checkin. - * - * Revision 5.3 1990/09/20 07:58:32 eggert - * Remove the test for non-text bytes; it caused more pain than it cured. - * - * Revision 5.2 1990/09/04 08:02:30 eggert - * Parse RCS files with no revisions. - * Don't strip leading white space from diff commands. Count RCS lines better. - * - * Revision 5.1 1990/08/29 07:14:06 eggert - * Add -kkvl. Clean old log messages too. - * - * Revision 5.0 1990/08/22 08:13:44 eggert - * Try to parse future RCS formats without barfing. - * Add -k. Don't require final newline. - * Remove compile-time limits; use malloc instead. - * Don't output branch keyword if there's no default branch, - * because RCS version 3 doesn't understand it. - * Tune. Remove lint. - * Add support for ISO 8859. Ansify and Posixate. - * Check that a newly checked-in file is acceptable as input to 'diff'. - * Check diff's output. - * - * Revision 4.6 89/05/01 15:13:32 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/08/09 19:13:21 eggert - * Allow cc -R; remove lint. - * - * Revision 4.4 87/12/18 11:46:16 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.3 87/10/18 10:39:36 narten - * Updating version numbers. Changes relative to 1.1 actually relative to - * 4.1 - * - * Revision 1.3 87/09/24 14:00:49 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:40 jenkins - * Port to suns - * - * Revision 4.1 83/03/28 11:38:49 wft - * Added parsing and printing of default branch. - * - * Revision 3.6 83/01/15 17:46:50 wft - * Changed readdelta() to initialize selector and log-pointer. - * Changed puttree to check for selector==DELETE; putdtext() uses DELNUMFORM. - * - * Revision 3.5 82/12/08 21:58:58 wft - * renamed Commentleader to Commleader. - * - * Revision 3.4 82/12/04 13:24:40 wft - * Added routine gettree(), which updates keeplock after reading the - * delta tree. - * - * Revision 3.3 82/11/28 21:30:11 wft - * Reading and printing of Suffix removed; version COMPAT2 skips the - * Suffix for files of release 2 format. Fixed problems with printing nil. - * - * Revision 3.2 82/10/18 21:18:25 wft - * renamed putdeltatext to putdtext. - * - * Revision 3.1 82/10/11 19:45:11 wft - * made sure getc() returns into an integer. - */ - - - -/* version COMPAT2 reads files of the format of release 2 and 3, but - * generates files of release 3 format. Need not be defined if no - * old RCS files generated with release 2 exist. - */ - -#include "rcsbase.h" - -libId(synId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcssyn.c 50472 1999-08-27 23:37:10Z peter $") - -static char const *getkeyval P((char const*,enum tokens,int)); -static int getdelta P((void)); -static int strn2expmode P((char const*,size_t)); -static struct hshentry *getdnum P((void)); -static void badDiffOutput P((char const*)) exiting; -static void diffLineNumberTooLarge P((char const*)) exiting; -static void getsemi P((char const*)); - -/* keyword table */ - -char const - Kaccess[] = "access", - Kauthor[] = "author", - Kbranch[] = "branch", - Kcomment[] = "comment", - Kdate[] = "date", - Kdesc[] = "desc", - Kexpand[] = "expand", - Khead[] = "head", - Klocks[] = "locks", - Klog[] = "log", - Knext[] = "next", - Kstate[] = "state", - Kstrict[] = "strict", - Ksymbols[] = "symbols", - Ktext[] = "text"; - -static char const -#if COMPAT2 - Ksuffix[] = "suffix", -#endif - K_branches[]= "branches"; - -static struct buf Commleader; -struct cbuf Comment; -struct cbuf Ignored; -struct access * AccessList; -struct assoc * Symbols; -struct rcslock *Locks; -int Expand; -int StrictLocks; -struct hshentry * Head; -char const * Dbranch; -int TotalDeltas; - - - static void -getsemi(key) - char const *key; -/* Get a semicolon to finish off a phrase started by KEY. */ -{ - if (!getlex(SEMI)) - fatserror("missing ';' after '%s'", key); -} - - static struct hshentry * -getdnum() -/* Get a delta number. */ -{ - register struct hshentry *delta = getnum(); - if (delta && countnumflds(delta->num)&1) - fatserror("%s isn't a delta number", delta->num); - return delta; -} - - - void -getadmin() -/* Read an and initialize the appropriate global variables. */ -{ - register char const *id; - struct access * newaccess; - struct assoc * newassoc; - struct rcslock *newlock; - struct hshentry * delta; - struct access **LastAccess; - struct assoc **LastSymbol; - struct rcslock **LastLock; - struct buf b; - struct cbuf cb; - - TotalDeltas=0; - - getkey(Khead); - Head = getdnum(); - getsemi(Khead); - - Dbranch = 0; - if (getkeyopt(Kbranch)) { - if ((delta = getnum())) - Dbranch = delta->num; - getsemi(Kbranch); - } - - -#if COMPAT2 - /* read suffix. Only in release 2 format */ - if (getkeyopt(Ksuffix)) { - if (nexttok==STRING) { - readstring(); nextlex(); /* Throw away the suffix. */ - } else if (nexttok==ID) { - nextlex(); - } - getsemi(Ksuffix); - } -#endif - - getkey(Kaccess); - LastAccess = &AccessList; - while ((id = getid())) { - newaccess = ftalloc(struct access); - newaccess->login = id; - *LastAccess = newaccess; - LastAccess = &newaccess->nextaccess; - } - *LastAccess = 0; - getsemi(Kaccess); - - getkey(Ksymbols); - LastSymbol = &Symbols; - while ((id = getid())) { - if (!getlex(COLON)) - fatserror("missing ':' in symbolic name definition"); - if (!(delta=getnum())) { - fatserror("missing number in symbolic name definition"); - } else { /*add new pair to association list*/ - newassoc = ftalloc(struct assoc); - newassoc->symbol=id; - newassoc->num = delta->num; - *LastSymbol = newassoc; - LastSymbol = &newassoc->nextassoc; - } - } - *LastSymbol = 0; - getsemi(Ksymbols); - - getkey(Klocks); - LastLock = &Locks; - while ((id = getid())) { - if (!getlex(COLON)) - fatserror("missing ':' in lock"); - if (!(delta=getdnum())) { - fatserror("missing number in lock"); - } else { /*add new pair to lock list*/ - newlock = ftalloc(struct rcslock); - newlock->login=id; - newlock->delta=delta; - *LastLock = newlock; - LastLock = &newlock->nextlock; - } - } - *LastLock = 0; - getsemi(Klocks); - - if ((StrictLocks = getkeyopt(Kstrict))) - getsemi(Kstrict); - - clear_buf(&Comment); - if (getkeyopt(Kcomment)) { - if (nexttok==STRING) { - Comment = savestring(&Commleader); - nextlex(); - } - getsemi(Kcomment); - } - - Expand = KEYVAL_EXPAND; - if (getkeyopt(Kexpand)) { - if (nexttok==STRING) { - bufautobegin(&b); - cb = savestring(&b); - if ((Expand = strn2expmode(cb.string,cb.size)) < 0) - fatserror("unknown expand mode %.*s", - (int)cb.size, cb.string - ); - bufautoend(&b); - nextlex(); - } - getsemi(Kexpand); - } - Ignored = getphrases(Kdesc); -} - -char const *const expand_names[] = { - /* These must agree with *_EXPAND in rcsbase.h. */ - "kv", "kvl", "k", "v", "o", "b", - 0 -}; - - int -str2expmode(s) - char const *s; -/* Yield expand mode corresponding to S, or -1 if bad. */ -{ - return strn2expmode(s, strlen(s)); -} - - static int -strn2expmode(s, n) - char const *s; - size_t n; -{ - char const *const *p; - - for (p = expand_names; *p; ++p) - if (memcmp(*p,s,n) == 0 && !(*p)[n]) - return p - expand_names; - return -1; -} - - - void -ignorephrases(key) - const char *key; -/* -* Ignore a series of phrases that do not start with KEY. -* Stop when the next phrase starts with a token that is not an identifier, -* or is KEY. -*/ -{ - for (;;) { - nextlex(); - if (nexttok != ID || strcmp(NextString,key) == 0) - break; - warnignore(); - hshenter=false; - for (;; nextlex()) { - switch (nexttok) { - case SEMI: hshenter=true; break; - case ID: - case NUM: ffree1(NextString); continue; - case STRING: readstring(); continue; - default: continue; - } - break; - } - } -} - - - static int -getdelta() -/* Function: reads a delta block. - * returns false if the current block does not start with a number. - */ -{ - register struct hshentry * Delta, * num; - struct branchhead **LastBranch, *NewBranch; - - if (!(Delta = getdnum())) - return false; - - hshenter = false; /*Don't enter dates into hashtable*/ - Delta->date = getkeyval(Kdate, NUM, false); - hshenter=true; /*reset hshenter for revision numbers.*/ - - Delta->author = getkeyval(Kauthor, ID, false); - - Delta->state = getkeyval(Kstate, ID, true); - - getkey(K_branches); - LastBranch = &Delta->branches; - while ((num = getdnum())) { - NewBranch = ftalloc(struct branchhead); - NewBranch->hsh = num; - *LastBranch = NewBranch; - LastBranch = &NewBranch->nextbranch; - } - *LastBranch = 0; - getsemi(K_branches); - - getkey(Knext); - Delta->next = num = getdnum(); - getsemi(Knext); - Delta->lockedby = 0; - Delta->log.string = 0; - Delta->selector = true; - Delta->ig = getphrases(Kdesc); - TotalDeltas++; - return (true); -} - - - void -gettree() -/* Function: Reads in the delta tree with getdelta(), then - * updates the lockedby fields. - */ -{ - struct rcslock const *currlock; - - while (getdelta()) - continue; - currlock=Locks; - while (currlock) { - currlock->delta->lockedby = currlock->login; - currlock = currlock->nextlock; - } -} - - - void -getdesc(prdesc) -int prdesc; -/* Function: read in descriptive text - * nexttok is not advanced afterwards. - * If prdesc is set, the text is printed to stdout. - */ -{ - - getkeystring(Kdesc); - if (prdesc) - printstring(); /*echo string*/ - else readstring(); /*skip string*/ -} - - - - - - - static char const * -getkeyval(keyword, token, optional) - char const *keyword; - enum tokens token; - int optional; -/* reads a pair of the form - * ; - * where token is one of or . optional indicates whether - * is optional. A pointer to - * the actual character string of or is returned. - */ -{ - register char const *val = 0; - - getkey(keyword); - if (nexttok==token) { - val = NextString; - nextlex(); - } else { - if (!optional) - fatserror("missing %s", keyword); - } - getsemi(keyword); - return(val); -} - - - void -unexpected_EOF() -{ - rcsfaterror("unexpected EOF in diff output"); -} - - void -initdiffcmd(dc) - register struct diffcmd *dc; -/* Initialize *dc suitably for getdiffcmd(). */ -{ - dc->adprev = 0; - dc->dafter = 0; -} - - static void -badDiffOutput(buf) - char const *buf; -{ - rcsfaterror("bad diff output line: %s", buf); -} - - static void -diffLineNumberTooLarge(buf) - char const *buf; -{ - rcsfaterror("diff line number too large: %s", buf); -} - - int -getdiffcmd(finfile, delimiter, foutfile, dc) - RILE *finfile; - FILE *foutfile; - int delimiter; - struct diffcmd *dc; -/* Get a editing command output by 'diff -n' from fin. - * The input is delimited by SDELIM if delimiter is set, EOF otherwise. - * Copy a clean version of the command to fout (if nonnull). - * Yield 0 for 'd', 1 for 'a', and -1 for EOF. - * Store the command's line number and length into dc->line1 and dc->nlines. - * Keep dc->adprev and dc->dafter up to date. - */ -{ - register int c; - declarecache; - register FILE *fout; - register char *p; - register RILE *fin; - long line1, nlines, t; - char buf[BUFSIZ]; - - fin = finfile; - fout = foutfile; - setupcache(fin); cache(fin); - cachegeteof_(c, { if (delimiter) unexpected_EOF(); return -1; } ) - if (delimiter) { - if (c==SDELIM) { - cacheget_(c) - if (c==SDELIM) { - buf[0] = c; - buf[1] = 0; - badDiffOutput(buf); - } - uncache(fin); - nextc = c; - if (fout) - aprintf(fout, "%c%c", SDELIM, c); - return -1; - } - } - p = buf; - do { - if (buf+BUFSIZ-2 <= p) { - rcsfaterror("diff output command line too long"); - } - *p++ = c; - cachegeteof_(c, unexpected_EOF();) - } while (c != '\n'); - uncache(fin); - if (delimiter) - ++rcsline; - *p = '\0'; - for (p = buf+1; (c = *p++) == ' '; ) - continue; - line1 = 0; - while (isdigit(c)) { - if ( - LONG_MAX/10 < line1 || - (t = line1 * 10, (line1 = t + (c - '0')) < t) - ) - diffLineNumberTooLarge(buf); - c = *p++; - } - while (c == ' ') - c = *p++; - nlines = 0; - while (isdigit(c)) { - if ( - LONG_MAX/10 < nlines || - (t = nlines * 10, (nlines = t + (c - '0')) < t) - ) - diffLineNumberTooLarge(buf); - c = *p++; - } - if (c == '\r') - c = *p++; - if (c || !nlines) { - badDiffOutput(buf); - } - if (line1+nlines < line1) - diffLineNumberTooLarge(buf); - switch (buf[0]) { - case 'a': - if (line1 < dc->adprev) { - rcsfaterror("backward insertion in diff output: %s", buf); - } - dc->adprev = line1 + 1; - break; - case 'd': - if (line1 < dc->adprev || line1 < dc->dafter) { - rcsfaterror("backward deletion in diff output: %s", buf); - } - dc->adprev = line1; - dc->dafter = line1 + nlines; - break; - default: - badDiffOutput(buf); - } - if (fout) { - aprintf(fout, "%s\n", buf); - } - dc->line1 = line1; - dc->nlines = nlines; - return buf[0] == 'a'; -} - - - -#ifdef SYNTEST - -/* Input an RCS file and print its internal data structures. */ - -char const cmdid[] = "syntest"; - - int -main(argc,argv) -int argc; char * argv[]; -{ - - if (argc<2) { - aputs("No input file\n",stderr); - exitmain(EXIT_FAILURE); - } - if (!(finptr = Iopen(argv[1], FOPEN_R, (struct stat*)0))) { - faterror("can't open input file %s", argv[1]); - } - Lexinit(); - getadmin(); - fdlock = STDOUT_FILENO; - putadmin(); - - gettree(); - - getdesc(true); - - nextlex(); - - if (!eoflex()) { - fatserror("expecting EOF"); - } - exitmain(EXIT_SUCCESS); -} - -void exiterr() { _exit(EXIT_FAILURE); } - -#endif diff --git a/gnu/usr.bin/rcs/lib/rcstime.c b/gnu/usr.bin/rcs/lib/rcstime.c deleted file mode 100644 index 9b5bd4281a8..00000000000 --- a/gnu/usr.bin/rcs/lib/rcstime.c +++ /dev/null @@ -1,191 +0,0 @@ -/* Convert between RCS time format and Posix and/or C formats. */ - -/* Copyright 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#include "rcsbase.h" -#include "partime.h" -#include "maketime.h" - -libId(rcstimeId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcstime.c 50472 1999-08-27 23:37:10Z peter $") - -static long zone_offset; /* seconds east of UTC, or TM_LOCAL_ZONE */ -static int use_zone_offset; /* if zero, use UTC without zone indication */ - -/* -* Convert Unix time to RCS format. -* For compatibility with older versions of RCS, -* dates from 1900 through 1999 are stored without the leading "19". -*/ - void -time2date(unixtime,date) - time_t unixtime; - char date[datesize]; -{ - register struct tm const *tm = time2tm(unixtime, RCSversiontm_year + ((unsigned)tm->tm_year < 100 ? 0 : 1900), - tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec - ); -} - -/* Like str2time, except die if an error was found. */ -static time_t str2time_checked P((char const*,time_t,long)); - static time_t -str2time_checked(source, default_time, default_zone) - char const *source; - time_t default_time; - long default_zone; -{ - time_t t = str2time(source, default_time, default_zone); - if (t == -1) - faterror("unknown date/time: %s", source); - return t; -} - -/* -* Parse a free-format date in SOURCE, convert it -* into RCS internal format, and store the result into TARGET. -*/ - void -str2date(source, target) - char const *source; - char target[datesize]; -{ - time2date( - str2time_checked(source, now(), - use_zone_offset ? zone_offset - : RCSversiontm_year + 1900, - z->tm_mon + 1, z->tm_mday, z->tm_hour, z->tm_min, z->tm_sec, - c, (int) (zone / (60*60)) - ); - if ((non_hour = zone % (60*60))) { -# if has_printf_dot - static char const fmt[] = ":%.2d"; -# else - static char const fmt[] = ":%02d"; -# endif - VOID sprintf(datebuf + strlen(datebuf), fmt, non_hour / 60); - if ((non_hour %= 60)) - VOID sprintf(datebuf + strlen(datebuf), fmt, non_hour); - } - } - return datebuf; -} diff --git a/gnu/usr.bin/rcs/lib/rcsutil.c b/gnu/usr.bin/rcs/lib/rcsutil.c deleted file mode 100644 index 5740c2e0dde..00000000000 --- a/gnu/usr.bin/rcs/lib/rcsutil.c +++ /dev/null @@ -1,1398 +0,0 @@ -/* RCS utility functions */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - - - - -/* - * Revision 5.20 1995/06/16 06:19:24 eggert - * (catchsig): Remove `return'. - * Update FSF address. - * - * Revision 5.19 1995/06/02 18:19:00 eggert - * (catchsigaction): New name for `catchsig', for sa_sigaction signature. - * Use nRCS even if !has_psiginfo, to remove unused variable warning. - * (setup_catchsig): Use sa_sigaction only if has_sa_sigaction. - * Use ENOTSUP only if defined. - * - * Revision 5.18 1995/06/01 16:23:43 eggert - * (catchsig, restoreints, setup_catchsig): Use SA_SIGINFO, not has_psiginfo, - * to determine whether to use SA_SIGINFO feature, - * but also check at runtime whether the feature works. - * (catchsig): If an mmap_signal occurs, report the affected file name. - * (unsupported_SA_SIGINFO, accessName): New variables. - * (setup_catchsig): If using SA_SIGINFO, use sa_sigaction, not sa_handler. - * If SA_SIGINFO fails, fall back on sa_handler method. - * - * (readAccessFilenameBuffer, dupSafer, fdSafer, fopenSafer): New functions. - * (concatenate): Remove. - * - * (runv): Work around bad_wait_if_SIGCHLD_ignored bug. - * Remove reference to OPEN_O_WORK. - * - * Revision 5.17 1994/03/20 04:52:58 eggert - * Specify subprocess input via file descriptor, not file name. - * Avoid messing with I/O buffers in the child process. - * Define dup in terms of F_DUPFD if it exists. - * Move setmtime to rcsedit.c. Remove lint. - * - * Revision 5.16 1993/11/09 17:40:15 eggert - * -V now prints version on stdout and exits. - * - * Revision 5.15 1993/11/03 17:42:27 eggert - * Use psiginfo and setreuid if available. Move date2str to maketime.c. - * - * Revision 5.14 1992/07/28 16:12:44 eggert - * Add -V. has_sigaction overrides sig_zaps_handler. Fix -M bug. - * Add mmap_signal, which minimizes signal handling for non-mmap hosts. - * - * Revision 5.13 1992/02/17 23:02:28 eggert - * Work around NFS mmap SIGBUS problem. Add -T support. - * - * Revision 5.12 1992/01/24 18:44:19 eggert - * Work around NFS mmap bug that leads to SIGBUS core dumps. lint -> RCS_lint - * - * Revision 5.11 1992/01/06 02:42:34 eggert - * O_BINARY -> OPEN_O_WORK - * while (E) ; -> while (E) continue; - * - * Revision 5.10 1991/10/07 17:32:46 eggert - * Support piece tables even if !has_mmap. - * - * Revision 5.9 1991/08/19 03:13:55 eggert - * Add spawn() support. Explicate assumptions about getting invoker's name. - * Standardize user-visible dates. Tune. - * - * Revision 5.8 1991/04/21 11:58:30 eggert - * Plug setuid security hole. - * - * Revision 5.6 1991/02/26 17:48:39 eggert - * Fix setuid bug. Use fread, fwrite more portably. - * Support waitpid. Don't assume -1 is acceptable to W* macros. - * strsave -> str_save (DG/UX name clash) - * - * Revision 5.5 1990/12/04 05:18:49 eggert - * Don't output a blank line after a signal diagnostic. - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.4 1990/11/01 05:03:53 eggert - * Remove unneeded setid check. Add awrite(), fremember(). - * - * Revision 5.3 1990/10/06 00:16:45 eggert - * Don't fread F if feof(F). - * - * Revision 5.2 1990/09/04 08:02:31 eggert - * Store fread()'s result in an fread_type object. - * - * Revision 5.1 1990/08/29 07:14:07 eggert - * Declare getpwuid() more carefully. - * - * Revision 5.0 1990/08/22 08:13:46 eggert - * Add setuid support. Permit multiple locks per user. - * Remove compile-time limits; use malloc instead. - * Switch to GMT. Permit dates past 1999/12/31. - * Add -V. Remove snooping. Ansify and Posixate. - * Tune. Some USG hosts define NSIG but not sys_siglist. - * Don't run /bin/sh if it's hopeless. - * Don't leave garbage behind if the output is an empty pipe. - * Clean up after SIGXCPU or SIGXFSZ. Print name of signal that caused cleanup. - * - * Revision 4.6 89/05/01 15:13:40 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/11/08 16:01:02 narten - * corrected use of varargs routines - * - * Revision 4.4 88/08/09 19:13:24 eggert - * Check for memory exhaustion. - * Permit signal handlers to yield either 'void' or 'int'; fix oldSIGINT botch. - * Use execv(), not system(); yield exit status like diff(1)'s. - * - * Revision 4.3 87/10/18 10:40:22 narten - * Updating version numbers. Changes relative to 1.1 actually - * relative to 4.1 - * - * Revision 1.3 87/09/24 14:01:01 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:43 jenkins - * Port to suns - * - * Revision 4.1 83/05/10 15:53:13 wft - * Added getcaller() and findlock(). - * Changed catchints() to check SIGINT for SIG_IGN before setting up the signal - * (needed for background jobs in older shells). Added restoreints(). - * Removed printing of full RCS path from logcommand(). - * - * Revision 3.8 83/02/15 15:41:49 wft - * Added routine fastcopy() to copy remainder of a file in blocks. - * - * Revision 3.7 82/12/24 15:25:19 wft - * added catchints(), ignoreints() for catching and ingnoring interrupts; - * fixed catchsig(). - * - * Revision 3.6 82/12/08 21:52:05 wft - * Using DATEFORM to format dates. - * - * Revision 3.5 82/12/04 18:20:49 wft - * Replaced SNOOPDIR with SNOOPFILE; changed addlock() to update - * lockedby-field. - * - * Revision 3.4 82/12/03 17:17:43 wft - * Added check to addlock() ensuring only one lock per person. - * Addlock also returns a pointer to the lock created. Deleted fancydate(). - * - * Revision 3.3 82/11/27 12:24:37 wft - * moved rmsema(), trysema(), trydiraccess(), getfullRCSname() to rcsfnms.c. - * Introduced macro SNOOP so that snoop can be placed in directory other than - * TARGETDIR. Changed %02d to %.2d for compatibility reasons. - * - * Revision 3.2 82/10/18 21:15:11 wft - * added function getfullRCSname(). - * - * Revision 3.1 82/10/13 16:17:37 wft - * Cleanup message is now suppressed in quiet mode. - */ - - - - -#include "rcsbase.h" - -libId(utilId, "$FreeBSD: stable/11/gnu/usr.bin/rcs/lib/rcsutil.c 50472 1999-08-27 23:37:10Z peter $") - -#if !has_memcmp - int -memcmp(s1, s2, n) - void const *s1, *s2; - size_t n; -{ - register unsigned char const - *p1 = (unsigned char const*)s1, - *p2 = (unsigned char const*)s2; - register size_t i = n; - register int r = 0; - while (i-- && !(r = (*p1++ - *p2++))) - ; - return r; -} -#endif - -#if !has_memcpy - void * -memcpy(s1, s2, n) - void *s1; - void const *s2; - size_t n; -{ - register char *p1 = (char*)s1; - register char const *p2 = (char const*)s2; - while (n--) - *p1++ = *p2++; - return s1; -} -#endif - -#if RCS_lint - malloc_type lintalloc; -#endif - -/* - * list of blocks allocated with ftestalloc() - * These blocks can be freed by ffree when we're done with the current file. - * We could put the free block inside struct alloclist, rather than a pointer - * to the free block, but that would be less portable. - */ -struct alloclist { - malloc_type alloc; - struct alloclist *nextalloc; -}; -static struct alloclist *alloced; - - - static malloc_type okalloc P((malloc_type)); - static malloc_type -okalloc(p) - malloc_type p; -{ - if (!p) - faterror("out of memory"); - return p; -} - - malloc_type -testalloc(size) - size_t size; -/* Allocate a block, testing that the allocation succeeded. */ -{ - return okalloc(malloc(size)); -} - - malloc_type -testrealloc(ptr, size) - malloc_type ptr; - size_t size; -/* Reallocate a block, testing that the allocation succeeded. */ -{ - return okalloc(realloc(ptr, size)); -} - - malloc_type -fremember(ptr) - malloc_type ptr; -/* Remember PTR in 'alloced' so that it can be freed later. Yield PTR. */ -{ - register struct alloclist *q = talloc(struct alloclist); - q->nextalloc = alloced; - alloced = q; - return q->alloc = ptr; -} - - malloc_type -ftestalloc(size) - size_t size; -/* Allocate a block, putting it in 'alloced' so it can be freed later. */ -{ - return fremember(testalloc(size)); -} - - void -ffree() -/* Free all blocks allocated with ftestalloc(). */ -{ - register struct alloclist *p, *q; - for (p = alloced; p; p = q) { - q = p->nextalloc; - tfree(p->alloc); - tfree(p); - } - alloced = 0; -} - - void -ffree1(f) - register char const *f; -/* Free the block f, which was allocated by ftestalloc. */ -{ - register struct alloclist *p, **a = &alloced; - - while ((p = *a)->alloc != f) - a = &p->nextalloc; - *a = p->nextalloc; - tfree(p->alloc); - tfree(p); -} - - char * -str_save(s) - char const *s; -/* Save s in permanently allocated storage. */ -{ - return strcpy(tnalloc(char, strlen(s)+1), s); -} - - char * -fstr_save(s) - char const *s; -/* Save s in storage that will be deallocated when we're done with this file. */ -{ - return strcpy(ftnalloc(char, strlen(s)+1), s); -} - - char * -cgetenv(name) - char const *name; -/* Like getenv(), but yield a copy; getenv() can overwrite old results. */ -{ - register char *p; - - return (p=getenv(name)) ? str_save(p) : p; -} - - char const * -getusername(suspicious) - int suspicious; -/* Get the caller's login name. Trust only getwpuid if SUSPICIOUS. */ -{ - static char *name; - - if (!name) { - if ( - /* Prefer getenv() unless suspicious; it's much faster. */ -# if getlogin_is_secure - (suspicious - || ( - !(name = cgetenv("LOGNAME")) - && !(name = cgetenv("USER")) - )) - && !(name = getlogin()) -# else - suspicious - || ( - !(name = cgetenv("LOGNAME")) - && !(name = cgetenv("USER")) - && !(name = getlogin()) - ) -# endif - ) { -#if has_getuid && has_getpwuid - struct passwd const *pw = getpwuid(ruid()); - if (!pw) - faterror("no password entry for userid %lu", - (unsigned long)ruid() - ); - name = pw->pw_name; -#else -#if has_setuid - faterror("setuid not supported"); -#else - faterror("Who are you? Please setenv LOGNAME."); -#endif -#endif - } - checksid(name); - } - return name; -} - - - - -#if has_signal - -/* - * Signal handling - * - * Standard C places too many restrictions on signal handlers. - * We obey as many of them as we can. - * Posix places fewer restrictions, and we are Posix-compatible here. - */ - -static sig_atomic_t volatile heldsignal, holdlevel; -#ifdef SA_SIGINFO - static int unsupported_SA_SIGINFO; - static siginfo_t bufsiginfo; - static siginfo_t *volatile heldsiginfo; -#endif - - -#if has_NFS && has_mmap && large_memory && mmap_signal - static char const *accessName; - - void - readAccessFilenameBuffer(filename, p) - char const *filename; - unsigned char const *p; - { - unsigned char volatile t; - accessName = filename; - t = *p; - accessName = 0; - } -#else -# define accessName ((char const *) 0) -#endif - - -#if !has_psignal - -# define psignal my_psignal - static void my_psignal P((int,char const*)); - static void -my_psignal(sig, s) - int sig; - char const *s; -{ - char const *sname = "Unknown signal"; -# if has_sys_siglist && defined(NSIG) - if ((unsigned)sig < NSIG) - sname = sys_siglist[sig]; -# else - switch (sig) { -# ifdef SIGHUP - case SIGHUP: sname = "Hangup"; break; -# endif -# ifdef SIGINT - case SIGINT: sname = "Interrupt"; break; -# endif -# ifdef SIGPIPE - case SIGPIPE: sname = "Broken pipe"; break; -# endif -# ifdef SIGQUIT - case SIGQUIT: sname = "Quit"; break; -# endif -# ifdef SIGTERM - case SIGTERM: sname = "Terminated"; break; -# endif -# ifdef SIGXCPU - case SIGXCPU: sname = "Cputime limit exceeded"; break; -# endif -# ifdef SIGXFSZ - case SIGXFSZ: sname = "Filesize limit exceeded"; break; -# endif -# if has_mmap && large_memory -# if defined(SIGBUS) && mmap_signal==SIGBUS - case SIGBUS: sname = "Bus error"; break; -# endif -# if defined(SIGSEGV) && mmap_signal==SIGSEGV - case SIGSEGV: sname = "Segmentation fault"; break; -# endif -# endif - } -# endif - - /* Avoid calling sprintf etc., in case they're not reentrant. */ - { - char const *p; - char buf[BUFSIZ], *b = buf; - for (p = s; *p; *b++ = *p++) - continue; - *b++ = ':'; - *b++ = ' '; - for (p = sname; *p; *b++ = *p++) - continue; - *b++ = '\n'; - VOID write(STDERR_FILENO, buf, b - buf); - } -} -#endif - -static signal_type catchsig P((int)); -#ifdef SA_SIGINFO - static signal_type catchsigaction P((int,siginfo_t*,void*)); -#endif - - static signal_type -catchsig(s) - int s; -#ifdef SA_SIGINFO -{ - catchsigaction(s, (siginfo_t *)0, (void *)0); -} - static signal_type -catchsigaction(s, i, c) - int s; - siginfo_t *i; - void *c; -#endif -{ -# if sig_zaps_handler - /* If a signal arrives before we reset the handler, we lose. */ - VOID signal(s, SIG_IGN); -# endif - -# ifdef SA_SIGINFO - if (!unsupported_SA_SIGINFO) - i = 0; -# endif - - if (holdlevel) { - heldsignal = s; -# ifdef SA_SIGINFO - if (i) { - bufsiginfo = *i; - heldsiginfo = &bufsiginfo; - } -# endif - return; - } - - ignoreints(); - setrid(); - if (!quietflag) { - /* Avoid calling sprintf etc., in case they're not reentrant. */ - char const *p; - char buf[BUFSIZ], *b = buf; - - if ( ! ( -# if has_mmap && large_memory && mmap_signal - /* Check whether this signal was planned. */ - s == mmap_signal && accessName -# else - 0 -# endif - )) { - char const *nRCS = "\nRCS"; -# if defined(SA_SIGINFO) && has_si_errno && has_mmap && large_memory && mmap_signal - if (s == mmap_signal && i && i->si_errno) { - errno = i->si_errno; - perror(nRCS++); - } -# endif -# if defined(SA_SIGINFO) && has_psiginfo - if (i) - psiginfo(i, nRCS); - else - psignal(s, nRCS); -# else - psignal(s, nRCS); -# endif - } - - for (p = "RCS: "; *p; *b++ = *p++) - continue; -# if has_mmap && large_memory && mmap_signal - if (s == mmap_signal) { - p = accessName; - if (!p) - p = "Was a file changed by some other process? "; - else { - char const *p1; - for (p1 = p; *p1; p1++) - continue; - VOID write(STDERR_FILENO, buf, b - buf); - VOID write(STDERR_FILENO, p, p1 - p); - b = buf; - p = ": Permission denied. "; - } - while (*p) - *b++ = *p++; - } -# endif - for (p = "Cleaning up.\n"; *p; *b++ = *p++) - continue; - VOID write(STDERR_FILENO, buf, b - buf); - } - exiterr(); -} - - void -ignoreints() -{ - ++holdlevel; -} - - void -restoreints() -{ - if (!--holdlevel && heldsignal) -# ifdef SA_SIGINFO - VOID catchsigaction(heldsignal, heldsiginfo, (void *)0); -# else - VOID catchsig(heldsignal); -# endif -} - - -static void setup_catchsig P((int const*,int)); - -#if has_sigaction - - static void check_sig P((int)); - static void - check_sig(r) - int r; - { - if (r != 0) - efaterror("signal handling"); - } - - static void - setup_catchsig(sig, sigs) - int const *sig; - int sigs; - { - register int i, j; - struct sigaction act; - - for (i=sigs; 0<=--i; ) { - check_sig(sigaction(sig[i], (struct sigaction*)0, &act)); - if (act.sa_handler != SIG_IGN) { - act.sa_handler = catchsig; -# ifdef SA_SIGINFO - if (!unsupported_SA_SIGINFO) { -# if has_sa_sigaction - act.sa_sigaction = catchsigaction; -# else - act.sa_handler = catchsigaction; -# endif - act.sa_flags |= SA_SIGINFO; - } -# endif - for (j=sigs; 0<=--j; ) - check_sig(sigaddset(&act.sa_mask, sig[j])); - if (sigaction(sig[i], &act, (struct sigaction*)0) != 0) { -# if defined(SA_SIGINFO) && defined(ENOTSUP) - if (errno == ENOTSUP && !unsupported_SA_SIGINFO) { - /* Turn off use of SA_SIGINFO and try again. */ - unsupported_SA_SIGINFO = 1; - i++; - continue; - } -# endif - check_sig(-1); - } - } - } - } - -#else -#if has_sigblock - - static void - setup_catchsig(sig, sigs) - int const *sig; - int sigs; - { - register int i; - int mask; - - mask = 0; - for (i=sigs; 0<=--i; ) - mask |= sigmask(sig[i]); - mask = sigblock(mask); - for (i=sigs; 0<=--i; ) - if ( - signal(sig[i], catchsig) == SIG_IGN && - signal(sig[i], SIG_IGN) != catchsig - ) - faterror("signal catcher failure"); - VOID sigsetmask(mask); - } - -#else - - static void - setup_catchsig(sig, sigs) - int const *sig; - int sigs; - { - register i; - - for (i=sigs; 0<=--i; ) - if ( - signal(sig[i], SIG_IGN) != SIG_IGN && - signal(sig[i], catchsig) != SIG_IGN - ) - faterror("signal catcher failure"); - } - -#endif -#endif - - -static int const regsigs[] = { -# ifdef SIGHUP - SIGHUP, -# endif -# ifdef SIGINT - SIGINT, -# endif -# ifdef SIGPIPE - SIGPIPE, -# endif -# ifdef SIGQUIT - SIGQUIT, -# endif -# ifdef SIGTERM - SIGTERM, -# endif -# ifdef SIGXCPU - SIGXCPU, -# endif -# ifdef SIGXFSZ - SIGXFSZ, -# endif -}; - - void -catchints() -{ - static int catching_ints; - if (!catching_ints) { - catching_ints = true; - setup_catchsig(regsigs, (int) (sizeof(regsigs)/sizeof(*regsigs))); - } -} - -#if has_mmap && large_memory && mmap_signal - - /* - * If you mmap an NFS file, and someone on another client removes the last - * link to that file, and you later reference an uncached part of that file, - * you'll get a SIGBUS or SIGSEGV (depending on the operating system). - * Catch the signal and report the problem to the user. - * Unfortunately, there's no portable way to differentiate between this - * problem and actual bugs in the program. - * This NFS problem is rare, thank goodness. - * - * This can also occur if someone truncates the file, even without NFS. - */ - - static int const mmapsigs[] = { mmap_signal }; - - void - catchmmapints() - { - static int catching_mmap_ints; - if (!catching_mmap_ints) { - catching_mmap_ints = true; - setup_catchsig(mmapsigs, (int)(sizeof(mmapsigs)/sizeof(*mmapsigs))); - } - } -#endif - -#endif /* has_signal */ - - - void -fastcopy(inf,outf) - register RILE *inf; - FILE *outf; -/* Function: copies the remainder of file inf to outf. - */ -{ -#if large_memory -# if maps_memory - awrite((char const*)inf->ptr, (size_t)(inf->lim - inf->ptr), outf); - inf->ptr = inf->lim; -# else - for (;;) { - awrite((char const*)inf->ptr, (size_t)(inf->readlim - inf->ptr), outf); - inf->ptr = inf->readlim; - if (inf->ptr == inf->lim) - break; - VOID Igetmore(inf); - } -# endif -#else - char buf[BUFSIZ*8]; - register fread_type rcount; - - /*now read the rest of the file in blocks*/ - while (!feof(inf)) { - if (!(rcount = Fread(buf,sizeof(*buf),sizeof(buf),inf))) { - testIerror(inf); - return; - } - awrite(buf, (size_t)rcount, outf); - } -#endif -} - -#ifndef SSIZE_MAX - /* This does not work in #ifs, but it's good enough for us. */ - /* Underestimating SSIZE_MAX may slow us down, but it won't break us. */ -# define SSIZE_MAX ((unsigned)-1 >> 1) -#endif - - void -awrite(buf, chars, f) - char const *buf; - size_t chars; - FILE *f; -{ - /* Posix 1003.1-1990 ssize_t hack */ - while (SSIZE_MAX < chars) { - if (Fwrite(buf, sizeof(*buf), SSIZE_MAX, f) != SSIZE_MAX) - Oerror(); - buf += SSIZE_MAX; - chars -= SSIZE_MAX; - } - - if (Fwrite(buf, sizeof(*buf), chars, f) != chars) - Oerror(); -} - -/* dup a file descriptor; the result must not be stdin, stdout, or stderr. */ - static int dupSafer P((int)); - static int -dupSafer(fd) - int fd; -{ -# ifdef F_DUPFD - return fcntl(fd, F_DUPFD, STDERR_FILENO + 1); -# else - int e, f, i, used = 0; - while (STDIN_FILENO <= (f = dup(fd)) && f <= STDERR_FILENO) - used |= 1<string); - bufrealloc(b, bl + sl + 4); - p = b->string + bl; - *p++ = c; - *p++ = '\''; - while (*s) { - if (*s == '\'') { - *p++ = '\''; - *p++ = '\\'; - *p++ = '\''; - } - *p++ = *s++; - } - *p++ = '\''; - *p = 0; -} - -#endif - -#if !has_spawn && has_fork -/* -* Output the string S to stderr, without touching any I/O buffers. -* This is useful if you are a child process, whose buffers are usually wrong. -* Exit immediately if the write does not completely succeed. -*/ -static void write_stderr P((char const *)); - static void -write_stderr(s) - char const *s; -{ - size_t slen = strlen(s); - if (write(STDERR_FILENO, s, slen) != slen) - _exit(EXIT_TROUBLE); -} -#endif - -/* -* Run a command. -* infd, if not -1, is the input file descriptor. -* outname, if nonzero, is the name of the output file. -* args[1..] form the command to be run; args[0] might be modified. -*/ - int -runv(infd, outname, args) - int infd; - char const *outname, **args; -{ - int wstatus; - -#if bad_wait_if_SIGCHLD_ignored - static int fixed_SIGCHLD; - if (!fixed_SIGCHLD) { - fixed_SIGCHLD = true; -# ifndef SIGCHLD -# define SIGCHLD SIGCLD -# endif - VOID signal(SIGCHLD, SIG_DFL); - } -#endif - - oflush(); - eflush(); - { -#if has_spawn - int in, out; - char const *file; - - in = -1; - if (infd != -1 && infd != STDIN_FILENO) { - if ((in = dup(STDIN_FILENO)) < 0) { - if (errno != EBADF) - efaterror("spawn input setup"); - in = -2; - } else { -# ifdef F_DUPFD - if (close(STDIN_FILENO) != 0) - efaterror("spawn input close"); -# endif - } - if ( -# ifdef F_DUPFD - fcntl(infd, F_DUPFD, STDIN_FILENO) != STDIN_FILENO -# else - dup2(infd, STDIN_FILENO) != STDIN_FILENO -# endif - ) - efaterror("spawn input redirection"); - } - - out = -1; - if (outname) { - if ((out = dup(STDOUT_FILENO)) < 0) { - if (errno != EBADF) - efaterror("spawn output setup"); - out = -2; - } - if (fdreopen( - STDOUT_FILENO, outname, - O_CREAT | O_TRUNC | O_WRONLY - ) < 0) - efaterror(outname); - } - - wstatus = spawn_RCS(0, args[1], (char**)(args + 1)); -# ifdef RCS_SHELL - if (wstatus == -1 && errno == ENOEXEC) { - args[0] = RCS_SHELL; - wstatus = spawnv(0, args[0], (char**)args); - } -# endif - redirect(in, STDIN_FILENO); - redirect(out, STDOUT_FILENO); -#else -#if has_fork - pid_t pid; - if (!(pid = vfork())) { - char const *notfound; - if (infd != -1 && infd != STDIN_FILENO && ( -# ifdef F_DUPFD - (VOID close(STDIN_FILENO), - fcntl(infd, F_DUPFD, STDIN_FILENO) != STDIN_FILENO) -# else - dup2(infd, STDIN_FILENO) != STDIN_FILENO -# endif - )) { - /* Avoid perror since it may misuse buffers. */ - write_stderr(args[1]); - write_stderr(": I/O redirection failed\n"); - _exit(EXIT_TROUBLE); - } - - if (outname) - if (fdreopen( - STDOUT_FILENO, outname, - O_CREAT | O_TRUNC | O_WRONLY - ) < 0) { - /* Avoid perror since it may misuse buffers. */ - write_stderr(args[1]); - write_stderr(": "); - write_stderr(outname); - write_stderr(": cannot create\n"); - _exit(EXIT_TROUBLE); - } - VOID exec_RCS(args[1], (char**)(args + 1)); - notfound = args[1]; -# ifdef RCS_SHELL - if (errno == ENOEXEC) { - args[0] = notfound = RCS_SHELL; - VOID execv(args[0], (char**)args); - } -# endif - - /* Avoid perror since it may misuse buffers. */ - write_stderr(notfound); - write_stderr(": not found\n"); - _exit(EXIT_TROUBLE); - } - if (pid < 0) - efaterror("fork"); -# if has_waitpid - if (waitpid(pid, &wstatus, 0) < 0) - efaterror("waitpid"); -# else - { - pid_t w; - do { - if ((w = wait(&wstatus)) < 0) - efaterror("wait"); - } while (w != pid); - } -# endif -#else - static struct buf b; - char const *p; - - /* Use system(). On many hosts system() discards signals. Yuck! */ - p = args + 1; - bufscpy(&b, *p); - while (*++p) - bufargcat(&b, ' ', *p); - if (infd != -1 && infd != STDIN_FILENO) { - char redirection[32]; - VOID sprintf(redirection, "<&%d", infd); - bufscat(&b, redirection); - } - if (outname) - bufargcat(&b, '>', outname); - wstatus = system(b.string); -#endif -#endif - } - if (!WIFEXITED(wstatus)) { - if (WIFSIGNALED(wstatus)) { - psignal(WTERMSIG(wstatus), args[1]); - fatcleanup(1); - } - faterror("%s failed for unknown reason", args[1]); - } - return WEXITSTATUS(wstatus); -} - -#define CARGSMAX 20 -/* -* Run a command. -* infd, if not -1, is the input file descriptor. -* outname, if nonzero, is the name of the output file. -* The remaining arguments specify the command and its arguments. -*/ - int -#if has_prototypes -run(int infd, char const *outname, ...) -#else - /*VARARGS2*/ -run(infd, outname, va_alist) - int infd; - char const *outname; - va_dcl -#endif -{ - va_list ap; - char const *rgargs[CARGSMAX]; - register int i; - vararg_start(ap, outname); - for (i = 1; (rgargs[i++] = va_arg(ap, char const*)); ) - if (CARGSMAX <= i) - faterror("too many command arguments"); - va_end(ap); - return runv(infd, outname, rgargs); -} - - -int RCSversion; - - void -setRCSversion(str) - char const *str; -{ - static int oldversion; - - register char const *s = str + 2; - - if (*s) { - int v = VERSION_DEFAULT; - - if (oldversion) - redefined('V'); - oldversion = true; - v = 0; - while (isdigit(*s)) - v = 10*v + *s++ - '0'; - if (*s) - error("%s isn't a number", str); - else if (v < VERSION_min || VERSION_max < v) - error("%s out of range %d..%d", - str, VERSION_min, VERSION_max - ); - - RCSversion = VERSION(v); - } else { - printf("RCS version %s\n", RCS_version_string); - exit(0); - } -} - - int -getRCSINIT(argc, argv, newargv) - int argc; - char **argv, ***newargv; -{ - register char *p, *q, **pp; - char const *ev; - size_t n; - - if ((ev = cgetenv("RCSLOCALID"))) - setRCSLocalId(ev); - - if ((ev = cgetenv("RCSINCEXC"))) - setIncExc(ev); - - if (!(q = cgetenv("RCSINIT"))) - *newargv = argv; - else { - n = argc + 2; - /* - * Count spaces in RCSINIT to allocate a new arg vector. - * This is an upper bound, but it's OK even if too large. - */ - for (p = q; ; ) { - switch (*p++) { - default: - continue; - - case ' ': - case '\b': case '\f': case '\n': - case '\r': case '\t': case '\v': - n++; - continue; - - case '\0': - break; - } - break; - } - *newargv = pp = tnalloc(char*, n); - *pp++ = *argv++; /* copy program name */ - for (p = q; ; ) { - for (;;) { - switch (*q) { - case '\0': - goto copyrest; - - case ' ': - case '\b': case '\f': case '\n': - case '\r': case '\t': case '\v': - q++; - continue; - } - break; - } - *pp++ = p; - ++argc; - for (;;) { - switch ((*p++ = *q++)) { - case '\0': - goto copyrest; - - case '\\': - if (!*q) - goto copyrest; - p[-1] = *q++; - continue; - - default: - continue; - - case ' ': - case '\b': case '\f': case '\n': - case '\r': case '\t': case '\v': - break; - } - break; - } - p[-1] = '\0'; - } - copyrest: - while ((*pp++ = *argv++)) - continue; - } - return argc; -} - - -#define cacheid(E) static uid_t i; static int s; if (!s){ s=1; i=(E); } return i - -#if has_getuid - uid_t ruid() { cacheid(getuid()); } -#endif -#if has_setuid - uid_t euid() { cacheid(geteuid()); } -#endif - - -#if has_setuid - -/* - * Setuid execution really works only with Posix 1003.1a Draft 5 seteuid(), - * because it lets us switch back and forth between arbitrary users. - * If seteuid() doesn't work, we fall back on setuid(), - * which works if saved setuid is supported, - * unless the real or effective user is root. - * This area is such a mess that we always check switches at runtime. - */ - - static void -#if has_prototypes -set_uid_to(uid_t u) -#else - set_uid_to(u) uid_t u; -#endif -/* Become user u. */ -{ - static int looping; - - if (euid() == ruid()) - return; -#if (has_fork||has_spawn) && DIFF_ABSOLUTE -# if has_setreuid - if (setreuid(u==euid() ? ruid() : euid(), u) != 0) - efaterror("setuid"); -# else - if (seteuid(u) != 0) - efaterror("setuid"); -# endif -#endif - if (geteuid() != u) { - if (looping) - return; - looping = true; - faterror("root setuid not supported" + (u?5:0)); - } -} - -static int stick_with_euid; - - void -/* Ignore all calls to seteid() and setrid(). */ -nosetid() -{ - stick_with_euid = true; -} - - void -seteid() -/* Become effective user. */ -{ - if (!stick_with_euid) - set_uid_to(euid()); -} - - void -setrid() -/* Become real user. */ -{ - if (!stick_with_euid) - set_uid_to(ruid()); -} -#endif - - time_t -now() -{ - static time_t t; - if (!t && time(&t) == -1) - efaterror("time"); - return t; -} diff --git a/gnu/usr.bin/rcs/lib/version.c b/gnu/usr.bin/rcs/lib/version.c deleted file mode 100644 index 81f5585b9d1..00000000000 --- a/gnu/usr.bin/rcs/lib/version.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "rcsbase.h" -char const RCS_version_string[] = "5.7"; diff --git a/gnu/usr.bin/rcs/merge/Makefile b/gnu/usr.bin/rcs/merge/Makefile deleted file mode 100644 index 9022bc4bf6e..00000000000 --- a/gnu/usr.bin/rcs/merge/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROG= merge -SRCS= merge.c -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/merge/Makefile.depend b/gnu/usr.bin/rcs/merge/Makefile.depend deleted file mode 100644 index 80c8ce12204..00000000000 --- a/gnu/usr.bin/rcs/merge/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/merge/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/merge/merge.1 b/gnu/usr.bin/rcs/merge/merge.1 deleted file mode 100644 index 1069b378d79..00000000000 --- a/gnu/usr.bin/rcs/merge/merge.1 +++ /dev/null @@ -1,137 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/merge/merge.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \&\s-1RCS\s0 -.TH MERGE 1 \*(Dt GNU -.SH NAME -merge \- three-way file merge -.SH SYNOPSIS -.B merge -[ -.I "options" -] -.I "file1 file2 file3" -.SH DESCRIPTION -.B merge -incorporates all changes that lead from -.I file2 -to -.I file3 -into -.IR file1 . -The result ordinarily goes into -.IR file1 . -.B merge -is useful for combining separate changes to an original. Suppose -.I file2 -is the original, and both -.I file1 -and -.I file3 -are modifications of -.IR file2 . -Then -.B merge -combines both changes. -.PP -A conflict occurs if both -.I file1 -and -.I file3 -have changes in a common segment of lines. -If a conflict is found, -.B merge -normally outputs a warning and brackets the conflict with -.B <<<<<<< -and -.B >>>>>>> -lines. -A typical conflict will look like this: -.LP -.RS -.nf -.BI <<<<<<< " file A" -.I "lines in file A" -.B "=======" -.I "lines in file B" -.BI >>>>>>> " file B" -.RE -.fi -.LP -If there are conflicts, the user should edit the result and delete one of the -alternatives. -.SH OPTIONS -.TP -.B \-A -Output conflicts using the -.B \-A -style of -.BR diff3 (1), -if supported by -.BR diff3 . -This merges all changes leading from -.I file2 -to -.I file3 -into -.IR file1 , -and generates the most verbose output. -.TP -\f3\-E\fP, \f3\-e\fP -These options specify conflict styles that generate less information -than -.BR \-A . -See -.BR diff3 (1) -for details. -The default is -.BR \-E . -With -.BR \-e , -.B merge -does not warn about conflicts. -.TP -.BI \-L " label" -This option may be given up to three times, and specifies labels -to be used in place of the corresponding file names in conflict reports. -That is, -.B "merge\ \-L\ x\ \-L\ y\ \-L\ z\ a\ b\ c" -generates output that looks like it came from files -.BR x , -.B y -and -.B z -instead of from files -.BR a , -.B b -and -.BR c . -.TP -.BI \-p -Send results to standard output instead of overwriting -.IR file1 . -.TP -.BI \-q -Quiet; do not warn about conflicts. -.TP -.BI \-V -Print \*r's version number. -.SH DIAGNOSTICS -Exit status is 0 for no conflicts, 1 for some conflicts, 2 for trouble. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH SEE ALSO -diff3(1), diff(1), rcsmerge(1), co(1). -.SH BUGS -It normally does not make sense to merge binary files as if they were text, but -.B merge -tries to do it anyway. -.br diff --git a/gnu/usr.bin/rcs/merge/merge.c b/gnu/usr.bin/rcs/merge/merge.c deleted file mode 100644 index 52aaa23fb31..00000000000 --- a/gnu/usr.bin/rcs/merge/merge.c +++ /dev/null @@ -1,113 +0,0 @@ -/* merge - three-way file merge */ - -/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#include "rcsbase.h" - -static void badoption P((char const*)); - -static char const usage[] = - "\nmerge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3"; - - static void -badoption(a) - char const *a; -{ - error("unknown option: %s%s", a, usage); -} - - -mainProg(mergeId, "merge", "$FreeBSD: stable/11/gnu/usr.bin/rcs/merge/merge.c 50472 1999-08-27 23:37:10Z peter $") -{ - register char const *a; - char const *arg[3], *label[3], *edarg = 0; - int labels, tostdout; - - labels = 0; - tostdout = false; - - for (; (a = *++argv) && *a++ == '-'; --argc) { - switch (*a++) { - case 'A': case 'E': case 'e': - if (edarg && edarg[1] != (*argv)[1]) - error("%s and %s are incompatible", - edarg, *argv - ); - edarg = *argv; - break; - - case 'p': tostdout = true; break; - case 'q': quietflag = true; break; - - case 'L': - if (3 <= labels) - faterror("too many -L options"); - if (!(label[labels++] = *++argv)) - faterror("-L needs following argument"); - --argc; - break; - - case 'V': - printf("RCS version %s\n", RCS_version_string); - exitmain(0); - - default: - badoption(a - 2); - continue; - } - if (*a) - badoption(a - 2); - } - - if (argc != 4) - faterror("%s arguments%s", - argc<4 ? "not enough" : "too many", usage - ); - - /* This copy keeps us `const'-clean. */ - arg[0] = argv[0]; - arg[1] = argv[1]; - arg[2] = argv[2]; - - for (; labels < 3; labels++) - label[labels] = arg[labels]; - - if (nerror) - exiterr(); - exitmain(merge(tostdout, edarg, label, arg)); -} - - -#if RCS_lint -# define exiterr mergeExit -#endif - void -exiterr() -{ - tempunlink(); - _exit(DIFF_TROUBLE); -} diff --git a/gnu/usr.bin/rcs/rcs/Makefile b/gnu/usr.bin/rcs/rcs/Makefile deleted file mode 100644 index 4343a82c56f..00000000000 --- a/gnu/usr.bin/rcs/rcs/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcs/Makefile 74861 2001-03-27 14:59:06Z ru $ - -PROG= rcs -MAN= rcs.1 rcsintro.1 rcsfile.5 -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/rcs/Makefile.depend b/gnu/usr.bin/rcs/rcs/Makefile.depend deleted file mode 100644 index 7629114cf2a..00000000000 --- a/gnu/usr.bin/rcs/rcs/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcs/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/rcs/rcs.1 b/gnu/usr.bin/rcs/rcs/rcs.1 deleted file mode 100644 index cd4685e91b6..00000000000 --- a/gnu/usr.bin/rcs/rcs/rcs.1 +++ /dev/null @@ -1,454 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcs/rcs.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \&\s-1RCS\s0 -.if n .ds - \%-- -.if t .ds - \(em -.if !\n(.g \{\ -. if !\w|\*(lq| \{\ -. ds lq `` -. if \w'\(lq' .ds lq "\(lq -. \} -. if !\w|\*(rq| \{\ -. ds rq '' -. if \w'\(rq' .ds rq "\(rq -. \} -.\} -.TH RCS 1 \*(Dt GNU -.SH NAME -rcs \- change RCS file attributes -.SH SYNOPSIS -.B rcs -.IR "options file " .\|.\|. -.SH DESCRIPTION -.B rcs -creates new \*r files or changes attributes of existing ones. -An \*r file contains multiple revisions of text, -an access list, a change log, -descriptive text, -and some control attributes. -For -.B rcs -to work, the caller's login name must be on the access list, -except if the access list is empty, the caller is the owner of the file -or the superuser, or -the -.B \-i -option is present. -.PP -Pathnames matching an \*r suffix denote \*r files; -all others denote working files. -Names are paired as explained in -.BR ci (1). -Revision numbers use the syntax described in -.BR ci (1). -.SH OPTIONS -.TP -.B \-i -Create and initialize a new \*r file, but do not deposit any revision. -If the \*r file has no path prefix, try to place it -first into the subdirectory -.BR ./RCS , -and then into the current directory. -If the \*r file -already exists, print an error message. -.TP -.BI \-a "logins" -Append the login names appearing in the comma-separated list -.I logins -to the access list of the \*r file. -.TP -.BI \-A "oldfile" -Append the access list of -.I oldfile -to the access list of the \*r file. -.TP -.BR \-e [\f2logins\fP] -Erase the login names appearing in the comma-separated list -.I logins -from the access list of the \*r file. -If -.I logins -is omitted, erase the entire access list. -.TP -.BR \-b [\f2rev\fP] -Set the default branch to -.IR rev . -If -.I rev -is omitted, the default -branch is reset to the (dynamically) highest branch on the trunk. -.TP -.BI \-c string -Set the comment leader to -.IR string . -An initial -.BR ci , -or an -.B "rcs\ \-i" -without -.BR \-c , -guesses the comment leader from the suffix of the working filename. -.RS -.PP -This option is obsolescent, since \*r normally uses the preceding -.B $\&Log$ -line's prefix when inserting log lines during checkout (see -.BR co (1)). -However, older versions of \*r use the comment leader instead of the -.B $\&Log$ -line's prefix, so -if you plan to access a file with both old and new versions of \*r, -make sure its comment leader matches its -.B $\&Log$ -line prefix. -.RE -.TP -.BI \-k subst -Set the default keyword substitution to -.IR subst . -The effect of keyword substitution is described in -.BR co (1). -Giving an explicit -.B \-k -option to -.BR co , -.BR rcsdiff , -and -.B rcsmerge -overrides this default. -Beware -.BR "rcs\ \-kv", -because -.B \-kv -is incompatible with -.BR "co\ \-l". -Use -.B "rcs\ \-kkv" -to restore the normal default keyword substitution. -.TP -.BR \-l [\f2rev\fP] -Lock the revision with number -.IR rev . -If a branch is given, lock the latest revision on that branch. -If -.I rev -is omitted, lock the latest revision on the default branch. -Locking prevents overlapping changes. -If someone else already holds the lock, the lock is broken as with -.B "rcs\ \-u" -(see below). -.TP -.BR \-u [\f2rev\fP] -Unlock the revision with number -.IR rev . -If a branch is given, unlock the latest revision on that branch. -If -.I rev -is omitted, remove the latest lock held by the caller. -Normally, only the locker of a revision can unlock it. -Somebody else unlocking a revision breaks the lock. -This causes a mail message to be sent to the original locker. -The message contains a commentary solicited from the breaker. -The commentary is terminated by end-of-file or by a line containing -.BR \&. "\ by" -itself. -.TP -.B \-L -Set locking to -.IR strict . -Strict locking means that the owner -of an \*r file is not exempt from locking for checkin. -This option should be used for files that are shared. -.TP -.B \-U -Set locking to non-strict. Non-strict locking means that the owner of -a file need not lock a revision for checkin. -This option should -.I not -be used for files that are shared. -Whether default locking is strict is determined by your system administrator, -but it is normally strict. -.TP -\f3\-m\fP\f2rev\fP\f3:\fP\f2msg\fP -Replace revision -.IR rev 's -log message with -.IR msg . -.TP -.B \-M -Do not send mail when breaking somebody else's lock. -This option is not meant for casual use; -it is meant for programs that warn users by other means, and invoke -.B "rcs\ \-u" -only as a low-level lock-breaking operation. -.TP -\f3\-n\fP\f2name\fP[\f3:\fP[\f2rev\fP]] -Associate the symbolic name -.I name -with the branch or -revision -.IR rev . -Delete the symbolic name if both -.B : -and -.I rev -are omitted; otherwise, print an error message if -.I name -is already associated with -another number. -If -.I rev -is symbolic, it is expanded before association. -A -.I rev -consisting of a branch number followed by a -.B .\& -stands for the current latest revision in the branch. -A -.B : -with an empty -.I rev -stands for the current latest revision on the default branch, -normally the trunk. -For example, -.BI "rcs\ \-n" name ":\ RCS/*" -associates -.I name -with the current latest revision of all the named \*r files; -this contrasts with -.BI "rcs\ \-n" name ":$\ RCS/*" -which associates -.I name -with the revision numbers extracted from keyword strings -in the corresponding working files. -.TP -\f3\-N\fP\f2name\fP[\f3:\fP[\f2rev\fP]] -Act like -.BR \-n , -except override any previous assignment of -.IR name . -.TP -.BI \-o range -deletes (\*(lqoutdates\*(rq) the revisions given by -.IR range . -A range consisting of a single revision number means that revision. -A range consisting of a branch number means the latest revision on that -branch. -A range of the form -.IB rev1 : rev2 -means -revisions -.I rev1 -to -.I rev2 -on the same branch, -.BI : rev -means from the beginning of the branch containing -.I rev -up to and including -.IR rev , -and -.IB rev : -means -from revision -.I rev -to the end of the branch containing -.IR rev . -None of the outdated revisions can have branches or locks. -.TP -.B \-q -Run quietly; do not print diagnostics. -.TP -.B \-I -Run interactively, even if the standard input is not a terminal. -.TP -.B \-s\f2state\fP\f1[\fP:\f2rev\fP\f1]\fP -Set the state attribute of the revision -.I rev -to -.IR state . -If -.I rev -is a branch number, assume the latest revision on that branch. -If -.I rev -is omitted, assume the latest revision on the default branch. -Any identifier is acceptable for -.IR state . -A useful set of states -is -.B Exp -(for experimental), -.B Stab -(for stable), and -.B Rel -(for -released). -By default, -.BR ci (1) -sets the state of a revision to -.BR Exp . -.TP -.BR \-t [\f2file\fP] -Write descriptive text from the contents of the named -.I file -into the \*r file, deleting the existing text. -The -.IR file -pathname cannot begin with -.BR \- . -If -.I file -is omitted, obtain the text from standard input, -terminated by end-of-file or by a line containing -.BR \&. "\ by" -itself. -Prompt for the text if interaction is possible; see -.BR \-I . -With -.BR \-i , -descriptive text is obtained -even if -.B \-t -is not given. -.TP -.BI \-t\- string -Write descriptive text from the -.I string -into the \*r file, deleting the existing text. -.TP -.B \-T -Preserve the modification time on the \*r file -unless a revision is removed. -This option can suppress extensive recompilation caused by a -.BR make (1) -dependency of some copy of the working file on the \*r file. -Use this option with care; it can suppress recompilation even when it is needed, -i.e. when a change to the \*r file -would mean a change to keyword strings in the working file. -.TP -.BI \-V -Print \*r's version number. -.TP -.BI \-V n -Emulate \*r version -.IR n . -See -.BR co (1) -for details. -.TP -.BI \-x "suffixes" -Use -.I suffixes -to characterize \*r files. -See -.BR ci (1) -for details. -.TP -.BI \-z zone -Use -.I zone -as the default time zone. -This option has no effect; -it is present for compatibility with other \*r commands. -.PP -At least one explicit option must be given, -to ensure compatibility with future planned extensions -to the -.B rcs -command. -.SH COMPATIBILITY -The -.BI \-b rev -option generates an \*r file that cannot be parsed by \*r version 3 or earlier. -.PP -The -.BI \-k subst -options (except -.BR \-kkv ) -generate an \*r file that cannot be parsed by \*r version 4 or earlier. -.PP -Use -.BI "rcs \-V" n -to make an \*r file acceptable to \*r version -.I n -by discarding information that would confuse version -.IR n . -.PP -\*r version 5.5 and earlier does not support the -.B \-x -option, and requires a -.B ,v -suffix on an \*r pathname. -.SH FILES -.B rcs -accesses files much as -.BR ci (1) -does, -except that it uses the effective user for all accesses, -it does not write the working file or its directory, -and it does not even read the working file unless a revision number of -.B $ -is specified. -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -See -.BR ci (1) -for details. -.SH DIAGNOSTICS -The \*r pathname and the revisions outdated are written to -the diagnostic output. -The exit status is zero if and only if all operations were successful. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH "SEE ALSO" -rcsintro(1), co(1), ci(1), ident(1), rcsclean(1), rcsdiff(1), -rcsmerge(1), rlog(1), rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.SH BUGS -A catastrophe (e.g. a system crash) can cause \*r to leave behind -a semaphore file that causes later invocations of \*r to claim -that the \*r file is in use. -To fix this, remove the semaphore file. -A semaphore file's name typically begins with -.B , -or ends with -.BR _ . -.PP -The separator for revision ranges in the -.B \-o -option used to be -.B \- -instead of -.BR : , -but this leads to confusion when symbolic names contain -.BR \- . -For backwards compatibility -.B "rcs \-o" -still supports the old -.B \- -separator, but it warns about this obsolete use. -.PP -Symbolic names need not refer to existing revisions or branches. -For example, the -.B \-o -option does not remove symbolic names for the outdated revisions; you must use -.B \-n -to remove the names. -.br diff --git a/gnu/usr.bin/rcs/rcs/rcs.c b/gnu/usr.bin/rcs/rcs/rcs.c deleted file mode 100644 index af86108e7ba..00000000000 --- a/gnu/usr.bin/rcs/rcs/rcs.c +++ /dev/null @@ -1,1629 +0,0 @@ -/* Change RCS file attributes. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.21 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.20 1995/06/01 16:23:43 eggert - * (main): Warn if no options were given. Punctuate messages properly. - * - * (sendmail): Rewind mailmess before flushing it. - * Output another warning if mail should work but fails. - * - * (buildeltatext): Pass "--binary" if -kb and if --binary makes a difference. - * - * Revision 5.19 1994/03/17 14:05:48 eggert - * Use ORCSerror to clean up after a fatal error. Remove lint. - * Specify subprocess input via file descriptor, not file name. Remove lint. - * Flush stderr after prompt. - * - * Revision 5.18 1993/11/09 17:40:15 eggert - * -V now prints version on stdout and exits. Don't print usage twice. - * - * Revision 5.17 1993/11/03 17:42:27 eggert - * Add -z. Don't lose track of -m or -t when there are no other changes. - * Don't discard ignored phrases. Improve quality of diagnostics. - * - * Revision 5.16 1992/07/28 16:12:44 eggert - * rcs -l now asks whether you want to break the lock. - * Add -V. Set RCS file's mode and time at right moment. - * - * Revision 5.15 1992/02/17 23:02:20 eggert - * Add -T. - * - * Revision 5.14 1992/01/27 16:42:53 eggert - * Add -M. Avoid invoking umask(); it's one less thing to configure. - * Add support for bad_creat0. lint -> RCS_lint - * - * Revision 5.13 1992/01/06 02:42:34 eggert - * Avoid changing RCS file in common cases where no change can occur. - * - * Revision 5.12 1991/11/20 17:58:08 eggert - * Don't read the delta tree from a nonexistent RCS file. - * - * Revision 5.11 1991/10/07 17:32:46 eggert - * Remove lint. - * - * Revision 5.10 1991/08/19 23:17:54 eggert - * Add -m, -r$, piece tables. Revision separator is `:', not `-'. Tune. - * - * Revision 5.9 1991/04/21 11:58:18 eggert - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.8 1991/02/25 07:12:38 eggert - * strsave -> str_save (DG/UX name clash) - * 0444 -> S_IRUSR|S_IRGRP|S_IROTH for portability - * - * Revision 5.7 1990/12/18 17:19:21 eggert - * Fix bug with multiple -n and -N options. - * - * Revision 5.6 1990/12/04 05:18:40 eggert - * Use -I for prompts and -q for diagnostics. - * - * Revision 5.5 1990/11/11 00:06:35 eggert - * Fix `rcs -e' core dump. - * - * Revision 5.4 1990/11/01 05:03:33 eggert - * Add -I and new -t behavior. Permit arbitrary data in logs. - * - * Revision 5.3 1990/10/04 06:30:16 eggert - * Accumulate exit status across files. - * - * Revision 5.2 1990/09/04 08:02:17 eggert - * Standardize yes-or-no procedure. - * - * Revision 5.1 1990/08/29 07:13:51 eggert - * Remove unused setuid support. Clean old log messages too. - * - * Revision 5.0 1990/08/22 08:12:42 eggert - * Don't lose names when applying -a option to multiple files. - * Remove compile-time limits; use malloc instead. Add setuid support. - * Permit dates past 1999/12/31. Make lock and temp files faster and safer. - * Ansify and Posixate. Add -V. Fix umask bug. Make linting easier. Tune. - * Yield proper exit status. Check diff's output. - * - * Revision 4.11 89/05/01 15:12:06 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.10 88/11/08 16:01:54 narten - * didn't install previous patch correctly - * - * Revision 4.9 88/11/08 13:56:01 narten - * removed include (not needed) - * minor fix for -A option - * - * Revision 4.8 88/08/09 19:12:27 eggert - * Don't access freed storage. - * Use execv(), not system(); yield proper exit status; remove lint. - * - * Revision 4.7 87/12/18 11:37:17 narten - * lint cleanups (Guy Harris) - * - * Revision 4.6 87/10/18 10:28:48 narten - * Updating verison numbers. Changes relative to 1.1 are actually - * relative to 4.3 - * - * Revision 1.4 87/09/24 13:58:52 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.3 87/03/27 14:21:55 jenkins - * Port to suns - * - * Revision 1.2 85/12/17 13:59:09 albitz - * Changed setstate to rcs_setstate because of conflict with random.o. - * - * Revision 4.3 83/12/15 12:27:33 wft - * rcs -u now breaks most recent lock if it can't find a lock by the caller. - * - * Revision 4.2 83/12/05 10:18:20 wft - * Added conditional compilation for sending mail. - * Alternatives: V4_2BSD, V6, USG, and other. - * - * Revision 4.1 83/05/10 16:43:02 wft - * Simplified breaklock(); added calls to findlock() and getcaller(). - * Added option -b (default branch). Updated -s and -w for -b. - * Removed calls to stat(); now done by pairfilenames(). - * Replaced most catchints() calls with restoreints(). - * Removed check for exit status of delivermail(). - * Directed all interactive output to stderr. - * - * Revision 3.9.1.1 83/12/02 22:08:51 wft - * Added conditional compilation for 4.2 sendmail and 4.1 delivermail. - * - * Revision 3.9 83/02/15 15:38:39 wft - * Added call to fastcopy() to copy remainder of RCS file. - * - * Revision 3.8 83/01/18 17:37:51 wft - * Changed sendmail(): now uses delivermail, and asks whether to break the lock. - * - * Revision 3.7 83/01/15 18:04:25 wft - * Removed putree(); replaced with puttree() in rcssyn.c. - * Combined putdellog() and scanlogtext(); deleted putdellog(). - * Cleaned up diagnostics and error messages. Fixed problem with - * mutilated files in case of deletions in 2 files in a single command. - * Changed marking of selector from 'D' to DELETE. - * - * Revision 3.6 83/01/14 15:37:31 wft - * Added ignoring of interrupts while new RCS file is renamed; - * Avoids deletion of RCS files by interrupts. - * - * Revision 3.5 82/12/10 21:11:39 wft - * Removed unused variables, fixed checking of return code from diff, - * introduced variant COMPAT2 for skipping Suffix on -A files. - * - * Revision 3.4 82/12/04 13:18:20 wft - * Replaced getdelta() with gettree(), changed breaklock to update - * field lockedby, added some diagnostics. - * - * Revision 3.3 82/12/03 17:08:04 wft - * Replaced getlogin() with getpwuid(), flcose() with ffclose(), - * /usr/ucb/Mail with macro MAIL. Removed handling of Suffix (-x). - * fixed -u for missing revno. Disambiguated structure members. - * - * Revision 3.2 82/10/18 21:05:07 wft - * rcs -i now generates a file mode given by the umask minus write permission; - * otherwise, rcs keeps the mode, but removes write permission. - * I added a check for write error, fixed call to getlogin(), replaced - * curdir() with getfullRCSname(), cleaned up handling -U/L, and changed - * conflicting, long identifiers. - * - * Revision 3.1 82/10/13 16:11:07 wft - * fixed type of variables receiving from getc() (char -> int). - */ - - -#include "rcsbase.h" - -struct Lockrev { - char const *revno; - struct Lockrev * nextrev; -}; - -struct Symrev { - char const *revno; - char const *ssymbol; - int override; - struct Symrev * nextsym; -}; - -struct Message { - char const *revno; - struct cbuf message; - struct Message *nextmessage; -}; - -struct Status { - char const *revno; - char const *status; - struct Status * nextstatus; -}; - -enum changeaccess {append, erase}; -struct chaccess { - char const *login; - enum changeaccess command; - struct chaccess *nextchaccess; -}; - -struct delrevpair { - char const *strt; - char const *end; - int code; -}; - -static int branchpoint P((struct hshentry*,struct hshentry*)); -static int breaklock P((struct hshentry const*)); -static int buildeltatext P((struct hshentries const*)); -static int doaccess P((void)); -static int doassoc P((void)); -static int dolocks P((void)); -static int domessages P((void)); -static int rcs_setstate P((char const*,char const*)); -static int removerevs P((void)); -static int sendmail P((char const*,char const*)); -static int setlock P((char const*)); -static struct Lockrev **rmnewlocklst P((char const*)); -static struct hshentry *searchcutpt P((char const*,int,struct hshentries*)); -static void buildtree P((void)); -static void cleanup P((void)); -static void getaccessor P((char*,enum changeaccess)); -static void getassoclst P((int,char*)); -static void getchaccess P((char const*,enum changeaccess)); -static void getdelrev P((char*)); -static void getmessage P((char*)); -static void getstates P((char*)); -static void scanlogtext P((struct hshentry*,int)); - -static struct buf numrev; -static char const *headstate; -static int chgheadstate, exitstatus, lockhead, unlockcaller; -static int suppress_mail; -static struct Lockrev *newlocklst, *rmvlocklst; -static struct Message *messagelst, **nextmessage; -static struct Status *statelst, **nextstate; -static struct Symrev *assoclst, **nextassoc; -static struct chaccess *chaccess, **nextchaccess; -static struct delrevpair delrev; -static struct hshentry *cuthead, *cuttail, *delstrt; -static struct hshentries *gendeltas; - -mainProg(rcsId, "rcs", "$FreeBSD: stable/11/gnu/usr.bin/rcs/rcs/rcs.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const cmdusage[] = - "\nrcs usage: rcs -{ae}logins -Afile -{blu}[rev] -cstring -{iILqTU} -ksubst -mrev:msg -{nN}name[:[rev]] -orange -sstate[:rev] -t[text] -Vn -xsuff -zzone file ..."; - - char *a, **newargv, *textfile; - char const *branchsym, *commsyml; - int branchflag, changed, expmode, initflag; - int strictlock, strict_selected, textflag; - int keepRCStime, Ttimeflag; - size_t commsymlen; - struct buf branchnum; - struct Lockrev *lockpt; - struct Lockrev **curlock, **rmvlock; - struct Status * curstate; - - nosetid(); - - nextassoc = &assoclst; - nextchaccess = &chaccess; - nextmessage = &messagelst; - nextstate = &statelst; - branchsym = commsyml = textfile = 0; - branchflag = strictlock = false; - bufautobegin(&branchnum); - commsymlen = 0; - curlock = &newlocklst; - rmvlock = &rmvlocklst; - expmode = -1; - suffixes = X_DEFAULT; - initflag= textflag = false; - strict_selected = 0; - Ttimeflag = false; - - /* preprocessing command options */ - if (1 < argc && argv[1][0] != '-') - warn("No options were given; this usage is obsolescent."); - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - while (a = *++argv, 0<--argc && *a++=='-') { - switch (*a++) { - - case 'i': /* initial version */ - initflag = true; - break; - - case 'b': /* change default branch */ - if (branchflag) redefined('b'); - branchflag= true; - branchsym = a; - break; - - case 'c': /* change comment symbol */ - if (commsyml) redefined('c'); - commsyml = a; - commsymlen = strlen(a); - break; - - case 'a': /* add new accessor */ - getaccessor(*argv+1, append); - break; - - case 'A': /* append access list according to accessfile */ - if (!*a) { - error("missing pathname after -A"); - break; - } - *argv = a; - if (0 < pairnames(1,argv,rcsreadopen,true,false)) { - while (AccessList) { - getchaccess(str_save(AccessList->login),append); - AccessList = AccessList->nextaccess; - } - Izclose(&finptr); - } - break; - - case 'e': /* remove accessors */ - getaccessor(*argv+1, erase); - break; - - case 'l': /* lock a revision if it is unlocked */ - if (!*a) { - /* Lock head or default branch. */ - lockhead = true; - break; - } - *curlock = lockpt = talloc(struct Lockrev); - lockpt->revno = a; - lockpt->nextrev = 0; - curlock = &lockpt->nextrev; - break; - - case 'u': /* release lock of a locked revision */ - if (!*a) { - unlockcaller=true; - break; - } - *rmvlock = lockpt = talloc(struct Lockrev); - lockpt->revno = a; - lockpt->nextrev = 0; - rmvlock = &lockpt->nextrev; - curlock = rmnewlocklst(lockpt->revno); - break; - - case 'L': /* set strict locking */ - if (strict_selected) { - if (!strictlock) /* Already selected -U? */ - warn("-U overridden by -L"); - } - strictlock = true; - strict_selected = true; - break; - - case 'U': /* release strict locking */ - if (strict_selected) { - if (strictlock) /* Already selected -L? */ - warn("-L overridden by -U"); - } - strict_selected = true; - break; - - case 'n': /* add new association: error, if name exists */ - if (!*a) { - error("missing symbolic name after -n"); - break; - } - getassoclst(false, (*argv)+1); - break; - - case 'N': /* add or change association */ - if (!*a) { - error("missing symbolic name after -N"); - break; - } - getassoclst(true, (*argv)+1); - break; - - case 'm': /* change log message */ - getmessage(a); - break; - - case 'M': /* do not send mail */ - suppress_mail = true; - break; - - case 'o': /* delete revisions */ - if (delrev.strt) redefined('o'); - if (!*a) { - error("missing revision range after -o"); - break; - } - getdelrev( (*argv)+1 ); - break; - - case 's': /* change state attribute of a revision */ - if (!*a) { - error("state missing after -s"); - break; - } - getstates( (*argv)+1); - break; - - case 't': /* change descriptive text */ - textflag=true; - if (*a) { - if (textfile) redefined('t'); - textfile = a; - } - break; - - case 'T': /* do not update last-mod time for minor changes */ - if (*a) - goto unknown; - Ttimeflag = true; - break; - - case 'I': - interactiveflag = true; - break; - - case 'q': - quietflag = true; - break; - - case 'x': - suffixes = a; - break; - - case 'V': - setRCSversion(*argv); - break; - - case 'z': - zone_set(a); - break; - - case 'k': /* set keyword expand mode */ - if (0 <= expmode) redefined('k'); - if (0 <= (expmode = str2expmode(a))) - break; - /* fall into */ - default: - unknown: - error("unknown option: %s%s", *argv, cmdusage); - }; - } /* end processing of options */ - - /* Now handle all pathnames. */ - if (nerror) cleanup(); - else if (argc < 1) faterror("no input file%s", cmdusage); - else for (; 0 < argc; cleanup(), ++argv, --argc) { - - ffree(); - - if ( initflag ) { - switch (pairnames(argc, argv, rcswriteopen, false, false)) { - case -1: break; /* not exist; ok */ - case 0: continue; /* error */ - case 1: rcserror("already exists"); - continue; - } - } - else { - switch (pairnames(argc, argv, rcswriteopen, true, false)) { - case -1: continue; /* not exist */ - case 0: continue; /* errors */ - case 1: break; /* file exists; ok*/ - } - } - - - /* - * RCSname contains the name of the RCS file, and - * workname contains the name of the working file. - * if !initflag, finptr contains the file descriptor for the - * RCS file. The admin node is initialized. - */ - - diagnose("RCS file: %s\n", RCSname); - - changed = initflag | textflag; - keepRCStime = Ttimeflag; - if (!initflag) { - if (!checkaccesslist()) continue; - gettree(); /* Read the delta tree. */ - } - - /* update admin. node */ - if (strict_selected) { - changed |= StrictLocks ^ strictlock; - StrictLocks = strictlock; - } - if ( - commsyml && - ( - commsymlen != Comment.size || - memcmp(commsyml, Comment.string, commsymlen) != 0 - ) - ) { - Comment.string = commsyml; - Comment.size = strlen(commsyml); - changed = true; - } - if (0 <= expmode && Expand != expmode) { - Expand = expmode; - changed = true; - } - - /* update default branch */ - if (branchflag && expandsym(branchsym, &branchnum)) { - if (countnumflds(branchnum.string)) { - if (cmpnum(Dbranch, branchnum.string) != 0) { - Dbranch = branchnum.string; - changed = true; - } - } else - if (Dbranch) { - Dbranch = 0; - changed = true; - } - } - - changed |= doaccess(); /* Update access list. */ - - changed |= doassoc(); /* Update association list. */ - - changed |= dolocks(); /* Update locks. */ - - changed |= domessages(); /* Update log messages. */ - - /* update state attribution */ - if (chgheadstate) { - /* change state of default branch or head */ - if (!Dbranch) { - if (!Head) - rcswarn("can't change states in an empty tree"); - else if (strcmp(Head->state, headstate) != 0) { - Head->state = headstate; - changed = true; - } - } else - changed |= rcs_setstate(Dbranch,headstate); - } - for (curstate = statelst; curstate; curstate = curstate->nextstatus) - changed |= rcs_setstate(curstate->revno,curstate->status); - - cuthead = cuttail = 0; - if (delrev.strt && removerevs()) { - /* rebuild delta tree if some deltas are deleted */ - if ( cuttail ) - VOID genrevs( - cuttail->num, (char *)0, (char *)0, (char *)0, - &gendeltas - ); - buildtree(); - changed = true; - keepRCStime = false; - } - - if (nerror) - continue; - - putadmin(); - if ( Head ) - puttree(Head, frewrite); - putdesc(textflag,textfile); - - if ( Head) { - if (delrev.strt || messagelst) { - if (!cuttail || buildeltatext(gendeltas)) { - advise_access(finptr, MADV_SEQUENTIAL); - scanlogtext((struct hshentry *)0, false); - /* copy rest of delta text nodes that are not deleted */ - changed = true; - } - } - } - - if (initflag) { - /* Adjust things for donerewrite's sake. */ - if (stat(workname, &RCSstat) != 0) { -# if bad_creat0 - mode_t m = umask(0); - (void) umask(m); - RCSstat.st_mode = (S_IRUSR|S_IRGRP|S_IROTH) & ~m; -# else - changed = -1; -# endif - } - RCSstat.st_nlink = 0; - keepRCStime = false; - } - if (donerewrite(changed, - keepRCStime ? RCSstat.st_mtime : (time_t)-1 - ) != 0) - break; - - diagnose("done\n"); - } - - tempunlink(); - exitmain(exitstatus); -} /* end of main (rcs) */ - - static void -cleanup() -{ - if (nerror) exitstatus = EXIT_FAILURE; - Izclose(&finptr); - Ozclose(&fcopy); - ORCSclose(); - dirtempunlink(); -} - - void -exiterr() -{ - ORCSerror(); - dirtempunlink(); - tempunlink(); - _exit(EXIT_FAILURE); -} - - - static void -getassoclst(flag, sp) -int flag; -char * sp; -/* Function: associate a symbolic name to a revision or branch, */ -/* and store in assoclst */ - -{ - struct Symrev * pt; - char const *temp; - int c; - - while ((c = *++sp) == ' ' || c == '\t' || c =='\n') - continue; - temp = sp; - sp = checksym(sp, ':'); /* check for invalid symbolic name */ - c = *sp; *sp = '\0'; - while( c == ' ' || c == '\t' || c == '\n') c = *++sp; - - if ( c != ':' && c != '\0') { - error("invalid string %s after option -n or -N",sp); - return; - } - - pt = talloc(struct Symrev); - pt->ssymbol = temp; - pt->override = flag; - if (c == '\0') /* delete symbol */ - pt->revno = 0; - else { - while ((c = *++sp) == ' ' || c == '\n' || c == '\t') - continue; - pt->revno = sp; - } - pt->nextsym = 0; - *nextassoc = pt; - nextassoc = &pt->nextsym; -} - - - static void -getchaccess(login, command) - char const *login; - enum changeaccess command; -{ - register struct chaccess *pt; - - pt = talloc(struct chaccess); - pt->login = login; - pt->command = command; - pt->nextchaccess = 0; - *nextchaccess = pt; - nextchaccess = &pt->nextchaccess; -} - - - - static void -getaccessor(opt, command) - char *opt; - enum changeaccess command; -/* Function: get the accessor list of options -e and -a, */ -/* and store in chaccess */ - - -{ - register c; - register char *sp; - - sp = opt; - while ((c = *++sp) == ' ' || c == '\n' || c == '\t' || c == ',') - continue; - if ( c == '\0') { - if (command == erase && sp-opt == 1) { - getchaccess((char*)0, command); - return; - } - error("missing login name after option -a or -e"); - return; - } - - while( c != '\0') { - getchaccess(sp, command); - sp = checkid(sp,','); - c = *sp; *sp = '\0'; - while( c == ' ' || c == '\n' || c == '\t'|| c == ',')c =(*++sp); - } -} - - - static void -getmessage(option) - char *option; -{ - struct Message *pt; - struct cbuf cb; - char *m; - - if (!(m = strchr(option, ':'))) { - error("-m option lacks revision number"); - return; - } - *m++ = 0; - cb = cleanlogmsg(m, strlen(m)); - if (!cb.size) { - error("-m option lacks log message"); - return; - } - pt = talloc(struct Message); - pt->revno = option; - pt->message = cb; - pt->nextmessage = 0; - *nextmessage = pt; - nextmessage = &pt->nextmessage; -} - - - static void -getstates(sp) -char *sp; -/* Function: get one state attribute and the corresponding */ -/* revision and store in statelst */ - -{ - char const *temp; - struct Status *pt; - register c; - - while ((c = *++sp) ==' ' || c == '\t' || c == '\n') - continue; - temp = sp; - sp = checkid(sp,':'); /* check for invalid state attribute */ - c = *sp; *sp = '\0'; - while( c == ' ' || c == '\t' || c == '\n' ) c = *++sp; - - if ( c == '\0' ) { /* change state of def. branch or Head */ - chgheadstate = true; - headstate = temp; - return; - } - else if ( c != ':' ) { - error("missing ':' after state in option -s"); - return; - } - - while ((c = *++sp) == ' ' || c == '\t' || c == '\n') - continue; - pt = talloc(struct Status); - pt->status = temp; - pt->revno = sp; - pt->nextstatus = 0; - *nextstate = pt; - nextstate = &pt->nextstatus; -} - - - - static void -getdelrev(sp) -char *sp; -/* Function: get revision range or branch to be deleted, */ -/* and place in delrev */ -{ - int c; - struct delrevpair *pt; - int separator; - - pt = &delrev; - while ((c = (*++sp)) == ' ' || c == '\n' || c == '\t') - continue; - - /* Support old ambiguous '-' syntax; this will go away. */ - if (strchr(sp,':')) - separator = ':'; - else { - if (strchr(sp,'-') && VERSION(5) <= RCSversion) - warn("`-' is obsolete in `-o%s'; use `:' instead", sp); - separator = '-'; - } - - if (c == separator) { /* -o:rev */ - while ((c = (*++sp)) == ' ' || c == '\n' || c == '\t') - continue; - pt->strt = sp; pt->code = 1; - while( c != ' ' && c != '\n' && c != '\t' && c != '\0') c =(*++sp); - *sp = '\0'; - pt->end = 0; - return; - } - else { - pt->strt = sp; - while( c != ' ' && c != '\n' && c != '\t' && c != '\0' - && c != separator ) c = *++sp; - *sp = '\0'; - while( c == ' ' || c == '\n' || c == '\t' ) c = *++sp; - if ( c == '\0' ) { /* -o rev or branch */ - pt->code = 0; - pt->end = 0; - return; - } - if (c != separator) { - error("invalid range %s %s after -o", pt->strt, sp); - } - while ((c = *++sp) == ' ' || c == '\n' || c == '\t') - continue; - if (!c) { /* -orev: */ - pt->code = 2; - pt->end = 0; - return; - } - } - /* -orev1:rev2 */ - pt->end = sp; pt->code = 3; - while( c!= ' ' && c != '\n' && c != '\t' && c != '\0') c = *++sp; - *sp = '\0'; -} - - - - - static void -scanlogtext(delta,edit) - struct hshentry *delta; - int edit; -/* Function: Scans delta text nodes up to and including the one given - * by delta, or up to last one present, if !delta. - * For the one given by delta (if delta), the log message is saved into - * delta->log if delta==cuttail; the text is edited if EDIT is set, else copied. - * Assumes the initial lexeme must be read in first. - * Does not advance nexttok after it is finished, except if !delta. - */ -{ - struct hshentry const *nextdelta; - struct cbuf cb; - - for (;;) { - foutptr = 0; - if (eoflex()) { - if(delta) - rcsfaterror("can't find delta for revision %s", - delta->num - ); - return; /* no more delta text nodes */ - } - nextlex(); - if (!(nextdelta=getnum())) - fatserror("delta number corrupted"); - if (nextdelta->selector) { - foutptr = frewrite; - aprintf(frewrite,DELNUMFORM,nextdelta->num,Klog); - } - getkeystring(Klog); - if (nextdelta == cuttail) { - cb = savestring(&curlogbuf); - if (!delta->log.string) - delta->log = cleanlogmsg(curlogbuf.string, cb.size); - nextlex(); - delta->igtext = getphrases(Ktext); - } else { - if (nextdelta->log.string && nextdelta->selector) { - foutptr = 0; - readstring(); - foutptr = frewrite; - putstring(foutptr, false, nextdelta->log, true); - afputc(nextc, foutptr); - } else - readstring(); - ignorephrases(Ktext); - } - getkeystring(Ktext); - - if (delta==nextdelta) - break; - readstring(); /* skip over it */ - - } - /* got the one we're looking for */ - if (edit) - editstring((struct hshentry*)0); - else - enterstring(); -} - - - - static struct Lockrev ** -rmnewlocklst(which) - char const *which; -/* Remove lock to revision WHICH from newlocklst. */ -{ - struct Lockrev *pt, **pre; - - pre = &newlocklst; - while ((pt = *pre)) - if (strcmp(pt->revno, which) != 0) - pre = &pt->nextrev; - else { - *pre = pt->nextrev; - tfree(pt); - } - return pre; -} - - - - static int -doaccess() -{ - register struct chaccess *ch; - register struct access **p, *t; - register int changed = false; - - for (ch = chaccess; ch; ch = ch->nextchaccess) { - switch (ch->command) { - case erase: - if (!ch->login) { - if (AccessList) { - AccessList = 0; - changed = true; - } - } else - for (p = &AccessList; (t = *p); p = &t->nextaccess) - if (strcmp(ch->login, t->login) == 0) { - *p = t->nextaccess; - changed = true; - break; - } - break; - case append: - for (p = &AccessList; ; p = &t->nextaccess) - if (!(t = *p)) { - *p = t = ftalloc(struct access); - t->login = ch->login; - t->nextaccess = 0; - changed = true; - break; - } else if (strcmp(ch->login, t->login) == 0) - break; - break; - } - } - return changed; -} - - - static int -sendmail(Delta, who) - char const *Delta, *who; -/* Function: mail to who, informing him that his lock on delta was - * broken by caller. Ask first whether to go ahead. Return false on - * error or if user decides not to break the lock. - */ -{ -#ifdef SENDMAIL - char const *messagefile; - int old1, old2, c, status; - FILE * mailmess; -#endif - - - aprintf(stderr, "Revision %s is already locked by %s.\n", Delta, who); - if (suppress_mail) - return true; - if (!yesorno(false, "Do you want to break the lock? [ny](n): ")) - return false; - - /* go ahead with breaking */ -#ifdef SENDMAIL - messagefile = maketemp(0); - if (!(mailmess = fopenSafer(messagefile, "w+"))) { - efaterror(messagefile); - } - - aprintf(mailmess, "Subject: Broken lock on %s\n\nYour lock on revision %s of file %s\nhas been broken by %s for the following reason:\n", - basefilename(RCSname), Delta, getfullRCSname(), getcaller() - ); - aputs("State the reason for breaking the lock:\n(terminate with single '.' or end of file)\n>> ", stderr); - eflush(); - - old1 = '\n'; old2 = ' '; - for (; ;) { - c = getcstdin(); - if (feof(stdin)) { - aprintf(mailmess, "%c\n", old1); - break; - } - else if ( c == '\n' && old1 == '.' && old2 == '\n') - break; - else { - afputc(old1, mailmess); - old2 = old1; old1 = c; - if (c == '\n') { - aputs(">> ", stderr); - eflush(); - } - } - } - Orewind(mailmess); - aflush(mailmess); - status = run(fileno(mailmess), (char*)0, SENDMAIL, who, (char*)0); - Ozclose(&mailmess); - if (status == 0) - return true; - warn("Mail failed."); -#endif - warn("Mail notification of broken locks is not available."); - warn("Please tell `%s' why you broke the lock.", who); - return(true); -} - - - - static int -breaklock(delta) - struct hshentry const *delta; -/* function: Finds the lock held by caller on delta, - * and removes it. - * Sends mail if a lock different from the caller's is broken. - * Prints an error message if there is no such lock or error. - */ -{ - register struct rcslock *next, **trail; - char const *num; - - num=delta->num; - for (trail = &Locks; (next = *trail); trail = &next->nextlock) - if (strcmp(num, next->delta->num) == 0) { - if ( - strcmp(getcaller(),next->login) != 0 - && !sendmail(num, next->login) - ) { - rcserror("revision %s still locked by %s", - num, next->login - ); - return false; - } - diagnose("%s unlocked\n", next->delta->num); - *trail = next->nextlock; - next->delta->lockedby = 0; - return true; - } - rcserror("no lock set on revision %s", num); - return false; -} - - - - static struct hshentry * -searchcutpt(object, length, store) - char const *object; - int length; - struct hshentries *store; -/* Function: Search store and return entry with number being object. */ -/* cuttail = 0, if the entry is Head; otherwise, cuttail */ -/* is the entry point to the one with number being object */ - -{ - cuthead = 0; - while (compartial(store->first->num, object, length)) { - cuthead = store->first; - store = store->rest; - } - return store->first; -} - - - - static int -branchpoint(strt, tail) -struct hshentry *strt, *tail; -/* Function: check whether the deltas between strt and tail */ -/* are locked or branch point, return 1 if any is */ -/* locked or branch point; otherwise, return 0 and */ -/* mark deleted */ - -{ - struct hshentry *pt; - struct rcslock const *lockpt; - - for (pt = strt; pt != tail; pt = pt->next) { - if ( pt->branches ){ /* a branch point */ - rcserror("can't remove branch point %s", pt->num); - return true; - } - for (lockpt = Locks; lockpt; lockpt = lockpt->nextlock) - if (lockpt->delta == pt) { - rcserror("can't remove locked revision %s", pt->num); - return true; - } - pt->selector = false; - diagnose("deleting revision %s\n",pt->num); - } - return false; -} - - - - static int -removerevs() -/* Function: get the revision range to be removed, and place the */ -/* first revision removed in delstrt, the revision before */ -/* delstrt in cuthead (0, if delstrt is head), and the */ -/* revision after the last removed revision in cuttail (0 */ -/* if the last is a leaf */ - -{ - struct hshentry *target, *target2, *temp; - int length; - int cmp; - - if (!expandsym(delrev.strt, &numrev)) return 0; - target = genrevs(numrev.string,(char*)0,(char*)0,(char*)0,&gendeltas); - if ( ! target ) return 0; - cmp = cmpnum(target->num, numrev.string); - length = countnumflds(numrev.string); - - if (delrev.code == 0) { /* -o rev or -o branch */ - if (length & 1) - temp=searchcutpt(target->num,length+1,gendeltas); - else if (cmp) { - rcserror("Revision %s doesn't exist.", numrev.string); - return 0; - } - else - temp = searchcutpt(numrev.string, length, gendeltas); - cuttail = target->next; - if ( branchpoint(temp, cuttail) ) { - cuttail = 0; - return 0; - } - delstrt = temp; /* first revision to be removed */ - return 1; - } - - if (length & 1) { /* invalid branch after -o */ - rcserror("invalid branch range %s after -o", numrev.string); - return 0; - } - - if (delrev.code == 1) { /* -o -rev */ - if ( length > 2 ) { - temp = searchcutpt( target->num, length-1, gendeltas); - cuttail = target->next; - } - else { - temp = searchcutpt(target->num, length, gendeltas); - cuttail = target; - while( cuttail && ! cmpnumfld(target->num,cuttail->num,1) ) - cuttail = cuttail->next; - } - if ( branchpoint(temp, cuttail) ){ - cuttail = 0; - return 0; - } - delstrt = temp; - return 1; - } - - if (delrev.code == 2) { /* -o rev- */ - if ( length == 2 ) { - temp = searchcutpt(target->num, 1,gendeltas); - if (cmp) - cuttail = target; - else - cuttail = target->next; - } - else { - if (cmp) { - cuthead = target; - if ( !(temp = target->next) ) return 0; - } - else - temp = searchcutpt(target->num, length, gendeltas); - getbranchno(temp->num, &numrev); /* get branch number */ - VOID genrevs(numrev.string, (char*)0, (char*)0, (char*)0, &gendeltas); - } - if ( branchpoint( temp, cuttail ) ) { - cuttail = 0; - return 0; - } - delstrt = temp; - return 1; - } - - /* -o rev1-rev2 */ - if (!expandsym(delrev.end, &numrev)) return 0; - if ( - length != countnumflds(numrev.string) - || (length>2 && compartial(numrev.string, target->num, length-1)) - ) { - rcserror("invalid revision range %s-%s", - target->num, numrev.string - ); - return 0; - } - - target2 = genrevs(numrev.string,(char*)0,(char*)0,(char*)0,&gendeltas); - if ( ! target2 ) return 0; - - if ( length > 2) { /* delete revisions on branches */ - if ( cmpnum(target->num, target2->num) > 0) { - cmp = cmpnum(target2->num, numrev.string); - temp = target; - target = target2; - target2 = temp; - } - if (cmp) { - if ( ! cmpnum(target->num, target2->num) ) { - rcserror("Revisions %s-%s don't exist.", - delrev.strt, delrev.end - ); - return 0; - } - cuthead = target; - temp = target->next; - } - else - temp = searchcutpt(target->num, length, gendeltas); - cuttail = target2->next; - } - else { /* delete revisions on trunk */ - if ( cmpnum( target->num, target2->num) < 0 ) { - temp = target; - target = target2; - target2 = temp; - } - else - cmp = cmpnum(target2->num, numrev.string); - if (cmp) { - if ( ! cmpnum(target->num, target2->num) ) { - rcserror("Revisions %s-%s don't exist.", - delrev.strt, delrev.end - ); - return 0; - } - cuttail = target2; - } - else - cuttail = target2->next; - temp = searchcutpt(target->num, length, gendeltas); - } - if ( branchpoint(temp, cuttail) ) { - cuttail = 0; - return 0; - } - delstrt = temp; - return 1; -} - - - - static int -doassoc() -/* Add or delete (if !revno) association that is stored in assoclst. */ -{ - char const *p; - int changed = false; - struct Symrev const *curassoc; - struct assoc **pre, *pt; - - /* add new associations */ - for (curassoc = assoclst; curassoc; curassoc = curassoc->nextsym) { - char const *ssymbol = curassoc->ssymbol; - - if (!curassoc->revno) { /* delete symbol */ - for (pre = &Symbols; ; pre = &pt->nextassoc) - if (!(pt = *pre)) { - rcswarn("can't delete nonexisting symbol %s", ssymbol); - break; - } else if (strcmp(pt->symbol, ssymbol) == 0) { - *pre = pt->nextassoc; - changed = true; - break; - } - } - else { - if (curassoc->revno[0]) { - p = 0; - if (expandsym(curassoc->revno, &numrev)) - p = fstr_save(numrev.string); - } else if (!(p = tiprev())) - rcserror("no latest revision to associate with symbol %s", - ssymbol - ); - if (p) - changed |= addsymbol(p, ssymbol, curassoc->override); - } - } - return changed; -} - - - - static int -dolocks() -/* Function: remove lock for caller or first lock if unlockcaller is set; - * remove locks which are stored in rmvlocklst, - * add new locks which are stored in newlocklst, - * add lock for Dbranch or Head if lockhead is set. - */ -{ - struct Lockrev const *lockpt; - struct hshentry *target; - int changed = false; - - if (unlockcaller) { /* find lock for caller */ - if ( Head ) { - if (Locks) { - switch (findlock(true, &target)) { - case 0: - /* remove most recent lock */ - changed |= breaklock(Locks->delta); - break; - case 1: - diagnose("%s unlocked\n",target->num); - changed = true; - break; - } - } else { - rcswarn("No locks are set."); - } - } else { - rcswarn("can't unlock an empty tree"); - } - } - - /* remove locks which are stored in rmvlocklst */ - for (lockpt = rmvlocklst; lockpt; lockpt = lockpt->nextrev) - if (expandsym(lockpt->revno, &numrev)) { - target = genrevs(numrev.string, (char *)0, (char *)0, (char *)0, &gendeltas); - if ( target ) - if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string)) - rcserror("can't unlock nonexisting revision %s", - lockpt->revno - ); - else - changed |= breaklock(target); - /* breaklock does its own diagnose */ - } - - /* add new locks which stored in newlocklst */ - for (lockpt = newlocklst; lockpt; lockpt = lockpt->nextrev) - changed |= setlock(lockpt->revno); - - if (lockhead) /* lock default branch or head */ - if (Dbranch) - changed |= setlock(Dbranch); - else if (Head) - changed |= setlock(Head->num); - else - rcswarn("can't lock an empty tree"); - return changed; -} - - - - static int -setlock(rev) - char const *rev; -/* Function: Given a revision or branch number, finds the corresponding - * delta and locks it for caller. - */ -{ - struct hshentry *target; - int r; - - if (expandsym(rev, &numrev)) { - target = genrevs(numrev.string, (char*)0, (char*)0, - (char*)0, &gendeltas); - if ( target ) - if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string)) - rcserror("can't lock nonexisting revision %s", - numrev.string - ); - else { - if ((r = addlock(target, false)) < 0 && breaklock(target)) - r = addlock(target, true); - if (0 <= r) { - if (r) - diagnose("%s locked\n", target->num); - return r; - } - } - } - return 0; -} - - - static int -domessages() -{ - struct hshentry *target; - struct Message *p; - int changed = false; - - for (p = messagelst; p; p = p->nextmessage) - if ( - expandsym(p->revno, &numrev) && - (target = genrevs( - numrev.string, (char*)0, (char*)0, (char*)0, &gendeltas - )) - ) { - /* - * We can't check the old log -- it's much later in the file. - * We pessimistically assume that it changed. - */ - target->log = p->message; - changed = true; - } - return changed; -} - - - static int -rcs_setstate(rev,status) - char const *rev, *status; -/* Function: Given a revision or branch number, finds the corresponding delta - * and sets its state to status. - */ -{ - struct hshentry *target; - - if (expandsym(rev, &numrev)) { - target = genrevs(numrev.string, (char*)0, (char*)0, - (char*)0, &gendeltas); - if ( target ) - if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string)) - rcserror("can't set state of nonexisting revision %s", - numrev.string - ); - else if (strcmp(target->state, status) != 0) { - target->state = status; - return true; - } - } - return false; -} - - - - - - static int -buildeltatext(deltas) - struct hshentries const *deltas; -/* Function: put the delta text on frewrite and make necessary */ -/* change to delta text */ -{ - register FILE *fcut; /* temporary file to rebuild delta tree */ - char const *cutname; - - fcut = 0; - cuttail->selector = false; - scanlogtext(deltas->first, false); - if ( cuthead ) { - cutname = maketemp(3); - if (!(fcut = fopenSafer(cutname, FOPEN_WPLUS_WORK))) { - efaterror(cutname); - } - - while (deltas->first != cuthead) { - deltas = deltas->rest; - scanlogtext(deltas->first, true); - } - - snapshotedit(fcut); - Orewind(fcut); - aflush(fcut); - } - - while (deltas->first != cuttail) - scanlogtext((deltas = deltas->rest)->first, true); - finishedit((struct hshentry*)0, (FILE*)0, true); - Ozclose(&fcopy); - - if (fcut) { - char const *diffname = maketemp(0); - char const *diffv[6 + !!OPEN_O_BINARY]; - char const **diffp = diffv; - *++diffp = DIFF; - *++diffp = DIFFFLAGS; -# if OPEN_O_BINARY - if (Expand == BINARY_EXPAND) - *++diffp == "--binary"; -# endif - *++diffp = "-"; - *++diffp = resultname; - *++diffp = 0; - switch (runv(fileno(fcut), diffname, diffv)) { - case DIFF_FAILURE: case DIFF_SUCCESS: break; - default: rcsfaterror("diff failed"); - } - Ofclose(fcut); - return putdtext(cuttail,diffname,frewrite,true); - } else - return putdtext(cuttail,resultname,frewrite,false); -} - - - - static void -buildtree() -/* Function: actually removes revisions whose selector field */ -/* is false, and rebuilds the linkage of deltas. */ -/* asks for reconfirmation if deleting last revision*/ -{ - struct hshentry * Delta; - struct branchhead *pt, *pre; - - if ( cuthead ) - if ( cuthead->next == delstrt ) - cuthead->next = cuttail; - else { - pre = pt = cuthead->branches; - while( pt && pt->hsh != delstrt ) { - pre = pt; - pt = pt->nextbranch; - } - if ( cuttail ) - pt->hsh = cuttail; - else if ( pt == pre ) - cuthead->branches = pt->nextbranch; - else - pre->nextbranch = pt->nextbranch; - } - else { - if (!cuttail && !quietflag) { - if (!yesorno(false, "Do you really want to delete all revisions? [ny](n): ")) { - rcserror("No revision deleted"); - Delta = delstrt; - while( Delta) { - Delta->selector = true; - Delta = Delta->next; - } - return; - } - } - Head = cuttail; - } - return; -} - -#if RCS_lint -/* This lets us lint everything all at once. */ - -char const cmdid[] = ""; - -#define go(p,e) {int p P((int,char**)); void e P((void)); if(*argv)return p(argc,argv);if(*argv[1])e();} - - int -main(argc, argv) - int argc; - char **argv; -{ - go(ciId, ciExit); - go(coId, coExit); - go(identId, identExit); - go(mergeId, mergeExit); - go(rcsId, exiterr); - go(rcscleanId, rcscleanExit); - go(rcsdiffId, rdiffExit); - go(rcsmergeId, rmergeExit); - go(rlogId, rlogExit); - return 0; -} -#endif diff --git a/gnu/usr.bin/rcs/rcs/rcsfile.5 b/gnu/usr.bin/rcs/rcs/rcsfile.5 deleted file mode 100644 index 5d944e0dc3e..00000000000 --- a/gnu/usr.bin/rcs/rcs/rcsfile.5 +++ /dev/null @@ -1,425 +0,0 @@ -.lf 1 ./rcsfile.5in -.\" Set p to 1 if your formatter can handle pic output. -.if t .nr p 1 -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcs/rcsfile.5 79454 2001-07-09 09:54:33Z dd $ -.ds r \s-1RCS\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH RCSFILE 5 \*(Dt GNU -.SH NAME -rcsfile \- format of RCS file -.SH DESCRIPTION -An \*r file's -contents are described by the grammar -below. -.PP -The text is free format: space, backspace, tab, newline, vertical -tab, form feed, and carriage return (collectively, -.IR "white space") -have no significance except in strings. -However, white space cannot appear within an id, num, or sym, -and an \*r file must end with a newline. -.PP -Strings are enclosed by -.BR @ . -If a string contains a -.BR @ , -it must be doubled; -otherwise, strings can contain arbitrary binary data. -.PP -The meta syntax uses the following conventions: `|' (bar) separates -alternatives; `{' and `}' enclose optional phrases; `{' and `}*' enclose -phrases that can be repeated zero or more times; -`{' and '}+' enclose phrases that must appear at least once and can be -repeated; -Terminal symbols are in -.BR boldface ; -nonterminal symbols are in -.IR italics . -.LP -.nr w \w'\f3deltatext\fP ' -.nr y \w'\f3newphrase\fP ' -.if \nw<\ny .nr w \ny -.nr x \w'\f3branches\fP' -.nr y \w'{ \f3comment\fP' -.if \nx<\ny .nr x \ny -.nr y \w'\f3{ branch\fP' -.if \nx<\ny .nr x \ny -.ta \nwu +\w'::= 'u +\nxu+\w' 'u -.fc # -.nf -\f2rcstext\fP ::= \f2admin\fP {\f2delta\fP}* \f2desc\fP {\f2deltatext\fP}* -.LP -\f2admin\fP ::= \f3head\fP {\f2num\fP}\f3;\fP - { \f3branch\fP {\f2num\fP}\f3;\fP } - \f3access\fP {\f2id\fP}*\f3;\fP - \f3symbols\fP {\f2sym\fP \f3:\fP \f2num\fP}*\f3;\fP - \f3locks\fP {\f2id\fP \f3:\fP \f2num\fP}*\f3;\fP {\f3strict ;\fP} - { \f3comment\fP {\f2string\fP}\f3;\fP } - { \f3expand\fP {\f2string\fP}\f3;\fP } - { \f2newphrase\fP }* -.LP -\f2delta\fP ::= \f2num\fP - \f3date\fP \f2num\fP\f3;\fP - \f3author\fP \f2id\fP\f3;\fP - \f3state\fP {\f2id\fP}\f3;\fP - \f3branches\fP {\f2num\fP}*\f3;\fP - \f3next\fP {\f2num\fP}\f3;\fP - { \f2newphrase\fP }* -.LP -\f2desc\fP ::= \f3desc\fP \f2string\fP -.LP -\f2deltatext\fP ::= \f2num\fP - \f3log\fP \f2string\fP - { \f2newphrase\fP }* - \f3text\fP \f2string\fP -.LP -\f2num\fP ::= {\f2digit\fP | \f3.\fP}+ -.LP -\f2digit\fP ::= \f30\fP | \f31\fP | \f32\fP | \f33\fP | \f34\fP | \f35\fP | \f36\fP | \f37\fP | \f38\fP | \f39\fP -.LP -\f2id\fP ::= {\f2num\fP} \f2idchar\fP {\f2idchar\fP | \f2num\fP}* -.LP -\f2sym\fP ::= {\f2digit\fP}* \f2idchar\fP {\f2idchar\fP | \f2digit\fP}* -.LP -\f2idchar\fP ::= any visible graphic character except \f2special\fP -.LP -\f2special\fP ::= \f3$\fP | \f3,\fP | \f3.\fP | \f3:\fP | \f3;\fP | \f3@\fP -.LP -\f2string\fP ::= \f3@\fP{any character, with \f3@\fP doubled}*\f3@\fP -.LP -\f2newphrase\fP ::= \f2id\fP \f2word\fP* \f3;\fP -.LP -\f2word\fP ::= \f2id\fP | \f2num\fP | \f2string\fP | \f3:\fP -.fi -.PP -Identifiers are case sensitive. Keywords are in lower case only. -The sets of keywords and identifiers can overlap. -In most environments \*r uses the \s-1ISO\s0 8859/1 encoding: -visible graphic characters are codes 041\-176 and 240\-377, -and white space characters are codes 010\-015 and 040. -.PP -Dates, which appear after the -.B date -keyword, are of the form -\f2Y\fP\f3.\fP\f2mm\fP\f3.\fP\f2dd\fP\f3.\fP\f2hh\fP\f3.\fP\f2mm\fP\f3.\fP\f2ss\fP, -where -.I Y -is the year, -.I mm -the month (01\-12), -.I dd -the day (01\-31), -.I hh -the hour (00\-23), -.I mm -the minute (00\-59), -and -.I ss -the second (00\-60). -.I Y -contains just the last two digits of the year -for years from 1900 through 1999, -and all the digits of years thereafter. -Dates use the Gregorian calendar; times use UTC. -.PP -The -.I newphrase -productions in the grammar are reserved for future extensions -to the format of \*r files. -No -.I newphrase -will begin with any keyword already in use. -.PP -The -.I delta -nodes form a tree. All nodes whose numbers -consist of a single pair -(e.g., 2.3, 2.1, 1.3, etc.) -are on the trunk, and are linked through the -.B next -field in order of decreasing numbers. -The -.B head -field in the -.I admin -node points to the head of that sequence (i.e., contains -the highest pair). -The -.B branch -node in the admin node indicates the default -branch (or revision) for most \*r operations. -If empty, the default -branch is the highest branch on the trunk. -.PP -All -.I delta -nodes whose numbers consist of -.RI 2 n -fields -.RI ( n \(>=2) -(e.g., 3.1.1.1, 2.1.2.2, etc.) -are linked as follows. -All nodes whose first -.RI 2 n \-1 -number fields are identical are linked through the -.B next -field in order of increasing numbers. -For each such sequence, -the -.I delta -node whose number is identical to the first -.RI 2 n \-2 -number fields of the deltas on that sequence is called the branchpoint. -The -.B branches -field of a node contains a list of the -numbers of the first nodes of all sequences for which it is a branchpoint. -This list is ordered in increasing numbers. -.LP -The following diagram shows an example of an \*r file's organization. -.if !\np \{\ -.nf -.vs 12 -.ne 36 -.cs 1 20 -.eo - - Head - | - | - v / \ - --------- / \ - / \ / \ | | / \ / \ - / \ / \ | 2.1 | / \ / \ - / \ / \ | | / \ / \ -/1.2.1.3\ /1.3.1.1\ | | /1.2.2.2\ /1.2.2.1.1.1\ ---------- --------- --------- --------- ------------- - ^ ^ | ^ ^ - | | | | | - | | v | | - / \ | --------- / \ | - / \ | \ 1.3 / / \ | - / \ ---------\ / / \----------- -/1.2.1.1\ \ / /1.2.2.1\ ---------- \ / --------- - ^ | ^ - | | | - | v | - | --------- | - | \ 1.2 / | - ----------------------\ /--------- - \ / - \ / - | - | - v - --------- - \ 1.1 / - \ / - \ / - \ / - -.ec -.cs 1 -.vs -.fi -.\} -.if \np \{\ -.lf 232 -.PS 4.250i 3.812i -.\" -2.0625 -4.25 1.75 0 -.\" 0.000i 4.250i 3.812i 0.000i -.nr 00 \n(.u -.nf -.nr 0x 1 -\h'3.812i' -.sp -1 -.lf 242 -\h'2.062i-(\w'Head'u/2u)'\v'0.125i-(0v/2u)+0v+0.22m'Head -.sp -1 -\h'2.062i'\v'0.250i'\D'l0.000i 0.500i' -.sp -1 -\h'2.087i'\v'0.650i'\D'l-0.025i 0.100i' -.sp -1 -\h'2.062i'\v'0.750i'\D'l-0.025i -0.100i' -.sp -1 -\h'1.688i'\v'1.250i'\D'l0.750i 0.000i' -.sp -1 -\h'2.438i'\v'1.250i'\D'l0.000i -0.500i' -.sp -1 -\h'2.438i'\v'0.750i'\D'l-0.750i 0.000i' -.sp -1 -\h'1.688i'\v'0.750i'\D'l0.000i 0.500i' -.sp -1 -.lf 244 -\h'2.062i-(\w'2.1'u/2u)'\v'1.000i-(0v/2u)+0v+0.22m'2.1 -.sp -1 -\h'2.062i'\v'1.250i'\D'l0.000i 0.500i' -.sp -1 -\h'2.087i'\v'1.650i'\D'l-0.025i 0.100i' -.sp -1 -\h'2.062i'\v'1.750i'\D'l-0.025i -0.100i' -.sp -1 -.lf 246 -\h'2.062i-(\w'1.3'u/2u)'\v'2.000i-(1v/2u)+0v+0.22m'1.3 -.sp -1 -\h'2.062i'\v'2.250i'\D'l-0.375i -0.500i' -.sp -1 -\h'1.688i'\v'1.750i'\D'l0.750i 0.000i' -.sp -1 -\h'2.438i'\v'1.750i'\D'l-0.375i 0.500i' -.sp -1 -\h'1.875i'\v'2.000i'\D'~-0.500i 0.000i 0.000i -0.500i' -.sp -1 -\h'1.350i'\v'1.600i'\D'l0.025i -0.100i' -.sp -1 -\h'1.375i'\v'1.500i'\D'l0.025i 0.100i' -.sp -1 -.lf 249 -\h'1.375i-(\w'1.3.1.1'u/2u)'\v'1.250i-(1v/2u)+1v+0.22m'1.3.1.1 -.sp -1 -\h'1.375i'\v'1.000i'\D'l-0.375i 0.500i' -.sp -1 -\h'1.000i'\v'1.500i'\D'l0.750i 0.000i' -.sp -1 -\h'1.750i'\v'1.500i'\D'l-0.375i -0.500i' -.sp -1 -\h'2.062i'\v'2.250i'\D'l0.000i 0.500i' -.sp -1 -\h'2.087i'\v'2.650i'\D'l-0.025i 0.100i' -.sp -1 -\h'2.062i'\v'2.750i'\D'l-0.025i -0.100i' -.sp -1 -.lf 252 -\h'2.062i-(\w'1.2'u/2u)'\v'3.000i-(1v/2u)+0v+0.22m'1.2 -.sp -1 -\h'2.062i'\v'3.250i'\D'l-0.375i -0.500i' -.sp -1 -\h'1.688i'\v'2.750i'\D'l0.750i 0.000i' -.sp -1 -\h'2.438i'\v'2.750i'\D'l-0.375i 0.500i' -.sp -1 -\h'1.875i'\v'3.000i'\D'~-0.500i 0.000i -0.500i 0.000i -0.500i 0.000i 0.000i -0.500i' -.sp -1 -\h'0.350i'\v'2.600i'\D'l0.025i -0.100i' -.sp -1 -\h'0.375i'\v'2.500i'\D'l0.025i 0.100i' -.sp -1 -.lf 255 -\h'0.375i-(\w'1.2.1.1'u/2u)'\v'2.250i-(1v/2u)+1v+0.22m'1.2.1.1 -.sp -1 -\h'0.375i'\v'2.000i'\D'l-0.375i 0.500i' -.sp -1 -\h'0.000i'\v'2.500i'\D'l0.750i 0.000i' -.sp -1 -\h'0.750i'\v'2.500i'\D'l-0.375i -0.500i' -.sp -1 -\h'0.375i'\v'2.000i'\D'l0.000i -0.500i' -.sp -1 -\h'0.350i'\v'1.600i'\D'l0.025i -0.100i' -.sp -1 -\h'0.375i'\v'1.500i'\D'l0.025i 0.100i' -.sp -1 -.lf 257 -\h'0.375i-(\w'1.2.1.3'u/2u)'\v'1.250i-(1v/2u)+1v+0.22m'1.2.1.3 -.sp -1 -\h'0.375i'\v'1.000i'\D'l-0.375i 0.500i' -.sp -1 -\h'0.000i'\v'1.500i'\D'l0.750i 0.000i' -.sp -1 -\h'0.750i'\v'1.500i'\D'l-0.375i -0.500i' -.sp -1 -\h'2.250i'\v'3.000i'\D'~0.500i 0.000i 0.000i -0.500i' -.sp -1 -\h'2.725i'\v'2.600i'\D'l0.025i -0.100i' -.sp -1 -\h'2.750i'\v'2.500i'\D'l0.025i 0.100i' -.sp -1 -.lf 261 -\h'2.750i-(\w'1.2.2.1'u/2u)'\v'2.250i-(1v/2u)+1v+0.22m'1.2.2.1 -.sp -1 -\h'2.750i'\v'2.000i'\D'l-0.375i 0.500i' -.sp -1 -\h'2.375i'\v'2.500i'\D'l0.750i 0.000i' -.sp -1 -\h'3.125i'\v'2.500i'\D'l-0.375i -0.500i' -.sp -1 -\h'2.938i'\v'2.250i'\D'~0.500i 0.000i 0.000i -0.500i 0.000i -0.500i' -.sp -1 -\h'3.413i'\v'1.350i'\D'l0.025i -0.100i' -.sp -1 -\h'3.438i'\v'1.250i'\D'l0.025i 0.100i' -.sp -1 -.lf 264 -\h'3.438i-(\w'\s-21.2.2.1.1.1\s0'u/2u)'\v'1.000i-(1v/2u)+1v+0.22m'\s-21.2.2.1.1.1\s0 -.sp -1 -\h'3.438i'\v'0.750i'\D'l-0.375i 0.500i' -.sp -1 -\h'3.062i'\v'1.250i'\D'l0.750i 0.000i' -.sp -1 -\h'3.812i'\v'1.250i'\D'l-0.375i -0.500i' -.sp -1 -\h'2.750i'\v'2.000i'\D'l0.000i -0.500i' -.sp -1 -\h'2.725i'\v'1.600i'\D'l0.025i -0.100i' -.sp -1 -\h'2.750i'\v'1.500i'\D'l0.025i 0.100i' -.sp -1 -.lf 267 -\h'2.750i-(\w'1.2.2.2'u/2u)'\v'1.250i-(1v/2u)+1v+0.22m'1.2.2.2 -.sp -1 -\h'2.750i'\v'1.000i'\D'l-0.375i 0.500i' -.sp -1 -\h'2.375i'\v'1.500i'\D'l0.750i 0.000i' -.sp -1 -\h'3.125i'\v'1.500i'\D'l-0.375i -0.500i' -.sp -1 -\h'2.062i'\v'3.250i'\D'l0.000i 0.500i' -.sp -1 -\h'2.087i'\v'3.650i'\D'l-0.025i 0.100i' -.sp -1 -\h'2.062i'\v'3.750i'\D'l-0.025i -0.100i' -.sp -1 -.lf 270 -\h'2.062i-(\w'1.1'u/2u)'\v'4.000i-(1v/2u)+0v+0.22m'1.1 -.sp -1 -\h'2.062i'\v'4.250i'\D'l-0.375i -0.500i' -.sp -1 -\h'1.688i'\v'3.750i'\D'l0.750i 0.000i' -.sp -1 -\h'2.438i'\v'3.750i'\D'l-0.375i 0.500i' -.sp -1 -.sp 4.250i+1 -.if \n(00 .fi -.br -.nr 0x 0 -.lf 271 -.PE -.lf 272 -.\} -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH SEE ALSO -rcsintro(1), ci(1), co(1), ident(1), rcs(1), rcsclean(1), rcsdiff(1), -rcsmerge(1), rlog(1) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. diff --git a/gnu/usr.bin/rcs/rcs/rcsintro.1 b/gnu/usr.bin/rcs/rcs/rcsintro.1 deleted file mode 100644 index e67b1b5110c..00000000000 --- a/gnu/usr.bin/rcs/rcs/rcsintro.1 +++ /dev/null @@ -1,302 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcs/rcsintro.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \&\s-1RCS\s0 -.if n .ds - \%-- -.if t .ds - \(em -.if !\n(.g \{\ -. if !\w|\*(lq| \{\ -. ds lq `` -. if \w'\(lq' .ds lq "\(lq -. \} -. if !\w|\*(rq| \{\ -. ds rq '' -. if \w'\(rq' .ds rq "\(rq -. \} -.\} -.am SS -.LP -.. -.TH RCSINTRO 1 \*(Dt GNU -.SH NAME -rcsintro \- introduction to RCS commands -.SH DESCRIPTION -The Revision Control System (\*r) manages multiple revisions of files. -\*r automates the storing, retrieval, logging, identification, and merging -of revisions. \*r is useful for text that is revised frequently, for example -programs, documentation, graphics, papers, and form letters. -.PP -The basic user interface is extremely simple. The novice only needs -to learn two commands: -.BR ci (1) -and -.BR co (1). -.BR ci , -short for \*(lqcheck in\*(rq, deposits the contents of a -file into an archival file called an \*r file. An \*r file -contains all revisions of a particular file. -.BR co , -short for \*(lqcheck out\*(rq, retrieves revisions from an \*r file. -.SS "Functions of \*r" -.IP \(bu -Store and retrieve multiple revisions of text. \*r saves all old -revisions in a space efficient way. -Changes no longer destroy the original, because the -previous revisions remain accessible. Revisions can be retrieved according to -ranges of revision numbers, symbolic names, dates, authors, and -states. -.IP \(bu -Maintain a complete history of changes. -\*r logs all changes automatically. -Besides the text of each revision, \*r stores the author, the date and time of -check-in, and a log message summarizing the change. -The logging makes it easy to find out -what happened to a module, without having to compare -source listings or having to track down colleagues. -.IP \(bu -Resolve access conflicts. When two or more programmers wish to -modify the same revision, \*r alerts the programmers and prevents one -modification from corrupting the other. -.IP \(bu -Maintain a tree of revisions. \*r can maintain separate lines of development -for each module. It stores a tree structure that represents the -ancestral relationships among revisions. -.IP \(bu -Merge revisions and resolve conflicts. -Two separate lines of development of a module can be coalesced by merging. -If the revisions to be merged affect the same sections of code, \*r alerts the -user about the overlapping changes. -.IP \(bu -Control releases and configurations. -Revisions can be assigned symbolic names -and marked as released, stable, experimental, etc. -With these facilities, configurations of modules can be -described simply and directly. -.IP \(bu -Automatically identify each revision with name, revision number, -creation time, author, etc. -The identification is like a stamp that can be embedded at an appropriate place -in the text of a revision. -The identification makes it simple to determine which -revisions of which modules make up a given configuration. -.IP \(bu -Minimize secondary storage. \*r needs little extra space for -the revisions (only the differences). If intermediate revisions are -deleted, the corresponding deltas are compressed accordingly. -.SS "Getting Started with \*r" -Suppose you have a file -.B f.c -that you wish to put under control of \*r. -If you have not already done so, make an \*r directory with the command -.IP -.B "mkdir RCS" -.LP -Then invoke the check-in command -.IP -.B "ci f.c" -.LP -This command creates an \*r file in the -.B RCS -directory, -stores -.B f.c -into it as revision 1.1, and -deletes -.BR f.c . -It also asks you for a description. The description -should be a synopsis of the contents of the file. All later check-in -commands will ask you for a log entry, which should summarize the -changes that you made. -.PP -Files in the \*r directory are called \*r files; -the others are called working files. -To get back the working file -.B f.c -in the previous example, use the check-out -command -.IP -.B "co f.c" -.LP -This command extracts the latest revision from the \*r file -and writes -it into -.BR f.c . -If you want to edit -.BR f.c , -you must lock it as you check it out with the command -.IP -.B "co \-l f.c" -.LP -You can now edit -.BR f.c . -.PP -Suppose after some editing you want to know what changes that you have made. -The command -.IP -.B "rcsdiff f.c" -.LP -tells you the difference between the most recently checked-in version -and the working file. -You can check the file back in by invoking -.IP -.B "ci f.c" -.LP -This increments the revision number properly. -.PP -If -.B ci -complains with the message -.IP -.BI "ci error: no lock set by " "your name" -.LP -then you have tried to check in a file even though you did not -lock it when you checked it out. -Of course, it is too late now to do the check-out with locking, because -another check-out would -overwrite your modifications. Instead, invoke -.IP -.B "rcs \-l f.c" -.LP -This command will lock the latest revision for you, unless somebody -else got ahead of you already. In this case, you'll have to negotiate with -that person. -.PP -Locking assures that you, and only you, can check in the next update, and -avoids nasty problems if several people work on the same file. -Even if a revision is locked, it can still be checked out for -reading, compiling, etc. All that locking -prevents is a -.I "check-in" -by anybody but the locker. -.PP -If your \*r file is private, i.e., if you are the only person who is going -to deposit revisions into it, strict locking is not needed and you -can turn it off. -If strict locking is turned off, -the owner of the \*r file need not have a lock for check-in; all others -still do. Turning strict locking off and on is done with the commands -.IP -.BR "rcs \-U f.c" " and " "rcs \-L f.c" -.LP -If you don't want to clutter your working directory with \*r files, create -a subdirectory called -.B RCS -in your working directory, and move all your \*r -files there. \*r commands will look first into that directory to find -needed files. All the commands discussed above will still work, without any -modification. -(Actually, pairs of \*r and working files can be specified in three ways: -(a) both are given, (b) only the working file is given, (c) only the -\*r file is given. Both \*r and working files may have arbitrary path prefixes; -\*r commands pair them up intelligently.) -.PP -To avoid the deletion of the working file during check-in (in case you want to -continue editing or compiling), invoke -.IP -.BR "ci \-l f.c" " or " "ci \-u f.c" -.LP -These commands check in -.B f.c -as usual, but perform an implicit -check-out. The first form also locks the checked in revision, the second one -doesn't. Thus, these options save you one check-out operation. -The first form is useful if you want to continue editing, -the second one if you just want to read the file. -Both update the identification markers in your working file (see below). -.PP -You can give -.B ci -the number you want assigned to a checked in -revision. Assume all your revisions were numbered 1.1, 1.2, 1.3, etc., -and you would like to start release 2. -The command -.IP -.BR "ci \-r2 f.c" " or " "ci \-r2.1 f.c" -.LP -assigns the number 2.1 to the new revision. -From then on, -.B ci -will number the subsequent revisions -with 2.2, 2.3, etc. The corresponding -.B co -commands -.IP -.BR "co \-r2 f.c" " and " "co \-r2.1 f.c" -.PP -retrieve the latest revision numbered -.RI 2. x -and the revision 2.1, -respectively. -.B co -without a revision number selects -the latest revision on the -.IR trunk , -i.e. the highest -revision with a number consisting of two fields. Numbers with more than two -fields are needed for branches. -For example, to start a branch at revision 1.3, invoke -.IP -.B "ci \-r1.3.1 f.c" -.LP -This command starts a branch numbered 1 at revision 1.3, and assigns -the number 1.3.1.1 to the new revision. For more information about -branches, see -.BR rcsfile (5). -.SS "Automatic Identification" -\*r can put special strings for identification into your source and object -code. To obtain such identification, place the marker -.IP -.B "$\&Id$" -.LP -into your text, for instance inside a comment. -\*r will replace this marker with a string of the form -.IP -.BI $\&Id: " filename revision date time author state " $ -.LP -With such a marker on the first page of each module, you can -always see with which revision you are working. -\*r keeps the markers up to date automatically. -To propagate the markers into your object code, simply put -them into literal character strings. In C, this is done as follows: -.IP -.ft 3 -static char rcsid[] = \&"$\&Id$\&"; -.ft -.LP -The command -.B ident -extracts such markers from any file, even object code -and dumps. -Thus, -.B ident -lets you find out -which revisions of which modules were used in a given program. -.PP -You may also find it useful to put the marker -.B $\&Log$ -into your text, inside a comment. This marker accumulates -the log messages that are requested during check-in. -Thus, you can maintain the complete history of your file directly inside it. -There are several additional identification markers; see -.BR co (1) -for -details. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993 Paul Eggert. -.SH "SEE ALSO" -ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.br diff --git a/gnu/usr.bin/rcs/rcsclean/Makefile b/gnu/usr.bin/rcs/rcsclean/Makefile deleted file mode 100644 index fe538a0a41f..00000000000 --- a/gnu/usr.bin/rcs/rcsclean/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROG= rcsclean -SRCS= rcsclean.c -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/rcsclean/Makefile.depend b/gnu/usr.bin/rcs/rcsclean/Makefile.depend deleted file mode 100644 index ed41e7c85b4..00000000000 --- a/gnu/usr.bin/rcs/rcsclean/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsclean/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/rcsclean/rcsclean.1 b/gnu/usr.bin/rcs/rcsclean/rcsclean.1 deleted file mode 100644 index ae23181b28d..00000000000 --- a/gnu/usr.bin/rcs/rcsclean/rcsclean.1 +++ /dev/null @@ -1,203 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsclean/rcsclean.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \&\s-1RCS\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH RCSCLEAN 1 \*(Dt GNU -.SH NAME -rcsclean \- clean up working files -.SH SYNOPSIS -.B rcsclean -.RI [ options "] [ " file " .\|.\|. ]" -.SH DESCRIPTION -.B rcsclean -removes files that are not being worked on. -.B "rcsclean \-u" -also unlocks and removes files that are being worked on -but have not changed. -.PP -For each -.I file -given, -.B rcsclean -compares the working file and a revision in the corresponding -\*r file. If it finds a difference, it does nothing. -Otherwise, it first unlocks the revision if the -.B \-u -option is given, -and then removes the working file -unless the working file is writable and the revision is locked. -It logs its actions by outputting the corresponding -.B "rcs \-u" -and -.B "rm \-f" -commands on the standard output. -.PP -Files are paired as explained in -.BR ci (1). -If no -.I file -is given, all working files in the current directory are cleaned. -Pathnames matching an \*r suffix denote \*r files; -all others denote working files. -.PP -The number of the revision to which the working file is compared -may be attached to any of the options -.BR \-n , -.BR \-q , -.BR \-r , -or -.BR \-u . -If no revision number is specified, then if the -.B \-u -option is given and the caller has one revision locked, -.B rcsclean -uses that revision; otherwise -.B rcsclean -uses the latest revision on the default branch, normally the root. -.PP -.B rcsclean -is useful for -.B clean -targets in makefiles. -See also -.BR rcsdiff (1), -which prints out the differences, -and -.BR ci (1), -which -normally reverts to the previous revision -if a file was not changed. -.SH OPTIONS -.TP -.BI \-k subst -Use -.I subst -style keyword substitution when retrieving the revision for comparison. -See -.BR co (1) -for details. -.TP -.BR \-n [\f2rev\fP] -Do not actually remove any files or unlock any revisions. -Using this option will tell you what -.B rcsclean -would do without actually doing it. -.TP -.BR \-q [\f2rev\fP] -Do not log the actions taken on standard output. -.TP -.BR \-r [\f2rev\fP] -This option has no effect other than specifying the revision for comparison. -.TP -.B \-T -Preserve the modification time on the \*r file -even if the \*r file changes because a lock is removed. -This option can suppress extensive recompilation caused by a -.BR make (1) -dependency of some other copy of the working file on the \*r file. -Use this option with care; it can suppress recompilation even when it is needed, -i.e. when the lock removal -would mean a change to keyword strings in the other working file. -.TP -.BR \-u [\f2rev\fP] -Unlock the revision if it is locked and no difference is found. -.TP -.BI \-V -Print \*r's version number. -.TP -.BI \-V n -Emulate \*r version -.IR n . -See -.BR co (1) -for details. -.TP -.BI \-x "suffixes" -Use -.I suffixes -to characterize \*r files. -See -.BR ci (1) -for details. -.TP -.BI \-z zone -Use -.I zone -as the time zone for keyword substitution; -see -.BR co (1) -for details. -.SH EXAMPLES -.LP -.RS -.ft 3 -rcsclean *.c *.h -.ft -.RE -.LP -removes all working files ending in -.B .c -or -.B .h -that were not changed -since their checkout. -.LP -.RS -.ft 3 -rcsclean -.ft -.RE -.LP -removes all working files in the current directory -that were not changed since their checkout. -.SH FILES -.B rcsclean -accesses files much as -.BR ci (1) -does. -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -A backslash escapes spaces within an option. -The -.B \s-1RCSINIT\s0 -options are prepended to the argument lists of most \*r commands. -Useful -.B \s-1RCSINIT\s0 -options include -.BR \-q , -.BR \-V , -.BR \-x , -and -.BR \-z . -.SH DIAGNOSTICS -The exit status is zero if and only if all operations were successful. -Missing working files and \*r files are silently ignored. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993 Paul Eggert. -.SH "SEE ALSO" -ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1), -rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.SH BUGS -At least one -.I file -must be given in older Unix versions that -do not provide the needed directory scanning operations. -.br diff --git a/gnu/usr.bin/rcs/rcsclean/rcsclean.c b/gnu/usr.bin/rcs/rcsclean/rcsclean.c deleted file mode 100644 index f3faae2a6ed..00000000000 --- a/gnu/usr.bin/rcs/rcsclean/rcsclean.c +++ /dev/null @@ -1,333 +0,0 @@ -/* Clean up working files. */ - -/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -#include "rcsbase.h" - -#if has_dirent - static int get_directory P((char const*,char***)); -#endif - -static int unlock P((struct hshentry *)); -static void cleanup P((void)); - -static RILE *workptr; -static int exitstatus; - -mainProg(rcscleanId, "rcsclean", "$FreeBSD: stable/11/gnu/usr.bin/rcs/rcsclean/rcsclean.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const usage[] = - "\nrcsclean: usage: rcsclean -ksubst -{nqru}[rev] -T -Vn -xsuff -zzone file ..."; - - static struct buf revision; - - char *a, **newargv; - char const *rev, *p; - int dounlock, expmode, perform, unlocked, unlockflag, waslocked; - int Ttimeflag; - struct hshentries *deltas; - struct hshentry *delta; - struct stat workstat; - - setrid(); - - expmode = -1; - rev = 0; - suffixes = X_DEFAULT; - perform = true; - unlockflag = false; - Ttimeflag = false; - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - for (;;) { - if (--argc < 1) { -# if has_dirent - argc = get_directory(".", &newargv); - argv = newargv; - break; -# else - faterror("no pathnames specified"); -# endif - } - a = *++argv; - if (!*a || *a++ != '-') - break; - switch (*a++) { - case 'k': - if (0 <= expmode) - redefined('k'); - if ((expmode = str2expmode(a)) < 0) - goto unknown; - break; - - case 'n': - perform = false; - goto handle_revision; - - case 'q': - quietflag = true; - /* fall into */ - case 'r': - handle_revision: - if (*a) { - if (rev) - warn("redefinition of revision number"); - rev = a; - } - break; - - case 'T': - if (*a) - goto unknown; - Ttimeflag = true; - break; - - case 'u': - unlockflag = true; - goto handle_revision; - - case 'V': - setRCSversion(*argv); - break; - - case 'x': - suffixes = a; - break; - - case 'z': - zone_set(a); - break; - - default: - unknown: - error("unknown option: %s%s", *argv, usage); - } - } - - dounlock = perform & unlockflag; - - if (nerror) - cleanup(); - else - for (; 0 < argc; cleanup(), ++argv, --argc) { - - ffree(); - - if (!( - 0 < pairnames( - argc, argv, - dounlock ? rcswriteopen : rcsreadopen, - true, true - ) && - (workptr = Iopen(workname, FOPEN_R_WORK, &workstat)) - )) - continue; - - if (same_file(RCSstat, workstat, 0)) { - rcserror("RCS file is the same as working file %s.", - workname - ); - continue; - } - - gettree(); - - p = 0; - if (rev) { - if (!fexpandsym(rev, &revision, workptr)) - continue; - p = revision.string; - } else if (Head) - switch (unlockflag ? findlock(false,&delta) : 0) { - default: - continue; - case 0: - p = Dbranch ? Dbranch : ""; - break; - case 1: - p = delta->num; - break; - } - delta = 0; - deltas = 0; /* Keep lint happy. */ - if (p && !(delta = genrevs(p,(char*)0,(char*)0,(char*)0,&deltas))) - continue; - - waslocked = delta && delta->lockedby; - locker_expansion = unlock(delta); - unlocked = locker_expansion & unlockflag; - if (unlockednum, RCSname); - - if (perform & unlocked) { - if_advise_access(deltas->first != delta, finptr, MADV_SEQUENTIAL); - if (donerewrite(true, - Ttimeflag ? RCSstat.st_mtime : (time_t)-1 - ) != 0) - continue; - } - - if (!quietflag) - aprintf(stdout, "rm -f %s\n", workname); - Izclose(&workptr); - if (perform && un_link(workname) != 0) - eerror(workname); - - } - - tempunlink(); - if (!quietflag) - Ofclose(stdout); - exitmain(exitstatus); -} - - static void -cleanup() -{ - if (nerror) exitstatus = EXIT_FAILURE; - Izclose(&finptr); - Izclose(&workptr); - Ozclose(&fcopy); - ORCSclose(); - dirtempunlink(); -} - -#if RCS_lint -# define exiterr rcscleanExit -#endif - void -exiterr() -{ - ORCSerror(); - dirtempunlink(); - tempunlink(); - _exit(EXIT_FAILURE); -} - - static int -unlock(delta) - struct hshentry *delta; -{ - register struct rcslock **al, *l; - - if (delta && delta->lockedby && strcmp(getcaller(),delta->lockedby)==0) - for (al = &Locks; (l = *al); al = &l->nextlock) - if (l->delta == delta) { - *al = l->nextlock; - delta->lockedby = 0; - return true; - } - return false; -} - -#if has_dirent - static int -get_directory(dirname, aargv) - char const *dirname; - char ***aargv; -/* - * Put a vector of all DIRNAME's directory entries names into *AARGV. - * Ignore names of RCS files. - * Yield the number of entries found. Terminate the vector with 0. - * Allocate the storage for the vector and entry names. - * Do not sort the names. Do not include '.' and '..'. - */ -{ - int i, entries = 0, entries_max = 64; - size_t chars = 0, chars_max = 1024; - size_t *offset = tnalloc(size_t, entries_max); - char *a = tnalloc(char, chars_max), **p; - DIR *d; - struct dirent *e; - - if (!(d = opendir(dirname))) - efaterror(dirname); - while ((errno = 0, e = readdir(d))) { - char const *en = e->d_name; - size_t s = strlen(en) + 1; - if (en[0]=='.' && (!en[1] || (en[1]=='.' && !en[2]))) - continue; - if (rcssuffix(en)) - continue; - while (chars_max < s + chars) - a = trealloc(char, a, chars_max<<=1); - if (entries == entries_max) - offset = trealloc(size_t, offset, entries_max<<=1); - offset[entries++] = chars; - VOID strcpy(a+chars, en); - chars += s; - } -# if void_closedir -# define close_directory(d) (closedir(d), 0) -# else -# define close_directory(d) closedir(d) -# endif - if (errno || close_directory(d) != 0) - efaterror(dirname); - if (chars) - a = trealloc(char, a, chars); - else - tfree(a); - *aargv = p = tnalloc(char*, entries+1); - for (i=0; i diff --git a/gnu/usr.bin/rcs/rcsdiff/Makefile.depend b/gnu/usr.bin/rcs/rcsdiff/Makefile.depend deleted file mode 100644 index c2b646913fa..00000000000 --- a/gnu/usr.bin/rcs/rcsdiff/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsdiff/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1 b/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1 deleted file mode 100644 index 4624a99491d..00000000000 --- a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1 +++ /dev/null @@ -1,158 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsdiff/rcsdiff.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \&\s-1RCS\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH RCSDIFF 1 \*(Dt GNU -.SH NAME -rcsdiff \- compare RCS revisions -.SH SYNOPSIS -.B rcsdiff -[ -.BI \-k subst -] [ -.B \-q -] [ -.BI \-r rev1 -[ -.BI \-r rev2 -] ] [ -.B \-T -] [ -.RI "\f3\-V\fP[" n ] -] [ -.BI \-x suffixes -] [ -.BI \-z zone -] [ -.I "diff options" -] -.I "file .\|.\|." -.SH DESCRIPTION -.B rcsdiff -runs -.BR diff (1) -to compare two revisions of each \*r file given. -.PP -Pathnames matching an \*r suffix denote \*r files; -all others denote working files. -Names are paired as explained in -.BR ci (1). -.PP -The option -.B \-q -suppresses diagnostic output. -Zero, one, or two revisions may be specified with -.BR \-r . -The option -.BI \-k subst -affects keyword substitution when extracting -revisions, as described in -.BR co (1); -for example, -.B "\-kk\ \-r1.1\ \-r1.2" -ignores differences in keyword values when comparing revisions -.B 1.1 -and -.BR 1.2 . -To avoid excess output from locker name substitution, -.B \-kkvl -is assumed if (1) at most one revision option is given, -(2) no -.B \-k -option is given, (3) -.B \-kkv -is the default keyword substitution, and -(4) the working file's mode would be produced by -.BR "co\ \-l". -See -.BR co (1) -for details -about -.BR \-T , -.BR \-V , -.B \-x -and -.BR \-z . -Otherwise, all options of -.BR diff (1) -that apply to regular files are accepted, with the same meaning as for -.BR diff . -.PP -If both -.I rev1 -and -.I rev2 -are omitted, -.B rcsdiff -compares the latest revision on the -default branch (by default the trunk) -with the contents of the corresponding working file. This is useful -for determining what you changed since the last checkin. -.PP -If -.I rev1 -is given, but -.I rev2 -is omitted, -.B rcsdiff -compares revision -.I rev1 -of the \*r file with -the contents of the corresponding working file. -.PP -If both -.I rev1 -and -.I rev2 -are given, -.B rcsdiff -compares revisions -.I rev1 -and -.I rev2 -of the \*r file. -.PP -Both -.I rev1 -and -.I rev2 -may be given numerically or symbolically. -.SH EXAMPLE -The command -.LP -.B " rcsdiff f.c" -.LP -compares the latest revision on the default branch of the \*r file -to the contents of the working file -.BR f.c . -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -See -.BR ci (1) -for details. -.SH DIAGNOSTICS -Exit status is 0 for no differences during any comparison, -1 for some differences, 2 for trouble. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993 Paul Eggert. -.SH "SEE ALSO" -ci(1), co(1), diff(1), ident(1), rcs(1), rcsintro(1), rcsmerge(1), rlog(1) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.br diff --git a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c b/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c deleted file mode 100644 index 836b87f0bbd..00000000000 --- a/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c +++ /dev/null @@ -1,480 +0,0 @@ -/* Compare RCS revisions. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.19 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.18 1995/06/01 16:23:43 eggert - * (main): Pass "--binary" if -kb and if --binary makes a difference. - * Don't treat + options specially. - * - * Revision 5.17 1994/03/17 14:05:48 eggert - * Specify subprocess input via file descriptor, not file name. Remove lint. - * - * Revision 5.16 1993/11/09 17:40:15 eggert - * -V now prints version on stdout and exits. Don't print usage twice. - * - * Revision 5.15 1993/11/03 17:42:27 eggert - * Add -z. Ignore -T. Pass -Vn to `co'. Add Name keyword. - * Put revision numbers in -c output. Improve quality of diagnostics. - * - * Revision 5.14 1992/07/28 16:12:44 eggert - * Add -V. Use co -M for better dates with traditional diff -c. - * - * Revision 5.13 1992/02/17 23:02:23 eggert - * Output more readable context diff headers. - * Suppress needless checkout and comparison of identical revisions. - * - * Revision 5.12 1992/01/24 18:44:19 eggert - * Add GNU diff 1.15.2's new options. lint -> RCS_lint - * - * Revision 5.11 1992/01/06 02:42:34 eggert - * Update usage string. - * - * Revision 5.10 1991/10/07 17:32:46 eggert - * Remove lint. - * - * Revision 5.9 1991/08/19 03:13:55 eggert - * Add RCSINIT, -r$. Tune. - * - * Revision 5.8 1991/04/21 11:58:21 eggert - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.7 1990/12/13 06:54:07 eggert - * GNU diff 1.15 has -u. - * - * Revision 5.6 1990/11/01 05:03:39 eggert - * Remove unneeded setid check. - * - * Revision 5.5 1990/10/04 06:30:19 eggert - * Accumulate exit status across files. - * - * Revision 5.4 1990/09/27 01:31:43 eggert - * Yield 1, not EXIT_FAILURE, when diffs are found. - * - * Revision 5.3 1990/09/11 02:41:11 eggert - * Simplify -kkvl test. - * - * Revision 5.2 1990/09/04 17:07:19 eggert - * Diff's argv was too small by 1. - * - * Revision 5.1 1990/08/29 07:13:55 eggert - * Add -kkvl. - * - * Revision 5.0 1990/08/22 08:12:46 eggert - * Add -k, -V. Don't use access(). Add setuid support. - * Remove compile-time limits; use malloc instead. - * Don't pass arguments with leading '+' to diff; GNU DIFF treats them as options. - * Add GNU diff's flags. Make lock and temp files faster and safer. - * Ansify and Posixate. - * - * Revision 4.6 89/05/01 15:12:27 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/08/09 19:12:41 eggert - * Use execv(), not system(); yield exit status like diff(1)s; allow cc -R. - * - * Revision 4.4 87/12/18 11:37:46 narten - * changes Jay Lepreau made in the 4.3 BSD version, to add support for - * "-i", "-w", and "-t" flags and to permit flags to be bundled together, - * merged in. - * - * Revision 4.3 87/10/18 10:31:42 narten - * Updating version numbers. Changes relative to 1.1 actually - * relative to 4.1 - * - * Revision 1.3 87/09/24 13:59:21 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:15 jenkins - * Port to suns - * - * Revision 4.1 83/05/03 22:13:19 wft - * Added default branch, option -q, exit status like diff. - * Added fterror() to replace faterror(). - * - * Revision 3.6 83/01/15 17:52:40 wft - * Expanded mainprogram to handle multiple RCS files. - * - * Revision 3.5 83/01/06 09:33:45 wft - * Fixed passing of -c (context) option to diff. - * - * Revision 3.4 82/12/24 15:28:38 wft - * Added call to catchsig(). - * - * Revision 3.3 82/12/10 16:08:17 wft - * Corrected checking of return code from diff; improved error msgs. - * - * Revision 3.2 82/12/04 13:20:09 wft - * replaced getdelta() with gettree(). Changed diagnostics. - * - * Revision 3.1 82/11/28 19:25:04 wft - * Initial revision. - * - */ -#include "rcsbase.h" - -#if DIFF_L -static char const *setup_label P((struct buf*,char const*,char const[datesize])); -#endif -static void cleanup P((void)); - -static int exitstatus; -static RILE *workptr; -static struct stat workstat; - -mainProg(rcsdiffId, "rcsdiff", "$FreeBSD: stable/11/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const cmdusage[] = - "\nrcsdiff usage: rcsdiff -ksubst -q -rrev1 [-rrev2] -Vn -xsuff -zzone [diff options] file ..."; - - int revnums; /* counter for revision numbers given */ - char const *rev1, *rev2; /* revision numbers from command line */ - char const *xrev1, *xrev2; /* expanded revision numbers */ - char const *expandarg, *lexpandarg, *suffixarg, *versionarg, *zonearg; -#if DIFF_L - static struct buf labelbuf[2]; - int file_labels; - char const **diff_label1, **diff_label2; - char date2[datesize]; -#endif - char const *cov[10 + !DIFF_L]; - char const **diffv, **diffp, **diffpend; /* argv for subsidiary diff */ - char const **pp, *p, *diffvstr; - struct buf commarg; - struct buf numericrev; /* expanded revision number */ - struct hshentries *gendeltas; /* deltas to be generated */ - struct hshentry * target; - char *a, *dcp, **newargv; - int no_diff_means_no_output; - register c; - - exitstatus = DIFF_SUCCESS; - - bufautobegin(&commarg); - bufautobegin(&numericrev); - revnums = 0; - rev1 = rev2 = xrev2 = 0; -#if DIFF_L - file_labels = 0; -#endif - expandarg = suffixarg = versionarg = zonearg = 0; - no_diff_means_no_output = true; - suffixes = X_DEFAULT; - - /* - * Room for runv extra + args [+ --binary] [+ 2 labels] - * + 1 file + 1 trailing null. - */ - diffv = tnalloc(char const*, 1 + argc + !!OPEN_O_BINARY + 2*DIFF_L + 2); - diffp = diffv + 1; - *diffp++ = DIFF; - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - while (a = *++argv, 0<--argc && *a++=='-') { - dcp = a; - while ((c = *a++)) switch (c) { - case 'r': - switch (++revnums) { - case 1: rev1=a; break; - case 2: rev2=a; break; - default: error("too many revision numbers"); - } - goto option_handled; - case '-': case 'D': - no_diff_means_no_output = false; - /* fall into */ - case 'C': case 'F': case 'I': case 'L': case 'W': -#if DIFF_L - if (c == 'L' && file_labels++ == 2) - faterror("too many -L options"); -#endif - *dcp++ = c; - if (*a) - do *dcp++ = *a++; - while (*a); - else { - if (!--argc) - faterror("-%c needs following argument%s", - c, cmdusage - ); - *diffp++ = *argv++; - } - break; - case 'y': - no_diff_means_no_output = false; - /* fall into */ - case 'B': case 'H': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'h': case 'i': case 'n': case 'p': - case 't': case 'u': case 'w': - *dcp++ = c; - break; - case 'q': - quietflag=true; - break; - case 'x': - suffixarg = *argv; - suffixes = *argv + 2; - goto option_handled; - case 'z': - zonearg = *argv; - zone_set(*argv + 2); - goto option_handled; - case 'T': - /* Ignore -T, so that RCSINIT can contain -T. */ - if (*a) - goto unknown; - break; - case 'V': - versionarg = *argv; - setRCSversion(versionarg); - goto option_handled; - case 'k': - expandarg = *argv; - if (0 <= str2expmode(expandarg+2)) - goto option_handled; - /* fall into */ - default: - unknown: - error("unknown option: %s%s", *argv, cmdusage); - }; - option_handled: - if (dcp != *argv+1) { - *dcp = 0; - *diffp++ = *argv; - } - } /* end of option processing */ - - for (pp = diffv+2, c = 0; ppnum; - - if (!fexpandsym(rev1, &numericrev, workptr)) continue; - if (!(target=genrevs(numericrev.string,(char *)0,(char *)0,(char *)0,&gendeltas))) continue; - xrev1=target->num; -#if DIFF_L - if (diff_label1) - *diff_label1 = setup_label(&labelbuf[0], target->num, target->date); -#endif - - lexpandarg = expandarg; - if (revnums==2) { - if (!fexpandsym( - *rev2 ? rev2 : Dbranch ? Dbranch : Head->num, - &numericrev, - workptr - )) - continue; - if (!(target=genrevs(numericrev.string,(char *)0,(char *)0,(char *)0,&gendeltas))) continue; - xrev2=target->num; - if (no_diff_means_no_output && xrev1 == xrev2) - continue; - } else if ( - target->lockedby - && !lexpandarg - && Expand == KEYVAL_EXPAND - && WORKMODE(RCSstat.st_mode,true) == workstat.st_mode - ) - lexpandarg = "-kkvl"; - Izclose(&workptr); -#if DIFF_L - if (diff_label2) - if (revnums == 2) - *diff_label2 = setup_label(&labelbuf[1], target->num, target->date); - else { - time2date(workstat.st_mtime, date2); - *diff_label2 = setup_label(&labelbuf[1], (char*)0, date2); - } -#endif - - diagnose("retrieving revision %s\n", xrev1); - bufscpy(&commarg, "-p"); - bufscat(&commarg, rev1); /* not xrev1, for $Name's sake */ - - pp = &cov[3 + !DIFF_L]; - *pp++ = commarg.string; - if (lexpandarg) *pp++ = lexpandarg; - if (suffixarg) *pp++ = suffixarg; - if (versionarg) *pp++ = versionarg; - if (zonearg) *pp++ = zonearg; - *pp++ = RCSname; - *pp = 0; - - diffp = diffpend; -# if OPEN_O_BINARY - if (Expand == BINARY_EXPAND) - *diffp++ = "--binary"; -# endif - diffp[0] = maketemp(0); - if (runv(-1, diffp[0], cov)) { - rcserror("co failed"); - continue; - } - if (!rev2) { - diffp[1] = workname; - if (*workname == '-') { - char *dp = ftnalloc(char, strlen(workname)+3); - diffp[1] = dp; - *dp++ = '.'; - *dp++ = SLASH; - VOID strcpy(dp, workname); - } - } else { - diagnose("retrieving revision %s\n",xrev2); - bufscpy(&commarg, "-p"); - bufscat(&commarg, rev2); /* not xrev2, for $Name's sake */ - cov[3 + !DIFF_L] = commarg.string; - diffp[1] = maketemp(1); - if (runv(-1, diffp[1], cov)) { - rcserror("co failed"); - continue; - } - } - if (!rev2) - diagnose("diff%s -r%s %s\n", diffvstr, xrev1, workname); - else - diagnose("diff%s -r%s -r%s\n", diffvstr, xrev1, xrev2); - - diffp[2] = 0; - switch (runv(-1, (char*)0, diffv)) { - case DIFF_SUCCESS: - break; - case DIFF_FAILURE: - if (exitstatus == DIFF_SUCCESS) - exitstatus = DIFF_FAILURE; - break; - default: - workerror("diff failed"); - } - } - - tempunlink(); - exitmain(exitstatus); -} - - static void -cleanup() -{ - if (nerror) exitstatus = DIFF_TROUBLE; - Izclose(&finptr); - Izclose(&workptr); -} - -#if RCS_lint -# define exiterr rdiffExit -#endif - void -exiterr() -{ - tempunlink(); - _exit(DIFF_TROUBLE); -} - -#if DIFF_L - static char const * -setup_label(b, num, date) - struct buf *b; - char const *num; - char const date[datesize]; -{ - char *p; - char datestr[datesize + zonelenmax]; - VOID date2str(date, datestr); - bufalloc(b, - strlen(workname) - + sizeof datestr + 4 - + (num ? strlen(num) : 0) - ); - p = b->string; - if (num) - VOID sprintf(p, "-L%s\t%s\t%s", workname, datestr, num); - else - VOID sprintf(p, "-L%s\t%s", workname, datestr); - return p; -} -#endif diff --git a/gnu/usr.bin/rcs/rcsfreeze/Makefile b/gnu/usr.bin/rcs/rcsfreeze/Makefile deleted file mode 100644 index 03522ccc9f3..00000000000 --- a/gnu/usr.bin/rcs/rcsfreeze/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsfreeze/Makefile 136679 2004-10-18 21:44:17Z ru $ - -SCRIPTS= rcsfreeze.sh -MAN= rcsfreeze.1 - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/rcsfreeze/Makefile.depend b/gnu/usr.bin/rcs/rcsfreeze/Makefile.depend deleted file mode 100644 index c49ecb82762..00000000000 --- a/gnu/usr.bin/rcs/rcsfreeze/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsfreeze/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1 b/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1 deleted file mode 100644 index c1c1c52f485..00000000000 --- a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1 +++ /dev/null @@ -1,68 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \s-1RCS\s0 -.TH RCSFREEZE 1 \*(Dt GNU -.SH NAME -rcsfreeze \- freeze a configuration of sources checked in under RCS -.SH SYNOPSIS -.B rcsfreeze -.RI [ "name" ] -.SH DESCRIPTION -.B rcsfreeze -assigns a symbolic revision -number to a set of \*r files that form a valid configuration. -.PP -The idea is to run -.B rcsfreeze -each time a new version is checked -in. A unique symbolic name (\c -.BI C_ number, -where -.I number -is increased each time -.B rcsfreeze -is run) is then assigned to the most -recent revision of each \*r file of the main trunk. -.PP -An optional -.I name -argument to -.B rcsfreeze -gives a symbolic name to the configuration. -The unique identifier is still generated -and is listed in the log file but it will not appear as -part of the symbolic revision name in the actual \*r files. -.PP -A log message is requested from the user for future reference. -.PP -The shell script works only on all \*r files at one time. -All changed files must be checked in already. -Run -.IR rcsclean (1) -first and see whether any sources remain in the current directory. -.SH FILES -.TP -.B RCS/.rcsfreeze.ver -version number -.TP -.B RCS/.rcsfreeze.log -log messages, most recent first -.SH AUTHOR -Stephan v. Bechtolsheim -.SH "SEE ALSO" -co(1), rcs(1), rcsclean(1), rlog(1) -.SH BUGS -.B rcsfreeze -does not check whether any sources are checked out and modified. -.PP -Although both source file names and RCS file names are accepted, -they are not paired as usual with RCS commands. -.PP -Error checking is rudimentary. -.PP -.B rcsfreeze -is just an optional example shell script, and should not be taken too seriously. -See \s-1CVS\s0 for a more complete solution. diff --git a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh b/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh deleted file mode 100644 index 36a8814b0a7..00000000000 --- a/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh +++ /dev/null @@ -1,99 +0,0 @@ -#! /bin/sh - -# rcsfreeze - assign a symbolic revision number to a configuration of RCS files - -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh 73349 2001-03-02 16:52:14Z ru $ - -# The idea is to run rcsfreeze each time a new version is checked -# in. A unique symbolic revision number (C_[number], where number -# is increased each time rcsfreeze is run) is then assigned to the most -# recent revision of each RCS file of the main trunk. -# -# If the command is invoked with an argument, then this -# argument is used as the symbolic name to freeze a configuration. -# The unique identifier is still generated -# and is listed in the log file but it will not appear as -# part of the symbolic revision name in the actual RCS file. -# -# A log message is requested from the user which is saved for future -# references. -# -# The shell script works only on all RCS files at one time. -# It is important that all changed files are checked in (there are -# no precautions against any error in this respect). -# file names: -# {RCS/}.rcsfreeze.ver version number -# {RCS/}.rscfreeze.log log messages, most recent first - -PATH=/bin:/usr/bin:$PATH -export PATH - -DATE=`LC_ALL=C date` || exit -# Check whether we have an RCS subdirectory, so we can have the right -# prefix for our paths. -if test -d RCS -then RCSDIR=RCS/ EXT= -else RCSDIR= EXT=,v -fi - -# Version number stuff, log message file -VERSIONFILE=${RCSDIR}.rcsfreeze.ver -LOGFILE=${RCSDIR}.rcsfreeze.log -# Initialize, rcsfreeze never run before in the current directory -test -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit - -# Get Version number, increase it, write back to file. -VERSIONNUMBER=`cat $VERSIONFILE` && -VERSIONNUMBER=`expr $VERSIONNUMBER + 1` && -echo $VERSIONNUMBER >$VERSIONFILE || exit - -# Symbolic Revision Number -SYMREV=C_$VERSIONNUMBER -# Allow the user to give a meaningful symbolic name to the revision. -SYMREVNAME=${1-$SYMREV} -echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\" -rcsfreeze: symbolic revision number used: \"${SYMREVNAME}\" -rcsfreeze: the two differ only when rcsfreeze invoked with argument -rcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \ - || exit - -# Stamp the logfile. Because we order the logfile the most recent -# first we will have to save everything right now in a temporary file. -TMPLOG=/tmp/rcsfrz$$ -trap 'rm -f $TMPLOG; exit 1' 1 2 13 15 -# Now ask for a log message, continously add to the log file -( - echo "Version: $SYMREVNAME($SYMREV), Date: $DATE ------------" || exit - while read MESS - do - case $MESS in - .) break - esac - echo " $MESS" || exit - done - echo "----------- -" && - cat $LOGFILE -) >$TMPLOG && - -# combine old and new logfiles -cp $TMPLOG $LOGFILE && -rm -f $TMPLOG && - -# Now the real work begins by assigning a symbolic revision number -# to each rcs file. Take the most recent version on the default branch. - -# If there are any .*,v files, throw them in too. -# But ignore RCS/.* files that do not end in ,v. -DOTFILES= -for DOTFILE in ${RCSDIR}.*,v -do - if test -f "$DOTFILE" - then - DOTFILES="${RCSDIR}.*,v" - break - fi -done - -exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES diff --git a/gnu/usr.bin/rcs/rcsmerge/Makefile b/gnu/usr.bin/rcs/rcsmerge/Makefile deleted file mode 100644 index 9fd8afaab02..00000000000 --- a/gnu/usr.bin/rcs/rcsmerge/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -PROG= rcsmerge -SRCS= rcsmerge.c -CFLAGS+= -I${.CURDIR}/../lib -LDADD= ${LIBRCS} -DPADD= ${LIBRCS} - -.include "../../Makefile.inc" -.include diff --git a/gnu/usr.bin/rcs/rcsmerge/Makefile.depend b/gnu/usr.bin/rcs/rcsmerge/Makefile.depend deleted file mode 100644 index d6eb563cf54..00000000000 --- a/gnu/usr.bin/rcs/rcsmerge/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsmerge/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1 b/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1 deleted file mode 100644 index 374eb4e0562..00000000000 --- a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1 +++ /dev/null @@ -1,189 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rcsmerge/rcsmerge.1 50472 1999-08-27 23:37:10Z peter $ -.ds r \&\s-1RCS\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH RCSMERGE 1 \*(Dt GNU -.SH NAME -rcsmerge \- merge RCS revisions -.SH SYNOPSIS -.B rcsmerge -.RI [ options ] " file" -.SH DESCRIPTION -.B rcsmerge -incorporates the changes between two revisions -of an \*r file into the corresponding working file. -.PP -Pathnames matching an \*r suffix denote \*r files; -all others denote working files. -Names are paired as explained in -.BR ci (1). -.PP -At least one revision must be specified with one of the options -described below, usually -.BR \-r . -At most two revisions may be specified. -If only one revision is specified, the latest -revision on the default branch (normally the highest branch on the trunk) -is assumed for the second revision. -Revisions may be specified numerically or symbolically. -.PP -.B rcsmerge -prints a warning if there are overlaps, and delimits -the overlapping regions as explained in -.BR merge (1). -The command is useful for incorporating changes into a checked-out revision. -.SH OPTIONS -.TP -.B \-A -Output conflicts using the -.B \-A -style of -.BR diff3 (1), -if supported by -.BR diff3 . -This merges all changes leading from -.I file2 -to -.I file3 -into -.IR file1 , -and generates the most verbose output. -.TP -\f3\-E\fP, \f3\-e\fP -These options specify conflict styles that generate less information -than -.BR \-A . -See -.BR diff3 (1) -for details. -The default is -.BR \-E . -With -.BR \-e , -.B rcsmerge -does not warn about conflicts. -.TP -.BI \-k subst -Use -.I subst -style keyword substitution. -See -.BR co (1) -for details. -For example, -.B "\-kk\ \-r1.1\ \-r1.2" -ignores differences in keyword values when merging the changes from -.B 1.1 -to -.BR 1.2 . -It normally does not make sense to merge binary files as if they were text, so -.B rcsmerge -refuses to merge files if -.B \-kb -expansion is used. -.TP -.BR \-p [\f2rev\fP] -Send the result to standard output instead of overwriting the working file. -.TP -.BR \-q [\f2rev\fP] -Run quietly; do not print diagnostics. -.TP -.BR \-r [\f2rev\fP] -Merge with respect to revision -.IR rev . -Here an empty -.I rev -stands for the latest revision on the default branch, normally the head. -.TP -.B \-T -This option has no effect; -it is present for compatibility with other \*r commands. -.TP -.BI \-V -Print \*r's version number. -.TP -.BI \-V n -Emulate \*r version -.IR n . -See -.BR co (1) -for details. -.TP -.BI \-x "suffixes" -Use -.I suffixes -to characterize \*r files. -See -.BR ci (1) -for details. -.TP -.BI \-z zone -Use -.I zone -as the time zone for keyword substitution. -See -.BR co (1) -for details. -.SH EXAMPLES -Suppose you have released revision 2.8 of -.BR f.c . -Assume -furthermore that after you complete an unreleased revision 3.4, you receive -updates to release 2.8 from someone else. -To combine the updates to 2.8 and your changes between 2.8 and 3.4, -put the updates to 2.8 into file f.c and execute -.LP -.B " rcsmerge \-p \-r2.8 \-r3.4 f.c >f.merged.c" -.PP -Then examine -.BR f.merged.c . -Alternatively, if you want to save the updates to 2.8 in the \*r file, -check them in as revision 2.8.1.1 and execute -.BR "co \-j": -.LP -.B " ci \-r2.8.1.1 f.c" -.br -.B " co \-r3.4 \-j2.8:2.8.1.1 f.c" -.PP -As another example, the following command undoes the changes -between revision 2.4 and 2.8 in your currently checked out revision -in -.BR f.c . -.LP -.B " rcsmerge \-r2.8 \-r2.4 f.c" -.PP -Note the order of the arguments, and that -.B f.c -will be -overwritten. -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -See -.BR ci (1) -for details. -.SH DIAGNOSTICS -Exit status is 0 for no overlaps, 1 for some overlaps, 2 for trouble. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH "SEE ALSO" -ci(1), co(1), ident(1), merge(1), rcs(1), rcsdiff(1), rcsintro(1), rlog(1), -rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.br diff --git a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c b/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c deleted file mode 100644 index b5da345657e..00000000000 --- a/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c +++ /dev/null @@ -1,286 +0,0 @@ -/* Merge RCS revisions. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.15 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.14 1995/06/01 16:23:43 eggert - * (main): Report an error if -kb, so don't worry about binary stdout. - * Punctuate messages properly. Rewrite to avoid `goto end'. - * - * Revision 5.13 1994/03/17 14:05:48 eggert - * Specify subprocess input via file descriptor, not file name. Remove lint. - * - * Revision 5.12 1993/11/09 17:40:15 eggert - * -V now prints version on stdout and exits. Don't print usage twice. - * - * Revision 5.11 1993/11/03 17:42:27 eggert - * Add -A, -E, -e, -z. Ignore -T. Allow up to three file labels. - * Pass -Vn to `co'. Pass unexpanded revision name to `co', so that Name works. - * - * Revision 5.10 1992/07/28 16:12:44 eggert - * Add -V. - * - * Revision 5.9 1992/01/24 18:44:19 eggert - * lint -> RCS_lint - * - * Revision 5.8 1992/01/06 02:42:34 eggert - * Update usage string. - * - * Revision 5.7 1991/11/20 17:58:09 eggert - * Don't Iopen(f, "r+"); it's not portable. - * - * Revision 5.6 1991/08/19 03:13:55 eggert - * Add -r$. Tune. - * - * Revision 5.5 1991/04/21 11:58:27 eggert - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.4 1991/02/25 07:12:43 eggert - * Merging a revision to itself is no longer an error. - * - * Revision 5.3 1990/11/01 05:03:50 eggert - * Remove unneeded setid check. - * - * Revision 5.2 1990/09/04 08:02:28 eggert - * Check for I/O error when reading working file. - * - * Revision 5.1 1990/08/29 07:14:04 eggert - * Add -q. Pass -L options to merge. - * - * Revision 5.0 1990/08/22 08:13:41 eggert - * Propagate merge's exit status. - * Remove compile-time limits; use malloc instead. - * Make lock and temp files faster and safer. Ansify and Posixate. Add -V. - * Don't use access(). Tune. - * - * Revision 4.5 89/05/01 15:13:16 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 88/08/09 19:13:13 eggert - * Beware merging into a readonly file. - * Beware merging a revision to itself (no change). - * Use execv(), not system(); yield exit status like diff(1)'s. - * - * Revision 4.3 87/10/18 10:38:02 narten - * Updating version numbers. Changes relative to version 1.1 - * actually relative to 4.1 - * - * Revision 1.3 87/09/24 14:00:31 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:36 jenkins - * Port to suns - * - * Revision 4.1 83/03/28 11:14:57 wft - * Added handling of default branch. - * - * Revision 3.3 82/12/24 15:29:00 wft - * Added call to catchsig(). - * - * Revision 3.2 82/12/10 21:32:02 wft - * Replaced getdelta() with gettree(); improved error messages. - * - * Revision 3.1 82/11/28 19:27:44 wft - * Initial revision. - * - */ -#include "rcsbase.h" - -static char const co[] = CO; - -mainProg(rcsmergeId, "rcsmerge", "$FreeBSD: stable/11/gnu/usr.bin/rcs/rcsmerge/rcsmerge.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const cmdusage[] = - "\nrcsmerge usage: rcsmerge -rrev1 [-rrev2] -ksubst -{pq}[rev] -Vn -xsuff -zzone file"; - static char const quietarg[] = "-q"; - - register int i; - char *a, **newargv; - char const *arg[3]; - char const *rev[3], *xrev[3]; /*revision numbers*/ - char const *edarg, *expandarg, *suffixarg, *versionarg, *zonearg; - int tostdout; - int status; - RILE *workptr; - struct buf commarg; - struct buf numericrev; /* holds expanded revision number */ - struct hshentries *gendeltas; /* deltas to be generated */ - struct hshentry * target; - - bufautobegin(&commarg); - bufautobegin(&numericrev); - edarg = rev[1] = rev[2] = 0; - status = 0; /* Keep lint happy. */ - tostdout = false; - expandarg = suffixarg = versionarg = zonearg = quietarg; /* no-op */ - suffixes = X_DEFAULT; - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - while (a = *++argv, 0<--argc && *a++=='-') { - switch (*a++) { - case 'p': - tostdout=true; - goto revno; - - case 'q': - quietflag = true; - revno: - if (!*a) - break; - /* falls into -r */ - case 'r': - if (!rev[1]) - rev[1] = a; - else if (!rev[2]) - rev[2] = a; - else - error("too many revision numbers"); - break; - - case 'A': case 'E': case 'e': - if (*a) - goto unknown; - edarg = *argv; - break; - - case 'x': - suffixarg = *argv; - suffixes = a; - break; - case 'z': - zonearg = *argv; - zone_set(a); - break; - case 'T': - /* Ignore -T, so that RCSINIT can contain -T. */ - if (*a) - goto unknown; - break; - case 'V': - versionarg = *argv; - setRCSversion(versionarg); - break; - - case 'k': - expandarg = *argv; - if (0 <= str2expmode(expandarg+2)) - break; - /* fall into */ - default: - unknown: - error("unknown option: %s%s", *argv, cmdusage); - }; - } /* end of option processing */ - - if (!rev[1]) faterror("no base revision number given"); - - /* Now handle all pathnames. */ - - if (!nerror) { - if (argc < 1) - faterror("no input file%s", cmdusage); - if (0 < pairnames(argc, argv, rcsreadopen, true, false)) { - - if (argc>2 || (argc==2 && argv[1])) - warn("excess arguments ignored"); - if (Expand == BINARY_EXPAND) - workerror("merging binary files"); - diagnose("RCS file: %s\n", RCSname); - if (!(workptr = Iopen(workname, FOPEN_R_WORK, (struct stat*)0))) - efaterror(workname); - - gettree(); /* reads in the delta tree */ - - if (!Head) rcsfaterror("no revisions present"); - - if (!*rev[1]) - rev[1] = Dbranch ? Dbranch : Head->num; - if (fexpandsym(rev[1], &numericrev, workptr) - && (target=genrevs(numericrev.string, (char *)0, (char *)0, (char*)0, &gendeltas)) - ) { - xrev[1] = target->num; - if (!rev[2] || !*rev[2]) - rev[2] = Dbranch ? Dbranch : Head->num; - if (fexpandsym(rev[2], &numericrev, workptr) - && (target=genrevs(numericrev.string, (char *)0, (char *)0, (char *)0, &gendeltas)) - ) { - xrev[2] = target->num; - - if (strcmp(xrev[1],xrev[2]) == 0) { - if (tostdout) { - fastcopy(workptr, stdout); - Ofclose(stdout); - } - } else { - Izclose(&workptr); - - for (i=1; i<=2; i++) { - diagnose("retrieving revision %s\n", xrev[i]); - bufscpy(&commarg, "-p"); - bufscat(&commarg, rev[i]); /* not xrev[i], for $Name's sake */ - if (run( - -1, - /* Do not collide with merger.c maketemp(). */ - arg[i] = maketemp(i+2), - co, quietarg, commarg.string, - expandarg, suffixarg, versionarg, zonearg, - RCSname, (char*)0 - )) - rcsfaterror("co failed"); - } - diagnose("Merging differences between %s and %s into %s%s\n", - xrev[1], xrev[2], workname, - tostdout?"; result to stdout":""); - - arg[0] = xrev[0] = workname; - status = merge(tostdout, edarg, xrev, arg); - } - } - } - - Izclose(&workptr); - } - } - tempunlink(); - exitmain(nerror ? DIFF_TROUBLE : status); -} - -#if RCS_lint -# define exiterr rmergeExit -#endif - void -exiterr() -{ - tempunlink(); - _exit(DIFF_TROUBLE); -} diff --git a/gnu/usr.bin/rcs/rcstest b/gnu/usr.bin/rcs/rcstest deleted file mode 100755 index 65db1429ac4..00000000000 --- a/gnu/usr.bin/rcs/rcstest +++ /dev/null @@ -1,454 +0,0 @@ -#! /bin/sh - -# Test RCS's functions. -# The RCS commands are searched for in the PATH as usual; -# to test the working directory's commands, prepend . to your PATH. - -# Test RCS by creating files RCS/a.* and RCS/a.c. -# If all goes well, output nothing, and remove the temporary files. -# Otherwise, send a message to standard output. -# Exit status is 0 if OK, 1 if an RCS bug is found, and 2 if scaffolding fails. -# With the -v option, output more debugging info. - -# If diff outputs `No differences encountered' when comparing identical files, -# then rcstest may also output these noise lines; ignore them. - -# The current directory and ./RCS must be readable, writable, and searchable. - -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rcstest 50472 1999-08-27 23:37:10Z peter $ - - -# Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert -# Distributed under license by the Free Software Foundation, Inc. -# -# This file is part of RCS. -# -# RCS 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 2, or (at your option) -# any later version. -# -# RCS 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 RCS; see the file COPYING. -# If not, write to the Free Software Foundation, -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Report problems and direct all questions to: -# -# rcs-bugs@cs.purdue.edu - -# The Makefile overrides the following defaults. -: ${ALL_CFLAGS=-Dhas_conf_h} -: ${CC=cc} -: ${DIFF=diff} -# : ${LDFLAGS=} ${LIBS=} tickles old shell bug - -CL="$CC $ALL_CFLAGS $LDFLAGS -o a.out" -L=$LIBS - -RCSINIT=-x -export RCSINIT - -SLASH=/ -RCSfile=RCS${SLASH}a.c -RCS_alt=RCS${SLASH}a.d -lockfile=RCS${SLASH}a._ - -case $1 in --v) q=; set -x;; -'') q=-q;; -*) echo >&2 "$0: usage: $0 [-v]"; exit 2 -esac - -if test -d RCS -then rmdir=: -else rmdir=rmdir; mkdir RCS || exit -fi - -rm -f a.* $RCSfile $RCS_alt $lockfile && -echo 1.1 >a.11 && -echo 1.1.1.1 >a.3x1 && -echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; } - -case "`$DIFF -c a.11 a.3x1`" in -*!\ 1.1.1.1) - diff="$DIFF -c";; -*) - echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic" - diff=$DIFF -esac - -rcs -i -L -ta.11 $q a.c && -test -r $RCSfile || { - echo "#rcs -i -L failed; perhaps RCS is not properly installed." - exit 1 -} - -rlog a.c >/dev/null || { echo "#rlog failed on empty RCS file"; exit 1; } -rm -f $RCSfile || exit 2 - -cp a.11 a.c && -ci -ta.11 -mm $q a.c && -test -r $RCSfile && -rcs -L $q a.c || { echo "#ci+rcs -L failed"; exit 1; } -test ! -f a.c || { echo "#ci did not remove working file"; exit 1; } -for l in '' '-l' -do - co $l $q a.c && - test -f a.c || { echo '#co' $l did not create working file; exit 1; } - $diff a.11 a.c || { echo '#ci' followed by co $l is not a no-op; exit 1; } -done - -cp a.12 a.c && -ci -mm $q a.c && -co $q a.c && -$diff a.12 a.c || { echo "#ci+co failed"; exit 1; } - -rm -f a.c && -co -r1.1 $q a.c && -$diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; } - -rm -f a.c && -cp a.3x1 a.c && -ci -r1.1.1 -mm $q a.c && -co -r1.1.1.1 $q a.c && -$diff a.3x1 a.c || { echo "#branches failed"; exit 1; } - -rm -f a.c && -co -l $q a.c && -ci -f -mm $q a.c && -co -r1.3 $q a.c && -$diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; } - -rm -f a.c && -co -l $q a.c && -echo 1.4 >a.c && -ci -l -mm $q a.c && -echo error >a.c && -ci -mm $q a.c || { echo "#ci -l failed"; exit 1; } - -rm -f a.c && -co -l $q a.c && -echo 1.5 >a.c && -ci -u -mm $q a.c && -test -r a.c || { echo "#ci -u didn't create a working file"; exit 1; } -rm -f a.c && -echo error >a.c || exit 2 -ci -mm $q a.c 2>/dev/null && { echo "#ci -u didn't unlock the file"; exit 1; } - -rm -f a.c && -rcs -l $q a.c && -co -u $q a.c || { echo "#rcs -l + co -u failed"; exit 1; } -rm -f a.c && -echo error >a.c || exit 2 -ci -mm $q a.c 2>/dev/null && { echo "#co -u didn't unlock the file"; exit 1; } - -rm -f a.c && -cp a.11 a.c && -co -f $q a.c || { echo "#co -f failed"; exit 1; } -$diff a.11 a.c >/dev/null && { echo "#co -f had no effect"; exit 1; } - -co -p1.1 $q a.c >a.t && -$diff a.11 a.t || { echo "#co -p failed"; exit 1; } - -for n in n N -do - rm -f a.c && - co -l $q a.c && - echo $n >a.$n && - cp a.$n a.c && - ci -${n}n -mm $q a.c && - co -rn $q a.c && - $diff a.$n a.c || { echo "#ci -$n failed"; exit 1; } -done - -case $LOGNAME in -?*) me=$LOGNAME;; -*) - case $USER in - ?*) me=$USER;; - *) - me=`who am i` || exit 2 - me=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'` - case $me in - '') echo >&2 "$0: cannot deduce user name"; exit 2 - esac - esac -esac - - -# Get the date of the previous revision in UTC. -date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` || exit -case $date in -[0-9][0-9][0-9]*[0-9]/[0-1][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-6][0-9]);; -*) echo >&2 "$0: $date: bad rlog date output"; exit 1 -esac -PWD=`pwd` && export PWD && -rm -f a.c && -co -l $q a.c && -sed 's/@/$/g' >a.kv <a.k && -sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl && -sed s/Oz//g a.kv >a.e && -sed s/Oz/N/g a.kv >a.N && -sed -e '/\$/!d' -e 's/\$$/: old $/' a.k >a.o && -sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v && -cp a.o a.c && -ci -d"$date" -nOz -ss -ww -u2.1 -mm $q a.c && -$diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; } -co -pOz -ko $q a.c >a.oo && -$diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; } -cp a.kv a.o && cp a.o a.b || exit 2 -rcs -oOz $q a.c && -rcs -l $q a.c && -ci -k -u $q a.c && -$diff a.kv a.c || { echo "#ci -k failed"; exit 1; } -sed -n 's/^[^$]*\$/$/p' a.kv >a.i && -ident a.c >a.i1 && -sed -e 1d -e 's/^[ ]*//' a.i1 >a.i2 && -$diff a.i a.i2 || { echo "#ident failed"; exit 1; } - -rcs -i $q a.c 2>/dev/null && { echo "#rcs -i permitted existing file"; exit 1; } - -rm -f a.c && -co -l $q a.c && -echo 2.2 >a.c && -ci -mm $q a.c && -echo 1.1.1.2 >a.c && -rcs -l1.1.1 $q a.c && -ci -r1.1.1.2 -mm $q a.c && -rcs -b1.1.1 $q a.c && -test " `co -p $q a.c`" = ' 1.1.1.2' || { echo "#rcs -b1.1.1 failed"; exit 1; } -rcs -b $q a.c && -test " `co -p $q a.c`" = ' 2.2' || { echo "#rcs -b failed"; exit 1; } - -echo 2.3 >a.c || exit 2 -rcs -U $q a.c || { echo "#rcs -U failed"; exit 1; } -ci -mm $q a.c || { echo "#rcs -U didn't unset strict locking"; exit 1; } -rcs -L $q a.c || { echo "#rcs -L failed"; exit 1; } -echo error >a.c || exit 2 -ci -mm $q a.c 2>/dev/null && { echo "#ci retest failed"; exit 1; } - -rm -f a.c && -log0=`rlog -h a.c` && -co -l $q a.c && -ci -mm $q a.c && -log1=`rlog -h a.c` && -test " $log0" = " $log1" || { echo "#unchanged ci didn't revert"; exit 1; } - -rm -f a.c && -rcs -nN:1.1 $q a.c && -co -rN $q a.c && -$diff a.11 a.c || { echo "#rcs -n failed"; exit 1; } - -rm -f a.c && -rcs -NN:2.1 $q a.c && -co -rN $q a.c && -$diff a.N a.c || { echo "#rcs -N failed"; exit 1; } - -rm -f a.c && -co -l $q a.c && -echo ':::$''Log$' >a.c && -ci -u -mm $q a.c && -test " `sed '$!d' a.c`" = ' :::' || { echo "#comment leader failed"; exit 1; } - -rm -f a.c && -rcs -o2.2: $q a.c && -co $q a.c && -$diff a.e a.c || { echo "#rcs -o failed"; exit 1; } - -rcsdiff -r1.1 -rOz $q a.c >a.0 -case $? in -1) ;; -*) echo "#rcsdiff bad status"; exit 1 -esac -$DIFF a.11 a.kv >a.1 -$diff a.0 a.1 || { echo "#rcsdiff failed"; exit 1; } - -rcs -l2.1 $q a.c || { echo "#rcs -l2.1 failed"; exit 1; } -for i in b k kv kvl o v -do - rm -f a.c && - cp a.$i a.c && - rcsdiff -k$i -rOz $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; } -done -co -p1.1 -ko $q a.c >a.t && -$diff a.11 a.t || { echo "#co -p1.1 -ko failed"; exit 1; } -rcs -u2.1 $q a.c || { echo "#rcs -u2.1 failed"; exit 1; } - -rm -f a.c && -rcsclean $q a.c && -rcsclean -u $q a.c || { echo "#rcsclean botched a nonexistent file"; exit 1; } - -rm -f a.c && -co $q a.c && -rcsclean -n $q a.c && -rcsclean -n -u $q a.c && -test -f a.c || { echo "#rcsclean -n removed a file"; exit 1; } - -rm -f a.c && -co $q a.c && -rcsclean $q a.c && -test ! -f a.c || { echo "#rcsclean missed an unlocked file"; exit 1; } - -rm -f a.c && -co -l $q a.c && -rcsclean $q a.c && -test -f a.c || { echo "#rcsclean removed a locked file"; exit 1; } -rcsclean -u $q a.c && -test ! -f a.c || { - echo "#rcsclean -u missed an unchanged locked file"; exit 1; -} - -rm -f a.c && -co -l $q a.c && -echo change >>a.c && -rcsclean $q a.c && -rcsclean $q -u a.c && -test -f a.c || { echo "#rcsclean removed a changed file"; exit 1; } - -rm -f a.c && -co -l $q a.c && -cat >a.c <<'EOF' -2.2 -a -b -c -d -EOF -test $? = 0 && -ci -l -mm $q a.c && -co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c && -ci -l -mm $q a.c && -co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2 -cat >a.0 <<'EOF' -2.3 -a -b1 -c -d1 -EOF -cat >a.1 <<'EOF' -<<<<<<< a.c -new -======= -2.3 ->>>>>>> 2.3 -a -b1 -c -d1 -EOF -rcsmerge -E -r2.2 -r2.3 $q a.c -case $? in -0) - if $diff a.0 a.c >/dev/null - then echo "#warning: diff3 -E does not work, " \ - "so merge and rcsmerge ignore overlaps and suppress overlap lines." - else - $diff a.1 a.c || { echo "#rcsmerge failed (status 0)"; exit 1; } - echo "#warning: The diff3 lib program exit status ignores overlaps," \ - "so rcsmerge does not warn about overlap lines that it generates." - fi - ;; -1) - $diff a.1 a.c || { echo "#rcsmerge failed (status 1)"; exit 1; } - ;; -*) - echo "#rcsmerge bad status"; exit 1 -esac - -# Avoid `tr' if possible; it's not portable, and it can't handle null bytes. -# Our substitute exclusive-ORs with '\n'; -# this ensures null bytes on output, which is even better than `tr', -# since some diffs think a file is binary only if it contains null bytes. -cat >a.c <<'EOF' -#include -int main() { - int c; - while ((c=getchar()) != EOF) - putchar(c ^ '\n'); - return 0; -} -EOF -tr=tr -if (rm -f a.exe a.out && $CL a.c $L >&2) >/dev/null 2>&1 -then - if test -s a.out - then tr=./a.out - elif test -s a.exe - then tr=./a.exe - fi -fi -{ - co -p $q a.c | $tr '\012' '\200' >a.24 && - cp a.24 a.c && - ciOut=`(ci -l -mm $q a.c 2>&1)` && - case $ciOut in - ?*) echo >&2 "$ciOut" - esac && - co -p $q a.c | $tr '\200' '\012' >a.c && - rcsdiff -r2.3 $q a.c >/dev/null && - - echo 2.5 >a.c && - ci -l -mm $q a.c && - cp a.24 a.c && - rcsdiff -r2.4 $q a.c >/dev/null -} || echo "#warning: Traditional diff is used, so RCS is limited to text files." - -rcs -u -o2.4: $q a.c || { echo "#rcs -u -o failed"; exit 1; } - -rcs -i -Aa.c -t- $q a.d || { echo "#rcs -i -A failed"; exit 1; } - -rlog -r2.1 a.c >a.t && -grep '^checked in with -k' a.t >/dev/null && -sed '/^checked in with -k/d' a.t >a.u && -$diff - a.u < diff --git a/gnu/usr.bin/rcs/rlog/Makefile.depend b/gnu/usr.bin/rcs/rlog/Makefile.depend deleted file mode 100644 index ad4659e5502..00000000000 --- a/gnu/usr.bin/rcs/rlog/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD: stable/11/gnu/usr.bin/rcs/rlog/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - gnu/usr.bin/rcs/lib \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/gnu/usr.bin/rcs/rlog/rlog.1 b/gnu/usr.bin/rcs/rlog/rlog.1 deleted file mode 100644 index dd3b6c9aa21..00000000000 --- a/gnu/usr.bin/rcs/rlog/rlog.1 +++ /dev/null @@ -1,318 +0,0 @@ -.de Id -.ds Rv \\$3 -.ds Dt \\$4 -.. -.Id $FreeBSD: stable/11/gnu/usr.bin/rcs/rlog/rlog.1 50472 1999-08-27 23:37:10Z peter $ -.ds i \&\s-1ISO\s0 -.ds r \&\s-1RCS\s0 -.ds u \&\s-1UTC\s0 -.if n .ds - \%-- -.if t .ds - \(em -.TH RLOG 1 \*(Dt GNU -.SH NAME -rlog \- print log messages and other information about RCS files -.SH SYNOPSIS -.B rlog -.RI [ " options " ] " file " .\|.\|. -.SH DESCRIPTION -.B rlog -prints information about \*r files. -.PP -Pathnames matching an \*r suffix denote \*r files; -all others denote working files. -Names are paired as explained in -.BR ci (1). -.PP -.B rlog -prints the following information for each -\*r file: \*r pathname, working pathname, head (i.e., the number -of the latest revision on the trunk), default branch, access list, locks, -symbolic names, suffix, total number of revisions, -number of revisions selected for printing, and -descriptive text. This is followed by entries for the selected revisions in -reverse chronological order for each branch. For each revision, -.B rlog -prints revision number, author, date/time, state, number of -lines added/deleted (with respect to the previous revision), -locker of the revision (if any), and log message. -All times are displayed in Coordinated Universal Time (\*u) by default; -this can be overridden with -.BR \-z . -Without options, -.B rlog -prints complete information. -The options below restrict this output. -.nr n \w'\f3\-V\fP\f2n\fP'+2n-1/1n -.ds n \nn -.if \n(.g .if r an-tag-sep .ds n \w'\f3\-V\fP\f2n\fP'u+\n[an-tag-sep]u -.TP \*n -.B \-L -Ignore \*r files that have no locks set. -This is convenient in combination with -.BR \-h , -.BR \-l , -and -.BR \-R . -.TP -.B \-R -Print only the name of the \*r file. -This is convenient for translating a -working pathname into an \*r pathname. -.TP -.BI \-v "[string]" -Print only the working pathname and tip-revision. -The optional string is prepended to the outputline. -.TP -.B \-h -Print only the \*r pathname, working pathname, head, -default branch, access list, locks, -symbolic names, and suffix. -.TP -.B \-t -Print the same as -.BR \-h , -plus the descriptive text. -.TP -.B \-N -Do not print the symbolic names. -.TP -.B \-b -Print information about the revisions on the default branch, normally -the highest branch on the trunk. -.TP -.BI \-d "dates" -Print information about revisions with a checkin date/time in the ranges given by -the semicolon-separated list of -.IR dates . -A range of the form -.IB d1 < d2 -or -.IB d2 > d1 -selects the revisions that were deposited between -.I d1 -and -.I d2 -exclusive. -A range of the form -.BI < d -or -.IB d > -selects -all revisions earlier than -.IR d . -A range of the form -.IB d < -or -.BI > d -selects -all revisions dated later than -.IR d . -If -.B < -or -.B > -is followed by -.B = -then the ranges are inclusive, not exclusive. -A range of the form -.I d -selects the single, latest revision dated -.I d -or earlier. -The date/time strings -.IR d , -.IR d1 , -and -.I d2 -are in the free format explained in -.BR co (1). -Quoting is normally necessary, especially for -.B < -and -.BR > . -Note that the separator is -a semicolon. -.TP -.BR \-l [\f2lockers\fP] -Print information about locked revisions only. -In addition, if the comma-separated list -.I lockers -of login names is given, -ignore all locks other than those held by the -.IR lockers . -For example, -.B "rlog\ \-L\ \-R\ \-lwft\ RCS/*" -prints the name of \*r files locked by the user -.BR wft . -.TP -.BR \-r [\f2revisions\fP] -prints information about revisions given in the comma-separated list -.I revisions -of revisions and ranges. -A range -.IB rev1 : rev2 -means revisions -.I rev1 -to -.I rev2 -on the same branch, -.BI : rev -means revisions from the beginning of the branch up to and including -.IR rev , -and -.IB rev : -means revisions starting with -.I rev -to the end of the branch containing -.IR rev . -An argument that is a branch means all -revisions on that branch. -A range of branches means all revisions -on the branches in that range. -A branch followed by a -.B .\& -means the latest revision in that branch. -A bare -.B \-r -with no -.I revisions -means the latest revision on the default branch, normally the trunk. -.TP -.BI \-s states -prints information about revisions whose state attributes match one of the -states given in the comma-separated list -.IR states . -.TP -.BR \-w [\f2logins\fP] -prints information about revisions checked in by users with -login names appearing in the comma-separated list -.IR logins . -If -.I logins -is omitted, the user's login is assumed. -.TP -.B \-T -This option has no effect; -it is present for compatibility with other \*r commands. -.TP -.BI \-V -Print \*r's version number. -.TP -.BI \-V n -Emulate \*r version -.I n -when generating logs. -See -.BR co (1) -for more. -.TP -.BI \-x "suffixes" -Use -.I suffixes -to characterize \*r files. -See -.BR ci (1) -for details. -.PP -.B rlog -prints the intersection of the revisions selected with -the options -.BR \-d , -.BR \-l , -.BR \-s , -and -.BR \-w , -intersected -with the union of the revisions selected by -.B \-b -and -.BR \-r . -.TP -.BI \-z zone -specifies the date output format, -and specifies the default time zone for -.I date -in the -.BI \-d dates -option. -The -.I zone -should be empty, a numeric \*u offset, or the special string -.B LT -for local time. -The default is an empty -.IR zone , -which uses the traditional \*r format of \*u without any time zone indication -and with slashes separating the parts of the date; -otherwise, times are output in \*i 8601 format with time zone indication. -For example, if local time is January 11, 1990, 8pm Pacific Standard Time, -eight hours west of \*u, -then the time is output as follows: -.RS -.LP -.RS -.nf -.ta \w'\f3\-z+05:30\fP 'u +\w'\f31990-01-11 09:30:00+05:30\fP 'u -.ne 4 -\f2option\fP \f2time output\fP -\f3\-z\fP \f31990/01/12 04:00:00\fP \f2(default)\fP -\f3\-zLT\fP \f31990-01-11 20:00:00\-08\fP -\f3\-z+05:30\fP \f31990-01-12 09:30:00+05:30\fP -.ta 4n +4n +4n +4n -.fi -.RE -.SH EXAMPLES -.LP -.nf -.B " rlog \-L \-R RCS/*" -.B " rlog \-L \-h RCS/*" -.B " rlog \-L \-l RCS/*" -.B " rlog RCS/*" -.fi -.LP -The first command prints the names of all \*r files in the subdirectory -.B RCS -that have locks. The second command prints the headers of those files, -and the third prints the headers plus the log messages of the locked revisions. -The last command prints complete information. -.SH ENVIRONMENT -.TP -.B \s-1RCSINIT\s0 -options prepended to the argument list, separated by spaces. -See -.BR ci (1) -for details. -.SH DIAGNOSTICS -The exit status is zero if and only if all operations were successful. -.SH IDENTIFICATION -Author: Walter F. Tichy. -.br -Manual Page Revision: \*(Rv; Release Date: \*(Dt. -.br -Copyright \(co 1982, 1988, 1989 Walter F. Tichy. -.br -Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. -.SH "SEE ALSO" -ci(1), co(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), -rcsfile(5) -.br -Walter F. Tichy, -\*r\*-A System for Version Control, -.I "Software\*-Practice & Experience" -.BR 15 , -7 (July 1985), 637-654. -.SH BUGS -The separator for revision ranges in the -.B \-r -option used to be -.B \- -instead of -.BR : , -but this leads to confusion when symbolic names contain -.BR \- . -For backwards compatibility -.B "rlog \-r" -still supports the old -.B \- -separator, but it warns about this obsolete use. -.br diff --git a/gnu/usr.bin/rcs/rlog/rlog.c b/gnu/usr.bin/rcs/rlog/rlog.c deleted file mode 100644 index 5ad060e185c..00000000000 --- a/gnu/usr.bin/rcs/rlog/rlog.c +++ /dev/null @@ -1,1290 +0,0 @@ -/* Print log messages and other information about RCS files. */ - -/* Copyright 1982, 1988, 1989 Walter Tichy - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert - Distributed under license by the Free Software Foundation, Inc. - -This file is part of RCS. - -RCS 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 2, or (at your option) -any later version. - -RCS 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 RCS; see the file COPYING. -If not, write to the Free Software Foundation, -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Report problems and direct all questions to: - - rcs-bugs@cs.purdue.edu - -*/ - -/* - * Revision 5.18 1995/06/16 06:19:24 eggert - * Update FSF address. - * - * Revision 5.17 1995/06/01 16:23:43 eggert - * (struct rcslockers): Renamed from `struct lockers'. - * (getnumericrev): Return error indication instead of ignoring errors. - * (main): Check it. Don't use dateform. - * (recentdate, extdate): cmpnum -> cmpdate - * - * Revision 5.16 1994/04/13 16:30:34 eggert - * Fix bug; `rlog -lxxx' inverted the sense of -l. - * - * Revision 5.15 1994/03/17 14:05:48 eggert - * -d' RCS_lint - * - * Revision 5.10 1992/01/06 02:42:34 eggert - * Update usage string. - * while (E) ; -> while (E) continue; - * - * Revision 5.9 1991/09/17 19:07:40 eggert - * Getscript() didn't uncache partial lines. - * - * Revision 5.8 1991/08/19 03:13:55 eggert - * Revision separator is `:', not `-'. - * Check for missing and duplicate logs. Tune. - * Permit log messages that do not end in newline (including empty logs). - * - * Revision 5.7 1991/04/21 11:58:31 eggert - * Add -x, RCSINIT, MS-DOS support. - * - * Revision 5.6 1991/02/26 17:07:17 eggert - * Survive RCS files with missing logs. - * strsave -> str_save (DG/UX name clash) - * - * Revision 5.5 1990/11/01 05:03:55 eggert - * Permit arbitrary data in logs and comment leaders. - * - * Revision 5.4 1990/10/04 06:30:22 eggert - * Accumulate exit status across files. - * - * Revision 5.3 1990/09/11 02:41:16 eggert - * Plug memory leak. - * - * Revision 5.2 1990/09/04 08:02:33 eggert - * Count RCS lines better. - * - * Revision 5.0 1990/08/22 08:13:48 eggert - * Remove compile-time limits; use malloc instead. Add setuid support. - * Switch to GMT. - * Report dates in long form, to warn about dates past 1999/12/31. - * Change "added/del" message to make room for the longer dates. - * Don't generate trailing white space. Add -V. Ansify and Posixate. - * - * Revision 4.7 89/05/01 15:13:48 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.6 88/08/09 19:13:28 eggert - * Check for memory exhaustion; don't access freed storage. - * Shrink stdio code size; remove lint. - * - * Revision 4.5 87/12/18 11:46:38 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.4 87/10/18 10:41:12 narten - * Updating version numbers - * Changes relative to 1.1 actually relative to 4.2 - * - * Revision 1.3 87/09/24 14:01:10 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:45 jenkins - * Port to suns - * - * Revision 4.2 83/12/05 09:18:09 wft - * changed rewriteflag to external. - * - * Revision 4.1 83/05/11 16:16:55 wft - * Added -b, updated getnumericrev() accordingly. - * Replaced getpwuid() with getcaller(). - * - * Revision 3.7 83/05/11 14:24:13 wft - * Added options -L and -R; - * Fixed selection bug with -l on multiple files. - * Fixed error on dates of the form -d'>date' (rewrote getdatepair()). - * - * Revision 3.6 82/12/24 15:57:53 wft - * shortened output format. - * - * Revision 3.5 82/12/08 21:45:26 wft - * removed call to checkaccesslist(); used DATEFORM to format all dates; - * removed unused variables. - * - * Revision 3.4 82/12/04 13:26:25 wft - * Replaced getdelta() with gettree(); removed updating of field lockedby. - * - * Revision 3.3 82/12/03 14:08:20 wft - * Replaced getlogin with getpwuid(), %02d with %.2d, fancydate with PRINTDATE. - * Fixed printing of nil, removed printing of Suffix, - * added shortcut if no revisions are printed, disambiguated struct members. - * - * Revision 3.2 82/10/18 21:09:06 wft - * call to curdir replaced with getfullRCSname(), - * fixed call to getlogin(), cosmetic changes on output, - * changed conflicting long identifiers. - * - * Revision 3.1 82/10/13 16:07:56 wft - * fixed type of variables receiving from getc() (char -> int). - */ - - - -#include "rcsbase.h" - -struct rcslockers { /* lockers in locker option; stored */ - char const * login; /* lockerlist */ - struct rcslockers * lockerlink; - } ; - -struct stateattri { /* states in state option; stored in */ - char const * status; /* statelist */ - struct stateattri * nextstate; - } ; - -struct authors { /* login names in author option; */ - char const * login; /* stored in authorlist */ - struct authors * nextauthor; - } ; - -struct Revpairs{ /* revision or branch range in -r */ - int numfld; /* option; stored in revlist */ - char const * strtrev; - char const * endrev; - struct Revpairs * rnext; - } ; - -struct Datepairs{ /* date range in -d option; stored in */ - struct Datepairs *dnext; - char strtdate[datesize]; /* duelst and datelist */ - char enddate[datesize]; - char ne_date; /* datelist only; distinguishes < from <= */ - }; - -static char extractdelta P((struct hshentry const*)); -static int checkrevpair P((char const*,char const*)); -static int extdate P((struct hshentry*)); -static int getnumericrev P((void)); -static struct hshentry const *readdeltalog P((void)); -static void cleanup P((void)); -static void exttree P((struct hshentry*)); -static void getauthor P((char*)); -static void getdatepair P((char*)); -static void getlocker P((char*)); -static void getrevpairs P((char*)); -static void getscript P((struct hshentry*)); -static void getstate P((char*)); -static void putabranch P((struct hshentry const*)); -static void putadelta P((struct hshentry const*,struct hshentry const*,int)); -static void putforest P((struct branchhead const*)); -static void putree P((struct hshentry const*)); -static void putrunk P((void)); -static void recentdate P((struct hshentry const*,struct Datepairs*)); -static void trunclocks P((void)); - -static char const *insDelFormat; -static int branchflag; /*set on -b */ -static int exitstatus; -static int lockflag; -static struct Datepairs *datelist, *duelst; -static struct Revpairs *revlist, *Revlst; -static struct authors *authorlist; -static struct rcslockers *lockerlist; -static struct stateattri *statelist; - - -mainProg(rlogId, "rlog", "$FreeBSD: stable/11/gnu/usr.bin/rcs/rlog/rlog.c 50472 1999-08-27 23:37:10Z peter $") -{ - static char const cmdusage[] = - "\nrlog usage: rlog -{bhLNRt} -v[string] -ddates -l[lockers] -r[revs] -sstates -Vn -w[logins] -xsuff -zzone file ..."; - - register FILE *out; - char *a, **newargv; - struct Datepairs *currdate; - char const *accessListString, *accessFormat; - char const *headFormat, *symbolFormat; - struct access const *curaccess; - struct assoc const *curassoc; - struct hshentry const *delta; - struct rcslock const *currlock; - int descflag, selectflag; - int onlylockflag; /* print only files with locks */ - int onlyRCSflag; /* print only RCS pathname */ - int pre5; - int shownames; - int revno; - int versionlist; - char *vstring; - - descflag = selectflag = shownames = true; - versionlist = onlylockflag = onlyRCSflag = false; - vstring=0; - out = stdout; - suffixes = X_DEFAULT; - - argc = getRCSINIT(argc, argv, &newargv); - argv = newargv; - while (a = *++argv, 0<--argc && *a++=='-') { - switch (*a++) { - - case 'L': - onlylockflag = true; - break; - - case 'N': - shownames = false; - break; - - case 'R': - onlyRCSflag =true; - break; - - case 'l': - lockflag = true; - getlocker(a); - break; - - case 'b': - branchflag = true; - break; - - case 'r': - getrevpairs(a); - break; - - case 'd': - getdatepair(a); - break; - - case 's': - getstate(a); - break; - - case 'w': - getauthor(a); - break; - - case 'h': - descflag = false; - break; - - case 't': - selectflag = false; - break; - - case 'q': - /* This has no effect; it's here for consistency. */ - quietflag = true; - break; - - case 'x': - suffixes = a; - break; - - case 'z': - zone_set(a); - break; - - case 'T': - /* Ignore -T, so that RCSINIT can contain -T. */ - if (*a) - goto unknown; - break; - - case 'V': - setRCSversion(*argv); - break; - - case 'v': - versionlist = true; - vstring = a; - break; - - default: - unknown: - error("unknown option: %s%s", *argv, cmdusage); - - }; - } /* end of option processing */ - - if (! (descflag|selectflag)) { - warn("-t overrides -h."); - descflag = true; - } - - pre5 = RCSversion < VERSION(5); - if (pre5) { - accessListString = "\naccess list: "; - accessFormat = " %s"; - headFormat = "RCS file: %s; Working file: %s\nhead: %s%s\nbranch: %s%s\nlocks: "; - insDelFormat = " lines added/del: %ld/%ld"; - symbolFormat = " %s: %s;"; - } else { - accessListString = "\naccess list:"; - accessFormat = "\n\t%s"; - headFormat = "RCS file: %s\nWorking file: %s\nhead:%s%s\nbranch:%s%s\nlocks:%s"; - insDelFormat = " lines: +%ld -%ld"; - symbolFormat = "\n\t%s: %s"; - } - - /* Now handle all pathnames. */ - if (nerror) - cleanup(); - else if (argc < 1) - faterror("no input file%s", cmdusage); - else - for (; 0 < argc; cleanup(), ++argv, --argc) { - ffree(); - - if (pairnames(argc, argv, rcsreadopen, true, false) <= 0) - continue; - - /* - * RCSname contains the name of the RCS file, - * and finptr the file descriptor; - * workname contains the name of the working file. - */ - - /* Keep only those locks given by -l. */ - if (lockflag) - trunclocks(); - - /* do nothing if -L is given and there are no locks*/ - if (onlylockflag && !Locks) - continue; - - if ( versionlist ) { - gettree(); - aprintf(out, "%s%s %s\n", vstring, workname, tiprev()); - continue; - } - - if ( onlyRCSflag ) { - aprintf(out, "%s\n", RCSname); - continue; - } - - gettree(); - - if (!getnumericrev()) - continue; - - /* - * Output the first character with putc, not printf. - * Otherwise, an SVR4 stdio bug buffers output inefficiently. - */ - aputc_('\n', out) - - /* print RCS pathname, working pathname and optional - administrative information */ - /* could use getfullRCSname() here, but that is very slow */ - aprintf(out, headFormat, RCSname, workname, - Head ? " " : "", Head ? Head->num : "", - Dbranch ? " " : "", Dbranch ? Dbranch : "", - StrictLocks ? " strict" : "" - ); - currlock = Locks; - while( currlock ) { - aprintf(out, symbolFormat, currlock->login, - currlock->delta->num); - currlock = currlock->nextlock; - } - if (StrictLocks && pre5) - aputs(" ; strict" + (Locks?3:0), out); - - aputs(accessListString, out); /* print access list */ - curaccess = AccessList; - while(curaccess) { - aprintf(out, accessFormat, curaccess->login); - curaccess = curaccess->nextaccess; - } - - if (shownames) { - aputs("\nsymbolic names:", out); /* print symbolic names */ - for (curassoc=Symbols; curassoc; curassoc=curassoc->nextassoc) - aprintf(out, symbolFormat, curassoc->symbol, curassoc->num); - } - if (pre5) { - aputs("\ncomment leader: \"", out); - awrite(Comment.string, Comment.size, out); - afputc('\"', out); - } - if (!pre5 || Expand != KEYVAL_EXPAND) - aprintf(out, "\nkeyword substitution: %s", - expand_names[Expand] - ); - - aprintf(out, "\ntotal revisions: %d", TotalDeltas); - - revno = 0; - - if (Head && selectflag & descflag) { - - exttree(Head); - - /* get most recently date of the dates pointed by duelst */ - currdate = duelst; - while( currdate) { - VOID strcpy(currdate->strtdate, "0.0.0.0.0.0"); - recentdate(Head, currdate); - currdate = currdate->dnext; - } - - revno = extdate(Head); - - aprintf(out, ";\tselected revisions: %d", revno); - } - - afputc('\n',out); - if (descflag) { - aputs("description:\n", out); - getdesc(true); - } - if (revno) { - while (! (delta = readdeltalog())->selector || --revno) - continue; - if (delta->next && countnumflds(delta->num)==2) - /* Read through delta->next to get its insertlns. */ - while (readdeltalog() != delta->next) - continue; - putrunk(); - putree(Head); - } - aputs("----------------------------\n", out); - aputs("=============================================================================\n",out); - } - Ofclose(out); - exitmain(exitstatus); -} - - static void -cleanup() -{ - if (nerror) exitstatus = EXIT_FAILURE; - Izclose(&finptr); -} - -#if RCS_lint -# define exiterr rlogExit -#endif - void -exiterr() -{ - _exit(EXIT_FAILURE); -} - - - - static void -putrunk() -/* function: print revisions chosen, which are in trunk */ - -{ - register struct hshentry const *ptr; - - for (ptr = Head; ptr; ptr = ptr->next) - putadelta(ptr, ptr->next, true); -} - - - - static void -putree(root) - struct hshentry const *root; -/* function: print delta tree (not including trunk) in reverse - order on each branch */ - -{ - if (!root) return; - - putree(root->next); - - putforest(root->branches); -} - - - - - static void -putforest(branchroot) - struct branchhead const *branchroot; -/* function: print branches that has the same direct ancestor */ -{ - if (!branchroot) return; - - putforest(branchroot->nextbranch); - - putabranch(branchroot->hsh); - putree(branchroot->hsh); -} - - - - - static void -putabranch(root) - struct hshentry const *root; -/* function : print one branch */ - -{ - if (!root) return; - - putabranch(root->next); - - putadelta(root, root, false); -} - - - - - - static void -putadelta(node,editscript,trunk) - register struct hshentry const *node, *editscript; - int trunk; -/* function: Print delta node if node->selector is set. */ -/* editscript indicates where the editscript is stored */ -/* trunk indicated whether this node is in trunk */ -{ - static char emptych[] = EMPTYLOG; - - register FILE *out; - char const *s; - size_t n; - struct branchhead const *newbranch; - struct buf branchnum; - char datebuf[datesize + zonelenmax]; - int pre5 = RCSversion < VERSION(5); - - if (!node->selector) - return; - - out = stdout; - aprintf(out, - "----------------------------\nrevision %s%s", - node->num, pre5 ? " " : "" - ); - if ( node->lockedby ) - aprintf(out, pre5+"\tlocked by: %s;", node->lockedby); - - aprintf(out, "\ndate: %s; author: %s; state: %s;", - date2str(node->date, datebuf), - node->author, node->state - ); - - if ( editscript ) - if(trunk) - aprintf(out, insDelFormat, - editscript->deletelns, editscript->insertlns); - else - aprintf(out, insDelFormat, - editscript->insertlns, editscript->deletelns); - - newbranch = node->branches; - if ( newbranch ) { - bufautobegin(&branchnum); - aputs("\nbranches:", out); - while( newbranch ) { - getbranchno(newbranch->hsh->num, &branchnum); - aprintf(out, " %s;", branchnum.string); - newbranch = newbranch->nextbranch; - } - bufautoend(&branchnum); - } - - afputc('\n', out); - s = node->log.string; - if (!(n = node->log.size)) { - s = emptych; - n = sizeof(emptych)-1; - } - awrite(s, n, out); - if (s[n-1] != '\n') - afputc('\n', out); -} - - - static struct hshentry const * -readdeltalog() -/* Function : get the log message and skip the text of a deltatext node. - * Return the delta found. - * Assumes the current lexeme is not yet in nexttok; does not - * advance nexttok. - */ -{ - register struct hshentry * Delta; - struct buf logbuf; - struct cbuf cb; - - if (eoflex()) - fatserror("missing delta log"); - nextlex(); - if (!(Delta = getnum())) - fatserror("delta number corrupted"); - getkeystring(Klog); - if (Delta->log.string) - fatserror("duplicate delta log"); - bufautobegin(&logbuf); - cb = savestring(&logbuf); - Delta->log = bufremember(&logbuf, cb.size); - - ignorephrases(Ktext); - getkeystring(Ktext); - Delta->insertlns = Delta->deletelns = 0; - if ( Delta != Head) - getscript(Delta); - else - readstring(); - return Delta; -} - - - static void -getscript(Delta) -struct hshentry * Delta; -/* function: read edit script of Delta and count how many lines added */ -/* and deleted in the script */ - -{ - int ed; /* editor command */ - declarecache; - register RILE *fin; - register int c; - register long i; - struct diffcmd dc; - - fin = finptr; - setupcache(fin); - initdiffcmd(&dc); - while (0 <= (ed = getdiffcmd(fin,true,(FILE *)0,&dc))) - if (!ed) - Delta->deletelns += dc.nlines; - else { - /* skip scripted lines */ - i = dc.nlines; - Delta->insertlns += i; - cache(fin); - do { - for (;;) { - cacheget_(c) - switch (c) { - default: - continue; - case SDELIM: - cacheget_(c) - if (c == SDELIM) - continue; - if (--i) - unexpected_EOF(); - nextc = c; - uncache(fin); - return; - case '\n': - break; - } - break; - } - ++rcsline; - } while (--i); - uncache(fin); - } -} - - - - - - - - static void -exttree(root) -struct hshentry *root; -/* function: select revisions , starting with root */ - -{ - struct branchhead const *newbranch; - - if (!root) return; - - root->selector = extractdelta(root); - root->log.string = 0; - exttree(root->next); - - newbranch = root->branches; - while( newbranch ) { - exttree(newbranch->hsh); - newbranch = newbranch->nextbranch; - } -} - - - - - static void -getlocker(argv) -char * argv; -/* function : get the login names of lockers from command line */ -/* and store in lockerlist. */ - -{ - register char c; - struct rcslockers *newlocker; - argv--; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - if ( c == '\0') { - lockerlist = 0; - return; - } - - while( c != '\0' ) { - newlocker = talloc(struct rcslockers); - newlocker->lockerlink = lockerlist; - newlocker->login = argv; - lockerlist = newlocker; - while ((c = *++argv) && c!=',' && c!=' ' && c!='\t' && c!='\n' && c!=';') - continue; - *argv = '\0'; - if ( c == '\0' ) return; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - } -} - - - - static void -getauthor(argv) -char *argv; -/* function: get the author's name from command line */ -/* and store in authorlist */ - -{ - register c; - struct authors * newauthor; - - argv--; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - if ( c == '\0' ) { - authorlist = talloc(struct authors); - authorlist->login = getusername(false); - authorlist->nextauthor = 0; - return; - } - - while( c != '\0' ) { - newauthor = talloc(struct authors); - newauthor->nextauthor = authorlist; - newauthor->login = argv; - authorlist = newauthor; - while ((c = *++argv) && c!=',' && c!=' ' && c!='\t' && c!='\n' && c!=';') - continue; - * argv = '\0'; - if ( c == '\0') return; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - } -} - - - - - static void -getstate(argv) -char * argv; -/* function : get the states of revisions from command line */ -/* and store in statelist */ - -{ - register char c; - struct stateattri *newstate; - - argv--; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - if ( c == '\0'){ - error("missing state attributes after -s options"); - return; - } - - while( c != '\0' ) { - newstate = talloc(struct stateattri); - newstate->nextstate = statelist; - newstate->status = argv; - statelist = newstate; - while ((c = *++argv) && c!=',' && c!=' ' && c!='\t' && c!='\n' && c!=';') - continue; - *argv = '\0'; - if ( c == '\0' ) return; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - } -} - - - - static void -trunclocks() -/* Function: Truncate the list of locks to those that are held by the */ -/* id's on lockerlist. Do not truncate if lockerlist empty. */ - -{ - struct rcslockers const *plocker; - struct rcslock *p, **pp; - - if (!lockerlist) return; - - /* shorten Locks to those contained in lockerlist */ - for (pp = &Locks; (p = *pp); ) - for (plocker = lockerlist; ; ) - if (strcmp(plocker->login, p->login) == 0) { - pp = &p->nextlock; - break; - } else if (!(plocker = plocker->lockerlink)) { - *pp = p->nextlock; - break; - } -} - - - - static void -recentdate(root, pd) - struct hshentry const *root; - struct Datepairs *pd; -/* function: Finds the delta that is closest to the cutoff date given by */ -/* pd among the revisions selected by exttree. */ -/* Successively narrows down the interval given by pd, */ -/* and sets the strtdate of pd to the date of the selected delta */ -{ - struct branchhead const *newbranch; - - if (!root) return; - if (root->selector) { - if ( cmpdate(root->date, pd->strtdate) >= 0 && - cmpdate(root->date, pd->enddate) <= 0) - VOID strcpy(pd->strtdate, root->date); - } - - recentdate(root->next, pd); - newbranch = root->branches; - while( newbranch) { - recentdate(newbranch->hsh, pd); - newbranch = newbranch->nextbranch; - } -} - - - - - - - static int -extdate(root) -struct hshentry * root; -/* function: select revisions which are in the date range specified */ -/* in duelst and datelist, start at root */ -/* Yield number of revisions selected, including those already selected. */ -{ - struct branchhead const *newbranch; - struct Datepairs const *pdate; - int revno, ne; - - if (!root) - return 0; - - if ( datelist || duelst) { - pdate = datelist; - while( pdate ) { - ne = pdate->ne_date; - if ( - (!pdate->strtdate[0] - || ne <= cmpdate(root->date, pdate->strtdate)) - && - (!pdate->enddate[0] - || ne <= cmpdate(pdate->enddate, root->date)) - ) - break; - pdate = pdate->dnext; - } - if (!pdate) { - pdate = duelst; - for (;;) { - if (!pdate) { - root->selector = false; - break; - } - if (cmpdate(root->date, pdate->strtdate) == 0) - break; - pdate = pdate->dnext; - } - } - } - revno = root->selector + extdate(root->next); - - newbranch = root->branches; - while( newbranch ) { - revno += extdate(newbranch->hsh); - newbranch = newbranch->nextbranch; - } - return revno; -} - - - - static char -extractdelta(pdelta) - struct hshentry const *pdelta; -/* function: compare information of pdelta to the authorlist, lockerlist,*/ -/* statelist, revlist and yield true if pdelta is selected. */ - -{ - struct rcslock const *plock; - struct stateattri const *pstate; - struct authors const *pauthor; - struct Revpairs const *prevision; - int length; - - if ((pauthor = authorlist)) /* only certain authors wanted */ - while (strcmp(pauthor->login, pdelta->author) != 0) - if (!(pauthor = pauthor->nextauthor)) - return false; - if ((pstate = statelist)) /* only certain states wanted */ - while (strcmp(pstate->status, pdelta->state) != 0) - if (!(pstate = pstate->nextstate)) - return false; - if (lockflag) /* only locked revisions wanted */ - for (plock = Locks; ; plock = plock->nextlock) - if (!plock) - return false; - else if (plock->delta == pdelta) - break; - if ((prevision = Revlst)) /* only certain revs or branches wanted */ - for (;;) { - length = prevision->numfld; - if ( - countnumflds(pdelta->num) == length+(length&1) && - 0 <= compartial(pdelta->num, prevision->strtrev, length) && - 0 <= compartial(prevision->endrev, pdelta->num, length) - ) - break; - if (!(prevision = prevision->rnext)) - return false; - } - return true; -} - - - - static void -getdatepair(argv) - char * argv; -/* function: get time range from command line and store in datelist if */ -/* a time range specified or in duelst if a time spot specified */ - -{ - register char c; - struct Datepairs * nextdate; - char const * rawdate; - int switchflag; - - argv--; - while ((c = *++argv)==',' || c==' ' || c=='\t' || c=='\n' || c==';') - continue; - if ( c == '\0' ) { - error("missing date/time after -d"); - return; - } - - while( c != '\0' ) { - switchflag = false; - nextdate = talloc(struct Datepairs); - if ( c == '<' ) { /* case: -d ne_date = c!='=')) - c = *++argv; - (nextdate->strtdate)[0] = '\0'; - } else if (c == '>') { /* case: -d'>date' */ - c = *++argv; - if (!(nextdate->ne_date = c!='=')) - c = *++argv; - (nextdate->enddate)[0] = '\0'; - switchflag = true; - } else { - rawdate = argv; - while( c != '<' && c != '>' && c != ';' && c != '\0') - c = *++argv; - *argv = '\0'; - if ( c == '>' ) switchflag=true; - str2date(rawdate, - switchflag ? nextdate->enddate : nextdate->strtdate); - if ( c == ';' || c == '\0') { /* case: -d date */ - VOID strcpy(nextdate->enddate,nextdate->strtdate); - nextdate->dnext = duelst; - duelst = nextdate; - goto end; - } else { - /* case: -d date< or -d date>; see switchflag */ - int eq = argv[1]=='='; - nextdate->ne_date = !eq; - argv += eq; - while ((c = *++argv) == ' ' || c=='\t' || c=='\n') - continue; - if ( c == ';' || c == '\0') { - /* second date missing */ - if (switchflag) - *nextdate->strtdate= '\0'; - else - *nextdate->enddate= '\0'; - nextdate->dnext = datelist; - datelist = nextdate; - goto end; - } - } - } - rawdate = argv; - while( c != '>' && c != '<' && c != ';' && c != '\0') - c = *++argv; - *argv = '\0'; - str2date(rawdate, - switchflag ? nextdate->strtdate : nextdate->enddate); - nextdate->dnext = datelist; - datelist = nextdate; - end: - if (RCSversion < VERSION(5)) - nextdate->ne_date = 0; - if ( c == '\0') return; - while ((c = *++argv) == ';' || c == ' ' || c == '\t' || c =='\n') - continue; - } -} - - - - static int -getnumericrev() -/* function: get the numeric name of revisions which stored in revlist */ -/* and then stored the numeric names in Revlst */ -/* if branchflag, also add default branch */ - -{ - struct Revpairs * ptr, *pt; - int n; - struct buf s, e; - char const *lrev; - struct buf const *rstart, *rend; - - Revlst = 0; - ptr = revlist; - bufautobegin(&s); - bufautobegin(&e); - while( ptr ) { - n = 0; - rstart = &s; - rend = &e; - - switch (ptr->numfld) { - - case 1: /* -rREV */ - if (!expandsym(ptr->strtrev, &s)) - goto freebufs; - rend = &s; - n = countnumflds(s.string); - if (!n && (lrev = tiprev())) { - bufscpy(&s, lrev); - n = countnumflds(lrev); - } - break; - - case 2: /* -rREV: */ - if (!expandsym(ptr->strtrev, &s)) - goto freebufs; - bufscpy(&e, s.string); - n = countnumflds(s.string); - (n<2 ? e.string : strrchr(e.string,'.'))[0] = 0; - break; - - case 3: /* -r:REV */ - if (!expandsym(ptr->endrev, &e)) - goto freebufs; - if ((n = countnumflds(e.string)) < 2) - bufscpy(&s, ".0"); - else { - bufscpy(&s, e.string); - VOID strcpy(strrchr(s.string,'.'), ".0"); - } - break; - - default: /* -rREV1:REV2 */ - if (!( - expandsym(ptr->strtrev, &s) - && expandsym(ptr->endrev, &e) - && checkrevpair(s.string, e.string) - )) - goto freebufs; - n = countnumflds(s.string); - /* Swap if out of order. */ - if (compartial(s.string,e.string,n) > 0) { - rstart = &e; - rend = &s; - } - break; - } - - if (n) { - pt = ftalloc(struct Revpairs); - pt->numfld = n; - pt->strtrev = fstr_save(rstart->string); - pt->endrev = fstr_save(rend->string); - pt->rnext = Revlst; - Revlst = pt; - } - ptr = ptr->rnext; - } - /* Now take care of branchflag */ - if (branchflag && (Dbranch||Head)) { - pt = ftalloc(struct Revpairs); - pt->strtrev = pt->endrev = - Dbranch ? Dbranch : fstr_save(partialno(&s,Head->num,1)); - pt->rnext=Revlst; Revlst=pt; - pt->numfld = countnumflds(pt->strtrev); - } - - freebufs: - bufautoend(&s); - bufautoend(&e); - return !ptr; -} - - - - static int -checkrevpair(num1,num2) - char const *num1, *num2; -/* function: check whether num1, num2 are legal pair,i.e. - only the last field are different and have same number of - fields( if length <= 2, may be different if first field) */ - -{ - int length = countnumflds(num1); - - if ( - countnumflds(num2) != length - || (2 < length && compartial(num1, num2, length-1) != 0) - ) { - rcserror("invalid branch or revision pair %s : %s", num1, num2); - return false; - } - - return true; -} - - - - static void -getrevpairs(argv) -register char * argv; -/* function: get revision or branch range from command line, and */ -/* store in revlist */ - -{ - register char c; - struct Revpairs * nextrevpair; - int separator; - - c = *argv; - - /* Support old ambiguous '-' syntax; this will go away. */ - if (strchr(argv,':')) - separator = ':'; - else { - if (strchr(argv,'-') && VERSION(5) <= RCSversion) - warn("`-' is obsolete in `-r%s'; use `:' instead", argv); - separator = '-'; - } - - for (;;) { - while (c==' ' || c=='\t' || c=='\n') - c = *++argv; - nextrevpair = talloc(struct Revpairs); - nextrevpair->rnext = revlist; - revlist = nextrevpair; - nextrevpair->numfld = 1; - nextrevpair->strtrev = argv; - for (;; c = *++argv) { - switch (c) { - default: - continue; - case '\0': case ' ': case '\t': case '\n': - case ',': case ';': - break; - case ':': case '-': - if (c == separator) - break; - continue; - } - break; - } - *argv = '\0'; - while (c==' ' || c=='\t' || c=='\n') - c = *++argv; - if (c == separator) { - while ((c = *++argv) == ' ' || c == '\t' || c =='\n') - continue; - nextrevpair->endrev = argv; - for (;; c = *++argv) { - switch (c) { - default: - continue; - case '\0': case ' ': case '\t': case '\n': - case ',': case ';': - break; - case ':': case '-': - if (c == separator) - break; - continue; - } - break; - } - *argv = '\0'; - while (c==' ' || c=='\t' || c =='\n') - c = *++argv; - nextrevpair->numfld = - !nextrevpair->endrev[0] ? 2 /* -rREV: */ : - !nextrevpair->strtrev[0] ? 3 /* -r:REV */ : - 4 /* -rREV1:REV2 */; - } - if (!c) - break; - else if (c==',' || c==';') - c = *++argv; - else - error("missing `,' near `%c%s'", c, argv+1); - } -} diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index 8294f66e444..7960c77ed5e 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -421,6 +421,7 @@ _DP_zpool= md pthread z icp spl nvpair avl umem _DP_zutil= avl geom m tpool _DP_be= zfs spl nvpair zfsbootenv _DP_netmap= +_DP_netpgp= bz2 crypto mj z _DP_ifconfig= m _DP_pfctl= nv @@ -443,6 +444,7 @@ _DP_osmvendor= ibumad pthread _DP_msearch= sqlite3 magic z _DP_mport= md archive bz2 lzma z fetch sqlite3 ucl pthread util zstd +_DP_mj= bz2 crypto z _DP_dispatch= BlocksRuntime pthread _DP_blocksruntime= @@ -727,6 +729,9 @@ LIBGTEST_MAINDIR= ${OBJTOP}/lib/googletest/gtest_main LIBALIASDIR= ${OBJTOP}/lib/libalias/libalias LIBBLACKLISTDIR= ${OBJTOP}/lib/libblacklist LIBBLOCKSRUNTIMEDIR= ${OBJTOP}/lib/libblocksruntime +LIBDISPATCHDIR= ${OBJTOP}/lib/libdispatch +LIBMPORTDIR= ${OBJTOP}/lib/libmport +LIBMSEARCHDIR= ${OBJTOP}/lib/libmsearch LIBBSNMPDIR= ${OBJTOP}/lib/libbsnmp/libbsnmp LIBCASPERDIR= ${OBJTOP}/lib/libcasper/libcasper LIBCAP_DNSDIR= ${OBJTOP}/lib/libcasper/services/cap_dns @@ -746,6 +751,8 @@ LIBMENUWDIR= ${OBJTOP}/lib/ncurses/menu LIBNCURSESWDIR= ${OBJTOP}/lib/ncurses/ncurses LIBPANELWDIR= ${OBJTOP}/lib/ncurses/panel LIBCRYPTODIR= ${OBJTOP}/secure/lib/libcrypto +LIBMJDIR= ${OBJTOP}/secure/lib/libmj +LIBNETPGPDIR= ${OBJTOP}/secure/lib/libnetpgp LIBSPLDIR= ${OBJTOP}/cddl/lib/libspl LIBSSHDIR= ${OBJTOP}/secure/lib/libssh LIBSSLDIR= ${OBJTOP}/secure/lib/libssl diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 9b61f53b013..11c71dbd918 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -143,6 +143,7 @@ __DEFAULT_YES_OPTIONS = \ MAILWRAPPER \ MAKE \ MALLOC_PRODUCTION \ + MIDNIGHTBSD_UPDATE \ MLX5TOOL \ NDIS \ NETCAT \