山本です。

>コンパイルして気がついたのですが、
>
>gcc -g -O2   -I. -I.  -c dir.c
>dir.c: In function `push_braces':
>dir.c:1386: warning: passing arg 1 of `memcpy' discards qualifiers from pointer target type
>dir.c:1387: warning: passing arg 1 of `__strcpy_small' discards qualifiers from pointer target type
>dir.c:1387: warning: passing arg 1 of `memcpy' discards qualifiers from pointer target type
>dir.c:1387: warning: passing arg 1 of `strcpy' discards qualifiers from pointer target type
>
>という警告が出ます。
>
>これは、こちらの環境 (gcc, glibc, linux) が悪いのか、ソースが悪いのか、
>どっちなんでしょう?

すみません、constを余計につけてました。修正をコミットしました。

ruby_1_8 ブランチのパッチも同じく間違っていたので、下のように修正します。


cvs diff -u -wb ruby.h (in directory E:\ruby-cvs\ruby_1_8\)
Index: ruby.h
===================================================================
RCS file: /ruby/ruby/ruby.h,v
retrieving revision 1.97
diff -u -w -b -r1.97 ruby.h
--- ruby.h	22 Dec 2003 08:23:54 -0000	1.97
+++ ruby.h	15 Feb 2004 06:44:18 -0000
@@ -468,8 +468,8 @@
 
 void rb_obj_infect _((VALUE,VALUE));
 
-void rb_glob _((char*,void(*)(const char*,VALUE),VALUE));
-void rb_globi _((char*,void(*)(const char*,VALUE),VALUE));
+void rb_glob _((const char*,void(*)(const char*,VALUE),VALUE));
+void rb_globi _((const char*,void(*)(const char*,VALUE),VALUE));
 
 VALUE rb_define_class _((const char*,VALUE));
 VALUE rb_define_module _((const char*));


cvs diff -u -wb dir.c (in directory E:\ruby-cvs\ruby_1_8\)
Index: dir.c
===================================================================
RCS file: /ruby/ruby/dir.c,v
retrieving revision 1.92.2.1
diff -u -w -b -r1.92.2.1 dir.c
--- dir.c	9 Feb 2004 04:03:47 -0000	1.92.2.1
+++ dir.c	15 Feb 2004 11:50:14 -0000
@@ -769,10 +769,10 @@
 /* Return nonzero if S has any special globbing chars in it.  */
 static int
 has_magic(s, send, flags)
-     char *s, *send;
+    const char *s, *send;
      int flags;
 {
-    register char *p = s;
+    register const char *p = s;
     register char c;
     int open = 0;
     int escape = !(flags & FNM_NOESCAPE);
@@ -803,7 +803,7 @@
 
 static char*
 extract_path(p, pend)
-    char *p, *pend;
+    const char *p, *pend;
 {
     char *alloc;
     int len;
@@ -827,9 +827,9 @@
 
 static char*
 extract_elem(path)
-    char *path;
+    const char *path;
 {
-    char *pend;
+    const char *pend;
 
     pend = strchr(path, '/');
     if (!pend) pend = path + strlen(path);
@@ -1053,18 +1053,24 @@
 
 static void
 rb_glob2(path, flags, func, arg)
-    char *path;
+    const char *path;
     int flags;
     void (*func) _((const char*, VALUE));
     VALUE arg;
 {
-    int status = glob_helper(path, 0, flags, func, arg);
+    char *buf;
+    int status;
+
+    buf = ALLOC_N(char, strlen(path)+1);
+    strcpy(buf, path);
+    status = glob_helper(buf, 0, flags, func, arg);
+    free(buf);
     if (status) rb_jump_tag(status);
 }
 
 void
 rb_glob(path, func, arg)
-    char *path;
+    const char *path;
     void (*func) _((const char*, VALUE));
     VALUE arg;
 {
@@ -1073,7 +1079,7 @@
 
 void
 rb_globi(path, func, arg)
-    char *path;
+    const char *path;
     void (*func) _((const char*, VALUE));
     VALUE arg;
 {
@@ -1098,7 +1104,7 @@
 static void
 push_globs(ary, s, flags)
     VALUE ary;
-    char *s;
+    const char *s;
     int flags;
 {
     rb_glob2(s, flags, push_pattern, ary);
@@ -1107,12 +1113,12 @@
 static void
 push_braces(ary, s, flags)
     VALUE ary;
-    char *s;
+    const char *s;
     int flags;
 {
-    char *buf;
-    char *p, *t, *b;
-    char *lbrace, *rbrace;
+    char *buf, *b;
+    const char *p, *t;
+    const char *lbrace, *rbrace;
     int nest = 0;
 
     p = s;
@@ -1163,7 +1169,7 @@
     VALUE str;
     int flags;
 {
-    char *p, *pend;
+    const char *p, *pend;
     char *buf;
     char *t;
     int nest, maxnest;