aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/g-speche.adb
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2007-12-13 11:27:58 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 11:27:58 +0100
commitc80d48556afdb3226ee55ef42b8b3327b71c631f (patch)
tree507d79df94d7670b6e5e13cfbfac98aa4c16fd86 /gcc/ada/g-speche.adb
parent1fdc61b5655590ecc6352866204174c093589df3 (diff)
downloadgcc-c80d48556afdb3226ee55ef42b8b3327b71c631f.zip
gcc-c80d48556afdb3226ee55ef42b8b3327b71c631f.tar.gz
gcc-c80d48556afdb3226ee55ef42b8b3327b71c631f.tar.bz2
g-spchge.ads, [...]: New files.
2007-12-06 Robert Dewar <dewar@adacore.com> * g-spchge.ads, g-spchge.adb, g-u3spch.adb, g-u3spch.ads, g-wispch.adb, g-wispch.ads, g-zspche.adb, g-zspche.ads, namet-sp.adb, namet-sp.ads: New files. * g-speche.adb: Use generic routine in g-spchge * s-wchcnv.ads, s-wchcnv.adb: Minor code cleanup (make formal type consistent with spec) * namet.adb: Update comments. * par-endh.adb (Evaluate_End_Entry): Use new Namet.Sp.Is_Bad_Spelling_Of function * par-load.adb (Load): Use new Namet.Sp.Is_Bad_Spelling_Of function * sem_aggr.adb (Resolve_Record_Aggregate): If a component of an ancestor is an access type initialized with a box, set its type explicitly, for use in subsequent expansion. (Check_Misspelled_Component): Use new Namet.Sp.Is_Bad_Spelling_Of function From-SVN: r130843
Diffstat (limited to 'gcc/ada/g-speche.adb')
-rw-r--r--gcc/ada/g-speche.adb121
1 files changed, 7 insertions, 114 deletions
diff --git a/gcc/ada/g-speche.adb b/gcc/ada/g-speche.adb
index 72c0abc..841eef8 100644
--- a/gcc/ada/g-speche.adb
+++ b/gcc/ada/g-speche.adb
@@ -35,8 +35,14 @@ pragma Warnings (Off);
pragma Compiler_Unit;
pragma Warnings (On);
+with GNAT.Spelling_Checker_Generic;
+
package body GNAT.Spelling_Checker is
+ function IBS is new
+ GNAT.Spelling_Checker_Generic.Is_Bad_Spelling_Of
+ (Character, String);
+
------------------------
-- Is_Bad_Spelling_Of --
------------------------
@@ -44,119 +50,6 @@ package body GNAT.Spelling_Checker is
function Is_Bad_Spelling_Of
(Found : String;
Expect : String) return Boolean
- is
- FN : constant Natural := Found'Length;
- FF : constant Natural := Found'First;
- FL : constant Natural := Found'Last;
-
- EN : constant Natural := Expect'Length;
- EF : constant Natural := Expect'First;
- EL : constant Natural := Expect'Last;
-
- begin
- -- If both strings null, then we consider this a match, but if one
- -- is null and the other is not, then we definitely do not match
-
- if FN = 0 then
- return (EN = 0);
-
- elsif EN = 0 then
- return False;
-
- -- If first character does not match, then we consider that this is
- -- definitely not a misspelling. An exception is when we expect a
- -- letter O and found a zero.
-
- elsif Found (FF) /= Expect (EF)
- and then (Found (FF) /= '0'
- or else (Expect (EF) /= 'o' and then Expect (EF) /= 'O'))
- then
- return False;
-
- -- Not a bad spelling if both strings are 1-2 characters long
-
- elsif FN < 3 and then EN < 3 then
- return False;
-
- -- Lengths match. Execute loop to check for a single error, single
- -- transposition or exact match (we only fall through this loop if
- -- one of these three conditions is found).
-
- elsif FN = EN then
- for J in 1 .. FN - 2 loop
- if Expect (EF + J) /= Found (FF + J) then
-
- -- If both mismatched characters are digits, then we do
- -- not consider it a misspelling (e.g. B345 is not a
- -- misspelling of B346, it is something quite different)
-
- if Expect (EF + J) in '0' .. '9'
- and then Found (FF + J) in '0' .. '9'
- then
- return False;
-
- elsif Expect (EF + J + 1) = Found (FF + J + 1)
- and then Expect (EF + J + 2 .. EL) = Found (FF + J + 2 .. FL)
- then
- return True;
-
- elsif Expect (EF + J) = Found (FF + J + 1)
- and then Expect (EF + J + 1) = Found (FF + J)
- and then Expect (EF + J + 2 .. EL) = Found (FF + J + 2 .. FL)
- then
- return True;
-
- else
- return False;
- end if;
- end if;
- end loop;
-
- -- At last character. Test digit case as above, otherwise we
- -- have a match since at most this last character fails to match.
-
- if Expect (EL) in '0' .. '9'
- and then Found (FL) in '0' .. '9'
- and then Expect (EL) /= Found (FL)
- then
- return False;
- else
- return True;
- end if;
-
- -- Length is 1 too short. Execute loop to check for single deletion
-
- elsif FN = EN - 1 then
- for J in 1 .. FN - 1 loop
- if Found (FF + J) /= Expect (EF + J) then
- return Found (FF + J .. FL) = Expect (EF + J + 1 .. EL);
- end if;
- end loop;
-
- -- If we fall through then the last character was missing, which
- -- we consider to be a match (e.g. found xyz, expected xyza).
-
- return True;
-
- -- Length is 1 too long. Execute loop to check for single insertion
-
- elsif FN = EN + 1 then
- for J in 1 .. EN - 1 loop
- if Found (FF + J) /= Expect (EF + J) then
- return Found (FF + J + 1 .. FL) = Expect (EF + J .. EL);
- end if;
- end loop;
-
- -- If we fall through then the last character was an additional
- -- character, which is a match (e.g. found xyza, expected xyz).
-
- return True;
-
- -- Length is completely wrong
-
- else
- return False;
- end if;
- end Is_Bad_Spelling_Of;
+ renames IBS;
end GNAT.Spelling_Checker;