From b00e9eb79737d9c1891de906b50db4c15b5a1afe Mon Sep 17 00:00:00 2001 From: gdr Date: Wed, 24 Sep 1997 06:34:59 +0000 Subject: [PATCH] Makefile: - Renamed from makefile.mk to Makefile. - Updated for proper operation as part of GNO build. - Discontinue use of vaend.c, basename.c for GNO v2.0.6. descu: - Document ability to specify an output file vice stdout (this feature was already in, but not documented) - Allow the output file to be the same name as the first input file (it will be overwritten). - Fix buffer overrun bugs that occured when: a) There was no initial input file; or b) There are no headers in the first input file; or c) There are no trailers in the first input file; or - Increased SLOTS_QUANTUM from 20 to 64, hopefully increasing the speed on large files. - fixed stack check code to use the new routines names - put version number in lockstep with descc and describe descc: - descc will now change the database file type to BIN, if it wasn't already so. - changed default location of system database - fixed stack check code to use the new routines names - put version number in lockstep with descu and describe describe: - changed default location of system database - fixed stack check code to use the new routines names - put version number in lockstep with descu and descc *.rez: - added resource source files --- usr.orca.bin/describe/Makefile | 73 ++++++++++++++ usr.orca.bin/describe/README | 26 +++-- usr.orca.bin/describe/basename.c | 4 +- usr.orca.bin/describe/desc.h | 7 +- usr.orca.bin/describe/descc.8 | 54 ++++++---- usr.orca.bin/describe/descc.c | 60 ++++++++++-- usr.orca.bin/describe/descc.desc | 5 +- usr.orca.bin/describe/descc.rez | 34 +++++++ usr.orca.bin/describe/describe.1 | 20 +++- usr.orca.bin/describe/describe.c | 31 +++--- usr.orca.bin/describe/describe.desc | 6 +- usr.orca.bin/describe/describe.rez | 34 +++++++ usr.orca.bin/describe/descu.8 | 41 ++++++-- usr.orca.bin/describe/descu.c | 147 +++++++++++++++++++--------- usr.orca.bin/describe/descu.desc | 5 +- usr.orca.bin/describe/descu.rez | 34 +++++++ usr.orca.bin/describe/makefile.mk | 44 --------- 17 files changed, 458 insertions(+), 167 deletions(-) create mode 100644 usr.orca.bin/describe/Makefile create mode 100644 usr.orca.bin/describe/descc.rez create mode 100644 usr.orca.bin/describe/describe.rez create mode 100644 usr.orca.bin/describe/descu.rez delete mode 100644 usr.orca.bin/describe/makefile.mk diff --git a/usr.orca.bin/describe/Makefile b/usr.orca.bin/describe/Makefile new file mode 100644 index 0000000..048e795 --- /dev/null +++ b/usr.orca.bin/describe/Makefile @@ -0,0 +1,73 @@ +# +# This is the makefile for the describe(1) package. It is for use +# with dmake(1). +# + +# Include configuration files if this is part of the GNO build. +.INCLUDE .IGNORE: /src/gno/paths.mk +.INCLUDE .IGNORE: /src/gno/binconst.mk + +# Use -D__STACK_CHECK__ in CFLAGS to show stack usage. +# The most recent measurements of stack usage showed: +# describe 930 bytes +# descc 943 +# descu 861 bytes + +CFLAGS += -O78 -s1024 # -D__STACK_CHECK__ +LDFLAGS += -v +LDLIBS += + +# If this is not part of the GNO builds, RELEASE_DIR is not defined +# so things get installed in a live file system instead. +BINDIR = $(RELEASE_DIR)/usr/bin +SBINDIR = $(RELEASE_DIR)/usr/sbin +MANDIR = $(RELEASE_DIR)/usr/man + +# If you have an old copy of GNO's libc, you may need to compile basename.c +# yourself. (As of v2.0.6, it's part of the standard libc.) vaend.c may +# be needed if you are using GNO v2.0.4 with ORCA/C v2.1.x +BASENAME = # basename.o +VAEND = # vaend.o + +DESC_FILES = describe.desc descc.desc descu.desc + +# A stand-alone build might not have these defined. +.IF $(INSTALL) == $(NULL) + INSTALL = /usr/bin/install +.END +.IF $(CATREZ) == $(NULL) + CATREZ = /usr/bin/catrez +.END +.IF $(DESC_DIR) == $(NULL) + DESC_DIR= $(RELEASE_DIR)/usr/lib + DESC_SRC= $(DESC_DIR)/describe.src +.END + +build: describe descc descu + +descc: descc.o $(BASENAME) descc.r + $(CC) $(LDFLAGS) descc.o $(BASENAME) -o $@ $(LDLIBS) + $(CATREZ) -d $@ descc.r + +describe: describe.o $(BASENAME) describe.r + $(CC) $(LDFLAGS) describe.o $(BASENAME) -o $@ $(LDLIBS) + $(CATREZ) -d $@ describe.r + +descu: descu.o $(BASENAME) $(VAEND) descu.r + $(CC) $(LDFLAGS) descu.o $(BASENAME) $(VAEND) -o $@ $(LDLIBS) + $(CATREZ) -d $@ descu.r + +descc.o:: desc.h +describe.o:: desc.h +descu.o:: desc.h + +install release: + $(INSTALL) -d $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8 + $(INSTALL) -d $(DESC_DIR) + $(INSTALL) describe $(BINDIR) + $(INSTALL) descc $(SBINDIR) + $(INSTALL) descu $(SBINDIR) + $(INSTALL) describe.1 $(MANDIR)/man1 + $(INSTALL) descc.8 $(MANDIR)/man8 + $(INSTALL) descu.8 $(MANDIR)/man8 + ./descu -o $(DESC_SRC) $(DESC_SRC) $(DESC_FILES) diff --git a/usr.orca.bin/describe/README b/usr.orca.bin/describe/README index b0e75f0..eb58790 100644 --- a/usr.orca.bin/describe/README +++ b/usr.orca.bin/describe/README @@ -1,14 +1,14 @@ -$Id: README,v 1.3 1996/01/28 17:39:22 gdr Exp $ +$Id: README,v 1.4 1997/09/24 06:34:57 gdr Exp $ This is the README file for the describe package. This package is -designated as version 1.0.3, and consists of the following utilities: +designated as version 1.0.4, and consists of the following utilities: - describe v1.0.3 - show database entries describing the current + describe v1.0.4 - show database entries describing the current status of programs - descc v1.0.3 - the describe source compiler + descc v1.0.4 - the describe source compiler - descu v1.0.3 - the describe source updater + descu v1.0.4 - the describe source updater ABOUT DESCRIBE AND DESCC ======================== @@ -21,8 +21,9 @@ different people are releasing these days. The reason it sat around on my harddrive so long is I was having qualms about its designated role in life. I wasn't sure exactly what I wanted it to do. Well, I've decided to KISS for now: descc simply compiles the utility list, which I maintain, -into a (very) simple "database" located in /usr/local/lib/ -[alternatively, the full path given in the environment variable DESCDB will be +into a (very) simple "database" located in /usr/local/lib. +[As of v1.0.4, this database is now in /usr/lib. gdr] [Alternatively, +the full path given in the environment variable DESCDB will be used, if it is set. sb]. The companion utility 'describe' is used to fetch information about a particular utility from this "database". @@ -46,7 +47,7 @@ ABOUT DESCU =========== I think describe and descc were really good ideas; they sure beat the -text file list of Gno utilities that James used to keep. The one major +text file list of GNO utilities that James used to keep. The one major shortfall I found was having to manually update the describe database source every time I wanted to include a new entry. @@ -82,6 +83,15 @@ CHANGES This details changes to the entire distribution. +v1.0.4 September 1997 + This package is now part of the base GNO distribution. + Version numbers are now in lockstep. + Some bugs were fixed in descu that cropped up when the + describe database source file didn't already exist. + Location of the system database has been changed to + /usr/lib/describe from /usr/local/lib/describe. + Descc will now set the file type of the database to BIN vice TXT. + v1.03 January 1996 descu now sorts entries correctly (longer entries ended up before shorter ones with 1.0.2, i.e. "calls" diff --git a/usr.orca.bin/describe/basename.c b/usr.orca.bin/describe/basename.c index 5769980..54762b5 100644 --- a/usr.orca.bin/describe/basename.c +++ b/usr.orca.bin/describe/basename.c @@ -1,4 +1,6 @@ -#pragma optimize -1 +/* + * $Id: basename.c,v 1.2 1997/09/24 06:34:57 gdr Exp $ + */ #include #include diff --git a/usr.orca.bin/describe/desc.h b/usr.orca.bin/describe/desc.h index 2eef4c0..123231f 100644 --- a/usr.orca.bin/describe/desc.h +++ b/usr.orca.bin/describe/desc.h @@ -1,10 +1,15 @@ /* * Header file for the describe package. This file is * used by describe(1), descc(8), and descu(8). + * + * $Id: desc.h,v 1.3 1997/09/24 06:34:57 gdr Exp $ */ +/* Keep these utilities in lockstep. */ +#define _VERSION_ "v1.0.4" + #define QUOTE_CHAR '#' -#define DATABASE "/usr/local/lib/describe" +#define DATABASE "/usr/lib/describe" #define FIELD_LEN 9 #define NAME_LEN 34 diff --git a/usr.orca.bin/describe/descc.8 b/usr.orca.bin/describe/descc.8 index f44b802..e80c911 100644 --- a/usr.orca.bin/describe/descc.8 +++ b/usr.orca.bin/describe/descc.8 @@ -1,14 +1,28 @@ -.TH DESCC 8 "System Administration" "7 May 1995" "Version 1.0.3" +.\" +.\" $Id: descc.8,v 1.4 1997/09/24 06:34:57 gdr Exp $ +.\" +.TH DESCC 8 "22 September 1997" GNO "System Administration" .SH NAME descc \- the describe(1) source compiler .SH SYNOPSIS -.BR descc " [" -hV ] +.BR descc +[ +.BR -hV +] .I sourcefile .SH DESCRIPTION +This manual page documents +.BR descc +version 1.0.4. +.LP .BR descc compiles the describe source file .I sourcefile and saves the result to the system describe database. +If the database doesn't exist, or doesn't have type BIN, then +.BR descc +will set the database file type to BIN and the auxtype to 0x0000 after +it has been updated. .SH OPTIONS .nf \fB-h\fR Show usage information. @@ -37,22 +51,23 @@ seven consist of one line of text and begin with the following identifiers: The last field consists of multiple lines of text. It should be a brief description of the program. The following is an example of a complete record: +.RS .nf - Name: describe - Version: 1.0.3 - Shell: ORCA/Shell, GNO/ME - Author: James Brookes - Contact: jamesb@ecst.csuchico.edu - Where: /usr/local/bin - FTP: ftp.cco.caltech.edu - - Print a multi-line description obtained from the compiled - 'describe' database; giving utility name, version, intended shell, - author, author's contact, where the utility is, as well as where the - utility can be FTPd from on the InterNet. +Name: describe +Version: 1.0.4 +Shell: GNO, ORCA/Shell +Author: James Brookes +Contact: jamesb@ecst.csuchico.edu +Where: /usr/bin +FTP: apple2.caltech.edu, ground.isca.uiowa.edu .fi +Print a multi-line description obtained from the compiled 'describe' +database; giving utility name, version, intended shell, author, +author's contact, where the utility is, as well as where the +utility can be FTPd from on the InterNet. +.RE .LP The describe database file consists of a .BR Header , @@ -75,7 +90,8 @@ in the following format: .fi .SH FILES -/usr/local/lib/describe \- the system +.IP \fB/usr/lib/describe\fR +The system .B describe database. If the environment variable .B DESCDB @@ -85,10 +101,12 @@ is set, its value will be used instead. Full path to the system describe database. If .B DESCDB is set, its value is used instead of the default location -/usr/local/lib/describe. - -.SH AUTHOR +.BR /usr/lib/describe . +.SH AUTHOR James Brookes . +.SH HISTORY +.BR descu +was incorporated into the GNO base distribution as of version 1.0.4 .SH "SEE ALSO" .BR apropos (1), .BR describe (1), diff --git a/usr.orca.bin/describe/descc.c b/usr.orca.bin/describe/descc.c index f9ff152..9c8d790 100644 --- a/usr.orca.bin/describe/descc.c +++ b/usr.orca.bin/describe/descc.c @@ -1,6 +1,13 @@ /* */ /* descc - compile info file into describe database file */ /* */ +/* $Id: descc.c,v 1.5 1997/09/24 06:34:58 gdr Exp $ */ +/* */ +/* v1.0.4 - Changed location of database. Describe is now */ +/* part of the base GNO distribution. Version numbers */ +/* now in lockstep. */ +/* Devin Reade [Mon 22 Sep 1997] */ +/* */ /* v1.0.3 - No changes, but changed version number to keep */ /* in line with descu. */ /* Soenke Behrens [Sun Jan 28 1996] */ @@ -37,24 +44,23 @@ /* 8 variable-length Null-terminated strings. */ /* */ -#pragma optimize 15 - #include #include #include -#include #include +#ifdef __GNO__ +#include +#include +#include +#endif #include "desc.h" -#define _VERSION_ "v1.0.3" - /* prototypes */ void usage(char *callname); void version(char *callname); void puke(int error,int lines); int mygets(char *buffer, int2 *lines, FILE *FInPtr); -char *strdup (const char *str); int Vflag; @@ -112,6 +118,34 @@ int mygets (char *buffer, int2 *lines, FILE *FInPtr) { return(0); } +#ifdef __GNO__ +#define BIN 0x06 + +/* + * Change the file type of to BINary + */ +void +changeToBin(const char *path) { + + FileInfoRecGS pblock; + pblock.pCount = 4; + if ((pblock.pathname = (GSString255Ptr) __C2GSMALLOC(path)) == NULL) { + /* silent failure */ + return; + } + GetFileInfoGS(&pblock); + if (_toolErr == 0) { + if (pblock.fileType != BIN) { + pblock.fileType = BIN; + pblock.auxType = 0L; + SetFileInfoGS(&pblock); + } + } + GIfree((GSStringPtr) pblock.pathname); + return; +} +#endif /* __GNO__ */ + /* */ /* Mainline */ /* */ @@ -128,8 +162,8 @@ int main (int argc, char **argv) { /* initialize globals */ Vflag=0; errflag=0; -#ifdef STACK_CHECK - begin_stack_check(); +#ifdef __STACK_CHECK__ + _beginStackCheck(); #endif assert(sizeof(int2)==2); @@ -271,12 +305,18 @@ int main (int argc, char **argv) { fseek(FOutPtr,endOfFile,SEEK_SET); fclose(FOutPtr); + +#ifdef __GNO__ + /* change the filetype of the database to BIN */ + changeToBin(db_path); +#endif + free(db_path); free(record_locs); free(buffer); -#ifdef STACK_CHECK - fprintf(stderr,"stack usage: %d bytes\n",end_stack_check()); +#ifdef __STACK_CHECK__ + fprintf(stderr,"stack usage: %d bytes\n", _endStackCheck()); #endif return 0; } diff --git a/usr.orca.bin/describe/descc.desc b/usr.orca.bin/describe/descc.desc index d92afc0..98957be 100644 --- a/usr.orca.bin/describe/descc.desc +++ b/usr.orca.bin/describe/descc.desc @@ -1,10 +1,9 @@ Name: descc -Version: 1.0.3 +Version: 1.0.4 Shell: ORCA/Shell, GNO/ME Author: James Brookes Contact: jamesb@ecst.csuchico.edu Where: /usr/sbin -FTP: ftp.cco.caltech.edu +FTP: apple2.caltech.edu, ground.isca.uiowa.edu, trenco.myrias.com Compile a source file into a 'describe' database file. - diff --git a/usr.orca.bin/describe/descc.rez b/usr.orca.bin/describe/descc.rez new file mode 100644 index 0000000..8fa6eb0 --- /dev/null +++ b/usr.orca.bin/describe/descc.rez @@ -0,0 +1,34 @@ +/* + * Resources for version and comment + * + * $Id: descc.rez,v 1.1 1997/09/24 06:34:58 gdr Exp $ + */ +#include "Types.rez" + +/* Don't forget to update the version numbers, below (two places) */ +#define PROG "descc" +#define DESC "describe(1) source compiler" +#define AUTHOR "Author: James Brookes " + +/* + * Version + */ +resource rVersion (1, purgeable3) { + { 1, 0, 4, /* Version 1.0.4 */ + release, /* development|alpha|beta|final|release */ + 0 }, /* non-final release number */ + verUS, /* Country */ + PROG, /* Program name */ + DESC " (GNO)" +}; + +/* + * Comment + */ +resource rComment (1, purgeable3) { + PROG " v1.0.4\n" + DESC " (GNO) \n" + AUTHOR +}; + + diff --git a/usr.orca.bin/describe/describe.1 b/usr.orca.bin/describe/describe.1 index f2b4147..1a30b49 100644 --- a/usr.orca.bin/describe/describe.1 +++ b/usr.orca.bin/describe/describe.1 @@ -1,10 +1,20 @@ -.TH DESCRIBE 1 "Commands and Applications" "7 May 1995" "Version 1.0.3" +.\" +.\" $Id: describe.1,v 1.4 1997/09/24 06:34:58 gdr Exp $ +.\" +.TH DESCRIBE 1 "22 September 1997" GNO "Commands and Applications" .SH NAME describe \- show information about a program .SH SYNOPSIS -.BR describe " [" -hvV ] +.BR describe +[ +.BR -hvV +] .I program .SH DESCRIPTION +This manual page documents +.BR describe +version 1.0.4. +.LP .BR describe will show current information about .IR program . @@ -34,7 +44,8 @@ uses a database compiled by \fB-V\fR Show version information. .fi .SH FILES -/usr/local/lib/describe \- the system +.IP \fB/usr/lib/describe\fR +The system .B describe database. If the environment variable .B DESCDB @@ -44,8 +55,7 @@ is set, its value will be used instead. Full path to the system describe database. If .B DESCDB is set, its value is used instead of the default location -/usr/local/lib/describe. - +.BR /usr/lib/describe . .SH AUTHOR James Brookes . .SH "SEE ALSO" diff --git a/usr.orca.bin/describe/describe.c b/usr.orca.bin/describe/describe.c index b35bb04..a79cebe 100644 --- a/usr.orca.bin/describe/describe.c +++ b/usr.orca.bin/describe/describe.c @@ -2,22 +2,21 @@ * describe(1) -- Copyright 1993-1995 James Brookes. See the README and * man page for details. * - * We have to have this pragma in here; Orca/C's bit 5 optimization - * (loop invariant removal) kills code somewhere in this file, resulting - * in a system panic. + * Don't use ORCA/C's bit 5 (loop invariant removal) optimization; it + * kills code somewhere in this file, resulting in a system panic. + * + * $Id: describe.c,v 1.5 1997/09/24 06:34:58 gdr Exp $ */ -#pragma optimize 31 - #include #include #include #include -#include +#ifdef __GNO__ +#include +#endif #include "desc.h" -#define _VERSION_ "v1.0.3" - /* prototypes */ void usage(char *callname); @@ -101,8 +100,8 @@ void print_entry(FILE *FInPtr, long int index) { myprintf(buffer,75); free(buffer); -#ifdef STACK_CHECK - printf("Stack: %d\n",end_stack_check()); +#ifdef __STACK_CHECK__ + printf("Stack: %d\n", _endStackCheck()); #endif exit(0); } @@ -116,8 +115,8 @@ int main (int argc, char **argv) { char *p, *tmp; char *db_path; -#ifdef STACK_CHECK - begin_stack_check(); +#ifdef __STACK_CHECK__ + _beginStackCheck(); #endif verbose = FALSE; @@ -211,8 +210,8 @@ int main (int argc, char **argv) { } else { if (verbose) { printf("Found entry %s!\n",tmp); -#ifdef STACK_CHECK - printf("Stack: %d\n",end_stack_check()); +#ifdef __STACK_CHECK__ + printf("Stack: %d\n", _endStackCheck()); #endif free (db_path); free (tmp); @@ -227,8 +226,8 @@ int main (int argc, char **argv) { if (offset1 > offset2) { printf("Entry '%s' not found in describe database.\n",searchName); -#ifdef STACK_CHECK - printf("Stack: %d\n",end_stack_check()); +#ifdef __STACK_CHECK__ + printf("Stack: %d\n", _endStackCheck()); #endif free (db_path); free (tmp); diff --git a/usr.orca.bin/describe/describe.desc b/usr.orca.bin/describe/describe.desc index 8ecdb6a..3fc9b31 100644 --- a/usr.orca.bin/describe/describe.desc +++ b/usr.orca.bin/describe/describe.desc @@ -1,10 +1,10 @@ Name: describe -Version: 1.0.3 +Version: 1.0.4 Shell: ORCA/Shell, GNO/ME Author: James Brookes Contact: jamesb@ecst.csuchico.edu -Where: /usr/local/bin -FTP: ftp.cco.caltech.edu +Where: /usr/bin +FTP: apple2.caltech.edu, ground.isca.uiowa.edu, trenco.myrias.com Print a multi-line description obtained from the compiled 'describe' database; giving utility name, version, intended shell, author, author's diff --git a/usr.orca.bin/describe/describe.rez b/usr.orca.bin/describe/describe.rez new file mode 100644 index 0000000..f41f637 --- /dev/null +++ b/usr.orca.bin/describe/describe.rez @@ -0,0 +1,34 @@ +/* + * Resources for version and comment + * + * $Id: describe.rez,v 1.1 1997/09/24 06:34:58 gdr Exp $ + */ +#include "Types.rez" + +/* Don't forget to update the version numbers, below (two places) */ +#define PROG "describe" +#define DESC "program information database utility" +#define AUTHOR "Author: James Brookes " + +/* + * Version + */ +resource rVersion (1, purgeable3) { + { 1, 0, 4, /* Version 1.0.4 */ + release, /* development|alpha|beta|final|release */ + 0 }, /* non-final release number */ + verUS, /* Country */ + PROG, /* Program name */ + DESC " (GNO)" +}; + +/* + * Comment + */ +resource rComment (1, purgeable3) { + PROG " v1.0.4\n" + DESC " (GNO) \n" + AUTHOR +}; + + diff --git a/usr.orca.bin/describe/descu.8 b/usr.orca.bin/describe/descu.8 index e6faa41..23175a2 100644 --- a/usr.orca.bin/describe/descu.8 +++ b/usr.orca.bin/describe/descu.8 @@ -1,19 +1,36 @@ -.TH DESCU 8 "System Administration" "7 May 1995" "Version 1.0.3" +.\" +.\" $Id: descu.8,v 1.4 1997/09/24 06:34:58 gdr Exp $ +.\" +.TH DESCU 8 "22 September 1997" GNO "System Administration" .SH NAME descu \- the describe(1) source updater .SH SYNOPSIS -.BR descu " [" -hV ] +.BR descu +[ +.B -hV +] [ +.B -o +.I outfile +] .I sourcefile .I patchfile1 [ .IR patchfile2 " ..." ] .SH DESCRIPTION +This manual page documents +.BR descu +version 1.0.4. +.LP .BR descu updates the describe source file .I sourcefile by applying the new and updated records from the \fIpatchfile\fRs -and prints the result to standard output. +and prints the result to standard output (or to +.IR outfile , +if the +.BR -o +flag was specified). .LP .IR Patchfile s are just one or more describe source entries as defined in @@ -26,7 +43,7 @@ are assumed to contain at most one entry (in all listed .IR patchfile s) for a given program, keyed on the .BR Name: -field. If an entry in +field. (They may otherwise contain any number of entries.) If an entry in .IR patchfile is already in .IR sourcefile , @@ -43,13 +60,19 @@ in the current directory. This contains all records that were removed from .IR sourcefile . .SH OPTIONS -.nf -\fB-h\fR Show usage information. - -\fB-V\fR Show version information. -.fi +.IP \fB-h\fR +Show usage information. +.IP "\fB-o\fR \fIoutfile\fR" +Send output to +.IR outfile +rather than stdout. +.IP \fB-v\fR +Show version information. .SH AUTHOR Devin Reade +.SH HISTORY +.BR descu +was incorporated into the GNO base distribution as of version 1.0.4 .SH "SEE ALSO" .BR apropos (1), .BR describe (1), diff --git a/usr.orca.bin/describe/descu.c b/usr.orca.bin/describe/descu.c index 8bb23bc..fee2cad 100644 --- a/usr.orca.bin/describe/descu.c +++ b/usr.orca.bin/describe/descu.c @@ -1,20 +1,19 @@ /* * descu - describe(1) update utility for maintaining describe source files * - * Usage: descu [-hV] sourcefile patchfile1 [patchfile2 ...] + * Usage: descu [-hV] [-o outfile] sourcefile patchfile1 [patchfile2 ...] * * Options: - * -h show usage information and exit. - * -V show version information + * -h show usage information and exit. + * -o file send output to rather than stdout + * -V show version information * - * Copyright 1995 by Devin Reade for James Brookes' describe(1) utility. + * Copyright 1995-1997 by Devin Reade for James Brookes' describe(1) utility. * See the included README file and man page for details. * - * $Id: descu.c,v 1.3 1996/01/28 17:39:29 gdr Exp $ + * $Id: descu.c,v 1.4 1997/09/24 06:34:58 gdr Exp $ */ -#pragma optimize -1 - #include #include #include @@ -25,12 +24,13 @@ #include #include #include -#include +#ifdef __GNO__ +#include +#endif #include "desc.h" -#define _VERSION_ "v1.0.3" #define MAX_BUFFER 65534 -#define SLOTS_QUANTUM 20 +#define SLOTS_QUANTUM 64 #define REJECT_FILE "descu.rej" #ifndef __ORCAC__ @@ -67,7 +67,8 @@ int array2SlotsUsed=0; * On the Apple IIgs, CR's are also converted to LF's */ -char *inhale (char *pathname) { +char * +inhale (char *pathname) { char *buffer; long bytecount, bytes_read; ssize_t i; @@ -75,7 +76,7 @@ char *inhale (char *pathname) { /* open the file */ if ((fd = open(pathname,O_RDONLY))==-1) { - fprintf(stderr,"inhale: open of %s failed: %s\n", + fprintf(stderr,"Warning: open of %s failed: %s\n", pathname,strerror(errno)); return NULL; } @@ -83,14 +84,14 @@ char *inhale (char *pathname) { /* create the buffer */ bytecount = lseek(fd,(off_t) 0,SEEK_END); if (bytecount > MAX_BUFFER) { - fprintf(stderr,"descu internal error: cannot handle files greater" + fprintf(stderr,"descu internal error: cannot handle files greater " "than %d bytes\n due to a compiler bug. Sorry.\n", MAX_BUFFER); exit(-1); } lseek(fd,(off_t) 0, SEEK_SET); if ((buffer = malloc(bytecount+1))==NULL) { - fprintf(stderr,"inhale: malloc of %ld-byte buffer failed for file %s:%s\n", + fprintf(stderr,"error: malloc of %ld-byte buffer failed for file %s:%s\n", bytecount+1,pathname,strerror(errno)); close(fd); return NULL; @@ -101,7 +102,7 @@ char *inhale (char *pathname) { while (bytes_read < bytecount) { i = read(fd,&buffer[bytes_read],(size_t)bytecount-bytes_read); if (i==-1) { - fprintf(stderr,"inhale: read failed on file %s:%s\n", + fprintf(stderr,"error: read failed on file %s:%s\n", pathname,strerror(errno)); free(buffer); close(fd); @@ -137,7 +138,8 @@ char *inhale (char *pathname) { * between the parts. */ -descEntry *extract_info(char *source) { +descEntry * +extract_info(char *source) { char *p; descEntry *entry; @@ -172,7 +174,8 @@ descEntry *extract_info(char *source) { * add_entry -- add entry to the descTable, even if it already exists. */ -void add_entry(descEntry *entry, int initial_buffer) { +void +add_entry(descEntry *entry, int initial_buffer) { descEntry **e, ***array; int *slotsAlloced, *slotsUsed; @@ -220,12 +223,22 @@ void add_entry(descEntry *entry, int initial_buffer) { void insert(char *buffer, int initial_buffer) { char *p, *q; descEntry *entry; + static char *emptyString = ""; /* we may return this, so keep it static */ /* pull out the header (if nec) and init p */ if (initial_buffer) header = buffer; p = strstr(buffer,NAME_SHORT); - if(!p) return; /* buffer doesn't have any describe entries! */ - *(p-1)='\0'; + if (p == NULL) { + return; /* buffer doesn't have any describe entries! */ + } + if (initial_buffer) { + if (p == buffer) { + /* there is no header */ + header = NULL; + } else { + *(p-1)='\0'; + } + } /* add all but the last entry */ while ((q=strstr(p+1,NAME_SHORT))!=NULL) { @@ -237,7 +250,7 @@ void insert(char *buffer, int initial_buffer) { /* extract out the trailer and add the last entry */ if ((q = strstr(p,"\n#"))==NULL) { - if (initial_buffer) trailer=""; + if (initial_buffer) trailer=emptyString; } else { if (initial_buffer) trailer=q+1; *q = '\0'; @@ -260,9 +273,9 @@ void sortArray(descEntry **array, int slotsUsed) { int l, j, ir, i; descEntry *rra; - if (slotsUsed==1) return; /* no need to sort one element */ - --array; /* fudge since the algorithm was designed */ - /* for a unit-indexing */ + if (slotsUsed <= 1) return; /* no need to sort one element */ + --array; /* fudge since the algorithm was designed */ + /* for a unit-indexing */ l = (slotsUsed>>1) + 1; ir = slotsUsed; @@ -373,7 +386,7 @@ int ns_stricmp (char *a, char *b) { void version (char *progName) { fprintf(stderr, - "%s version %s Copyright 1995 Devin Reade\n" + "%s version %s Copyright 1995-1997 Devin Reade\n" "Freeware. See the manual page for copying restrictions.\n", progName,versionStr); return; @@ -390,9 +403,10 @@ void usage(char *progName) { if (!Vflag || errflag) { fprintf(stderr, "%s -- describe(1) source update utility\n" - "Usage: %s [-hV] sourcefile patchfile1 [patchfile2 ...]\n" - "\t-h\tshow usage information\n" - "\t-V\tshow version information\n\n", + "Usage: %s [-hV] [-o outfile] sourcefile patchfile1 [patchfile2 ...]\n" + "\t-h\t\tshow usage information\n" + "\t-o outfile\tsend output to rather than stdout\n" + "\t-V\t\tshow version information\n\n", progName,progName); } version(progName); @@ -406,13 +420,13 @@ void usage(char *progName) { int main(int argc, char **argv) { char *buffer; int i, j; - FILE *outfp, *rejfp; + FILE *outfp, *rejfp, *temp = NULL; int c; char *outputfile=NULL; int compare; -#ifdef STACK_CHECK - begin_stack_check(); +#ifdef __STACK_CHECK__ + _beginStackCheck(); #endif /* initialize */ @@ -443,28 +457,43 @@ int main(int argc, char **argv) { /* show version info */ if (Vflag) version(basename(argv[0])); - /* open output (if nec) and reject file */ + /* + * open output file if necessary. If the output filename matches + * that of the first input file, then dump stuff to a temporary file. + */ if (oflag) { - if ((outfp = fopen(outputfile,"w+"))==NULL) { - perror("main: couldn't open output file"); - exit(1); + if (!strcmp(outputfile, argv[optind])) { + if ((outfp = tmpfile()) == NULL) { + perror("unable to open temporary file"); + exit(1); + } + temp = outfp; + } else { + if ((outfp = fopen(outputfile,"w+")) == NULL) { + perror("couldn't open output file"); + exit(1); + } } } else { outfp = stdout; } + + /* open the rejects file */ if ((rejfp = fopen(REJECT_FILE,"w+"))==NULL) { - perror("main: couldn't open rejects file"); + perror("couldn't open rejects file"); exit(1); } /* read in original describe source file */ - buffer = inhale(argv[optind]); - insert(buffer,1); + if ((buffer = inhale(argv[optind])) != NULL) { + insert(buffer,1); + } /* insert describe patch files */ for (optind++; optind 0) { + fwrite(buf, 1, count, outfp); + } + fclose(temp); + } + fclose(outfp); + } + +#ifdef __STACK_CHECK__ + fprintf(stderr,"stack usage: %d bytes\n", _endStackCheck()); #endif return 0; diff --git a/usr.orca.bin/describe/descu.desc b/usr.orca.bin/describe/descu.desc index 43f4338..2cb0291 100644 --- a/usr.orca.bin/describe/descu.desc +++ b/usr.orca.bin/describe/descu.desc @@ -1,10 +1,9 @@ Name: descu -Version: 1.0.3 +Version: 1.0.4 Shell: ORCA/Shell, GNO/ME Author: Devin Reade Contact: gdr@myrias.ab.ca Where: /usr/sbin -FTP: ftp.cco.caltech.edu +FTP: apple2.caltech.edu, ground.isca.uiowa.edu, trenco.myrias.com Update a 'describe' source file. - diff --git a/usr.orca.bin/describe/descu.rez b/usr.orca.bin/describe/descu.rez new file mode 100644 index 0000000..e44a3d1 --- /dev/null +++ b/usr.orca.bin/describe/descu.rez @@ -0,0 +1,34 @@ +/* + * Resources for version and comment + * + * $Id: descu.rez,v 1.1 1997/09/24 06:34:59 gdr Exp $ + */ +#include "Types.rez" + +/* Don't forget to update the version numbers, below (two places) */ +#define PROG "descu" +#define DESC "describe(1) source updater" +#define AUTHOR "Author: Devin Reade " + +/* + * Version + */ +resource rVersion (1, purgeable3) { + { 1, 0, 4, /* Version 1.0.4 */ + release, /* development|alpha|beta|final|release */ + 0 }, /* non-final release number */ + verUS, /* Country */ + PROG, /* Program name */ + DESC " (GNO)" +}; + +/* + * Comment + */ +resource rComment (1, purgeable3) { + PROG " v1.0.4\n" + DESC " (GNO) \n" + AUTHOR +}; + + diff --git a/usr.orca.bin/describe/makefile.mk b/usr.orca.bin/describe/makefile.mk deleted file mode 100644 index 30dd0fd..0000000 --- a/usr.orca.bin/describe/makefile.mk +++ /dev/null @@ -1,44 +0,0 @@ -# -# This is the makefile for the describe(1) package. It is for use -# with dmake(1). -# - -# Use -DSTACK_CHECK in CFLAGS to show stack usage. - -CFLAGS += -O -v -I/usr/include -s768 -LDFLAGS += -v -LDLIBS += -BINDIR = /usr/local/bin -SBINDIR = /usr/sbin -MANDIR = /usr/man -INSTALL = /bin/cp - -build: describe descc descu - -descc: descc.o basename.o descc.r - @purge - $(CC) $(LDFLAGS) descc.o basename.o -o $@ $(LDLIBS) - copyfork descc.r descc - -describe: describe.o basename.o describe.r - @purge - $(CC) $(LDFLAGS) describe.o basename.o -o $@ $(LDLIBS) - copyfork describe.r describe - -descu: descu.o basename.o vaend.o descu.r - @purge - $(CC) $(LDFLAGS) descu.o basename.o vaend.o -o $@ $(LDLIBS) - copyfork descu.r descu - -descc.o:: desc.h -describe.o:: desc.h -descu.o:: desc.h - -install: - $(RM) -f /usr/local/bin/descc - $(INSTALL) describe $(BINDIR) - $(INSTALL) descc $(SBINDIR) - $(INSTALL) descu $(SBINDIR) - $(INSTALL) describe.1 $(MANDIR)/man1 - $(INSTALL) descc.8 $(MANDIR)/man8 - $(INSTALL) descu.8 $(MANDIR)/man8