diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-10 13:51:40 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-10 13:51:40 +0000 |
commit | 8ee79a8446354ac1a9e20fd284e879a3d55860ba (patch) | |
tree | 63cfc97375650994bb335d260cabbdfd63f70efd /gcc/ada/a-strsea.adb | |
parent | 7189d17fd684291638652f906a2c14487fe77419 (diff) | |
download | gcc-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-strsea.adb')
-rw-r--r-- | gcc/ada/a-strsea.adb | 116 |
1 files changed, 108 insertions, 8 deletions
diff --git a/gcc/ada/a-strsea.adb b/gcc/ada/a-strsea.adb index 62089c31f8e..c4e4d5db54b 100644 --- a/gcc/ada/a-strsea.adb +++ b/gcc/ada/a-strsea.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2004 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- -- @@ -76,9 +76,9 @@ package body Ada.Strings.Search is ----------- function Count - (Source : String; - Pattern : String; - Mapping : Maps.Character_Mapping := Maps.Identity) return Natural + (Source : String; + Pattern : String; + Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is N : Natural; J : Natural; @@ -110,9 +110,9 @@ package body Ada.Strings.Search is end Count; function Count - (Source : String; - Pattern : String; - Mapping : Maps.Character_Mapping_Function) return Natural + (Source : String; + Pattern : String; + Mapping : Maps.Character_Mapping_Function) return Natural is Mapped_Source : String (Source'Range); N : Natural; @@ -280,7 +280,6 @@ package body Ada.Strings.Search is declare pragma Unsuppress (Access_Check); - begin for J in Source'Range loop Mapped_Source (J) := Mapping.all (Source (J)); @@ -348,6 +347,84 @@ package body Ada.Strings.Search is return 0; end Index; + function Index + (Source : String; + Pattern : String; + From : Positive; + Going : Direction := Forward; + Mapping : Maps.Character_Mapping := 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 : String; + Pattern : String; + From : Positive; + Going : Direction := Forward; + Mapping : Maps.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 : String; + Set : Maps.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 -- --------------------- @@ -375,7 +452,30 @@ package body Ada.Strings.Search is -- Fall through if no match return 0; + end Index_Non_Blank; + function Index_Non_Blank + (Source : 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.Search; |