[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FDclone-users:00785] Re: FDclone 3.00 の alias について
- Subject: [FDclone-users:00785] Re: FDclone 3.00 の alias について
- From: Takashi SHIRAI <shirai@unixusers.net>
- Date: Mon, 02 Jun 2008 21:45:48 +0900
しらいです。
In Message-Id <4842C617.70608@imao.jp>
Yasushi Imao <yasushi_imao@imao.jp>さんwrites:
> お世話になります。今尾といいます。
> 早速 FDclone 3.00 を login shell として利用開始させていただいたところ、
> ~/.fd2rc で指定した alias の一部のコマンドが利かなくなりました。
検証したところこちらでの再現しました。β版でも再現したので、
出来ればもう少し早い段階で気づいて貰えたらなと思いました。
> つまり、alias [name[=com]] の com が name のオプション付の alias である
> 場合は、OK であるが、com がまったく別のコマンドであると NG となるようです。
そういうことではなくて、alias name の後ろに引数が後続して
いる場合は成功して、alias name 単体で使用すると失敗している
と思います。
失敗している例でも引数を追加すれば alias の置換えが行なわ
れていると思います。例えば「ll /home」とか「vi /etc/hosts」
とか記述すると期待した結果になりませんか?
逆に成功している例でも引数なしで実行すれば失敗すると思いま
す。
原因は組込みで用意した strchr2() の実装ミスにあります。こ
れは library 関数 strchr(3) の置換えですが、元の関数にある仕
様が実装し切れていませんでした。
strchr(3) の仕様では、第二引数が \0 の時に必ず第一引数の文
字列終端を返すのですが、strchr2() ではこの時に NULL を返すよ
うになっていました。
2.0x では strchr(3) を使用していた全ての箇所を、3.00 では
strchr2() に置換えているために、3.00 になってこの仕様違いが
表面化する結果になったのです。
なので、strchr2() 及び strrchr2() の仕様をそれぞれの元関数
に合わせ、同時に呼出側の処理としてこれらの関数の第二引数とし
て \0 を渡さないような配慮を行なってみました。
patch を作ってみたのでこれを試してみて貰えないでしょうか。
---- Cut Here ----
diff -u ../old/FD-3.00/posixsh.c ./posixsh.c
--- ../old/FD-3.00/posixsh.c Sat May 31 00:00:00 2008
+++ ./posixsh.c Mon Jun 2 20:46:04 2008
@@ -513,7 +513,8 @@
&& !(statementlist[i].type & STT_NEEDLIST)))
return(-1);
- if ((!strchr2(IFS_SET, delim) && !strchr2(ALIASDELIMIT, delim)))
+ if (delim
+ && (!strchr2(IFS_SET, delim) && !strchr2(ALIASDELIMIT, delim)))
return(-1);
i = searchalias(ident, len);
if (!(shellalias[i].ident) || (shellalias[i].flags & AL_USED))
@@ -559,7 +560,7 @@
else if (s[ptr] == '(') {
if ((ptr = evalexpression(s, ptr + 1, resultp, 9)) < 0)
return(-1);
- while (strchr2(IFS_SET, s[ptr])) ptr++;
+ while (s[ptr] && strchr2(IFS_SET, s[ptr])) ptr++;
if (s[ptr++] != ')') return(-1);
}
else if (isdigit2(s[ptr])) {
diff -u ../old/FD-3.00/string.c ./string.c
--- ../old/FD-3.00/string.c Sat May 31 00:00:00 2008
+++ ./string.c Mon Jun 2 20:45:01 2008
@@ -13,34 +13,32 @@
CONST char *s;
int c;
{
- int i;
-
- for (i = 0; s[i]; i++) {
- if (s[i] == c) return((char *)&(s[i]));
- if (iskanji1(s, i)) i++;
+ for (; *s != c; s++) {
+ if (!*s) return(NULL);
+ if (iskanji1(s, 0)) s++;
#ifdef CODEEUC
- else if (isekana(s, i)) i++;
+ else if (isekana(s, 0)) s++;
#endif
}
- return(NULL);
+ return((char *)s);
}
char *strrchr2(s, c)
CONST char *s;
int c;
{
- int i;
char *cp;
cp = NULL;
- for (i = 0; s[i]; i++) {
- if (s[i] == c) cp = (char *)&(s[i]);
- if (iskanji1(s, i)) i++;
+ for (; *s; s++) {
+ if (*s == c) cp = (char *)s;
+ if (iskanji1(s, 0)) s++;
#ifdef CODEEUC
- else if (isekana(s, i)) i++;
+ else if (isekana(s, 0)) s++;
#endif
}
+ if (!c) cp = (char *)s;
return(cp);
}
---- Cut Here ----
しらい たかし