1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
------------------------------------------------------------------------------
-- --
-- GNATPP COMPONENTS --
-- --
-- A S I S _ U L . E N V I R O N M E N T . C H E C K _ P A R A M E T E R S --
-- --
-- (adapted for gnatpp from ASIS Utility Library) --
-- --
-- B o d y --
-- --
-- Copyright (C) 2009-2017, AdaCore --
-- --
-- GNATPP is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or ( at your option) any later --
-- version. GNATCHECK is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with GNAT; see file COPYING3. If --
-- not, go to http://www.gnu.org/licenses for a complete copy of the --
-- license. --
-- --
-- GNATPP is maintained by AdaCore (http://www.adacore.com) --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with System.WCh_Con;
use type System.WCh_Con.WC_Encoding_Method;
with ASIS_UL.Tree_Creation;
with GNATPP.Options; use GNATPP.Options;
with GNATPP.Output; use GNATPP.Output;
with GNATPP.Projects;
separate (ASIS_UL.Environment)
procedure Check_Parameters is
begin
if Verbose_Mode and then not Mimic_gcc then
-- In incremental mode, we want Verbose_Mode to print this only in the
-- outer invocation.
Print_Version_Info (2003);
end if;
if ASIS_UL.Options.Generate_XML_Help then
XML_Help;
return;
end if;
-- First, read all the argument files using all available path information
if ASIS_UL.Options.No_Argument_File_Specified then
Error ("No input source file set");
raise Parameter_Error;
end if;
Read_Args_From_Temp_Storage
(Duplication_Report =>
not GNATPP.Projects.Is_Specified (GNATPP.Options.Gnatpp_Prj),
Arg_Project => GNATPP.Options.Gnatpp_Prj);
Nothing_To_Do := Last_Source < First_SF_Id;
if Nothing_To_Do then
Error ("No existing file to process");
-- All the rest does not make any sense
return;
end if;
if ASIS_UL.Options.Exempted_Units /= null
and then Incremental_Mode
then
Error ("--ignore option cannot be used in incremental mode");
Brief_Help;
raise Parameter_Error;
end if;
if RM_Style_Spacing then
-- RM-style colons are incompatible with aligning them
Align_Colons_In_Decl := False;
Align_Asign_In_Decl := False;
Align_Asign_In_Stmts := False;
Align_Arrows := False;
Align_Ats := False;
end if;
if GNATPP.Options.Gnatpp_Prj.Is_Specified then
GNATPP.Projects.Set_Global_Result_Dirs (GNATPP.Options.Gnatpp_Prj);
GNATPP.Projects.Set_Individual_Source_Options
(GNATPP.Options.Gnatpp_Prj);
Set_Arg_List;
end if;
if ASIS_UL.Options.Exempted_Units /= null then
Process_Exemptions (ASIS_UL.Options.Exempted_Units.all);
end if;
Total_Sources := Total_Sources_To_Process;
if Total_Sources = 0 then
Error ("No existing file to process");
-- All the rest does not make any sense
return;
end if;
Sources_Left := Total_Sources;
-- Check that GNAT_Comment_Inden and Standard_Comment_Indent
-- are not set together
if GNAT_Comment_Inden and then Standard_Comment_Indent then
Put (Standard_Error,
"gnatpp: comment processing modes -c1 and -c2 ");
Put_Line (Standard_Error, "can not be set together");
raise Parameter_Error;
end if;
-- If --output-dir= was given on the command line, set Output_Mode to the
-- corresponding mode.
if Out_Dir /= null then
Output_Mode := Out_Directory;
end if;
if Incremental_Mode
and then Output_Mode not in Out_Directory | Replace_Modes
then
Error ("in --incremental mode, must also specify " &
"-rnb, -rf, -r, or --output-dir=");
raise Parameter_Error;
end if;
if Output_Mode = Pipe then
if Out_File_Format /= Default then
Put_Line (Standard_Error,
"gnatpp: out file format can not be set in pipe mode");
raise Parameter_Error;
end if;
-- Check that the out file format is not set for the pipe output mode:
if Out_File_Format /= Default then
Put_Line (Standard_Error,
"gnatpp: out file format can not be set in pipe mode");
raise Parameter_Error;
end if;
-- Check that the out file encoding is not set for the pipe output mode,
-- and set the needed value for the Form parameter for the Create
-- and Open procedures:
if Output_Encoding /= WCEM_Default then
Put_Line (Standard_Error,
"gnatpp: out file encoding can not be set in pipe mode");
raise Parameter_Error;
end if;
else
Set_Form_String;
end if;
-- Check that there is no contradictory settings for THEN and LOOP
-- keyword layout
if Separate_Line_For_THEN_and_LOOP and then
No_Separate_Line_For_THEN_and_LOOP
then
Put (Standard_Error,
"gnatpp: --separate-loop-then and --no-separate-loop-then");
Put_Line (Standard_Error,
" can not be set together");
raise Parameter_Error;
end if;
if Last_Source = First_SF_Id then
Multiple_File_Mode := False;
-- If we have only one source to reformat, we have to check
-- the settings of the output file, if it is set
Progress_Indicator_Mode := False;
-- We do not need this in case of one file, and we may be in the
-- mode of outputting the reformatted source into Stdout
if Output_Mode in Create_Modes then
-- We have to set the output file here, before we get into the
-- temporary directory
if Res_File_Name /= null and then
Is_Regular_File (Res_File_Name.all)
then
if Output_Mode = Create_File then
Put (Standard_Error, "gnatpp: file ");
Put (Standard_Error, Res_File_Name.all);
Put (Standard_Error, " exists. Use '-of' option");
Put (Standard_Error, " to override");
New_Line (Standard_Error);
raise Parameter_Error;
end if;
end if;
Res_File_Name := new String'(Normalize_Pathname (Res_File_Name.all));
end if;
else
-- If we have more than one file to reformat, we can not have options
-- '-o' or '-of' set
Multiple_File_Mode := True;
if Output_Mode in Create_Modes then
Put (Standard_Error, "gnatpp: explicit output file name is not ");
Put (Standard_Error, "allowed when multiple ");
Put_Line (Standard_Error, "argument sources set");
raise Parameter_Error;
end if;
end if;
-- And now - some preparations:
-- Compute the default continuation line indentation, if needed
if not PP_Cont_Line_Indentation_Set then
PP_Cont_Line_Indentation := PP_Indentation;
if PP_Cont_Line_Indentation > 1 then
PP_Cont_Line_Indentation := PP_Cont_Line_Indentation - 1;
end if;
end if;
-- Set casing for specific kinds of names
if not PP_Enum_Literal_Casing_Specified then
PP_Enum_Literal_Casing := PP_Name_Casing;
end if;
if not PP_Type_Casing_Specified then
PP_Type_Casing := PP_Name_Casing;
end if;
if not PP_Nnumbers_Casing_Specified then
PP_Nnumbers_Casing := PP_Name_Casing;
end if;
if Test_Mode then
End_Labels := False;
end if;
-- Check that user did not specify --pp-off=X and --pp-on=X, where X = X
if Pp_Off_String /= null and then Pp_On_String /= null then
if Pp_Off_String.all = Pp_On_String.all then
Put_Line
(Standard_Error,
"gnatpp: cannot specify --pp-off and --pp-on with same string");
raise Parameter_Error;
end if;
end if;
Set_Arg_List;
ASIS_UL.Tree_Creation.Set_Max_Processes;
if J_Specified
and then Output_Mode in Replace_Modes
and then not Incremental_Mode
then
Error ("-j cannot be used with " &
(case Output_Mode is
when Replace => "-r",
when Force_Replace => "-rf",
when Replace_No_Backup => "-rnb",
when others => "") &
" option unless --incremental is used");
raise Parameter_Error;
end if;
end Check_Parameters;
|