Clean up deleted files.
This commit is contained in:
parent
571aba5ed9
commit
6c5fe93efb
@ -1,249 +0,0 @@
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 1, February 1989
|
||||
|
||||
Copyright (C) 1989 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.
|
||||
|
||||
Preamble
|
||||
|
||||
The license agreements of most software companies try to keep users
|
||||
at the mercy of those companies. By contrast, our 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. The
|
||||
General Public License applies to the Free Software Foundation's
|
||||
software and to any other program whose authors commit to using it.
|
||||
You can use it for your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Specifically, the General Public License is designed to make
|
||||
sure that you have the freedom to give away or sell copies of free
|
||||
software, 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 a 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 tell them 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.
|
||||
|
||||
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 Agreement 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 work containing the
|
||||
Program or a portion of it, either verbatim or with modifications. Each
|
||||
licensee is addressed as "you".
|
||||
|
||||
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
|
||||
General Public License and to the absence of any warranty; and give any
|
||||
other recipients of the Program a copy of this General Public License
|
||||
along with the Program. You may charge a fee for the physical act of
|
||||
transferring a copy.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of
|
||||
it, and copy and distribute such modifications under the terms of Paragraph
|
||||
1 above, provided that you also do the following:
|
||||
|
||||
a) cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change; and
|
||||
|
||||
b) cause the whole of any work that you distribute or publish, that
|
||||
in whole or in part contains the Program or any part thereof, either
|
||||
with or without modifications, to be licensed at no charge to all
|
||||
third parties under the terms of this General Public License (except
|
||||
that you may choose to grant warranty protection to some or all
|
||||
third parties, at your option).
|
||||
|
||||
c) If the modified program normally reads commands interactively when
|
||||
run, you must cause it, when started running for such interactive use
|
||||
in the simplest and most usual 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 General
|
||||
Public License.
|
||||
|
||||
d) 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.
|
||||
|
||||
Mere aggregation of another independent work with the Program (or its
|
||||
derivative) on a volume of a storage or distribution medium does not bring
|
||||
the other work under the scope of these terms.
|
||||
|
||||
3. You may copy and distribute the Program (or a portion or derivative of
|
||||
it, under Paragraph 2) in object code or executable form under the terms of
|
||||
Paragraphs 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
|
||||
Paragraphs 1 and 2 above; or,
|
||||
|
||||
b) accompany it with a written offer, valid for at least three
|
||||
years, to give any third party free (except for a nominal charge
|
||||
for the cost of distribution) a complete machine-readable copy of the
|
||||
corresponding source code, to be distributed under the terms of
|
||||
Paragraphs 1 and 2 above; or,
|
||||
|
||||
c) accompany it with the information you received as to where the
|
||||
corresponding source code may be obtained. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form alone.)
|
||||
|
||||
Source code for a work means the preferred form of the work for making
|
||||
modifications to it. For an executable file, complete source code means
|
||||
all the source code for all modules it contains; but, as a special
|
||||
exception, it need not include source code for modules which are standard
|
||||
libraries that accompany the operating system on which the executable
|
||||
file runs, or for standard header files or definitions files that
|
||||
accompany that operating system.
|
||||
|
||||
4. You may not copy, modify, sublicense, distribute or transfer the
|
||||
Program except as expressly provided under this General Public License.
|
||||
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
|
||||
the Program is void, and will automatically terminate your rights to use
|
||||
the Program under this License. However, parties who have received
|
||||
copies, or rights to use copies, from you under this General Public
|
||||
License will not have their licenses terminated so long as such parties
|
||||
remain in full compliance.
|
||||
|
||||
5. By copying, distributing or modifying 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.
|
||||
|
||||
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.
|
||||
|
||||
7. 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 the 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
|
||||
the license, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
8. 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
|
||||
|
||||
9. 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.
|
||||
|
||||
10. 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
|
||||
|
||||
Appendix: 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 humanity, 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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <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 1, 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.
|
||||
|
||||
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) 19xx 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 a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
program `Gnomovision' (a program to direct compilers to make passes
|
||||
at assemblers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
@ -1,194 +0,0 @@
|
||||
Thu Aug 8 00:15:33 1991 David J. MacKenzie (djm at bleen)
|
||||
|
||||
* Version 1.08.
|
||||
|
||||
* sed.c (compile_filename): If reading a file fails, read
|
||||
/dev/null instead. It's what Unix and POSIX do, effectively.
|
||||
|
||||
* sed.c (compile_regex): The 'slash' character doesn't
|
||||
terminate the regex if it's in a character class.
|
||||
|
||||
* sed.c (main): If given no args, or bad option, print usage
|
||||
message.
|
||||
(usage): New function.
|
||||
|
||||
* sed.c (execute_program): Amount written for 'P' command was
|
||||
wrong. From stephend@ksr.com (Stephen Davis).
|
||||
|
||||
Wed Aug 7 16:51:14 1991 David J. MacKenzie (djm at apple-gunkies)
|
||||
|
||||
* sed.c (append_pattern_space): Check for buffer full before
|
||||
instead of after writing to buffer. Don't need to test for
|
||||
EOF initially anymore, due to the next change.
|
||||
(execute_program): For 'n' and 'N' commands, if eof is reached
|
||||
in input, quit the script like Unix sed does.
|
||||
Fix memory allocation problems for 'a' and 'r' commands.
|
||||
(compile_program): Fix off by one error in processing comments.
|
||||
All of the above are from Tapani Tarvainen, tarvaine@tukki.jyu.fi.
|
||||
|
||||
* sed.c (setup_jump): Use isblank instead of testing for ' '
|
||||
or '\t', for POSIX locales.
|
||||
|
||||
* utils.c (ck_strdup): Renamed from strdup.
|
||||
* sed.c: Change callers.
|
||||
|
||||
* sed.c, utils.c: Clean up declarations and includes to get
|
||||
rid of compiler warnings.
|
||||
|
||||
* sed.c (main): Add long-named options. Don't complain if -n
|
||||
is given twice.
|
||||
|
||||
Fri Aug 2 12:33:16 1991 David J. MacKenzie (djm at apple-gunkies)
|
||||
|
||||
* configure: Support +srcdir arg. Create config.status and
|
||||
remove it and Makefile if interrupted while creating them.
|
||||
* Makefile.in: Change DESTDIR to prefix.
|
||||
|
||||
Mon Jul 15 13:07:39 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu)
|
||||
|
||||
* sed.c (main): Add -V option to print version number.
|
||||
(USAGE): Mention -V.
|
||||
|
||||
Mon Jul 8 01:42:22 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
|
||||
|
||||
* sed.c: Define bcopy in terms of memcpy if STDC_HEADERS as
|
||||
well as if USG.
|
||||
(compile_filename): Don't glob filename (for 'r' and 'w'
|
||||
commands). Unix sed doesn't do it and it's not very useful,
|
||||
since it can only match 0 or 1 files.
|
||||
(execute_program): Change '\a' to 007 since some compilers
|
||||
don't recognize \a.
|
||||
* utils.c: New file; code moved from sed.c.
|
||||
* Replace Makefile with Makefile.in and configure.
|
||||
Update README.
|
||||
|
||||
Tue Mar 26 13:00:48 EST 1991 Jay Fenlason (hack@gnu.ai.mit.edu)
|
||||
|
||||
* sed.c (match_address) Added a trivial cast for portability.
|
||||
|
||||
Mon Feb 25 13:23:29 EST 1991 Jay Fenlason (hack@ai.mit.edu)
|
||||
|
||||
* sed.c Changed 's' command to work with latest version of regex()
|
||||
routines, which mysteriously changed somewhere in there. . .
|
||||
A one-line patch from David Eckelkamp (eckelkamp@mcc.com).
|
||||
|
||||
Initialize the fastmap in the hopes that it'll make sed faster.
|
||||
|
||||
Thu Feb 21 13:42:27 EST 1991 Jay Fenlason (hack@ai.mti.edu)
|
||||
|
||||
* sed.c Change panic to compile with other __STDC__ compilers.
|
||||
|
||||
Wed Jan 30 10:46:38 EST 1991 Jay Fenlason (hack@ai.mit.edu)
|
||||
|
||||
* sed.c Changed version number. Made new release.
|
||||
|
||||
Tue Nov 27 15:34:51 EST 1990 Jay Fenlason (hack@ai.mit.edu)
|
||||
|
||||
* sed.c (setup_jump) Don't blow chunks if there isn't a label
|
||||
after a b or t command.
|
||||
|
||||
(main) Don't panic if it a branch command doesn't have
|
||||
a label to branch to.
|
||||
|
||||
(main) Collect all the -e arguments together and parse them
|
||||
all at once. This way, -e { -e mumble -e } will work.
|
||||
|
||||
All these small patches from David Schmidt (davids@isc-br.isc-br.com)
|
||||
|
||||
Tue Sep 11 12:51:37 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
|
||||
|
||||
* sed.c Changed some function forward declarations to use VOID *
|
||||
instead of char *
|
||||
|
||||
Mon Jul 16 11:12:54 EDT 1990 Jay Fenlason (hack@ai.mit.edu)
|
||||
|
||||
* sed.c (ck_malloc) Use malloc(1) instead of malloc(0) if given
|
||||
a request for zero bytes.
|
||||
|
||||
Tue Jun 5 02:05:37 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
|
||||
|
||||
* sed.c: Remove excess newlines from calls to panic.
|
||||
Reformat some comments to fit in 79 columns.
|
||||
Base whether to use void * on __STDC__, not __GNU__.
|
||||
(main): Add missing arg when printing usage message.
|
||||
Print usage if given invalid arg.
|
||||
(panic) [__STDC__]: Add missing ", ...".
|
||||
(compile_filename): Print correct error message if glob_filename
|
||||
returns NULL.
|
||||
|
||||
Thu Apr 5 21:41:12 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
|
||||
|
||||
* sed.c (execute_program, case 'r'): When need to realloc append.text,
|
||||
multiply append.alloc by 2 instead of adding
|
||||
cur_cmd->x.cmd_txt.text_len.
|
||||
|
||||
Tue Mar 6 15:55:35 EST 1990 Jay Fenlason (hack@ai.mit.edu)
|
||||
|
||||
* sed.c (compile_regex) Allocate 10 bytes extra space needed by
|
||||
re_compile_pattern.
|
||||
|
||||
Sun Feb 25 16:32:10 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
|
||||
|
||||
* sed.c (execute_program, case 'l'): Print \00 instead of \0.
|
||||
Print backslash as \\ not \.
|
||||
Print \xx instead of /xx.
|
||||
|
||||
Thu Feb 1 14:02:28 EST 1990 hack@wookumz
|
||||
|
||||
* sed.c (memchr) Use () inside inner loop so it will work correctly.
|
||||
A two character patch from Robert A Bruce (rab@allspice.berkeley.edu)
|
||||
|
||||
Wed Sep 27 18:47:39 EDT 1989 hack@ai.mit.edu
|
||||
|
||||
* sed.c (compile_regex) New function. When compiling regex,
|
||||
turn ^ into \` and $ into \' so that they won't match on embedded
|
||||
newlines. UN*X pattern matching is a crock.
|
||||
(compile_program, compile_address) call compile_regex.
|
||||
|
||||
Mon Sep 18 10:15:32 EDT 1989 hack@ai.mit.edu
|
||||
|
||||
* sed.c (compile_program): define translate as unsigned char * so
|
||||
that y command will work on non-ascii characters.
|
||||
|
||||
Changed version number to 1.06.
|
||||
|
||||
Thu Sep 14 15:57:08 EDT 1989 hack@ai.mit.edu
|
||||
|
||||
* sed.c (compile_program) Let programs use ; to terminate } as
|
||||
well as newline.
|
||||
|
||||
(read_file) Print an error msg to stderr if it can't open an
|
||||
input file.
|
||||
|
||||
Thu Mar 23 18:04:46 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu)
|
||||
|
||||
* Makefile, sed.c: Added new copyright notice.
|
||||
|
||||
* Makefile: Make distributions which follow the symlinks.
|
||||
|
||||
hack@ai.mit.edu
|
||||
|
||||
1.05 Fixed error in 'r' (now does things in the right order)
|
||||
|
||||
1.04 Fixed s/re/rep/[number]
|
||||
|
||||
1.03 Fixes from Mike Haertel for regexps that match the
|
||||
empty string, and for Ritchie stdio (non-sticky EOF)
|
||||
|
||||
1.02 Fixed 't', 'b', ':' to trim leading spaces and tabs
|
||||
Fixed \\ in replacement of 's' command
|
||||
Added comments
|
||||
|
||||
1.01 Added s/re/rep/[digits]
|
||||
added #n as first line of script
|
||||
added filename globbing
|
||||
added 'l' command
|
||||
All in the name of POSIX
|
||||
|
||||
1.00 Began (thinking about) distributing this file
|
||||
|
||||
Local Variables:
|
||||
mode: indented-text
|
||||
left-margin: 8
|
||||
version-control: never
|
||||
End:
|
@ -1,84 +0,0 @@
|
||||
# Generated automatically from Makefile.in by configure.
|
||||
# Makefile for GNU SED, a batch editor.
|
||||
# Copyright (C) 1987-1991 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU SED.
|
||||
#
|
||||
# GNU SED 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.
|
||||
#
|
||||
# GNU SED 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 GNU SED; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = .
|
||||
|
||||
|
||||
CC = gcc -O
|
||||
INSTALL = install -c
|
||||
|
||||
# Things you might add to DEFS:
|
||||
# -DSTDC_HEADERS If you have ANSI C headers and libraries.
|
||||
# -DUSG If you have System V/ANSI C string
|
||||
# and memory functions and headers.
|
||||
# -DCHAR_UNSIGNED If type `char' is unsigned.
|
||||
# -DNO_VFPRINTF If you lack vprintf function (but have _doprnt).
|
||||
|
||||
DEFS =
|
||||
LIBS =
|
||||
|
||||
CFLAGS = -I$(srcdir) $(DEFS)
|
||||
LDFLAGS =
|
||||
|
||||
prefix = /usr/local
|
||||
|
||||
# Where to install the executable.
|
||||
bindir = $(prefix)/gnubin
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
OBJS = sed.o utils.o regex.o getopt.o getopt1.o
|
||||
SRCS = sed.c utils.c regex.c getopt.c getopt1.c
|
||||
DISTFILES = COPYING ChangeLog README Makefile.in configure \
|
||||
regex.h getopt.h $(SRCS)
|
||||
|
||||
all: sed
|
||||
|
||||
sed: $(OBJS)
|
||||
$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
|
||||
sed.o regex.o: regex.h
|
||||
sed.o getopt1.o: getopt.h
|
||||
|
||||
install: all
|
||||
$(INSTALL) sed $(bindir)
|
||||
|
||||
TAGS: $(SRCS)
|
||||
etags $(SRCS)
|
||||
|
||||
clean:
|
||||
rm -f sed $(OBJS) core
|
||||
|
||||
distclean: clean
|
||||
rm -f TAGS Makefile config.status
|
||||
|
||||
realclean: distclean
|
||||
|
||||
dist: $(DISTFILES)
|
||||
echo sed-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q sed.c` > .fname
|
||||
rm -rf `cat .fname`
|
||||
mkdir `cat .fname`
|
||||
ln $(DISTFILES) `cat .fname`
|
||||
tar chZf `cat .fname`.tar.Z `cat .fname`
|
||||
rm -rf `cat .fname` .fname
|
@ -1,10 +0,0 @@
|
||||
|
||||
PROG= sed
|
||||
SRCS= sed.c utils.c regex.c getopt.c getopt1.c
|
||||
CFLAGS+=-I${.CURDIR} # -DSTDC_HEADERS
|
||||
NOMAN=noman
|
||||
|
||||
sed.o regex.o: regex.h
|
||||
sed.o getopt1.o: getopt.h
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,48 +0,0 @@
|
||||
This directory contains GNU sed. Please report all bugs and comments
|
||||
to bug-gnu-utils@prep.ai.mit.edu.
|
||||
|
||||
This sed may run slower than some UN*X seds. This is because it uses
|
||||
the regular-expression routines from Emacs, which are rather complete
|
||||
and powerful, but not as fast as they could be. If you really care
|
||||
about speed, use perl instead.
|
||||
|
||||
To compile:
|
||||
|
||||
1. Type `sh configure'. This shell script attempts to guess correct
|
||||
values for various system-dependent variables used during compilation,
|
||||
and creates the file `Makefile'. This takes a minute or so.
|
||||
|
||||
If you want to compile in a different directory from the one
|
||||
containing the source code, `cd' to that directory and run `configure'
|
||||
with the option `+srcdir=DIR', where DIR is the directory that
|
||||
contains the source code. The object files and executables will be
|
||||
put in the current directory. This option only works with versions of
|
||||
`make' that support the VPATH variable. `configure' ignores any other
|
||||
arguments you give it.
|
||||
|
||||
If your system requires unusual options for compilation or linking
|
||||
that `configure' doesn't know about, you can give `configure' initial
|
||||
values for variables by setting them in the environment; in
|
||||
Bourne-compatible shells, you can do that on the command line like
|
||||
this:
|
||||
$ CC='gcc -traditional' LIBS=-lposix sh configure
|
||||
|
||||
2. If you want to change the directories where the program will be
|
||||
installed, or the optimization options, edit `Makefile' and change
|
||||
those values. If you have an unusual system that needs special
|
||||
compilation options that `configure' doesn't know about, and you
|
||||
didn't pass them in the environment when running `configure', you
|
||||
should add them to `Makefile' now. Alternately, teach `configure' how
|
||||
to figure out that it is being run on a system where they are needed,
|
||||
and mail the diffs to the address listed at the top of this file so we
|
||||
can include them in the next release.
|
||||
|
||||
3. Type `make'.
|
||||
|
||||
4. If the program compiles successfully, type `make install' to
|
||||
install it.
|
||||
|
||||
5. After you have installed the program, you can remove the binary
|
||||
from the source directory by typing `make clean'. Type `make
|
||||
distclean' if you also want to remove `Makefile', for instance if you
|
||||
are going to recompile sed next on another type of machine.
|
@ -1,594 +0,0 @@
|
||||
/* Getopt for GNU.
|
||||
Copyright (C) 1987, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else /* not __GNUC__ */
|
||||
#ifdef sparc
|
||||
#include <alloca.h>
|
||||
#else
|
||||
#ifdef _AIX
|
||||
#pragma alloca
|
||||
#else
|
||||
char *alloca ();
|
||||
#endif
|
||||
#endif /* sparc */
|
||||
#endif /* not __GNUC__ */
|
||||
|
||||
#ifndef __STDC__
|
||||
#define const
|
||||
#endif
|
||||
|
||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||
but it behaves differently for the user, since it allows the user
|
||||
to intersperse the options with the other arguments.
|
||||
|
||||
As `getopt' works, it permutes the elements of `argv' so that,
|
||||
when it is done, all the options precede everything else. Thus
|
||||
all application programs are extended to handle flexible argument order.
|
||||
|
||||
Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
|
||||
Then the behavior is completely standard.
|
||||
|
||||
GNU application programs can use a third alternative mode in which
|
||||
they can distinguish the relative order of options and other arguments. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
|
||||
#include <stdlib.h>
|
||||
#else /* STDC_HEADERS or __GNU_LIBRARY__ */
|
||||
char *getenv ();
|
||||
char *malloc ();
|
||||
#endif /* STDC_HEADERS or __GNU_LIBRARY__ */
|
||||
|
||||
#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
|
||||
#include <string.h>
|
||||
#define bcopy(s, d, n) memcpy ((d), (s), (n))
|
||||
#define index strchr
|
||||
#else /* USG or STDC_HEADERS or __GNU_LIBRARY__ */
|
||||
#ifdef VMS
|
||||
#include <string.h>
|
||||
#else /* VMS */
|
||||
#include <strings.h>
|
||||
#endif /* VMS */
|
||||
/* Declaring bcopy causes errors on systems whose declarations are different.
|
||||
If the declaration is omitted, everything works fine. */
|
||||
#endif /* USG or STDC_HEADERS or __GNU_LIBRARY__ */
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
char *optarg = 0;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
int optind = 0;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
|
||||
static char *nextchar;
|
||||
|
||||
/* Callers store zero here to inhibit the error message
|
||||
for unrecognized options. */
|
||||
|
||||
int opterr = 1;
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
_POSIX_OPTION_ORDER is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable _POSIX_OPTION_ORDER, or using `+' as the first character
|
||||
of the list of option characters.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we scan,
|
||||
so that eventually all the non-options are at the end. This allows options
|
||||
to be given in any order, even with programs that were not written to
|
||||
expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were written
|
||||
to expect options and other ARGV-elements in any order and that care about
|
||||
the ordering of the two. We describe each non-option ARGV-element
|
||||
as if it were the argument of an option with character code 1.
|
||||
Using `-' as the first character of the list of option characters
|
||||
selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
|
||||
|
||||
static enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} ordering;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
_GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an
|
||||
element containing a name which is zero.
|
||||
The field `has_arg' is 1 if the option takes an argument,
|
||||
2 if it takes an optional argument. */
|
||||
|
||||
struct option
|
||||
{
|
||||
char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
const struct option *_getopt_long_options;
|
||||
|
||||
int _getopt_long_only = 0;
|
||||
|
||||
/* Index in _GETOPT_LONG_OPTIONS of the long-named option actually found.
|
||||
Only valid when a long-named option was found. */
|
||||
|
||||
int option_index;
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
||||
`last_nonopt' is the index after the last of them. */
|
||||
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt)
|
||||
which contains all the non-options that have been skipped so far.
|
||||
The other is elements [last_nonopt,optind), which contains all
|
||||
the options processed since those non-options were skipped.
|
||||
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved. */
|
||||
|
||||
static void
|
||||
exchange (argv)
|
||||
char **argv;
|
||||
{
|
||||
int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
|
||||
char **temp = (char **) alloca (nonopts_size);
|
||||
|
||||
/* Interchange the two blocks of data in ARGV. */
|
||||
|
||||
bcopy (&argv[first_nonopt], temp, nonopts_size);
|
||||
bcopy (&argv[last_nonopt], &argv[first_nonopt],
|
||||
(optind - last_nonopt) * sizeof (char *));
|
||||
bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size);
|
||||
|
||||
/* Update records for the slots the non-options now occupy. */
|
||||
|
||||
first_nonopt += (optind - last_nonopt);
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING.
|
||||
|
||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
||||
then it is an option element. The characters of this element
|
||||
(aside from the initial '-') are option characters. If `getopt'
|
||||
is called repeatedly, it returns successively each of the option characters
|
||||
from each of the option elements.
|
||||
|
||||
If `getopt' finds another option character, it returns that character,
|
||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
||||
resume the scan with the following option character or ARGV-element.
|
||||
|
||||
If there are no more option characters, `getopt' returns `EOF'.
|
||||
Then `optind' is the index in ARGV of the first ARGV-element
|
||||
that is not an option. (The ARGV-elements have been permuted
|
||||
so that those that are not options now come last.)
|
||||
|
||||
OPTSTRING is a string containing the legitimate option characters.
|
||||
If an option character is seen that is not listed in OPTSTRING,
|
||||
return '?' after printing an error message. If you set `opterr' to
|
||||
zero, the error message is suppressed but we still return '?'.
|
||||
|
||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
||||
so the following text in the same ARGV-element, or the text of the following
|
||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
||||
wants an optional arg; if there is text in the current ARGV-element,
|
||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
||||
|
||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
||||
handling the non-option ARGV-elements.
|
||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
||||
|
||||
Long-named options begin with `+' instead of `-'.
|
||||
Their names may be abbreviated as long as the abbreviation is unique
|
||||
or is an exact match for some defined option. If they have an
|
||||
argument, it follows the option name in the same ARGV-element, separated
|
||||
from the option name by a `=', or else the in next ARGV-element.
|
||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
||||
`flag' field is nonzero, the value of the option's `val' field
|
||||
otherwise. */
|
||||
|
||||
int
|
||||
getopt (argc, argv, optstring)
|
||||
int argc;
|
||||
char **argv;
|
||||
const char *optstring;
|
||||
{
|
||||
optarg = 0;
|
||||
|
||||
/* Initialize the internal data when the first call is made.
|
||||
Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||
is the program name); the sequence of previously skipped
|
||||
non-option ARGV-elements is empty. */
|
||||
|
||||
if (optind == 0)
|
||||
{
|
||||
first_nonopt = last_nonopt = optind = 1;
|
||||
|
||||
nextchar = 0;
|
||||
|
||||
/* Determine how to handle the ordering of options and nonoptions. */
|
||||
|
||||
if (optstring[0] == '-')
|
||||
{
|
||||
ordering = RETURN_IN_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (optstring[0] == '+')
|
||||
{
|
||||
ordering = REQUIRE_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (getenv ("_POSIX_OPTION_ORDER") != 0)
|
||||
ordering = REQUIRE_ORDER;
|
||||
else
|
||||
ordering = PERMUTE;
|
||||
}
|
||||
|
||||
if (nextchar == 0 || *nextchar == 0)
|
||||
{
|
||||
if (ordering == PERMUTE)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange (argv);
|
||||
else if (last_nonopt != optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
/* Now skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optind < argc
|
||||
&& (argv[optind][0] != '-'
|
||||
|| argv[optind][1] == 0)
|
||||
&& (_getopt_long_options == 0
|
||||
|| argv[optind][0] != '+'
|
||||
|| argv[optind][1] == 0))
|
||||
optind++;
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* Special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option,
|
||||
then exchange with previous non-options as if it were an option,
|
||||
then skip everything else like a non-option. */
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
||||
{
|
||||
optind++;
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange (argv);
|
||||
else if (first_nonopt == last_nonopt)
|
||||
first_nonopt = optind;
|
||||
last_nonopt = argc;
|
||||
|
||||
optind = argc;
|
||||
}
|
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == 0)
|
||||
&& (_getopt_long_options == 0
|
||||
|| argv[optind][0] != '+' || argv[optind][1] == 0))
|
||||
{
|
||||
if (ordering == REQUIRE_ORDER)
|
||||
return EOF;
|
||||
optarg = argv[optind++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Start decoding its characters. */
|
||||
|
||||
nextchar = argv[optind] + 1;
|
||||
}
|
||||
|
||||
if (_getopt_long_options != 0
|
||||
&& (argv[optind][0] == '+'
|
||||
|| (_getopt_long_only && argv[optind][0] == '-'))
|
||||
)
|
||||
{
|
||||
const struct option *p;
|
||||
char *s = nextchar;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
const struct option *pfound = 0;
|
||||
int indfound;
|
||||
|
||||
while (*s && *s != '=')
|
||||
s++;
|
||||
|
||||
/* Test all options for either exact match or abbreviated matches. */
|
||||
for (p = _getopt_long_options, option_index = 0; p->name;
|
||||
p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, s - nextchar))
|
||||
{
|
||||
if (s - nextchar == strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == 0)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (pfound != 0)
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*s)
|
||||
{
|
||||
if (pfound->has_arg > 0)
|
||||
optarg = s + 1;
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
/* Can't find it as a long option. If this is getopt_long_only,
|
||||
and the option starts with '-' and is a valid short
|
||||
option, then interpret it as a short option. Otherwise it's
|
||||
an error. */
|
||||
if (_getopt_long_only == 0 || argv[optind][0] == '+' ||
|
||||
index (optstring, *nextchar) == 0)
|
||||
{
|
||||
if (opterr != 0)
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next option-character. */
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = index (optstring, c);
|
||||
|
||||
/* Increment `optind' when we start to process its last character. */
|
||||
if (*nextchar == 0)
|
||||
optind++;
|
||||
|
||||
if (temp == 0 || c == ':')
|
||||
{
|
||||
if (opterr != 0)
|
||||
{
|
||||
if (c < 040 || c >= 0177)
|
||||
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
|
||||
argv[0], c);
|
||||
else
|
||||
fprintf (stderr, "%s: unrecognized option `-%c'\n",
|
||||
argv[0], c);
|
||||
}
|
||||
return '?';
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != 0)
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = 0;
|
||||
nextchar = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != 0)
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr != 0)
|
||||
fprintf (stderr, "%s: option `-%c' requires an argument\n",
|
||||
argv[0], c);
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = 0;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
/* Compile with -DTEST to make an executable for use in testing
|
||||
the above definition of `getopt'. */
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
|
||||
c = getopt (argc, argv, "abc:d:0123456789");
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
Loading…
Reference in New Issue
Block a user