From c45e5332cc03dc81591dfc409fdc224e4e1643c0 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 18 Jul 2014 11:59:53 +0200 Subject: [PATCH] [multiple changes] 2014-07-18 Robert Dewar * a-witeio.adb: Minor code reorganization. * i-cstrea.ads: Add comment. 2014-07-18 Thomas Quinot * s-oscons-tmplt.c (NAME_MAX): Minor cleaup and comment clarifications. From-SVN: r212801 --- gcc/ada/ChangeLog | 10 ++++++++++ gcc/ada/a-witeio.adb | 18 ++++++++++++------ gcc/ada/i-cstrea.ads | 9 +++++++-- gcc/ada/s-oscons-tmplt.c | 22 +++++++++++++++------- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 59ad09f051dc..fc5a3bede2ff 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2014-07-18 Robert Dewar + + * a-witeio.adb: Minor code reorganization. + * i-cstrea.ads: Add comment. + +2014-07-18 Thomas Quinot + + * s-oscons-tmplt.c (NAME_MAX): Minor cleaup and comment + clarifications. + 2014-07-18 Robert Dewar * g-memdum.adb, g-memdum.ads, exp_strm.adb: Minor reformatting. diff --git a/gcc/ada/a-witeio.adb b/gcc/ada/a-witeio.adb index b1d2bef5ed7f..1f5e4622761f 100644 --- a/gcc/ada/a-witeio.adb +++ b/gcc/ada/a-witeio.adb @@ -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; diff --git a/gcc/ada/i-cstrea.ads b/gcc/ada/i-cstrea.ads index a2d6ab0056d2..020701ec62c4 100644 --- a/gcc/ada/i-cstrea.ads +++ b/gcc/ada/i-cstrea.ads @@ -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); ---------------------------- diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c index 2b16448aafca..7fef2455ecbc 100644 --- a/gcc/ada/s-oscons-tmplt.c +++ b/gcc/ada/s-oscons-tmplt.c @@ -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") -- 2.47.3