tr: Fix multiple ranges with different lengths (Michael Forney)

See his description below. Thanks Michael!

---
A bug was introduced in bc4c293fe59de042c1ac71793d33bb685c4fb915 causing the
range length for the next set to be used instead of the first one. This causes
issues when choosing the replacement rune when the ranges are of different
lengths.

Current behavior:

$ echo 1234 | tr 'a-f1-4' '1-6a-d'
56ab

Correct behavior:

$ echo 1234 | tr 'a-f1-4' '1-6a-d'
abcd

This also fixes range expressions in the form [a-z], which get encoded as four
ranges '[', 'a'..'z', ']', causing all a-z characters to get mapped to ']'. This
form is occasionally used in shell scripts, including the syscalltbl.sh script
used to build linux.
---
1 file changed
tree: ee2947458c9c15cc44bc26c9a5173434236e8797
  1. libutf/
  2. libutil/
  3. arg.h
  4. basename.1
  5. basename.c
  6. cal.1
  7. cal.c
  8. cat.1
  9. cat.c
  10. chgrp.1
  11. chgrp.c
  12. chmod.1
  13. chmod.c
  14. chown.1
  15. chown.c
  16. chroot.1
  17. chroot.c
  18. cksum.1
  19. cksum.c
  20. cmp.1
  21. cmp.c
  22. cols.1
  23. cols.c
  24. comm.1
  25. comm.c
  26. compat.h
  27. config.mk
  28. cp.1
  29. cp.c
  30. cron.1
  31. cron.c
  32. crypt.h
  33. cut.1
  34. cut.c
  35. date.1
  36. date.c
  37. dirname.1
  38. dirname.c
  39. du.1
  40. du.c
  41. echo.1
  42. echo.c
  43. ed.1
  44. ed.c
  45. env.1
  46. env.c
  47. expand.1
  48. expand.c
  49. expr.1
  50. expr.c
  51. false.1
  52. false.c
  53. find.1
  54. find.c
  55. flock.1
  56. flock.c
  57. fold.1
  58. fold.c
  59. fs.h
  60. getconf.1
  61. getconf.c
  62. getconf.sh
  63. grep.1
  64. grep.c
  65. head.1
  66. head.c
  67. hostname.1
  68. hostname.c
  69. join.1
  70. join.c
  71. kill.1
  72. kill.c
  73. LICENSE
  74. link.1
  75. link.c
  76. ln.1
  77. ln.c
  78. logger.1
  79. logger.c
  80. logname.1
  81. logname.c
  82. ls.1
  83. ls.c
  84. Makefile
  85. md5.h
  86. md5sum.1
  87. md5sum.c
  88. mkdir.1
  89. mkdir.c
  90. mkfifo.1
  91. mkfifo.c
  92. mktemp.1
  93. mktemp.c
  94. mv.1
  95. mv.c
  96. nice.1
  97. nice.c
  98. nl.1
  99. nl.c
  100. nohup.1
  101. nohup.c
  102. od.1
  103. od.c
  104. paste.1
  105. paste.c
  106. pathchk.1
  107. pathchk.c
  108. printenv.1
  109. printenv.c
  110. printf.1
  111. printf.c
  112. pwd.1
  113. pwd.c
  114. queue.h
  115. readlink.1
  116. readlink.c
  117. README
  118. renice.1
  119. renice.c
  120. rm.1
  121. rm.c
  122. rmdir.1
  123. rmdir.c
  124. sed.1
  125. sed.c
  126. seq.1
  127. seq.c
  128. setsid.1
  129. setsid.c
  130. sha1.h
  131. sha1sum.1
  132. sha1sum.c
  133. sha224.h
  134. sha224sum.1
  135. sha224sum.c
  136. sha256.h
  137. sha256sum.1
  138. sha256sum.c
  139. sha384.h
  140. sha384sum.1
  141. sha384sum.c
  142. sha512-224.h
  143. sha512-224sum.1
  144. sha512-224sum.c
  145. sha512-256.h
  146. sha512-256sum.1
  147. sha512-256sum.c
  148. sha512.h
  149. sha512sum.1
  150. sha512sum.c
  151. sleep.1
  152. sleep.c
  153. sort.1
  154. sort.c
  155. split.1
  156. split.c
  157. sponge.1
  158. sponge.c
  159. strings.1
  160. strings.c
  161. sync.1
  162. sync.c
  163. tail.1
  164. tail.c
  165. tar.1
  166. tar.c
  167. tee.1
  168. tee.c
  169. test.1
  170. test.c
  171. text.h
  172. tftp.1
  173. tftp.c
  174. time.1
  175. time.c
  176. TODO
  177. touch.1
  178. touch.c
  179. tr.1
  180. tr.c
  181. true.1
  182. true.c
  183. tsort.1
  184. tsort.c
  185. tty.1
  186. tty.c
  187. uname.1
  188. uname.c
  189. unexpand.1
  190. unexpand.c
  191. uniq.1
  192. uniq.c
  193. unlink.1
  194. unlink.c
  195. utf.h
  196. util.h
  197. uudecode.1
  198. uudecode.c
  199. uuencode.1
  200. uuencode.c
  201. wc.1
  202. wc.c
  203. which.1
  204. which.c
  205. whoami.1
  206. whoami.c
  207. xargs.1
  208. xargs.c
  209. xinstall.1
  210. xinstall.c
  211. yes.1
  212. yes.c