Repository navigation
Conversation
|
Conflict with recent push of formatted tr.v |
Follow-up to vlang#239. Parse and behavior work measured against GNU 9.4 and uutils 0.0.17 on this machine: proper -c complement (positional over 256 bytes), -t truncation after complementing, -s with two sets (translate then squeeze SET2), short-SET2 last-char repetition, all POSIX classes, octal and alert/backspace/formfeed/vertical-tab escapes, [c*n]/[c*] repeats, and the two operand-error paths (exit 1, empty stdout). Known residuals are noted in code comments: -ct follows GNU where uutils differs, extra operands are ignored with -d like uutils rather than rejected like GNU, and [= =] equivalence classes are not implemented.
|
Rebased onto current
The bug, measuredV's
Every class dropped its last character. There is a second bug, and it is the bigger one
end := s.index_after(']', i + 2) or { s.len }
class := s[i + 2..end]
That is why I did not open a one-line hotfix for this. A Differential against GNUSince the repo's own
Both remaining cases are the same thing and not a defect: GNU prints its own Functional spot check after the rebase: Not verified here: the full |
Follow-up to #239, which got basic translation, delete, squeeze and the lower/upper/digit classes in.
What this adds, each measured byte-for-byte against GNU 9.4 (WSL) and uutils 0.0.17 on this machine:
-cis a real complement now: SET1 is replaced by all 256 bytes outside it, in byte order, then translated positionally (tr -c a-z A-Zmaps\ntoK, spaces/digits toZ). The old code translated SET1 and stuffed every other byte withset2[0].-t/--truncate-set1, applied after complementing.-swith two sets translates first, then squeezes SET2 (-s a-z A-ZturnshellointoHELO).alnum blank cntrl graph print punct space xdigit, withspacenow including VT/FF); octal escapes plus\a \b \f \v;[c*n]and bare[c*]repeats; the two operand-error paths exit 1 with empty stdout...ranges exclude the end (a-zexpanded toa-y),[:digit:]parsed asdigit:(trailing colon kept), andset2[0]used where the last character belongs.Residuals (also in code comments, deliberate):
tr -ctfollows GNU (identity here); uutils 0.0.17 maps every byte to the last character of SET2 instead. Untested against the rig reference for that reason.-d/-dsare ignored like uutils; GNU rejects them.[=c=]equivalence classes are not implemented.v test src/trgreen (14 test functions, differential against uutils),v fmt -lclean.