[#18440] racc segv revisited — "Akinori MUSHA" <knu@...>

 次のバグの件なんですが、現時点では原因究明を含めて未解決という

24 messages 2002/10/02
[#18617] Re: racc segv revisited — "Akinori MUSHA" <knu@...> 2002/11/02

At Wed, 2 Oct 2002 23:19:59 +0900,

[ruby-dev:18473] Compiling using oldnames on mswin/mingw/bccwin

From: nobu.nakada@...
Date: 2002-10-10 04:43:01 UTC
List: ruby-dev #18473
なかだです。

[ruby-talk:52801]の件ですが、こんなところでどうでしょうか。気に
なる点としては

* utime.hもsys/utime.hもないけれどそれ以外のどこかで struct
  utimbufを定義してあるという環境ではコンパイルできなくなる。

* bccで_open()の替わりに_sopen()を使ってるのは、単に引数の数を
  合わせるためだけ?

* strcasecmp()とstrncasecmp()は#defineのままでよい?

できればついでにNTじゃなくて_WIN32とかにしてしまったほうがいい
かも知れません。


Index: configure.in
===================================================================
RCS file: /cvs/ruby/src/ruby/configure.in,v
retrieving revision 1.146
diff -u -2 -p -r1.146 configure.in
--- configure.in	4 Oct 2002 05:46:45 -0000	1.146
+++ configure.in	10 Oct 2002 03:07:22 -0000
@@ -268,5 +271,5 @@ cygwin*)	rb_cv_have_daylight=no
 		ac_cv_func_setitimer=no
 		;;
-mingw*)		LIBS="-lwsock32 -lmsvcrt $LIBS"
+mingw*)		LIBS="-lcoldname -lwsock32 -lmsvcrt $LIBS"
 		rb_cv_need_io_flush_between_rw=no
 		rb_cv_need_io_flush_before_seek=no
@@ -351,5 +354,5 @@ AC_CHECK_HEADERS(stdlib.h string.h unist
 		 fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
 		 syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h \
-		 sys/mkdev.h)
+		 sys/mkdev.h sys/utime.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
Index: file.c
===================================================================
RCS file: /cvs/ruby/src/ruby/file.c,v
retrieving revision 1.113
diff -u -2 -p -r1.113 file.c
--- file.c	6 Sep 2002 08:59:38 -0000	1.113
+++ file.c	10 Oct 2002 03:49:27 -0000
@@ -55,4 +55,6 @@ VALUE rb_time_new _((time_t, time_t));
 #ifdef HAVE_UTIME_H
 #include <utime.h>
+#elif defined HAVE_SYS_UTIME_H
+#include <sys/utime.h>
 #endif
 
@@ -1207,20 +1209,9 @@ rb_file_s_utime(argc, argv)
 #else
 
-#ifndef HAVE_UTIME_H
-# ifdef NT
-#   if defined(__BORLANDC__)
-#     include <utime.h>
-#   else
-#  include <sys/utime.h>
-#   endif
-#   if defined(_MSC_VER) || defined __MINGW32__
-#  define utimbuf _utimbuf
-#   endif
-# else
+#if !defined HAVE_UTIME_H && !defined HAVE_SYS_UTIME_H
 struct utimbuf {
     long actime;
     long modtime;
 };
-# endif
 #endif
 
Index: util.c
===================================================================
RCS file: /cvs/ruby/src/ruby/util.c,v
retrieving revision 1.29
diff -u -2 -p -r1.29 util.c
--- util.c	28 Aug 2002 08:05:23 -0000	1.29
+++ util.c	10 Oct 2002 03:46:16 -0000
@@ -247,6 +247,11 @@ valid_filename(char *s)
     // It doesn't exist, so see if we can open it.
     */
-    
-    if ((fd = _open(s, O_CREAT, 0666)) >= 0) {
+
+#ifdef __BORLANDC__
+    fd = _open(s, O_CREAT);
+#else
+    fd = _open(s, O_CREAT, 0666);
+#endif
+    if (fd >= 0) {
 	_close(fd);
 	_unlink (s);	/* don't leave it laying around */
Index: bcc32/Makefile.sub
===================================================================
RCS file: /cvs/ruby/src/ruby/bcc32/Makefile.sub,v
retrieving revision 1.8
diff -u -2 -p -r1.8 Makefile.sub
--- bcc32/Makefile.sub	15 Sep 2002 12:57:21 -0000	1.8
+++ bcc32/Makefile.sub	10 Oct 2002 03:24:19 -0000
@@ -199,5 +199,5 @@ config.h: Makefile $(srcdir)bcc32/Makefi
 /* \#define HAVE_SYS_WAIT_H 1  */
 \#define HAVE_STRING_H 1
-/* \#define HAVE_UTIME_H 1     */
+\#define HAVE_UTIME_H 1
 \#define HAVE_MEMORY_H 1
 /* \#define HAVE_ST_BLKSIZE 1  */
Index: Makefile.sub
===================================================================
RCS file: /cvs/ruby/src/ruby/win32/Makefile.sub,v
retrieving revision 1.28
diff -u -2 -p -r1.28 Makefile.sub
--- Makefile.sub	15 Sep 2002 12:57:20 -0000	1.28
+++ Makefile.sub	10 Oct 2002 02:25:36 -0000
@@ -93,5 +93,5 @@ RFLAGS = -r
 EXTLIBS =
 !endif
-LIBS = user32.lib advapi32.lib wsock32.lib $(EXTLIBS)
+LIBS = oldnames.lib user32.lib advapi32.lib wsock32.lib $(EXTLIBS)
 MISSING = acosh.obj crypt.obj win32.obj isinf.obj isnan.obj
 LDSHARED = $(CC) -LD
@@ -275,5 +275,5 @@ s,@CPPFLAGS@,$(CPPFLAGS),;t t
 s,@FFLAGS@,$(FFLAGS),;t t
 s,@LDFLAGS@,$(LDFLAGS),;t t
-s,@LIBS@,user32.lib advapi32.lib wsock32.lib,;t t
+s,@LIBS@,$(LIBS),;t t
 s,@exec_prefix@,$${prefix},;t t
 s,@prefix@,,;t t
Index: win32/win32.c
===================================================================
RCS file: /cvs/ruby/src/ruby/win32/win32.c,v
retrieving revision 1.71
diff -u -2 -p -r1.71 win32.c
--- win32/win32.c	1 Oct 2002 15:26:39 -0000	1.71
+++ win32/win32.c	10 Oct 2002 03:51:40 -0000
@@ -1325,7 +1325,12 @@ valid_filename(char *s)
     // It doesn't exist, so see if we can open it.
     //
-    
-    if ((fd = _open(s, _O_CREAT, 0666)) >= 0) {
-	close(fd);
+
+#ifdef __BORLANDC__
+    fd = _open(s, _O_CREAT);
+#else
+    fd = _open(s, _O_CREAT, 0666);
+#endif
+    if (fd >= 0) {
+	_close(fd);
 	_unlink (s);	// don't leave it laying around
 	return 1;
Index: win32/win32.h
===================================================================
RCS file: /cvs/ruby/src/ruby/win32/win32.h,v
retrieving revision 1.30
diff -u -2 -p -r1.30 win32.h
--- win32/win32.h	1 Oct 2002 15:26:39 -0000	1.30
+++ win32/win32.h	10 Oct 2002 03:23:53 -0000
@@ -1,4 +1,4 @@
-#ifndef EXT_NT_H
-#define EXT_NT_H
+#ifndef RUBY_WIN32_H
+#define RUBY_WIN32_H
 
 /*
@@ -57,9 +57,4 @@ extern "C++" {
 #include <sys/stat.h>
 #include <sys/types.h>
-#if !defined(__BORLANDC__)
-# include <sys/utime.h>
-#else
-# include <utime.h>
-#endif
 #include <io.h>
 #include <malloc.h>
@@ -88,63 +83,27 @@ extern "C++" {
 #define getchar()		rb_w32_getc(stdin)
 #define putchar(_c)		rb_w32_putc(_c, stdout)
-#define fgetchar(_stream)	getchar()
-#define fputchar(_c, _stream)	putchar(_c)
+#define fgetchar()		getchar()
+#define fputchar(_c)		putchar(_c)
 
-#ifndef __BORLANDC__
+#ifndef __MINGW32__
+static inline int
+strcasecmp(const char *s1, const char *s2)
+{
+    return stricmp(s1, s2);
+}
 
-#define access	   _access
-#define chmod	   _chmod
-#define chsize	   _chsize
-#define dup	   _dup
-#define dup2	   _dup2
-#define isatty	   _isatty
-#define open	   _open
-#define setmode    _setmode
-#define execl	   _execl
-#define execle	   _execle
-#define execlp	   _execlp
-#define execlpe    _execlpe
-#define execv	   _execv
-#define execve	   _execve
-#define execvp	   _execvp
-#define execvpe    _execvpe
-#define lseek      _lseek
-#define spawnl	   _spawnl
-#define spawnle    _spawnle
-#define spawnlp    _spawnlp
-#define spawnlpe   _spawnlpe
-#define spawnv	   _spawnv
-#define spawnve    _spawnve
-#define spawnvp    _spawnvp
-#define spawnvpe   _spawnvpe
-#if _MSC_VER < 800
-#define fileno	   _fileno
+static inline int
+strncasecmp(const char *s1, const char *s2, size_t n)
+{
+    return strnicmp(s1, s2, n);
+}
 #endif
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
-#else
-#define strcasecmp  stricmp
-#define strncasecmp strnicmp
-#define _open       _sopen
-#endif
-
-#define close	   _close
-#define creat	   _creat
-#define eof	   _eof
-#define filelength _filelength
-#define locking    _locking
-#define mktemp	   _mktemp
-#define perror     _perror
-#define read	   _read
-#define sopen	   _sopen
-#define tell	   _tell
-#define umask	   _umask
-#define unlink	   _unlink
-#define write	   _write
+
 #define getpid	   rb_w32_getpid
 #define sleep(x)   rb_w32_sleep((x)*1000)
-#define utime      _utime
 #define vsnprintf  _vsnprintf
 #define snprintf   _snprintf
+#define Sleep(msec) (void)rb_w32_sleep(msec)
+
 #undef stat
 #define stat(path,st) rb_w32_stat(path,st)
@@ -162,4 +121,11 @@ extern char * NtGetBin(void);
 extern pid_t  pipe_exec(char *, int, FILE **, FILE **);
 extern int    flock(int fd, int oper);
+extern int    rb_w32_sleep(unsigned long msec);
+extern void   rb_w32_enter_critical(void);
+extern void   rb_w32_leave_critical(void);
+extern int    rb_w32_putc(int, FILE*);
+extern int    rb_w32_getc(FILE*);
+extern int    rb_w32_close(int);
+extern int    rb_w32_fclose(FILE*);
 extern int    rb_w32_accept(int, struct sockaddr *, int *);
 extern int    rb_w32_bind(int, struct sockaddr *, int);
@@ -189,4 +155,5 @@ extern struct protoent * rb_w32_getproto
 extern struct servent  * rb_w32_getservbyname(char *, char *);
 extern struct servent  * rb_w32_getservbyport(int, char *);
+
 extern char * rb_w32_getenv(const char *);
 extern int    rb_w32_rename(const char *, const char *);
@@ -471,11 +438,5 @@ struct tms {
 /* thread stuff */
 HANDLE GetCurrentThreadHandle(void);
-int  rb_w32_main_context(int arg, void (*handler)(int));
-int  rb_w32_sleep(unsigned long msec);
-void rb_w32_enter_critical(void);
-void rb_w32_leave_critical(void);
-int  rb_w32_putc(int, FILE*);
-int  rb_w32_getc(FILE*);
-#define Sleep(msec) (void)rb_w32_sleep(msec)
+extern int  rb_w32_main_context(int arg, void (*handler)(int));
 
 /*


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread

Prev Next