libc-19980601: spurious use of __errno_location
Matthias Urlichs
smurf@work.noris.de
Wed Jun 3 23:19:00 GMT 1998
drepper@cygnus.com (Ulrich Drepper) writes:
>
> I've applied the changes. But please don't generate patches using cvs
> diff in future. They are not usable due to these stupid CVS
> restrictions. The file name are not complete.
>
Of course the file names are complete. In the "Index:" line, they are,
which is all that should matter.
Since I hate that too, here's a patch to patch patch with. ;-)
It adds an "-I" (or --prefer-index) option which does exactly that.
I even remembered to update the documentation...
If anybody wants to forward this hack to whoever maintains patch at the
moment, feel free.
Index: pch.c
--- pch.c.orig Thu, 04 Dec 1997 09:52:04 +0100 smurf (gnu_patch/6_pch.c 1.1.1.4 444) base.5
+++ pch.c Fri, 23 Jan 1998 09:01:52 +0100 smurf (gnu_patch/6_pch.c 1.1.1.5 664) noris.5
@@ -469,6 +469,8 @@
if either the old and new names are both absent
or posixly_correct is nonzero.
Consider the file names to be in the order (old, new, index).
+ If 'preferindex' is set, use (index) if it's set, otherwise
+ use (old, new).
- If some named files exist, use the first one if posixly_correct
is nonzero, the best one otherwise.
- If patch_get is nonzero, and no named files exist,
@@ -487,12 +489,27 @@
{
enum nametype i0 = NONE;
- if (! posixly_correct && (name[OLD] || name[NEW]) && name[INDEX])
+ if (name[INDEX])
{
- free (name[INDEX]);
- name[INDEX] = 0;
+ if (preferindex)
+ {
+ if (name[OLD])
+ {
+ free (name[OLD]);
+ name[OLD] = 0;
+ }
+ if (name[NEW])
+ {
+ free (name[NEW]);
+ name[NEW] = 0;
+ }
+ }
+ else if (! posixly_correct && (name[OLD] || name[NEW]))
+ {
+ free (name[INDEX]);
+ name[INDEX] = 0;
+ }
}
-
for (i = OLD; i <= INDEX; i++)
if (name[i])
{
Index: patch.man
--- patch.man.orig Thu, 04 Dec 1997 09:52:04 +0100 smurf (gnu_patch/8_patch.man 1.1.1.4 444) base.5
+++ patch.man Fri, 23 Jan 1998 09:01:52 +0100 smurf (gnu_patch/8_patch.man 1.1.1.5 664) noris.5
@@ -371,6 +371,20 @@
.BR \- ,
read from standard input, the default.
.TP
+\fB\-I\fP or \fB\*=prefer\-index\fP
+Prefer the file name from the "Index:" header within the patch if it's
+present, i.e. totally ignore the "old" and "new" file names.
+.Sp
+This option is useful if the patch file was generated by emitting an
+.IR Index:
+line with the correct file name and then feeding two temporary
+files to
+.I diff
+since old versions of
+.I diff
+cannot easily be convinced to replace the file names in the header of the
+patch.
+.TP
\fB\-l\fP or \fB\*=ignore\-whitespace\fP
Match patterns loosely, in case tabs or spaces
have been munged in your files.
Index: patch.c
--- patch.c.orig Thu, 04 Dec 1997 09:52:04 +0100 smurf (gnu_patch/9_patch.c 1.1.1.4 444) base.5
+++ patch.c Fri, 23 Jan 1998 09:01:52 +0100 smurf (gnu_patch/9_patch.c 1.1.1.5 664) noris.5
@@ -458,7 +458,7 @@
skip_rest_of_patch = FALSE;
}
-static char const shortopts[] = "bB:cd:D:eEfF:g:i:lnNo:p:r:RstTuvV:x:Y:z:Z";
+static char const shortopts[] = "bB:cd:D:eEfF:g:i:IlnNo:p:r:RstTuvV:x:Y:z:Z";
static struct option const longopts[] =
{
{"backup", no_argument, NULL, 'b'},
@@ -472,6 +472,7 @@
{"fuzz", required_argument, NULL, 'F'},
{"get", no_argument, NULL, 'g'},
{"input", required_argument, NULL, 'i'},
+ {"prefer-index", no_argument, NULL, 'I'},
{"ignore-whitespace", no_argument, NULL, 'l'},
{"normal", no_argument, NULL, 'n'},
{"forward", no_argument, NULL, 'N'},
@@ -504,6 +505,7 @@
"Input options:",
"",
" -p NUM --strip=NUM Strip NUM leading components from file names.",
+" -I --prefer-index Prefer the Index: header for file names.",
" -F LINES --fuzz LINES Set the fuzz factor to LINES for inexact matching.",
" -l --ignore-whitespace Ignore white space changes between patch and input.",
"",
@@ -652,6 +654,9 @@
break;
case 'i':
patchname = savestr (optarg);
+ break;
+ case 'I':
+ preferindex = TRUE;
break;
case 'l':
canonicalize = TRUE;
Index: common.h
--- common.h.orig Thu, 04 Dec 1997 09:51:38 +0100 smurf (gnu_patch/18_common.h 1.1.1.3 444) base.5
+++ common.h Fri, 23 Jan 1998 09:01:52 +0100 smurf (gnu_patch/18_common.h 1.1.1.5 664) noris.5
@@ -171,6 +171,7 @@
XTERN bool force;
XTERN bool batch;
XTERN bool noreverse;
+XTERN bool preferindex;
XTERN int reverse;
XTERN enum { DEFAULT_VERBOSITY, SILENT, VERBOSE } verbosity;
XTERN bool skip_rest_of_patch;
@@ -242,8 +243,10 @@
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
+#ifndef __GLIBC__
#ifndef lseek
off_t lseek ();
+#endif
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
Index: Makefile.in
--- Makefile.in.orig Thu, 04 Dec 1997 09:52:04 +0100 smurf (gnu_patch/24_Makefile.i 1.1.1.4 444) base.5
+++ Makefile.in Thu, 04 Dec 1997 10:15:23 +0100 smurf (gnu_patch/24_Makefile.i 1.1.1.5 664) noris.5
@@ -56,12 +56,12 @@
SHELL = /bin/sh
-LIBSRCS = getopt.c getopt1.c memchr.c rename.c
+LIBSRCS = memchr.c rename.c
SRCS = addext.c argmatch.c backupfile.c basename.c inp.c maketime.c \
partime.c patch.c pch.c quotearg.c util.c version.c $(LIBSRCS)
OBJS = addext.o argmatch.o backupfile.o basename.o inp.o maketime.o \
partime.o patch.o pch.o quotearg.o util.o version.o $(LIBOBJS)
-HDRS = argmatch.h backupfile.h common.h getopt.h \
+HDRS = argmatch.h backupfile.h common.h \
inp.h maketime.h partime.h pch.h quotearg.h util.h version.h
MISC = COPYING ChangeLog INSTALL Makefile.in NEWS README \
acconfig.h config.hin configure configure.in \
@@ -147,11 +147,10 @@
argmatch.o: argmatch.h
backupfile.o: argmatch.h backupfile.h
basename.o: backupfile.h
-getopt.o getopt1.o: getopt.h
maketime.o: maketime.h partime.h
inp.o: backupfile.h common.h inp.h pch.h util.h
partime.o: partime.h
-patch.o: argmatch.h backupfile.h common.h getopt.h inp.h pch.h util.h version.h
+patch.o: argmatch.h backupfile.h common.h inp.h pch.h util.h version.h
pch.o: common.h inp.h pch.h util.h
quotearg.o: quotearg.h
util.o: backupfile.h common.h maketime.h partime.h quotearg.h util.h version.h
--
Matthias Urlichs
noris network GmbH
More information about the Libc-hacker
mailing list