mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-10 08:22:27 +01:00
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:
parent
d2893b161b
commit
482711cfa6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100874
@ -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;) {
|
||||
|
Loading…
Reference in New Issue
Block a user