gnat_ugn.texi, [...] (Suffix_Matches): A suffix can also match the full base name of the file when...

2009-06-24  Emmanuel Briot  <briot@adacore.com>

	* gnat_ugn.texi, prj-nmsc.adb (Suffix_Matches): A suffix can also match
	the full base name of the file when the suffix doesn't start with a '.'.

From-SVN: r148903
This commit is contained in:
Emmanuel Briot 2009-06-24 09:51:10 +00:00 committed by Arnaud Charlet
parent 95cd3246e6
commit 2b42667481
3 changed files with 32 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2009-06-24 Emmanuel Briot <briot@adacore.com>
* gnat_ugn.texi, prj-nmsc.adb (Suffix_Matches): A suffix can also match
the full base name of the file when the suffix doesn't start with a '.'.
2009-06-24 Vincent Celier <celier@adacore.com>
* prj-nmsc.adb (Check): A project declared abstract is legal if no

View File

@ -12572,10 +12572,12 @@ The current list of qualifiers is:
@itemize @bullet
@item
@code{abstract}: qualify a project with no sources. An abstract project must
have a declaration specifying that there are no sources in the project, and,
if it extends another project, the project it extends must also be a qualified
abstract project.
@code{abstract}: qualify a project with no sources. A qualified abstract
project must either have no declaration of attributes @code{Source_Dirs},
@code{Source_Files}, @code{Languages} or @code{Source_List_File}, or one of
@code{Source_Dirs}, @code{Source_Files}, or @code{Languages} must be declared
as empty. If it extends another project, the project it extends must also be a
qualified abstract project.
@item
@code{standard}: a standard project is a non library project with sources.
@ -13870,6 +13872,14 @@ same string, then a file name that ends with the longest of these two suffixes
will be a body if the longest suffix is @code{Body_Suffix ("Ada")} or a spec
if the longest suffix is @code{Spec_Suffix ("Ada")}.
If the suffix does not start with a '.', a file with a name exactly equal
to the suffix will also be part of the project (for instance if you define
the suffix as @code{Makefile}, a file called @file{Makefile} will be part
of the project. This is not interesting in general when using projects to
compile. However, it might become useful when a project is also used to
find the list of source files in an editor, like the GNAT Programming System
(GPS).
If @code{Body_Suffix ("Ada")} is not specified, then the default is
@code{"^.adb^.ADB^"}.

View File

@ -628,6 +628,7 @@ package body Prj.Nmsc is
(Filename : String;
Suffix : File_Name_Type) return Boolean
is
Min_Prefix_Length : Natural := 0;
begin
if Suffix = No_File or else Suffix = Empty_File then
return False;
@ -636,7 +637,18 @@ package body Prj.Nmsc is
declare
Suf : constant String := Get_Name_String (Suffix);
begin
return Filename'Length > Suf'Length
-- The file name must end with the suffix (which is not an extension)
-- For instance a suffix "configure.in" must match a file with the
-- same name. To avoid dummy cases, though, a suffix starting with
-- '.' requires a file that is at least one character longer ('.cpp'
-- should not match a file with the same name)
if Suf (Suf'First) = '.' then
Min_Prefix_Length := 1;
end if;
return Filename'Length >= Suf'Length + Min_Prefix_Length
and then Filename
(Filename'Last - Suf'Length + 1 .. Filename'Last) = Suf;
end;