Natools

Check-in [2e3532af53]
Login
Overview
Comment:getopt_long: fix Format_Long_Names
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2e3532af537504c143929193e3d54e7ed141a682
User & Date: nat on 2013-07-27 16:57:38
Other Links: manifest | tags
Context
2013-07-27
17:29
Add GNAT project files for library and tests check-in: 5042166b70 user: nat tags: trunk
16:57
getopt_long: fix Format_Long_Names check-in: 2e3532af53 user: nat tags: trunk
2011-12-09
22:56
Separation of library source and test code into distinct directories check-in: fb1e9e5c96 user: nat tags: trunk
Changes

Modified src/natools-getopt_long.adb from [d133c1264a] to [5c67cce333].

261
262
263
264
265
266
267

268
269
270
271
272
273
274



275

276
277

278
279
280
281



282
283
284
285
286
287




288
289
290
291
292
293
294
295
296
297
     (Config      : Configuration;
      Id          : Option_Id;
      Separator   : String := ", ";
      Name_Prefix : String := "--")
      return String
   is
      Long_Name_Count : constant Natural := Get_Long_Name_Count (Config, Id);

      Space_Per_Name : constant Positive
        := Name_Prefix'Length + 1 + Separator'Length;
      Result : String (1 .. Long_Name_Count * Space_Per_Name);
   begin
      if Long_Name_Count = 0 then
         return "";
      end if;



      for J in 1 .. Long_Name_Count loop

         declare
            First : constant Positive

              := Result'First + (J - 1) * Space_Per_Name;
            Name : constant String := Get_Long_Name (Config, Id, J);
         begin
            Result (First .. First + Name_Prefix'Length - 1) := Name_Prefix;



            Result (First + Name_Prefix'Length ..
                    First + Name_Prefix'Length + Name'Length - 1)
              := Name;
            Result (First + Name_Prefix'Length + Name'Length ..
                    First + Space_Per_Name - 1)
              := Separator;




         end;
      end loop;
      return Result (1 .. Long_Name_Count * Space_Per_Name - Separator'Length);
   end Format_Long_Names;


   function Format_Names
     (Config            : Configuration;
      Id                : Option_Id;
      Separator         : String := ", ";







>
|
<
<




>
>
>

>
|
|
>
|
|
|
|
>
>
>
|
|
|
|
|
|
>
>
>
>
|
|
|







261
262
263
264
265
266
267
268
269


270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
     (Config      : Configuration;
      Id          : Option_Id;
      Separator   : String := ", ";
      Name_Prefix : String := "--")
      return String
   is
      Long_Name_Count : constant Natural := Get_Long_Name_Count (Config, Id);
      Result_Length : Natural;
      Position : Positive;


   begin
      if Long_Name_Count = 0 then
         return "";
      end if;

      Result_Length := Long_Name_Count * Name_Prefix'Length
                     + (Long_Name_Count - 1) * Separator'Length;
      for J in 1 .. Long_Name_Count loop
         Result_Length := Result_Length + Get_Long_Name (Config, Id, J)'Length;
      end loop;

      return Result : String (1 .. Result_Length) do
         Position := Result'First;
         for J in 1 .. Long_Name_Count loop
            if J > 1 then
               Result (Position .. Position + Separator'Length - 1)
                 := Separator;
               Position := Position + Separator'Length;
            end if;

            Result (Position .. Position + Name_Prefix'Length - 1)
              := Name_Prefix;
            Position := Position + Name_Prefix'Length;

            declare
               Name : constant String := Get_Long_Name (Config, Id, J);
            begin
               Result (Position .. Position + Name'Length - 1) := Name;
               Position := Position + Name'Length;
            end;
         end loop;
      end return;
   end Format_Long_Names;


   function Format_Names
     (Config            : Configuration;
      Id                : Option_Id;
      Separator         : String := ", ";