From 990cf1286a165588c5b2f4d4fa98bb9d45c8fd11 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 19 Jan 2026 08:56:41 +0100 Subject: file.c: Inc macro now handle NULL encoding --- file.c | 9 ++------- 1 file 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]; -- cgit v1.2.3