delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/02/11/11:48:27

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: pavenis AT lanet DOT lv
To: djgpp-workers AT delorie DOT com
Date: Mon, 11 Feb 2002 18:48:17 +0200
MIME-Version: 1.0
Subject: GCC-3.1 related patches for DJGPP CVS version
Message-ID: <3C6811F1.25868.10A3D21@localhost>
X-mailer: Pegasus Mail for Windows (v4.01)
Reply-To: djgpp-workers AT delorie DOT com

Tried to compile DJGPP today's CVS version with GCC-3.1 20020210.
To get it to compile applied included patches. 

1) internal representation of __builtin_va_list changed to char *, as result
many breakages. Mostly added some ugly type casts

2) warning were generated about snprintf  with empty format. 

Perhaps changes which only requires using va_list of something more ugly
but not explicit casts from (or to) va_list can be applied. I don't know 
about other ones though

Andris

diff -ur3 djgpp.orig/src/debug/edebug/unassmbl.c 
djgpp/src/debug/edebug/unassmbl.c
--- djgpp.orig/src/debug/edebug/unassmbl.c	Tue Oct 28 21:35:18 1997
+++ djgpp/src/debug/edebug/unassmbl.c	Mon Feb 11 18:39:06 2002
@@ -15,6 +15,7 @@
 */
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <string.h>
 
 #include "ed.h"
@@ -340,8 +341,10 @@
 /*------------------------------------------------------------------------*/
 static void uprintf(const char *s, ...)
 {
-  const char **a = &s;
-  vsprintf(ubufp, s, a+1);
+  va_list args;
+  va_start(args, s);
+  vsprintf(ubufp, s, args);
+  va_end(args);
   while (*ubufp) ubufp++;
 }
 
diff -ur3 djgpp.orig/src/debug/fsdb/unassmbl.c djgpp/src/debug/fsdb/unassmbl.c
--- djgpp.orig/src/debug/fsdb/unassmbl.c	Mon Sep  7 21:12:42 1998
+++ djgpp/src/debug/fsdb/unassmbl.c	Mon Feb 11 18:40:26 2002
@@ -18,6 +18,7 @@
    debugger.  These changes are copyright 1994 by Morten Welinder.  */
 
 #include <stdio.h>
+#include <stdarg.h>
 #include <string.h>
 #include <sys/stat.h>
 
@@ -354,8 +355,10 @@
 void
 uprintf(char *s, ...)
 {
-  char **a = &s;
-  vsprintf(ubufp, s, a+1);
+  va_list args;
+  va_start(args, s);
+  vsprintf(ubufp, s, args);
+  va_end(args);
   while (*ubufp) ubufp++;
 }
 
diff -ur3 djgpp.orig/src/libc/ansi/stdio/fprintf.c 
djgpp/src/libc/ansi/stdio/fprintf.c
--- djgpp.orig/src/libc/ansi/stdio/fprintf.c	Mon Dec 26 22:34:46 1994
+++ djgpp/src/libc/ansi/stdio/fprintf.c	Mon Feb 11 17:48:16 2002
@@ -1,5 +1,7 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <stdio.h>
+#include <stdarg.h>
 #include <libc/file.h>
 
 int
@@ -7,13 +9,15 @@
 {
   int len;
   char localbuf[BUFSIZ];
+  va_list args;
 
+  va_start(args, fmt);
   if (iop->_flag & _IONBF)
   {
     iop->_flag &= ~_IONBF;
     iop->_ptr = iop->_base = localbuf;
     iop->_bufsiz = BUFSIZ;
-    len = _doprnt(fmt, (&fmt)+1, iop);
+    len = _doprnt(fmt, args, iop);
     fflush(iop);
     iop->_flag |= _IONBF;
     iop->_base = NULL;
@@ -21,6 +25,7 @@
     iop->_cnt = 0;
   }
   else
-    len = _doprnt(fmt, (&fmt)+1, iop);
+    len = _doprnt(fmt, args, iop);
+  va_end(args);
   return ferror(iop) ? EOF : len;
 }
diff -ur3 djgpp.orig/src/libc/ansi/stdio/fscanf.c 
djgpp/src/libc/ansi/stdio/fscanf.c
--- djgpp.orig/src/libc/ansi/stdio/fscanf.c	Mon Dec 26 22:34:48 1994
+++ djgpp/src/libc/ansi/stdio/fscanf.c	Mon Feb 11 17:49:18 2002
@@ -9,7 +9,7 @@
   int r;
   va_list a=0;
   va_start(a, fmt);
-  r = _doscan(f, fmt, a);
+  r = _doscan(f, fmt, (void **) a);
   va_end(a);
   return r;
 }
diff -ur3 djgpp.orig/src/libc/ansi/stdio/printf.c 
djgpp/src/libc/ansi/stdio/printf.c
--- djgpp.orig/src/libc/ansi/stdio/printf.c	Fri Jan  2 01:05:02 1998
+++ djgpp/src/libc/ansi/stdio/printf.c	Mon Feb 11 17:47:28 2002
@@ -1,14 +1,19 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <stdio.h>
+#include <stdarg.h>
 #include <libc/file.h>
 
 int
 printf(const char *fmt, ...)
 {
   int len;
+  va_list args;
 
-  len = _doprnt(fmt, (&fmt)+1, stdout);
+  va_start(args, fmt);
+  len = _doprnt(fmt, args, stdout);
+  va_end(args);
 
   /* People were confused when printf() didn't flush stdout,
      so we'll do it to reduce confusion */
diff -ur3 djgpp.orig/src/libc/ansi/stdio/remove.c 
djgpp/src/libc/ansi/stdio/remove.c
--- djgpp.orig/src/libc/ansi/stdio/remove.c	Sat Jun  9 16:33:58 2001
+++ djgpp/src/libc/ansi/stdio/remove.c	Mon Feb 11 17:53:14 2002
@@ -24,7 +24,7 @@
   int rv;
 
   /* see if a file system extension wants to handle this */
-  if (__FSEXT_call_open_handlers(__FSEXT_unlink, &rv, &fn))
+  if (__FSEXT_call_open_handlers(__FSEXT_unlink, &rv, (va_list) &fn))
     return rv;
 
   /* Handle symlinks */
diff -ur3 djgpp.orig/src/libc/ansi/stdio/scanf.c 
djgpp/src/libc/ansi/stdio/scanf.c
--- djgpp.orig/src/libc/ansi/stdio/scanf.c	Mon Dec 26 22:34:54 1994
+++ djgpp/src/libc/ansi/stdio/scanf.c	Mon Feb 11 17:49:38 2002
@@ -9,7 +9,7 @@
   int r;
   va_list a=0;
   va_start(a, fmt);
-  r = _doscan(stdin, fmt, a);
+  r = _doscan(stdin, fmt, (void **) a);
   va_end(a);
   return r;
 }
diff -ur3 djgpp.orig/src/libc/ansi/stdio/sprintf.c 
djgpp/src/libc/ansi/stdio/sprintf.c
--- djgpp.orig/src/libc/ansi/stdio/sprintf.c	Wed Aug  4 22:58:22 1999
+++ djgpp/src/libc/ansi/stdio/sprintf.c	Mon Feb 11 17:54:34 2002
@@ -2,6 +2,7 @@
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <stdio.h>
 #include <limits.h>
+#include <stdarg.h>
 #include <libc/file.h>
 
 int
@@ -9,11 +10,14 @@
 {
   FILE _strbuf;
   int len;
+  va_list args;
 
+  va_start(args, fmt);
   _strbuf._flag = _IOWRT|_IOSTRG|_IONTERM;
   _strbuf._ptr = str;
   _strbuf._cnt = INT_MAX;
-  len = _doprnt(fmt, &(fmt)+1, &_strbuf);
+  len = _doprnt(fmt, args, &_strbuf);
+  va_end(args);
   *_strbuf._ptr = 0;
   return len;
 }
diff -ur3 djgpp.orig/src/libc/ansi/stdio/sscanf.c 
djgpp/src/libc/ansi/stdio/sscanf.c
--- djgpp.orig/src/libc/ansi/stdio/sscanf.c	Wed Aug  4 22:58:22 1999
+++ djgpp/src/libc/ansi/stdio/sscanf.c	Mon Feb 11 17:55:00 2002
@@ -20,7 +20,7 @@
   while (*str++)
     _strbuf._cnt++;
   _strbuf._bufsiz = _strbuf._cnt;
-  r = _doscan(&_strbuf, fmt, a);
+  r = _doscan(&_strbuf, fmt, (void **) a);
   va_end(a);
   return r;
 }
diff -ur3 djgpp.orig/src/libc/compat/ioctl/ioctl.c 
djgpp/src/libc/compat/ioctl/ioctl.c
--- djgpp.orig/src/libc/compat/ioctl/ioctl.c	Fri Aug 10 02:00:50 2001
+++ djgpp/src/libc/compat/ioctl/ioctl.c	Mon Feb 11 17:58:56 2002
@@ -263,7 +263,7 @@
   if(func)
   {
     int rv;
-    if (func(__FSEXT_ioctl,&rv, &fd))
+    if (func(__FSEXT_ioctl,&rv, (va_list) &fd))
        return rv;
   }
 
@@ -319,7 +319,7 @@
    ** see if this is a file system extension file
    **
    */
-  if (func && func(__FSEXT_ioctl, &rv, &fd))
+  if (func && func(__FSEXT_ioctl, &rv, (va_list) &fd))
     return rv;
 
   va_start(args, cmd);
diff -ur3 djgpp.orig/src/libc/compat/stdio/vscanf.c 
djgpp/src/libc/compat/stdio/vscanf.c
--- djgpp.orig/src/libc/compat/stdio/vscanf.c	Sun Jun 28 20:45:50 1998
+++ djgpp/src/libc/compat/stdio/vscanf.c	Mon Feb 11 17:59:40 2002
@@ -5,5 +5,5 @@
 int
 vscanf(const char *fmt, va_list ap)
 {
-  return _doscan(stdin, fmt, ap);
+  return _doscan(stdin, fmt, (void **) ap);
 }
diff -ur3 djgpp.orig/src/libc/compat/stdio/vsscanf.c 
djgpp/src/libc/compat/stdio/vsscanf.c
--- djgpp.orig/src/libc/compat/stdio/vsscanf.c	Wed Aug  4 22:58:22 1999
+++ djgpp/src/libc/compat/stdio/vsscanf.c	Mon Feb 11 18:00:24 2002
@@ -16,5 +16,5 @@
   while (*str++)
     _strbuf._cnt++;
   _strbuf._bufsiz = _strbuf._cnt;
-  return _doscan(&_strbuf, fmt, ap);
+  return _doscan(&_strbuf, fmt, (void **) ap);
 }
diff -ur3 djgpp.orig/src/libc/compat/time/select.c 
djgpp/src/libc/compat/time/select.c
--- djgpp.orig/src/libc/compat/time/select.c	Sat Mar 31 13:33:42 2001
+++ djgpp/src/libc/compat/time/select.c	Mon Feb 11 18:01:26 2002
@@ -165,7 +165,7 @@
       int fsext_ready = -1;
 
       if (func)
-	func(__FSEXT_ready, &fsext_ready, &i);
+	func(__FSEXT_ready, &fsext_ready, (va_list) &i);
 
       if (readfds && FD_ISSET (i, readfds))
       {
diff -ur3 djgpp.orig/src/libc/compat/unistd/_irdlink.c 
djgpp/src/libc/compat/unistd/_irdlink.c
--- djgpp.orig/src/libc/compat/unistd/_irdlink.c	Thu Jan 10 01:15:44 2002
+++ djgpp/src/libc/compat/unistd/_irdlink.c	Mon Feb 11 18:04:14 2002
@@ -24,7 +24,7 @@
    int           fd;
    int           ret;
    off_t         old_pos = 0;
-   long          file_size;
+   long          file_size = 0;
 
    /* Reject NULL and impossible arg combinations */
    if (!__buf || (__path && __fhandle) || !(__path || __fhandle))
@@ -37,7 +37,7 @@
    if (__path)
    {
       struct ffblk  file_info;
-      if (__FSEXT_call_open_handlers(__FSEXT_readlink, &ret, &__path))
+      if (__FSEXT_call_open_handlers(__FSEXT_readlink, &ret, (va_list) 
&__path))
          return ret;
       /* We will check if file exists by the way */
       if (findfirst(__path, &file_info, 0))
@@ -53,7 +53,7 @@
       if (func)
       {
          int rv;
-         if (func(__FSEXT_readlink, &rv, &__path))
+         if (func(__FSEXT_readlink, &rv, (va_list) &__path))
             return rv;
       }
       file_size = filelength(__fhandle);
diff -ur3 djgpp.orig/src/libc/compat/unistd/llseek.c 
djgpp/src/libc/compat/unistd/llseek.c
--- djgpp.orig/src/libc/compat/unistd/llseek.c	Mon Oct 15 01:15:52 2001
+++ djgpp/src/libc/compat/unistd/llseek.c	Mon Feb 11 18:04:40 2002
@@ -27,7 +27,7 @@
   if( func )
   {
     int rv;
-    if( func(__FSEXT_llseek, &rv, &handle) )
+    if( func(__FSEXT_llseek, &rv, (va_list) &handle) )
     {
       return rv;
     }
diff -ur3 djgpp.orig/src/libc/compat/unistd/symlink.c 
djgpp/src/libc/compat/unistd/symlink.c
--- djgpp.orig/src/libc/compat/unistd/symlink.c	Fri May 11 20:52:26 2001
+++ djgpp/src/libc/compat/unistd/symlink.c	Mon Feb 11 18:05:06 2002
@@ -33,7 +33,7 @@
    }
 
    /* Provide ability to hook symlink support */
-   if (__FSEXT_call_open_handlers(__FSEXT_symlink, &ret, &source))
+   if (__FSEXT_call_open_handlers(__FSEXT_symlink, &ret, (va_list) &source))
       return ret;
 
 
diff -ur3 djgpp.orig/src/libc/dos/io/_close.c djgpp/src/libc/dos/io/_close.c
--- djgpp.orig/src/libc/dos/io/_close.c	Wed Mar  7 07:40:26 2001
+++ djgpp/src/libc/dos/io/_close.c	Mon Feb 11 18:06:28 2002
@@ -19,7 +19,7 @@
   if (func)
   {
     int rv;
-    if (func(__FSEXT_close, &rv, &handle))
+    if (func(__FSEXT_close, &rv, (va_list) &handle))
     {
       /* So that we don't try to use it later!
 	 The extension *should* do this itself! */
diff -ur3 djgpp.orig/src/libc/dos/io/_creat.c djgpp/src/libc/dos/io/_creat.c
--- djgpp.orig/src/libc/dos/io/_creat.c	Wed Sep 26 02:00:48 2001
+++ djgpp/src/libc/dos/io/_creat.c	Mon Feb 11 18:06:42 2002
@@ -25,7 +25,7 @@
     return -1;
   }
 
-  if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
+  if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, (va_list) &filename))
     return rv;
 
   if(use_lfn) {
diff -ur3 djgpp.orig/src/libc/dos/io/_creat_n.c 
djgpp/src/libc/dos/io/_creat_n.c
--- djgpp.orig/src/libc/dos/io/_creat_n.c	Wed Sep 26 02:00:48 2001
+++ djgpp/src/libc/dos/io/_creat_n.c	Mon Feb 11 18:06:58 2002
@@ -24,7 +24,7 @@
     return -1;
   }
 
-  if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
+  if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, (va_list) &filename))
     return rv;
 
   _put_path(filename);
diff -ur3 djgpp.orig/src/libc/dos/io/_open.c djgpp/src/libc/dos/io/_open.c
--- djgpp.orig/src/libc/dos/io/_open.c	Wed Sep 26 02:00:50 2001
+++ djgpp/src/libc/dos/io/_open.c	Mon Feb 11 18:07:14 2002
@@ -25,7 +25,7 @@
     return -1;
   }
 
-  if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
+  if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, (va_list) &filename))
     return rv;
 
   if(use_lfn && _os_trueversion == 0x532) {
diff -ur3 djgpp.orig/src/libc/dos/io/_read.c djgpp/src/libc/dos/io/_read.c
--- djgpp.orig/src/libc/dos/io/_read.c	Sat Nov 25 23:48:30 1995
+++ djgpp/src/libc/dos/io/_read.c	Mon Feb 11 18:07:42 2002
@@ -22,7 +22,7 @@
   if (func)
   {
     int rv;
-    if (func(__FSEXT_read, &rv, &handle))
+    if (func(__FSEXT_read, &rv, (va_list) &handle))
       return rv;
   }
 
diff -ur3 djgpp.orig/src/libc/dos/io/_write.c djgpp/src/libc/dos/io/_write.c
--- djgpp.orig/src/libc/dos/io/_write.c	Sat May 19 21:31:34 2001
+++ djgpp/src/libc/dos/io/_write.c	Mon Feb 11 18:07:54 2002
@@ -22,7 +22,7 @@
   if (func)
   {
     int rv;
-    if (func(__FSEXT_write, &rv, &handle))
+    if (func(__FSEXT_write, &rv, (va_list) &handle))
       return rv;
   }
 
diff -ur3 djgpp.orig/src/libc/posix/fcntl/fcntl.c 
djgpp/src/libc/posix/fcntl/fcntl.c
--- djgpp.orig/src/libc/posix/fcntl/fcntl.c	Mon Jun 11 13:47:58 2001
+++ djgpp/src/libc/posix/fcntl/fcntl.c	Mon Feb 11 18:09:36 2002
@@ -264,7 +264,7 @@
   if (func)
   {
     int rv;
-    if (func(__FSEXT_fcntl, &rv, &fd))
+    if (func(__FSEXT_fcntl, &rv, (va_list) &fd))
       return rv;
   }
 
diff -ur3 djgpp.orig/src/libc/posix/sys/stat/fstat.c 
djgpp/src/libc/posix/sys/stat/fstat.c
--- djgpp.orig/src/libc/posix/sys/stat/fstat.c	Sun Dec  2 01:15:40 2001
+++ djgpp/src/libc/posix/sys/stat/fstat.c	Mon Feb 11 18:10:54 2002
@@ -900,7 +900,7 @@
 
   /* see if this is file system extension file */
   func = __FSEXT_get_function(handle);
-  if (func && func(__FSEXT_fstat, &rv, &handle))
+  if (func && func(__FSEXT_fstat, &rv, (va_list) &handle))
     {
        return rv;
     }
diff -ur3 djgpp.orig/src/libc/posix/sys/stat/lstat.c 
djgpp/src/libc/posix/sys/stat/lstat.c
--- djgpp.orig/src/libc/posix/sys/stat/lstat.c	Thu Jan 17 01:15:42 2002
+++ djgpp/src/libc/posix/sys/stat/lstat.c	Mon Feb 11 18:15:06 2002
@@ -895,7 +895,7 @@
 static int fsext_wrapper(int * ret, const char * path, 
                          struct stat * statbuf __attribute__((unused)))
 {
-   return __FSEXT_call_open_handlers(__FSEXT_stat, ret, &path);
+   return __FSEXT_call_open_handlers(__FSEXT_stat, ret, (va_list) &path);
 }
 
 
diff -ur3 djgpp.orig/src/libc/posix/unistd/confstr.c 
djgpp/src/libc/posix/unistd/confstr.c
--- djgpp.orig/src/libc/posix/unistd/confstr.c	Wed Jun 20 02:00:46 2001
+++ djgpp/src/libc/posix/unistd/confstr.c	Mon Feb 11 18:17:28 2002
@@ -43,7 +43,9 @@
     case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
     case _CS_POSIX_V6_ILP32_OFF32_LIBS:
     {
-      out_len = snprintf(buf, len, "");
+/*      out_len = snprintf(buf, len, "");  */
+      if (len>0) *buf=0; 
+      out_len=0;
       ++out_len;
       break;
     }
diff -ur3 djgpp.orig/src/libc/posix/unistd/link.c 
djgpp/src/libc/posix/unistd/link.c
--- djgpp.orig/src/libc/posix/unistd/link.c	Sun Jun 28 20:27:32 1998
+++ djgpp/src/libc/posix/unistd/link.c	Mon Feb 11 18:18:06 2002
@@ -33,7 +33,7 @@
   }
 
   /* see if a file system extension implements the link */
-  if (__FSEXT_call_open_handlers(__FSEXT_link, &rv, &path1))
+  if (__FSEXT_call_open_handlers(__FSEXT_link, &rv, (va_list) &path1))
     return rv;
 
   /* Fail if path1 does not exist - stat() will set errno */
diff -ur3 djgpp.orig/src/libc/posix/unistd/lseek.c 
djgpp/src/libc/posix/unistd/lseek.c
--- djgpp.orig/src/libc/posix/unistd/lseek.c	Mon Oct 15 01:15:52 2001
+++ djgpp/src/libc/posix/unistd/lseek.c	Mon Feb 11 18:18:24 2002
@@ -20,7 +20,7 @@
   if (func)
   {
     int rv;
-    if (func(__FSEXT_lseek, &rv, &handle))
+    if (func(__FSEXT_lseek, &rv, (va_list) &handle))
       return rv;
   }
 
diff -ur3 djgpp.orig/src/libc/posix/unistd/write.c 
djgpp/src/libc/posix/unistd/write.c
--- djgpp.orig/src/libc/posix/unistd/write.c	Sun Jun 10 02:00:44 2001
+++ djgpp/src/libc/posix/unistd/write.c	Mon Feb 11 18:19:10 2002
@@ -53,7 +53,7 @@
 
   /* Let's handle FSEXT_write ! */
   if(func &&				/* if handler is installed, ...*/
-     func(__FSEXT_write, &rv, &handle)) /* ... call extension ... */
+     func(__FSEXT_write, &rv, (va_list) &handle)) /* ... call extension ... */
       return rv;			/* ... and exit if handled. */
 
   if (__has_fd_properties(handle)
diff -ur3 djgpp.orig/src/libemu/src/emu387.cc djgpp/src/libemu/src/emu387.cc
--- djgpp.orig/src/libemu/src/emu387.cc	Sun Mar 18 17:59:22 2001
+++ djgpp/src/libemu/src/emu387.cc	Mon Feb 11 18:45:16 2002
@@ -5,6 +5,7 @@
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <setjmp.h>
 #include <string.h>
 
@@ -142,7 +143,10 @@
 static void eprintf(const char *f, ...)
 {
   char buf[1000];
-  vsprintf(buf, f, (&f)+1);
+  va_list args;
+  va_start(args, f);
+  vsprintf(buf, f, args);
+  va_end(args);
   _write(1, buf, strlen(buf));
 }
 #endif



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019