xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*
[official-gcc.git] / gcc / m2 / gm2-libs / SArgs.mod
blobb1996cc4591ad9d3b7b720fe5de1482d759c9086
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 ppc: PtrToPtrToChar ;
64 BEGIN
65 i := VAL (INTEGER, n) ;
66 IF i < GetArgC ()
67 THEN
68 (* ppc := ADDRESS (VAL (PtrToPtrToChar, ArgV) + (i * CARDINAL (TSIZE(PtrToChar)))) ; *)
69 ppc := ADDRESS (PtrToChar (GetArgV ()) + (n * TSIZE (PtrToChar))) ;
70 s := InitStringCharStar (ppc^) ;
72 RETURN TRUE
73 ELSE
74 s := NIL ;
75 RETURN FALSE
76 END ;
77 END GetArg ;
81 Narg - returns the number of arguments available from
82 command line.
85 PROCEDURE Narg () : CARDINAL ;
86 BEGIN
87 RETURN GetArgC ()
88 END Narg ;
91 END SArgs.