summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-01-19 08:56:41 +0100
committerJean Boussier <jean.boussier@gmail.com>2026-01-20 08:33:42 +0100
commit990cf1286a165588c5b2f4d4fa98bb9d45c8fd11 (patch)
treed2ff3136a54663fc2902949f67a26b3586f829d5
parent240a58ecc63d07b50ddfb027a9c9b9bc317ffc49 (diff)
file.c: Inc macro now handle NULL encoding
-rw-r--r--file.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/file.c b/file.c
index 95bb557aee..365df5a292 100644
--- a/file.c
+++ b/file.c
@@ -3571,7 +3571,7 @@ static const char file_alt_separator[] = {FILE_ALT_SEPARATOR, '\0'};
# define isADS(x) 0
#endif
-#define Next(p, e, enc) ((p) + rb_enc_mbclen((p), (e), (enc)))
+#define Next(p, e, enc) ((p) + ((enc) ? rb_enc_mbclen((p), (e), (enc)) : 1))
#define Inc(p, e, enc) ((p) = Next((p), (e), (enc)))
#if defined(DOSISH_UNC)
@@ -5114,12 +5114,7 @@ rb_file_dirname_n(VALUE fname, int n)
if (i == n) i = 0;
}
else {
- if (RB_UNLIKELY(enc)) {
- Inc(p, end, enc);
- }
- else {
- p++;
- }
+ Inc(p, end, enc);
}
}
p = seps[i];