Debian Codegraph @

source_2020/pre_cmdln.mss

raw
1 @comment{ $Source: e:\\cvsroot/ARM/Source/pre_cmdln.mss,v $ }
2 @comment{ $Revision: 1.33 $ $Date: 2019/02/09 03:46:57 $ $Author: randy $ }
3 @Part(predefcmdln, Root="ada.mss")
4
5 @Comment{$Date: 2019/02/09 03:46:57 $}
6 @LabeledClause{The Package Command_Line}
7 @begin{Intro}
8 The package Command_Line allows a program to obtain the values of its
9 arguments and to set the exit status code to be returned on normal termination.
10 @ChgImplDef{Version=[2],Kind=[Revised],InitialVersion=[0],
11 Text=[The meaning of Argument_Count,
12 Argument, and Command_Name@Chg{Version=[2],New=[ for package Command_Line. The
13 bounds of type Command_Line.Exit_Status],Old=[]}.]}
14 @end{Intro}
15
16 @begin{StaticSem}
17 @Leading@Keepnext@;The library package Ada.Command_Line has the following declaration:
18 @begin{Example}
19 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0241-1]}
20 @key[package] Ada.Command_Line@Chg{Version=[5],New=[],Old=[ @key[is]]}@ChildUnit{Parent=[Ada],Child=[Command_Line]}
21 @Chg{Version=[5],New=[@key[with]],Old=[@key[pragma]]} Preelaborate@Chg{Version=[5],New=[, Nonblocking @key[is]],Old=[(Command_Line);]}
22
23 @key[function] @AdaSubDefn{Argument_Count} @key[return] Natural;
24
25 @key[function] @AdaSubDefn{Argument} (Number : @key[in] Positive) @key[return] String;
26
27 @key[function] @AdaSubDefn{Command_Name} @key[return] String;
28
29 @key[type] @AdaTypeDefn{Exit_Status} @key[is] @RI{implementation-defined integer type};
30
31 @AdaObjDefn{Success} : @key[constant] Exit_Status;
32 @AdaObjDefn{Failure} : @key[constant] Exit_Status;
33
34 @key[procedure] @AdaSubDefn{Set_Exit_Status} (Code : @key[in] Exit_Status);
35
36 @key[private]
37 ... -- @RI{not specified by the language}
38 @key[end] Ada.Command_Line;
39 @comment{Blank line}
40 @end{example}
41 @begin{DescribeCode}
42 @begin{Example}@Keepnext
43 @key[function] Argument_Count @key[return] Natural;
44 @end{Example}
45 @Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
46 If the external execution environment supports passing arguments to
47 a program, then Argument_Count returns
48 the number of arguments passed to the program
49 invoking the function. Otherwise@Chg{Version=[3],New=[,],Old=[]}
50 it returns 0.
51 The meaning of @lquotes@;number of arguments@rquotes@; is implementation defined.
52
53 @begin{Example}@Keepnext
54 @key[function] Argument (Number : @key[in] Positive) @key[return] String;
55 @end{Example}
56 @Trailing@ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0259-1]}
57 If the external execution environment supports passing arguments to
58 a program, then
59 Argument returns an implementation-defined value@Chg{Version=[5],New=[ with
60 lower bound 1],Old=[]} corresponding to
61 the argument at relative position Number.
62 If Number is outside the range 1..Argument_Count, then
63 Constraint_Error is propagated.
64 @begin{Ramification}
65 If the external execution environment does not support
66 passing arguments to a program, then Argument(N) for any N will
67 raise Constraint_Error, since Argument_Count is 0.@end{ramification}
68
69 @begin{Example}@Keepnext
70 @key[function] Command_Name @key[return] String;
71 @end{Example}
72 @Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
73 @ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0259-1]}
74 If the external execution environment supports passing arguments to
75 a program, then
76 Command_Name returns an implementation-defined value@Chg{Version=[5],New=[ with
77 lower bound 1],Old=[]} corresponding to
78 the name of the command invoking the program;
79 otherwise@Chg{Version=[3],New=[,],Old=[]}
80 Command_Name returns the null string.
81
82 @Comment{This is missing; leading the following paragraph glued to "Command_Name"}
83 @begin{Example}@Keepnext
84 @ChgRef{Version=[1],Kind=[Added]}
85 @Chg{New=[@key[type] Exit_Status @key[is] @RI{implementation-defined integer type};],Old=[]}
86 @end{Example}
87 @Trailing@;
88 The type Exit_Status represents the range of exit
89 status values supported by the external execution environment.
90 The constants Success and Failure correspond to success and failure,
91 respectively.
92
93 @begin{Example}@Keepnext
94 @key[procedure] Set_Exit_Status (Code : @key[in] Exit_Status);
95 @end{Example}
96 If the external execution environment supports returning an exit status
97 from a program, then Set_Exit_Status sets Code as the status. Normal
98 termination of a program returns as the exit status the value most
99 recently set by Set_Exit_Status, or, if no such value has been set, then the
100 value Success. If a program terminates abnormally, the status set by
101 Set_Exit_Status is ignored, and an implementation-defined exit status value
102 is set.
103
104 @ChgNote{An incorrect index entry; presentation AI-00005}
105 @Chg{New=[],Old=[@PDefn{unspecified}]}
106 If the external execution environment does not support returning
107 an exit value from a program, then Set_Exit_Status does nothing.
108 @end{DescribeCode}
109 @end{StaticSem}
110
111 @begin{ImplPerm}
112 An alternative declaration is allowed
113 for package Command_Line if different functionality is appropriate
114 for the external execution environment.
115 @end{ImplPerm}
116
117 @begin{Notes}
118 Argument_Count, Argument, and Command_Name
119 correspond to the C language's argc, argv[n] (for n>0) and argv[0],
120 respectively.
121 @begin{Honest}
122 The correspondence of Argument_Count to argc is not direct @em
123 argc would be one more than Argument_Count, since the argc count
124 includes the command name, whereas Argument_Count does not.
125 @end{Honest}
126 @end{Notes}
127
128 @begin{Extend83}
129 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
130 @Defn{extensions to Ada 83}
131 This @Chg{Version=[3],New=[subclause],Old=[clause]} is new in Ada 95.
132 @end{Extend83}
133
134 @begin{DiffWord2012}
135 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0259-1]}
136 @ChgAdded{Version=[5],Text=[@b<Correction:> Defined the lower bound of
137 functions Argument and Command_Name. This could be inconsistent if someone
138 depended on the lower bound of these routines (and it wasn't 1), but such
139 code was never portable (even to later versions of the same implementation).
140 Thus we don't document it as an inconsistency.]}
141 @end{Diffword2012}
142
143
144 @LabeledAddedSubClause{Version=[5],Name=[The Packages Wide_Command_Line and Wide_Wide_Command_Line]}
145
146 @begin{Intro}
147 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0021-1]}
148 @ChgAdded{Version=[5],Text=[The packages Wide_Command_Line and
149 Wide_Wide_Command_Line allow a program to obtain the values of its arguments
150 and to set the exit status code to be returned on normal termination.]}
151 @end{Intro}
152
153 @begin{StaticSem}
154 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0021-1]}
155 @ChgAdded{Version=[5],Text=[The specification of package Wide_Command_Line is
156 the same as for Command_Line, except that each occurrence of String is
157 replaced by Wide_String.@ChildUnit{Parent=[Ada],Child=[Wide_Command_Line]}]}
158
159 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0021-1]}
160 @ChgAdded{Version=[5],Text=[The specification of package
161 Wide_Wide_Command_Line is the same as for Command_Line, except that each
162 occurrence of String is replaced by
163 Wide_Wide_String.@ChildUnit{Parent=[Ada],Child=[Wide_Wide_Command_Line]}]}
164
165 @end{StaticSem}
166
167
168 @begin{Extend2012}
169 @ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0021-1]}
170 @ChgAdded{Version=[5],Text=[@Defn{extensions to Ada 2012}
171 These packages are new.]}
172 @end{Extend2012}
173