Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Some changes to 'afio', a cpio replacement

13 views
Skip to first unread message

Karl Denninger

unread,
Oct 29, 1987, 12:32:10 PM10/29/87
to
These are context diffs to the 'afio' program, a cpio replacement, that was
posted recently. The changes here take care of what I saw as a possible
gaffe in the '-y' and '-Y' options.

As originally posted, you must supply full pathnames for these options, with
partial paths and wild cards not supported.

These diffs will cause the '-y' and '-Y' options to behave as follows:

1. A path specification of the form '/xxx/xxx/xxx' must match exactly for
the file to be considered.

2. A path specification of the form '/xxx/xxx/xxx/*' will match anything
that is identical up to the asterisk (ie: asterisk becomes wild for
'remaining of the path').

3. If the '-Y' option is used, then if the path matches it is excluded,
regardless of whether it also matches an 'inclusive' specification.

4. If there is more than one instance of the '-y' switch is specified, then
the switches are read as if "or"ed together. Note that combinations of
the '-y' and '-Y' switches are still legal, and that "or"ing is still
subject to rule #3 above.

5. The asterisk *must* be the last character, or it will not be used as a
wild card. That is, you cannot specify '/usr/lib/*/files'. Also, if you
do specify a wild pathname, you should enclose the entire path in single
quotes so the shell doesn't try to expand it.

I would like to take this time to express my thanks to the authors of this
fine utility -- Lachman Associates, Inc. It just saved my butt last night
on a damaged cpio archive -- needless to say, it's replacing cpio, at least
here!

No claim is made that these changes are cute, well-coded, optimized, or even
completely correct - this is a hack made in response to an immediate need,
one which you may have yourself! It appeared from the documentation that
this was the original intent of these switches, but they didn't work that
way on our System V machine, so we hacked. Your mileage may vary on other
versions of Unix.

(Feed this to patch)


*** afio.c.old Wed Oct 28 23:32:12 1987
--- afio.c Thu Oct 29 10:11:23 1987
***************
*** 1449,1454
reg Pattern *px;
reg int positive;
reg int match;

positive = match = 0;
for (px = pattern; px; px = px->p_forw) {

--- 1449,1457 -----
reg Pattern *px;
reg int positive;
reg int match;
+ int x;
+ int wild = 0;
+ int comp;

positive = match = 0;
if (pattern == NULL) return(0); /* Ok if nothing spec'd */
***************
*** 1451,1456
reg int match;

positive = match = 0;
for (px = pattern; px; px = px->p_forw) {
if (!px->p_not)
++positive;

--- 1454,1460 -----
int comp;

positive = match = 0;
+ if (pattern == NULL) return(0); /* Ok if nothing spec'd */
for (px = pattern; px; px = px->p_forw) {
if (!px->p_not)
++positive;
***************
*** 1454,1464
for (px = pattern; px; px = px->p_forw) {
if (!px->p_not)
++positive;
! if (strncmp(name, px->p_str, px->p_len) == 0
! && (name[px->p_len] == '/' || name[px->p_len] == '\0')) {
! if (px->p_not)
! return (-1);
! ++match;
}
}
return (match || !positive ? 0 : -1);

--- 1458,1467 -----
for (px = pattern; px; px = px->p_forw) {
if (!px->p_not)
++positive;
! x = px->p_len;
! if (px->p_str[px->p_len - 1] == '*') {
! x--; /* If wild, back up one */
! wild++;
}
comp = strncmp(name, px->p_str, x);
if (px->p_not) {
***************
*** 1460,1465
return (-1);
++match;
}
}
return (match || !positive ? 0 : -1);
}

--- 1463,1488 -----
x--; /* If wild, back up one */
wild++;
}
+ comp = strncmp(name, px->p_str, x);
+ if (px->p_not) {
+ if (wild == 0) { /* If not wild */
+ if ((name[x] != '\0') || (comp != 0))
+ ++match;
+ else
+ return(-1); /* OUT NOW */
+ } else
+ if (comp != 0)
+ ++match;
+ else
+ return(-1); /* OUT NOW */
+ } else {
+ if (wild == 0) { /* If not wild */
+ if ((name[x] == '\0') && (comp == 0))
+ ++match;
+ } else
+ if (comp == 0)
+ ++match;
+ }
}
if (match > 0)
return(0);
***************
*** 1461,1467
++match;
}
}
! return (match || !positive ? 0 : -1);
}

/*

--- 1484,1492 -----
++match;
}
}
! if (match > 0)
! return(0);
! return(-1);
}

/*
--

Karl Denninger UUCP : ...ihnp4!ddsw1!karl
Macro Computer Solutions Dial : +1 (312) 566-8909 (300-1200)
"Quality solutions at a fair price" Voice: +1 (312) 566-8910 (24 hrs)

0 new messages