Skip to content

Commit 990cf12

Browse files
committed
file.c: Inc macro now handle NULL encoding
1 parent 240a58e commit 990cf12

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

file.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,7 @@ static const char file_alt_separator[] = {FILE_ALT_SEPARATOR, '\0'};
35713571
# define isADS(x) 0
35723572
#endif
35733573

3574-
#define Next(p, e, enc) ((p) + rb_enc_mbclen((p), (e), (enc)))
3574+
#define Next(p, e, enc) ((p) + ((enc) ? rb_enc_mbclen((p), (e), (enc)) : 1))
35753575
#define Inc(p, e, enc) ((p) = Next((p), (e), (enc)))
35763576

35773577
#if defined(DOSISH_UNC)
@@ -5114,12 +5114,7 @@ rb_file_dirname_n(VALUE fname, int n)
51145114
if (i == n) i = 0;
51155115
}
51165116
else {
5117-
if (RB_UNLIKELY(enc)) {
5118-
Inc(p, end, enc);
5119-
}
5120-
else {
5121-
p++;
5122-
}
5117+
Inc(p, end, enc);
51235118
}
51245119
}
51255120
p = seps[i];

0 commit comments

Comments
 (0)