1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-24 04:33:24 +00:00

Fix a bug where a \ at EOL did not work as escape character.

Obtained from:	[FDclone-users:00287]
This commit is contained in:
Akinori MUSHA 2004-06-12 18:00:41 +00:00
parent 3cedd6e4b9
commit b97e137237
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=111347
4 changed files with 88 additions and 0 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= fd
PORTVERSION= 2.05e
PORTREVISION= 1
CATEGORIES= shells
MASTER_SITES= http://hp.vector.co.jp/authors/VA012337/soft/fd/ \
ftp://ftp.unixusers.net/src/fdclone/

View File

@ -0,0 +1,59 @@
--- pathname.c.orig Wed Jun 9 00:00:00 2004
+++ pathname.c Sun Jun 13 01:48:43 2004
@@ -141,7 +141,7 @@
static char *NEAR getenvvar __P_((char *, int));
static int NEAR setvar __P_((char *, char *, int));
-static int NEAR ismeta __P_((char *s, int, int, int));
+static int NEAR ismeta __P_((char *s, int, int, int, int));
#ifdef _NOORIGGLOB
static char *NEAR cnvregexp __P_((char *, int));
#else
@@ -820,9 +820,9 @@
return(s);
}
-static int NEAR ismeta(s, ptr, quote, len)
+static int NEAR ismeta(s, ptr, quote, len, flags)
char *s;
-int ptr, quote, len;
+int ptr, quote, len, flags;
{
#ifdef FAKEMETA
return(0);
@@ -830,7 +830,7 @@
if (s[ptr] != PMETA || quote == '\'') return(0);
if (len >= 0) {
- if (ptr + 1 >= len) return(0);
+ if (!(flags & EA_EOLMETA) && ptr + 1 >= len) return(0);
# ifndef BASHSTYLE
/* bash does not treat "\" as \ */
if (quote == '"' && s[ptr + 1] == quote && ptr + 2 >= len)
@@ -838,7 +838,7 @@
# endif
}
else {
- if (!s[ptr + 1]) return(0);
+ if (!(flags & EA_EOLMETA) && !s[ptr + 1]) return(0);
# ifndef BASHSTYLE
/* bash does not treat "\" as \ */
if (quote == '"' && s[ptr + 1] == quote && !s[ptr + 2])
@@ -884,7 +884,7 @@
re[j++] = s[i];
continue;
}
- else if (ismeta(s, i, '\0', len)) {
+ else if (ismeta(s, i, '\0', len, 0)) {
re[j++] = s[i++];
re[j++] = s[i];
}
@@ -2183,7 +2183,7 @@
#endif
else if (*qp == '\'') return(PC_SQUOTE);
else if (spc && *s == spc) return(*s);
- else if (ismeta(s, 0, *qp, len)) return(PC_META);
+ else if (ismeta(s, 0, *qp, len, flags)) return(PC_META);
#ifdef BASHSTYLE
/* bash can include `...` in "..." */
else if ((flags & EA_BACKQ) && *s == '`') {

View File

@ -0,0 +1,10 @@
--- pathname.h.orig Wed Jun 9 00:00:00 2004
+++ pathname.h Sun Jun 13 01:47:14 2004
@@ -129,6 +129,7 @@
#define EA_NOEVALQ 0010
#define EA_STRIPQLATER 0020
#define EA_NOUNIQDELIM 0040
+#define EA_EOLMETA 0100
#ifdef NOUID_T
typedef u_short uid_t;

View File

@ -0,0 +1,18 @@
--- system.c.orig Wed Jun 9 00:00:00 2004
+++ system.c Sun Jun 13 01:55:23 2004
@@ -5795,11 +5795,12 @@
}
}
- pc = parsechar(&(s[i]), -1,
+ pc = parsechar(&(s[i]), -1, '$', EA_BACKQ | EA_EOLMETA,
#ifdef BASHSTYLE
- '$', EA_BACKQ, &(rp -> new), &(rp -> old));
+ /* bash can include `...` in "..." */
+ &(rp -> new), &(rp -> old));
#else
- '$', EA_BACKQ, &(rp -> new), NULL);
+ &(rp -> new), NULL);
#endif
if (pc == PC_OPQUOTE || pc == PC_CLQUOTE || pc == PC_SQUOTE)