summaryrefslogtreecommitdiff
path: root/gcc/ada/sfn_scan.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sfn_scan.adb')
-rw-r--r--gcc/ada/sfn_scan.adb26
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/ada/sfn_scan.adb b/gcc/ada/sfn_scan.adb
index 1652e6eb732..4c2a6dcdfc4 100644
--- a/gcc/ada/sfn_scan.adb
+++ b/gcc/ada/sfn_scan.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2000-2001 Free Software Foundation, Inc. --
+-- Copyright (C) 2000-2002 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -38,6 +38,13 @@ package body SFN_Scan is
use ASCII;
-- Allow easy access to control character definitions
+ EOF : constant Character := ASCII.SUB;
+ -- The character SUB (16#1A#) is used in DOS and other systems derived
+ -- from DOS (OS/2, NT etc) to signal the end of a text file. If this
+ -- character appears as the last character of a file scanned by a call
+ -- to Scan_SFN_Pragmas, then it is ignored, otherwise it is treated as
+ -- an illegal character.
+
type String_Ptr is access String;
S : String_Ptr;
@@ -184,7 +191,22 @@ package body SFN_Scan is
function At_EOF return Boolean is
begin
- return P > S'Last;
+ -- Immediate return (False) if before last character of file
+
+ if P < S'Last then
+ return False;
+
+ -- Special case: DOS EOF character as last character of file is
+ -- allowed and treated as an end of file.
+
+ elsif P = S'Last then
+ return S (P) = EOF;
+
+ -- If beyond last character of file, then definitely at EOF
+
+ else
+ return True;
+ end if;
end At_EOF;
---------------------