[multiple changes]
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 9 Jul 2005 09:33:31 +0000 (09:33 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 9 Jul 2005 09:33:31 +0000 (09:33 +0000)
2005-07-07  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
    Thomas Koenig  <Thomas.Koenig@online.de>

PR libfortran/22217
* io/write.c (extract_unit):  New function; extract
ints as unsigned signed int of the correct size.
* io/write.c (write_int):  Use it.
* runtime/error.c:  Adjust copyright years.
Adjust size of buffer to maximum that can occur.

2005-07-07  Thomas Koenig  <Thomas.Koenig@online.de>

PR libfortran/22217
* gfortran.dg/negative-z-descriptor.f90:  New test.

From-SVN: r101829

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/negative-z-descriptor.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/write.c
libgfortran/runtime/error.c

index f61b473..7717a13 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-09  Thomas Koenig  <Thomas.Koenig@online.de>
+
+       PR libfortran/22217
+       * gfortran.dg/negative-z-descriptor.f90:  New test.
+
 2005-07-08  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR tree-opt/22329
 2005-07-08  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR tree-opt/22329
diff --git a/gcc/testsuite/gfortran.dg/negative-z-descriptor.f90 b/gcc/testsuite/gfortran.dg/negative-z-descriptor.f90
new file mode 100644 (file)
index 0000000..1ad3a32
--- /dev/null
@@ -0,0 +1,27 @@
+! { dg-do run }
+! PR 22217:  Z edit descriptor with negative numbers used to give lots of *
+
+program main
+  character(len=70) line
+  character(len=20) fmt
+  write(unit=line,fmt='(Z4)') -1_1
+  if (line(1:4) .ne. '  FF') call abort
+  write(unit=line,fmt='(Z5)') -1_2
+  if (line(1:5) .ne. ' FFFF') call abort
+  write(unit=line,fmt='(Z9)') -1_4
+  if (line(1:9) .ne. ' FFFFFFFF') call abort
+  write(unit=line,fmt='(Z17)') -2_8
+  if (line(1:17) .ne. ' FFFFFFFFFFFFFFFE') call abort
+  write(unit=line,fmt='(Z2)') 10_8
+  if (line(1:2) .ne. ' A') call abort
+
+  write(unit=line,fmt='(Z8)') -43_8
+  if (line(1:1) .ne. '*') call abort
+
+  write(unit=line,fmt='(B65)') -1_8
+  if (line(1:2) .ne. ' 1') call abort
+  if (line(64:66) .ne. '11 ') call abort
+
+  write(unit=line,fmt='(O4)') -2_1
+  if (line(1:4) .ne. ' 376') call abort
+end
index 9fb6c5b..a73202d 100644 (file)
@@ -1,3 +1,13 @@
+2005-07-09  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+           Thomas Koenig  <Thomas.Koenig@online.de>
+
+       PR libfortran/22217
+       * io/write.c (extract_unit):  New function; extract
+       ints as unsigned signed int of the correct size.
+       * io/write.c (write_int):  Use it.
+       * runtime/error.c:  Adjust copyright years.
+       Adjust size of buffer to maximum that can occur.
+
 2005-07-07  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * libgfortran.h (GFC_ARRAY_DESCRIPTOR): Replace 'type *base' by
 2005-07-07  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * libgfortran.h (GFC_ARRAY_DESCRIPTOR): Replace 'type *base' by
index 0e2a3ac..5603d6d 100644 (file)
@@ -102,6 +102,40 @@ extract_int (const void *p, int len)
   return i;
 }
 
   return i;
 }
 
+static GFC_UINTEGER_LARGEST
+extract_uint (const void *p, int len)
+{
+  GFC_UINTEGER_LARGEST i = 0;
+
+  if (p == NULL)
+    return i;
+
+  switch (len)
+    {
+    case 1:
+      i = (GFC_UINTEGER_1) *((const GFC_INTEGER_1 *) p);
+      break;
+    case 2:
+      i = (GFC_UINTEGER_2) *((const GFC_INTEGER_2 *) p);
+      break;
+    case 4:
+      i = (GFC_UINTEGER_4) *((const GFC_INTEGER_4 *) p);
+      break;
+    case 8:
+      i = (GFC_UINTEGER_8) *((const GFC_INTEGER_8 *) p);
+      break;
+#ifdef HAVE_GFC_INTEGER_16
+    case 16:
+      i = (GFC_UINTEGER_16) *((const GFC_INTEGER_16 *) p);
+      break;
+#endif
+    default:
+      internal_error ("bad integer kind");
+    }
+
+  return i;
+}
+
 static GFC_REAL_LARGEST
 extract_real (const void *p, int len)
 {
 static GFC_REAL_LARGEST
 extract_real (const void *p, int len)
 {
@@ -802,7 +836,7 @@ write_int (fnode *f, const char *source, int len,
   w = f->u.integer.w;
   m = f->u.integer.m;
 
   w = f->u.integer.w;
   m = f->u.integer.m;
 
-  n = extract_int (source, len);
+  n = extract_uint (source, len);
 
   /* Special case:  */
 
 
   /* Special case:  */
 
index 8b42041..ff91b96 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
    Contributed by Andy Vaught
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -63,7 +63,8 @@ iexport_data(filename);
 unsigned line = 0;
 iexport_data(line);
 
 unsigned line = 0;
 iexport_data(line);
 
-static char buffer[32];                /* buffer for integer/ascii conversions */
+/* buffer for integer/ascii conversions.  */
+static char buffer[sizeof (GFC_UINTEGER_LARGEST) * 8 + 1];
 
 
 /* Returns a pointer to a static buffer. */
 
 
 /* Returns a pointer to a static buffer. */