Debian Codegraph @

gcc/testsuite/gm2/pim/pass/strparam.mod

raw
1 (* Copyright (C) 2008 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 IMPLEMENTATION MODULE strparam ;
19
20 (*
21 FROM ASCII IMPORT nul ;
22 FROM StrLib IMPORT StrLen, StrRemoveWhitePrefix ;
23 *)
24
25
26 PROCEDURE toint (a: ARRAY OF CHAR; VAR x: INTEGER) ;
27 BEGIN
28 x := 0
29 END toint ;
30
31 (*
32 VAR
33 i : CARDINAL ;
34 ok,
35 Negative : BOOLEAN ;
36 higha : CARDINAL ;
37 BEGIN
38 StrRemoveWhitePrefix(a, a) ;
39 higha := StrLen(a) ;
40 i := 0 ;
41 Negative := FALSE ;
42 ok := TRUE ;
43 WHILE ok DO
44 IF i<higha
45 THEN
46 IF a[i]='-'
47 THEN
48 INC(i) ;
49 Negative := NOT Negative
50 ELSIF (a[i]<'0') OR (a[i]>'9')
51 THEN
52 INC(i)
53 ELSE
54 ok := FALSE
55 END
56 ELSE
57 ok := FALSE
58 END
59 END ;
60 x := 0 ;
61 IF i<higha
62 THEN
63 ok := TRUE ;
64 REPEAT
65 IF Negative
66 THEN
67 x := 10*x - INTEGER(ORD(a[i])-ORD('0'))
68 ELSE
69 x := 10*x + INTEGER(ORD(a[i])-ORD('0'))
70 END ;
71 IF i<higha
72 THEN
73 INC(i) ;
74 IF (a[i]<'0') OR (a[i]>'9')
75 THEN
76 ok := FALSE
77 END
78 ELSE
79 ok := FALSE
80 END
81 UNTIL NOT ok ;
82 END
83 END toint ;
84 *)
85
86 END strparam.