Debian Codegraph @

source_2012/pre_cmdln.mss

raw
1 @comment{ $Source: e:\\cvsroot/ARM/Source/pre_cmdln.mss,v $ }
2 @comment{ $Revision: 1.29 $ $Date: 2012/11/28 23:53:06 $ $Author: randy $ }
3 @Part(predefcmdln, Root="ada.mss")
4
5 @Comment{$Date: 2012/11/28 23:53:06 $}
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 @key[package] Ada.Command_Line @key[is]@ChildUnit{Parent=[Ada],Child=[Command_Line]}
20 @key[pragma] Preelaborate(Command_Line);
21
22 @key[function] @AdaSubDefn{Argument_Count} @key[return] Natural;
23
24 @key[function] @AdaSubDefn{Argument} (Number : @key[in] Positive) @key[return] String;
25
26 @key[function] @AdaSubDefn{Command_Name} @key[return] String;
27
28 @key[type] @AdaTypeDefn{Exit_Status} @key[is] @RI{implementation-defined integer type};
29
30 @AdaObjDefn{Success} : @key[constant] Exit_Status;
31 @AdaObjDefn{Failure} : @key[constant] Exit_Status;
32
33 @key[procedure] @AdaSubDefn{Set_Exit_Status} (Code : @key[in] Exit_Status);
34
35 @key[private]
36 ... -- @RI{not specified by the language}
37 @key[end] Ada.Command_Line;
38 @comment{Blank line}
39 @end{example}
40 @begin{DescribeCode}
41 @begin{Example}@Keepnext
42 @key[function] Argument_Count @key[return] Natural;
43 @end{Example}
44 @Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
45 If the external execution environment supports passing arguments to
46 a program, then Argument_Count returns
47 the number of arguments passed to the program
48 invoking the function. Otherwise@Chg{Version=[3],New=[,],Old=[]}
49 it returns 0.
50 The meaning of @lquotes@;number of arguments@rquotes@; is implementation defined.
51
52 @begin{Example}@Keepnext
53 @key[function] Argument (Number : @key[in] Positive) @key[return] String;
54 @end{Example}
55 @Trailing@;If the external execution environment supports passing arguments to
56 a program, then
57 Argument returns an implementation-defined value corresponding to
58 the argument at relative position Number.
59 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
60 If Number is outside the range 1..Argument_Count, then
61 Constraint_Error is propagated.
62 @begin{Ramification}
63 If the external execution environment does not support
64 passing arguments to a program, then Argument(N) for any N will
65 raise Constraint_Error, since Argument_Count is 0.@end{ramification}
66
67 @begin{Example}@Keepnext
68 @key[function] Command_Name @key[return] String;
69 @end{Example}
70 @Trailing@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]}
71 If the external execution environment supports passing arguments to
72 a program, then
73 Command_Name returns an implementation-defined value corresponding to
74 the name of the command invoking the program;
75 otherwise@Chg{Version=[3],New=[,],Old=[]}
76 Command_Name returns the null string.
77
78 @Comment{This is missing; leading the following paragraph glued to "Command_Name"}
79 @begin{Example}@Keepnext
80 @ChgRef{Version=[1],Kind=[Added]}
81 @Chg{New=[@key[type] Exit_Status @key[is] @RI{implementation-defined integer type};],Old=[]}
82 @end{Example}
83 @Trailing@;
84 The type Exit_Status represents the range of exit
85 status values supported by the external execution environment.
86 The constants Success and Failure correspond to success and failure,
87 respectively.
88
89 @begin{Example}@Keepnext
90 @key[procedure] Set_Exit_Status (Code : @key[in] Exit_Status);
91 @end{Example}
92 If the external execution environment supports returning an exit status
93 from a program, then Set_Exit_Status sets Code as the status. Normal
94 termination of a program returns as the exit status the value most
95 recently set by Set_Exit_Status, or, if no such value has been set, then the
96 value Success. If a program terminates abnormally, the status set by
97 Set_Exit_Status is ignored, and an implementation-defined exit status value
98 is set.
99
100 @ChgNote{An incorrect index entry; presentation AI-00005}
101 @Chg{New=[],Old=[@PDefn{unspecified}]}
102 If the external execution environment does not support returning
103 an exit value from a program, then Set_Exit_Status does nothing.
104 @end{DescribeCode}
105 @end{StaticSem}
106
107 @begin{ImplPerm}
108 An alternative declaration is allowed
109 for package Command_Line if different functionality is appropriate
110 for the external execution environment.
111 @end{ImplPerm}
112
113 @begin{Notes}
114 Argument_Count, Argument, and Command_Name
115 correspond to the C language's argc, argv[n] (for n>0) and argv[0],
116 respectively.
117 @begin{Honest}
118 The correspondence of Argument_Count to argc is not direct @em
119 argc would be one more than Argument_Count, since the argc count
120 includes the command name, whereas Argument_Count does not.
121 @end{Honest}
122 @end{Notes}
123
124 @begin{Extend83}
125 @ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]}
126 @Defn{extensions to Ada 83}
127 This @Chg{Version=[3],New=[subclause],Old=[clause]} is new in Ada 95.
128 @end{Extend83}