1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
28 -----------------------
29 -- Local Subprograms --
30 -----------------------
32 function V
(T
: Time_Stamp_Type
; X
: Time_Stamp_Index
) return Nat
;
33 -- Extract two decimal digit value from time stamp
39 function "<" (Left
, Right
: Time_Stamp_Type
) return Boolean is
41 return not (Left
= Right
) and then String (Left
) < String (Right
);
48 function "<=" (Left
, Right
: Time_Stamp_Type
) return Boolean is
50 return not (Left
> Right
);
57 function "=" (Left
, Right
: Time_Stamp_Type
) return Boolean is
62 if String (Left
) = String (Right
) then
65 elsif Left
(1) = ' ' or else Right
(1) = ' ' then
69 -- In the following code we check for a difference of 2 seconds or less
71 -- Recall that the time stamp format is:
73 -- Y Y Y Y M M D D H H M M S S
74 -- 01 02 03 04 05 06 07 08 09 10 11 12 13 14
76 -- Note that we do not bother to worry about shifts in the day.
77 -- It seems unlikely that such shifts could ever occur in practice
78 -- and even if they do we err on the safe side, i.e., we say that the
79 -- time stamps are different.
81 Sright
:= V
(Right
, 13) + 60 * (V
(Right
, 11) + 60 * V
(Right
, 09));
82 Sleft
:= V
(Left
, 13) + 60 * (V
(Left
, 11) + 60 * V
(Left
, 09));
84 -- So the check is: dates must be the same, times differ 2 sec at most
86 return abs (Sleft
- Sright
) <= 2
87 and then String (Left
(1 .. 8)) = String (Right
(1 .. 8));
94 function ">" (Left
, Right
: Time_Stamp_Type
) return Boolean is
96 return not (Left
= Right
) and then String (Left
) > String (Right
);
103 function ">=" (Left
, Right
: Time_Stamp_Type
) return Boolean is
105 return not (Left
< Right
);
112 function Get_Char_Code
(C
: Character) return Char_Code
is
114 return Char_Code
'Val (Character'Pos (C
));
121 function Get_Character
(C
: Char_Code
) return Character is
123 pragma Assert
(C
<= 255);
124 return Character'Val (C
);
131 subtype Wordh
is Word
range 0 .. 15;
132 Hex
: constant array (Wordh
) of Character := "0123456789abcdef";
134 function Get_Hex_String
(W
: Word
) return Word_Hex_String
is
136 WS
: Word_Hex_String
;
139 for J
in reverse 1 .. 8 loop
140 WS
(J
) := Hex
(X
mod 16);
147 ------------------------
148 -- Get_Wide_Character --
149 ------------------------
151 function Get_Wide_Character
(C
: Char_Code
) return Wide_Character is
153 pragma Assert
(C
<= 65535);
154 return Wide_Character'Val (C
);
155 end Get_Wide_Character
;
157 ------------------------
158 -- In_Character_Range --
159 ------------------------
161 function In_Character_Range
(C
: Char_Code
) return Boolean is
164 end In_Character_Range
;
166 -----------------------------
167 -- In_Wide_Character_Range --
168 -----------------------------
170 function In_Wide_Character_Range
(C
: Char_Code
) return Boolean is
173 end In_Wide_Character_Range
;
175 ---------------------
176 -- Make_Time_Stamp --
177 ---------------------
179 procedure Make_Time_Stamp
186 TS
: out Time_Stamp_Type
)
188 Z
: constant := Character'Pos ('0');
191 TS
(01) := Character'Val (Z
+ Year
/ 1000);
192 TS
(02) := Character'Val (Z
+ (Year
/ 100) mod 10);
193 TS
(03) := Character'Val (Z
+ (Year
/ 10) mod 10);
194 TS
(04) := Character'Val (Z
+ Year
mod 10);
195 TS
(05) := Character'Val (Z
+ Month
/ 10);
196 TS
(06) := Character'Val (Z
+ Month
mod 10);
197 TS
(07) := Character'Val (Z
+ Day
/ 10);
198 TS
(08) := Character'Val (Z
+ Day
mod 10);
199 TS
(09) := Character'Val (Z
+ Hour
/ 10);
200 TS
(10) := Character'Val (Z
+ Hour
mod 10);
201 TS
(11) := Character'Val (Z
+ Minutes
/ 10);
202 TS
(12) := Character'Val (Z
+ Minutes
mod 10);
203 TS
(13) := Character'Val (Z
+ Seconds
/ 10);
204 TS
(14) := Character'Val (Z
+ Seconds
mod 10);
207 ----------------------------
208 -- Null_Source_Buffer_Ptr --
209 ----------------------------
211 function Null_Source_Buffer_Ptr
(X
: Source_Buffer_Ptr
) return Boolean is
213 return Source_Buffer_Ptr_Equal
(X
, null);
214 end Null_Source_Buffer_Ptr
;
216 ----------------------
217 -- Split_Time_Stamp --
218 ----------------------
220 procedure Split_Time_Stamp
221 (TS
: Time_Stamp_Type
;
231 -- Y Y Y Y M M D D H H M M S S
232 -- 01 02 03 04 05 06 07 08 09 10 11 12 13 14
234 Year
:= 100 * V
(TS
, 01) + V
(TS
, 03);
238 Minutes
:= V
(TS
, 11);
239 Seconds
:= V
(TS
, 13);
240 end Split_Time_Stamp
;
246 function V
(T
: Time_Stamp_Type
; X
: Time_Stamp_Index
) return Nat
is
248 return 10 * (Character'Pos (T
(X
)) - Character'Pos ('0')) +
249 Character'Pos (T
(X
+ 1)) - Character'Pos ('0');