aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ghdldrv/ghdllocal.adb34
-rw-r--r--src/options.adb8
-rw-r--r--src/vhdl/scanner.adb28
-rw-r--r--src/vhdl/scanner.ads2
4 files changed, 37 insertions, 35 deletions
diff --git a/src/ghdldrv/ghdllocal.adb b/src/ghdldrv/ghdllocal.adb
index 2a231d693..59c02a54e 100644
--- a/src/ghdldrv/ghdllocal.adb
+++ b/src/ghdldrv/ghdllocal.adb
@@ -1507,18 +1507,18 @@ package body Ghdllocal is
function Is_Bad_Unit_Name return Boolean is
begin
- if Nam_Length = 0 then
+ if Name'Length = 0 then
return True;
end if;
-- Don't try to handle extended identifier.
- if Nam_Buffer (1) = '\' then
+ if Name (Name'First) = '\' then
return False;
end if;
-- Look for suspicious characters.
-- Do not try to be exhaustive as the correct check will be done
-- by convert_identifier.
- for I in 1 .. Nam_Length loop
- case Nam_Buffer (I) is
+ for I in Name'Range loop
+ case Name (I) is
when '.' | '/' | '\' =>
return True;
when others =>
@@ -1531,36 +1531,35 @@ package body Ghdllocal is
function Is_A_File_Name return Boolean is
begin
-- Check .vhd
- if Nam_Length > 4
- and then Nam_Buffer (Nam_Length - 3 .. Nam_Length) = ".vhd"
+ if Name'Length > 4
+ and then Name (Name'Last - 3 .. Name'Last) = ".vhd"
then
return True;
end if;
-- Check .vhdl
- if Nam_Length > 5
- and then Nam_Buffer (Nam_Length - 4 .. Nam_Length) = ".vhdl"
+ if Name'Length > 5
+ and then Name (Name'Last - 4 .. Name'Last) = ".vhdl"
then
return True;
end if;
-- Check ../
- if Nam_Length > 3
- and then Nam_Buffer (1 .. 3) = "../"
+ if Name'Length > 3
+ and then Name (Name'First .. Name'First + 2) = "../"
then
return True;
end if;
-- Check ..\
- if Nam_Length > 3
- and then Nam_Buffer (1 .. 3) = "..\"
+ if Name'Length > 3
+ and then Name (Name'First .. Name'First + 2) = "..\"
then
return True;
end if;
-- Should try to find the file ?
return False;
end Is_A_File_Name;
- begin
- Nam_Length := Name'Length;
- Nam_Buffer (1 .. Nam_Length) := Name.all;
+ Res : String_Access;
+ begin
-- Try to identifier bad names (such as file names), so that
-- friendly message can be displayed.
if Is_Bad_Unit_Name then
@@ -1571,8 +1570,9 @@ package body Ghdllocal is
end if;
raise Option_Error;
end if;
- Scanner.Convert_Identifier;
- return new String'(Nam_Buffer (1 .. Nam_Length));
+ Res := new String'(Name.all);
+ Scanner.Convert_Identifier (Res.all);
+ return Res;
end Convert_Name;
procedure Extract_Elab_Unit
diff --git a/src/options.adb b/src/options.adb
index 224560f88..9622140c8 100644
--- a/src/options.adb
+++ b/src/options.adb
@@ -119,11 +119,11 @@ package body Options is
elsif Opt'Length > 7 and then Opt (1 .. 7) = "--work=" then
declare
use Name_Table;
+ Name : String (1 .. Opt'Last - 8 + 1);
begin
- Nam_Length := Opt'Last - 8 + 1;
- Nam_Buffer (1 .. Nam_Length) := Opt (8 .. Opt'Last);
- Scanner.Convert_Identifier;
- Libraries.Work_Library_Name := Get_Identifier;
+ Name := Opt (8 .. Opt'Last);
+ Scanner.Convert_Identifier (Name);
+ Libraries.Work_Library_Name := Get_Identifier (Name);
end;
elsif Opt = "-C" or else Opt = "--mb-comments" then
Mb_Comment := True;
diff --git a/src/vhdl/scanner.adb b/src/vhdl/scanner.adb
index fdafdae27..ab4695b78 100644
--- a/src/vhdl/scanner.adb
+++ b/src/vhdl/scanner.adb
@@ -1297,7 +1297,7 @@ package body Scanner is
Current_Token := Tok_Identifier;
end Scan_Extended_Identifier;
- procedure Convert_Identifier
+ procedure Convert_Identifier (Str : in out String)
is
procedure Error_Bad is
begin
@@ -1311,36 +1311,38 @@ package body Scanner is
use Name_Table;
C : Character;
+ subtype Id_Subtype is String (1 .. Str'Length);
+ Id : Id_Subtype renames Str;
begin
- if Nam_Length = 0 then
+ if Id'Length = 0 then
Error_Msg_Option ("identifier required");
return;
end if;
- if Nam_Buffer (1) = '\' then
+ if Id (1) = '\' then
-- Extended identifier.
if Vhdl_Std = Vhdl_87 then
Error_Msg_Option ("extended identifiers not allowed in vhdl87");
return;
end if;
- if Nam_Length < 3 then
+ if Id'Length < 3 then
Error_Msg_Option ("extended identifier is too short");
return;
end if;
- if Nam_Buffer (Nam_Length) /= '\' then
+ if Id (Id'Last) /= '\' then
Error_Msg_Option ("extended identifier must finish with a '\'");
return;
end if;
- for I in 2 .. Nam_Length - 1 loop
- C := Nam_Buffer (I);
+ for I in 2 .. Id'Last - 1 loop
+ C := Id (I);
case Characters_Kind (C) is
when Format_Effector =>
Error_Msg_Option ("format effector in extended identifier");
return;
when Graphic_Character =>
if C = '\' then
- if Nam_Buffer (I + 1) /= '\'
+ if Id (I + 1) /= '\'
or else I = Nam_Length - 1
then
Error_Msg_Option ("anti-slash must be doubled "
@@ -1354,14 +1356,14 @@ package body Scanner is
end loop;
else
-- Identifier
- for I in 1 .. Nam_Length loop
- C := Nam_Buffer (I);
+ for I in 1 .. Id'Length loop
+ C := Id (I);
case Characters_Kind (C) is
when Upper_Case_Letter =>
if Vhdl_Std = Vhdl_87 and C > 'Z' then
Error_8bit;
end if;
- Nam_Buffer (I) := To_Lower_Map (C);
+ Id (I) := To_Lower_Map (C);
when Lower_Case_Letter | Digit =>
if Vhdl_Std = Vhdl_87 and C > 'z' then
Error_8bit;
@@ -1374,12 +1376,12 @@ package body Scanner is
("identifier cannot start with an underscore");
return;
end if;
- if Nam_Buffer (I - 1) = '_' then
+ if Id (I - 1) = '_' then
Error_Msg_Option
("two underscores can't be consecutive");
return;
end if;
- if I = Nam_Length then
+ if I = Id'Last then
Error_Msg_Option
("identifier cannot finish with an underscore");
return;
diff --git a/src/vhdl/scanner.ads b/src/vhdl/scanner.ads
index 05f45f663..610d63140 100644
--- a/src/vhdl/scanner.ads
+++ b/src/vhdl/scanner.ads
@@ -119,7 +119,7 @@ package Scanner is
-- given in the command line.
-- Errors are directly reported through error_msg_option.
-- Also, Vhdl_Std should be set.
- procedure Convert_Identifier;
+ procedure Convert_Identifier (Str : in out String);
-- Return TRUE iff C is a whitespace.
-- LRM93 13.2 Lexical elements, separators, and delimiters