aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/lib-util.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-10-14 14:58:07 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2013-10-14 14:58:07 +0200
commite4691ba99bff054f10be59543a6571fdbabbb427 (patch)
tree0da9ae3cf125fe15279d8fbab380186d017f8e4e /gcc/ada/lib-util.adb
parent0a387eca30eaf0766b8de644dd61bf9cadbbf21d (diff)
downloadgcc-e4691ba99bff054f10be59543a6571fdbabbb427.zip
gcc-e4691ba99bff054f10be59543a6571fdbabbb427.tar.gz
gcc-e4691ba99bff054f10be59543a6571fdbabbb427.tar.bz2
[multiple changes]
2013-10-14 Robert Dewar <dewar@adacore.com> * exp_prag.adb, sem_prag.adb, a-exexda.adb, s-vmexta.ads: Minor reformatting. 2013-10-14 Vincent Celier <celier@adacore.com> * ali.adb (Get_File_Name): New Boolean parameter May_Be_Quoted, defaulted to False. Calls Get_Name with May_Be_Quoted. (Get_Name): New Boolean parameter May_Be_Quoted, defaulted to False. If May_Be_Quoted is True and first non blank charater is '"', unquote the name. (Scan_ALI): For the file/path name on the D line, call Get_File_Name with May_Be_Quoted = True, as it may have been quoted. * lib-util.adb, lib-util.ads (Write_Info_Name_May_Be_Quoted): New procedure to write file/path names that may contain spaces and if they do are quoted. * lib-writ.adb (Write_ALI): Use new procedure Write_Info_Name_May_Be_Quoted to write file/path names on D lines. From-SVN: r203534
Diffstat (limited to 'gcc/ada/lib-util.adb')
-rw-r--r--gcc/ada/lib-util.adb47
1 files changed, 46 insertions, 1 deletions
diff --git a/gcc/ada/lib-util.adb b/gcc/ada/lib-util.adb
index 9047690..ae6e204 100644
--- a/gcc/ada/lib-util.adb
+++ b/gcc/ada/lib-util.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -176,6 +176,51 @@ package body Lib.Util is
Write_Info_Name (Name_Id (Name));
end Write_Info_Name;
+ -----------------------------------
+ -- Write_Info_Name_May_Be_Quoted --
+ -----------------------------------
+
+ procedure Write_Info_Name_May_Be_Quoted (Name : File_Name_Type) is
+ Quoted : Boolean := False;
+ Cur : Positive;
+
+ begin
+ Get_Name_String (Name);
+
+ -- The file/path name is quoted only if it includes spaces
+
+ for J in 1 .. Name_Len loop
+ if Name_Buffer (J) = ' ' then
+ Quoted := True;
+ exit;
+ end if;
+ end loop;
+
+ -- Deal with quoting string if needed
+
+ if Quoted then
+ Insert_Str_In_Name_Buffer ("""", 1);
+ Add_Char_To_Name_Buffer ('"');
+
+ -- Any character '"' is doubled
+
+ Cur := 2;
+ while Cur < Name_Len loop
+ if Name_Buffer (Cur) = '"' then
+ Insert_Str_In_Name_Buffer ("""", Cur);
+ Cur := Cur + 2;
+ else
+ Cur := Cur + 1;
+ end if;
+ end loop;
+ end if;
+
+ Info_Buffer (Info_Buffer_Len + 1 .. Info_Buffer_Len + Name_Len) :=
+ Name_Buffer (1 .. Name_Len);
+ Info_Buffer_Len := Info_Buffer_Len + Name_Len;
+ Info_Buffer_Col := Info_Buffer_Col + Name_Len;
+ end Write_Info_Name_May_Be_Quoted;
+
--------------------
-- Write_Info_Nat --
--------------------