summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/string.c b/string.c
index 26ae87a25e..11c80d4618 100644
--- a/string.c
+++ b/string.c
@@ -3264,13 +3264,14 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
while (s < send) {
VALUE v = rb_hash_aref(hash, INT2FIX(*s));
if (!NIL_P(v)) {
- if (cflag) {
- *s = last;
- }
- else {
+ if (!cflag) {
c = FIX2INT(v);
*s = c & 0xff;
+ modify = 1;
}
+ }
+ else if (cflag) {
+ *s = last;
modify = 1;
}
s++;