~ubuntu-branches/ubuntu/precise/topal/precise

« back to all changes in this revision

Viewing changes to command_line_wrapper.adb

  • Committer: Bazaar Package Importer
  • Author(s): Phil Brooke
  • Date: 2008-07-18 07:57:38 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080718075738-i1szqvmxz0evz32p
Tags: upstream-62
ImportĀ upstreamĀ versionĀ 62

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--
2
 
--
3
 
--
4
 
--
 
1
-- Topal: GPG/GnuPG and Alpine/Pine integration
 
2
-- Copyright (C) 2001--2008  Phillip J. Brooke
 
3
--
 
4
-- This program is free software: you can redistribute it and/or modify
 
5
-- it under the terms of the GNU General Public License version 3 as
 
6
-- published by the Free Software Foundation.
 
7
--
 
8
-- This program is distributed in the hope that it will be useful,
 
9
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
-- GNU General Public License for more details.
 
12
--
 
13
-- You should have received a copy of the GNU General Public License
 
14
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
5
15
 
6
16
with Ada.Command_Line; use Ada.Command_Line;
7
17
with Ada.Text_IO;
23
20
 
24
21
   J : Integer := 1; -- A pointer into the argument list.
25
22
 
 
23
   -- This deals with leading hyphens.  As long as both have at least
 
24
   --  one leading hyphen, then the leading hyphens will be treated as
 
25
   --  the same.
 
26
   function Compare (A, B : String) return Boolean is
 
27
      -- Do A and B have hyphens?
 
28
      AH, BH : Boolean := False;
 
29
      -- Start points for A and B.
 
30
      AS, BS : Integer;
 
31
   begin
 
32
      -- Get the start point, check for leading hyphen, advance past them.
 
33
      AS := A'First;
 
34
      AH := A(AS) = '-';
 
35
      while A(AS) = '-' and AS <= A'Last loop
 
36
         AS := AS + 1;
 
37
      end loop;
 
38
      -- Get the start point, check for leading hyphen, advance past them.
 
39
      BS := B'First;
 
40
      BH := B(BS) = '-';
 
41
      while B(BS) = '-' and BS <= B'Last loop
 
42
         BS := BS + 1;
 
43
      end loop;
 
44
      -- Now we can compare the remains....
 
45
      return (AH = BH) and (A(AS..A'Last) = B(BS..B'Last));
 
46
   end Compare;
 
47
 
26
48
   -- Three functions for working through the command line.
27
49
   -- The first only advances the pointer if the test was true.
28
50
   -- Two forms, one taking a string, one taking a UBS_Array.
29
51
   function Match (A : in String) return Boolean is
30
52
   begin
31
53
      if J <= Argument_Count then
32
 
         if A = Argument(J) then
 
54
         if Compare(A, Argument(J)) then
33
55
            J := J + 1;
34
56
            return True;
35
57
         else
51
73
   begin
52
74
      if J <= Argument_Count then
53
75
         for I in A'First .. A'Last loop
54
 
            A_Match := A_Match or (ToStr(A(I)) = Argument(J));
 
76
            A_Match := A_Match or Compare(ToStr(A(I)), Argument(J));
55
77
         end loop;
56
78
         if A_Match then
57
79
            J := J + 1;