aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-08-08 08:06:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-04-07 17:29:23 +0900
commit0d93fd0f69cf6b8f60d76948b2e7d1144c1cd843 (patch)
tree1769472e7c3cc995ec31e7e05cc1892251e77d6e /ruby.c
parent0620f006c2043c9842f2a431f14cf1d3f846fb07 (diff)
downloadruby-0d93fd0f69cf6b8f60d76948b2e7d1144c1cd843.tar.gz
Merge `push_include_cygwin` into `push_include`
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/ruby.c b/ruby.c
index cf32aa6e50..7d154b58e8 100644
--- a/ruby.c
+++ b/ruby.c
@@ -444,34 +444,25 @@ push_include(const char *path, VALUE (*filter)(VALUE))
const char sep = PATH_SEP_CHAR;
const char *p, *s;
VALUE load_path = GET_VM()->load_path;
-
- p = path;
- while (*p) {
- while (*p == sep)
- p++;
- if (!*p) break;
- for (s = p; *s && *s != sep; s = CharNext(s));
- rb_ary_push(load_path, (*filter)(rubylib_path_new(p, s - p)));
- p = s;
- }
-}
-
#ifdef __CYGWIN__
-static void
-push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
-{
- const char *p, *s;
char rubylib[FILENAME_MAX];
VALUE buf = 0;
+# define is_path_sep(c) ((c) == sep || (c) == ';')
+#else
+# define is_path_sep(c) ((c) == sep)
+#endif
p = path;
while (*p) {
- unsigned int len;
- while (*p == ';')
+ long len;
+ while (is_path_sep(*p))
p++;
if (!*p) break;
- for (s = p; *s && *s != ';'; s = CharNext(s));
+ for (s = p; *s && !is_path_sep(*s); s = CharNext(s));
len = s - p;
+#undef is_path_sep
+
+#ifdef __CYGWIN__
if (*s) {
if (!buf) {
buf = rb_str_new(p, len);
@@ -488,18 +479,17 @@ push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
#else
# error no cygwin_conv_path
#endif
- if (CONV_TO_POSIX_PATH(p, rubylib) == 0)
+ if (CONV_TO_POSIX_PATH(p, rubylib) == 0) {
p = rubylib;
- push_include(p, filter);
- if (!*s) break;
- p = s + 1;
+ len = strlen(p);
+ }
+#endif
+ rb_ary_push(load_path, (*filter)(rubylib_path_new(p, len)));
+ p = s;
}
}
-#define push_include push_include_cygwin
-#endif
-
-void
+static void
ruby_push_include(const char *path, VALUE (*filter)(VALUE))
{
if (path == 0)
@@ -512,6 +502,7 @@ identical_path(VALUE path)
{
return path;
}
+
static VALUE
locale_path(VALUE path)
{