bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch: questions: prereq and backup?


From: Gary Funck
Subject: patch: questions: prereq and backup?
Date: Wed, 21 Feb 2001 18:16:22 -0800

I'm putting together a patch, and have a couple of questions
regarding the documented and possibly undocumented behavior of patch.

I'm checking out my patch by running an older version of patch (2.1)
and the latest (2.5.4).  The earlier version comes with SGI Irix 6.5,
and is installed in /usr/sbin/patch -- I don't know if SGI made
any system-specific changes, but I think not.  I built the the latest
version from GNU sources.

I want my patch to work with both versions, just to avoid user
confusion.  It appears to me that there may be some subtle
differences in behavior, and I wanted to confirm it here.  The
2.1 version appeared to back up original files to *.orig by
default (so, no -b is required).  But the newer version (2.5.4)
appears *not* to back up originals by default.  Is that a correct
conclusion regarding the behavior of the differing versions?  If I want
the backup behavior, should I explicitly supply -b, and that'll work
for both versions of patch?

My other question is: what is the correct specification for the
field that follows the "Prereq:" field?  The 2.5.4 man page
says the following:

          Additionally, if the leading garbage contains a Prereq:
          line, patch takes the first word from the prerequisites line
          (normally a version number) and checks the original file to
          see if that word can be found. [...]

When I read the description above, the term "word" to me, meant
"any string of alphanumer characters or `_'".  But upon investigation,
I have found that this is not exactly the case.  I wanted to
use `Prereq' to verify the version number of gcc in the file
gcc/version, which appears as follows:

char *version_string = "2.95.2 19991024 (release)";

So, I tried:

Prereq: 2.95.2

but this failed to match the version number.  Reading the sources,
I found that patch is looking for the equivalent egrep-like pattern,
    (^| )2.95.2( | $)
In other words, the string, 2.95.2 delimited by either a
white space character or a beginning or end of line.

Further, the patch program doesn't just use the next "word" on the
"Prereq:" line, it uses everything on the line following "Prereq:",
ignoring any whitespace characters following "Prereq:".

Thus, the following Prereq line matched the version informatin
shown above:

Prereq: "2.95.2 19991024 (release)";

At a minimum, it seems that the manual page isn't completely accurate
in its description of `Prereq' handling.  My question is: is thei
Prereq line above (""2.95.2 19991024 (release)";) incorrect in that
it specifies more than one "word".  Is it acceptable for the patches
that I build to make use of multi-word lines as shown above?

What I would have preferred, is that Prereq use a defintion of word
that is consistent with something like the egrep/ed meaning
of: '\<word\>', and that Pre-req allow only one 'word' on the
line following "Prereq:" and issue an error if more than word is
supplied.  Alternatively, patch might accept everything following,
"Prereq:" and any optional white space, up to the end of line,
and then add the \<\> word delimiters to that line when checking
for version compatibility.  Thus, the following Prereq lines
would match the text shown above:

    Prereq: 2.95.2
    Prereq: 2.95.2 19991024
    Prereq: 2.95.2 19991024 (release)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]