.. index:: -gnateG (gcc)
-:switch:`-gnateG`
- Save result of preprocessing in a text file.
+:switch:`-gnateG[bce]`
+ Save result of preprocessing in a text file. An optional character (b, c,
+ or e) can be appended to indicate that filtered lines are to be replaced by
+ blank lines, comment lines that include the filtered line, or empty comment
+ lines ("--!"), respectively. The default is to replace filtered lines with
+ blank lines.
.. index:: -gnateH (gcc)
don't specify a value, the symbol is defined to be ``True``. You can
use this switch instead of providing a definition file.
+.. index:: -e (gnatprep)
+
+:switch:`-e`
+ Causes both preprocessor lines and the lines deleted by
+ preprocessing to be replaced by empty comment lines marked
+ with ``"--!"`` (and no other text) in the output source file,
+ preserving line numbers in the output file. This option can
+ be useful as an alternative to :switch:`-b` and :switch:`-c`
+ when compilation style switches like :switch:`-gnatyu` or
+ :switch:`-gnatyM` are used (to avoid warnings about multiple
+ blank lines or lines too long).
+
.. index:: -r (gnatprep)
:switch:`-r`
Causes both preprocessor lines and the lines deleted by
preprocessing to be replaced by blank lines, preserving the line number.
This switch is always implied; however, if specified after :switch:`-c`
- it cancels the effect of :switch:`-c`.
+ or :switch:`-e` it cancels the effect of those switches.
:switch:`-c`
Causes both preprocessor lines and the lines deleted
name defined in a definition file.
+ :switch:`-e`
+ Causes both preprocessor lines and the lines deleted by
+ preprocessing to be replaced by empty comment lines marked
+ with '`--!`' (and no other text) in the output source file,
+
+
:switch:`-s`
Causes a sorted list of symbol names and values to be
listed on the standard output file.
This switch is similar to switch :switch:`-D` of ``gnatprep``.
-:switch:`-gnateG`
+.. index:: -gnateG (gcc)
+
+:switch:`-gnateG[bce]`
When integrated preprocessing is performed on source file :file:`filename.extension`,
create or overwrite :file:`filename.extension.prep` to contain
the result of the preprocessing.
For example if the source file is :file:`foo.adb` then
the output file is :file:`foo.adb.prep`.
+ An optional character (b, c, or e) can be appended to indicate that filtered
+ lines are to be replaced by blank lines, comments, or empty comments (see
+ documentation above about :switch:`-b`, :switch:`-c`, and :switch:`-e`).
+ If one of those switches is given in a preprocessor data file, then it
+ will override any option included with :switch:`-gnateG`.
.. _Mixed_Language_Programming:
use this switch instead of providing a definition file.
@end table
+@geindex -e (gnatprep)
+
+
+@table @asis
+
+@item @code{-e}
+
+Causes both preprocessor lines and the lines deleted by
+preprocessing to be replaced by empty comment lines marked
+with @code{"--!"} (and no other text) in the output source file,
+preserving line numbers in the output file. This option can
+be useful as an alternative to @code{-b} and @code{-c}
+when compilation style switches like @code{-gnatyu} or
+@code{-gnatyM} are used (to avoid warnings about multiple
+blank lines or lines too long).
+@end table
+
@geindex -r (gnatprep)
Causes both preprocessor lines and the lines deleted by
preprocessing to be replaced by blank lines, preserving the line number.
This switch is always implied; however, if specified after @code{-c}
-it cancels the effect of @code{-c}.
+or @code{-e} it cancels the effect of those switches.
@item @code{-c}
symbol declared with this switch replaces a symbol with the same
name defined in a definition file.
+@item @code{-e}
+
+Causes both preprocessor lines and the lines deleted by
+preprocessing to be replaced by empty comment lines marked
+with ‘@cite{–!}’ (and no other text) in the output source file,
+
@item @code{-s}
Causes a sorted list of symbol names and values to be
switch @code{-D} in the preprocessor data file.
This switch is similar to switch @code{-D} of @code{gnatprep}.
+@end table
+
+@geindex -gnateG (gcc)
-@item @code{-gnateG}
+
+@table @asis
+
+@item @code{-gnateG[bce]}
When integrated preprocessing is performed on source file @code{filename.extension},
create or overwrite @code{filename.extension.prep} to contain
the result of the preprocessing.
For example if the source file is @code{foo.adb} then
the output file is @code{foo.adb.prep}.
+An optional character (b, c, or e) can be appended to indicate that filtered
+lines are to be replaced by blank lines, comments, or empty comments (see
+documentation above about @code{-b}, @code{-c}, and @code{-e}).
+If one of those switches is given in a preprocessor data file, then it
+will override any option included with @code{-gnateG}.
@end table
@node Mixed Language Programming,GNAT and Other Compilation Models,Conditional Compilation,The GNAT Compilation Model
@table @asis
-@item @code{-gnateG}
+@item @code{-gnateG[bce]}
-Save result of preprocessing in a text file.
+Save result of preprocessing in a text file. An optional character (b, c,
+or e) can be appended to indicate that filtered lines are to be replaced by
+blank lines, comment lines that include the filtered line, or empty comment
+lines (”–!”), respectively. The default is to replace filtered lines with
+blank lines.
@end table
@geindex -gnateH (gcc)
@printindex ge
-@anchor{d2}@w{ }
@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ }
+@anchor{d2}@w{ }
@c %**end of body
@bye
loop
begin
- Switch := GNAT.Command_Line.Getopt ("D: a b c C r s T u v");
+ Switch := GNAT.Command_Line.Getopt ("D: a b c C e r s T u v");
case Switch is
when ASCII.NUL =>
when 'c' =>
Opt.Comment_Deleted_Lines := True;
+ when 'e' =>
+ Opt.Empty_Comment_Deleted_Lines := True;
+
when 'C' =>
Opt.Replace_In_Comments := True;
Write_Line (" -c Keep preprocessor lines as comments");
Write_Line (" -C Do symbol replacements within comments");
Write_Line (" -D Associate symbol with value");
+ Write_Line (" -e Replace preprocessor lines by empty comment lines");
Write_Line (" -r Generate Source_Reference pragma");
Write_Line (" -s Print a sorted list of symbol names and values");
Write_Line (" -T Use LF as line terminators");
-- True if echoed commands to be written to stdout instead of stderr
Comment_Deleted_Lines : Boolean := False;
- -- GNATPREP
+ -- GNAT, GNATPREP
-- True if source lines removed by the preprocessor should be commented
-- in the output file.
-- GNATBIND
-- Set to True to output chosen elaboration order
+ Empty_Comment_Deleted_Lines : Boolean := False;
+ -- GNAT, GNATPREP
+ -- True if source lines removed by the preprocessor are to be replaced
+ -- by empty comment lines ("--!" and no other text) in the output file.
+
Enable_128bit_Types : Boolean := False;
-- GNAT
-- Set to True to enable the support for 128-bit types in the compiler.
Output (From, To);
end if;
+ New_EOL.all;
+
+ elsif Empty_Comment_Deleted_Lines then
+ Put_Char ('-');
+ Put_Char ('-');
+ Put_Char ('!');
+
New_EOL.all;
end if;
pragma Warnings (On);
type Preproc_Data is record
- Mapping : Symbol_Table.Instance;
- File_Name : File_Name_Type := No_File;
- Deffile : String_Id := No_String;
- Undef_False : Boolean := False;
- Always_Blank : Boolean := False;
- Comments : Boolean := False;
- No_Deletion : Boolean := False;
- List_Symbols : Boolean := False;
- Processed : Boolean := False;
+ Mapping : Symbol_Table.Instance;
+ File_Name : File_Name_Type := No_File;
+ Deffile : String_Id := No_String;
+ Undef_False : Boolean := False;
+ Always_Blank : Boolean := False;
+ Comments : Boolean := False;
+ Empty_Comments : Boolean := False;
+ No_Deletion : Boolean := False;
+ List_Symbols : Boolean := False;
+ Processed : Boolean := False;
end record;
-- Structure to keep the preprocessing data for a file name or for the
-- default (when Name_Id = No_Name).
No_Preproc_Data : constant Preproc_Data :=
- (Mapping => No_Mapping,
- File_Name => No_File,
- Deffile => No_String,
- Undef_False => False,
- Always_Blank => False,
- Comments => False,
- No_Deletion => False,
- List_Symbols => False,
- Processed => False);
+ (Mapping => No_Mapping,
+ File_Name => No_File,
+ Deffile => No_String,
+ Undef_False => False,
+ Always_Blank => False,
+ Comments => False,
+ Empty_Comments => False,
+ No_Deletion => False,
+ List_Symbols => False,
+ Processed => False);
Default_Data : Preproc_Data := No_Preproc_Data;
-- The preprocessing data to be used when no specific preprocessing data
No_Preprocessing := False;
Current_Data.Processed := True;
+ if Opt.Blank_Deleted_Lines then
+ Current_Data.Always_Blank := True;
+
+ elsif Opt.Comment_Deleted_Lines then
+ Current_Data.Comments := True;
+
+ elsif Opt.Empty_Comment_Deleted_Lines then
+ Current_Data.Empty_Comments := True;
+
+ end if;
+
-- Start with an empty, initialized mapping table; use Prep.Mapping,
-- because Prep.Index_Of uses Prep.Mapping.
OK := True;
end if;
+ when 'e' =>
+
+ -- Replace removed lines with empty comment lines ("--!")
+
+ if Name_Len = 1 then
+ Current_Data.Empty_Comments := True;
+ OK := True;
+ end if;
+
when 's' =>
-- List symbols
-- Set the preprocessing flags according to the preprocessing data
- if Current_Data.Comments and not Current_Data.Always_Blank then
- Comment_Deleted_Lines := True;
- Blank_Deleted_Lines := False;
+ if Current_Data.Comments then
+ Comment_Deleted_Lines := True;
+ Empty_Comment_Deleted_Lines := False;
+ Blank_Deleted_Lines := False;
+
+ elsif Current_Data.Always_Blank then
+ Comment_Deleted_Lines := False;
+ Empty_Comment_Deleted_Lines := False;
+ Blank_Deleted_Lines := True;
+
+ -- By default, emit empty comment lines in place of deleted lines
+
else
- Comment_Deleted_Lines := False;
- Blank_Deleted_Lines := True;
+ Comment_Deleted_Lines := False;
+ Empty_Comment_Deleted_Lines := True;
+ Blank_Deleted_Lines := False;
end if;
No_Deletion := Current_Data.No_Deletion;
Generate_Processed_File := True;
Ptr := Ptr + 1;
+ if Ptr <= Max
+ and then Switch_Chars (Ptr) in 'b' | 'c' | 'e'
+ then
+ case Switch_Chars (Ptr) is
+ when 'b' =>
+ Opt.Blank_Deleted_Lines := True;
+ Opt.Comment_Deleted_Lines := False;
+ Opt.Empty_Comment_Deleted_Lines := False;
+
+ when 'c' =>
+ Opt.Blank_Deleted_Lines := False;
+ Opt.Comment_Deleted_Lines := True;
+ Opt.Empty_Comment_Deleted_Lines := False;
+
+ when 'e' =>
+ Opt.Blank_Deleted_Lines := False;
+ Opt.Comment_Deleted_Lines := False;
+ Opt.Empty_Comment_Deleted_Lines := True;
+
+ when others =>
+ raise Program_Error;
+ end case;
+
+ Ptr := Ptr + 1;
+
+ -- Default to emitting blank lines for deleted lines
+ -- when generating a preprocessor output file. This is
+ -- despite the fact that when the file isn't being
+ -- generated, we emit empty comment lines for the
+ -- internally generated output (to avoid conflicts
+ -- with style switches -gnatyu and -gnatyM), but is
+ -- done for compatibility with the behavior of -gnateG
+ -- prior to adding support for empty comment lines.
+
+ else
+ Opt.Blank_Deleted_Lines := True;
+ Opt.Comment_Deleted_Lines := False;
+ Opt.Empty_Comment_Deleted_Lines := False;
+ end if;
+
-- -gnateH (set reverse Bit_Order threshold to 64)
when 'H' =>
-- Line for -gnateG switch
- Write_Switch_Char ("eG");
- Write_Line ("Generate preprocessed source");
+ Write_Switch_Char ("eG[?]");
+ Write_Line ("Generate preprocessed source (?=b/c/e)");
-- Line for -gnateH switch