aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2013-12-29 04:10:36 +0100
committerTristan Gingold <tgingold@free.fr>2013-12-29 04:10:36 +0100
commit8d37e1b6f69f60ccdf1dd8197f1e7225d80c2e05 (patch)
treeffdfd8ec4def9b27c087c5ef1d6104355e773591
parente053480a1adc2d170ab2b4434413e0e56e0e27a1 (diff)
downloadghdl-8d37e1b6f69f60ccdf1dd8197f1e7225d80c2e05.tar.gz
ghdl-8d37e1b6f69f60ccdf1dd8197f1e7225d80c2e05.tar.bz2
ghdl-8d37e1b6f69f60ccdf1dd8197f1e7225d80c2e05.zip
Fix bug16144 (ghdl --lines on empty line).
-rw-r--r--testsuite/gna/bug16144/adder.vhdl2
-rwxr-xr-xtestsuite/gna/bug16144/testsuite.sh7
-rw-r--r--translate/ghdldrv/ghdlprint.adb8
3 files changed, 16 insertions, 1 deletions
diff --git a/testsuite/gna/bug16144/adder.vhdl b/testsuite/gna/bug16144/adder.vhdl
new file mode 100644
index 000000000..139597f9c
--- /dev/null
+++ b/testsuite/gna/bug16144/adder.vhdl
@@ -0,0 +1,2 @@
+
+
diff --git a/testsuite/gna/bug16144/testsuite.sh b/testsuite/gna/bug16144/testsuite.sh
new file mode 100755
index 000000000..7a261edee
--- /dev/null
+++ b/testsuite/gna/bug16144/testsuite.sh
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+$GHDL --lines adder.vhdl
+
+echo "Test successful"
diff --git a/translate/ghdldrv/ghdlprint.adb b/translate/ghdldrv/ghdlprint.adb
index dedc1eb0a..dfe44ff42 100644
--- a/translate/ghdldrv/ghdlprint.adb
+++ b/translate/ghdldrv/ghdlprint.adb
@@ -868,6 +868,7 @@ package body Ghdlprint is
begin
Local_Id := Get_Identifier ("");
for I in Args'Range loop
+ -- Load the file.
Id := Get_Identifier (Args (I).all);
Fe := Files_Map.Load_Source_File (Local_Id, Id);
if Fe = No_Source_File_Entry then
@@ -875,6 +876,8 @@ package body Ghdlprint is
raise Compile_Error;
end if;
Set_File (Fe);
+
+ -- Scan the content, to compute the number of lines.
loop
Scan.Scan;
exit when Current_Token = Tok_Eof;
@@ -925,7 +928,10 @@ package body Ghdlprint is
end loop;
-- Disp line.
- Put (String (Buf (Ptr .. Eptr - 1)));
+ if Eptr > Ptr then
+ -- Avoid constraint error on conversion of nul array.
+ Put (String (Buf (Ptr .. Eptr - 1)));
+ end if;
New_Line;
end loop;
end loop;