summaryrefslogtreecommitdiff
path: root/gcc/ada/g-regpat.adb
diff options
context:
space:
mode:
authorbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-11 23:14:07 +0000
committerbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-11 23:14:07 +0000
commit9ffca0cd58b37593feacfcbfd9e10c767ab16f49 (patch)
treee7c51126c4c56276a05c1955bd4b196956a352c7 /gcc/ada/g-regpat.adb
parent23551094631c8b413f1b8d81e05d854b96753f87 (diff)
downloadgcc-9ffca0cd58b37593feacfcbfd9e10c767ab16f49.tar.gz
* gnatmain.adb: Initial version.
* gnatmain.ads: Initial version. * prj-attr.adb (Initialisation_Data): Add package Gnatstub. * snames.adb: Updated to match snames.ads. * snames.ads: Added Gnatstub. * prj-attr.adb (Initialization_Data): Change name from Initialisation_Data. * g-regpat.adb (Parse_Literal): Properly handle simple operators ?, + and * applied to backslashed expressions like \r. * g-os_lib.ads: String_List type added, Argument_List type is now subtype of String_List. * g-os_lib.ads: Change copyright to FSF Add comments for String_List type * g-dirope.adb (Expand_Path): Fix bug. (wrong length when adding a string to the buffer). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47905 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-regpat.adb')
-rw-r--r--gcc/ada/g-regpat.adb20
1 files changed, 13 insertions, 7 deletions
diff --git a/gcc/ada/g-regpat.adb b/gcc/ada/g-regpat.adb
index f36d5bf9ffc..ab1b69c79d0 100644
--- a/gcc/ada/g-regpat.adb
+++ b/gcc/ada/g-regpat.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- $Revision: 1.31 $
+-- $Revision$
-- --
-- Copyright (C) 1986 by University of Toronto. --
-- Copyright (C) 1996-2001 Ada Core Technologies, Inc. --
@@ -1563,6 +1563,7 @@ package body GNAT.Regpat is
Start_Pos : Natural := 0;
C : Character;
Length_Ptr : Pointer;
+ Has_Special_Operator : Boolean := False;
begin
Parse_Pos := Parse_Pos - 1; -- Look at current character
@@ -1585,6 +1586,7 @@ package body GNAT.Regpat is
when '.' | '[' | '(' | ')' | '|' | ASCII.LF | '$' | '^' =>
if Start_Pos = 0 then
+ Start_Pos := Parse_Pos;
Emit (C); -- First character is always emitted
else
exit Parse_Loop; -- Else we are done
@@ -1593,12 +1595,14 @@ package body GNAT.Regpat is
when '?' | '+' | '*' | '{' =>
if Start_Pos = 0 then
+ Start_Pos := Parse_Pos;
Emit (C); -- First character is always emitted
-- Are we looking at an operator, or is this
-- simply a normal character ?
elsif not Is_Mult (Parse_Pos) then
- Case_Emit (C);
+ Start_Pos := Parse_Pos;
+ Case_Emit (C);
else
-- We've got something like "abc?d". Mark this as a
-- special case. What we want to emit is a first
@@ -1606,11 +1610,12 @@ package body GNAT.Regpat is
-- ultimately be transformed with a CURLY operator, A
-- special case has to be handled for "a?", since there
-- is no initial string to emit.
- Start_Pos := Natural'Last;
+ Has_Special_Operator := True;
exit Parse_Loop;
end if;
when '\' =>
+ Start_Pos := Parse_Pos;
if Parse_Pos = Parse_End then
Fail ("Trailing \");
else
@@ -1629,12 +1634,13 @@ package body GNAT.Regpat is
Parse_Pos := Parse_Pos + 1;
end if;
- when others => Case_Emit (C);
+ when others =>
+ Start_Pos := Parse_Pos;
+ Case_Emit (C);
end case;
exit Parse_Loop when Emit_Ptr - Length_Ptr = 254;
- Start_Pos := Parse_Pos;
Parse_Pos := Parse_Pos + 1;
exit Parse_Loop when Parse_Pos > Parse_End;
@@ -1643,11 +1649,11 @@ package body GNAT.Regpat is
-- Is the string followed by a '*+?{' operator ? If yes, and if there
-- is an initial string to emit, do it now.
- if Start_Pos = Natural'Last
+ if Has_Special_Operator
and then Emit_Ptr >= Length_Ptr + 3
then
Emit_Ptr := Emit_Ptr - 1;
- Parse_Pos := Parse_Pos - 1;
+ Parse_Pos := Start_Pos;
end if;
if Emit_Code then