[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 18 Jul 2014 09:59:53 +0000 (11:59 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 18 Jul 2014 09:59:53 +0000 (11:59 +0200)
2014-07-18  Robert Dewar  <dewar@adacore.com>

* a-witeio.adb: Minor code reorganization.
* i-cstrea.ads: Add comment.

2014-07-18  Thomas Quinot  <quinot@adacore.com>

* s-oscons-tmplt.c (NAME_MAX): Minor cleaup and comment
clarifications.

From-SVN: r212801

gcc/ada/ChangeLog
gcc/ada/a-witeio.adb
gcc/ada/i-cstrea.ads
gcc/ada/s-oscons-tmplt.c

index 59ad09f..fc5a3be 100644 (file)
@@ -1,5 +1,15 @@
 2014-07-18  Robert Dewar  <dewar@adacore.com>
 
+       * a-witeio.adb: Minor code reorganization.
+       * i-cstrea.ads: Add comment.
+
+2014-07-18  Thomas Quinot  <quinot@adacore.com>
+
+       * s-oscons-tmplt.c (NAME_MAX): Minor cleaup and comment
+       clarifications.
+
+2014-07-18  Robert Dewar  <dewar@adacore.com>
+
        * g-memdum.adb, g-memdum.ads, exp_strm.adb: Minor reformatting.
 
 2014-07-18  Pascal Obry  <obry@adacore.com>
index b1d2bef..1f5e462 100644 (file)
@@ -1082,13 +1082,20 @@ package body Ada.Wide_Text_IO is
       FIO.Check_Write_Status (AP (File));
 
       for K in 1 .. Spacing loop
+
+         --  We use Put here (rather than Putc) so that we get the proper
+         --  behavior on windows for output of Wide_String to the console.
+
          Put (File, Wide_Character'Val (LM));
+
          File.Line := File.Line + 1;
 
-         if File.Page_Length /= 0
-           and then File.Line > File.Page_Length
-         then
+         if File.Page_Length /= 0 and then File.Line > File.Page_Length then
+
+            --  Same situation as above, use Put instead of Putc
+
             Put (File, Wide_Character'Val (PM));
+
             File.Line := 1;
             File.Page := File.Page + 1;
          end if;
@@ -1242,8 +1249,7 @@ package body Ada.Wide_Text_IO is
          Putc (Character'Pos (C), File);
       end Out_Char;
 
-      R : int;
-      pragma Unreferenced (R);
+      Discard : int;
 
    --  Start of processing for Put
 
@@ -1252,7 +1258,7 @@ package body Ada.Wide_Text_IO is
 
       if text_translation_required then
          set_wide_text_mode (fileno (File.Stream));
-         R := fputwc (Wide_Character'Pos (Item), File.Stream);
+         Discard := fputwc (Wide_Character'Pos (Item), File.Stream);
       else
          WC_Out (Item, File.WC_Method);
       end if;
index a2d6ab0..020701e 100644 (file)
@@ -221,13 +221,18 @@ package Interfaces.C_Streams is
    -- Control of Text/Binary Mode --
    ---------------------------------
 
+   --  Is the above section title good enough, given the new addition???
+
    --  If text_translation_required is true, then the following functions may
    --  be used to dynamically switch a file from binary to text mode or vice
    --  versa. These functions have no effect if text_translation_required is
    --  false (i.e. in normal unix mode). Use fileno to get a stream handle.
 
-   procedure set_binary_mode    (handle : int);
-   procedure set_text_mode      (handle : int);
+   procedure set_binary_mode (handle : int);
+   procedure set_text_mode   (handle : int);
+
+   --  The following needs documentation ???
+
    procedure set_wide_text_mode (handle : int);
 
    ----------------------------
index 2b16448..7fef245 100644 (file)
@@ -80,8 +80,11 @@ pragma Style_Checks ("M32766");
 
 /* Feature macro definitions */
 
-/* Define _POSIX_SOURCE to get NAME_MAX, PATH_MAX */
-#define _POSIX_SOURCE
+/**
+ ** Note: we deliberately do not define _POSIX_SOURCE / _POSIX_C_SOURCE
+ ** unconditionally, as on many platforms these macros actually disable
+ ** a number of non-POSIX but useful/required features.
+ **/
 
 #if defined (__linux__) && !defined (_XOPEN_SOURCE)
 /* For Linux, define _XOPEN_SOURCE to get IOV_MAX */
@@ -319,17 +322,22 @@ CND(IOV_MAX, "Maximum writev iovcnt")
 /* NAME_MAX is used to compute the allocation size for a struct dirent
  * passed to readdir() / readdir_r(). However on some systems it is not
  * defined, as it is technically a filesystem dependent property that
- * we should retrieve through pathconf().
+ * we should retrieve through pathconf(). In any case, we do not need a
+ * precise value but only an upper limit.
  */
 #ifndef NAME_MAX
 # ifdef MAXNAMELEN
    /* Solaris has no NAME_MAX but defines MAXNAMELEN */
 #  define NAME_MAX MAXNAMELEN
-# else
-   /* PATH_MAX (maximum length of a full path name) is a safe last
-    * chance fall back.
-    */
+# elif defined(PATH_MAX)
+   /* PATH_MAX (maximum length of a full path name) is a safe fall back */
 #  define NAME_MAX PATH_MAX
+# elif defined(FILENAME_MAX)
+   /* Similarly FILENAME_MAX can provide a safe fall back */
+#  define NAME_MAX FILENAME_MAX
+# else
+   /* Hardcode a reasonably large value as a last chance fallback */
+#  define NAME_MAX 1024
 # endif
 #endif
 CND(NAME_MAX, "Maximum file name length")