This change ensures that verbose debugging/diagnostics messages emitted by gnatls/gnat list are sent to stderr instead of being interspersed with the normal stdout output.
Tested on x86_64-pc-linux-gnu, committed on trunk 2011-12-21 Thomas Quinot <qui...@adacore.com> * gnatls.adb (Gnatls): Call Set_Standard_Error at startup, and then Set_Standard_Output just before producing normal (non-diagnostic) output. * gnatcmd.adb (Gnatcmd): Call Set_Standard_Error at initialization (and again after parsing project files).
Index: gnatcmd.adb =================================================================== --- gnatcmd.adb (revision 182572) +++ gnatcmd.adb (working copy) @@ -34,7 +34,7 @@ with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; -with Output; +with Output; use Output; with Prj; use Prj; with Prj.Env; with Prj.Ext; use Prj.Ext; @@ -1375,6 +1375,10 @@ -- Start of processing for GNATCmd begin + -- All output from GNATCmd is debugging or error output: send to stderr + + Set_Standard_Error; + -- Initializations Csets.Initialize; @@ -1901,6 +1905,10 @@ Env => Root_Environment, Packages_To_Check => Packages_To_Check); + -- Prj.Pars.Parse calls Set_Standard_Output, reset to stderr + + Set_Standard_Error; + if Project = Prj.No_Project then Fail ("""" & Project_File.all & """ processing failed"); end if; Index: gnatls.adb =================================================================== --- gnatls.adb (revision 182572) +++ gnatls.adb (working copy) @@ -1553,6 +1553,7 @@ -- If -l (output license information) is given, it must be the only switch if License and then Arg_Count /= 2 then + Set_Standard_Error; Write_Str ("Can't use -l with another switch"); Write_Eol; Usage; @@ -1713,6 +1714,7 @@ GNATDIST.Output_No_ALI (Lib_File_Name (Main_File)); else + Set_Standard_Error; Write_Str ("Can't find library info for "); Get_Name_String (Main_File); Write_Char ('"'); -- " @@ -1745,6 +1747,10 @@ end if; end loop; + -- Reset default output file descriptor, if needed + + Set_Standard_Output; + if Very_Verbose_Mode then for A in ALIs.First .. ALIs.Last loop GNATDIST.Output_ALI (A);