When translating and the -c option is specified, handle the case where the

second string argument is more than one character in length in the way
required by SUSv3 (and the way GNU textutils and SVR4 do it).
This commit is contained in:
Tim J. Robbins 2002-07-29 14:50:54 +00:00
parent d2893b161b
commit 482711cfa6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100874

View File

@ -238,12 +238,17 @@ main(argc, argv)
(void)next(&s2);
}
if (cflag)
for (cnt = 0, p = string1; cnt < NCHARS; ++p, ++cnt)
*p = *p == OOBCH ? ch : cnt;
else if (Cflag)
for (cnt = 0, p = string1; cnt < NCHARS; ++p, ++cnt)
*p = *p == OOBCH && ISCHAR(cnt) ? ch : cnt;
if (cflag || Cflag) {
s2.str = argv[1];
s2.state = NORMAL;
for (cnt = 0, p = string1; cnt < NCHARS; ++p, ++cnt) {
if (*p == OOBCH && (!Cflag || ISCHAR(cnt))) {
(void)next(&s2);
*p = s2.lastch;
} else
*p = cnt;
}
}
if (sflag)
for (lastch = OOBCH; (ch = getchar()) != EOF;) {