summaryrefslogtreecommitdiff
path: root/gcc/ada/a-stwise.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-10 13:51:40 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-10 13:51:40 +0000
commit8ee79a8446354ac1a9e20fd284e879a3d55860ba (patch)
tree63cfc97375650994bb335d260cabbdfd63f70efd /gcc/ada/a-stwise.adb
parent7189d17fd684291638652f906a2c14487fe77419 (diff)
downloadgcc-8ee79a8446354ac1a9e20fd284e879a3d55860ba.tar.gz
2005-02-09 Robert Dewar <dewar@adacore.com>
* a-strunb.ads, a-strunb.adb: Add missing pragma Ada_05 statements Fix name of Set routine * a-strfix.ads, a-strfix.adb: Add new index functions from AI-301 to fixed packages. * a-stwise.ads, a-stwise.adb, a-stwifi.ads, a-stwifi.adb, a-strsea.ads, a-strsea.adb: Add new index functions from AI-301 to fixed packages * a-witeio.ads, a-witeio.adb, a-textio.ads, a-textio.adb: New function forms of Get_Line subprograms for AI-301. * a-wtcoau.adb, a-wtcoau.ads, a-wtcoio.adb, a-wtcoio.ads, a-wtedit.adb, a-wtedit.adb, a-wtedit.ads, a-wttest.adb, a-wttest.ads, a-strmap.ads, a-strmap.adb, a-stwima.adb, a-stwima.ads: Minor reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94810 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-stwise.adb')
-rw-r--r--gcc/ada/a-stwise.adb176
1 files changed, 134 insertions, 42 deletions
diff --git a/gcc/ada/a-stwise.adb b/gcc/ada/a-stwise.adb
index a8b8ae910f3..d1eae0ed637 100644
--- a/gcc/ada/a-stwise.adb
+++ b/gcc/ada/a-stwise.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005 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- --
@@ -42,8 +42,7 @@ package body Ada.Strings.Wide_Search is
function Belongs
(Element : Wide_Character;
Set : Wide_Maps.Wide_Character_Set;
- Test : Membership)
- return Boolean;
+ Test : Membership) return Boolean;
pragma Inline (Belongs);
-- Determines if the given element is in (Test = Inside) or not in
-- (Test = Outside) the given character set.
@@ -55,9 +54,8 @@ package body Ada.Strings.Wide_Search is
function Belongs
(Element : Wide_Character;
Set : Wide_Maps.Wide_Character_Set;
- Test : Membership)
- return Boolean is
-
+ Test : Membership) return Boolean
+ is
begin
if Test = Inside then
return Is_In (Element, Set);
@@ -71,10 +69,10 @@ package body Ada.Strings.Wide_Search is
-----------
function Count
- (Source : in Wide_String;
- Pattern : in Wide_String;
- Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
- return Natural
+ (Source : Wide_String;
+ Pattern : Wide_String;
+ Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
+ return Natural
is
N : Natural;
J : Natural;
@@ -117,10 +115,9 @@ package body Ada.Strings.Wide_Search is
end Count;
function Count
- (Source : in Wide_String;
- Pattern : in Wide_String;
- Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
- return Natural
+ (Source : Wide_String;
+ Pattern : Wide_String;
+ Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
Mapped_Source : Wide_String (Source'Range);
@@ -132,9 +129,9 @@ package body Ada.Strings.Wide_Search is
return Count (Mapped_Source, Pattern);
end Count;
- function Count (Source : in Wide_String;
- Set : in Wide_Maps.Wide_Character_Set)
- return Natural
+ function Count
+ (Source : in Wide_String;
+ Set : Wide_Maps.Wide_Character_Set) return Natural
is
N : Natural := 0;
@@ -153,9 +150,9 @@ package body Ada.Strings.Wide_Search is
----------------
procedure Find_Token
- (Source : in Wide_String;
- Set : in Wide_Maps.Wide_Character_Set;
- Test : in Membership;
+ (Source : Wide_String;
+ Set : Wide_Maps.Wide_Character_Set;
+ Test : Membership;
First : out Positive;
Last : out Natural)
is
@@ -190,11 +187,11 @@ package body Ada.Strings.Wide_Search is
-----------
function Index
- (Source : in Wide_String;
- Pattern : in Wide_String;
- Going : in Direction := Forward;
- Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
- return Natural
+ (Source : Wide_String;
+ Pattern : Wide_String;
+ Going : Direction := Forward;
+ Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
+ return Natural
is
begin
if Pattern = "" then
@@ -239,16 +236,11 @@ package body Ada.Strings.Wide_Search is
return 0;
end Index;
- -----------
- -- Index --
- -----------
-
function Index
- (Source : in Wide_String;
- Pattern : in Wide_String;
- Going : in Direction := Forward;
- Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
- return Natural
+ (Source : Wide_String;
+ Pattern : Wide_String;
+ Going : Direction := Forward;
+ Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
Mapped_Source : Wide_String (Source'Range);
@@ -261,11 +253,10 @@ package body Ada.Strings.Wide_Search is
end Index;
function Index
- (Source : in Wide_String;
- Set : in Wide_Maps.Wide_Character_Set;
- Test : in Membership := Inside;
- Going : in Direction := Forward)
- return Natural
+ (Source : Wide_String;
+ Set : Wide_Maps.Wide_Character_Set;
+ Test : Membership := Inside;
+ Going : Direction := Forward) return Natural
is
begin
if Going = Forward then
@@ -288,14 +279,92 @@ package body Ada.Strings.Wide_Search is
return 0;
end Index;
+ function Index
+ (Source : Wide_String;
+ Pattern : Wide_String;
+ From : Positive;
+ Going : Direction := Forward;
+ Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
+ return Natural
+ is
+ begin
+ if Going = Forward then
+ if From < Source'First then
+ raise Index_Error;
+ end if;
+
+ return
+ Index (Source (From .. Source'Last), Pattern, Forward, Mapping);
+
+ else
+ if From > Source'Last then
+ raise Index_Error;
+ end if;
+
+ return
+ Index (Source (Source'First .. From), Pattern, Backward, Mapping);
+ end if;
+ end Index;
+
+ function Index
+ (Source : Wide_String;
+ Pattern : Wide_String;
+ From : Positive;
+ Going : Direction := Forward;
+ Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
+ is
+ begin
+ if Going = Forward then
+ if From < Source'First then
+ raise Index_Error;
+ end if;
+
+ return Index
+ (Source (From .. Source'Last), Pattern, Forward, Mapping);
+
+ else
+ if From > Source'Last then
+ raise Index_Error;
+ end if;
+
+ return Index
+ (Source (Source'First .. From), Pattern, Backward, Mapping);
+ end if;
+ end Index;
+
+ function Index
+ (Source : Wide_String;
+ Set : Wide_Maps.Wide_Character_Set;
+ From : Positive;
+ Test : Membership := Inside;
+ Going : Direction := Forward) return Natural
+ is
+ begin
+ if Going = Forward then
+ if From < Source'First then
+ raise Index_Error;
+ end if;
+
+ return
+ Index (Source (From .. Source'Last), Set, Test, Forward);
+
+ else
+ if From > Source'Last then
+ raise Index_Error;
+ end if;
+
+ return
+ Index (Source (Source'First .. From), Set, Test, Backward);
+ end if;
+ end Index;
+
---------------------
-- Index_Non_Blank --
---------------------
function Index_Non_Blank
- (Source : in Wide_String;
- Going : in Direction := Forward)
- return Natural
+ (Source : Wide_String;
+ Going : Direction := Forward) return Natural
is
begin
if Going = Forward then
@@ -316,7 +385,30 @@ package body Ada.Strings.Wide_Search is
-- Fall through if no match
return 0;
+ end Index_Non_Blank;
+ function Index_Non_Blank
+ (Source : Wide_String;
+ From : Positive;
+ Going : Direction := Forward) return Natural
+ is
+ begin
+ if Going = Forward then
+ if From < Source'First then
+ raise Index_Error;
+ end if;
+
+ return
+ Index_Non_Blank (Source (From .. Source'Last), Forward);
+
+ else
+ if From > Source'Last then
+ raise Index_Error;
+ end if;
+
+ return
+ Index_Non_Blank (Source (Source'First .. From), Backward);
+ end if;
end Index_Non_Blank;
end Ada.Strings.Wide_Search;