i386: Use offsetable address constraint for double-word memory operands
[official-gcc.git] / gcc / m2 / gm2-libs / SArgs.mod
blob3c3fe8d85a18d33c8a9f49ca3bf12c29df84f270
1 (* SArgs.mod provides a String interface to the command line arguments.
3 Copyright (C) 2001-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 IMPLEMENTATION MODULE SArgs ;
29 FROM SYSTEM IMPORT TSIZE, ADDRESS ;
30 FROM UnixArgs IMPORT GetArgC, GetArgV ;
32 FROM DynamicStrings IMPORT InitStringCharStar,
33 InitStringDB, InitStringCharStarDB,
34 InitStringCharDB, MultDB, DupDB, SliceDB ;
36 TYPE
37 PtrToChar = POINTER TO CHAR ;
38 PtrToPtrToChar = POINTER TO PtrToChar ;
41 #undef GM2_DEBUG_SARGS
42 if defined(GM2_DEBUG_SARGS)
43 # define InitString(X) InitStringDB(X, __FILE__, __LINE__)
44 # define InitStringCharStar(X) InitStringCharStarDB(X, __FILE__, __LINE__)
45 # define InitStringChar(X) InitStringCharDB(X, __FILE__, __LINE__)
46 # define Mult(X,Y) MultDB(X, Y, __FILE__, __LINE__)
47 # define Dup(X) DupDB(X, __FILE__, __LINE__)
48 # define Slice(X,Y,Z) SliceDB(X, Y, Z, __FILE__, __LINE__)
49 #endif
54 GetArg - returns the nth argument from the command line.
55 The success of the operation is returned.
56 If TRUE is returned then the string, s, contains a
57 new string, otherwise s is set to NIL.
60 PROCEDURE GetArg (VAR s: String; n: CARDINAL) : BOOLEAN ;
61 VAR
62 i : INTEGER ;
63 a : ADDRESS ;
64 ppc: PtrToPtrToChar ;
65 BEGIN
66 i := VAL (INTEGER, n) ;
67 IF i < GetArgC ()
68 THEN
69 a := ADDRESS (GetArgV ()) ;
70 INC (a, n * TSIZE (PtrToChar)) ;
71 ppc := a ;
72 s := InitStringCharStar (ppc^) ;
73 RETURN TRUE
74 ELSE
75 s := NIL ;
76 RETURN FALSE
77 END ;
78 END GetArg ;
82 Narg - returns the number of arguments available from
83 command line.
86 PROCEDURE Narg () : CARDINAL ;
87 BEGIN
88 RETURN GetArgC ()
89 END Narg ;
92 END SArgs.