comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* spurious error with GNAT 13.2.0 on Intel macOS 17.2
@ 2023-12-14 23:49  5% moi
  0 siblings, 0 replies; 195+ results
From: moi @ 2023-12-14 23:49 UTC (permalink / raw)


The 17.2 update is accompanied by updated Command Line Tools,
so, having made a copy of the current CLTs, I let it update.


With GNAT 13.2.0 on Intel macOS 17.2 this happens:

/Users/wf/KDF9/emulation/Testing: chmod 444 ST0

On compiling and running the minimum test case:


with Ada.Direct_IO;
with Ada.IO_Exceptions;
procedure failure is
     package my_IO is new Ada.Direct_IO(Integer);
     use my_IO;
     my_file : File_Type;
begin
Open(my_file, Inout_File, "ST0");
exception
    when Ada.IO_Exceptions.Use_Error =>
        raise program_error with "Open failed to get RW access";
end failure;


I get:

A. with  ”-largs -Wl,-ld_classic” in the linker parameters:

/Users/wf/KDF9/emulation/Testing: failure
raised PROGRAM_ERROR : Open failed to get RW access

This is what should happen.

B. recompiled and relinked without ”-largs -Wl,-ld_classic”:

/Users/wf/KDF9/emulation/Testing: failure
raised CONSTRAINT_ERROR : erroneous memory access

OOPS!

Strangely, this is now the ONLY one out of dozens of regression tests
that fails in this software configuration.
Previously, they all failed at the link stage.

-- 
Bill F.

^ permalink raw reply	[relevance 5%]

* Re: Weird behavior of Get character with trailing new lines.
  2023-09-22 19:30  3% Weird behavior of Get character with trailing new lines Blady
@ 2023-09-22 19:52  0% ` Niklas Holsti
  0 siblings, 0 replies; 195+ results
From: Niklas Holsti @ 2023-09-22 19:52 UTC (permalink / raw)


On 2023-09-22 22:30, Blady wrote:
> Hello,
> 
> I'm reading a text file with Get character from Text_IO with a while 
> loop controlled by End_Of_File.
> 
> % cat test_20230922_get_char.adb
> with Ada.Text_IO; use Ada.Text_IO;
> procedure test_20230922_get_char is
>     procedure Get is
>        F : File_Type;
>        Ch : Character;
>     begin
>        Open (F, In_File, "test_20230922_get_char.adb");
>        while not End_Of_File(F) loop
>           Get (F, Ch);
>           Put (Ch);
>        end loop;
>        Close (F);
>        Put_Line ("File read with get.");
>     end;
> begin
> Get;
> end;
> 
> 
> 
> All will be well, unfortunately not!
> 
> Despite the End_Of_File, I got an END_ERROR exception when there are 
> several trailing new lines at the end of the text:
> 
> % test_20230922_get_char
> with Ada.Text_IO; use Ada.Text_IO;procedure test_20230922_get_char is 
> procedure Get is      F : File_Type;      Ch : Character;   begin Open 
> (F, In_File, "test_20230922_get_char.adb");      while not 
> End_Of_File(F) loop         Get (F, Ch);         Put (Ch);      end 
> loop;      Close (F);      Put_Line ("File read with get."); 
> end;beginGet;end;
> 
> Execution of ../bin/test_20230922_get_char terminated by unhandled 
> exception
> raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:517
> 
> The code is compiled with GNAT, does it comply with the standard?
> 
> A.10.7 Input-Output of Characters and Strings
> For an item of type Character the following procedures are provided:
> procedure Get(File : in File_Type; Item : out Character);
> procedure Get(Item : out Character);
> After skipping any line terminators and any page terminators, reads the 
> next character from the specified input file and returns the value of 
> this character in the out parameter Item.
> The exception End_Error is propagated if an attempt is made to skip a 
> file terminator.
> 
> This seems to be the case, then how to avoid the exception?


In Text_IO, a line terminator is not an ordinary character, so you must 
handle it separately, for example like this:

       while not End_Of_File(F) loop
          if End_Of_Line(F) then
             New_Line;
             Skip_Line(F);
          else
             Get (F, Ch);
             Put (Ch);
          end if;





^ permalink raw reply	[relevance 0%]

* Weird behavior of Get character with trailing new lines.
@ 2023-09-22 19:30  3% Blady
  2023-09-22 19:52  0% ` Niklas Holsti
  0 siblings, 1 reply; 195+ results
From: Blady @ 2023-09-22 19:30 UTC (permalink / raw)


Hello,

I'm reading a text file with Get character from Text_IO with a while 
loop controlled by End_Of_File.

% cat test_20230922_get_char.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure test_20230922_get_char is
    procedure Get is
       F : File_Type;
       Ch : Character;
    begin
       Open (F, In_File, "test_20230922_get_char.adb");
       while not End_Of_File(F) loop
          Get (F, Ch);
          Put (Ch);
       end loop;
       Close (F);
       Put_Line ("File read with get.");
    end;
begin
Get;
end;



All will be well, unfortunately not!

Despite the End_Of_File, I got an END_ERROR exception when there are 
several trailing new lines at the end of the text:

% test_20230922_get_char
with Ada.Text_IO; use Ada.Text_IO;procedure test_20230922_get_char is 
procedure Get is      F : File_Type;      Ch : Character;   begin 
Open (F, In_File, "test_20230922_get_char.adb");      while not 
End_Of_File(F) loop         Get (F, Ch);         Put (Ch);      end 
loop;      Close (F);      Put_Line ("File read with get."); 
end;beginGet;end;

Execution of ../bin/test_20230922_get_char terminated by unhandled exception
raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:517

The code is compiled with GNAT, does it comply with the standard?

A.10.7 Input-Output of Characters and Strings
For an item of type Character the following procedures are provided:
procedure Get(File : in File_Type; Item : out Character);
procedure Get(Item : out Character);
After skipping any line terminators and any page terminators, reads the 
next character from the specified input file and returns the value of 
this character in the out parameter Item.
The exception End_Error is propagated if an attempt is made to skip a 
file terminator.

This seems to be the case, then how to avoid the exception?

Thanks, Pascal.



^ permalink raw reply	[relevance 3%]

* Re: ALR unable to get many packages
  @ 2023-08-06 23:29  1%             ` Kenneth Wolcott
  0 siblings, 0 replies; 195+ results
From: Kenneth Wolcott @ 2023-08-06 23:29 UTC (permalink / raw)


Hi Simon;

An attempt to "get" aws follows along with all of my openssl installed packages from MacPorts.

alr --no-color get aws
Warning:
Warning:    New solution is incomplete.
Warning:    +i gnat     13.1.0 (new,installed,gnat_external)
Warning:    +  gnatcoll 23.0.0 (new)
Warning:    +  libgpr   23.0.0 (new,indirect)
Warning:    +  make     3.81.0 (new)
Warning:    +~ openssl  *      (new,external)
Warning:    +  xmlada   23.0.0 (new)
Warning:
Warning: Could not find a complete solution for aws=23.0.0
Build will fail unless externals are made available, do you want to continue?
[Y] Yes  [N] No  (default is No) y
Note: Deploying aws=23.0.0...
########################################################################################################################### 100.0%
warn: Generating possibly incomplete environment because of missing dependencies
Note: Deploying make=3.81.0...
Note: Deploying xmlada=23.0.0...
   -=O#-    #     #       #
Note: Running post_fetch actions for xmlada=23.0.0...
checking build system type... aarch64-apple-darwin22.6.0
checking host system type... aarch64-apple-darwin22.6.0
checking target system type... aarch64-apple-darwin22.6.0
checking whether gnat can build shared libs... yes
checking for a BSD-compatible install... /opt/local/bin/ginstall -c
checking whether ln -s works... yes
configure: creating ./config.status
config.status: creating xmlada_shared.gpr
config.status: creating Makefile
config.status: creating tests/dom/default.gpr
Note: Deploying libgpr=23.0.0...
   -=O#-    #     #       #
Note: Deploying gnatcoll=23.0.0...
   -=#=- #     #       #
Note: Running post_fetch actions for aws=23.0.0...
sed: illegal option -- s
usage: sed script [-Ealnru] [-i extension] [file ...]
	sed [-Ealnu] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: illegal option -- s
usage: sed script [-Ealnru] [-i extension] [file ...]
	sed [-Ealnu] [-i extension] [-e script] ... [-f script_file] ... [file ...]
Bind
   [gprbind]      xoscons.bexch
   [Ada]          xoscons.ali
Link
   [link]         xoscons.adb
Setup OS specific definitions
aws-os_lib-tmplt.c:324:24: error: invalid operand for inline asm constraint 'i'
/*NOGEN*/ asm volatile("\n->CND:%0:" "SIN_FAMILY_OFFSET" ":%1:" "sin_family offset in record" : : "i" (324), "i" ((int) (uintptr_t)((uintptr_t)&sa.sin_family - (uintptr_t)&sa)));;
                       ^
aws-os_lib-tmplt.c:343:24: error: invalid operand for inline asm constraint 'i'
/*NOGEN*/ asm volatile("\n->CND:%0:" "AI_FAMILY_OFFSET" ":%1:" "???" : : "i" (343), "i" ((int) (uintptr_t)((uintptr_t)&ai.ai_family - (uintptr_t)&ai)));;
                       ^
aws-os_lib-tmplt.c:344:24: error: invalid operand for inline asm constraint 'i'
/*NOGEN*/ asm volatile("\n->CND:%0:" "AI_CANONNAME_OFFSET" ":%1:" "???" : : "i" (344), "i" ((int) (uintptr_t)((uintptr_t)&ai.ai_canonname - (uintptr_t)&ai)));;
                       ^
aws-os_lib-tmplt.c:345:24: error: invalid operand for inline asm constraint 'i'
/*NOGEN*/ asm volatile("\n->CND:%0:" "AI_ADDR_OFFSET" ":%1:" "???" : : "i" (345), "i" ((int) (uintptr_t)((uintptr_t)&ai.ai_addr - (uintptr_t)&ai)));;
                       ^
aws-os_lib-tmplt.c:233:17: error: unexpected token at start of statement
asm volatile("\n->TXT:%0:" "--  This is the version for " "arm64-apple-darwin22.6.0" : : "i" (233));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->TXT:233:--  This is the version for arm64-apple-darwin22.6.0
^
aws-os_lib-tmplt.c:234:17: error: unexpected token at start of statement
asm volatile("\n->TXT:%0:" "" : : "i" (234));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->TXT:234:
^
aws-os_lib-tmplt.c:240:17: error: unexpected token at start of statement
asm volatile("\n->TXT:%0:" "with Interfaces.C.Strings;" : : "i" (240));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->TXT:240:with Interfaces.C.Strings;
^
aws-os_lib-tmplt.c:241:17: error: unexpected token at start of statement
asm volatile("\n->TXT:%0:" "with System;" : : "i" (241));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->TXT:241:with System;
^
aws-os_lib-tmplt.c:243:17: error: unexpected token at start of statement
asm volatile("\n->TXT:%0:" "with GNAT.OS_Lib;" : : "i" (243));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->TXT:243:with GNAT.OS_Lib;
^
aws-os_lib-tmplt.c:272:17: error: unexpected token at start of statement
asm volatile("\n->C:%0:" "Target_OS" ":" "OS_Type" ":" "Other_OS" ":" "" : : "i" (272));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->C:272:Target_OS:OS_Type:Other_OS:
^
aws-os_lib-tmplt.c:281:17: error: unexpected token at start of statement
asm volatile("\n->C:%0:" "Target_Name" ":" "String" ":" "arm64-apple-darwin22.6.0" ":" "" : : "i" (281));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->C:281:Target_Name:String:arm64-apple-darwin22.6.0:
^
aws-os_lib-tmplt.c:310:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_unsigned_int" ":%1:" "Size of unsigned int" : : "i" (310), "i" ((int) sizeof (unsigned int)));
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:310:SIZEOF_unsigned_int:4:Size of unsigned int
^
aws-os_lib-tmplt.c:313:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_fd_set" ":%1:" "fd_set" : : "i" (313), "i" ((int) (sizeof (fd_set))));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:313:SIZEOF_fd_set:128:fd_set
^
aws-os_lib-tmplt.c:314:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "FD_SETSIZE" ":%1:" "Max fd value" : : "i" (314), "i" ((int) 1024));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:314:FD_SETSIZE:1024:Max fd value
^
aws-os_lib-tmplt.c:320:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_sin_family" ":%1:" "Size of sa.sin_family" : : "i" (320), "i" ((int) sizeof (sa.sin_family) * 8));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:320:SIZEOF_sin_family:8:Size of sa.sin_family
^
aws-os_lib-tmplt.c:353:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_nfds_t" ":%1:" "Size of nfds_t" : : "i" (353), "i" ((int) sizeof (nfds_t) * 8));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:353:SIZEOF_nfds_t:32:Size of nfds_t
^
aws-os_lib-tmplt.c:362:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_pollfd_events" ":%1:" "Size of pollfd.events" : : "i" (362), "i" ((int) sizeof (v_pollfd.events) * 8));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:362:SIZEOF_pollfd_events:16:Size of pollfd.events
^
aws-os_lib-tmplt.c:373:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_fd_type" ":%1:" "Size of socket fd" : : "i" (373), "i" ((int) sizeof (v_pollfd.fd) * 8));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:373:SIZEOF_fd_type:32:Size of socket fd
^
aws-os_lib-tmplt.c:381:17: error: unexpected token at start of statement
asm volatile("\n->CND:%0:" "SIZEOF_socklen_t" ":%1:" "Size of socklen_t" : : "i" (381), "i" ((int) sizeof (socklen_t) * 8));;
                ^
<inline asm>:2:1: note: instantiated into assembly here
->CND:381:SIZEOF_socklen_t:32:Size of socklen_t
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
raised raised ADA.IO_EXCEPTIONS.NAME_ERROR : aws-os_lib-tmplt.s: No such file or directory

make[1]: *** [../.build/arm64-apple-darwin22.6.0/debug/../setup/src/aws-os_lib.ads] Error 1
make: *** [config_setup] Error 2
ERROR: A post-fetch action failed, re-run with -vv -d for details

-----------------------------------------------
port installed | grep openssl
  openssl @3_8
  openssl @3_9
  openssl @3_9+universal
  openssl @3_10+universal
  openssl @3_10
  openssl @3_11
  openssl @3_12 (active)
  openssl3 @3.0.7_0+legacy
  openssl3 @3.0.7_2+legacy
  openssl3 @3.0.8_1+legacy
  openssl3 @3.0.8_1+legacy+universal
  openssl3 @3.1.0_0+universal
  openssl3 @3.1.0_1
  openssl3 @3.1.0_1+universal
  openssl3 @3.1.0_2+universal
  openssl3 @3.1.0_3+universal
  openssl3 @3.1.0_3
  openssl3 @3.1.1_0
  openssl3 @3.1.2_0 (active)
  openssl10 @1.0.2u_4 (active)
  openssl11 @1.1.1s_0
  openssl11 @1.1.1t_0
  openssl11 @1.1.1t_1
  openssl11 @1.1.1u_1
  openssl11 @1.1.1v_1 (active)
  py310-openssl @21.0.0_0
  py310-openssl @22.1.0_0
  py310-openssl @23.0.0_0
  py310-openssl @23.2.0_0 (active)
  py311-openssl @23.0.0_0
  py311-openssl @23.2.0_0 (active)
  qt5-qtbase @5.15.6_1+openssl
  qt5-qtbase @5.15.8_0+openssl
  qt5-qtbase @5.15.8_1+openssl
  qt5-qtbase @5.15.9_0+openssl
  qt5-qtbase @5.15.10_0+openssl (active)
  qt6-qtbase @6.4.3_1+openssl (active)
-----------------------------------------------

That reminds me, I need to uninstall those "universal" packages...

Thanks, 
Ken

^ permalink raw reply	[relevance 1%]

* Re: GNAT Community 2020 (20200818-93): Big_Integer
  @ 2023-06-30 21:07  3% ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2023-06-30 21:07 UTC (permalink / raw)


On 2023-06-30 21:28, Frank Jørgen Jørgensen wrote:

> I'm running the below program with GNAT Community 2020 (20200818-93)
> on Windows 11 Home.
> I have some problems trying to save big numbers to a file - so I noticed this behaviour:
> If I open Test.dat in Visual Studio Hex editor,  it seems like this program saves this big number with a different bit pattern each time.
> Is that as expected?
> I do have some problems reading back the big numbers in my real code.
> When I compile I get the warning: "Ada.Numerics.Big_Numbers.Big_Integers"  is an Ada 202x unit.
> 
> --
> with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
> with Ada.Numerics.Big_Numbers.Big_Integers;
> 
> procedure Test is
> 
>        B1 : Ada.Numerics.Big_Numbers.Big_Integers.Big_Integer;
>        F1 : File_Type;
>        S1 : Stream_Access;
>     begin
>        B1 := 1;
> 
>        Ada.Streams.Stream_IO.Create (F1, Out_File, "Test.dat");
>        S1 := Ada.Streams.Stream_IO.Stream (F1);
>        Ada.Numerics.Big_Numbers.Big_Integers.Big_Integer'Write(S1, B1);
>        Ada.Numerics.Big_Numbers.Big_Integers.Big_Integer'Output(S1, B1);
>        Ada.Streams.Stream_IO.Close (F1);
> end Test;

As a general rule, you should never use predefined implementations of 
stream attributes except for Stream_Element or Character. Anything else 
you must always override or else not use.

If you want to serialize signed integers use some portable format for 
it. E.g. a chained encoding.

Here is a test program for a straightforward implementation of chained 
store/restore:
-------------------------
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Numerics.Big_Numbers.Big_Integers;
with Ada.Exceptions;
with Ada.IO_Exceptions;

procedure Test is

    use Ada.Streams;
    use Ada.Numerics.Big_Numbers.Big_Integers;
    use Ada.Exceptions;
    use Ada.Streams.Stream_IO;

    Two : constant Big_Integer := To_Big_Integer (2);

    package Conversions is new Unsigned_Conversions (Stream_Element);
    use Conversions;

    function Get
             (  Stream : in out Root_Stream_Type'Class
             )  return Big_Integer is
       Result   : Big_Integer;
       Power    : Natural := 6;
       Negative : Boolean;
       Buffer   : Stream_Element_Array (1..1);
       Last     : Stream_Element_Offset;
       This     : Stream_Element renames Buffer (1);
    begin
       Stream.Read (Buffer, Last);
       if Last /= 1 then
          raise End_Error;
       end if;
       Result   := To_Big_Integer ((This and 2#0111_1110#) / 2);
       Negative := 0 /= (This and 1);
       if 0 = (This and 16#80#) then
          if Negative then
             return -Result - 1;
          else
             return Result;
          end if;
       end if;
       loop
          Stream.Read (Buffer, Last);
          if Last /= 1 then
             raise End_Error;
          end if;
          Result := Result +
             Two**Power * To_Big_Integer (This and 16#7F#);
          if 0 = (This and 16#80#) then
             if Negative then
                return -Result - 1;
             else
                return Result;
             end if;
          end if;
          Power := Power + 7;
       end loop;
    end Get;

    procedure Put
              (  Stream : in out Root_Stream_Type'Class;
                 Value  : Big_Integer
              )  is
       Item   : Big_Integer := Value;
       Buffer : Stream_Element_Array (1..1);
       This   : Stream_Element renames Buffer (1);
    begin
       if Item >= 0 then
          Item := Value;
          This := From_Big_Integer (Item mod (16#40#)) * 2;
       else
          Item := -(Value + 1);
          This := From_Big_Integer (Item mod (16#40#)) * 2 + 1;
       end if;
       Item := Item / 16#40#;
       if Item = 0 then
          Stream.Write (Buffer);
          return;
       end if;
       This := This or 16#80#;
       Stream.Write (Buffer);
       loop
          This := From_Big_Integer (Item mod 16#80#) or 16#80#;
          Item := Item / 16#80#;
          if Item = 0 then
             This := This and 16#7F#;
             Stream.Write (Buffer);
             return;
          end if;
          Stream.Write (Buffer);
       end loop;
    end Put;

    F : File_Type;
begin
    Create (F, Out_File, "Test.dat");
    for I in -1_000_000..1_000_000 loop
       Put (Stream (F).all, To_Big_Integer (I));
    end loop;
    Close (F);
    Open (F, In_File, "Test.dat");
    for I in -1_000_000..1_000_000 loop
       declare
          Value : constant Big_Integer := Get (Stream (F).all);
       begin
          if Value /= To_Big_Integer (I) then
             raise Data_Error;
          end if;
       end;
    end loop;
    Close (F);
end Test;
-------------------------
The above could be optimized to work with buffers rather than 
reading/writing stream octets one by one. It is a long story, but 
normally you would implement some data blocks with the length count on 
top of the stream in order to avoid inefficient octet by octet reading 
and add an error correction layer.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 3%]

* Re: components_4_64 python Test_Class Build Fails
  2022-10-21 16:52  4% ` Simon Wright
@ 2022-10-21 18:39  0%   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2022-10-21 18:39 UTC (permalink / raw)


On 2022-10-21 18:52, Simon Wright wrote:
> Roger Mc <rogermcm2@gmail.com> writes:
> 
>> Mac OSX Monterey
>> Trying to build Test_Class fails with
>> /System/Volumes/Data/Ada_Source/components_4_64/python-examples/class/test_class
>> dyld[89915]: Library not loaded:
>> '/Library/Frameworks/Python.framework/Versions/3.8/Python'
>>    Referenced from:
>> '/System/Volumes/Data/Ada_Source/components_4_64/python-examples/class/test_class'
>>    Reason: tried:
>> '/Library/Frameworks/Python.framework/Versions/3.8/Python' (no such
>> file),
>> '/System/Library/Frameworks/Python.framework/Versions/3.8/Python' (no
>> such file)
>>
>> I have set the gpr Linker item to
>> -F/usr/local/Cellar/python@3.10/3.10.5/Frameworks
>> but this does not fix th problem
> 
> Not sure I've ever seen /System/Volumes/Data at the start of a path
> before! would have expected just /Ada_Source.
> 
> Which compiler are you using?
> 
> I don't know what triggers that message about
> /Library/Frameworks/Python.framework/Versions/3.8/Python,
> you'd need to be running a fairly old compiler - if it's one of mine
> it'd have to be GCC 10.1.0, otherwise it won't look in
> /Library/Frameworks at all.
> 
> If your homebrew setup is like mine, you could just say
> -F/usr/local/Frameworks, but you have to say _which_ framework, i.e.
> -framework python (or maybe -framework Python, probably better).
> 
> I built this using GNATstudio, GCC 12.1.0, x86_64 Monterey 12.6,
> Atomic_Access auto,
> Development Debug,
> Legacy Ada2012,
> Object_Dir nested,
> Target_OS OSX,
> Tasking Multiple,
> Traced_Objects Off,
> arch x86_64
> 
> and it linked without issue. Didn't run,
> Error: raised ADA.IO_EXCEPTIONS.USE_ERROR : Failed to load Python DLL "libpython3.so"

Right, because it is obviously wrong since Python under OSX looks quite 
different from Linux. I mindlessly copied Linux implementation. Now I 
finally have an opportunity to fix it! (:-))

BTW, what are you "posh guys" (:-)) are going to do with M1/2? Is there 
GNAT?

Is there any noticeable differences to X86_64 on the Ada level? 
Endianness must be same, correct? Alignment/padding inside C structures 
when interfacing to Ada?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 0%]

* Re: components_4_64 python Test_Class Build Fails
  @ 2022-10-21 16:52  4% ` Simon Wright
  2022-10-21 18:39  0%   ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Simon Wright @ 2022-10-21 16:52 UTC (permalink / raw)


Roger Mc <rogermcm2@gmail.com> writes:

> Mac OSX Monterey
> Trying to build Test_Class fails with
> /System/Volumes/Data/Ada_Source/components_4_64/python-examples/class/test_class
> dyld[89915]: Library not loaded:
> '/Library/Frameworks/Python.framework/Versions/3.8/Python'
>   Referenced from:
> '/System/Volumes/Data/Ada_Source/components_4_64/python-examples/class/test_class'
>   Reason: tried:
> '/Library/Frameworks/Python.framework/Versions/3.8/Python' (no such
> file),
> '/System/Library/Frameworks/Python.framework/Versions/3.8/Python' (no
> such file)
>
> I have set the gpr Linker item to
> -F/usr/local/Cellar/python@3.10/3.10.5/Frameworks
> but this does not fix th problem

Not sure I've ever seen /System/Volumes/Data at the start of a path
before! would have expected just /Ada_Source.

Which compiler are you using?

I don't know what triggers that message about
/Library/Frameworks/Python.framework/Versions/3.8/Python,
you'd need to be running a fairly old compiler - if it's one of mine
it'd have to be GCC 10.1.0, otherwise it won't look in
/Library/Frameworks at all.

If your homebrew setup is like mine, you could just say
-F/usr/local/Frameworks, but you have to say _which_ framework, i.e.
-framework python (or maybe -framework Python, probably better).

I built this using GNATstudio, GCC 12.1.0, x86_64 Monterey 12.6,
Atomic_Access auto,
Development Debug,
Legacy Ada2012,
Object_Dir nested,
Target_OS OSX,
Tasking Multiple,
Traced_Objects Off,
arch x86_64

and it linked without issue. Didn't run,
Error: raised ADA.IO_EXCEPTIONS.USE_ERROR : Failed to load Python DLL "libpython3.so"

^ permalink raw reply	[relevance 4%]

* Re: Ada_GUI
  2022-04-06 15:29  4%     ` Ada_GUI AdaMagica
@ 2022-04-06 15:38  0%       ` Jeffrey R.Carter
  0 siblings, 0 replies; 195+ results
From: Jeffrey R.Carter @ 2022-04-06 15:38 UTC (permalink / raw)


On 2022-04-06 17:29, AdaMagica wrote:
> Hi Jeff,
> I observe very strange behaviour wrt icon.
> Today it suddenly appeared with yesterday's executable. It's your favicon.ico.

Curious, see my post of a few minutes ago.

 >I deleted the file, and very strangely, if I start the executable again, 
favicon is still there.
> More strange behaviour: I replaced it by my own Ada.ico - drum roll: favicon is still there.

Browsers cache things.

 >
When I kill the exe, I get:
> 2022-04-06 17:18:35.69 : Deleting connection - 1
> 2022-04-06 17:18:35.70 : Connection error ID-1 with message : raised ADA.IO_EXCEPTIONS.LAYOUT_ERROR : Subscript error
> 
> 2022-04-06 17:18:35.71 : HTTP Server Stopping
> 2022-04-06 17:18:35.74 : Normal exit of task: main_task_00000000009D5710
> [2022-04-06 17:18:35] process terminated successfully, elapsed time: 08.79s

The exception msg always occurs when the program ends. At that point it doesn't 
seem important, so I haven't put much effort into suppressing it.

-- 
Jeff Carter
"We'll make Rock Ridge think it's a chicken
that got caught in a tractor's nuts!"
Blazing Saddles
87

^ permalink raw reply	[relevance 0%]

* Re: Ada_GUI
  @ 2022-04-06 15:29  4%     ` AdaMagica
  2022-04-06 15:38  0%       ` Ada_GUI Jeffrey R.Carter
  0 siblings, 1 reply; 195+ results
From: AdaMagica @ 2022-04-06 15:29 UTC (permalink / raw)


Hi Jeff,
I observe very strange behaviour wrt icon.
Today it suddenly appeared with yesterday's executable. It's your favicon.ico. I deleted the file, and very strangely, if I start the executable again, favicon is still there.
More strange behaviour: I replaced it by my own Ada.ico - drum roll: favicon is still there. When I kill the exe, I get:
2022-04-06 17:18:35.69 : Deleting connection - 1
2022-04-06 17:18:35.70 : Connection error ID-1 with message : raised ADA.IO_EXCEPTIONS.LAYOUT_ERROR : Subscript error

2022-04-06 17:18:35.71 : HTTP Server Stopping
2022-04-06 17:18:35.74 : Normal exit of task: main_task_00000000009D5710
[2022-04-06 17:18:35] process terminated successfully, elapsed time: 08.79s

Christoph

^ permalink raw reply	[relevance 4%]

* Re: gnatcol json vs network read
  @ 2018-12-15  9:41  5%   ` Stephen Leake
  0 siblings, 0 replies; 195+ results
From: Stephen Leake @ 2018-12-15  9:41 UTC (permalink / raw)


On Friday, December 14, 2018 at 1:58:05 PM UTC-8, Per Sandberg wrote:
> Well this all depends on the definition of Network_String'Input and 
> Network_String'Output.
> 
> Will Network_String'Output always send the whole string in such a format 
> that Network_String'Input is able to reconstruct it regardless of 
> fragmentation on the transport.

Sigh, you are right. I use this for 'Input:

      Str      : Stream_Element_Array (1 .. 8);
      Str_Last : Stream_Element_Offset;
   begin
      Read (Stream.all, Str, Str_Last);
      if Str_Last < Str'Last then
         raise Ada.IO_Exceptions.End_Error;
      end if;

So 'Input either returns all the bytes sent, or raises End_Error.

Thanks for the nudge :).

-- Stephe


^ permalink raw reply	[relevance 5%]

* Re: Strings with discriminated records
  2018-05-30  5:00  6%                         ` J-P. Rosen
@ 2018-05-30 20:09  0%                           ` Randy Brukardt
  0 siblings, 0 replies; 195+ results
From: Randy Brukardt @ 2018-05-30 20:09 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2202 bytes --]


"J-P. Rosen" <rosen@adalog.fr> wrote in message 
news:pelb5u$cqo$1@gioia.aioe.org...
> Le 30/05/2018 à 00:41, Randy Brukardt a écrit :
...
>>(Of course,
>> the real problem above is "package use clauses", don't use (ahem) them 
>> and
>> you can't possibly have this problem.)
>> ????
> With use clauses, you'll have to write:
>    when Ada.IO_Exceptions.End_Error =>
>
> while without use clauses, you'll have to write:
>    when Ada.IO_Exceptions.End_Error =>
>
> I fail to see the "real problem". Use clauses make the code more
> readable, and when there is an ambiguity, you fall back to what you
> would do without them. What's the problem?

(A) The person I was responding to was upset that they had to write the 
fully qualified name in this case, and practically, they're right. (Tucker 
has complained about this multiple times.)

(B) But package use clauses make things visible that are not overloadable 
(like objects), so they tend to be a substantial maintenance hazard --  
adding something to a package can make client code using use clauses illegal 
because of conflicts. Adding unrelated stuff should *never* make any client 
illegal (changes, obviously are different).

If Ada had made objects/exceptions overloadable, this problem would be much 
less severe. But it didn't, and changing that now would be difficult to do 
without lots of subtle incompatibilities.

Use type/use all type (and better still, prefix calls) mostly avoid this 
problem by only operating on overloadable things. You still can get 
conflicts, but only when there are design issues (having multiple operations 
with the same name and profile means either there is unnecessary duplication 
[two routines doing the same thing] or that there is routines doing 
different things with the same name (yikes!).

In a best case world, a rename conflicting with the original routine or 
another rename of it would be ignored in all use clauses, along with 
overloading of objects/exceptions. That would reduce conflicts to a handful 
of cases. (If overloading of generics could be figured out, that would be 
even better.) But that has to wait for Ada++.

                                                    Randy.


^ permalink raw reply	[relevance 0%]

* Re: Strings with discriminated records
  2018-05-29 22:41  0%                       ` Randy Brukardt
@ 2018-05-30  5:00  6%                         ` J-P. Rosen
  2018-05-30 20:09  0%                           ` Randy Brukardt
  0 siblings, 1 reply; 195+ results
From: J-P. Rosen @ 2018-05-30  5:00 UTC (permalink / raw)


Le 30/05/2018 à 00:41, Randy Brukardt a écrit :
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
> news:pejmlh$1ic1$1@gioia.aioe.org...
> ...
>> The case is represented by this:
>>
>>    use Ada.IO_Exceptions;
>>    use Streams.Stream_IO;
>>
>>    begin
>>       ...
>>    exception
>>       when End_Error => -- Illegal
>>          null;
>>    end;
>>
>> which is obviously wrong, the code must be OK.

>(Of course, 
> the real problem above is "package use clauses", don't use (ahem) them and 
> you can't possibly have this problem.)
> ????
With use clauses, you'll have to write:
    when Ada.IO_Exceptions.End_Error =>

while without use clauses, you'll have to write:
    when Ada.IO_Exceptions.End_Error =>

I fail to see the "real problem". Use clauses make the code more
readable, and when there is an ambiguity, you fall back to what you
would do without them. What's the problem?

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


^ permalink raw reply	[relevance 6%]

* Re: Strings with discriminated records
  2018-05-29 14:04  4%                     ` Dmitry A. Kazakov
@ 2018-05-29 22:41  0%                       ` Randy Brukardt
  2018-05-30  5:00  6%                         ` J-P. Rosen
  0 siblings, 1 reply; 195+ results
From: Randy Brukardt @ 2018-05-29 22:41 UTC (permalink / raw)



"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:pejmlh$1ic1$1@gioia.aioe.org...
...
> The case is represented by this:
>
>    use Ada.IO_Exceptions;
>    use Streams.Stream_IO;
>
>    begin
>       ...
>    exception
>       when End_Error => -- Illegal
>          null;
>    end;
>
> which is obviously wrong, the code must be OK.
>
> But if anybody would care write an AI to fix that, it will be surely 
> rejected by ARG, on the ground of being "nice to have". I have more 
> important things to do, so count me out.

It's been discussed over dinner a few times, but everyone has more important 
things to do than write an AI for it. So nothing ever happens. (Of course, 
the real problem above is "package use clauses", don't use (ahem) them and 
you can't possibly have this problem.)

In any case, it is too late for Ada 2020; the deadline for new ideas (from 
anyone, including me) has passed.

                                                         Randy.



^ permalink raw reply	[relevance 0%]

* Re: Strings with discriminated records
  @ 2018-05-29 14:04  4%                     ` Dmitry A. Kazakov
  2018-05-29 22:41  0%                       ` Randy Brukardt
  0 siblings, 1 reply; 195+ results
From: Dmitry A. Kazakov @ 2018-05-29 14:04 UTC (permalink / raw)


On 2018-05-29 03:40 PM, Dan'l Miller wrote:

> If you think that the ARG made a mistake in the wording of the _LRM_ to allow vastly more usage of RENAMES than “what* was originally intended”, then submit one or more AIs to launder the very-soiled dirty laundry versus have this viewpoint vetted by experts to see whether it has any merit at all.

Whatever mistakes made they are permanent now due to the backward 
compatibility issue.

Except for, possibly, not allowing a renaming to hide another renaming 
of the same object, there is nothing that can be fixed.

The case is represented by this:

    use Ada.IO_Exceptions;
    use Streams.Stream_IO;

    begin
       ...
    exception
       when End_Error => -- Illegal
          null;
    end;

which is obviously wrong, the code must be OK.

But if anybody would care write an AI to fix that, it will be surely 
rejected by ARG, on the ground of being "nice to have". I have more 
important things to do, so count me out.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 4%]

* Re: CONSTRAINT ERROR? access check failed
  @ 2018-03-01 14:31  4%     ` Mehdi Saada
  0 siblings, 0 replies; 195+ results
From: Mehdi Saada @ 2018-03-01 14:31 UTC (permalink / raw)


Now I understand: it was part of a bigger loop, and once nothing was entered as a command, the whole loop was walked through, and the file asked again. I just had to put INNER before the main loop. Why can't I see that immediately...
Thanks for your contribution, though.

When entering a file name, it raised raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96
No exception handler seem to catch that exception. Yet it happens only when I provided an existing file name.
The (rewritten) loop;
loop
      declare
	 NOM_FICHIER : String := Get_Line;
	 INDICE      : NATURAL := 0;
      begin
	 if Index_Non_Blank (NOM_FICHIER) /= 0 then
	    if not Exists (NOM_FICHIER) then Put_Line ("N'existe pas. Recommencez.");
	    else OPEN (FILE_ENTREE, In_File, NOM_FICHIER);
	       Set_Input (FILE_ENTREE);
	       begin
		  while not End_Of_File loop
		     INDICE := INDICE + 10;
		     INSERT_OR_REPLACE (INDICE, LET_ONLY_GRAPHIC_CHARACTERS (GET_LINE));
		  end loop;
		  exit;
	       exception when others => PUT_LINE ("HERE !");
	       end;
	    end if; 
	 end if; end;
   end loop;

I put exception handlers EVERYWHERE, in every function called, besides standard libraries' ones, of course.


^ permalink raw reply	[relevance 4%]

* Re: Finding the end of a stream from a socket
  2017-10-21 17:34  0%   ` Andrew Shvets
@ 2017-10-21 19:18  0%     ` Andrew Shvets
  0 siblings, 0 replies; 195+ results
From: Andrew Shvets @ 2017-10-21 19:18 UTC (permalink / raw)


On Saturday, October 21, 2017 at 1:34:15 PM UTC-4, Andrew Shvets wrote:
> On Saturday, October 21, 2017 at 4:44:42 AM UTC-4, Dmitry A. Kazakov wrote:
> > On 2017-10-21 04:05, Andrew Shvets wrote:
> > 
> > > I've been recently trying to make a small TCP server (a toy.) I have
> > > a channel that reads Characters and was trying to find the end of
> > > the stream. Reading the documentation, I came across the following
> > > in  g-socket.ads:
> > > 
> > > type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
> > > --  Same interface as Ada.Streams.Stream_IO
> > > 
> > > I was trying to have a way to find out when the last Character was 
> > > read from the stream. I could catch the Ada.IO_Exceptions.End_Error 
> > > exception, but I'm wondering if there is a better way.
> > 
> > End_Error is the best possible way, when applied. GNAT socket streams do 
> > not raise End_Error, AFAIK.
> > 
> > > while not Ada.Streams.Stream_IO.End_Of_File(Channel) loop
> > >    Character'Read(Channel, Received_Char);
> > >    Ada.Text_IO.Put(Received_Char);
> > > end loop;
> > 
> > This is a bad idea even when if it can work. In the case of sockets 
> > there is no file end. When the connection is closed by the peer the 
> > stream will stop both returning data and blocking. I suppose that will 
> > cause Constraint_Error in Character'Read.
> > 
> > In practice there is a higher level protocol on top of the socket 
> > stream, so that it is always known how many octets to read next.
> > 
> > Regarding your case, try this:
> > 
> >     Buffer : Stream_Element_Array (1..Buffer_Size);
> >     Last   : Stream_Element_Offset;
> > begin
> >     loop
> >        Receive_Socket (Socket, Buffer, Last);
> >        exit when Last < Buffer'First; -- Connection is closed by the peer
> >        for Octet in Buffer'First..Last loop -- Dump octets as-is
> >           Put (Character'Val (Buffer (Octet)));
> >        end loop;
> >     end loop;
> > 
> > -- 
> > Regards,
> > Dmitry A. Kazakov
> > http://www.dmitry-kazakov.de
> 
> Hi Dmitry,
> 
> This is my entire code.
> https://gist.github.com/anonymous/b7c3a5bdcd8c78453a643b6785573131

On this line:
GNAT.Sockets.Connect_Socket(Receiver,  Client_Addr);


I get the following exception:
!! TCP Server started !!
FOO 1

raised GNAT.SOCKETS.SOCKET_ERROR :[10022] Unknown system error


Weird, I thought, then I uncommented the Connect_Socket procedure call, since the socket is already being used to listen, it should be "connected".  When I did this, I got this error:

https://gist.github.com/anonymous/b79594f71309df87fc8fcc44bd6a28ee

What gets me, what is trying to connect from 0.0.0.0:0?  I have never seen or heard of this address being used.


^ permalink raw reply	[relevance 0%]

* Re: Finding the end of a stream from a socket
  2017-10-21 13:45  4%   ` Andrew Shvets
@ 2017-10-21 18:11  0%     ` Dennis Lee Bieber
  0 siblings, 0 replies; 195+ results
From: Dennis Lee Bieber @ 2017-10-21 18:11 UTC (permalink / raw)


On Sat, 21 Oct 2017 06:45:22 -0700 (PDT), Andrew Shvets
<andrew.shvets@gmail.com> declaimed the following:


>
>
>  loop
>    begin
>      GNAT.Sockets.Receive_Socket(Receiver, Buffer, Last);
>
>      -- the connection was reset by peer.
>      exit when Last < Buffer'First;
>
>      for Octet in Buffer'First .. Last loop
>        Ada.Text_IO.Put(Character'Val(Buffer(Octet)));
>      end loop;
>    exception
>      when Ada.IO_Exceptions.End_Error =>
>        Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error, " ERROR: Issue encountered while receiving data from user.");
>    end;
>  end loop;
>
>
>I get the following error when I make the Receive_Socket procedure call:
>
>raised GNAT.SOCKETS.SOCKET_ERROR : [107] Transport endpoint is not connected


>  GNAT.Sockets.Bind_Socket(Receiver, (GNAT.Sockets.Family_Inet, GNAT.Sockets.Inet_Addr("127.0.0.1"), 50000));
>  GNAT.Sockets.Listen_Socket(Receiver);
>
	From those statements I'm guessing you are trying to set this program
up as a server, and have some other program which will connect to send data
to this one.


>  Ada.Text_IO.Put_Line(" !! TCP Server started !!");
>
>  loop
>    Ada.Text_IO.Put_Line(" FOO 1");
>    GNAT.Sockets.Connect_Socket(Receiver,  Client_Addr);

	But here you are saying /this/ program is going to connect to a server
at (undefined) Client_Addr.

	I suspect you really need to be using g.s.Accept_Socket() instead.

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

^ permalink raw reply	[relevance 0%]

* Re: Finding the end of a stream from a socket
  2017-10-21  8:44  0% ` Dmitry A. Kazakov
  2017-10-21 13:45  4%   ` Andrew Shvets
@ 2017-10-21 17:34  0%   ` Andrew Shvets
  2017-10-21 19:18  0%     ` Andrew Shvets
  1 sibling, 1 reply; 195+ results
From: Andrew Shvets @ 2017-10-21 17:34 UTC (permalink / raw)


On Saturday, October 21, 2017 at 4:44:42 AM UTC-4, Dmitry A. Kazakov wrote:
> On 2017-10-21 04:05, Andrew Shvets wrote:
> 
> > I've been recently trying to make a small TCP server (a toy.) I have
> > a channel that reads Characters and was trying to find the end of
> > the stream. Reading the documentation, I came across the following
> > in  g-socket.ads:
> > 
> > type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
> > --  Same interface as Ada.Streams.Stream_IO
> > 
> > I was trying to have a way to find out when the last Character was 
> > read from the stream. I could catch the Ada.IO_Exceptions.End_Error 
> > exception, but I'm wondering if there is a better way.
> 
> End_Error is the best possible way, when applied. GNAT socket streams do 
> not raise End_Error, AFAIK.
> 
> > while not Ada.Streams.Stream_IO.End_Of_File(Channel) loop
> >    Character'Read(Channel, Received_Char);
> >    Ada.Text_IO.Put(Received_Char);
> > end loop;
> 
> This is a bad idea even when if it can work. In the case of sockets 
> there is no file end. When the connection is closed by the peer the 
> stream will stop both returning data and blocking. I suppose that will 
> cause Constraint_Error in Character'Read.
> 
> In practice there is a higher level protocol on top of the socket 
> stream, so that it is always known how many octets to read next.
> 
> Regarding your case, try this:
> 
>     Buffer : Stream_Element_Array (1..Buffer_Size);
>     Last   : Stream_Element_Offset;
> begin
>     loop
>        Receive_Socket (Socket, Buffer, Last);
>        exit when Last < Buffer'First; -- Connection is closed by the peer
>        for Octet in Buffer'First..Last loop -- Dump octets as-is
>           Put (Character'Val (Buffer (Octet)));
>        end loop;
>     end loop;
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Hi Dmitry,

This is my entire code.
https://gist.github.com/anonymous/b7c3a5bdcd8c78453a643b6785573131


^ permalink raw reply	[relevance 0%]

* Re: Finding the end of a stream from a socket
  2017-10-21  8:44  0% ` Dmitry A. Kazakov
@ 2017-10-21 13:45  4%   ` Andrew Shvets
  2017-10-21 18:11  0%     ` Dennis Lee Bieber
  2017-10-21 17:34  0%   ` Andrew Shvets
  1 sibling, 1 reply; 195+ results
From: Andrew Shvets @ 2017-10-21 13:45 UTC (permalink / raw)


On Saturday, October 21, 2017 at 4:44:42 AM UTC-4, Dmitry A. Kazakov wrote:
> On 2017-10-21 04:05, Andrew Shvets wrote:
> 
> > I've been recently trying to make a small TCP server (a toy.) I have
> > a channel that reads Characters and was trying to find the end of
> > the stream. Reading the documentation, I came across the following
> > in  g-socket.ads:
> > 
> > type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
> > --  Same interface as Ada.Streams.Stream_IO
> > 
> > I was trying to have a way to find out when the last Character was 
> > read from the stream. I could catch the Ada.IO_Exceptions.End_Error 
> > exception, but I'm wondering if there is a better way.
> 
> End_Error is the best possible way, when applied. GNAT socket streams do 
> not raise End_Error, AFAIK.
> 
> > while not Ada.Streams.Stream_IO.End_Of_File(Channel) loop
> >    Character'Read(Channel, Received_Char);
> >    Ada.Text_IO.Put(Received_Char);
> > end loop;
> 
> This is a bad idea even when if it can work. In the case of sockets 
> there is no file end. When the connection is closed by the peer the 
> stream will stop both returning data and blocking. I suppose that will 
> cause Constraint_Error in Character'Read.
> 
> In practice there is a higher level protocol on top of the socket 
> stream, so that it is always known how many octets to read next.
> 
> Regarding your case, try this:
> 
>     Buffer : Stream_Element_Array (1..Buffer_Size);
>     Last   : Stream_Element_Offset;
> begin
>     loop
>        Receive_Socket (Socket, Buffer, Last);
>        exit when Last < Buffer'First; -- Connection is closed by the peer
>        for Octet in Buffer'First..Last loop -- Dump octets as-is
>           Put (Character'Val (Buffer (Octet)));
>        end loop;
>     end loop;
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Thanks for your reply.  I did what you recommended.


  loop
    begin
      GNAT.Sockets.Receive_Socket(Receiver, Buffer, Last);

      -- the connection was reset by peer.
      exit when Last < Buffer'First;

      for Octet in Buffer'First .. Last loop
        Ada.Text_IO.Put(Character'Val(Buffer(Octet)));
      end loop;
    exception
      when Ada.IO_Exceptions.End_Error =>
        Ada.Text_IO.Put_Line(Ada.Text_IO.Standard_Error, " ERROR: Issue encountered while receiving data from user.");
    end;
  end loop;


I get the following error when I make the Receive_Socket procedure call:

raised GNAT.SOCKETS.SOCKET_ERROR : [107] Transport endpoint is not connected


^ permalink raw reply	[relevance 4%]

* Re: Finding the end of a stream from a socket
  2017-10-21  2:05  4% Finding the end of a stream from a socket Andrew Shvets
@ 2017-10-21  8:44  0% ` Dmitry A. Kazakov
  2017-10-21 13:45  4%   ` Andrew Shvets
  2017-10-21 17:34  0%   ` Andrew Shvets
  0 siblings, 2 replies; 195+ results
From: Dmitry A. Kazakov @ 2017-10-21  8:44 UTC (permalink / raw)


On 2017-10-21 04:05, Andrew Shvets wrote:

> I've been recently trying to make a small TCP server (a toy.) I have
> a channel that reads Characters and was trying to find the end of
> the stream. Reading the documentation, I came across the following
> in  g-socket.ads:
> 
> type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
> --  Same interface as Ada.Streams.Stream_IO
> 
> I was trying to have a way to find out when the last Character was 
> read from the stream. I could catch the Ada.IO_Exceptions.End_Error 
> exception, but I'm wondering if there is a better way.

End_Error is the best possible way, when applied. GNAT socket streams do 
not raise End_Error, AFAIK.

> while not Ada.Streams.Stream_IO.End_Of_File(Channel) loop
>    Character'Read(Channel, Received_Char);
>    Ada.Text_IO.Put(Received_Char);
> end loop;

This is a bad idea even when if it can work. In the case of sockets 
there is no file end. When the connection is closed by the peer the 
stream will stop both returning data and blocking. I suppose that will 
cause Constraint_Error in Character'Read.

In practice there is a higher level protocol on top of the socket 
stream, so that it is always known how many octets to read next.

Regarding your case, try this:

    Buffer : Stream_Element_Array (1..Buffer_Size);
    Last   : Stream_Element_Offset;
begin
    loop
       Receive_Socket (Socket, Buffer, Last);
       exit when Last < Buffer'First; -- Connection is closed by the peer
       for Octet in Buffer'First..Last loop -- Dump octets as-is
          Put (Character'Val (Buffer (Octet)));
       end loop;
    end loop;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 0%]

* Finding the end of a stream from a socket
@ 2017-10-21  2:05  4% Andrew Shvets
  2017-10-21  8:44  0% ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Andrew Shvets @ 2017-10-21  2:05 UTC (permalink / raw)


Hello,

I've been recently trying to make a small TCP server (a toy.)  I have a channel that reads Characters and was trying to find the end of the stream.  Reading the documentation, I came across the following in g-socket.ads:


type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; 
--  Same interface as Ada.Streams.Stream_IO


I was trying to have a way to find out when the last Character was read from the stream.  I could catch the Ada.IO_Exceptions.End_Error exception, but I'm wondering if there is a better way.


Channel       : GNAT.Sockets.Stream_Access;

....

while not Ada.Streams.Stream_IO.End_Of_File(Channel) loop
  Character'Read(Channel, Received_Char);
  Ada.Text_IO.Put(Received_Char);
end loop;





Many thank yous in advance for your help!


^ permalink raw reply	[relevance 4%]

* Re: Weird Bug in Get_Line
  2017-04-26  7:38  4% Weird Bug in Get_Line Brian Kolden
  2017-04-26  8:28  0% ` Brian Drummond
  2017-04-26 10:58  0% ` Simon Wright
@ 2017-04-26 17:03  0% ` Jeffrey R. Carter
  2 siblings, 0 replies; 195+ results
From: Jeffrey R. Carter @ 2017-04-26 17:03 UTC (permalink / raw)


On 04/26/2017 09:38 AM, Brian Kolden wrote:
> I came across an interesting issue in the Get_Line function. When piping in a
> file (using the linux cammand '<') GNAT "raises ADA.IO_EXCEPTIONS.END_ERROR :
> a-tigeli.adb:96".
>
> However, the interesting issue is this only happens for a very small number
> of line lengths. I've noticed the exception is only thrown on lines with
> length 500, 501, 1000, 1001. Lines bigger or smaller don't seem to raise the
> issue, even other multiples of 500. This only is effected when using a file
> as input, copying and pasting the line into the terminal does not seem to
> trigger it.

And also

> I forgot to mention the line has to be the very last line, otherwise there
> would be no EOF character to read. No newline character should be there, vim
> auto inserts one by default, for example. I was also able to trigger it on
> Redhat 5.11.0.9 running GNAT 4.1.2.

According to the ARM (A.10), Text_IO operates on "text files" as defined there. 
Part of that definition is that "the end of a line is marked by a _line 
terminator_" and "the end of a file is marked by the combination of a line 
terminator immediately followed by a page terminator and then a _file 
terminator_" [A.10(7)]. So technically, an implementation of Text_IO is not 
required to work on files that aren't valid Text_IO text files, and the error is 
that your file is not a valid Text_IO text file.

However, such an implementation of Text_IO is pretty useless on most systems, 
and compiler writers usually try hard to make sure that Text_IO works on foreign 
files. AdaCore certainly does. Still, if you produce files without a final line 
terminator, it's usually a good idea to find out why and fix that.

-- 
Jeff Carter
"Hold your temper. Count ten.... Now let 'er go.
You got a good aim."
Never Give a Sucker an Even Break
105


^ permalink raw reply	[relevance 0%]

* Re: Weird Bug in Get_Line
  2017-04-26  7:38  4% Weird Bug in Get_Line Brian Kolden
  2017-04-26  8:28  0% ` Brian Drummond
@ 2017-04-26 10:58  0% ` Simon Wright
  2017-04-26 17:03  0% ` Jeffrey R. Carter
  2 siblings, 0 replies; 195+ results
From: Simon Wright @ 2017-04-26 10:58 UTC (permalink / raw)


Brian Kolden <bakolden5@gmail.com> writes:

> I came across an interesting issue in the Get_Line function. When
> piping in a file (using the linux cammand '<') GNAT "raises
> ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96".
>
> However, the interesting issue is this only happens for a very small
> number of line lengths. I've noticed the exception is only thrown on
> lines with length 500, 501, 1000, 1001. Lines bigger or smaller don't
> seem to raise the issue, even other multiples of 500. This only is
> effected when using a file as input, copying and pasting the line into
> the terminal does not seem to trigger it.
>
> So, is this an GNAT issue or an OS issue?

A GNAT issue, most likely.

Check out http://blog.adacore.com/formal-verification-of-legacy-code


^ permalink raw reply	[relevance 0%]

* Re: Weird Bug in Get_Line
  2017-04-26  7:38  4% Weird Bug in Get_Line Brian Kolden
@ 2017-04-26  8:28  0% ` Brian Drummond
  2017-04-26 10:58  0% ` Simon Wright
  2017-04-26 17:03  0% ` Jeffrey R. Carter
  2 siblings, 0 replies; 195+ results
From: Brian Drummond @ 2017-04-26  8:28 UTC (permalink / raw)


On Wed, 26 Apr 2017 00:38:55 -0700, Brian Kolden wrote:

> I came across an interesting issue in the Get_Line function. When piping
> in a file (using the linux cammand '<') GNAT "raises
> ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96".
> 
> However, the interesting issue is this only happens for a very small
> number of line lengths. I've noticed the exception is only thrown on
> lines with length 500, 501, 1000, 1001. Lines bigger or smaller don't
> seem to raise the issue, even other multiples of 500. This only is
> effected when using a file as input, copying and pasting the line into
> the terminal does not seem to trigger it.
> 
> So, is this an GNAT issue or an OS issue?
> 
> 
> with Ada.Text_IO; use Ada.Text_IO;
> procedure Test is
> 	type String_Pointer is access all String;
> 	S : String := Get_Line;
> begin
> 	null;
> end Test;

Which Gnat? Which Linux?

-- Brian

^ permalink raw reply	[relevance 0%]

* Weird Bug in Get_Line
@ 2017-04-26  7:38  4% Brian Kolden
  2017-04-26  8:28  0% ` Brian Drummond
                   ` (2 more replies)
  0 siblings, 3 replies; 195+ results
From: Brian Kolden @ 2017-04-26  7:38 UTC (permalink / raw)


I came across an interesting issue in the Get_Line function. When piping in a file (using the linux cammand '<') GNAT "raises ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96". 

However, the interesting issue is this only happens for a very small number of line lengths. I've noticed the exception is only thrown on lines with length 500, 501, 1000, 1001. Lines bigger or smaller don't seem to raise the issue, even other multiples of 500. This only is effected when using a file as input, copying and pasting the line into the terminal does not seem to trigger it.

So, is this an GNAT issue or an OS issue?


with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
	type String_Pointer is access all String;
	S : String := Get_Line;
begin
	null;
end Test;

^ permalink raw reply	[relevance 4%]

* Re: ADA.IO_EXCEPTIONS.USE_ERROR thrown by Ada.Directories.More_Entries
  2016-07-27 16:28  6% ADA.IO_EXCEPTIONS.USE_ERROR thrown by Ada.Directories.More_Entries WBull
@ 2016-07-28 11:07  7% ` AdaMagica
  0 siblings, 0 replies; 195+ results
From: AdaMagica @ 2016-07-28 11:07 UTC (permalink / raw)


Looks like a GNAT bug. There is no exception mentioned in A.16(108/2).
Use_Error can be raised by Start_Search A.16(104/3).

^ permalink raw reply	[relevance 7%]

* ADA.IO_EXCEPTIONS.USE_ERROR thrown by Ada.Directories.More_Entries
@ 2016-07-27 16:28  6% WBull
  2016-07-28 11:07  7% ` AdaMagica
  0 siblings, 1 reply; 195+ results
From: WBull @ 2016-07-27 16:28 UTC (permalink / raw)


Running an Ada program that calls Ada.Directories.More_Entries on a Windows 7 system that has a protected system file in the directory of the search will throw the USE_ERROR which prevents finding the rest of the entries in the directory. The program was built with the 2016 GPL release of GNAT.

It seems like it would be more useful if the More_Entries call would succeed but the Get_Next_Entry would through the exception which would let the scanning of the directory continue.

^ permalink raw reply	[relevance 6%]

* ANN: Cortex GNAT RTS 20160522
@ 2016-05-22 14:20  3% Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2016-05-22 14:20 UTC (permalink / raw)


Available at
https://sourceforge.net/projects/cortex-gnat-rts/files/20160522/

This release includes GNAT Ada Run Time Systems (RTSs) based
on FreeRTOS (http://www.freertos.org) and targeted at boards with
Cortex-M3, -M4, -M4F MCUs (Arduino Due from http://www.arduino.org,
the STM32F4-series evaluation boards from STMicroelectronics at
http://www.st.com).

In each case, the board support for the RTS (configuration for size
and location of Flash, RAM; clock initialization; interrupt naming) is
in $RTS/adainclude. Support for the on-chip peripherals is also
included, in Ada spec files generated by SVD2Ada
(https://github.com/AdaCore/svd2ada).

The Ada source is either original or based on FSF GCC (mainly 4.9.1,
some later releases too).

(1) arduino-due is a Ravenscar-style RTOS based on FreeRTOS from
    http://www.freertos.org for the Arduino Due.

    See arduino-due/COPYING* for licensing terms.

    On-chip peripheral support in atsam3x8e/.

    Tests in test-arduino-due/.

(2) stm32f4 is a Ravenscar-style RTOS based on FreeRTOS from
    http://www.freertos.org for the STM32F4-DISC* board.

    See stm32f4/COPYING* for licensing terms.

    On-chip peripheral support in stm32f40x/.

    Tests in test-stm32f4/.

(3) stm32f429i is a Ravenscar-style RTOS based on FreeRTOS from
    http://www.freertos.org for the STM32F429I-DISC* board.

    See stm32f429i/COPYING* for licensing terms.

    On-chip peripheral support in stm32f429x/.

    Tests in test-stm32f429i/.

In this release,

* There is no longer any dependence on the STMicroelectronics'
  STM32Cube package.

* The support for on-chip peripherals is limited to the
  SVD2Ada-generated spec files. The AdaCore 'bareboard' software
  (currently https://github.com/AdaCore/bareboard, but a name change
  is under consideration) supports the STM32 line.

* Tasking no longer requires an explicit start
  (https://sourceforge.net/p/cortex-gnat-rts/tickets/5/).

* Locking in interrupt-handling protected objects no longer inhibits
  all interrupts, only those of equal or lower priority
  (https://sourceforge.net/p/cortex-gnat-rts/tickets/18/).

The standard packages included (there are more, implementation-specific,
ones) are:

Ada
Ada.Containers
Ada.Containers.Bounded_Hashed_Maps
Ada.Containers.Bounded_Vectors
Ada.Exceptions
Ada.IO_Exceptions
Ada.Interrupts
Ada.Interrupts.Names
Ada.Iterator_Interfaces
Ada.Real_Time
Ada.Streams
Ada.Synchronous_Task_Control
Ada.Tags
Ada.Task_Identification
Interfaces
Interfaces.C
Interfaces.C.Strings
System
System.Assertions
System.Address_To_Access_Conversions
System.Storage_Elements
GNAT
GNAT.Source_Info


^ permalink raw reply	[relevance 3%]

* ANN: Cortex GNAT RTS 20160314
@ 2016-03-14 17:42  4% Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2016-03-14 17:42 UTC (permalink / raw)


At https://sourceforge.net/projects/cortex-gnat-rts/files/20160314/.

This release includes

* an RTS for the Arduino Due, arduino-due, and a minimal BSP,
  arduino-due-bsp.

* an RTS for the STM32F429I-DISCO, stm32f429i-disco-rtos, based on
  STMicroelectronics' STM32Cube package and FreeRTOS, and a
  corresponding partial BSP, stm32f429i-disco-bsp.

* an RTS for the STM32F429I-DISCO, stm32f429i, based on FreeRTOS, with
  a set of peripheral definition packages created by SVD2Ada.

In this release,

* the Containers support generalized iteration ("for all E of C
  loop"). Note, this is achieved by removing tampering checks. While
  tampering errors are rare, it would be as well to check algorithms
  using a fully-featured desktop compiler.

The standard packages included (there are more, implementation-specific,
ones) are:

Ada
Ada.Containers
Ada.Containers.Bounded_Hashed_Maps
Ada.Containers.Bounded_Vectors
Ada.Exceptions
Ada.IO_Exceptions
Ada.Interrupts
Ada.Interrupts.Names
Ada.Iterator_Interfaces
Ada.Real_Time
Ada.Streams
Ada.Synchronous_Task_Control
Ada.Tags
Ada.Task_Identification
Interfaces
Interfaces.C
Interfaces.C.Strings
System
System.Assertions
System.Address_To_Access_Conversions
System.Storage_Elements
GNAT
GNAT.Source_Info


^ permalink raw reply	[relevance 4%]

* Re: Line-Terminator-Independent Text I/O (Mostly)
  2016-02-14 17:39  4% ` comicfanzine
  2016-02-14 18:20  0%   ` Jeffrey R. Carter
@ 2016-02-14 21:14  0%   ` PragmAda Software Engineering
  1 sibling, 0 replies; 195+ results
From: PragmAda Software Engineering @ 2016-02-14 21:14 UTC (permalink / raw)


On 02/14/2016 10:39 AM, comicfanzine@gmail.com wrote:
>
> dead-code@machine:~/Bureau/PragmARC-Ada-07$ "./main"
>
> Execution terminated by unhandled exception
> Exception name: ADA.IO_EXCEPTIONS.END_ERROR
> Message: s-stratt.adb:194
> Call stack traceback locations:
> 0x8069483 0x804c5e9 0x804bdfc 0x804c8d0 0x804a04f 0xb75664d1 0x8049a9f
> dead-code@machine:~/Bureau/PragmARC-Ada-07$
>
>
> dead-code@machine:~/Bureau/PragmARC-Ada-07$ addr2line --exe=main 0x8069483 0x804c5e9 0x804bdfc 0x804c8d0 0x804a04f 0xb75664d1 0x8049a9f
> ??:0
> /home/dead-code/Bureau/PragmARC-Ada-07/pragmarc-text_io.adb:210
> /home/dead-code/Bureau/PragmARC-Ada-07/pragmarc-text_io.adb:93
> /home/dead-code/Bureau/PragmARC-Ada-07/main.adb:22
> /home/dead-code/Bureau/PragmARC-Ada-07/b~main.adb:293
> ??:0
> ??:0

This was caused by the input having a final line that was not terminated 
by a line terminator. This is now corrected in the version available 
from the PragmAda web site, or from

https://github.com/jrcarter/PragmARC

-- 
Jeffrey R. Carter, President
PragmAda Software Engineering
pragmada.x10hosting.com


--- news://freenews.netfront.net/ - complaints: news@netfront.net ---


^ permalink raw reply	[relevance 0%]

* Re: Line-Terminator-Independent Text I/O (Mostly)
  2016-02-14 17:39  4% ` comicfanzine
@ 2016-02-14 18:20  0%   ` Jeffrey R. Carter
  2016-02-14 21:14  0%   ` PragmAda Software Engineering
  1 sibling, 0 replies; 195+ results
From: Jeffrey R. Carter @ 2016-02-14 18:20 UTC (permalink / raw)


On 02/14/2016 10:39 AM, comicfanzine@gmail.com wrote:
> 
> There is a End_Error problem with this package , that i don't understand :
> 
> dead-code@machine:~/Bureau/PragmARC-Ada-07$ "./main"
> 
> Execution terminated by unhandled exception
> Exception name: ADA.IO_EXCEPTIONS.END_ERROR
> Message: s-stratt.adb:194
> Call stack traceback locations:
> 0x8069483 0x804c5e9 0x804bdfc 0x804c8d0 0x804a04f 0xb75664d1 0x8049a9f
> dead-code@machine:~/Bureau/PragmARC-Ada-07$ 
> 
> 
> dead-code@machine:~/Bureau/PragmARC-Ada-07$ addr2line --exe=main 0x8069483 0x804c5e9 0x804bdfc 0x804c8d0 0x804a04f 0xb75664d1 0x8049a9f
> ??:0
> /home/dead-code/Bureau/PragmARC-Ada-07/pragmarc-text_io.adb:210
> /home/dead-code/Bureau/PragmARC-Ada-07/pragmarc-text_io.adb:93
> /home/dead-code/Bureau/PragmARC-Ada-07/main.adb:22
> /home/dead-code/Bureau/PragmARC-Ada-07/b~main.adb:293

Interesting. I was unable to reproduce the problem. Could you send the file used
as input to pragmada@pragmada.x10hosting.com ?

-- 
Jeff Carter
"Unix and C are the ultimate computer viruses."
Richard Gabriel
99


^ permalink raw reply	[relevance 0%]

* Re: Line-Terminator-Independent Text I/O (Mostly)
  @ 2016-02-14 17:39  4% ` comicfanzine
  2016-02-14 18:20  0%   ` Jeffrey R. Carter
  2016-02-14 21:14  0%   ` PragmAda Software Engineering
  0 siblings, 2 replies; 195+ results
From: comicfanzine @ 2016-02-14 17:39 UTC (permalink / raw)


Hi ,

There is a End_Error problem with this package , that i don't understand :

dead-code@machine:~/Bureau/PragmARC-Ada-07$ "./main"

Execution terminated by unhandled exception
Exception name: ADA.IO_EXCEPTIONS.END_ERROR
Message: s-stratt.adb:194
Call stack traceback locations:
0x8069483 0x804c5e9 0x804bdfc 0x804c8d0 0x804a04f 0xb75664d1 0x8049a9f
dead-code@machine:~/Bureau/PragmARC-Ada-07$ 


dead-code@machine:~/Bureau/PragmARC-Ada-07$ addr2line --exe=main 0x8069483 0x804c5e9 0x804bdfc 0x804c8d0 0x804a04f 0xb75664d1 0x8049a9f
??:0
/home/dead-code/Bureau/PragmARC-Ada-07/pragmarc-text_io.adb:210
/home/dead-code/Bureau/PragmARC-Ada-07/pragmarc-text_io.adb:93
/home/dead-code/Bureau/PragmARC-Ada-07/main.adb:22
/home/dead-code/Bureau/PragmARC-Ada-07/b~main.adb:293
??:0
??:0
dead-code@machine:~/Bureau/PragmARC-Ada-07$ 

Code : http://pastebin.com/DZuEYC01

^ permalink raw reply	[relevance 4%]

* ANN: Cortex GNAT RTS 20160207
@ 2016-02-07 22:45  4% Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2016-02-07 22:45 UTC (permalink / raw)


This release is at Sourceforge[1].

This release includes an RTS for the Arduino Due, arduino-due, and a
minimal BSP, arduino-due-bsp.

For the STM32F429I-DISCO, there is one RTS, stm32f429i-disco-rtos, and
one BSP, stm32f429i-disco-bsp.

In this release,

* the Containers support generalized iteration ("for all E of C
  loop"). Note, this is achieved by removing tampering checks. While
  tampering errors are rare, it would be as well to check algorithms
  using a fully-featured desktop compiler.

* FreeRTOS is configured to detect stack overflow (if it is detected,
  the RTS loops inside vApplicationStackOverflowHook()).

The standard packages included (there are more,
implementation-specific, ones) are:

   Ada
   Ada.Containers
   Ada.Containers.Bounded_Hashed_Maps
   Ada.Containers.Bounded_Vectors
   Ada.Exceptions
   Ada.IO_Exceptions
   Ada.Interrupts
   Ada.Interrupts.Names
   Ada.Iterator_Interfaces
   Ada.Real_Time
   Ada.Streams
   Ada.Synchronous_Task_Control
   Ada.Tags
   Ada.Task_Identification
   Interfaces
   Interfaces.C
   Interfaces.C.Strings
   System
   System.Assertions
   System.Address_To_Access_Conversions
   System.Storage_Elements
   GNAT
   GNAT.Source_Info

The software is supplied built with for debugging (-g) and with suitable
optimisation (-Og), using GNAT GPL 2015 on Mac OS X (it should work
out of the box with a Linux-hosted GNAT GPL 2015 cross-compiler, but
will need recompiling for another compiler version).

[1] https://sourceforge.net/projects/cortex-gnat-rts/files/20160207/


^ permalink raw reply	[relevance 4%]

* Re: Re-write a file in Ada
  2016-01-18 15:05  0%     ` gautier_niouzes
@ 2016-01-19 12:24  0%       ` Brian Drummond
  0 siblings, 0 replies; 195+ results
From: Brian Drummond @ 2016-01-19 12:24 UTC (permalink / raw)


On Mon, 18 Jan 2016 07:05:55 -0800, gautier_niouzes wrote:

> Le lundi 11 janvier 2016 18:18:48 UTC+1, Brian Drummond a écrit :
> 
>> > raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96
>> 
>> In outline, when you see this sort of error, find the installation's
>> "Ada include directory" which contains the named file...
>> 
>> locate a-tigeli.adb
>> /usr/lib/gcc/x86_64-linux-gnu/4.9/rts-native/adainclude/a-tigeli.adb
...
>> Looks like we ran out of file somehow. From here on it's usually
>> straightforward.
> 
> Sure - but all that investigation effort brings nothing: the exception's
> name gives already this hint: the end of a file was reached. The fact
> that it raised somewhere in the run-time library is obvious and brings
> zero information for finding the bug: no indication is given about where
> the exception occurred in the program. 

Yes, that is true for End_Error specifically, (assuming you have already 
learned what "End_Error" means. Which may not be obvious to a beginner) 

Other exceptions - Constraint_Error, Storage_Error and so on have a much 
wider range of causes, then this process can be more helpful. I could 
have been clearer that I wanted to make a wider point.

For example, tracing "Constraint_Error" that way, once landed me in the 
Ada.Command_Line package, which made it immediately obvious I wasn't 
trapping command lines with missing arguments.

> It's a shame that GNAT doesn't
> switch on its trace-back by default, IMHO. The current setup is
> disturbing for beginners and cumbersome for people using GNAT for larger
> programs.

Agreed. Traceback would be very helpful. Because I can never remember 
how, I'll outline it here, partly in the hope of memorising it. From

https://gcc.gnu.org/onlinedocs/gnat_ugn/Non-Symbolic-Traceback.html#Non-
Symbolic-Traceback

To enable this feature you must use the `-E' gnatbind's option. 
(And compile with -g for debug information)
gnatmake -g main.adb -bargs -E

A similar point has been made for the "Ada compliant" checking flags, and 
while Gnat has been improved in this area, I think you still need to add 
some flags, giving

gnatmake -g -gnataoE -fstack-check main.adb -bargs -E

-- Brian


^ permalink raw reply	[relevance 0%]

* Re: End of a file
  @ 2016-01-19  7:20  5% ` comicfanzine
  0 siblings, 0 replies; 195+ results
From: comicfanzine @ 2016-01-19  7:20 UTC (permalink / raw)


>If you have 30 lines, set_line (30) is OK. It's >set_Line (31) that raises End_Error... 

Ok , then why it's the case here :
" raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:1900 "

There is only 26 lines , and the loop is suppose to stop at the end of the file . 

WITH Ada.Text_IO ;  USE Ada.Text_IO ;

Procedure count_nb_lines is

  this_file : File_type ;

  Last_line : Positive_Count := 1 ;

Begin

    Open
     (File => this_file ,
      Mode => In_file ,
      Name => "count_nb_lines.adb");

   loop exit when End_Of_File( this_file );
     skip_line( this_file , Last_line );

     Last_line := Last_line + 1 ;
   end loop ;

   put ( "Total of lines by Ada.Text_IO' s package : "&Positive_Count'Image( Last_line ) );

   Close( this_file );

end count_nb_lines ;


^ permalink raw reply	[relevance 5%]

* Re: Re-write a file in Ada
  2016-01-11 17:16  0%   ` Brian Drummond
@ 2016-01-18 15:05  0%     ` gautier_niouzes
  2016-01-19 12:24  0%       ` Brian Drummond
  0 siblings, 1 reply; 195+ results
From: gautier_niouzes @ 2016-01-18 15:05 UTC (permalink / raw)


Le lundi 11 janvier 2016 18:18:48 UTC+1, Brian Drummond a écrit :

> > raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96
> 
> In outline, when you see this sort of error, find the installation's "Ada 
> include directory" which contains the named file...
> 
> locate a-tigeli.adb
> /usr/lib/gcc/x86_64-linux-gnu/4.9/rts-native/adainclude/a-tigeli.adb
> 
> open in editor (read only) ... and see
> --     A D A . T E X T _ I O . G E T _ L I N E      --
> so we know the error occurred in "Get_Line"
> 
> And look at line 96:
> 
>    function Get_Chunk (N : Positive) return Natural is
> ...blah...
>          else
>             raise End_Error;
>          end if;
> 
> Looks like we ran out of file somehow. From here on it's usually 
> straightforward.

Sure - but all that investigation effort brings nothing: the exception's name gives already this hint: the end of a file was reached. The fact that it raised somewhere in the run-time library is obvious and brings zero information for finding the bug: no indication is given about where the exception occurred in the program. It's a shame that GNAT doesn't switch on its trace-back by default, IMHO. The current setup is disturbing for beginners and cumbersome for people using GNAT for larger programs.
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address


^ permalink raw reply	[relevance 0%]

* Re: Re-write a file in Ada
  2016-01-10 16:54  5% ` comicfanzine
  2016-01-10 18:59  0%   ` Björn Lundin
@ 2016-01-11 17:16  0%   ` Brian Drummond
  2016-01-18 15:05  0%     ` gautier_niouzes
  1 sibling, 1 reply; 195+ results
From: Brian Drummond @ 2016-01-11 17:16 UTC (permalink / raw)


On Sun, 10 Jan 2016 08:54:01 -0800, comicfanzine wrote:

> Ok , in others words :
> 
> The error :
> 
> raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96

In outline, when you see this sort of error, find the installation's "Ada 
include directory" which contains the named file...

locate a-tigeli.adb
/usr/lib/gcc/x86_64-linux-gnu/4.9/rts-native/adainclude/a-tigeli.adb

open in editor (read only) ... and see
--     A D A . T E X T _ I O . G E T _ L I N E      --
so we know the error occurred in "Get_Line"

And look at line 96:

   function Get_Chunk (N : Positive) return Natural is
...blah...
         else
            raise End_Error;
         end if;

Looks like we ran out of file somehow. From here on it's usually 
straightforward.

-- Brian

^ permalink raw reply	[relevance 0%]

* Re: Re-write a file in Ada
  2016-01-10 16:54  5% ` comicfanzine
@ 2016-01-10 18:59  0%   ` Björn Lundin
  2016-01-11 17:16  0%   ` Brian Drummond
  1 sibling, 0 replies; 195+ results
From: Björn Lundin @ 2016-01-10 18:59 UTC (permalink / raw)


On 2016-01-10 17:54, comicfanzine@gmail.com wrote:
> Ok , in others words :
> 
> I want to open the file , copy all the lines in it , then do some change in those lignes ( unbounded_strings ) , and finally paste all in the file ( mode : Out_file ) .
> 
> This is what i meant by " Re-write a file " .
> 
> 
> The error :
> 
> raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96
> 

Below, you need tocomplement with paramters for
open/create, and declare from_file and to_file

try something like :


--pseudo code

with Ada.Text_IO.Unbounded_IO ;	use Ada.Text_IO.Unbounded_IO ;
with Ada.Strings.Unbounded ;	use Ada.Strings.Unbounded ;
with Ada.Text_IO ;              use Ada.Text_IO ;

procedure Rewrite is
  Buffer : Unbounded_String := Null_Unbounded_String;
begin
  Open (From_file);
  Create(To_File);

  begin
    loop
      Buffer := Get_Line(From_File);
      Put_Line(To_File, Buffer);
    end loop;
  exception
    when End_Error =>
      Close(From_File);
      Close(To_File);
  end;
end Rewrite;



-- 
--
Björn


^ permalink raw reply	[relevance 0%]

* Re: Re-write a file in Ada
  @ 2016-01-10 16:54  5% ` comicfanzine
  2016-01-10 18:59  0%   ` Björn Lundin
  2016-01-11 17:16  0%   ` Brian Drummond
  0 siblings, 2 replies; 195+ results
From: comicfanzine @ 2016-01-10 16:54 UTC (permalink / raw)


Ok , in others words :

I want to open the file , copy all the lines in it , then do some change in those lignes ( unbounded_strings ) , and finally paste all in the file ( mode : Out_file ) .

This is what i meant by " Re-write a file " .


The error :

raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96

^ permalink raw reply	[relevance 5%]

* Re: Create in a root directory (Linux)
    2015-10-29  6:41  5%     ` comicfanzine
@ 2015-10-29  6:50  4%     ` comicfanzine
  1 sibling, 0 replies; 195+ results
From: comicfanzine @ 2015-10-29  6:50 UTC (permalink / raw)


Le jeudi 29 octobre 2015 00:01:49 UTC+1, Paul Rubin a écrit :
> Simon Wright <simon@pushface.org> writes:
> >>    Create( MonFichier,Name => " /clone.adb");
> 
> The problem is the leading space before the /

I use Linux = Ubuntu .
My fault i have not paste the code right , in fact the code whas without the space already :

WITH Ada.Text_IO ;  USE Ada.Text_IO ; 

PROCEDURE TestFichier IS

   MonFichier : File_type ; 
   
BEGIN 
   Create( MonFichier,Name => "/clone.adb");
   Close(MonFichier);
END TestFichier ;
[/code]I got the error :
raised ADA.IO_EXCEPTIONS.USE_ERROR : /clone.adb: Permission denied

Then how can i be recognize as "root" for create my file in this directory .


^ permalink raw reply	[relevance 4%]

* Re: Create in a root directory (Linux)
  @ 2015-10-29  6:41  5%     ` comicfanzine
  2015-10-29  6:50  4%     ` comicfanzine
  1 sibling, 0 replies; 195+ results
From: comicfanzine @ 2015-10-29  6:41 UTC (permalink / raw)


Le jeudi 29 octobre 2015 00:01:49 UTC+1, Paul Rubin a écrit :
> Simon Wright <simon@pushface.org> writes:
> >>    Create( MonFichier,Name => " /clone.adb");
> 
> The problem is the leading space before the /

My fault i have not paste the code right , in fact the code whas without the space :

[code]WITH Ada.Text_IO ;  USE Ada.Text_IO ; 

PROCEDURE TestFichier IS

   MonFichier : File_type ; 
   
BEGIN 
   Create( MonFichier,Name => "/clone.adb");
  if Is_Open (MonFichier) then
   Put (Item => "Le fichier , ouvert ? : ", File => MonFichier);
end if;
END TestFichier ;[code/]
 I got the error : raised ADA.IO_EXCEPTIONS.USE_ERROR : /clone.adb: Permission denied

^ permalink raw reply	[relevance 5%]

* Re: Error "exception not permitted here" when putting EXCEPTION in a loop
  2015-07-18 14:32  6%           ` Trish Cayetano
@ 2015-07-18 14:59  6%             ` Björn Lundin
  0 siblings, 0 replies; 195+ results
From: Björn Lundin @ 2015-07-18 14:59 UTC (permalink / raw)


On 2015-07-18 16:32, Trish Cayetano wrote:
> On Saturday, July 18, 2015 at 9:55:12 PM UTC+8, björn lundin wrote:

This one works.
As Tero said - skip_line in exception handler does it.
But you ONLY need it there.

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;

procedure Main is
   GuessWord : String(1..20);
   last: Natural;
   option : Integer := 0;
   endGame: Boolean := False;
begin
    while not endGame loop
      begin
          Ada.Text_IO.Put_Line(" | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass
3)Enter Word 4)Exit ");
          Ada.Integer_Text_IO.Get(option);
          case option is
             when 1 =>
                Ada.Text_IO.Put_Line("Shuffle");
             when 2 =>
                Ada.Text_IO.Put_Line("Pass");
             when 3 =>
                Skip_Line; -- needed ????
                Ada.Text_IO.Put_Line("Enter word: ");
                Ada.Text_IO.Get_Line(GuessWord, Last);
             when 4 =>
                Ada.Text_IO.Put_Line("See you again soon!");
                endGame := true;
             when others =>
                Ada.Text_IO.Put_Line("Invalid Option");
          end case;
	exception
	  when ADA.IO_EXCEPTIONS.Data_Error =>
	    Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");
	    skip_line;
         end;
     end loop;
end Main;

--
Björn

^ permalink raw reply	[relevance 6%]

* Re: Error "exception not permitted here" when putting EXCEPTION in a loop
  @ 2015-07-18 14:32  6%           ` Trish Cayetano
  2015-07-18 14:59  6%             ` Björn Lundin
  0 siblings, 1 reply; 195+ results
From: Trish Cayetano @ 2015-07-18 14:32 UTC (permalink / raw)


On Saturday, July 18, 2015 at 9:55:12 PM UTC+8, björn lundin wrote:
> On 2015-07-18 14:41, Trish Cayetano wrote:
> > Hello Björn, 
> > 
> > I don't need the inner loop after all.
> > I removed the inner loop but it still run in infinite loops.
> 
> it runs fine as long as you do not enter a non-digit.
> Then it seems like the call to
>   Ada.Integer_Text_IO.Get(option);
> does not clear the buffer.
> 
> if fed a character, Data_error is raised - which is correct.
> But the next time the code enters the loop, it seems it does
> not wait for input again.
> It raises the data_error again, and the infinite loop is there.
> 
> Seems like a compiler bug to me, but the behavior of *text_io.get
> has surprised me before.
> 
> --
> Björn

Well which reminds me! I added a SKIP_LINE... The expected output is close... It shows the exception error every other input... it waits for 2 inputs and then 1 input and then 2... 

REVISED

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;

procedure Main is

   GuessWord : String(1..20);
   last: Natural;

   option : Integer := 0;

   endGame: Boolean := False;


begin

    while not endGame loop


         begin

         Ada.Text_IO.Put_Line(" | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit ");
         Skip_Line;
         Ada.Integer_Text_IO.Get(option);
         
          exception
            when ADA.IO_EXCEPTIONS.Data_Error =>
            Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");


      case option is
         when 1 =>
            Ada.Text_IO.Put_Line("Shuffle");
         when 2 =>
            Ada.Text_IO.Put_Line("Pass");
         when 3 =>
            Skip_Line;
            Ada.Text_IO.Put_Line("Enter word: ");
            Ada.Text_IO.Get_Line(GuessWord, Last);
         when 4 =>
            Ada.Text_IO.Put_Line("See you again soon!");
            endGame := true;
         when others =>
            Ada.Text_IO.Put_Line("Invalid Option");


      end case;

           
           



         end;

          end loop;



end Main;


=====

OUTPUT

C:\Users\a0284014\Desktop\ada\exception\obj\main
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
e
1
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
3
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
e
Try a number from 1 to 4, Buddy
Enter word: 
e
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
r
t
Try a number from 1 to 4, Buddy
Enter word: 
r
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
r

^ permalink raw reply	[relevance 6%]

* Re: Error "exception not permitted here" when putting EXCEPTION in a loop
  @ 2015-07-18 12:41  6%       ` Trish Cayetano
    0 siblings, 1 reply; 195+ results
From: Trish Cayetano @ 2015-07-18 12:41 UTC (permalink / raw)


On Saturday, July 18, 2015 at 6:07:12 PM UTC+8, björn lundin wrote:
> On 2015-07-18 10:14, Trish Cayetano wrote:
> 
> e is my own code (i removed the functions and others)... S
> 
> orry I am really new to Ada. I actually tried also to put
> 
> another loop and added declare, begin and end. It
> 
> hang after I ran. And when I terminated the process, it looks like it
> ran infinitely in loops.
> > 
> 
> when you set endGame to true,
> you are in the *inner* loop.
> but the *outer* loop tests for endGame.
> 
> How do you exit the *inner* loop?
> 
> what purpose has the *inner* loop?
> 
> When you have the answer,
> your program will be easy to fix.
> 
> --
> Björn

Hello Björn, 

I don't need the inner loop after all.
I removed the inner loop but it still run in infinite loops.

REVISED CODE:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;

procedure Main is

   GuessWord : String(1..20);
   last: Natural;

   option : Integer := 0;

   endGame: Boolean := False;


begin

    while not endGame loop


         begin

      Ada.Text_IO.Put_Line(" | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit ");
      Ada.Integer_Text_IO.Get(option);

      case option is
         when 1 =>
            Ada.Text_IO.Put_Line("Shuffle");
         when 2 =>
            Ada.Text_IO.Put_Line("Pass");
         when 3 =>
            Skip_Line;
            Ada.Text_IO.Put_Line("Enter word: ");
            Ada.Text_IO.Get_Line(GuessWord, Last);
         when 4 =>
            Ada.Text_IO.Put_Line("See you again soon!");
            endGame := true;
         when others =>
            Ada.Text_IO.Put_Line("Invalid Option");


      end case;

            Skip_Line;
            exception
            when ADA.IO_EXCEPTIONS.Data_Error =>
            Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");
           



         end;
      
          end loop;



end Main;


RESULT:
C:\Users\a0284014\Desktop\ada\exception\obj\main
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
f
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy

[2015-07-18 20:39:33] process exited with status 1, elapsed time: 10.81s

^ permalink raw reply	[relevance 6%]

* Re: Error "exception not permitted here" when putting EXCEPTION in a loop
  2015-07-17 15:58  0% ` G.B.
@ 2015-07-18  8:14  5%   ` Trish Cayetano
    0 siblings, 1 reply; 195+ results
From: Trish Cayetano @ 2015-07-18  8:14 UTC (permalink / raw)


On Friday, July 17, 2015 at 11:58:18 PM UTC+8, G.B. wrote:
> On 17.07.15 17:47, Trish Cayetano wrote:
> > Hi,
> >
> > I am getting error "exception not permitted here" when running below in a loop.
> > Well it runs if I put it outside the loop but I need it inside the loop...
> >
> >             exception
> >              when ADA.IO_EXCEPTIONS.DATA_ERROR =>
> >              Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");
> >
> > Thanks in advance for your help...
> >
> 
> does it look like
> 
>   loop
>      ...
>     exception ...
>      ...
>   end loop
> 
> If so, then note that "exception" must be in a block,
> such as a procedure body, or a block statement (LRM 5.6):
> 
> 
>    loop
>      begin
>        ...  -- handled sequence of statements
>      exception ...
>      ...
>      end;
>    end loop
> 
> More complete examples would help reducing guess work.

Thanks, David and GB.
It still does not work... 
Here is my own code (i removed the functions and others)... Sorry I am really new to Ada. I actually tried also to put another loop and added declare, begin and end. It hang after I ran. And when I terminated the process, it looks like it ran infinitely in loops. 

   
===== 
--start of code

   with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;

procedure Main is

   GuessWord : String(1..20);
   last: Natural;
 
   option : Integer := 0;
 
   endGame: Boolean := False;


begin

    while not endGame loop

      loop
         begin

      Ada.Text_IO.Put_Line(" | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit ");
      Ada.Integer_Text_IO.Get(option);

      case option is
         when 1 =>
            Ada.Text_IO.Put_Line("Shuffle");
         when 2 =>
            Ada.Text_IO.Put_Line("Pass");
         when 3 =>
            Skip_Line;
            Ada.Text_IO.Put_Line("Enter word: ");
            Ada.Text_IO.Get_Line(GuessWord, Last);
         when 4 =>
            Ada.Text_IO.Put_Line("See you again soon!");
            endGame := true;
         when others =>
            Ada.Text_IO.Put_Line("Invalid Option");


      end case;

            exception
            when ADA.IO_EXCEPTIONS.Data_Error =>
            Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");




         end;
          end loop;
      end loop;


end Main;



--end of code
==============
RESULT:

C:\Users\a0284014\Desktop\ada\exception\obj\main
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
1
Shuffle
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
e
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 
Try a number from 1 to 4, Buddy
 | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit 

--retracted repeats
[2015-07-18 16:11:13] process exited with status 1, elapsed time: 19.58s

^ permalink raw reply	[relevance 5%]

* Re: Error "exception not permitted here" when putting EXCEPTION in a loop
  2015-07-17 15:47  5% Error "exception not permitted here" when putting EXCEPTION in a loop Trish Cayetano
  2015-07-17 15:58  0% ` G.B.
@ 2015-07-17 16:02  0% ` Björn Lundin
  1 sibling, 0 replies; 195+ results
From: Björn Lundin @ 2015-07-17 16:02 UTC (permalink / raw)


On 2015-07-17 17:47, Trish Cayetano wrote:
> Hi, 
> 
> I am getting error "exception not permitted here" when running below in a loop. 
> Well it runs if I put it outside the loop but I need it inside the loop... 
> 
>            exception
>             when ADA.IO_EXCEPTIONS.DATA_ERROR =>
>             Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");
> 
> Thanks in advance for your help...
> 

-- basic procedure
procedure bla is
begin
  null;
exception
  when Constraint_error => null;
end bla;



procedure bla is
begin

  -- catch 1 exception and then fall out of loop
  begin
    loop
      do_stuff;
    end loop;
  exception
    when Constraint_error => null;
  end;

-- or perhaps

  -- catch exception outside every invocation of do_stuff
  -- not falling out of loop
  loop
    begin
      do_stuff;
    exception
      when Constraint_error => null;
    end;
  end loop;


exception
  when Constraint_error => null;
end bla;




-- 
--
Björn


^ permalink raw reply	[relevance 0%]

* Re: Error "exception not permitted here" when putting EXCEPTION in a loop
  2015-07-17 15:47  5% Error "exception not permitted here" when putting EXCEPTION in a loop Trish Cayetano
@ 2015-07-17 15:58  0% ` G.B.
  2015-07-18  8:14  5%   ` Trish Cayetano
  2015-07-17 16:02  0% ` Björn Lundin
  1 sibling, 1 reply; 195+ results
From: G.B. @ 2015-07-17 15:58 UTC (permalink / raw)


On 17.07.15 17:47, Trish Cayetano wrote:
> Hi,
>
> I am getting error "exception not permitted here" when running below in a loop.
> Well it runs if I put it outside the loop but I need it inside the loop...
>
>             exception
>              when ADA.IO_EXCEPTIONS.DATA_ERROR =>
>              Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");
>
> Thanks in advance for your help...
>

does it look like

  loop
     ...
    exception ...
     ...
  end loop

If so, then note that "exception" must be in a block,
such as a procedure body, or a block statement (LRM 5.6):


   loop
     begin
       ...  -- handled sequence of statements
     exception ...
     ...
     end;
   end loop

More complete examples would help reducing guess work.

^ permalink raw reply	[relevance 0%]

* Error "exception not permitted here" when putting EXCEPTION in a loop
@ 2015-07-17 15:47  5% Trish Cayetano
  2015-07-17 15:58  0% ` G.B.
  2015-07-17 16:02  0% ` Björn Lundin
  0 siblings, 2 replies; 195+ results
From: Trish Cayetano @ 2015-07-17 15:47 UTC (permalink / raw)


Hi, 

I am getting error "exception not permitted here" when running below in a loop. 
Well it runs if I put it outside the loop but I need it inside the loop... 

           exception
            when ADA.IO_EXCEPTIONS.DATA_ERROR =>
            Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");

Thanks in advance for your help...


^ permalink raw reply	[relevance 5%]

* ANN: STM32F4 GNAT Run Time Systems 20150406
@ 2015-04-06 17:27  4% Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2015-04-06 17:27 UTC (permalink / raw)


This is the fourth release of a GNAT RTS with the GCC Runtime Library
exception for STM32F4 boards.

(a) Tasking is implemented using FreeRTOS[3], which STMicroelectronics
    provide a copy of with their BSP.

(b) I've included a BSP with minimal higher-level Ada interfaces to the
    board hardware: clock, buttons, LEDs, LCD. In addition, there's a
    machine-generated translation of STMicroelectronics' type-specific
    header in stm32f429xx_h.ads, for low-level interfacing.

The release is at
https://sourceforge.net/projects/stm32f4-gnat-rts/files/20150406/.

From its README,

20150406
========

This release has been reorganised from previous releases.

There is one RTS, stm32f4-disco-rtos, and one BSP, stm32f4-disco-bsp.

Changes to the RTS from the previous release:
---------------------------------------------

These units (and supporting units) are now included:

  Ada.Containers.Bounded_Vectors (*)
  Ada.Containers.Bounded_Hashed_Maps (*)
  Ada.Containers.Generic_Array_Sort
  Ada.Containers.Generic_Constrained_Array_Sort
  Ada.IO_Exceptions
  Ada.Streams
  Ada.Task_Identification
  Interfaces.C
  Interfaces.C.Strings
  System.Assertions

  (*) The new iterators (for some F in Foo loop ...) are NOT supported
      (they require finalization).

The STM32F429I_Discovery tree has been moved to the BSP.

The following tickets have been fixed:

  2  Protected spec hides package Interfaces
  14 Last_Chance_Handler doesn’t stop tasking

Tasking is started by calling Start_FreeRTOS_Scheduler.

^ permalink raw reply	[relevance 4%]

* Re: Reading data from file
  2014-03-07 21:55  4%                   ` Laurent
@ 2014-03-08  6:56  0%                     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2014-03-08  6:56 UTC (permalink / raw)


On Fri, 7 Mar 2014 13:55:41 -0800 (PST), Laurent wrote:

> While building my procedure to read data from
> a text file I had a few endless loops which blocked
> GPS completely. Got spinning ball of death and I had
> to force quit GPS. So I had no possibility to see my
> text to find out where it loops.

I suppose it is under Windows and you doing much output. That is not
entirely GPS' fault, it is the GTK text view widget GPS uses to show the
program's output. Since GTK is single-threaded and event-driven a steady
flow of output from an infinite loop chokes all GPS.

But you don't need to kill the GPS, you do your program instead from the
task manager. That will cut flooding the messages loop and GPS will respond
again.

> I tried to open my binary app which displayed the text.
> But when it arrives at the place where it should read the
> text file it raises:
> 
> raised ADA.IO_EXCEPTIONS.NAME_ERROR : Datafile.txt: No such file or directory
> 
> Now that I have found the error of the endless loops 
> and everything works as it should in GPS.
> 
> But the application still raises this error.
> 
> The txt file is in the folder with the dab/adses, the
> application is in the build folder:
> 
> Source Folder/Datafile.txt
> Source Folder/Build/My_Application
> 
> Quite useless application if it doesn't
> work without GPS.
> 
> How can I solve this?

By passing a correct file name to your application, of course. If the
application execution folder and the file folder are different you must use
the full path.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 0%]

* Re: Reading data from file
  @ 2014-03-07 21:55  4%                   ` Laurent
  2014-03-08  6:56  0%                     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Laurent @ 2014-03-07 21:55 UTC (permalink / raw)


Hi

While building my procedure to read data from
a text file I had a few endless loops which blocked
GPS completely. Got spinning ball of death and I had
to force quit GPS. So I had no possibility to see my
text to find out where it loops.

I tried to open my binary app which displayed the text.
But when it arrives at the place where it should read the
text file it raises:

raised ADA.IO_EXCEPTIONS.NAME_ERROR : Datafile.txt: No such file or directory

Now that I have found the error of the endless loops 
and everything works as it should in GPS.

But the application still raises this error.

The txt file is in the folder with the dab/adses, the
application is in the build folder:

Source Folder/Datafile.txt
Source Folder/Build/My_Application

Quite useless application if it doesn't
work without GPS.

How can I solve this?

Thanks

Laurent

^ permalink raw reply	[relevance 4%]

* Re: Reading data from file
  2014-03-04 21:27  3%   ` Laurent
@ 2014-03-04 21:42  0%     ` Niklas Holsti
    1 sibling, 0 replies; 195+ results
From: Niklas Holsti @ 2014-03-04 21:42 UTC (permalink / raw)


On 14-03-04 23:27 , Laurent wrote:
> Hi
> 
> @Mike: Thanks for this detailed example. 
> 
> Unfortunately I seem to have mixed up a few things while writing my post. 
> 
> The text file contains just:
>    
>   1234
>   test
>   male ...
> 
> The ID: ,... was just supposed to inform you about the type. 
> 
> The exact error message is: 
> 
> raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tienio.adb:57 instantiated at employees-io.adb:17
> 
> which is:
> 
>     type GenderType is (Female, Male);     
> 
>      package GenderType_IO is
>      new Ada.Text_IO.Enumeration_IO (Enum => GenderType);
> 
> Here is my code. It compiles but it isn't complete. Will
> probably fail for the moment if I try to read more than
> one record. (Won't read even one so...). Reading the name
> could be one reason for the problem with the enumeration.

I believe you have found the error there...

> procedure Read_Employee_From_File (Item : out Employees.Employee) is
> 
>       Import_File : Ada.Text_IO.File_Type;
>       Temp_Record : Employees.Employee;
>       Name_Length: Natural;
> 
>    begin -- Read_Employee_From_File
> 
>       -- open the file and associate it with the file variable name
>       Ada.Text_IO.Open (File => Import_File, Mode => Ada.Text_IO.In_File,
>                                    Name => "Datafile.txt");
> 
>       -- read each data item
> 
>       loop
>          exit when Ada.Text_IO.End_Of_File (Import_File);
> 
>          Ada.Integer_Text_IO.Get (File => Import_File, Item => Temp_Record.ID);

The above Get will leave the file read pointer at the point after the
last digit of the ID number, which is at the end-of-line marker for that
line.

>          Ada.Text_IO.Get_Line (File => Import_File, Item => Temp_Record.Name, Last => Name_Length);

The above Get_Line will then read the rest of the ID line, up to the
end-of-line marker, and the result is the empty string (unless there is
something after the ID and before the end of the line).

The file read point is left at the start of the "name" line.

>          GenderType_IO.Get (File => Import_File, Item => Temp_Record.Gender);

That tries to the string "test" as a GenderType, causing the failure.

So the problem is that after reading the ID you must move the read point
to the start of the "name" line. Add a Skip_Line between the Get(ID) and
the Get_Line(Name).

> PS: Will never again post a message from my smartphone. crap onscreen keyboard/tiny screen. Not made for browsing a forum.

Also try to configure your news-reader to break the lines in your
postings to some reasonable length, say 70 characters. Commenting is
difficult if you post messages with very long lines, at least in my
news-reader (Thunderbird).

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .

^ permalink raw reply	[relevance 0%]

* Re: Reading data from file
  @ 2014-03-04 21:27  3%   ` Laurent
  2014-03-04 21:42  0%     ` Niklas Holsti
    0 siblings, 2 replies; 195+ results
From: Laurent @ 2014-03-04 21:27 UTC (permalink / raw)


Hi

@Mike: Thanks for this detailed example. 

Unfortunately I seem to have mixed up a few things while writing my post. 

The text file contains just:
   
  1234
  test
  male ...

The ID: ,... was just supposed to inform you about the type. 

The exact error message is: 

raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tienio.adb:57 instantiated at employees-io.adb:17

which is:

    type GenderType is (Female, Male);     

     package GenderType_IO is
     new Ada.Text_IO.Enumeration_IO (Enum => GenderType);

Here is my code. It compiles but it isn't complete. Will probably fail for the moment if I try to read more than one record. (Won't read even one so...). Reading the name could be one reason for the problem with the enumeration. 

procedure Read_Employee_From_File (Item : out Employees.Employee) is

      Import_File : Ada.Text_IO.File_Type;
      Temp_Record : Employees.Employee;
      Name_Length: Natural;

   begin -- Read_Employee_From_File

      -- open the file and associate it with the file variable name
      Ada.Text_IO.Open (File => Import_File, Mode => Ada.Text_IO.In_File,
                                   Name => "Datafile.txt");

      -- read each data item

      loop
         exit when Ada.Text_IO.End_Of_File (Import_File);

         Ada.Integer_Text_IO.Get (File => Import_File, Item => Temp_Record.ID);
         Ada.Text_IO.Get_Line (File => Import_File, Item => Temp_Record.Name, Last => Name_Length);
         GenderType_IO.Get (File => Import_File, Item => Temp_Record.Gender);
         Ada.Integer_Text_IO.Get (File => Import_File, Item => Temp_Record.NumDepend);
         Currency.IO.Get (File => Import_File, Item => Temp_Record.Salary);
         Dates.IO.Get (File => Import_File, Item => Temp_Record.StartDate);

         Item := Temp_Record;

      end loop;


   end Read_Employee_From_File;

There is an other exercise in the book which uses this construction too and which works. Just reads a string and an int  until the end of the file. 

@Adam: I think I have to put a line to display what my construction is reading/and the content of Temp_Record just before the program terminates.


Other question: I have a working procedure to get the same information but from terminal which also checks if the data is correctly formatted. Is it possible to reroute the info from the file to this procedure? If yes how would I do that.

Because I (rather the author of the book) have this procedures which seem to do the same thing (or the other way around. Don't really understand why there are 2 procedures for the same thing).  Just that until now I didn't read anything from a file.


procedure Get (File : in Ada.Text_IO.File_Type; Item : out Quantity) is
      F : Float;
   begin -- get

      -- just read it as a float quantity, then convert
      Ada.Float_Text_IO.Get (File => File, Item => F);
      Item := MakeCurrency (F);

   end Get;

 procedure Get (Item : out Quantity) is
   begin -- get
      Get (File => Ada.Text_IO.Standard_Input, Item => Item);
   end Get;

Thanks

Laurent

PS: Will never again post a message from my smartphone. crap onscreen keyboard/tiny screen. Not made for browsing a forum.

^ permalink raw reply	[relevance 3%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-11  8:38  0%                 ` Simon Wright
@ 2013-12-11 17:07  0%                   ` Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2013-12-11 17:07 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:
>
>> $ ./s
>> testing \n
>>
>> raised ADA.IO_EXCEPTIONS.NAME_ERROR : s.dat: No such file or directory
>>
>> and indeed s.dat does not exist.
>
> Drat.
>
> I forgot to add that you need to do (the equivalent of) "touch s.dat"
> before running the program (I thought it was quite long enough already
> without adding the Create/Open dance).

And now I look in the Ada95 AARM there's nothing that says what happens
if the external file to be Create'd already exists. I must have been
thinking of the Open/Create dance, or even Open-To-Append/Create.

^ permalink raw reply	[relevance 0%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-11  1:01  6%               ` Jeffrey Carter
@ 2013-12-11  8:38  0%                 ` Simon Wright
  2013-12-11 17:07  0%                   ` Simon Wright
  0 siblings, 1 reply; 195+ results
From: Simon Wright @ 2013-12-11  8:38 UTC (permalink / raw)


Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:

> $ ./s
> testing \n
>
> raised ADA.IO_EXCEPTIONS.NAME_ERROR : s.dat: No such file or directory
>
> and indeed s.dat does not exist.

Drat.

I forgot to add that you need to do (the equivalent of) "touch s.dat"
before running the program (I thought it was quite long enough already
without adding the Create/Open dance).


^ permalink raw reply	[relevance 0%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-11  0:34  3%             ` Simon Wright
@ 2013-12-11  1:01  6%               ` Jeffrey Carter
  2013-12-11  8:38  0%                 ` Simon Wright
  0 siblings, 1 reply; 195+ results
From: Jeffrey Carter @ 2013-12-11  1:01 UTC (permalink / raw)


On 12/10/2013 05:34 PM, Simon Wright wrote:
>
> results in
>
> ------------------------------------------------------------------------
> testing \n
> EOL is TRUE
> EOF is TRUE
> testing \r\n
> EOL is FALSE
> EOF is FALSE
> testing \n42
> Value is  42
> testing \r\n42
>
> Execution terminated by unhandled exception
> Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR

On Linux (GNAT 4.6), it results in

$ ./s
testing \n

raised ADA.IO_EXCEPTIONS.NAME_ERROR : s.dat: No such file or directory

and indeed s.dat does not exist.

If I change the Open to Create in Write_As_Stream, I get

$ ./s
testing \n
EOL is TRUE
EOF is TRUE
testing \r\n
EOL is FALSE
EOF is FALSE
testing \n42
Value is  42
testing \r\n42

raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:66 instantiated at 
a-inteio.ads:18

-- 
Jeff Carter
"I've got to stay here, but there's no reason
why you folks shouldn't go out into the lobby
until this thing blows over."
Horse Feathers
50


^ permalink raw reply	[relevance 6%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  @ 2013-12-11  0:34  3%             ` Simon Wright
  2013-12-11  1:01  6%               ` Jeffrey Carter
  0 siblings, 1 reply; 195+ results
From: Simon Wright @ 2013-12-11  0:34 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Simon Wright" <simon@pushface.org> wrote in message 
> news:lywqjf45za.fsf@pushface.org...
> ...
>> I'm not sure of the best way to get an Ada program not to care what
>> sort of input line terminators it's reading.
>
> I'm surprised that that would be a problem, at least for Unix and
> Windows files. It's pretty simple to design Text_IO so that it can
> read either properly; that's how Text_IO in Janus/Ada works. (The only
> difference for it between Windows and Unix versions is the characters
> output by New_Line).

GNAT is certainly not as clever as that. On Mac OS X, this program

========================================================================
with Ada.Streams.Stream_IO;
with Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;

procedure S is

   Data_File_Name : constant String := "s.dat";
   Text_File : Ada.Text_IO.File_Type;

   procedure Write_As_Stream (Data : String) is
      package ASS renames Ada.Streams.Stream_IO;
      Stream_File : ASS.File_Type;
   begin
      ASS.Open (Stream_File,
                Name => Data_File_Name,
                Mode => ASS.Out_File);
      declare
         Stream_Access : constant ASS.Stream_Access
           := ASS.Stream (Stream_File); -- the file has to be open already
      begin
         String'Write (Stream_Access, Data);
      end;
      ASS.Close (Stream_File);
   end Write_As_Stream;

begin

   Put_Line ("testing \n");
   Write_As_Stream (String'(1 => ASCII.LF));
   Open (Text_File, Name => Data_File_Name, Mode => In_File);
   Put_Line ("EOL is " & Boolean'Image (End_Of_Line (Text_File)));
   Put_Line ("EOF is " & Boolean'Image (End_Of_File (Text_File)));
   Close (Text_File);

   Put_Line ("testing \r\n");
   Write_As_Stream (String'(1 => ASCII.CR, 2 => ASCII.LF));
   Open (Text_File, Name => Data_File_Name, Mode => In_File);
   Put_Line ("EOL is " & Boolean'Image (End_Of_Line (Text_File)));
   Put_Line ("EOF is " & Boolean'Image (End_Of_File (Text_File)));
   Close (Text_File);

   declare
      Dummy : Integer;
   begin
      Put_Line ("testing \n42");
      Write_As_Stream (String'(1 => ASCII.LF) & "42");
      Open (Text_File, Name => Data_File_Name, Mode => In_File);
      Ada.Integer_Text_IO.Get (Text_File, Dummy);
      Put_Line ("Value is " & Integer'Image (Dummy));
      Close (Text_File);
   end;

   declare
      Dummy : Integer;
   begin
      Put_Line ("testing \r\n42");
      Write_As_Stream (String'(1 => ASCII.CR, 2 => ASCII.LF) & "42");
      Open (Text_File, Name => Data_File_Name, Mode => In_File);
      Ada.Integer_Text_IO.Get (Text_File, Dummy);
      Put_Line ("Value is " & Integer'Image (Dummy));
      Close (Text_File);
   end;

end S;
========================================================================

results in

------------------------------------------------------------------------
testing \n
EOL is TRUE
EOF is TRUE
testing \r\n
EOL is FALSE
EOF is FALSE
testing \n42
Value is  42
testing \r\n42

Execution terminated by unhandled exception
Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR
------------------------------------------------------------------------

whereas on a Windows machine I get

------------------------------------------------------------------------
testing \n
EOL is TRUE
EOF is TRUE
testing \r\n
EOL is TRUE
EOF is TRUE
testing \n42
Value is  42
testing \r\n42
Value is  42
------------------------------------------------------------------------

so I feel a bug report coming on .. 

> But if you don't want to change the terminators (or your compiler has an 
> unnecessarily inflexible Text_IO), I'd suggest using Stream_IO. Of course, 
> then you'll have to do your own buffering of input (but that's usually a 
> good idea anyway).

Yes. Actually I tried Sequential_IO, but for just reading Characters
there's not a lot of difference ... is there?


^ permalink raw reply	[relevance 3%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-08 17:17  3%         ` Simon Wright
@ 2013-12-08 18:44  0%           ` Austin Obyrne
    1 sibling, 0 replies; 195+ results
From: Austin Obyrne @ 2013-12-08 18:44 UTC (permalink / raw)


On Sunday, December 8, 2013 5:17:45 PM UTC, Simon Wright wrote:
> Austin Obyrne <austin.obyrne@hotmail.com> writes: > Could I ask you to start again and download "SureCrypt Cipher" from > > http://www.adacryptpages.com Things are not as good as I'd hoped. The programs build OK (aside from a warning or two), but general_decryption_program_mark_1 fails immediately with Execution terminated by unhandled exception Exception name: STORAGE_ERROR Message: stack overflow at the start of the main program. This is usually a symptom of not having enough stack space, caused (in your case) by having lots of large arrays in the main program, not helped by initialising them - there was a recent thread[1] here about this. On the Mac there's a default stack limit of 8Mb; other OS's will have different limits, if limits at all. After poking at this for some time, there are two solutions: (a) move all the array declarations to a package of their own (for example, General_Decryption_Program_Mark_1_Arrays) and with/use it. The arrays are no longer on the stack (I'm not sure about the initializers). (b) increase the program's stack size. The help for gnatbind says I could add the switch -d16m for a 16 Mb stack, but this had no effect; instead, there's a Mac-specific way of doing this which I won't bore you with. Having got the program to start, I tried to decrypt the supplied CipherTextFile_1.dat and got Execution terminated by unhandled exception Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR and as far as I can tell this was caused by the Windows line terminator[2] in the data file; that's to say, when I removed the CR character from the Windows CR/LF the program decoded correctly. I'm not sure of the best way to get an Ada program not to care what sort of input line terminators it's reading. --S [1] https://groups.google.com/forum/?hl=en#!searchin/comp.lang.ada/large$20array%7Csort:date/comp.lang.ada/d-HSSQR9jHo/NjNp6cl6WaIJ [2] http://en.wikipedia.org/wiki/Newline

Hi Simon,

I think part of the trouble may be caused by one very large counting array that is not really necessary to the running of the program in the program as follows,

Could I ask you to comment out all of this counting function and try again.

GENERAL_DECRYPTION_PROGRAM_MARK_1.adb

This is the array in question – note I have commented it out later.

SUBTYPE Index_34 IS Integer RANGE -1000000 .. 1000000;
TYPE I_CoefficientsNumArray IS ARRAY(Index_34) OF Integer;
I_Num : I_CoefficientsNumArray:= (others =>0);
  -- counts the nominated coefficients of the ciphertext.
 
*Could I ask you to totally disable this counting function by commenting out these lines of source code as follows.
 
Line 32      --    Q    : Integer;

Lines 238, 239, 240. 241 

--  SUBTYPE Index_34 IS Integer RANGE -1000000 .. 1000000;
--  TYPE I_CoefficientsNumArray IS ARRAY(Index_34) OF Integer;
--  I_Num : I_CoefficientsNumArray:= (others =>0);
--  -- counts the nominated coefficients of the ciphertext.

Lines 881, 882,

--  Q:= W(1)REM 1000000;
--  I_Num(Q) := I_Num(Q)+1;

Pleases see next,

BATCH_ENCRYPTION_PROGRAM_MARK_1.adb

The corresponding lines to be commented out in the encryption program are,

Line 32: --    Q    : Integer;

Lines 251,252,253,254

--  SUBTYPE Index_36 IS Integer RANGE -1000000 .. 1000000;
--  TYPE I_CoefficientsNumArray IS ARRAY(Index_36) OF Integer;
--  I_Num : I_CoefficientsNumArray:= (others =>0);
--  -- counts the nominated coefficients of the ciphertext.

Lines 972,973

--  Q:= W(1)REM 1000000;
--  I_Num(Q) := I_Num(Q)+1;
 
Finally, 

EMAIL_ENCRYPTIONS_MARK_1.adb

The lines for commenting out here are,

Line 33: --    Q    : Integer;
253,254,255,256,

--  SUBTYPE Index_36 IS Integer RANGE -1000000 .. 1000000;
--  TYPE I_CoefficientsNumArray IS ARRAY(Index_36) OF Integer;
--  I_Num : I_CoefficientsNumArray:= (others =>0);
--  -- counts the nominated coefficients of the ciphertext.

Lines 940,941,

--  Q:= W(1)REM 1000000;
--  I_Num(Q) := I_Num(Q)+1;

• I have test run the programs after this commenting out exercise and they run ok.

Thanks for going to this extreme trouble.

I think the line problem requires an exception handler related to the GET function.(fools ruch in....)

Austin.


^ permalink raw reply	[relevance 0%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-07 18:26  0%       ` Austin Obyrne
@ 2013-12-08 17:17  3%         ` Simon Wright
  2013-12-08 18:44  0%           ` Austin Obyrne
    0 siblings, 2 replies; 195+ results
From: Simon Wright @ 2013-12-08 17:17 UTC (permalink / raw)


Austin Obyrne <austin.obyrne@hotmail.com> writes:

> Could I ask you to start again and download "SureCrypt Cipher" from 
>
> http://www.adacryptpages.com

Things are not as good as I'd hoped.

The programs build OK (aside from a warning or two), but
general_decryption_program_mark_1 fails immediately with

   Execution terminated by unhandled exception
   Exception name: STORAGE_ERROR
   Message: stack overflow

at the start of the main program. This is usually a symptom of not
having enough stack space, caused (in your case) by having lots of large
arrays in the main program, not helped by initialising them - there was
a recent thread[1] here about this.

On the Mac there's a default stack limit of 8Mb; other OS's will have
different limits, if limits at all.

After poking at this for some time, there are two solutions:

(a) move all the array declarations to a package of their own (for
example, General_Decryption_Program_Mark_1_Arrays) and with/use it. The
arrays are no longer on the stack (I'm not sure about the initializers).

(b) increase the program's stack size. The help for gnatbind says I
could add the switch -d16m for a 16 Mb stack, but this had no effect;
instead, there's a Mac-specific way of doing this which I won't bore you
with.


Having got the program to start, I tried to decrypt the supplied
CipherTextFile_1.dat and got

   Execution terminated by unhandled exception
   Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR

and as far as I can tell this was caused by the Windows line
terminator[2] in the data file; that's to say, when I removed the CR
character from the Windows CR/LF the program decoded correctly.

I'm not sure of the best way to get an Ada program not to care what sort
of input line terminators it's reading.

--S

[1]
https://groups.google.com/forum/?hl=en#!searchin/comp.lang.ada/large$20array%7Csort:date/comp.lang.ada/d-HSSQR9jHo/NjNp6cl6WaIJ
[2] http://en.wikipedia.org/wiki/Newline


^ permalink raw reply	[relevance 3%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-07 17:18  4%     ` Simon Wright
  2013-12-07 18:26  0%       ` Austin Obyrne
@ 2013-12-07 22:49  0%       ` Austin Obyrne
  1 sibling, 0 replies; 195+ results
From: Austin Obyrne @ 2013-12-07 22:49 UTC (permalink / raw)


On Saturday, December 7, 2013 5:18:06 PM UTC, Simon Wright wrote:
> Austin Obyrne <austin.obyrne@hotmail.com> writes:
> 
> 
> 
> > From what you have told me I think I should leave the dissemination of
> 
> > the finished ciphers (currently to hand in Ada-95 only but required in
> 
> > all the possible future versions of Ada) to experienced people who are
> 
> > au fait with all the nuances of compilers that are available to day.
> 
> 
> 
> The compilers I've tried with this are Ada2005 natively, and your
> 
> programs also work with the -gnat12 (Ada 2012) switch.
> 
> 
> 
> You might have tripped over new reserved words, but didn't, and since
> 
> you haven't used access or tagged types or tasking I think you'd be
> 
> pretty safe to upgrade your compiler.
> 
> 
> 
> A couple of points:
> 
> 
> 
> (a) when I encrypted
> 
> 
> 
> Now is the time for all good men
> 
> to come to the aid of the Party.
> 
> ~
> 
> 
> 
> it decrypted as
> 
> 
> 
> Now is the time for all good mento come to the aid of the Party.~
> 
> 
> 
> Is that meant to happen, or is there a problem with Windows line
> 
> terminators (CR/LF) vs Unix (LF)?
> 
> 
> 
> (b) when I decrypted Email_CipherTextFile_X.dat I got
> 
> 
> 
> Execution terminated by unhandled exception
> 
> Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR
> 
> 
> 
> and the exception was raised at line 683 of
> 
> general_decryption_program_mark_2.adb.

Hi Simon, 

"The compilers I've tried with this are Ada2005 natively, and your 
programs also work with the -gnat12 (Ada 2012) switch."

This answers the general question will the software run in Macos ?.

You have done me proud with your researches and I am hugely grateful.

Many thanks for everything.

Austin



^ permalink raw reply	[relevance 0%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  2013-12-07 17:18  4%     ` Simon Wright
@ 2013-12-07 18:26  0%       ` Austin Obyrne
  2013-12-08 17:17  3%         ` Simon Wright
  2013-12-07 22:49  0%       ` Austin Obyrne
  1 sibling, 1 reply; 195+ results
From: Austin Obyrne @ 2013-12-07 18:26 UTC (permalink / raw)


On Saturday, December 7, 2013 5:18:06 PM UTC, Simon Wright wrote:
> Austin Obyrne <austin.obyrne@hotmail.com> writes: > From what you have told me I think I should leave the dissemination of > the finished ciphers (currently to hand in Ada-95 only but required in > all the possible future versions of Ada) to experienced people who are > au fait with all the nuances of compilers that are available to day. The compilers I've tried with this are Ada2005 natively, and your programs also work with the -gnat12 (Ada 2012) switch. You might have tripped over new reserved words, but didn't, and since you haven't used access or tagged types or tasking I think you'd be pretty safe to upgrade your compiler. A couple of points: (a) when I encrypted Now is the time for all good men to come to the aid of the Party. ~ it decrypted as Now is the time for all good mento come to the aid of the Party.~ Is that meant to happen, or is there a problem with Windows line terminators (CR/LF) vs Unix (LF)? (b) when I decrypted Email_CipherTextFile_X.dat I got Execution terminated by unhandled exception Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR and the exception was raised at line 683 of general_decryption_program_mark_2.adb.    

Hi Simon,

The second line down below is line 683

FOR I IN 1 .. 3 LOOP
      *=> Ada.Integer_Text_IO.Get(File => InData, Item => W(I));
      --Ada.Integer_Text_IO.Put(Item => W(I), Width => 8);
END LOOP;
 This appears to be ok to me ?

You are working from a very old edition of this program

Could I ask you to start again and download "SureCrypt Cipher" from 

http://www.adacryptpages.com
 
Sorry for the inconvenience - you are going great guns - the line numbers are difficult for me to trace today in the older program - Note - There is only one of each program in this more recent download.

I think there is always going to be some small errors - ideally I should liaise very closely with anybody such as yourself in any exercises like this.

Can you please spell out exactly which program you are referring to also because I have sometimes renamed them differently over the years in different uploads.

Ada-wise all these programs are the same -just extra refinements have been added now and then.

Thanks for what you are doing.

Austin  



^ permalink raw reply	[relevance 0%]

* Re: Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking.
  @ 2013-12-07 17:18  4%     ` Simon Wright
  2013-12-07 18:26  0%       ` Austin Obyrne
  2013-12-07 22:49  0%       ` Austin Obyrne
  0 siblings, 2 replies; 195+ results
From: Simon Wright @ 2013-12-07 17:18 UTC (permalink / raw)


Austin Obyrne <austin.obyrne@hotmail.com> writes:

> From what you have told me I think I should leave the dissemination of
> the finished ciphers (currently to hand in Ada-95 only but required in
> all the possible future versions of Ada) to experienced people who are
> au fait with all the nuances of compilers that are available to day.

The compilers I've tried with this are Ada2005 natively, and your
programs also work with the -gnat12 (Ada 2012) switch.

You might have tripped over new reserved words, but didn't, and since
you haven't used access or tagged types or tasking I think you'd be
pretty safe to upgrade your compiler.

A couple of points:

(a) when I encrypted

Now is the time for all good men
to come to the aid of the Party.
~

it decrypted as

Now is the time for all good mento come to the aid of the Party.~

Is that meant to happen, or is there a problem with Windows line
terminators (CR/LF) vs Unix (LF)?

(b) when I decrypted Email_CipherTextFile_X.dat I got

Execution terminated by unhandled exception
Exception name: ADA.IO_EXCEPTIONS.DATA_ERROR

and the exception was raised at line 683 of
general_decryption_program_mark_2.adb.


^ permalink raw reply	[relevance 4%]

* Re: GCC 4.8.1 for Mac OS X
  @ 2013-07-17 21:00  3%   ` Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2013-07-17 21:00 UTC (permalink / raw)


Felix Krause <flyx@isobeef.org> writes:

> On 2013-07-07 18:37:02 +0000, Simon Wright said:
>
>> Tools included: ASIS, AUnit, GPRbuild, GNATColl, XMLAda from GNAT GPL
>> 2013.
>
> Just noticed that there is no gdb included. Would be great to have
> that. It does't seem to be possible to use the gdb from Apple, it
> doesn't recognize things like "break exception". I am rather unsure
> about how language support is compiled into gdb and how one would
> compile a gdb that supports Ada.

The system gdb is 6.3, and as you say doesn't understand Ada (BTW, the
current usage is 'catch exception', not 'break exception').

GDB 7.6 builds with the GCC 4.8.1 I uploaded, with very little
configuration needed (or possible):

   ../gdb-7.6/configure \
      --prefix=/opt/gcc-4.8.1 \
      --build=x86_64-apple-darwin12

but the resulting GDB isn't without its problems --

   * it needs to be code-signed (but you can run it as root)

   * it needs to be kicked to realise that it can catch Ada exceptions,
     just like in [1]

   * it gets confused about exceptions, but seems to stumble its way
     through eventually

   * it doesn't demangle Ada subprogram names properly

-- see [2].

I used to use the GDB that comes with GNAT GPL, but I see that the GPL
2013 version has exactly the same problems I noted above! Bug report
required, I think.

[1]
http://forward-in-code.blogspot.co.uk/2012/01/catching-exceptions-in-gdb.html

[2]
(gdb) catch exception name_error
Your Ada runtime appears to be missing some debugging information.
Cannot insert Ada exception catchpoint in this configuration.
(gdb) print __gnat_debug_raise_exception
$1 = {<text variable, no debug info>} 0x10017d4dd <__gnat_debug_raise_exception>
(gdb) catch exception name_error
warning: failed to reevaluate internal exception condition for catchpoint 0: A syntax error in expression, near `e) = long_integer (&name_error)'.
Catchpoint 1: `name_error' Ada exception
(gdb) run foo.uml
Starting program: /Users/simon/coldframe/tools/normalize_xmi foo.uml
warning: failed to reevaluate internal exception condition for catchpoint 1: A syntax error in expression, near `e) = long_integer (&name_error)'.
warning: failed to reevaluate internal exception condition for catchpoint 1: A syntax error in expression, near `e) = long_integer (&name_error)'.
processing foo.uml

Catchpoint 1, ADA.IO_EXCEPTIONS.NAME_ERROR at 0x000000010009b5f7 in _ada_normalize_xmi__main () at /Users/simon/coldframe/tools/normalize_xmi-main.adb:90
90	            Input_Sources.File.Open (Arg, File_Source);
(gdb) 


^ permalink raw reply	[relevance 3%]

* Re: When is a rename not a rename?
  @ 2013-02-01 11:27  6%   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2013-02-01 11:27 UTC (permalink / raw)


On Fri, 1 Feb 2013 02:44:21 -0800 (PST), Ada novice wrote:

> If you have a minimal example that is proving the contrary, please post it here.

Here is how renaming is not renaming:

with Ada.IO_Exceptions;
procedure Test is
   package P is
      End_Error : exception renames Ada.IO_Exceptions.End_Error;
   end P;
   use P, Ada.IO_Exceptions;
begin
   null;
exception
   when End_Error => -- Compile error, should be none
      null;
end Test;

This is "diamond diagram" constructed using renaming:

procedure Test is
   package P is
      I : Integer;
   end P;
   package Q is
      J : Integer renames P.I;
   end Q;
   package R is
      J : Integer renames P.I;
   end R;
   use Q, R;
   X : Integer := J; -- Compile error, should be none
begin
   null;
end Test;

[Diamond diagram is common-place bogus argument against MI]

Yet another example when rename is something totally broken:

with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
   X : Integer;
   Y : Positive renames X;
begin
   Y := -1;
   Put_Line ("And today positive number is " & Integer'Image (Y));
end Test;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Data_Error and Enumeration_IO
@ 2012-01-12 22:41  3% John McCormick
  0 siblings, 0 replies; 195+ results
From: John McCormick @ 2012-01-12 22:41 UTC (permalink / raw)


I need some assistance in understanding the consumption of input
characters when a Data_Error is raised during the input of an
enumeration value.  My experiments show that there is a different
behavior depending on whether the illegal input consists of alphabetic
characters or digits.

Here is a short example to illustrate my ingorance.  The following
code fragment reads in an enumeration value using a Data_Error
exception to catch invalid entries.


type    Choice_Type is (Encode, Decode);
package Choice_IO   is new Ada.Text_IO.Enumeration_IO (Enum =>
Choice_Type);

loop
   Ada.Text_IO.Put_Line ("Would you like to encode or decode a
message");
   begin
      Choice_IO.Get (Choice);
      exit; -- the data validation loop
   exception
      when Ada.IO_Exceptions.Data_Error =>
         Ada.Text_IO.Put_Line ("Invalid entry. Please enter Encode or
Decode.");
         Ada.Text_IO.Skip_Line;  -- Skip over the offending data
   end;
end loop;


This code is my usual pattern for data validation and works for
whatever invalid input I enter.

However, when my students leave out the call to Skip_Line in the
Data_Error exception handler the behavior depends on the actual value
entered.  It still works as desired when the input is alphabetic
characters such as “abc”.  But when the input consists of digits such
as “123” the loop becomes infinite, repeating the prompt and error
message.  It appears to me that the call to Choice_IO.Get consumes the
alphabetic input but does not consume the digit input leaving it
available for the next call to Get.  I could not find anything in the
language reference manual about how Enumeration_IO consumes input
characters when Data_Error is raised.  Can anyone give me an
explanation?  Is it implementation defined?  I am running GNAT GPL
2011.



^ permalink raw reply	[relevance 3%]

* Re: How does Ada.Text_IO.Enumeration_IO work?
  2011-11-03 14:52  0% ` Adam Beneschan
@ 2011-11-04 22:46  0%   ` Jerry
  0 siblings, 0 replies; 195+ results
From: Jerry @ 2011-11-04 22:46 UTC (permalink / raw)


On Nov 3, 7:52 am, Adam Beneschan <a...@irvine.com> wrote:
> On Nov 3, 1:52 am, Jerry <lancebo...@qwest.net> wrote:
>
>
>
>
>
> > I don't understand how the following program works, specifically, how
> > instances of Ada.Text_IO.Enumeration_IO read input. I understand that
> > it will skip leading white space, leave anything after finding a
> > proper element including line terminator, that apostophe ' is a valid
> > character, and that it can raise an exception (quoting ARM):
>
> > "The exception Data_Error is propagated if the sequence input does not
> > have the required syntax, or if the identifier or character literal
> > does not correspond to a value of the subtype Enum."
>
> > I want the program to read input until a valid element is found, then
> > quit.
>
> > with Ada.Text_IO; use Ada.Text_IO;
> > with Ada.IO_Exceptions; use Ada.IO_Exceptions;
> > procedure Day_Proc is
> >     type Day_Type is (Sunday, Monday, Tuesday);
> >     Day : Day_Type;
> >     package Day_Type_IO is new Ada.Text_IO.Enumeration_IO(Day_Type);
> >     Have_Good_Value : Boolean;
> > begin
> >     Put("Enter a day: ");
> >     loop
> >         Have_Good_Value := True;
> >         begin
> >             Day_Type_IO.Get(Day);
> >             --Skip_Line; -- Doesn't matter if present or not.
> >         exception
> >         when Ada.IO_Exceptions.Data_Error =>
> >             Have_Good_Value := False;
> >             Put_Line("Exception raised");
> >         end;
> >         Put_Line(Boolean'image(Have_Good_Value));
> >         exit when Have_Good_Value;
> >     end loop;
> >     Put_Line("Your day is " & Day_Type'image(Day));
> > end Day_Proc;
>
> > This works as I expect for inputs such as
>
> >    Monday
> > Monday Friday
> > Friday Monday
> > Fri7day Monday
> > Friday ' Monday
> > Monday.
> >  etc.
>
> > but anytime the input contains a non-apostrophe punctuation mark
> > before a valid element, or an otherwise inproperly syntaxed element,
> > it loops endlessly, outputting Exception raised and FALSE for each
> > passage through the loop. For instance, these lines cause infinite
> > looping:
>
> > Friday. Monday
> > Friday.Monday
> > Friday ? Monday
> > Fri?day Monday
> > Friday 7Thursday Monday
> > This is (or is not) a comment
> >  etc.
>
> > It is correctly raising the exception upon encountering the bad input,
> > but why does it keep looping and not proceed past the bad input to
> > find the following correct element?
>
> 'Cuz the rules say so.  A.10.6(5) is the important one here: "Next,
> characters are input only so long as the sequence input is an initial
> sequence of an identifier or of a character literal (in particular,
> input ceases when a line terminator is encountered). The character or
> line terminator that causes input to cease remains available for
> subsequent input."  A.10.6(10): "The exception Data_Error is
> propagated by a Get procedure if the sequence finally input is not a
> lexical element corresponding to the type, in particular if no
> characters were input ...".  That's the case when your input (skipping
> leading blanks) starts with an invalid character like a comma.  Since
> the comma can't be the first character of an enumeration literal, the
> comma "remains available for subsequent input", and thus "no
> characters are input" and Data_Error is raised.
>
> By the way, apostrophes are "allowed" but they have to be in the
> correct syntax.  So if your line begins with
>
> 'ABCDE'
>
> I believe the characters 'A will be input, but since 'AB cannot be the
> start of an enumeration literal, input stops at that point, and B will
> be the next character available for input.
>
>                          -- Adam

[Not sure why my earlier reply didn't make it but here is a
reconstruction of it.]

Thanks, Adam. I believe that the clue for me is that "remains
available for subsequent input" means that it is available only to non-
enumeration input, characters excepted.

Jerry



^ permalink raw reply	[relevance 0%]

* Re: How does Ada.Text_IO.Enumeration_IO work?
  2011-11-03  8:52  6% How does Ada.Text_IO.Enumeration_IO work? Jerry
@ 2011-11-03 14:52  0% ` Adam Beneschan
  2011-11-04 22:46  0%   ` Jerry
  0 siblings, 1 reply; 195+ results
From: Adam Beneschan @ 2011-11-03 14:52 UTC (permalink / raw)


On Nov 3, 1:52 am, Jerry <lancebo...@qwest.net> wrote:
> I don't understand how the following program works, specifically, how
> instances of Ada.Text_IO.Enumeration_IO read input. I understand that
> it will skip leading white space, leave anything after finding a
> proper element including line terminator, that apostophe ' is a valid
> character, and that it can raise an exception (quoting ARM):
>
> "The exception Data_Error is propagated if the sequence input does not
> have the required syntax, or if the identifier or character literal
> does not correspond to a value of the subtype Enum."
>
> I want the program to read input until a valid element is found, then
> quit.
>
> with Ada.Text_IO; use Ada.Text_IO;
> with Ada.IO_Exceptions; use Ada.IO_Exceptions;
> procedure Day_Proc is
>     type Day_Type is (Sunday, Monday, Tuesday);
>     Day : Day_Type;
>     package Day_Type_IO is new Ada.Text_IO.Enumeration_IO(Day_Type);
>     Have_Good_Value : Boolean;
> begin
>     Put("Enter a day: ");
>     loop
>         Have_Good_Value := True;
>         begin
>             Day_Type_IO.Get(Day);
>             --Skip_Line; -- Doesn't matter if present or not.
>         exception
>         when Ada.IO_Exceptions.Data_Error =>
>             Have_Good_Value := False;
>             Put_Line("Exception raised");
>         end;
>         Put_Line(Boolean'image(Have_Good_Value));
>         exit when Have_Good_Value;
>     end loop;
>     Put_Line("Your day is " & Day_Type'image(Day));
> end Day_Proc;
>
> This works as I expect for inputs such as
>
>    Monday
> Monday Friday
> Friday Monday
> Fri7day Monday
> Friday ' Monday
> Monday.
>  etc.
>
> but anytime the input contains a non-apostrophe punctuation mark
> before a valid element, or an otherwise inproperly syntaxed element,
> it loops endlessly, outputting Exception raised and FALSE for each
> passage through the loop. For instance, these lines cause infinite
> looping:
>
> Friday. Monday
> Friday.Monday
> Friday ? Monday
> Fri?day Monday
> Friday 7Thursday Monday
> This is (or is not) a comment
>  etc.
>
> It is correctly raising the exception upon encountering the bad input,
> but why does it keep looping and not proceed past the bad input to
> find the following correct element?

'Cuz the rules say so.  A.10.6(5) is the important one here: "Next,
characters are input only so long as the sequence input is an initial
sequence of an identifier or of a character literal (in particular,
input ceases when a line terminator is encountered). The character or
line terminator that causes input to cease remains available for
subsequent input."  A.10.6(10): "The exception Data_Error is
propagated by a Get procedure if the sequence finally input is not a
lexical element corresponding to the type, in particular if no
characters were input ...".  That's the case when your input (skipping
leading blanks) starts with an invalid character like a comma.  Since
the comma can't be the first character of an enumeration literal, the
comma "remains available for subsequent input", and thus "no
characters are input" and Data_Error is raised.

By the way, apostrophes are "allowed" but they have to be in the
correct syntax.  So if your line begins with

'ABCDE'

I believe the characters 'A will be input, but since 'AB cannot be the
start of an enumeration literal, input stops at that point, and B will
be the next character available for input.

                         -- Adam




^ permalink raw reply	[relevance 0%]

* How does Ada.Text_IO.Enumeration_IO work?
@ 2011-11-03  8:52  6% Jerry
  2011-11-03 14:52  0% ` Adam Beneschan
  0 siblings, 1 reply; 195+ results
From: Jerry @ 2011-11-03  8:52 UTC (permalink / raw)


I don't understand how the following program works, specifically, how
instances of Ada.Text_IO.Enumeration_IO read input. I understand that
it will skip leading white space, leave anything after finding a
proper element including line terminator, that apostophe ' is a valid
character, and that it can raise an exception (quoting ARM):

"The exception Data_Error is propagated if the sequence input does not
have the required syntax, or if the identifier or character literal
does not correspond to a value of the subtype Enum."

I want the program to read input until a valid element is found, then
quit.


with Ada.Text_IO; use Ada.Text_IO;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
procedure Day_Proc is
    type Day_Type is (Sunday, Monday, Tuesday);
    Day : Day_Type;
    package Day_Type_IO is new Ada.Text_IO.Enumeration_IO(Day_Type);
    Have_Good_Value : Boolean;
begin
    Put("Enter a day: ");
    loop
        Have_Good_Value := True;
        begin
            Day_Type_IO.Get(Day);
            --Skip_Line; -- Doesn't matter if present or not.
        exception
        when Ada.IO_Exceptions.Data_Error =>
            Have_Good_Value := False;
            Put_Line("Exception raised");
        end;
        Put_Line(Boolean'image(Have_Good_Value));
        exit when Have_Good_Value;
    end loop;
    Put_Line("Your day is " & Day_Type'image(Day));
end Day_Proc;


This works as I expect for inputs such as

   Monday
Monday Friday
Friday Monday
Fri7day Monday
Friday ' Monday
Monday.
 etc.

but anytime the input contains a non-apostrophe punctuation mark
before a valid element, or an otherwise inproperly syntaxed element,
it loops endlessly, outputting Exception raised and FALSE for each
passage through the loop. For instance, these lines cause infinite
looping:

Friday. Monday
Friday.Monday
Friday ? Monday
Fri?day Monday
Friday 7Thursday Monday
This is (or is not) a comment
 etc.

It is correctly raising the exception upon encountering the bad input,
but why does it keep looping and not proceed past the bad input to
find the following correct element?

Jerry



^ permalink raw reply	[relevance 6%]

* xmlada validate schema trickery
@ 2011-10-14 14:19  3% björn lundin
  0 siblings, 0 replies; 195+ results
From: björn lundin @ 2011-10-14 14:19 UTC (permalink / raw)


Hi!
I'm using xmlada to validate some xmlfiles, and it works well.


  function Validate(Xml, Xsd : in String) return Boolean is
    Explicit_XSD : Boolean := False;
    Read      : File_Input;
    Schema    : Schema_Reader;
    Grammar   : XML_Grammar := No_Grammar;
    My_Reader : Validating_Reader;
  begin
    if Xsd'length > 0 then
      if Ada.Directories.Exists(Xsd) then
        begin
          Open (Xsd, Read);
          Parse (Schema, Read);
          Close (Read);
          Explicit_XSD := True;
        exception
          when XML_Validation_Error =>
          Close (Read);
          raise;
        end;
      else
        Feedback("File '" & Xsd & "' does not exist");
        return False;
      end if;
    end if;

    if Ada.Directories.Exists(Xml) then
      if Explicit_XSD then
        Grammar  := Get_Created_Grammar(Schema);
        Global_Check (Grammar);
      end if;
    xmlns="http://www.consafelogistics.com/sattmate"
      Set_Validating_Grammar(My_Reader, Grammar);
      Set_Feature(My_Reader, Schema_Validation_Feature, True);
      Open(Xml, Read);
      Parse(My_Reader, Read);
      Close(Read);
      Feedback("File '" & Xml & "' is valid");
      return True;
    else
      Feedback("File '" & Xml & "' does not exist");
      return False;
    end if;
  exception
    when E : XML_Validation_Error | XML_Fatal_Error =>
        Feedback(Exception_Message (E));
        Close(Read);
        return False;
    when Ada.Io_Exceptions.Name_Error =>
        Feedback("File '" & Xml & "' is not a valid filename");
        return False;
  end Validate;
    ----------------------------------------

this is called by

      if Is_Set(Xsd) then
        if Validate(Xml => Parameter(1),
                    Xsd => Value(Xsd)) then
          Set_Exit_Status(Success);
        end if;
      else
        if Validate(Xml => Parameter(1),
                    Xsd => "") then
          Set_Exit_Status(Success);
        end if;
      end if;

where  Value(Xsd)) holds xsd filename and  Parameter(1) holds xml
filename

xml looks like
<?xml version="1.0" encoding="iso-8859-1"?>
<root_element xmlns="http://www.abc.com/some_namespace" >
  <Term Name="goal" Type="9" Size="9">
</root_element>

and xsd
<?xml version='1.0' encoding='iso-8859-15'?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
           xmlns='http://www.abc.com/some_namespace'
           targetNamespace='http://www.abc.com/some_namespace'
           elementFormDefault='qualified'
           attributeFormDefault='unqualified'>

  <xs:complexType name='goalType'>
    <xs:sequence>
      <xs:element name='goal' minOccurs='1' maxOccurs='1'/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name='MaAstro' type='xcl:goalType' />
</xs:schema>

This works well :-)

However, the xmlfiles are processed by some tcl-scripts as well,
and the (bad) tcldom(2.6) implementation (which I cannot upgrade)
crashes on the xmlns attribute
<root_element xmlns="http://www.abc.com/some_namespace" >


So I remove that so the xml looks like
<?xml version="1.0" encoding="iso-8859-1"?>
<root_element>
  <Term Name="goal" Type="9" Size="9">
</root_element>

but then I get an error:
 Element "goal": No matching declaration available


So, Im looking for a way to trick the parser to believe that
the  xmlns="http://www.abc.com/some_namespace" attribute is there,
thus keeping me, tcl, and xmlada happy

Any suggestions?

/Björn




^ permalink raw reply	[relevance 3%]

* Re: problems with interfacing c
  @ 2011-01-28  9:41  5%     ` Ludovic Brenta
  0 siblings, 0 replies; 195+ results
From: Ludovic Brenta @ 2011-01-28  9:41 UTC (permalink / raw)


Staszek Goldstein wrote on comp.lang.ada:
> I am sending a solution to a problem to a site managing programming contests, and
> the stdin is in fact redirected to some text file with data. I do not know how
> big the data file will be, I know only the upper limit. Quick reading of the data is the
> key to success, and the two lines of C work very well for the purpose. I have not
> tried your solution, is it not going to cause constraint_error when it meets the end of the
> file?

If you really read from Standard_Input, there is no upper limit to the
size of the file, so you should not depend on one. i.e. your program
should work if you say:

$ yes | my_program

The proper way to read a potentially infinite amount of data from
Standard_Input is to read one character at a time, buffer the input
for processing, and discard the buffer from time to time so your
program runs in constant memory. The points in time where you discard
the buffer depend on the algorithm.

Like Dmitry, I strongly suggest you use Ada.Streams, not Ada.Text_IO,
because the latter is much slower (it does a lot of unnecessary
bookkeeping behind the scenes).

Here is a small example where I process the input buffer whenever it
is full and then discard it. I also do that when I reach the end of
the input stream. Note that I have not compiled this example, so it
may contain (intentional :)) bugs.

with Ada.IO_Exceptions;
with Ada.Text_IO;
with Ada.Strings.Bounded;
procedure My_Program is
   Current_Input : constant Ada.Text_IO.Text_Streams.Stream_Access :=
     Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Current_Input);
   package Buffers is new Ada.Strings.Bounded.Generic_Bounded_Length
(Max => 100_000);

   procedure Process_And_Discard (Buffer : in out
Buffers.Bounded_String) is
   begin
      -- actual processing left as an exercise for the reader :)
      Buffers.Delete (Source => Buffer, From => 1, Through =>
Buffers.Max_Length);
   end Process_And_Discard;

   Buffer : Buffers.Bounded_String;
begin
   loop
      declare
          C : Character;
      begin
          Character'Read (Current_Input, C);
          if Buffers.Length (Buffer) = Buffers.Max_Length then --
buffer is full
             Process_And_Discard (Buffer);
          end if;
          Buffers.Append (Source => Buffer, New_Item => C);
      exception
          when Ada.IO_Exceptions.End_Error => -- end of stream reached
             Process_And_Discard (Buffer); -- process whatever we read
last
             exit;
      end;
   end loop;
end My_Program;

> The other question is - how to use the C bindings properly in such a case?

Don't.

--
Ludovic Brenta.



^ permalink raw reply	[relevance 5%]

* Re: An Example for Ada.Execution_Time
  2010-12-30 23:51  3%     ` BrianG
@ 2011-01-01  0:07  0%       ` Randy Brukardt
  0 siblings, 0 replies; 195+ results
From: Randy Brukardt @ 2011-01-01  0:07 UTC (permalink / raw)


"BrianG" <briang000@gmail.com> wrote in message 
news:ifj5u9$rr5$1@news.eternal-september.org...
> Randy Brukardt wrote:
>> "BrianG" <briang000@gmail.com> wrote in message 
>> news:ifbi5c$rqt$1@news.eternal-september.org...
>> ...
>>>    >Neither Execution_Time or Execution_Time.Timers provides any value
>>>    >that can be used directly.
>>
>> This seems like a totally silly question. Giving this some sort of 
>> religious importance is beyond silly...
>>
>>                                    Randy.
>
>
> Apparently, asking how a package, defined in the standard, was intended to 
> be used is now a silly question, and asking for an answer to the question 
> I originally asked (which was to clarify a previous response, not to 
> provide an example of use) is a religious debate.  I need to revise my 
> definitions.

But you didn't ask how a package defined in the standard was intended to be 
used. You asked why you have to use another package (Ada.Real_Time) in order 
for it to be useful. And you've repeated that over and over and over like it 
was meaningful in some way. But that is pretty much the definition of a 
silly question. It's just the way the package was defined, and it doesn't 
matter beyond having to add one additional "with" clause.

And that's pretty much irrelevant. In real Ada programs, there are many with 
clauses in the average compilation unit. In Janus/Ada, the number of withs 
averages 20 or so, and Claw programs are much higher than that. One could 
reduce those numbers by putting everything into a few massive packages, but 
those would be unweldy, poorly encapuslated, and close to unmaintainable.

The need to add one extra with to use a real-time package just falls into 
the noise. Probably it would have been better to offer the option of 
retrieving a value in terms of Duration, but it is just not a significant 
difference.

The answer to the "how do you use" question is simple and has been provided 
many times: use "-" to get a Time_Span, operate on that, and why that would 
be a problem to you or anyone else is beyond my comprehension.

> I won't claim to be an expert on the RM, but I don't recall any other 
> package (I did look at the ones you mention) that define a private type 
> but don't provide operations that make that type useful (for some 
> definition of 'use').  Ada.Directories doesn't require Ada.IO_Exceptions 
> to use Directory_Entry_Type or Search_Type; Ada.Streams.Stream_IO doesn't 
> require Ada.Streams (or Ada.Text_IO) to Create/Open/Read/etc. a File_Type. 
> The only thing provided from a CPU_Time is a count in seconds, or another 
> private type.

Here I completely disagree. If you plan to do anything *practical* with the 
Ada.Directories types, you'll have to use another package (at least 
Ada.Text_IO) to do something with the results. (Indeed, that is true of 
*all* Ada packages -- you have to do I/O somewhere or the results are 
irrelevant.  And you are wrong about Stream_IO.Read; you have to use a 
Stream_Element_Array in order to do that, and that is in Ada.Streams, not in 
Stream_IO.

In any case, I'm done wasting my time answering this question. It's obvious 
that you have lost you mind vis-a-vis this question, and there is no reason 
to waste any more time if/until you get it back. Do not feed the troll (even 
if the troll is someone that is otherwise reasonable).

                                                    Randy.





^ permalink raw reply	[relevance 0%]

* Re: An Example for Ada.Execution_Time
  2010-12-29  3:10  4%   ` Randy Brukardt
@ 2010-12-30 23:51  3%     ` BrianG
  2011-01-01  0:07  0%       ` Randy Brukardt
  0 siblings, 1 reply; 195+ results
From: BrianG @ 2010-12-30 23:51 UTC (permalink / raw)


Randy Brukardt wrote:
> "BrianG" <briang000@gmail.com> wrote in message 
> news:ifbi5c$rqt$1@news.eternal-september.org...
> ...
>>    >Neither Execution_Time or Execution_Time.Timers provides any value
>>    >that can be used directly.
> 
> This seems like a totally silly question. 
> 
> Giving this some sort of religious importance is beyond 
> silly...
> 
>                                    Randy.


Apparently, asking how a package, defined in the standard, was intended 
to be used is now a silly question, and asking for an answer to the 
question I originally asked (which was to clarify a previous response, 
not to provide an example of use) is a religious debate.  I need to 
revise my definitions.

I won't claim to be an expert on the RM, but I don't recall any other 
package (I did look at the ones you mention) that define a private type 
but don't provide operations that make that type useful (for some 
definition of 'use').  Ada.Directories doesn't require Ada.IO_Exceptions 
to use Directory_Entry_Type or Search_Type; Ada.Streams.Stream_IO 
doesn't require Ada.Streams (or Ada.Text_IO) to Create/Open/Read/etc. a 
File_Type.  The only thing provided from a CPU_Time is a count in 
seconds, or another private type.

Since D.16 defines CPU_Time as if it were a numeric value, is it too 
much to ask why a conversion to some form of numeric value wasn't 
provided?  Perhaps either a "-" or To_Duration  (and before anyone 
mentions duplicating the existing function, look at all of the 
Open/Close/Create/etc. for all the *_IO File_Types)?  I wasn't asking 
for anything to be changed, merely "why" - because I originally thought 
there might be some use that I hadn't foreseen.  Apparently not.

(Give the RM definition, making it a child of Real_Time might make it 
seem more logical, I guess, but since CPU_Time is not really a time, and 
is not related to "real time" that doesn't seem to make any sense.  I 
would think that would be all the more reason not to relate it to 
Ada.Real_Time.)

--BrianG

-- don't ask me
-- I'm just improvising
--   my illusion of careless flight
-- can't you see
--   my temperature's rising
-- I radiate more heat than light



^ permalink raw reply	[relevance 3%]

* Re: An Example for Ada.Execution_Time
  @ 2010-12-29  3:10  4%   ` Randy Brukardt
  2010-12-30 23:51  3%     ` BrianG
  0 siblings, 1 reply; 195+ results
From: Randy Brukardt @ 2010-12-29  3:10 UTC (permalink / raw)


"BrianG" <briang000@gmail.com> wrote in message 
news:ifbi5c$rqt$1@news.eternal-september.org...
...
> I asked for:
>    >> An algorithm comparison program might look like:
>    >>
>    >> with Ada.Execution_Time ;
>    >> with Ada.Execution_Time.Timers ;
>    >Given the below program, please add some of the missing details to
>    >show how this can be useful without also "with Ada.Real_Time".
>    >Neither Execution_Time or Execution_Time.Timers provides any value
>    >that can be used directly.

This seems like a totally silly question. There are a lot of well-designed 
packages in Ada that don't do anything useful without at least one or more 
other packages. Indeed, if you consider "Standard" to be a separate package 
(and it is), there are hardly any packages that *don't* require some other 
package to be useful.

More to the point, you probably need Ada.IO_Exceptions to use 
Ada.Directories effectively (use of any package without error handling is 
toy use); Ada.Streams.Stream_IO require use of Ada.Streams (a separate 
package, which you will need separate use clauses for even if you get it 
imported automatically); Ada.Strings.Maps aren't useful for anything unless 
you combine them with one of the string handling packages, and so on.

Perhaps you would have been happier if Ada.Execution_Time had been a child 
of Ada.Real_Time (exactly as in the string case), but this wouldn't change 
anything.

The odd thing is that Duration is defined in Standard, rather than some more 
appropriate package. Giving this some sort of religious importance is beyond 
silly...

                                   Randy.





^ permalink raw reply	[relevance 4%]

* Re: Binary opperations under Ada?
  @ 2010-08-28 20:14  6% ` Gerd
  0 siblings, 0 replies; 195+ results
From: Gerd @ 2010-08-28 20:14 UTC (permalink / raw)


On 21 Aug., 01:23, Trogdor <bga...@aol.com> wrote:
> Greetings!
>
> -) I want to read in a raw binary file and perform bit manipulation
> on the data.
>
> -) I vaguely remember seeing a post about a module package for low
> level stuff, cut han no longer find it in the group.
>
> -) All (four) of my Ada books were written in the '90's and don't
> help much with this subject.
>
> -) I am running GNAT under MinGW under WinXP 64.
>
> Could some kind soul please...
> - Let me know just what I am looking for.
> - Where do I get it?
> - Where do I read about it so I don't have to pester the group with
> dozens of questions?
>
> Thanks in Advance!
>
> --
> --------------------------------- --- -- -
> Posted with NewsLeecher v3.9 Final
> Web @http://www.newsleecher.com/?usenet
> ------------------- ----- ---- -- -


You can use the code below. I've found it on the net some years ago.

But - be aware, this is not the "Ada way", and - it's not portable,
it's pure Windows.


First the spec:
--------------------------------------------------------------------------
with Ada.IO_Exceptions;
with Win32.Winnt; use win32.Winnt;

package UnstructuredFile is
  --
------------------------------------------------------------------------------
--
  -- This package implements a file processing which is similar to
that of Modula-2 --
  -- It provides fast and easy access on unstructured files
(e.g. .exe)             --
 
--
--
  -- Maintenance level:
1.04A00                                         19.10.2004  --
  --
------------------------------------------------------------------------------
--

  type File_Type is limited private;

  procedure Open (f : in out File_Type; Name : STRING);
  --
------------------------------------------------------------------------------
--
  -- Opens the file "Name" for read access:  It fails if the file does
not exist.   --
  -- In this case the exeption Name_Error is raised. If the file is
already open    --
  -- the exception Status_Error is
raised.                                          --
  --
------------------------------------------------------------------------------
--

  procedure Create (f : in out File_Type; Name : STRING);
  --
------------------------------------------------------------------------------
--
  -- Creates a new file named "Name" and opens it for write access. If
a file with  --
  -- this name already exists it is overwritten. If the file is
already open the    --
  -- exception Status_Error is
raised.                                              --
  --
------------------------------------------------------------------------------
--

  procedure Append (f : in out File_Type; Name : STRING);
  --
------------------------------------------------------------------------------
--
  -- Opens the file "Name" for append. This means, it has write access
and it is    --
  -- positioned at the end, so that subsequent writes append data at
the end. If    --
  -- If the file is already open the exception Status_Error is
raised.              --
  --
------------------------------------------------------------------------------
--

  procedure Close (f : in out File_Type);
  --
------------------------------------------------------------------------------
--
  -- Closes the file represented by "f". Exception Status_Error is
raised if the    --
  -- file is not
open.                                                              --
  --
------------------------------------------------------------------------------
--

  procedure ReadNBytes (f : in out File_Type; Buffer : out STRING;
BytesRead : out INTEGER);
  --
------------------------------------------------------------------------------
--
  -- Reads as many bytes as will fit into buffer, execpt there are not
enough bytes --
  -- remaining in file "f". "BytesRead" returns the number of bytes
actually read.  --
  -- Exception Status_Error is raised if the file is not open,
exception Mode_Error --
  -- is raised if the file was "Created" for write
acccess.                         --
  --
------------------------------------------------------------------------------
--

  procedure WriteNBytes (f : in out File_Type; Buffer : STRING;
BytesWritten : out INTEGER);
  --
------------------------------------------------------------------------------
--
  -- Writes the bytes from "Buffer" to the file. "BytesWritten"
returns the number  --
  -- of bytes actually written (this should always be the number of
bytes of        --
  -- "Buffer" except in case of
errors).                                            --
  -- Exception Status_Error is raised if the file is not open,
exception Mode_Error --
  -- is raised if the file was "Opened" for read
acccess.                           --
  --
------------------------------------------------------------------------------
--

  function Is_Eof (f : File_Type) return boolean;
  --
------------------------------------------------------------------------------
--
  -- Returns TRUE if a file opened for read access was beyond the end
of file on    --
  -- the last read operation. The exception Status_Error is raised if
the file is   --
  -- not open, the exception Mode_Error is raised if the file was
"Created" for     --
  -- write
access.
--
  --
------------------------------------------------------------------------------
--

  procedure SetFilePos (f : File_Type; FilePos : INTEGER);
  --
------------------------------------------------------------------------------
--
  -- Sets the file position to "FilePos". "FilePos" specifies the
number of bytes   --
  -- relative to the begining of the file. The exception Status_Error
is raised if  --
  -- the file is not
open.                                                          --
  --
------------------------------------------------------------------------------
--

  function GetFilePos (f : File_Type) return INTEGER;
  --
------------------------------------------------------------------------------
--
  -- Gets the current position within the file. The returned value is
relative to   --
  -- the beginning of the file. The exception Status_Error is raised
if the file is --
  -- not
open.
--
  --
------------------------------------------------------------------------------
--

  function GetFileSize (f : File_Type) return INTEGER;
  --
------------------------------------------------------------------------------
--
  -- Returns the size of the file (up to
2GB).                                      --
  -- The exception Status_Error is raised if the file is not
open.                   --
  --
------------------------------------------------------------------------------
--

  Status_Error : exception renames Ada.IO_Exceptions.Status_Error;
  Mode_Error   : exception renames Ada.IO_Exceptions.Mode_Error;
  Name_Error   : exception renames Ada.IO_Exceptions.Name_Error;
  Use_Error    : exception renames Ada.IO_Exceptions.Use_Error;
  Device_Error : exception renames Ada.IO_Exceptions.Device_Error;
  End_Error    : exception renames Ada.IO_Exceptions.End_Error;
  Data_Error   : exception renames Ada.IO_Exceptions.Data_Error;
  Layout_Error : exception renames Ada.IO_Exceptions.Layout_Error;

private
  type Access_Mode is (Read_Only, Write_Only);

  type File_Type is record
                      Is_Open      : boolean := FALSE;
                      Current_Mode : Access_Mode;
                      Is_At_Eof    : boolean;
                      File_Handle  : HANDLE;
                    end record;
end UnstructuredFile;

--------------------------------------------------------------------------

Next the body:
--------------------------------------------------------------------------
-- with TEXT_IO;
with SYSTEM; use SYSTEM;
with UNCHECKED_CONVERSION;
with Win32; use Win32;
with Win32.Winerror; use Win32.Winerror;
--with Win32.Winnt; use win32.Winnt;
with Win32.Winbase; use Win32.Winbase;

package body UnstructuredFile is
  --
------------------------------------------------------------------------------
--
  -- This package implements a file processing which is similar to
that of Modula-2 --
  -- It provides fast and easy access on unstructured files
(e.g. .exe)             --
 
--
--
  -- Maintenance level:
1.04A00                                         19.10.2004  --
  --
------------------------------------------------------------------------------
--

  function LPVOID_from_ADDRESS  is new UNCHECKED_CONVERSION (ADDRESS,
LPCVOID);
  function LPCVOID_from_ADDRESS is new UNCHECKED_CONVERSION (ADDRESS,
LPCVOID);
  function LPDWORD_from_ADDRESS is new UNCHECKED_CONVERSION (ADDRESS,
LPDWORD);
  function LPCSTR_from_ADDRESS  is new UNCHECKED_CONVERSION (ADDRESS,
LPCSTR);
  function LPOVERLAPPED_from_INTEGER  is new UNCHECKED_CONVERSION
(INTEGER, LPOVERLAPPED);
  function To_Handle is new Unchecked_Conversion (Integer,
Win32.Winnt.HANDLE);

  use type Win32.DWORD;

  procedure Open (f : in out File_Type; Name : STRING) is
    F_Name : STRING := Name &  ASCII.NUL;
  begin
    if f.Is_Open
    then
      raise Status_Error;
    else
      f.FILE_HANDLE := CreateFile (LPCSTR_from_ADDRESS
(F_NAME'address),
                                   WinNT.GENERIC_READ,
                                   FILE_SHARE_READ, null,
                                   OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, TO_HANDLE (0));

      if f.FILE_HANDLE = INVALID_HANDLE_VALUE
      then
        if GETLASTERROR = ERROR_FILE_NOT_FOUND
        then
          raise Name_Error;
        else
          raise Device_Error;
        end if;
      else
        f.Is_Open := TRUE;
        f.Is_At_Eof := FALSE;
        f.Current_Mode := Read_Only;
      end if;
    end if;
  end Open;

  procedure Create (f : in out File_Type; Name : STRING) is
    F_Name : STRING := Name &  ASCII.NUL;
  begin
    if f.Is_Open
    then
      raise Status_Error;
    else
      f.FILE_HANDLE := CreateFile (LPCSTR_from_ADDRESS
(F_NAME'address),
                                   WinNT.GENERIC_WRITE,
                                   0, null,
                                   CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, TO_HANDLE (0));

      if f.FILE_HANDLE = INVALID_HANDLE_VALUE
      then
        if GETLASTERROR = ERROR_FILE_NOT_FOUND
        then
          raise Name_Error;
        else
          raise Device_Error;
        end if;
      else
        f.Is_Open := TRUE;
        f.Is_At_Eof := FALSE;
        f.Current_Mode := Write_Only;
      end if;
    end if;
  end Create;

  procedure Append (f : in out File_Type; Name : STRING) is
    F_Name : STRING := Name &  ASCII.NUL;
    NewPos : DWORD;
  begin
    if f.Is_Open
    then
      raise Status_Error;
    else
      f.FILE_HANDLE := CreateFile (LPCSTR_from_ADDRESS
(F_NAME'address),
                                   WinNT.GENERIC_WRITE,
                                   0, null,
                                   Open_ALWAYS, FILE_ATTRIBUTE_NORMAL,
TO_HANDLE (0));

      if f.FILE_HANDLE = INVALID_HANDLE_VALUE
      then
        if GETLASTERROR = ERROR_FILE_NOT_FOUND
        then
          raise Name_Error;
        else
          raise Device_Error;
        end if;
      else
        f.Is_Open := TRUE;
        f.Is_At_Eof := FALSE;
        f.Current_Mode := Write_Only;
      end if;
    end if;

    NewPos := SetFilePointer (f.FILE_HANDLE, LONG (0), null,
FILE_END);
  end Append;

  procedure Close (f : in out File_Type) is
    CloseResult : BOOL;
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    end if;

    CloseResult := CloseHandle (f.FILE_HANDLE);

    f.Is_Open := FALSE;
  end Close;

  procedure ReadNBytes (f : in out File_Type; Buffer : out STRING;
BytesRead : out INTEGER) is
    ReadResult   : BOOL;
    BytesToRead : DWORD;
    NumBytesRead : DWORD;
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    elsif f.Current_Mode = Write_Only
    then
      raise Mode_Error;
    elsif f.Is_At_Eof
    then
      raise End_Error;
    end if;

    BytesToRead := DWORD (Buffer'LAST - Buffer'First + 1);

    ReadResult := ReadFile (f.FILE_HANDLE, Buffer'ADDRESS,
                            BytesToRead, LPDWORD_from_ADDRESS
(NumBytesRead'ADDRESS),
                            LPOVERLAPPED_from_INTEGER (0));

    BytesRead := INTEGER (NumBytesRead);

    if ReadResult = Win32.FALSE
    then
      raise Device_Error;
    end if;

    f.Is_At_Eof := (ReadResult = Win32.TRUE) AND (BytesRead = 0);
  end ReadNBytes;

  procedure WriteNBytes (f : in out File_Type; Buffer : STRING;
BytesWritten : out INTEGER) is
    WriteResult : BOOL;
    BytesToWrite : DWORD;
    NumBytesWritten : DWORD;
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    elsif f.Current_Mode = Read_Only
    then
      raise Mode_Error;
    end if;

    BytesToWrite := DWORD (Buffer'LAST - Buffer'First + 1);

    WriteResult := WriteFile (f.FILE_HANDLE, Buffer'ADDRESS,
                              BytesToWrite, LPDWORD_from_ADDRESS
(NumBytesWritten'ADDRESS),
                              LPOVERLAPPED_from_INTEGER (0));

    BytesWritten := INTEGER
(NumBytesWritten);

    if WriteResult = Win32.FALSE
    then
      raise Device_Error;
    end if;
  end WriteNBytes;

  function Is_Eof (f : File_Type) return boolean is
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    elsif f.Current_Mode = Write_Only
    then
      raise Mode_Error;
    end if;

    return f.Is_At_Eof;
  end Is_Eof;

  procedure SetFilePos (f : File_Type; FilePos : INTEGER) is
    NewPos : DWORD;
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    end if;

    NewPos := SetFilePointer (f.FILE_HANDLE, LONG (FilePos), null,
FILE_BEGIN);
  end SetFilePos;

  function GetFilePos (f : File_Type) return INTEGER is
    NewPos : DWORD;
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    end if;

    NewPos := SetFilePointer (f.FILE_HANDLE, 0, null, FILE_CURRENT);

    return INTEGER (NewPos);
  end GetFilePos;

  function GetFileSize (f : File_Type) return INTEGER is
    SizeVal : DWORD;
  begin
    if not f.Is_Open
    then
      raise Status_Error;
    end if;

    SizeVal := GetFileSize (f.FILE_HANDLE, null);

    return INTEGER (SizeVal);
  end GetFileSize;

end UnstructuredFile;

--------------------------------------------------------------------------



^ permalink raw reply	[relevance 6%]

* Re: S-expression I/O in Ada
  2010-08-12  7:53  3%           ` Ludovic Brenta
@ 2010-08-12 20:22  0%             ` Ludovic Brenta
  0 siblings, 0 replies; 195+ results
From: Ludovic Brenta @ 2010-08-12 20:22 UTC (permalink / raw)


I wrote on comp.lang.ada:
> I made some fixes and I now consider my S-Expression parser[1] feature-
> complete as of revision b13ccabbaf227bad264bde323138910751aa2c2b.
> There may still be some bugs though, and the error reporting (to
> diagnose syntax errors in the input) is very primitive.
>
> Highlights:
> * the procedure S_Expression.Read is a quasi-recursive descent
> parser.  "Quasi" because it only recurses when encountering an opening
> parenthesis, but processes atoms without recursion, in the same finite
> state machine.
> * the parser reads each character exactly once; there is no push_back
> or backtracking involved.  This makes the parser suitable to process
> standard input on the fly.
> * to achive this, I had to resort to using exceptions instead of
> backtracking; this happens when the parser encounters a ')'
> immediately after an S-Expression (atom or list).
> * the parser also supports lists of the form (a b c) (more than 2
> elements) and properly translates them to (a (b c)).  The Append()
> procedure that does this is also public and available to clients.
> * the parser does not handle incomplete input well.  If it gets
> Ada.IO_Exceptions.End_Error in the middle of an S-Expression, it will
> return an incomplete, possibly empty, S-Expression rather than report
> the error.  I'll try to improve that.
> * the test.adb program demonstrates how to construct an S-Expression
> tree in memory (using cons()) and then sending it to a stream (using
> 'Write).
> * the test.adb program also demonstrates how to read an S-Expression
> from a stream (using 'Read) and then traverse the in-memory tree
> (using car(), cdr()).
>
> [1] http://green.ada-france.org:8081/branch/changes/org.ludovic-brenta.s_expressions
>
> I have not yet tested the parser on your proposed input (IIUC,
> consisting of two S-Expressions with a missing closing parenthesis).
> I think this will trigger the bug where End_Error in the middle of an
> S-Expression is not diagnosed.
>
> I also still need to add the proper GPLv3 license text on each file.
>
> I'll probably add support for Lisp-style comments (starting with ';'
> and ending at end of line) in the future.


As of revision b60f80fba074431aeeffd95aa273a1d4fc81bf41, I now handle
end-of-stream in all situations and (I believe) react appropriately.

I have now tested the parser against this sample input file:

$ cat test_input
(tcp-connect (host foo.bar) (port 80))

(tcp-connect ((host foo.bar) (port 80))
(tcp-connect (host foo.bar) (port 80)))

$ ./test < test_input
(tcp-connect ((host foo.example) (port 80)))
Parsing the S-Expression: (tcp-connect ((host foo.bar) (port 80)))
Writing the S-Expression: (tcp-connect ((host foo.bar) (port 80)))
Parsing the S-Expression: Exception name: TEST.SYNTAX_ERROR
Message: Expected atom with value 'host'

Writing the S-Expression: (tcp-connect ((((host foo.bar) (port 80)) (tcp-connect (host foo.bar))) (port 80)))

raised S_EXPRESSION.SYNTAX_ERROR : Found ')' at the start of an expression



The very first line of output is the result of 'Write of an S-Expression
constructed from a hardcoded TCP_Connect record.

"Parsing" refers to the high-level part of the parsing that traverses
the in-memory S-Expression tree and converts it to a TCP_Connect_T
record.

"Writing" refers to both halves of the low-level parsing: reading the
character stream, producing the in-memory S-Expression tree, and
converting it back to a character stream.

The TEST.SYNTAX_ERROR is because the high-level parser found a list
instead of the expected atom "host"; this is because of the extra '('
before "host" at line 3 in the input.

The S_EXPRESSION.SYNTAX_ERROR is because the low-level parser found an
extra ')' at the very end of line 4 in the input; it coalesced lines 3
and 4 into a single, valid, S-Expression, and was expecting a new
S-Expression starting with '('.

-- 
Ludovic Brenta.



^ permalink raw reply	[relevance 0%]

* Re: S-expression I/O in Ada
  @ 2010-08-12  7:53  3%           ` Ludovic Brenta
  2010-08-12 20:22  0%             ` Ludovic Brenta
  0 siblings, 1 reply; 195+ results
From: Ludovic Brenta @ 2010-08-12  7:53 UTC (permalink / raw)


Georg Bauhaus wrote:
> On 10.08.10 17:48, Ludovic Brenta wrote:
>
>> I've corrected that and rewritten test.adb to use your example:
>>
>> (tcp-connection ((host foo.bar) (port 80)))
>>
>> My parser needs still the above syntax and will not accept the
>> theoretically equivalent
>>
>> (tcp-connection (host foo.bar) (port 80))
>>
>> yet.
>
> How does it handle
> (tcp-connection ((host foo.bar) (port 80))
> (tcp-connection ((host abc.xyz) (port 80)))

I made some fixes and I now consider my S-Expression parser[1] feature-
complete as of revision b13ccabbaf227bad264bde323138910751aa2c2b.
There may still be some bugs though, and the error reporting (to
diagnose syntax errors in the input) is very primitive.

Highlights:
* the procedure S_Expression.Read is a quasi-recursive descent
parser.  "Quasi" because it only recurses when encountering an opening
parenthesis, but processes atoms without recursion, in the same finite
state machine.
* the parser reads each character exactly once; there is no push_back
or backtracking involved.  This makes the parser suitable to process
standard input on the fly.
* to achive this, I had to resort to using exceptions instead of
backtracking; this happens when the parser encounters a ')'
immediately after an S-Expression (atom or list).
* the parser also supports lists of the form (a b c) (more than 2
elements) and properly translates them to (a (b c)).  The Append()
procedure that does this is also public and available to clients.
* the parser does not handle incomplete input well.  If it gets
Ada.IO_Exceptions.End_Error in the middle of an S-Expression, it will
return an incomplete, possibly empty, S-Expression rather than report
the error.  I'll try to improve that.
* the test.adb program demonstrates how to construct an S-Expression
tree in memory (using cons()) and then sending it to a stream (using
'Write).
* the test.adb program also demonstrates how to read an S-Expression
from a stream (using 'Read) and then traverse the in-memory tree
(using car(), cdr()).

[1] http://green.ada-france.org:8081/branch/changes/org.ludovic-brenta.s_expressions

I have not yet tested the parser on your proposed input (IIUC,
consisting of two S-Expressions with a missing closing parenthesis).
I think this will trigger the bug where End_Error in the middle of an
S-Expression is not diagnosed.

I also still need to add the proper GPLv3 license text on each file.

I'll probably add support for Lisp-style comments (starting with ';'
and ending at end of line) in the future.

--
Ludovic Brenta.



^ permalink raw reply	[relevance 3%]

* Ada.Directories and network shares
@ 2010-07-17 10:43  4% Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2010-07-17 10:43 UTC (permalink / raw)


It seems that Ada.Directories is broken. Neither under Fedora or Debian the
following can walk a network share (cifs). The following does not work with
mounted shares:

with Ada.Directories;  use Ada.Directories;
with Ada.Text_IO;
 
procedure Test_Directory_Walk is
   procedure Walk (Name : String; Pattern : String) is
      procedure Print (Item : Directory_Entry_Type) is
      begin
         Ada.Text_IO.Put_Line (Full_Name (Item));
      end Print;
      procedure Walk (Item : Directory_Entry_Type) is
      begin
         if Simple_Name (Item) /= "." and then Simple_Name (Item) /= ".."
         then
            Walk (Full_Name (Item), Pattern);
         end if;
      exception
         when Name_Error => null;
      end Walk;
   begin
      Search (Name, Pattern, (others => True), Print'Access);
      Search (Name, "*", (Directory => True, others => False),
         Walk'Access);
   end Walk;
begin
   Walk (".", "*");
end Test_Directory_Walk;

When starting at the directory containing the mounting point, the result is
that the mounting point is not printed at all. When cd at the mounting
point and starting it there, then the result is:

raised ADA.IO_EXCEPTIONS.NAME_ERROR : unknown directory ""

P.S. GNAT GPL 2010 seem to work, but I have a suspicion that it has some
issues as well. I didn't figured yet when and which.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 4%]

* Re: Atomic file creation
  2010-01-04 14:24  6% ` vlc
@ 2010-01-05  4:16  0%   ` Stephen Leake
  0 siblings, 0 replies; 195+ results
From: Stephen Leake @ 2010-01-05  4:16 UTC (permalink / raw)


vlc <just.another.spam.account@googlemail.com> writes:

> I also tried something like this:
>
>  1  Ada.Text_IO.Create (Handle, Out_File);
>  2  declare
>  3     Temp_File : String := Ada.Text_IO.Name (Handle);
>  4  begin
>  5     Ada.Text_IO.Close (Handle);
>  6     Ada.Text_IO.Rename (Temp_File, "file");
>  7     Ada.Text_IO.Put_Line ("Success");
>  8  exception
>  9     when Ada.IO_Exceptions.Use_Error =>
> 10        Ada.Text_IO.Put_Line ("Failure");
> 11     when others =>
> 12        raise;
> 13  end;
>
> But Ada.Text_IO.Rename always raises Ada.IO_Exceptions.Use_Error, even
> if the file does not exist. 

Ada.Text_IO.Rename is not in the LRM. Ada.Directories.Rename is.

Some OS's don't allow renaming files across devices; if you are on
Unix, and Temp_File is /tmp/.., while "file" is /usr/..., and /tmp is
mounted to disk1, while /usr is mounted to disk2, that might explain
the use error.

In fact, the ALRM for Ada.Directories.Rename says:

67.a/2
          Implementation Note: This operation is expected to work
          within a a single directory, and implementers are encouraged
          to support it across directories on a single device. Copying
          files from one device to another is discouraged (that's what
          Copy_File is for). However, there is no requirement to detect
          file copying by the target system. If the target system has
          an API that gives that for "free", it can be used. For
          Windows®, for instance, MoveFile can be used to implement
          Rename.

> But if I replace line 1 with
>
>  1  Ada.Text_IO.Create (Handle, Out_File, "my_temp_file");
>
> it works. It seems that Ada.Text_IO.Rename cannot rename temporary
> files for whatever reason.
>
> Using Ada.Directories.Copy_File instead of Ada.Text_IO.Rename does not
> help as Ada.Directories.Copy_File overwrites files without raising an
> exception. Bad luck ...

It does seem you need to use an OS specific Form parameter to
Copy_File.

I think it's a bug that Rename raises Use_Error if Target_Name exists,
but Copy_File does not, since Copy_File is supposed to be used to
rename a file across devices.

-- 
-- Stephe



^ permalink raw reply	[relevance 0%]

* Re: Atomic file creation
  @ 2010-01-04 14:24  6% ` vlc
  2010-01-05  4:16  0%   ` Stephen Leake
  0 siblings, 1 reply; 195+ results
From: vlc @ 2010-01-04 14:24 UTC (permalink / raw)


I also tried something like this:

 1  Ada.Text_IO.Create (Handle, Out_File);
 2  declare
 3     Temp_File : String := Ada.Text_IO.Name (Handle);
 4  begin
 5     Ada.Text_IO.Close (Handle);
 6     Ada.Text_IO.Rename (Temp_File, "file");
 7     Ada.Text_IO.Put_Line ("Success");
 8  exception
 9     when Ada.IO_Exceptions.Use_Error =>
10        Ada.Text_IO.Put_Line ("Failure");
11     when others =>
12        raise;
13  end;

But Ada.Text_IO.Rename always raises Ada.IO_Exceptions.Use_Error, even
if the file does not exist. But if I replace line 1 with

 1  Ada.Text_IO.Create (Handle, Out_File, "my_temp_file");

it works. It seems that Ada.Text_IO.Rename cannot rename temporary
files for whatever reason.

Using Ada.Directories.Copy_File instead of Ada.Text_IO.Rename does not
help as Ada.Directories.Copy_File overwrites files without raising an
exception. Bad luck ...



^ permalink raw reply	[relevance 6%]

* Re: Ada Shootout program for K-Nucleotide (patches)
  2009-08-05 22:31  0%                         ` Georg Bauhaus
@ 2009-08-06  7:51  0%                           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2009-08-06  7:51 UTC (permalink / raw)


On Thu, 06 Aug 2009 00:31:00 +0200, Georg Bauhaus wrote:

> Ludovic Brenta wrote:
>> Georg Bauhaus wrote on comp.lang.ada:
>>> +    procedure Print (Item : String) is
>>> +       Data : char_array renames To_C (Item & ASCII.LF);
>>> +    begin
>>> +       if fputs (Data'Address, stdout) < 0 then
>>> +          raise Ada.IO_Exceptions.Device_Error;
>>> +       end if;
>>> +    end Print;
>> 
>> I'm curious to know how the following performs:
>>
>> Stdout : constant Ada.Text_IO.Text_Streams.Stream_Access :=
>>   Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output);
>> 
>> procedure Print (Item : String) is
>> begin
>>    String'Write (Stdout, Item);
>>    Character'Write (Stdout, ASCII.LF);
>> end Print;
> 
> Terribly slow.  Requesting only a tenth of the required amount
> (i.e. N = 2500000) has taken ~30s. By extrapolation the full
> set is produced only after ~5m. That's almost 20x slower
> than the original Ada.Text_IO.
> 
> (The RM explains that String'Write calls procedure
> Character'Write for each component of the String...)

Newer GNATs use blocks of 256 characters or so, I don't remember the
figure. But as Jeff has suggested, you could use raw stream Write from
Ada.Streams.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 0%]

* Re: Ada Shootout program for K-Nucleotide (patches)
  2009-08-05 22:04  0%                       ` Ludovic Brenta
@ 2009-08-05 22:31  0%                         ` Georg Bauhaus
  2009-08-06  7:51  0%                           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Georg Bauhaus @ 2009-08-05 22:31 UTC (permalink / raw)


Ludovic Brenta wrote:
> Georg Bauhaus wrote on comp.lang.ada:
>> +    procedure Print (Item : String) is
>> +       Data : char_array renames To_C (Item & ASCII.LF);
>> +    begin
>> +       if fputs (Data'Address, stdout) < 0 then
>> +          raise Ada.IO_Exceptions.Device_Error;
>> +       end if;
>> +    end Print;
> 
> I'm curious to know how the following performs:
>
> Stdout : constant Ada.Text_IO.Text_Streams.Stream_Access :=
>   Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output);
> 
> procedure Print (Item : String) is
> begin
>    String'Write (Stdout, Item);
>    Character'Write (Stdout, ASCII.LF);
> end Print;


Terribly slow.  Requesting only a tenth of the required amount
(i.e. N = 2500000) has taken ~30s. By extrapolation the full
set is produced only after ~5m. That's almost 20x slower
than the original Ada.Text_IO.

(The RM explains that String'Write calls procedure
Character'Write for each component of the String...)



^ permalink raw reply	[relevance 0%]

* Re: Ada Shootout program for K-Nucleotide (patches)
  2009-08-05 21:18 14%                     ` Georg Bauhaus
@ 2009-08-05 22:04  0%                       ` Ludovic Brenta
  2009-08-05 22:31  0%                         ` Georg Bauhaus
  0 siblings, 1 reply; 195+ results
From: Ludovic Brenta @ 2009-08-05 22:04 UTC (permalink / raw)


Georg Bauhaus wrote on comp.lang.ada:
> +    procedure Print (Item : String) is
> +       Data : char_array renames To_C (Item & ASCII.LF);
> +    begin
> +       if fputs (Data'Address, stdout) < 0 then
> +          raise Ada.IO_Exceptions.Device_Error;
> +       end if;
> +    end Print;

I'm curious to know how the following performs:

Stdout : constant Ada.Text_IO.Text_Streams.Stream_Access :=
  Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output);

procedure Print (Item : String) is
begin
   String'Write (Stdout, Item);
   Character'Write (Stdout, ASCII.LF);
end Print;

--
Ludovic Brenta.



^ permalink raw reply	[relevance 0%]

* Re: Ada Shootout program for K-Nucleotide (patches)
  @ 2009-08-05 21:18 14%                     ` Georg Bauhaus
  2009-08-05 22:04  0%                       ` Ludovic Brenta
  0 siblings, 1 reply; 195+ results
From: Georg Bauhaus @ 2009-08-05 21:18 UTC (permalink / raw)


Isaac Gouy wrote:
> On Aug 4, 10:08 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
> wrote:
>> Isaac Gouy schrieb:
>>
>>
>>
>>> On Aug 4, 8:43 am, Isaac Gouy <igo...@yahoo.com> wrote:
>>>> On Aug 3, 1:29 pm, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
>>>>> Isaac Gouy <igo...@yahoo.com> writes:
>>>>>> On Aug 3, 5:36 am, Jacob Sparre Andersen <spa...@nbi.dk> wrote:
>>>>>>> If we interpret this as the choice of the implementer, then there is
>>>>>>> no problem.  If the programs have to be able to read from stdin, then
>>>>>>> memory mapped files aren't of much use.
>>>>>> "read line-by-line a redirected FASTA format file from stdin"
>>>>>> http://shootout.alioth.debian.org/u32/benchmark.php?test=knucleotide&...
>>>>> What exactly does that mean?
>>>>> Would it be "cheating" to read all of stdin until reaching end-of-file,
>>>>> and then break the result up into lines (by whatever means)?
>>>> iirc the default buffer size for Java reader is 8192 bytes - use that.
>>> Better yet, the C++ programn seems to do just fine with this:
>>> char buffer[128];
>> But the more pressing question is, to me at least---others
>> will have better ideas---what functionality may we use for
>> reading, say, 128 char values?  Can we import OS functions?
>> Or the POSIX library? I have already install libflorist in
>> a new testing VM, in order to compare Text_IO agains POSIX
>> input.
> 
> 
> And was that an improvement?

Yes.

Using GNAT's binding to C streams improves running time
of fasta 25000000 from ~14s to ~10s on Ubuntu 9.04 64bit
running in VMware. ($ time ./fasta 25000000 > /dev/null)
The result is even more noticeable when either version's
output is redirected into a fresh (new) file on disk.
(~42s versus ~20s).
Using Florist should end up making similar calls,
so I expect similar improvements (TBD, soon).

The change is small (to fasta #1 as is):

1 - Add a small Print procedure that takes an Ada string,
copies it into a C string with \n and \0, and sends that
to fputs(3).

2 - Print then replaces every occurence of Text_IO.Put_Line

(I.e., even when building new strings from Ada strings for
the C functions the speedup seems quite noticeable.  There
are no occurrences of unchecked conversions or other high
speed techniques in the change (yet?).)

Might a change like this be acceptable?  (Obviously, fgets
could similarly be used when reading input in other programs.)

*** fasta.ada	old
--- fasta.ada	new
***************
*** 23 ****
! with Ada.Text_IO; use Ada.Text_IO;
--- 23,25 ----
! with Interfaces.C_Streams;  use Interfaces.C_Streams;
! with Interfaces.C;  use Interfaces.C;
! with Ada.IO_Exceptions;
***************
*** 74 ****
--- 77,84 ----
+    procedure Print (Item : String) is
+       Data : char_array renames To_C (Item & ASCII.LF);
+    begin
+       if fputs (Data'Address, stdout) < 0 then
+          raise Ada.IO_Exceptions.Device_Error;
+       end if;
+    end Print;
+
***************
*** 82 ****
!       Put_Line (">" & Id & ' ' & Desc);
--- 92 ----
!       Print (">" & Id & ' ' & Desc);
***************
*** 91 ****
!          Put_Line (Pick (1 .. M));
--- 101 ----
!          Print (Pick (1 .. M));
***************
*** 101 ****
!       Put_Line (">" & Id & ' ' & Desc);
--- 111 ----
!       Print (">" & Id & ' ' & Desc);
***************
*** 104 ****
!          Put_Line (S_App (K .. K + Integer'Min(Todo, Line_Length) - 1));
--- 114 ----
!          Print (S_App (K .. K + Integer'Min(Todo, Line_Length) - 1));



^ permalink raw reply	[relevance 14%]

* Re: Large files on 32 and 64 bits ystem
  2009-05-25 19:13  4% Large files on 32 and 64 bits ystem Olivier Scalbert
  2009-05-25 23:23  0% ` Ludovic Brenta
@ 2009-05-26  0:49  0% ` anon
  1 sibling, 0 replies; 195+ results
From: anon @ 2009-05-26  0:49 UTC (permalink / raw)


With GNAT:
 
Ada.Direct_IO uses a file indexes that has the type of Count or Positive_Count. 
And these types are based on the positive range which is define as the size of a 
long_Integer which is normally in a 32-bit machine set to positive value of 
( 2**63 - 1 ).
 
So it is possible from Ada, but the interface links between Ada and the OS 
may limit the size. Or in some cases it could be the OS or device-drivers 
that is limiting the file size.

But in looking at the routine System.FileIO.Write_Buf where the exception 
occurred and the Interfaces.C.Streams they both limit the file size to 
Standard'Address_Size or in the case of GNAT 32-bit version, to a positive 
range of 32-bit word aka (2GB -1). 

So, the answer is: On a 64-bit machine is limited to 2**64-1 file size 
                     and 
                     on a 32-bit machine is limited to 2**32-1 file size.
 

In <4a1aedda$0$2855$ba620e4c@news.skynet.be>, Olivier Scalbert <olivier.scalbert@algosyn.com> writes:
>Hello everybody,
>
>Here is my weekly question ....
>
>
>I need to create a file that has 2540160000 bytes, that is a little more 
>than 2**31 bytes.
>
>On a 64 bits linux box, it is ok, but on a 32 bits linux box, I have:
>raised ADA.IO_EXCEPTIONS.DEVICE_ERROR : s-fileio.adb:1135
>
>The file length is: 2147483647, which is 2**31 - 1
>
>Is it possible to write more than 2**31 bytes with an Ada program on a 
>32 bits linux ?
>
>Thanks for your help,
>
>Olivier.




^ permalink raw reply	[relevance 0%]

* Re: Large files on 32 and 64 bits ystem
  2009-05-25 19:13  4% Large files on 32 and 64 bits ystem Olivier Scalbert
@ 2009-05-25 23:23  0% ` Ludovic Brenta
  2009-05-26  0:49  0% ` anon
  1 sibling, 0 replies; 195+ results
From: Ludovic Brenta @ 2009-05-25 23:23 UTC (permalink / raw)


On May 25, 9:13 pm, Olivier Scalbert <olivier.scalb...@algosyn.com>
wrote:
> Hello everybody,
>
> Here is my weekly question ....
>
> I need to create a file that has 2540160000 bytes, that is a little more
> than 2**31 bytes.
>
> On a 64 bits linux box, it is ok, but on a 32 bits linux box, I have:
> raised ADA.IO_EXCEPTIONS.DEVICE_ERROR : s-fileio.adb:1135

That line indicates that the GNAT run-time library delegates the write
to fwrite(3), so your question really boils down to whether the C run-
time library has support for large files or not.  What filesystem type
do you use on your machines? (I use XFS which supports files up to 8
exabytes :) )

> The file length is: 2147483647, which is 2**31 - 1

This limitation exists on FAT16 ("msdos" in Linux parlance). Newer
filesystems have higher limits.

> Is it possible to write more than 2**31 bytes with an Ada program on a
> 32 bits linux ?

32-bit Linux has "large file support" using either a dedicated 64-bit
API or the O_LARGEFILE flag supported in open(2) since glibc 2.2. It
might be a good idea to check how GNAT's run-time library deals with
this API but I don't have the time right now. Anyone?

--
Ludovic Brenta.



^ permalink raw reply	[relevance 0%]

* Large files on 32 and 64 bits ystem
@ 2009-05-25 19:13  4% Olivier Scalbert
  2009-05-25 23:23  0% ` Ludovic Brenta
  2009-05-26  0:49  0% ` anon
  0 siblings, 2 replies; 195+ results
From: Olivier Scalbert @ 2009-05-25 19:13 UTC (permalink / raw)


Hello everybody,

Here is my weekly question ....


I need to create a file that has 2540160000 bytes, that is a little more 
than 2**31 bytes.

On a 64 bits linux box, it is ok, but on a 32 bits linux box, I have:
raised ADA.IO_EXCEPTIONS.DEVICE_ERROR : s-fileio.adb:1135

The file length is: 2147483647, which is 2**31 - 1

Is it possible to write more than 2**31 bytes with an Ada program on a 
32 bits linux ?

Thanks for your help,

Olivier.



^ permalink raw reply	[relevance 4%]

* GNAT Ada.Directories implementation and Windows file name
@ 2009-05-05 23:42  4% Hibou57 (Yannick Duchêne)
  0 siblings, 0 replies; 195+ results
From: Hibou57 (Yannick Duchêne) @ 2009-05-05 23:42 UTC (permalink / raw)


Hello,

It's a long time I did not get my eyes here :p (will be back soon for
some questions which raised into my mind a few days ago)

I've meet a trouble with an Ada 2005 application which traverse
directories using Ada.Directories.Search. Whenever a file or directory
name contains a character like “ É ” or “ À ”, which are valid within
Windows file name, the application ends with the message “ raised
ADA.IO_EXCEPTIONS.NAME_ERROR : invalid simple name ” follow by the
file name.

Do someone know about it ? Is it a GNAT Ada.Directories implementation
trouble ? Is it the same on Unix-like ? (I know some Unix-like allow
this kind of characters in filenames).

Have a nice time and read you soon.

Yannick



^ permalink raw reply	[relevance 4%]

* Re: GNAT GPL 2008 is out
  2008-06-12 23:43  0%     ` Anh Vo
@ 2008-06-13 11:39  0%       ` Anh Vo
  0 siblings, 0 replies; 195+ results
From: Anh Vo @ 2008-06-13 11:39 UTC (permalink / raw)


On Jun 12, 4:43 pm, Anh Vo <anhvofrc...@gmail.com> wrote:
> On Jun 12, 9:33 am, qunying <zhu.quny...@gmail.com> wrote:
>
> > On Jun 12, 7:31 am, Maxim Reznik <rezni...@gmail.com> wrote:
>
> > > It seems they have wrong file permission for Linux  PolyORB:
> > > I'm trying to download polyorb-gpl-2.4.0-1-src.tgz and get
>
> > > Exception name: ADA.IO_EXCEPTIONS.USE_ERROR
> > > Message: s-fileio.adb:988
> > > Call stack traceback locations:
> > > 0x82279ea 0x8202591 0x284feb1f 0x285da586 0x285da8cc 0x28517be0
> > > 0x284cedd4 0x284eb820 0x284ebf95 0x284ed584 0x2858c1dd 0x2858cbb8
> > > 0x81e7298 0x28924e53
>
> > I downloaded it without problem.
>
> I got the same error message when downloading PolyORB for x86-linux.
> Note that PolyORB for Windows had no problem. In addition, I reported
> this problem to AdaCore already.
>
> AV

This problem was fixed. Infact, it works fine now.



^ permalink raw reply	[relevance 0%]

* Re: GNAT GPL 2008 is out
  2008-06-12 16:33  0%   ` qunying
@ 2008-06-12 23:43  0%     ` Anh Vo
  2008-06-13 11:39  0%       ` Anh Vo
  0 siblings, 1 reply; 195+ results
From: Anh Vo @ 2008-06-12 23:43 UTC (permalink / raw)


On Jun 12, 9:33 am, qunying <zhu.quny...@gmail.com> wrote:
> On Jun 12, 7:31 am, Maxim Reznik <rezni...@gmail.com> wrote:
>
> > It seems they have wrong file permission for Linux  PolyORB:
> > I'm trying to download polyorb-gpl-2.4.0-1-src.tgz and get
>
> > Exception name: ADA.IO_EXCEPTIONS.USE_ERROR
> > Message: s-fileio.adb:988
> > Call stack traceback locations:
> > 0x82279ea 0x8202591 0x284feb1f 0x285da586 0x285da8cc 0x28517be0
> > 0x284cedd4 0x284eb820 0x284ebf95 0x284ed584 0x2858c1dd 0x2858cbb8
> > 0x81e7298 0x28924e53
>
> I downloaded it without problem.

I got the same error message when downloading PolyORB for x86-linux.
Note that PolyORB for Windows had no problem. In addition, I reported
this problem to AdaCore already.

AV




^ permalink raw reply	[relevance 0%]

* Re: GNAT GPL 2008 is out
  2008-06-12 14:31  5% ` Maxim Reznik
@ 2008-06-12 16:33  0%   ` qunying
  2008-06-12 23:43  0%     ` Anh Vo
  0 siblings, 1 reply; 195+ results
From: qunying @ 2008-06-12 16:33 UTC (permalink / raw)


On Jun 12, 7:31 am, Maxim Reznik <rezni...@gmail.com> wrote:

> It seems they have wrong file permission for Linux  PolyORB:
> I'm trying to download polyorb-gpl-2.4.0-1-src.tgz and get
>
> Exception name: ADA.IO_EXCEPTIONS.USE_ERROR
> Message: s-fileio.adb:988
> Call stack traceback locations:
> 0x82279ea 0x8202591 0x284feb1f 0x285da586 0x285da8cc 0x28517be0
> 0x284cedd4 0x284eb820 0x284ebf95 0x284ed584 0x2858c1dd 0x2858cbb8
> 0x81e7298 0x28924e53

I downloaded it without problem.



^ permalink raw reply	[relevance 0%]

* Re: GNAT GPL 2008 is out
  @ 2008-06-12 14:31  5% ` Maxim Reznik
  2008-06-12 16:33  0%   ` qunying
  0 siblings, 1 reply; 195+ results
From: Maxim Reznik @ 2008-06-12 14:31 UTC (permalink / raw)


On 11 июн, 21:21, qunying <zhu.quny...@gmail.com> wrote:
> Hi,
>
> Just got an email from Libre site, GNAT GPL 2008 is out.
>
> ^_^

It seems they have wrong file permission for Linux  PolyORB:
I'm trying to download polyorb-gpl-2.4.0-1-src.tgz and get

Exception name: ADA.IO_EXCEPTIONS.USE_ERROR
Message: s-fileio.adb:988
Call stack traceback locations:
0x82279ea 0x8202591 0x284feb1f 0x285da586 0x285da8cc 0x28517be0
0x284cedd4 0x284eb820 0x284ebf95 0x284ed584 0x2858c1dd 0x2858cbb8
0x81e7298 0x28924e53



^ permalink raw reply	[relevance 5%]

* Re: Shared library in Ada
  @ 2008-04-19 12:47  4%     ` Sebastien
  0 siblings, 0 replies; 195+ results
From: Sebastien @ 2008-04-19 12:47 UTC (permalink / raw)


> Yes I'm running Gnat on FreeBSD.
> Thanks about this link, I didn't know.

I follow the instruction and did the sample thing:

Lib:
::::::::::::::
lib/mylib.adb
::::::::::::::
with Ada.Text_IO; use Ada.Text_IO;

package body MyLib is
         procedure Print is
         begin
                 Put_Line("The lib");
         end Print;
end MyLib;
::::::::::::::
lib/mylib.ads
::::::::::::::
package MyLib is

         procedure Print;
         pragma Export (Convention => C, Entity => Print, External_Name 
=> "Print");
end MyLib;

::::::::::::::
main.adb
::::::::::::::
with MyLib; use MyLib;

procedure Main is
begin
         Print;
end Main;
::::::::::::::
mylib.ads
::::::::::::::
package MyLib is

         procedure Print;
         pragma Import (Convention => C, Entity => Print, External_Name 
=> "Print");
end MyLib;
::::::::::::::
main.gpr
::::::::::::::
Project Main is
         for Externally_Built use "true";
         for Source_Files use ("main.adb");
         pragma Linker_Options ("-lmylib");
end Main;

I compile the lib using:
gcc-4.1 -g3 -c mylib.adb
and link:
gcc-4.1 -shared -g3 -o ../libmylib.so mylib.o
I compile the main program using
gcc-4.1 -g3 -c mylib.ads
gcc-4.1 -g3 -c mylib.adb
and link:
gnatbind -x main.ali
gnatlink main.ali -lmylib

I got the following error:
# ./main

raised ADA.IO_EXCEPTIONS.STATUS_ERROR : s-fileio.adb:187

If I don't use shared object I got the program working, what am I missing?

Sebastien




^ permalink raw reply	[relevance 4%]

* Re: GNAT Project Manager and DLLs
  @ 2008-02-21 18:10  5%       ` marcelo.batera
  0 siblings, 0 replies; 195+ results
From: marcelo.batera @ 2008-02-21 18:10 UTC (permalink / raw)


I have another problem now.

When I unload the DLL created with the GPR file it fails miserably
later on when calling Ada.Text_IO.Put_Line( "some string" ), giving me
this exception:


raised ADA.IO_EXCEPTIONS.STATUS_ERROR : s-fileio.adb:187


It appears to me that, for some reason, when unloading the DLL it
messed up with GNAT runtime environment.


I tried for Library_Options use ("-single_module");  as well with no
success.



Any clue?



^ permalink raw reply	[relevance 5%]

* Re: STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
  @ 2007-04-02 14:11  4%   ` andrew.carroll
  0 siblings, 0 replies; 195+ results
From: andrew.carroll @ 2007-04-02 14:11 UTC (permalink / raw)


All the files are below.  The last file in the list, called
tables.txt, is the input file.  I've supplied the input file I am
using when I get the errors.





with Ada.Text_IO, Ada.Directories, GNAT.Calendar.Time_IO,
Ada.Characters.Latin_1, Ada.IO_Exceptions,
 Ada.Strings.Maps.Constants, Ada.Strings.Fixed,
Ada.Characters.Handling, Ada.Calendar,
 schema_types, attribute_types, parser, util, index_types;

use parser, GNAT.Calendar.Time_IO, Ada.Characters.Latin_1,
Ada.Strings.Maps.Constants, Ada.Strings.Fixed,
Ada.Characters.Handling, Ada.Calendar, schema_types, attribute_types,
util;

procedure dbprog is

    -- the input file contains the table specifications --
    input : Ada.Text_IO.File_Type;

    ------------------------------------
    --    Variables for Processing    --
    ------------------------------------
    char      : Character;
    line      : string_ptr;
    tablename : string_ptr;
    datacols  : string_array_ptr;
    pkcols    : string_array_ptr;
    schemas   : schema_array_ptr;
    sindex    : Integer := 1;
    tupls     : tuple_ptr;

    procedure showoptionsmenu is
    begin
        cls;
        pl ("---------------------------------------------------",
True);
        pl ("Type one of the following at the prompt:", True);
        pl (" ", True);
        pl ("~  QUIT ", True);
        pl ("1  INSERT DATA", True);
        pl ("2  UPDATE DATA", True);
        pl ("3  DELETE DATA", True);
        pl ("4  SHOW RECORDS", True);
        pl ("For help type 'help'", True);
        pl ("---------------------------------------------------",
True);
        pl (">>", False);

        while Ada.Text_IO.End_Of_Line loop
            Ada.Text_IO.Skip_Line;
        end loop;

        line := new String'(Ada.Text_IO.Get_Line);

    end showoptionsmenu;

    function markschema return Integer is
        idx : Integer := 0;
    begin
        --find the schema in schemas.
        if schemas'length <= 0 then
            return idx;
        end if;

        loop
            idx := idx + 1;
            exit when idx > schemas'length
                     or else Index (To_Upper (schemas
(idx).tablename), tablename.all) > 0;
        end loop;

        return idx;

    end markschema;

    procedure getcolumnnamesandvalues is
        year  : Year_Number;
        month : Month_Number;
        day   : Day_Number;
        line  : string_ptr := new String'("");
        valid : Boolean    := False;
    begin
        --markschema sets sindex to the appropriate index in schemas
        --for the table with tablename.
        sindex := markschema;

        --tables are already loaded and ready to go.
        datacols := new string_array (1 .. schemas
(sindex).attributes'length);

        for x in  1 .. schemas (sindex).attributes'length loop
            if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) = "DATE" then

                while not valid loop
                    pl
                       ("Enter a YEAR (1901 - 2099) for " &
                        Trim (schemas (sindex).attributes (x).name,
Ada.Strings.Both) &
                        "  >>",
                        False,
                        False);

                    while Ada.Text_IO.End_Of_Line loop
                        Ada.Text_IO.Skip_Line;
                    end loop;

                    line := new String'(Ada.Text_IO.Get_Line);

                    if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) > 0 then
                        pl ("!! INVALID !!", True, False);
                    elsif Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0
                       and then Integer'value (line.all) not  in
Ada.Calendar.Year_Number'range
                    then
                        pl ("!! INVALID !!", True, False);
                    else
                        valid := True;
                    end if;
                end loop;

                year  := Year_Number'value (line.all);
                valid := False;

                while not valid loop
                    pl
                       ("Enter a MONTH NUMBER for " &
                        Trim (schemas (sindex).attributes (x).name,
Ada.Strings.Both) &
                        "  >>",
                        False,
                        False);

                    while Ada.Text_IO.End_Of_Line loop
                        Ada.Text_IO.Skip_Line;
                    end loop;

                    line := new String'(Ada.Text_IO.Get_Line);

                    if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) > 0 then
                        pl ("!! INVALID !!", True, False);
                    elsif Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0
                       and then Integer'value (line.all) not  in
Ada.Calendar.Month_Number'range
                    then
                        pl ("!! INVALID !!", True, False);
                    else
                        valid := True;
                    end if;
                end loop;

                month := Month_Number'value (line.all);
                valid := False;

                while not valid loop
                    pl
                       ("Enter a DAY NUMBER for " &
                        Trim (schemas (sindex).attributes (x).name,
Ada.Strings.Both) &
                        "  >>",
                        False,
                        False);

                    while Ada.Text_IO.End_Of_Line loop
                        Ada.Text_IO.Skip_Line;
                    end loop;

                    line := new String'(Ada.Text_IO.Get_Line);

                    if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) > 0 then
                        pl ("!! INVALID !!", True, False);
                    elsif Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0
                       and then Integer'value (line.all) not  in
Ada.Calendar.Day_Number'range
                    then
                        pl ("!! INVALID !!", True, False);
                    else
                        valid := True;
                    end if;
                end loop;

                day              := Day_Number'value (line.all);
                datacols.all (x) := new String'(Image (Time_Of (year,
month, day), ISO_Date));
                valid            := False;
            else
                while not valid loop
                    pl
                       ("Enter a value for " &
                        Trim (schemas (sindex).attributes (x).name,
Ada.Strings.Both) &
                        "(" &
                        Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) &
                        ")  >>",
                        False,
                        False);

                    while Ada.Text_IO.End_Of_Line loop
                        Ada.Text_IO.Skip_Line;
                    end loop;

                    line := new String'(Ada.Text_IO.Get_Line);

                    if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                       "BOOLEAN"
                    then
                        if To_Upper (line.all) = "TRUE" then
                            line  := new String'("True");
                            valid := True;
                        elsif To_Upper (line.all) = "FALSE" then
                            line  := new String'("False");
                            valid := True;
                        elsif line.all = "1" then
                            line  := new String'("True");
                            valid := True;
                        elsif line.all = "0" then
                            line  := new String'("False");
                            valid := True;
                        else
                            pl ("!! INVALID !!", True, False);
                        end if;
                    elsif Trim (schemas (sindex).attributes
(x).domain, Ada.Strings.Both) =
                          "INTEGER"
                    then
                        if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0 then
                            valid := True;
                        else
                            pl ("!! INVALID !!", True, False);
                        end if;
                    else --"STRING"
                        valid := True;
                    end if;

                end loop;

                valid            := False;
                datacols.all (x) := new String'(line.all);
            end if;

        end loop;

    end getcolumnnamesandvalues;

    procedure getprimarykeynamesandvalues is
        year  : Year_Number;
        month : Month_Number;
        day   : Day_Number;
        line  : string_ptr := new String'("");
        valid : Boolean    := False;
    begin
        --markschema sets sindex to the appropriate index in schemas
        --for the table with tablename.
        sindex := markschema;

        pl ("Provide the primary key values to identify the record to
delete.", False, True);
        pl ("Press Enter to continue...", True, True);
        Ada.Text_IO.Get_Immediate (char);

        --tables are already loaded and ready to go.
        pkcols := new string_array (1 .. schemas
(sindex).primary_key_count);

        for x in  1 .. schemas (sindex).attributes'length loop
            if schemas (sindex).attributes (x).isprimarykey then
                if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) = "DATE" then

                    while not valid loop
                        pl
                           ("Enter a YEAR (1901 - 2099) for " &
                            Trim (schemas (sindex).attributes
(x).name, Ada.Strings.Both) &
                            "  >>",
                            False,
                            False);

                        while Ada.Text_IO.End_Of_Line loop
                            Ada.Text_IO.Skip_Line;
                        end loop;

                        line := new String'(Ada.Text_IO.Get_Line);

                        if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) > 0 then
                            pl ("!! INVALID !!", True, False);
                        elsif Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0
                           and then Integer'value (line.all) not  in
Ada.Calendar.Year_Number'range
                        then
                            pl ("!! INVALID !!", True, False);
                        else
                            valid := True;
                        end if;
                    end loop;

                    year  := Year_Number'value (line.all);
                    valid := False;

                    while not valid loop
                        pl
                           ("Enter a MONTH NUMBER for " &
                            Trim (schemas (sindex).attributes
(x).name, Ada.Strings.Both) &
                            "  >>",
                            False,
                            False);

                        while Ada.Text_IO.End_Of_Line loop
                            Ada.Text_IO.Skip_Line;
                        end loop;

                        line := new String'(Ada.Text_IO.Get_Line);

                        if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) > 0 then
                            pl ("!! INVALID !!", True, False);
                        elsif Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0
                           and then Integer'value (line.all) not  in
Ada.Calendar.Month_Number'
                             range
                        then
                            pl ("!! INVALID !!", True, False);
                        else
                            valid := True;
                        end if;
                    end loop;

                    month := Month_Number'value (line.all);
                    valid := False;

                    while not valid loop
                        pl
                           ("Enter a DAY NUMBER for " &
                            Trim (schemas (sindex).attributes
(x).name, Ada.Strings.Both) &
                            "  >>",
                            False,
                            False);

                        while Ada.Text_IO.End_Of_Line loop
                            Ada.Text_IO.Skip_Line;
                        end loop;

                        line := new String'(Ada.Text_IO.Get_Line);

                        if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) > 0 then
                            pl ("!! INVALID !!", True, False);
                        elsif Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <= 0
                           and then Integer'value (line.all) not  in
Ada.Calendar.Day_Number'range
                        then
                            pl ("!! INVALID !!", True, False);
                        else
                            valid := True;
                        end if;
                    end loop;

                    day            := Day_Number'value (line.all);
                    pkcols.all (x) := new String'(Image (Time_Of
(year, month, day), ISO_Date));
                    valid          := False;
                else
                    while not valid loop
                        pl
                           ("Enter a value for " &
                            Trim (schemas (sindex).attributes
(x).name, Ada.Strings.Both) &
                            "(" &
                            Trim (schemas (sindex).attributes
(x).domain, Ada.Strings.Both) &
                            ")  >>",
                            False,
                            False);

                        while Ada.Text_IO.End_Of_Line loop
                            Ada.Text_IO.Skip_Line;
                        end loop;

                        line := new String'(Ada.Text_IO.Get_Line);

                        if Trim (schemas (sindex).attributes
(x).domain, Ada.Strings.Both) =
                           "BOOLEAN"
                        then
                            if To_Upper (line.all) = "TRUE" then
                                line  := new String'("True");
                                valid := True;
                            elsif To_Upper (line.all) = "FALSE" then
                                line  := new String'("False");
                                valid := True;
                            elsif line.all = "1" then
                                line  := new String'("True");
                                valid := True;
                            elsif line.all = "0" then
                                line  := new String'("False");
                                valid := True;
                            else
                                pl ("!! INVALID !!", True, False);
                            end if;
                        elsif Trim (schemas (sindex).attributes
(x).domain, Ada.Strings.Both) =
                              "INTEGER"
                        then
                            if Index (line.all, Decimal_Digit_Set,
Ada.Strings.Outside) <=
                               0
                            then
                                valid := True;
                            else
                                pl ("!! INVALID !!", True, False);
                            end if;
                        else --"STRING"
                            valid := True;
                        end if;

                    end loop;

                    valid          := False;
                    pkcols.all (x) := new String'(line.all);
                end if;
            end if;

        end loop;
    end getprimarykeynamesandvalues;

    procedure gettablename is
        count : Integer := 1;
    begin
        pl ("Enter the table name in CAPITAL letters >>", False);
        tablename     := new String'(Ada.Text_IO.Get_Line);
        tablename.all := To_Upper (tablename.all);

        while not Ada.Directories.Exists (tablename.all) and count < 5
loop
            pl ("Enter the table name in CAPITAL letters >>", False);
            tablename     := new String'(Ada.Text_IO.Get_Line);
            tablename.all := To_Upper (tablename.all);
            count         := count + 1;
        end loop;

        if count >= 5 then
            raise Constraint_Error;
        end if;

    end gettablename;

    procedure getchosenoptiondata is
    begin
        gettablename;

        --we don't do "4" here because it is just a select and we
don't
        --need values for it and we already have the attribute names
in
        --the schemas(sindex) object for which to SELECT or SHOW the
        --data.
        if line.all = "1" then
            getcolumnnamesandvalues;
        elsif line.all = "2" then
            getprimarykeynamesandvalues;
            pl (" ", True, True);
            pl ("Please enter new values for each item.  You can enter
the same ", True, True);
            pl ("data if you don't want it modified.", True, True);
            pl (" ", True, True);
            getcolumnnamesandvalues;
        elsif line.all = "3" then
            getprimarykeynamesandvalues;

        end if;

    end getchosenoptiondata;

    procedure parsechosenoption is
        pkattribs  : attribute_array_ptr;
        newvalues  : attribute_array_ptr;
        linelength : Integer;
        outline    : string_ptr;
    begin
        if line.all = "1" then

            -------------------
            --  INSERT DATA  --
            -------------------
            newvalues := new attribute_array (1 .. schemas
(sindex).attributes'length);

            --fill in the values on the objects and pass that to
insert.
            for x in  1 .. newvalues'length loop
                if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                   "BOOLEAN"
                then
                    newvalues (x) :=
                     new booleanattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Boolean'value (datacols
(x).all));
                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "STRING"
                then
                    newvalues (x) :=
                     new stringattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => max_stringlength * ' ');

                    Replace_Slice
                       (stringattribute (newvalues (x).all).value,
                        1,
                        max_stringlength,
                        datacols (x).all);

                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "INTEGER"
                then
                    newvalues (x) :=
                     new integerattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Integer'value (datacols
(x).all));

                else -- "DATE"
                    newvalues (x) :=
                     new dateattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Value (datacols (x).all),
                        year         => Year (Value (datacols
(x).all)),
                        month        => Month (Value (datacols
(x).all)),
                        day          => Day (Value (datacols
(x).all)));
                end if;
            end loop;

            insertrec (schemas (sindex).all, newvalues.all);

        elsif line.all = "2" then

            -------------------
            --  UPDATE DATA  --
            -------------------
            pkattribs := new attribute_array (1 .. pkcols'length);

            --fill in the values on the objects and pass that to
insert.
            for x in  1 .. pkcols'length loop
                if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                   "BOOLEAN"
                then
                    pkattribs (x) :=
                     new booleanattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Boolean'value (pkcols
(x).all));
                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "STRING"
                then

                    pkattribs (x) :=
                     new stringattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => max_stringlength * ' ');

                    Replace_Slice
                       (stringattribute (pkattribs (x).all).value,
                        1,
                        max_stringlength,
                        pkcols (x).all);

                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "INTEGER"
                then
                    pkattribs (x) :=
                     new integerattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Integer'value (pkcols
(x).all));

                else -- "DATE"
                    pkattribs (x) :=
                     new dateattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Value (pkcols (x).all),
                        year         => Year (Value (pkcols (x).all)),
                        month        => Month (Value (pkcols
(x).all)),
                        day          => Day (Value (pkcols (x).all)));
                end if;
            end loop;

            newvalues := new attribute_array (1 .. schemas
(sindex).attributes'length);

            --fill in the values on the objects and pass that to
insert.
            for x in  1 .. newvalues'length loop
                if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                   "BOOLEAN"
                then
                    newvalues (x) :=
                     new booleanattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Boolean'value (datacols
(x).all));
                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "STRING"
                then
                    newvalues (x) :=
                     new stringattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => max_stringlength * ' ');

                    Replace_Slice
                       (stringattribute (newvalues (x).all).value,
                        1,
                        max_stringlength,
                        datacols (x).all);

                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "INTEGER"
                then
                    newvalues (x) :=
                     new integerattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Integer'value (datacols
(x).all));

                else -- "DATE"
                    newvalues (x) :=
                     new dateattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Value (datacols (x).all),
                        year         => Year (Value (datacols
(x).all)),
                        month        => Month (Value (datacols
(x).all)),
                        day          => Day (Value (datacols
(x).all)));
                end if;
            end loop;

            updaterec (schemas (sindex).all, pkattribs.all,
newvalues.all);

        elsif line.all = "3" then

            -------------------
            --  DELETE DATA  --
            -------------------
            Ada.Text_IO.Put_Line (Integer'image (sindex));
            Ada.Text_IO.Put_Line (tablename.all);

            pkattribs := new attribute_array (1 .. pkcols'length);

            --fill in the values on the objects and pass that to
delete.
            for x in  1 .. pkcols'length loop
                if Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                   "BOOLEAN"
                then
                    pkattribs (x) :=
                     new booleanattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Boolean'value (pkcols
(x).all));
                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "STRING"
                then

                    pkattribs (x) :=
                     new stringattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => max_stringlength * ' ');

                    Replace_Slice
                       (stringattribute (pkattribs (x).all).value,
                        1,
                        max_stringlength,
                        pkcols (x).all);

                elsif Trim (schemas (sindex).attributes (x).domain,
Ada.Strings.Both) =
                      "INTEGER"
                then
                    pkattribs (x) :=
                     new integerattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Integer'value (pkcols
(x).all));

                else -- "DATE"
                    pkattribs (x) :=
                     new dateattribute'
                       (name         => schemas (sindex).attributes
(x).name,
                        domain       => schemas (sindex).attributes
(x).domain,
                        isprimarykey => schemas (sindex).attributes
(x).isprimarykey,
                        byte_start   => 0,
                        byte_end     => 0,
                        value        => Value (pkcols (x).all),
                        year         => Year (Value (pkcols (x).all)),
                        month        => Month (Value (pkcols
(x).all)),
                        day          => Day (Value (pkcols (x).all)));
                end if;
            end loop;

            deleterec (schemas (sindex).all, pkattribs.all);

        elsif line.all = "4" then

            ----------------------
            --  SELECT RECORDS  --
            ----------------------
            linelength := 60;
            sindex     := markschema;
            outline    := new String'(1 .. linelength => '-');
            pl (outline.all, True, False);
            pl (schemas (sindex).tablename, True, False);
            pl (outline.all, True, False);
            pl ("| ", False, False);
            for x in  1 .. schemas (sindex).attributes'length loop
                pl (Trim (schemas (sindex).attributes (x).name,
Ada.Strings.Both), False, False);

                if x < schemas (sindex).attributes'length then
                    pl (" | ", False, False);
                end if;

            end loop;
            pl (" |", True, False);
            pl (outline.all, True, False);

            tupls := selectrec (schemas (sindex).all);

            if tupls = null then
                pl ("No Data", True, False);
            else
                for y in  1 .. tupls'length loop
                    newvalues := tupls (y);

                    for x in  1 .. newvalues'length loop
                        if Trim (newvalues (x).domain,
Ada.Strings.Both) = "BOOLEAN" then
                            pl
                               (Trim
                                    (Boolean'image (booleanattribute
(newvalues (x).all).value),
                                     Ada.Strings.Both),
                                False,
                                False);
                        elsif Trim (newvalues (x).domain,
Ada.Strings.Both) = "STRING" then
                            pl
                               (Trim
                                    (stringattribute (newvalues
(x).all).value,
                                     Ada.Strings.Both),
                                False,
                                False);
                        elsif Trim (newvalues (x).domain,
Ada.Strings.Both) = "INTEGER" then
                            pl
                               (Trim
                                    (Integer'image (integerattribute
(newvalues (x).all).value),
                                     Ada.Strings.Both),
                                False,
                                False);
                        else -- "DATE"
                            pl
                               (Trim
                                    (Image (dateattribute (newvalues
(x).all).value, ISO_Date),
                                     Ada.Strings.Both),
                                False,
                                False);
                        end if;

                        if x < newvalues'length then
                            pl ("   ", False, False);
                        end if;

                    end loop;
                    pl (" ", True, False);
                end loop;
            end if;

            pl (outline.all, True, False);
            pl ("Press Enter  >>", False, False);
            Ada.Text_IO.Get_Immediate (char);
        end if;

        sindex    := 0;
        tablename := null;
        datacols  := null;
        pkcols    := null;
        tupls     := null;

    end parsechosenoption;

begin

    cls;
    pl ("---------------------------------------------------", True);
    pl ("Put your table definitions in a file named ", True);
    pl ("tables.txt and place the file in the same folder as", True);
    pl ("this program (Parser.exe).  Type C to continue or.", True);
    pl ("~ to quit.", True);
    pl ("---------------------------------------------------", True);
    pl (">>", False);
    Ada.Text_IO.Get (char);
    line := new String'(Ada.Text_IO.Get_Line);

    if char = ETX or char = Tilde then
        raise Ada.IO_Exceptions.End_Error;
    end if;

    setinputfile ("tables.txt");
    schemas := parsetables;
    closeinputfile;
    showoptionsmenu;

    while line.all /= "~" loop

        if line.all = "help" or line.all = "HELP" then
            pl ("---------------------------------------------------",
True);
            pl ("If you want to quit type the tilde '~' character",
True);
            pl ("---------------------------------------------------",
True);
            pl (">>", False);
            line := new String'(Ada.Text_IO.Get_Line);
            cls;
        elsif line.all = "goodbye" or
              line.all = "GOODBYE" or
              line.all = "exit" or
              line.all = "EXIT" or
              line.all = "quit" or
              line.all = "QUIT" or
              line.all = "q" or
              line.all = "Q"
        then
            line := new String'("~");
        else
            ------------------------
            --   output results   --
            ------------------------
            getchosenoptiondata;
            parsechosenoption;
            showoptionsmenu;

        end if;

    end loop;

    cls;
    pl ("---------------------------------------------------", True);
    pl ("Goodbye!", True);
    pl ("---------------------------------------------------", True);

exception
    when Ada.IO_Exceptions.End_Error =>
        if Ada.Text_IO.Is_Open (input) then
            Ada.Text_IO.Close (input);
        end if;
        cls;
        pl ("---------------------------------------------------",
True);
        pl ("An error occured while reading data.  Possibly a
missing", True);
        pl ("semi-colon or other format character.  Or, you pressed ",
True);
        pl ("CTRL + C.  Goodbye!", True);
        pl ("---------------------------------------------------",
True);

    when Ada.Calendar.Time_Error =>
        pl ("A date value was not entered correctly.", True);
        pl ("Unfortunately this will cause the program to exit.",
True);
        pl ("Your data is safe so long as you don't 'create fresh'.",
True);
        pl ("the table when you start the program again.", True);
    when Ada.IO_Exceptions.Data_Error =>
        if Ada.Text_IO.Is_Open (input) then
            Ada.Text_IO.Close (input);
        end if;
    when Constraint_Error =>
        Ada.Text_IO.Put_Line ("You entered the data wrong.");

end dbprog;


with Ada.Text_IO, schema_types, attribute_types;

use schema_types, attribute_types;

package parser is

    file : Ada.Text_IO.File_Type;

    ---------------------------
    --    Utility Methods    --
    ---------------------------
    procedure setinputfile (filename : String);
    procedure closeinputfile;
    function parsetables return schema_array_ptr;
    function parsetable return schema'class;
    function parseattributes return attribute_array_ptr;
    function parseattribute return attribute'class;

end parser;


with Ada.Text_IO, Ada.Directories, Ada.Integer_Text_IO,
Ada.Strings.Fixed, Ada.Characters.Latin_1,
 Ada.IO_Exceptions, schema_types, attribute_types, util;

use Ada.Strings.Fixed, Ada.Characters.Latin_1, schema_types,
attribute_types, util;

package body parser is

    procedure setinputfile (filename : String) is

    begin
        Ada.Text_IO.Open (file, Ada.Text_IO.In_File, filename);
    end setinputfile;

    procedure closeinputfile is
    begin
        if Ada.Text_IO.Is_Open (file) then
            Ada.Text_IO.Close (file);
        end if;
    end closeinputfile;

    -----------------------
    --    parseTables    --
    -----------------------
    function parsetables return schema_array_ptr is
        eof        : Boolean          := False;
        char       : Character;
        schemas    : schema_array_ptr := null;
        swap       : schema_array_ptr := null;
        schemainfo : schema_ptr       := null;
        i          : Integer          := 1;
    begin
        eatWhite (file, eof);

        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);
        else
            raise Ada.IO_Exceptions.End_Error;
        end if;

        --at this point we should be ready to read the table name.
        swap := new schema_array (1 .. max_tables);

        while not eof loop

            schemainfo := new schema'class'(parsetable);

            pl ("Create the table fresh? [y/Y] >>", False, True);
            Ada.Text_IO.Get (char);

	    swap(i) := new schema(schemainfo.attributes'length);

            if char = 'y' or char = 'Y' then
                swap (i)     := schemainfo;
                createtable (swap (i));
            else
                if Ada.Directories.Exists (schemainfo.tablename) then
                    swap (i) := loadtable (schemainfo.tablename);
                else
                    pl ("No table exists on disc with name = " &
schemainfo.tablename, True, True);
                    pl ("You will not be able to query " &
schemainfo.tablename, True, True);
                    pl (" ", True, False);
                end if;
            end if;

	    i := i + 1;
            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            end if;
        end loop;

        i := i - 1;

        if i < 1 then
            schemas := null;
            swap    := null;
        else
            schemas := new schema_array (1 .. i);

            for x in  1 .. i loop
                schemas (x) := swap (x);
            end loop;

            swap := null;

        end if;

        return schemas;

    end parsetables;

    ----------------------
    --    parseTable    --
    ----------------------
    function parsetable return schema'class is
        temp    : schema_ptr := null;
        eof     : Boolean    := False;
        char    : Character;
        tname   : String (1 .. max_tablename_length);
        attribs : attribute_array_ptr;
        i       : Integer    := 1;
    begin

        eatWhite (file, eof);

        --at this point we should be ready to read the table name.
        --the call to eatwhite might be redundant from the instance
that
        --called 'me' but we want to ensure we are in the right
location within
        --the file.
        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);
        else
            raise Ada.IO_Exceptions.End_Error;
        end if;

        while char /= Space and
              char /= HT and
              char /= LF and
              char /= CR and
              char /= Left_Parenthesis and
              not eof
        loop

            Ada.Text_IO.Get (file, char);
            tname (i) := char;
            i         := i + 1;
            Ada.Text_IO.Look_Ahead (file, char, eof);
        end loop;

        for x in  i .. max_tablename_length loop
            tname (x) := ' ';
        end loop;

        --We just read the table name.  We are expecting an opening
'('.
        --If it's not there then there is a problem with the input
file
        --format.
        eatWhite (file, eof);

        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);

            if char = Left_Parenthesis then
                Ada.Text_IO.Get (file, char);
            else
                Ada.Text_IO.Put_Line(
"        Error in input file format:  No attributes found.  Must have
(<attribute list>)");
            end if;
        else
            raise Ada.IO_Exceptions.End_Error;
        end if;

        attribs := parseattributes;

        if attribs /= null then

            temp            := new schema (attribs.all'length);
            temp.attributes := attribs.all;
            temp.tablename  := tname;

            for x in  1 .. temp.attributes'length loop
                if temp.attributes (x).all.isprimarykey then
                    temp.primary_key_count := temp.primary_key_count +
1;
                end if;
            end loop;
        else
            temp := null;
        end if;

        --at this point we should have read the ')' for the whole
table spec.
        --if we peek, we should find a ';'.
        eatWhite (file, eof);

        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);

            if char = Semicolon then
                Ada.Text_IO.Get (file, char);
            else
                Ada.Text_IO.Put_Line
                   ("        Error in input file format:  Missing
closing ';' on table spec.");
                temp := null;
            end if;
        else
            Ada.Text_IO.Put_Line
               ("        Error in input file format:  Missing closing
')' on table spec.");
            temp := null;
        end if;

        return temp.all;

    end parsetable;

    ---------------------------
    --    parseAttributes    --
    ---------------------------
    function parseattributes return attribute_array_ptr is
        eof     : Boolean             := False;
        char    : Character;
        attribs : attribute_array_ptr := null;
        swap    : attribute_array_ptr := null;
        i       : Integer             := 1;
    begin
        eatWhite (file, eof);

        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);
        else
            raise Ada.IO_Exceptions.End_Error;
        end if;

        --at this point we should be ready to read the attribute name.
        if not eof and char /= Right_Parenthesis then
            Ada.Text_IO.Look_Ahead (file, char, eof);
        else
            Ada.Text_IO.Put_Line ("            found eof prematurely
or ')' is in wrong place.");
            raise Ada.IO_Exceptions.End_Error;
        end if;

        swap := new attribute_array (1 .. max_columns);

        while char /= Right_Parenthesis and char /= Semicolon and not
eof loop
            swap (i) := new attribute'class'(parseattribute);
            i        := i + 1;
            eatWhite (file, eof);

            if not eof and char /= Right_Parenthesis then
                --we are expecting a ')' or a comma.
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

            if char /= Comma and char /= Right_Parenthesis and not eof
then
                Ada.Text_IO.Put_Line
                   ("            Error in input file:  Missing comma
between attributes.");
                eof  := True;
                swap := null;
            elsif not eof then
                --read the comma or the ')'
                Ada.Text_IO.Get (file, char);
            end if;

            eatWhite (file, eof);

            if eof then
                Ada.Text_IO.Put_Line ("Missing semi-colon or other
format error.");
                raise Ada.IO_Exceptions.End_Error;
            end if;

        end loop;

        i := i - 1;

        if i < 1 then
            swap := null;
        else
            attribs := new attribute_array (1 .. i);

            for x in  1 .. i loop
                attribs (x) := swap (x);
            end loop;

            swap := null;

        end if;

        return attribs;

    end parseattributes;

    --------------------------
    --    parseAttribute    --
    --------------------------
    function parseattribute return attribute'class is
        temp         : attribute_types.attribute_ptr;
        eof          : Boolean := False;
        char         : Character;
        aname        : String (1 .. max_attributename_length);
        atype        : String (1 .. max_typename_length);
        asize        : Integer;
        isprimarykey : Boolean := False;
        i            : Integer := 1;
    begin

        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);
        else
            raise Ada.IO_Exceptions.End_Error;
        end if;

        while char /= Space and
              char /= HT and
              char /= LF and
              char /= CR and
              char /= Left_Parenthesis and
              char /= Colon and
              not eof
        loop
            Ada.Text_IO.Get (file, char);
            aname (i) := char;
            i         := i + 1;
            Ada.Text_IO.Look_Ahead (file, char, eof);
        end loop;

        for x in  i .. max_attributename_length loop
            aname (x) := ' ';
        end loop;

        --at this point we have the attribute name.  Read white space
to
        --a parenthesis or an colon.
        eatWhite (file, eof);

        if not eof then
            Ada.Text_IO.Look_Ahead (file, char, eof);
        else
            raise Ada.IO_Exceptions.End_Error;
        end if;

        --the next character should be '(' or ':'
        if char = Left_Parenthesis then
            Ada.Text_IO.Get (file, char);
            eatWhite (file, eof);

            i := 1;

            --read "primary"
            while char /= Space and
                  char /= HT and
                  char /= LF and
                  char /= CR and
                  char /= Right_Parenthesis and
                  not eof
            loop
                Ada.Text_IO.Get (file, char);
                atype (i) := char;
                i         := i + 1;
                Ada.Text_IO.Look_Ahead (file, char, eof);
            end loop;

            for x in  i .. max_typename_length loop
                atype (x) := ' ';
            end loop;

            if Trim (atype, Ada.Strings.Both) = "PRIMARY" then
                isprimarykey := True;
            end if;

            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

            i := 1;

            --read "key"
            while char /= Space and
                  char /= HT and
                  char /= LF and
                  char /= CR and
                  char /= Right_Parenthesis and
                  not eof
            loop
                Ada.Text_IO.Get (file, char);
                atype (i) := char;
                i         := i + 1;
                Ada.Text_IO.Look_Ahead (file, char, eof);
            end loop;

            for x in  i .. max_typename_length loop
                atype (x) := ' ';
            end loop;

            if Trim (atype, Ada.Strings.Both) = "KEY" then
                isprimarykey := True;
            else
                isprimarykey := False;
            end if;

            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

            if char = ')' then
                Ada.Text_IO.Get (file, char);
            else
                Ada.Text_IO.Put_Line
                   ("            Error in input:  Missing ')' after
Primary Key designation.");
            end if;

            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

        end if;

        if char = Colon then
            Ada.Text_IO.Get (file, char);

            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

            i := 1;

            --read the type of the attribute into atype variable
            while char /= Space and
                  char /= HT and
                  char /= LF and
                  char /= CR and
                  char /= Comma and
                  char /= Left_Parenthesis and
                  char /= Right_Parenthesis and
                  char /= Semicolon and
                  not eof
            loop
                Ada.Text_IO.Get (file, char);
                atype (i) := char;
                i         := i + 1;
                Ada.Text_IO.Look_Ahead (file, char, eof);
            end loop;

            for x in  i .. max_typename_length loop
                atype (x) := ' ';
            end loop;

            eatWhite (file, eof);

            --read the left parenthesis
            if not eof and
               char = Left_Parenthesis and
               Trim (atype, Ada.Strings.Both) = "STRING"
            then
                Ada.Text_IO.Get (file, char);
                Ada.Text_IO.Look_Ahead (file, char, eof);
            elsif not eof and
                  char /= Left_Parenthesis and
                  Trim (atype, Ada.Strings.Both) = "STRING"
            then
                Ada.Text_IO.Put_Line ("            Incorrect syntax:
missing (size) for string.");
            elsif eof then
                raise Ada.IO_Exceptions.End_Error;
            end if;

            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

            --read the size of the type of the attribute into atype
variable
            while char /= Space and
                  char /= HT and
                  char /= LF and
                  char /= CR and
                  char /= Comma and
                  char /= Right_Parenthesis and
                  char /= Left_Parenthesis and
                  not eof
            loop

                Ada.Integer_Text_IO.Get (file, asize, 0);
                Ada.Text_IO.Look_Ahead (file, char, eof);
            end loop;

            --I have to do this temporarily to get this program
            --to work.  ALL strings are the same length.  The reason
            --is because there is no way to know how long the string
is
            --when serializing it in from a file (see loadtable in
            --schema_types) before we serialize it so that we can
            --provide a length discriminant to the type defined in
            --attribute_types.  So, we just make them all the same
            --length.
            asize := max_stringlength;

            eatWhite (file, eof);

            --read the right parenthesis
            if not eof and
               char = Right_Parenthesis and
               Trim (atype, Ada.Strings.Both) = "STRING"
            then
                Ada.Text_IO.Get (file, char);
                Ada.Text_IO.Look_Ahead (file, char, eof);
            elsif not eof and
                  char /= Right_Parenthesis and
                  Trim (atype, Ada.Strings.Both) = "STRING"
            then
                Ada.Text_IO.Put_Line
                   ("            Incorrect syntax:  missing (size ~)~
for string.");
            elsif eof then
                raise Ada.IO_Exceptions.End_Error;
            end if;

            eatWhite (file, eof);

            if Trim (atype, Ada.Strings.Both) = "BOOLEAN" then

                temp        := new booleanattribute;
                temp.name   := aname;
                temp.domain := atype;

                if isprimarykey then
                    temp.isprimarykey := True;
                end if;

            elsif Trim (atype, Ada.Strings.Both) = "STRING" then

                temp        := new stringattribute;
                temp.name   := aname;
                temp.domain := atype;

                if isprimarykey then
                    temp.isprimarykey := True;
                end if;

            elsif Trim (atype, Ada.Strings.Both) = "INTEGER" then

                temp        := new integerattribute;
                temp.name   := aname;
                temp.domain := atype;

                if isprimarykey then
                    temp.isprimarykey := True;
                end if;

            elsif Trim (atype, Ada.Strings.Both) = "DATE" then

                temp        := new dateattribute;
                temp.name   := aname;
                temp.domain := atype;

                if isprimarykey then
                    temp.isprimarykey := True;
                end if;

            else
                Ada.Text_IO.Put_Line ("            unknown type
specified.");
            end if;

            --after eating the white space we should be left at the
',' or
            --the ')'.
            eatWhite (file, eof);

            if not eof then
                Ada.Text_IO.Look_Ahead (file, char, eof);
            else
                raise Ada.IO_Exceptions.End_Error;
            end if;

            --we leave the comma in the stream so that parseAttributes
can
            --pick it up and loop for the next attribute.  We leave
the second
            --')' for parseAttributes to read to know when to exit the
loop and
            --quit parsing attributes.
            if char /= Comma and char /= Right_Parenthesis then
                Ada.Text_IO.Put_Line(
"            Error in input:  Missing ')' after Primary Key
designation or ',' between attributes.")
;
                temp := null;
            end if;

        else
            Ada.Text_IO.Put_Line
               (
"            Error in input file:  Format not correct, no type
specified for attribute " &
                aname);
            temp := null;
        end if;

        return temp.all;

    end parseattribute;

begin

    null;

end parser;


with Ada.Text_IO, Ada.Characters.Latin_1, Ada.Strings.Fixed,
Ada.Strings.Maps, Ada.IO_Exceptions;

use Ada.Characters.Latin_1;

package util is
    type string_ptr is access all String;
    type string_array is array (Integer range <>) of string_ptr;
    type string_array_ptr is access all string_array;

    max_columns              : Integer := 5;
    max_tables               : Integer := 5;
    max_tablename_length     : Integer := 25;
    max_attributename_length : Integer := 25;
    max_stringlength         : Integer := 255;
    max_typename_length      : Integer := 7;
    max_filename_length      : Integer := 45;
    max_index_namelength: integer := 50;

    procedure cls;
    procedure pl (text : in String; newline : in Boolean; setcolumn :
in Boolean := True);
    function tokenize (text : in String) return string_array_ptr;
    procedure eatWhite (fin : in out Ada.Text_IO.File_Type; eof : in
out Boolean);
end util;


package body Util is

    procedure cls is
        i : Integer := 1;
    begin
        while i < 40 loop
            Ada.Text_IO.New_Line;
            i := i + 1;
        end loop;
    end cls;

    procedure pl (text : in String; newline : in Boolean; setcolumn :
in Boolean := True) is
    begin

        if newline then
            if setcolumn then
                Ada.Text_IO.Set_Col (15);
            end if;
            Ada.Text_IO.Put_Line (text);
        elsif setcolumn then
            Ada.Text_IO.Set_Col (15);
            Ada.Text_IO.Put (text);
        else
            Ada.Text_IO.Put (text);
        end if;

    end pl;

    function tokenize (text : in String) return string_array_ptr is
        temp             : string_array_ptr;
        first            : Integer := 1;
        i                : Integer := 1;
        number_of_commas : Integer := 0;
        data             : string_ptr;
        data2            : string_ptr;
    begin
        data             := new String'(text);
        number_of_commas := Ada.Strings.Fixed.Count (data.all,
Ada.Strings.Maps.To_Set (','));

        if number_of_commas > max_columns then
            pl ("Invalid number of columns specified", True);
            raise Ada.IO_Exceptions.Data_Error;
        end if;

        temp := new string_array (1 .. number_of_commas + 1);

        --first will point to the first comma.
        first :=
            Ada.Strings.Fixed.Index
               (data.all,
                Ada.Strings.Maps.To_Set (','),
                Ada.Strings.Inside,
                Ada.Strings.Forward);

        while i <= number_of_commas and number_of_commas < max_columns
loop

            temp.all (i) := new String'(data.all (1 .. first - 1));
            data2        := new String (1 .. data.all'length - first);
            data2.all    := data.all (first + 1 .. data.all'length);
            data         := new String'(data2.all);
            i            := i + 1;
            first        :=
                Ada.Strings.Fixed.Index
                   (data.all,
                    Ada.Strings.Maps.To_Set (','),
                    Ada.Strings.Inside,
                    Ada.Strings.Forward);

        end loop;

        temp.all (i) := new String'(data.all);

        return temp;
    end tokenize;

    --------------------
    --    eatWhite    --
    --------------------
    procedure eatWhite (fin : in out Ada.Text_IO.File_Type; eof : in
out Boolean) is
        char : Character;
    begin

        Ada.Text_IO.Look_Ahead (fin, char, eof);

        while Ada.Text_IO.End_Of_Line (fin) and not
Ada.Text_IO.End_Of_File (fin) loop
            Ada.Text_IO.Skip_Line (fin);
        end loop;

        Ada.Text_IO.Look_Ahead (fin, char, eof);

        while (char = Space or char = HT or char = LF or char = CR)
and
              not Ada.Text_IO.End_Of_File (fin)
        loop

            Ada.Text_IO.Get (fin, char);

            while Ada.Text_IO.End_Of_Line (fin) and not
Ada.Text_IO.End_Of_File (fin) loop
                Ada.Text_IO.Skip_Line (fin);
            end loop;

            Ada.Text_IO.Look_Ahead (fin, char, eof);
        end loop;

    end eatWhite;

begin
    null;
end Util;


with util, Ada.Calendar, attribute_types, Ada.Streams.Stream_IO;

use util, attribute_types;

package schema_types is

    ---------------------------------
    --    Variable Declarations    --
    ---------------------------------
    fin  : Ada.Streams.Stream_IO.File_Type;
    fout : Ada.Streams.Stream_IO.File_Type;

    type schema (number_of_attributes : Integer) is tagged record
        tablename : String (1 .. max_tablename_length) := (1 ..
max_tablename_length => ' ');
        attributes        : attribute_array (1 ..
number_of_attributes);
        byte_start        : Integer := 0;
        byte_end          : Integer := 0;
        primary_key_count : Integer := 0;
    end record;
    type schema_ptr is access all schema'class;
    type schema_array is array (Integer range <>) of schema_ptr;
    type schema_array_ptr is access all schema_array;
    type tuple is array (Integer range <>) of attribute_array_ptr;
    type tuple_ptr is access all tuple;

    procedure createtable (schemainfo : schema_ptr);
    function loadtable (sname : String) return schema_ptr;
    function findrecord (schemainfo : schema; values :
attribute_array) return Integer;
    procedure insertrec (schemainfo : schema; values :
attribute_array);
    procedure deleterec (schemainfo : schema; primary_key_values :
attribute_array);
    procedure updaterec
       (schemainfo : schema;
        pkattribs  : attribute_array;
        values     : attribute_array);
    function selectrec (schemainfo : schema) return tuple_ptr;

end schema_types;


with Ada.Streams.Stream_IO, Ada.Calendar, GNAT.Calendar.Time_IO,
Ada.Text_IO, Ada.Strings.Fixed,
 Ada.Directories, Ada.IO_Exceptions;
use Ada.Streams.Stream_IO, Ada.Calendar, GNAT.Calendar.Time_IO,
Ada.Strings.Fixed;

package body schema_types is

    procedure createtable (schemainfo : schema_ptr) is
        fout     : File_Type;
        attribs  : attribute_array_ptr;
        attribs2 : attribute_array_ptr;
        i        : Integer := 1;
        ii       : Integer := 1;
        temp     : access attribute'class;
    begin

        if schemainfo = null then
            return;
        end if;

        --  put them in order first
        for x in  1 .. schemainfo.attributes'length loop
            for y in  x + 1 .. schemainfo.attributes'length loop

                if schemainfo.attributes (y).name <
schemainfo.attributes (x).name then
                    temp                      := schemainfo.attributes
(y);
                    schemainfo.attributes (y) := schemainfo.attributes
(x);
                    schemainfo.attributes (x).all := temp.all;
                end if;
            end loop;
        end loop;

        attribs  := new attribute_array (1 ..
schemainfo.attributes'length);
        attribs2 := new attribute_array (1 ..
schemainfo.attributes'length);

        for x in  1 .. schemainfo.attributes'length loop
            if schemainfo.attributes (x).isprimarykey then
                attribs (i) := schemainfo.attributes (x);
                i           := i + 1;
            else
                attribs2 (ii) := schemainfo.attributes (x);
                ii            := ii + 1;
            end if;
        end loop;

        i  := i - 1;
        ii := ii - 1;

        --  the primary_key attributes first
        for x in  1 .. i loop
            schemainfo.attributes (x) := attribs (x);
        end loop;

        --  non-primary key attributes next
        for x in  1 .. ii loop
            schemainfo.attributes (x + i) := attribs2 (x);
        end loop;

        Create (fout, Out_File, Trim (schemainfo.all.tablename,
Ada.Strings.Both));
        --We are writing the number of attributes so that when we load
        --the table we can determine the number of attributes to put
        --into the new, loading schema.
        Integer'write (Stream (fout),
schemainfo.all.attributes'length);

        schemainfo.all.byte_start := Integer'val (Index (fout));

	--we output it once so that we can capture the file position for
byte_end
        schema'output (Stream (fout), schemainfo.all);

	--fill in byte_end
        schemainfo.all.byte_end := Integer'val (Index (fout));

	close(fout);
	Open (fout, Out_File, Trim (schemainfo.all.tablename,
Ada.Strings.Both));

        Integer'write (Stream (fout),
schemainfo.all.attributes'length);

	--now we have byte_start and byte_end
        schema'output (Stream (fout), schemainfo.all);

        for x in  1 .. schemainfo.all.attributes'length loop
	    to_disc(fout, schemainfo.all.attributes(x).all);
        end loop;

        Close (fout);

    end createtable;

    function loadtable (sname : String) return schema_ptr is
        schemainfo : schema_ptr;
        fin        : File_Type;
        length     : Integer;
        position   : integer;
    begin
        Open (fin, In_File, Trim (sname, Ada.Strings.Both));

        Integer'read (Stream (fin), length);

        schemainfo                := new schema (length);
        schemainfo.all            := schema'class'input (Stream
(fin));

	--mark where we are at in the file to start reading attributes.
        position                  := Integer'val (Index (fin));

        for x in  1 .. schemainfo.attributes'length loop
-----------------------------------------------------
-- Old code I plan on removing
-----------------------------------------------------
--              schemainfo.all.attributes (x).all.byte_start :=
position;
--
--              if Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "BOOLEAN" then
--  		schemainfo.all.attributes (x)                := new
booleanattribute;
--                  schemainfo.all.attributes (x).all            :=
--                      booleanattribute'input (Stream (fin));
--              elsif Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "STRING" then
--                  schemainfo.all.attributes (x)                :=
new stringattribute;
--                  schemainfo.all.attributes (x).all            :=
--                      stringattribute'input (Stream (fin));
--              elsif Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "INTEGER" then
--                  schemainfo.all.attributes (x)                :=
new integerattribute;
--                  schemainfo.all.attributes (x).all            :=
--                      integerattribute'input (Stream (fin));
--              else --  "DATE"
--                  schemainfo.all.attributes (x)                :=
new dateattribute;
--                  schemainfo.all.attributes (x).all            :=
--                      dateattribute'input (Stream (fin));
--              end if;
--              position := Integer'val (Index (fin));
--              schemainfo.all.attributes (x).all.byte_end   :=
position;
-- End old code
------------------------------------------------------
-----------------------------------------------------------
-- The code I want to use for dispatching
-----------------------------------------------------------
--  	    schemainfo.all.attributes (x) := new
attribute'class'(from_disc(fin, schemainfo.all.attributes (x).all));
-----------------------------------------------------------

------------------------------------------------------------
-- Debug code below --
------------------------------------------------------------
-- For some reason some of the attributes on schemainfo come through
-- as "unknown" after the schemainfo was filled in from
'input(stream).
-- It doesn't appear to me that createtable procedure in this package
-- writes the schema object incorrectly so I don't understand why
-- the attributes of the schemainfo object we retrieve with 'input are
-- "unknown".  Well, the domain member of the attribute is not one of
-- BOOLEAN, STRING, INTEGER or DATE; that's why it prints it but why
-- isn't the domain member one of those values?

            if Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "BOOLEAN" then
ada.text_io.put_line(schemainfo.all.attributes (x).name);
ada.text_io.put_line(schemainfo.all.attributes (x).domain);

            elsif Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "STRING" then
ada.text_io.put_line(schemainfo.all.attributes (x).name);
ada.text_io.put_line(schemainfo.all.attributes (x).domain);

	    elsif Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "INTEGER" then
ada.text_io.put_line(schemainfo.all.attributes (x).name);
ada.text_io.put_line(schemainfo.all.attributes (x).domain);

            elsif Trim (schemainfo.all.attributes (x).domain,
Ada.Strings.Both) = "DATE" then
ada.text_io.put_line(schemainfo.all.attributes (x).name);
ada.text_io.put_line(schemainfo.all.attributes (x).domain);
	    else
ada.text_io.put_line("unknown");
            end if;
        end loop;

-- End Debug Code
---------------------------------------------------------------
        Close (fin);

        return schemainfo;

    exception
        when Ada.IO_Exceptions.Status_Error =>
            Ada.Text_IO.Put_Line ("Status error in loadtable");
            return null;
    end loadtable;

    ---------------------
    --  INSERT RECORD  --
    ---------------------
    procedure insertrec (schemainfo : schema; values :
attribute_array) is
        location : Integer := -1;
        char     : Character;
    begin

        location := findrecord (schemainfo, values);

        --if the record isn't in there it is -1
        if location = -1 then

            Open (fout, Append_File, Trim (schemainfo.tablename,
Ada.Strings.Both));

            for x in  1 .. schemainfo.attributes'length loop
		to_disc(fout, values (x).all);
            end loop;

            Close (fout);
        else
            pl ("Record already exists with that key", True, True);
            pl ("Press Enter to continue...", True, True);
            Ada.Text_IO.Get_Immediate (char);
        end if;

    end insertrec;

    ---------------------
    --  SELECT RECORD  --
    ---------------------
    function selectrec (schemainfo : schema) return tuple_ptr is
        temp  : attribute_array_ptr;
        recs  : tuple_ptr;
        recs2 : tuple_ptr;
        i     : Integer := 1;

    begin
        Open (fin, In_File, Trim (schemainfo.tablename,
Ada.Strings.Both));
        Set_Index
           (fin,
            Ada.Streams.Stream_IO.Count'val
                (schemainfo.attributes
(schemainfo.attributes'length).all.byte_end));

        temp := new attribute_array (1 ..
schemainfo.attributes'length);

        if End_Of_File (fin) then
            Close (fin);
            return null;
        end if;

        recs := new tuple (1 .. 1);

        while not End_Of_File (fin) loop
            for x in  1 .. temp.all'length loop
		temp(x) := new attribute'class'(from_disc(fin, schemainfo.attributes
(x).all));
            end loop;

            if i < 2 then
                recs (recs'last) := temp;
            else
                recs2 := new tuple (1 .. recs'length);

                for z in  1 .. recs'length loop
                    recs2 (z) := recs (z);
                end loop;

                recs := new tuple (1 .. i);

                for z in  1 .. recs2'length loop
                    recs (z) := recs2 (z);
                end loop;

                recs (recs'last) := temp;
            end if;
            temp := new attribute_array (1 ..
schemainfo.attributes'length);
            i    := i + 1;
        end loop;

        Close (fin);

        return recs;

    end selectrec;

    -------------------
    --  FIND RECORD  --
    -------------------
    function findrecord (schemainfo : schema; values :
attribute_array) return Integer is
        temp         : attribute_array_ptr;
        location     : Ada.Streams.Stream_IO.Count;
        found        : Integer := 0;
        done         : Boolean := False;
        comparrisons : Integer := 0;
    begin

        Open (fin, In_File, Trim (schemainfo.tablename,
Ada.Strings.Both));

        Set_Index
           (fin,
            Ada.Streams.Stream_IO.Count'val
                (schemainfo.attributes
(schemainfo.attributes'length).all.byte_end));
        temp := new attribute_array (1 ..
schemainfo.attributes'length);

        while not End_Of_File (fin) and then not done loop
            --mark our current location in the file.
            location := Index (fin);

            --read the whole line from the file,
            for x in  1 .. schemainfo.attributes'length loop
		temp(x) := new attribute'class'(from_disc(fin,
schemainfo.attributes(x).all));
            end loop;

            --then compare them.
            comparrisons := 0;
            found        := 0;

            for x in  1 .. values'length loop

                if schemainfo.attributes (x).isprimarykey then

                    comparrisons := comparrisons + 1;

                    if Trim (values (x).domain, Ada.Strings.Both) =
"BOOLEAN" then
                        if booleanattribute (temp (x).all).value =
                           booleanattribute (values (x).all).value
                        then
                            found := found + 1;
                        end if;
                        --
ada.text_io.put_line(boolean'image(booleanattribute(temp(x).all).value
                        --));
                    elsif Trim (values (x).domain, Ada.Strings.Both) =
"STRING" then
                        if stringattribute (temp (x).all).value =
                           stringattribute (values (x).all).value
                        then
                            found := found + 1;
                        end if;
                        --
ada.text_io.put_line(stringattribute(temp(x).all).value);
                    elsif Trim (values (x).domain, Ada.Strings.Both) =
"INTEGER" then
                        if integerattribute (temp (x).all).value =
                           integerattribute (values (x).all).value
                        then
                            found := found + 1;
                        end if;
                        --
ada.text_io.put_line(integer'image(integerattribute(temp(x).all).value
                        --));
                    else -- "DATE"
                        if dateattribute (temp (x).all).value =
                           dateattribute (values (x).all).value
                        then
                            found := found + 1;
                        end if;
                        --
ada.text_io.put_line(image(dateattribute(temp(x).all).value,
                        --iso_date));
                    end if;
                end if;
            end loop;

            if found = comparrisons and then comparrisons > 0 then
                done := True;
            end if;

            if End_Of_File (fin) then
                done := True;
            end if;
        end loop;

        Close (fin);

        if found < comparrisons then
            return -1;
        elsif found = 0 and then comparrisons = 0 then
            return -1;
        else
            return Integer'val (location);
        end if;

    end findrecord;

    ---------------------
    --  DELETE RECORD  --
    ---------------------
    procedure deleterec (schemainfo : schema; primary_key_values :
attribute_array) is
        location          : Integer;
        original_byte_end : Integer := schemainfo.attributes
(schemainfo.attributes'last).byte_end;
        temp              : attribute_array_ptr;
        char              : Character;
    begin
        location := findrecord (schemainfo, primary_key_values);

        --If findrecord seeks past the schema info header in the file
and ends
        --on the end of file it will return -1.  Therefore, no records
to delete
        --in the file.
        if location = -1 then
            pl ("No records to delete with that key", True, True);
            pl ("Press Enter to continue...", True, True);
            Ada.Text_IO.Get_Immediate (char);
            return;
        end if;

        Create (fout, Out_File, "swapfile");
        Open (fin, In_File, Trim (schemainfo.tablename,
Ada.Strings.Both));

        --output the schema header information to the file
        Integer'write (Stream (fout), schemainfo.attributes'length);

	--I took these out so that we could create a function for
	--updating records that returns an rrn.  functions do not
	--allow out mode parameters and deleterec had an out mode
	--parameter because of this next line.
        --schemainfo.byte_start := Integer'val (Index (fout));
        schema'output (Stream (fout), schemainfo);

	--I took these out so that we could create a function for
	--updating records that returns an rrn.  functions do not
	--allow out mode parameters and deleterec had an out mode
	--parameter because of this next line.
        --schemainfo.byte_end := Integer'val (Index (fout));

        for x in  1 .. schemainfo.attributes'length loop

		to_disc(fout, schemainfo.attributes(x).all);
        end loop;

        --set the index on the input file so we skip the header on
input file.
        Set_Index (fin, Ada.Streams.Stream_IO.Count'val
(original_byte_end));
        temp := new attribute_array (1 ..
schemainfo.attributes'length);

        --Read records from one file and insert them into the other
file until
        --we get to the location of the record we want to delete.
        while Index (fin) < Ada.Streams.Stream_IO.Count'val (location)
loop

            for x in  1 .. temp.all'length loop
		temp(x) := new attribute'class'(from_disc(fin,
schemainfo.attributes(x).all));
		to_disc(fin, temp(x).all);
            end loop;
        end loop;

        --do a blank read to move past the line to delete
        for x in  1 .. schemainfo.attributes'length loop

	    temp(x) := new attribute'class'(from_disc(fin,
schemainfo.attributes(x).all));
        end loop;

	--output the rest of the records.
        while not End_Of_File (fin) loop
            for x in  1 .. temp.all'length loop
		temp(x) := new attribute'class'(from_disc(fin,
schemainfo.attributes(x).all));
		to_disc(fout, temp(x).all);
            end loop;
        end loop;

        Close (fin);
        Close (fout);
        Ada.Directories.Delete_File (Trim (schemainfo.tablename,
Ada.Strings.Both));
        Ada.Directories.Rename ("swapfile", Trim
(schemainfo.tablename, Ada.Strings.Both));

        location := findrecord (schemainfo, primary_key_values);

        if location >= 1 then
            deleterec (schemainfo, primary_key_values);
        end if;

    end deleterec;

    ---------------------
    --  UPDATE RECORD  --
    ---------------------
    procedure updaterec
       (schemainfo : schema;
        pkattribs  : attribute_array;
        values     : attribute_array)
    is
        position : Integer := 0;
        char     : Character;
    begin
        position := findrecord (schemainfo, pkattribs);

        --if the record doesn't exist then insert it
        if position < 1 then
            pl ("That record doesn't exist in the database.", True,
True);
            pl ("Insert it instead (menu item 1).", True, True);
            pl ("Press Enter to continue...", True, True);
            Ada.Text_IO.Get_Immediate (char);
        elsif position >= 1 then
            deleterec (schemainfo, pkattribs);
            insertrec (schemainfo, values);
        end if;
    end updaterec;

begin
    null;
end schema_types;


with util, Ada.Calendar, ada.streams.stream_io;

use util, Ada.Calendar, ada.streams.stream_io;

package attribute_types is

    -----------------------------------
    --    Forwarding Declarations    --
    -----------------------------------
    type attribute is abstract tagged;
    type booleanattribute is tagged;
    type integerattribute is tagged;
    type stringattribute is tagged;
    type dateattribute is tagged;

    --------------------------------------
    --    Attribute Type Declarations    --
    --------------------------------------
    type attribute is abstract tagged record
        name         : String (1 .. max_attributename_length) :=
           (1 .. max_attributename_length => ' ');
        domain       : String (1 .. max_typename_length) := (1 ..
max_typename_length => ' ');
        isprimarykey : Boolean                                :=
False;
        byte_start   : Integer                                := 0;
        byte_end     : Integer                                := 0;
    end record;

    --------------------------------------
    --    Basic Pointer Declarations    --
    --------------------------------------
    type attribute_ptr is access attribute'class;
    type attribute_array is array (Integer range <>) of access
attribute'class;
    type attribute_array_ptr is access all attribute_array;

    procedure to_disc (fout: file_type; item: in out attribute) is
abstract;
    function from_disc(fout: file_type; item: attribute) return
attribute'class is abstract;


    -----------------------------------
    --    Extended Attribute Types   --
    -----------------------------------
    type booleanattribute is new attribute with record
        value : Boolean := False;
    end record;
    type booleanattribute_ptr is access all booleanattribute'class;
    procedure to_disc (fout: file_type; item: in out
booleanattribute);
    function from_disc(fin: file_type; item: booleanattribute) return
attribute'class;

    type integerattribute is new attribute with record
        value : Integer := 0;
    end record;
    type integerattribute_ptr is access all integerattribute'class;
    procedure to_disc (fout: file_type; item: in out
integerattribute);
    function from_disc(fin: file_type; item: integerattribute) return
attribute'class;

    type stringattribute is new attribute with record
        value : String (1 .. max_stringlength) := (1 ..
max_stringlength => ' ');
    end record;
    type stringattribute_ptr is access all stringattribute'class;
    procedure to_disc (fout: file_type; item: in out stringattribute);
    function from_disc(fin: file_type; item: stringattribute) return
attribute'class;

    type dateattribute is new attribute with record
        year  : Year_Number  := 1901;
        month : Month_Number := 1;
        day   : Day_Number   := 1;
        value : Time         := Time_Of (1901, 1, 1);
    end record;
    type dateattribute_ptr is access all dateattribute'class;
    procedure to_disc (fout: file_type; item: in out dateattribute);
    function from_disc(fin: file_type; item: dateattribute) return
attribute'class;

end attribute_types;


with ada.text_io, util, ada.calendar;
use util, ada.calendar;

package body attribute_types is

    procedure to_disc (fout: file_type; item: in out booleanattribute)
is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(booleanattribute'size / 8) - 7;
        booleanattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: booleanattribute) return
attribute'class is
        temp : access attribute'class;
    begin
      temp := new booleanattribute;
      temp.all := booleanattribute'class'input (Stream (fin));
      return temp.all;
    end from_disc;

    procedure to_disc (fout: file_type; item: in out integerattribute)
is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(integerattribute'size / 8) - 7;
        integerattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: integerattribute) return
attribute'class is
    	temp : access attribute'class;
    begin
  	temp := new integerattribute;
	temp.all := integerattribute'class'input (Stream (fin));
	return temp.all;
    end from_disc;

    procedure to_disc (fout: file_type; item: in out stringattribute)
is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(stringattribute'size / 8) - 7;
        stringattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: stringattribute) return
attribute'class is
    	temp: access attribute'class;
    begin
  	temp := new stringattribute;
	temp.all := stringattribute'class'input (Stream (fin));
	return temp.all;
    end from_disc;

    procedure to_disc (fout: file_type; item: in out dateattribute) is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(dateattribute'size / 8) - 11;
        dateattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: dateattribute) return
attribute'class is
    	temp: access attribute'class;
    begin
    	temp := new dateattribute;
	temp.all := dateattribute'class'input (Stream (fin));
	return temp.all;
    end from_disc;

begin
    null;
end attribute_types;


with Ada.Streams.Stream_IO, util, attribute_types,Ada.Calendar; use
util, attribute_types,Ada.Calendar;

package index_types is

    ---------------------------------
    --    Variable Declarations    --
    ---------------------------------
    fin  : Ada.Streams.Stream_IO.File_Type;
    fout : Ada.Streams.Stream_IO.File_Type;
--------------------------------------------------------
--  THIS FILE IS NOT COMPLETE NOR USED YET!!!
--  IT IS INCLUDED BECAUSE IT IS WITH'D
--------------------------------------------------------
    --an index is a file
    --it contains the primary key value and file position for the
primary key for a primary index
	    --the spec sounds like only one attribute will make up a primary
key.
    --for a secondary index it contains an attribute and a position.
	    --The spec says only one attribute.
    --primary indexes are named after the table it belongs to
<tablename>_PIDX
    --secondary indexes are named after the table it belongs to like
<tablename>_SIDX

    --each schema object has a list of index names for a table
	    --initially the list of index names is empty
    --the user adds an index to the table and then the index name goes
into the list of indexes on
    --the schema
    --the schema information will have to be re-written to the table
file when an index is added.
	    --This is the same for the secondary indexes
    --if a tuple that an index is based on is inserted, deleted or
updated then the index must be
    --loaded and re-created.
    ----on updates we only have to change the index if the index value
is being changed.

--The attributes store the name of an index on itself.  When we load
the schema
--we go through each attribute and determine if it is indexed then
load that
--index if it is.  This gives us the "type" on the index value,
elleviates the
--need to maintain a list of index names in the schema object,
----what do we load an index into?


    --There are two types of indexes: primary and secondary
    --** note ** the primary index is just like the secondary; it only
has one entry per item
    --because there is only
    --one item allowed per entry due to the fact that primary keys are
unique.
    --The differences in indexes are:
    ----if we remove a value from a secondary we must match the rrn to
remove the correct
    --item; with a primary key there is only one to remove.
    ----when finding a record, with a primary index when we find the
value we don't
    ----have to search a bunch of records for the exact tuple match.
With secondary
    ----, because there are multiple values that are the same with
different rrn's
    ----we have to search each rrn and compare values to match the
tuple.

    --we don't sort as we read the table, we read the table and then
sort the index file.

    type index is abstract tagged record
        filename : String (1 .. max_index_namelength);
        rrn  : Ada.Streams.Stream_IO.Count := 0;
    end record;
    type index_ptr is access all index;
    type index_array is array (Integer range <>) of index_ptr;

    type booleanindex is tagged record
        key : boolean;
    end record;

    type integerindex is tagged record
        key : integer;
    end record;

    type stringindex is tagged record
        key : string(1..max_stringlength);
    end record;

    type dateindex is tagged record
        key : time;
    end record;
end index_types;


*************************
* Contents of the table.txt file
* This file is used by the main procedure dbprog.
* It must be labeled tables.txt and placed in the
* same directory as the executable dbprog.exe
*************************
T3(
ID(PRIMARY KEY):INTEGER
);

T2(
DATA(PRIMARY KEY):STRING(15)
);

T4(
II(PRIMARY KEY):DATE
);

T1(
mine(PRIMARY KEY):BOOLEAN
);
*************************




^ permalink raw reply	[relevance 4%]

* Re: Structured exception information
  @ 2007-01-28 12:39  5%                               ` Simon Wright
  0 siblings, 0 replies; 195+ results
From: Simon Wright @ 2007-01-28 12:39 UTC (permalink / raw)


Stephen Leake <stephen_leake@stephe-leake.org> writes:

> In addition, you have ignored the problem that each version of
> Write_Output for different hardware will need need a corresponding
> version of the exception type; more work.

I suppose the model of Ada.IO_Exceptions might help.



^ permalink raw reply	[relevance 5%]

* Ada.Directories and multibyte-filename
@ 2006-07-13 17:38  5% Y.Tomino
  0 siblings, 0 replies; 195+ results
From: Y.Tomino @ 2006-07-13 17:38 UTC (permalink / raw)


Searching directory with Ada.Directories, it raises Name_Error for
normal multibyte-filename.

Test:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Directories; use Ada.Directories;
procedure Test is
   Search : Search_Type;
   File : Directory_Entry_Type;
begin
   Start_Search(Search, ".", "*");
   while More_Entries(Search) loop
      Get_Next_Entry(Search, File);
      Ada.Text_IO.Put_Line(Simple_Name(File));
   end loop;
   End_Search(Search);
end Test;

Compile and run it on the directory containing file named with
multibyte-characters.

raised ADA.IO_EXCEPTIONS.NAME_ERROR : a-direct.adb:122

It is not possible to use Ada.Directories in the regions having
multibyte-characters...

-- 
YT



^ permalink raw reply	[relevance 5%]

* Re: Advice on abort
  2005-11-05 18:33  4%   ` Simon Wright
@ 2005-11-05 21:23  0%     ` REH
  0 siblings, 0 replies; 195+ results
From: REH @ 2005-11-05 21:23 UTC (permalink / raw)



"Simon Wright" <simon@pushface.org> wrote in message 
news:m2fyqb9c6o.fsf@grendel.local...
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> Close that socket from another task. That should end the blocking
>> I/O on the socket with some error code. And the task will become
>> ready accept a rendezvous.
>
> We have recently been bitten by OS-dependent behaviour in this area.
>
> On Windows, the read fails immediately with an
> GNAT.Sockets.Socket_Error exception. However, on VxWorks and Linux
> (and possibly other OS's), you get a successful read of *zero* bytes
> (at any rate, fewer than you requested) and the exception only happens
> on the next read.
>
> Of course, getting a short read may end up with an
> Ada.IO_Exceptions.End_Error anyway (we had forgotten to check the
> length :-( ).

That's fine.  We are VxWorks too.  Besides, a return of 0 on a read is not 
considered "successful" with sockets.  It means the socket has been closed. 
You got an exception on the next read, because you were trying to read from 
a closed socket.

REH






^ permalink raw reply	[relevance 0%]

* Re: Advice on abort
  @ 2005-11-05 18:33  4%   ` Simon Wright
  2005-11-05 21:23  0%     ` REH
  0 siblings, 1 reply; 195+ results
From: Simon Wright @ 2005-11-05 18:33 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> Close that socket from another task. That should end the blocking
> I/O on the socket with some error code. And the task will become
> ready accept a rendezvous.

We have recently been bitten by OS-dependent behaviour in this area.

On Windows, the read fails immediately with an
GNAT.Sockets.Socket_Error exception. However, on VxWorks and Linux
(and possibly other OS's), you get a successful read of *zero* bytes
(at any rate, fewer than you requested) and the exception only happens
on the next read.

Of course, getting a short read may end up with an
Ada.IO_Exceptions.End_Error anyway (we had forgotten to check the
length :-( ).



^ permalink raw reply	[relevance 4%]

* Re: Ada call from vc++
  2005-06-07  6:01  4% Ada call from vc++ Matthias
  2005-06-07 16:41  0% ` James Alan Farrell
@ 2005-06-07 20:45  0% ` Björn Persson
  1 sibling, 0 replies; 195+ results
From: Björn Persson @ 2005-06-07 20:45 UTC (permalink / raw)


Matthias wrote:
> we have an c++-application that includes a dll with adacode. Another
> c++-application starts this app with CreateProcess(...). After starting
> the c++-app the following error comes up:
> "Program terminated by an exception propagated out of the main
> subprogram. Exception raised: ADA.IO_EXCEPTIONS.USE_ERROR. Executable
> name... EIP EBP..."
> If we start the c++-app with the adacode dll manually there is no error
> message shown.

The RM says: "The exception Use_Error is propagated if an operation is 
attempted that is not possible for reasons that depend on 
characteristics of the external file."

So you'll have to think of things like: Are there any differences in 
which files the DLL tries to access? Does the program get the same 
standard in, standard out and standard error files in both cases? Any 
parameters that might change how it operates on the files?

If you have the source code it'll help you a lot if you can get a stack 
trace and see where the exception comes from.

-- 
Bj�rn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu



^ permalink raw reply	[relevance 0%]

* Re: Ada call from vc++
  2005-06-07  6:01  4% Ada call from vc++ Matthias
@ 2005-06-07 16:41  0% ` James Alan Farrell
  2005-06-07 20:45  0% ` Björn Persson
  1 sibling, 0 replies; 195+ results
From: James Alan Farrell @ 2005-06-07 16:41 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

Matthias wrote:
> Hi all,
> 
> we have an c++-application that includes a dll with adacode. Another
> c++-application starts this app with CreateProcess(...). After starting
> the c++-app the following error comes up:
> "Program terminated by an exception propagated out of the main
> subprogram. Exception raised: ADA.IO_EXCEPTIONS.USE_ERROR. Executable
> name... EIP EBP..."
> If we start the c++-app with the adacode dll manually there is no error
> message shown.
> Somebody knows about this problem?
> 
> Matthias
> 

What Ada compiler did you use to make the DLL?

If it is gnat, then there is a function ada_init() that must be called 
from c++.

James

[-- Attachment #2: jfarrell.vcf --]
[-- Type: text/x-vcard, Size: 88 bytes --]

begin:vcard
fn:James Alan Farrell
n:Farrell;James
org:GrammaTech
version:2.1
end:vcard


^ permalink raw reply	[relevance 0%]

* Ada call from vc++
@ 2005-06-07  6:01  4% Matthias
  2005-06-07 16:41  0% ` James Alan Farrell
  2005-06-07 20:45  0% ` Björn Persson
  0 siblings, 2 replies; 195+ results
From: Matthias @ 2005-06-07  6:01 UTC (permalink / raw)


Hi all,

we have an c++-application that includes a dll with adacode. Another
c++-application starts this app with CreateProcess(...). After starting
the c++-app the following error comes up:
"Program terminated by an exception propagated out of the main
subprogram. Exception raised: ADA.IO_EXCEPTIONS.USE_ERROR. Executable
name... EIP EBP..."
If we start the c++-app with the adacode dll manually there is no error
message shown.
Somebody knows about this problem?

Matthias




^ permalink raw reply	[relevance 4%]

* Re: ASIS and gnatelim : Will I make it work ?
  2005-05-27 15:00  3% ASIS and gnatelim : Will I make it work ? J�r�me Haguet
@ 2005-05-27 15:05  0% ` Ludovic Brenta
  0 siblings, 0 replies; 195+ results
From: Ludovic Brenta @ 2005-05-27 15:05 UTC (permalink / raw)


Jérôme Haguet writes:
> - With gnat 3.15p on Debian, I get :
>
>    gnatgcc -c -I./ -gnatc -gnatt -I- /home/homes/jerome/CVS-CO/HEAD/my_package_001.adb
>    gnatgcc -c -I./ -gnatc -gnatt -I- /home/homes/jerome/CVS-CO/HEAD/my_package_002.adb
>    ...
>    gnatgcc -c -I./ -gnatc -gnatt -I- /home/homes/jerome/CVS-CO/HEAD/my_package_098.adb
>    +===========================GNAT BUG DETECTED==============================+
>    | 3.15p  (20020523) (i486-pc-linux-gnu) Storage_Error stack overflow (or erroneous memory access)|
>    | Error detected at /home/homes/jerome/CVS-CO/HEAD/my_package_023.adb:137:7
>    [/home/homes/jerome/CVS-CO/HEAD/my_package_025.adb:130:7
>    [/home/homes/jerome/CVS-CO/HEAD/my_package_098:20:4]]|
>    | Please submit bug report by email to ...
>    ...

Is this one of the known bugs? If not, please report it in the Debian
bug tracking system.

> - OK. Let's move to a more recent release.
> As far as I understood, as gcc-4.0.0 includes some Ada0Y improvments, better
> to stay with a Ada95 compiler, let's try with Debian gcc-3.4.4 ...

With both versions (3.4 and 4.0), the Ada 200y features are only
enabled if you pass -gnatX on the command line.  But... ASIS is not
available with either of them, at least from AdaCore.

> This time, things are going further ...
>
>    gcc-3.4 -c -I./ -gnatc -gnatt -I- /home/homes/CVS-CO/HEAD/my_package_001.adb
>    gcc-3.4 -c -I./ -gnatc -gnatt -I- /home/homes/CVS-CO/HEAD/my_package_002.adb
>    ...
>    gcc-3.4 -c -I./ -gnatc -gnatt -I- /home/homes/CVS-CO/HEAD/my_package_199.adb
>
> Now, which gnatelim ?
> Should I build it from source ? Should I use a binary ? Which one ?
> I try both. Without any success.
> With asis-4_0_0-20050203.src, I build it following the instructions and ...
>
>    gnatelim                     license_manager_code_generator
>
>    Unexpected bug in --  GNATELIM (built with ASIS 2.0.R for GNAT 3.4.3)
>    ADA.IO_EXCEPTIONS.END_ERROR was raised: a-textio.adb:631
>    Please report to ...
>
> Any advice ?

My advice is to try to work around the bug in GNAT 3.15p, and use ASIS
3.15p.  Usually, this is not too difficult; a small change in
my_package_023.adb should suffice.

Or, if you feel adventurous, you can try to fix the bug in ASIS for GNAT 4.0.

> Thank you in advance.

-- 
Ludovic Brenta.



^ permalink raw reply	[relevance 0%]

* ASIS and gnatelim : Will I make it work ?
@ 2005-05-27 15:00  3% J�r�me Haguet
  2005-05-27 15:05  0% ` Ludovic Brenta
  0 siblings, 1 reply; 195+ results
From: J�r�me Haguet @ 2005-05-27 15:00 UTC (permalink / raw)


Hello
I try to work with gnatelim, and I faced a few problems ...

- With gnat 3.15p on Windows, I get :

   gcc -c -I./ -gnatc -gnatt -I- c:/CVS-CO/HEAD/my_package_001.adb
   gcc -c -I./ -gnatc -gnatt -I- c:/CVS-CO/HEAD/my_package_002.adb
   ...
   gcc -c -I./ -gnatc -gnatt -I- c:/CVS-CO/HEAD/my_package_125.adb
   gcc -c -I./ -gnatc -gnatt -I- c:/CVS-CO/HEAD/my_package_126.adb
   gnatmake: "c:/CVS-CO/HEAD/my_package_126.adb" compilation error

- With gnat 3.15p on Debian, I get :

   gnatgcc -c -I./ -gnatc -gnatt -I- /home/homes/jerome/CVS-CO/HEAD/my_package_001.adb
   gnatgcc -c -I./ -gnatc -gnatt -I- /home/homes/jerome/CVS-CO/HEAD/my_package_002.adb
   ...
   gnatgcc -c -I./ -gnatc -gnatt -I- /home/homes/jerome/CVS-CO/HEAD/my_package_098.adb
   +===========================GNAT BUG DETECTED==============================+
   | 3.15p  (20020523) (i486-pc-linux-gnu) Storage_Error stack overflow (or erroneous memory access)|
   | Error detected at /home/homes/jerome/CVS-CO/HEAD/my_package_023.adb:137:7
   [/home/homes/jerome/CVS-CO/HEAD/my_package_025.adb:130:7
   [/home/homes/jerome/CVS-CO/HEAD/my_package_098:20:4]]|
   | Please submit bug report by email to ...
   ...

- OK. Let's move to a more recent release.
As far as I understood, as gcc-4.0.0 includes some Ada0Y improvments, better
to stay with a Ada95 compiler, let's try with Debian gcc-3.4.4 ...
This time, things are going further ...

   gcc-3.4 -c -I./ -gnatc -gnatt -I- /home/homes/CVS-CO/HEAD/my_package_001.adb
   gcc-3.4 -c -I./ -gnatc -gnatt -I- /home/homes/CVS-CO/HEAD/my_package_002.adb
   ...
   gcc-3.4 -c -I./ -gnatc -gnatt -I- /home/homes/CVS-CO/HEAD/my_package_199.adb

Now, which gnatelim ?
Should I build it from source ? Should I use a binary ? Which one ?
I try both. Without any success.
With asis-4_0_0-20050203.src, I build it following the instructions and ...

   gnatelim                     license_manager_code_generator

   Unexpected bug in --  GNATELIM (built with ASIS 2.0.R for GNAT 3.4.3)
   ADA.IO_EXCEPTIONS.END_ERROR was raised: a-textio.adb:631
   Please report to ...

Any advice ?

Thank you in advance.





^ permalink raw reply	[relevance 3%]

* Re: gnat: symbolic traceback on exceptions
  @ 2005-05-24 11:05  4%   ` Manuel Collado
  0 siblings, 0 replies; 195+ results
From: Manuel Collado @ 2005-05-24 11:05 UTC (permalink / raw)


Bernd Specht escribi�:
> Manuel Collado <m.collado@lml.ls.fi.upm.es> wrote in 
> news:4291b4ed@news.upm.es:
> 
>>Using gnat 3.15p on WindowsXP. Wanted symbolic traceback automatically 
>>generated on unhandled exceptions. Mainly for student programs.
> 
> Did you try it with AdaGide with switch "Trace exception" set? Compile F3, 
> run F4.

No, I din't. But I've done it now without success. It seems that the 
"Trace exceptions" option lets AdaGide to run the program through an 
"AD" utility that interfaces with GDB. In my machine AD itself seems to 
crash. Example:
------------------------------------
  1
AD: executable=.\a_test.exe


raised CONSTRAINT_ERROR : ad_siph.adb:143
AD crashes... Re-run with /D option for details
Bug report GNAT/DOS: Gautier.deMontmollin@Maths.UniNe.CH
            GNAT/NT:  mcc@cs.usafa.af.mil

raised ADA.IO_EXCEPTIONS.USE_ERROR : s-fileio.adb:813
-------------------------------------

The /D option does nothing.

Thanks, anyway.
-- 
To reply by e-mail, please remove the extra dot
in the given address:  m.collado -> mcollado



^ permalink raw reply	[relevance 4%]

* Re: Using GNAT.Sockets
  @ 2005-04-18 18:23  5%                     ` markp
  0 siblings, 0 replies; 195+ results
From: markp @ 2005-04-18 18:23 UTC (permalink / raw)


I figured out the parameters for the read call.

Data_Type'Read(
   My_Stream_Access,
  Data);

However, when I tried to send a different type of message immediately
after the first one, I get an exception:ADA.IO_EXCEPTIONS.END_ERROR.

What do I need to fix this?

Thanks,

Mark




^ permalink raw reply	[relevance 5%]

* Re: Manifesto against Vector
  @ 2004-05-10 12:13  6%                             ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2004-05-10 12:13 UTC (permalink / raw)


On Mon, 10 May 2004 10:26:38 +0200, Vinzent 'Gadget' Hoefler
<nntp-2004-05@t-domaingrabbing.de> wrote:

>Dmitry A. Kazakov wrote:
>
>>Vinzent 'Gadget' Hoefler wrote:
>>
>>> Dmitry A. Kazakov wrote:
>>> 
>>>>On Thu, 06 May 2004 15:30:42 +0200, Vinzent 'Gadget' Hoefler
>>>><nntp-2004-05@t-domaingrabbing.de> wrote:
>>>>
>>> Well, call me old school or so, but most of the times the only IDE I
>>> use is just a simple text editor.
>>
>>So, here you are. You have to mention *all* used packages, or?
>
>All directly used ones, yes. And I *want* to mention them. :)

Ah, and you surely would define "directly used" as ones mentioned in
"with". Looks much like a vicious circle! (:-))

>>No. "without" would be a contract not to use something. At least it would
>>have some sense. "with" is just a comment.
>
>No it's not just a comment. Yes, it is sort of redundancy. But
>repeating all the function declaration is, too.

It is necessary because their names can be overloaded. Package names
are also repeated in their bodies. No problem with that.

>And nobody seems to complain about that.

There are warts to complain about:

1. The parameter defaults should not be repeated in the
implementation. C++ does it right.

2. There should be a way to make the defaults private. Presently one
should expose them in the public part.

>>So far nobody brought any other
>>argument in its favor.
>
>It tells me, what I am using,

It does not:

1. See above. An incomplete truth is a lie.

2. It tells that to early, defeating the principle: "declare something
as late as you can".

3. What you are using is already said either in a fully qualified name
or in "use".

>it tells the compiler what I am going to
>intend to use. If there is a discrepancy in that I am trying to use
>something which I didn't say so before, the damn stupid compiler will
>complain. That's a *good* thing.

It will complain anyway. And note that it is quite often non-trivial,
especially for a beginner, to design a correct "with" when generics
are in play. That's a *bad* thing.

>>> Just assuming that each argument to pragma Restriction could have two
>>> options only, you could form up to 65536 different profiles alone from
>>> those 16 restrictions defined there.
>>
>>Is it an argument against profiles and restrictions? (:-))
>
>No. It's just an argument against declaring a profile for each
>possible case someone weird could think of. ;)

True. I am feel myself a bit uncomfortable with the idea of profiles.
But it seems that there is no better way. Though, don't you see that
the set of "with" clauses is a kind of profile? Then ...

>You wanted something that could forbid you to use Unchecked_Conversion
>in a project, here you have it. It's the sort of "without" you've
>asked for before.

I didn't ask for it. It was just an example.

>>>>ARM does not specify how unit library works. So even if you write
>>>>"with X", it does not warranty that X will be with-ed, especially when
>>>>it is not in the library. (:-))
>>> 
>>> Well, if it doesn't, it won't compile in the end.
>>
>>So where is any difference between:
>>
>>with Ada.Text_IO;
>>-- with Ada.Text_IO?
>
>That the compiler can tell me that it agrees with me here.

Agree on what? Again, if you bring this argument, then it should be
"without". An unused "with" clause is not an error.

>>>>You have to set up the project, use -I
>>>>key in gnatmake etc. The point is, if this work has to be done in one
>>>>place, why should it be repeated in the source again?
>>> 
>>> Because I want to fucking *know* about it.
>>
>>Put a comment to remember.
>
>NO! I want to be sure and the compiler is a good tool to give me
>confidence about it. I am the one who is making mistakes, so I don't
>rely on anything I've written. Especially if nobody counterchecks if
>this is eventually a case where I was actually right.

Fortunately the compiler *always* checks all names.

>>>>The difference is that
>>>>Ada allows view management. To drop this idea, essential for building
>>>>and maintaining large layered system, just because of a moss-grown
>>>>language where types and subroutines are global, that would be at
>>>>least unwise.
>>> 
>>> Yes, but this is exactly what "use" without "with" would be then (well
>>> well, not quite). But all the "use"s could then be scattered all over
>>> the source file
>>
>>Sorry, but you support this principle, i.e. "move "use" as far down as you
>>can".
>
>Yes. But before I do that I "with" everything I "use" at the first
>lines of the source. So I *know* if some module is fiddling around
>with the programmable address region registers for instance.

This clearly violates the principle. BTW it would also require that no
"with" be allowed in the bodies.

You should first decide whether "with X" is *always* a contract and
never an implementation detail. Once you agree that it might be the
later, then you should also agree that it would be better to deduce
it, when possible.

My position is that in many cases "with" constitutes no contract. If
it yet appears to do, then probably the package should be made a
child.

>>Only if it is "with use". I talked about "use" implying with.
>
>That's even worse. Now the only way to find out if the source is
>actually messing around with some of the nastier parts of the hardware
>is - to read each whole sourcefile.

I do not understand this. The package name is specified in "use".

>>>>>>Then semantics of renaming is inconsitent with one of "use", or better
>>>>>>to say, simply inconsistent. This is the source of numerous problems:
>>>>>>
>>> [...]
>>>>>>   when X_Error =>
>>>>>>      -- This is OK, multiple views of same thing
>>>>>>      ...
>>>>>>   when End_Error =>
>>>>>>      -- This is illegal, viewing two different views of one thing!
>>>>>>      ...
>>>>>>end C;
>>>>>
>>>>>See. That's a perfect example for a "use"-Problem, which I simply want
>>>>>to avoid (and which I want to do consistently):
>>>>
>>>>No, "use" is consistent.
>>> 
>>> Yes. I didn't say otherwise. I just mentioned that it can cause
>>> problems as you illustrated here.
>>
>>The problems are caused solely by renaming.
>
>The problem is because you have the same name in two packages which
>the compiler is bound *not* to resolve autoamtically in any way.

Names are always resolved.

>>>>What is inconsistent, is that renaming of an
>>>>exception creates a view colliding with a view of the renamed thing.
>>> 
>>> No, not exactly, we're talking about different packages here.
>>
>>It is no matter. [BTW, renaming A to B does not create any new package. If
>>renaming would be consistently inconsistent (:-)), it would clash in
>>"use"-ing both A and B!]
>
>No. It doesn't even clash if you use "Ada.Text_IO" twice. So why
>should it here?

According to your [wrong] theory it should, because once I have
renamed A to B, I have different names A.* and B.* which should
collide.

>>> What
>>> you've created here was:
>>> 
>>> |A.End_Error;
>>> |B.End_Error;
>>> 
>>> and (not exactly created)
>>> 
>>> |Ada.Exceptions.End_Error;
>>> 
>>> Yes, because of the renaming in this example those are all the same
>>> thing.
>>> 
>>> _But_: the compiler does not want to know about the implementation.
>>> So, because nobody can hinder me to change the definition in A and/or
>>> B later, it won't know [and even if it does, it does not *want* to ;)]
>>> that all these names all denote the same entity. So when you said just
>>> "End_Error", the compiler could not know which one to choose, of
>>> course. Really, it does not matter that all these names in fact just
>>> accidently denote the same entity, they are not bound to do this each
>>> time.
>>
>>Wrong. The example was *not* a case of implementation through renaming.
>
>The compiler sees a package. It sees a name for one or more entities
>there and their corresponding type. That's it. It doesn't care about
>any implementation at this stage. This gets resolved later. (At least
>that's what I'd say.)

Wrong. Observe that the following is illegal in Ada:

with Ada.IO_Exceptions;
procedure Test is
   End_Error : exception renames Ada.IO_Exceptions.End_Error;
begin
   null;
exception
   when End_Error => null;
   when Ada.IO_Exceptions.End_Error => null;
end Test;

End_Error and Ada.IO_Exceptions.End_Error is the same thing. And the
compiler perfectly *knows* that. Your theory that renaming is an
implementation is wrong.

>>>>How could names indicating the same thing conflict?
>>> 
>>> Because they are not in the same view.
>>> 
>>> Just because someone writes "Foo : constant Some_Type;" and another
>>> "Bar : constant Some_Type;" and in the private part they *are* the
>>> same that doesn't mean, you will *not* sooner or later run into
>>> problems when you just randomly interchange them in your code.
>>
>>There is absolutely no problem with that, if you mean Foo privately renaming
>>Bar. In public view there are two *different* Some_Type, because you have
>>an implementation through renaming. On the contrary in private view there
>>should be only one object!
>
>So what's the difference here? Why shouldn't the compiler know about
>the more private parts (in fact, at some stage it needs to know at
>least to preserve enough storage space for the type) here?

The difference is that the public part is a contract to fulfil. If it
states that Foo is not Bar, then they should appear as such. The
implementation (private part) may privately change this, if necessary,
but that may have no influence on the contract.

>>>>What is overloaded here to cause the conflict?
>>> 
>>> Common sense?
>>> 
>>> Who tells you that A.End_Error and B.End_Error have to remain the same
>>> in all eternity,
>>
>>They were declared as such. This is the contract, because it happened in the
>>public part.
>
>And where in the contract does A know about that it will be renamed by
>B?

Does that matter?

>>> just because they were at the very moment you used
>>> them?
>>
>>See above. If the program designer had an intention to keep them separate
>>he/she should have chosen other design.
>
>Quick prototyping? Just filling out some blanks so that it *will*
>compile some of the more important rest?

To do that one needs no renaming. One should just declare End_Error as
an independent exception.

>>>>What is the sense of the
>>>>conflict? Something unresolved, ambiguous, what?
>>> 
>>> The possibility that a simple change would break the project that
>>> compiled perfectly.
>>
>>The project will cease to compile. This is what we have *NOW*.
>
>No, not if you don't use "use". So we're back at the evil that causes
>the problem.

See my example. It will never compile, because either with or without
"use" A.End_Error is Ada.IO_Exceptions.End_Error.

--
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Manifesto against Vector
  @ 2004-05-09 20:34  3%                         ` Dmitry A. Kazakov
    0 siblings, 1 reply; 195+ results
From: Dmitry A. Kazakov @ 2004-05-09 20:34 UTC (permalink / raw)


Vinzent 'Gadget' Hoefler wrote:

> Dmitry A. Kazakov wrote:
> 
>>On Thu, 06 May 2004 15:30:42 +0200, Vinzent 'Gadget' Hoefler
>><nntp-2004-05@t-domaingrabbing.de> wrote:
>>
>>>Dmitry A. Kazakov wrote:
>>>
>>>>On Thu, 06 May 2004 11:41:11 +0200, Vinzent 'Gadget' Hoefler
>>>><nntp-2004-05@t-domaingrabbing.de> wrote:
>>>>
>>>>>Dmitry A. Kazakov wrote:
>>>>>
>>>>>>Why that should be told? I'd say that "with" is superfluous.
>>>>>
>>>>>No! If at all then it is "use" which is superfluous. ;-)
>>>>
>>>>How so? "Use" has some semantical sense. It changes visibility. You
>>>>might claim that this is not necessary, but that would be another
>>>>story. On the contrary "with" has no other sense than being just a
>>>>hint to the compiler/linker.
>>>
>>>And a idea to me which packages another one is using.
>>
>>Either you agree on that IDE could tell you that better, or I would
>>claim that all packages with-ed implicitly should be made explicit!
>>(:-))
> 
> Well, call me old school or so, but most of the times the only IDE I
> use is just a simple text editor.

So, here you are. You have to mention *all* used packages, or?

> And sometimes I am just using the ssh-connection to a simple
> text-based terminal to change some lines of code. No place for a big
> IDE keeping track of everything here.

I hope that it is not Ada's design goal to support programming over modem
connections? Anyway, if you want to use "slow-connection/typewriter-use"
argument, then note that it works against both "with" and full names.

>>>This is
>>>especially useful with some of the more "evil" parts of Ada like
>>>Unchecked_Conversion. :)
>>
>>Then it it should be "without"!
> 
> Hmm.
> 
> You mean instead of:
> 
> |with Elan520.Basic_Types;
> |with Elan520.CPU_Registers;
> |with Elan520.MMCR;
> |with Elan520.Programmable_Address_Region;
> |with Elan520.Registers;
> |with Elan520.SDRAM_Controller_Registers;
> |
> |package body Elan520 is [...]
> 
> I should simply write:
> 
> |without Ada.*;
> |without System.*;
> |without Unchecked_*;

No. "without" would be a contract not to use something. At least it would
have some sense. "with" is just a comment. So far nobody brought any other
argument in its favor.

> Just assuming that each argument to pragma Restriction could have two
> options only, you could form up to 65536 different profiles alone from
> those 16 restrictions defined there.

Is it an argument against profiles and restrictions? (:-)) Honestly, I would
agree, they erode the language. But it is an inevitable evil.

>>ARM does not specify how unit library works. So even if you write
>>"with X", it does not warranty that X will be with-ed, especially when
>>it is not in the library. (:-))
> 
> Well, if it doesn't, it won't compile in the end.

So where is any difference between:

with Ada.Text_IO;
-- with Ada.Text_IO?

>>You have to set up the project, use -I
>>key in gnatmake etc. The point is, if this work has to be done in one
>>place, why should it be repeated in the source again?
> 
> Because I want to fucking *know* about it.

Put a comment to remember. For example: 

A.B.C.D.E := 2;
  -- We need A
  -- We need A.B too
  -- Not to forget: A.B.C
  -- And A.B.C.D, of course

>>>(BTW, for that discussion it might be funny to note that these days
>>>even more and more of the C++-folks consider "using some_namespace;"
>>>to be evil. And now we want to encourage to do exactly the opposite of
>>>that in Ada?)
>>
>>Because Ada was designed with "use" in mind!
> 
> Hmm. What's wrong with that? ;)

I have asked first! (:-))

>>The difference is that
>>Ada allows view management. To drop this idea, essential for building
>>and maintaining large layered system, just because of a moss-grown
>>language where types and subroutines are global, that would be at
>>least unwise.
> 
> Yes, but this is exactly what "use" without "with" would be then (well
> well, not quite). But all the "use"s could then be scattered all over
> the source file

Sorry, but you support this principle, i.e. "move "use" as far down as you
can". You can replace it with another - "start with "use"". Even if you
want both, fine, Ada supports this too, multiple "uses" of the package are
OK!

> and no human would know about what really *is* used
> without reading the whole source file.

Why a human should know? The point is that "use" helps a reader to
understand the program. If it does not, do not use it. If it does, then its
mission is over, there is nothing to "know" here. As simple as that.

>>>For me it is still the same principle: Make something as local as you
>>>can. No matter if it is a variable, a procedure, ... or a namespace.
>>
>>I didn't object this principle.
> 
> Well, the "with use Something;" (or whatever someone might like to see
> instead) which was proposed would violate this principle. :)

Only if it is "with use". I talked about "use" implying with. That would be
compatible with any principle, even with one requiring avoiding "use"!
(:-))

>>>>Then semantics of renaming is inconsitent with one of "use", or better
>>>>to say, simply inconsistent. This is the source of numerous problems:
>>>>
> [...]
>>>>   when X_Error =>
>>>>      -- This is OK, multiple views of same thing
>>>>      ...
>>>>   when End_Error =>
>>>>      -- This is illegal, viewing two different views of one thing!
>>>>      ...
>>>>end C;
>>>
>>>See. That's a perfect example for a "use"-Problem, which I simply want
>>>to avoid (and which I want to do consistently):
>>
>>No, "use" is consistent.
> 
> Yes. I didn't say otherwise. I just mentioned that it can cause
> problems as you illustrated here.

The problems are caused solely by renaming.

>>What is inconsistent, is that renaming of an
>>exception creates a view colliding with a view of the renamed thing.
> 
> No, not exactly, we're talking about different packages here.

It is no matter. [BTW, renaming A to B does not create any new package. If
renaming would be consistently inconsistent (:-)), it would clash in
"use"-ing both A and B!]

> What
> you've created here was:
> 
> |A.End_Error;
> |B.End_Error;
> 
> and (not exactly created)
> 
> |Ada.Exceptions.End_Error;
> 
> Yes, because of the renaming in this example those are all the same
> thing.
> 
> _But_: the compiler does not want to know about the implementation.
> So, because nobody can hinder me to change the definition in A and/or
> B later, it won't know [and even if it does, it does not *want* to ;)]
> that all these names all denote the same entity. So when you said just
> "End_Error", the compiler could not know which one to choose, of
> course. Really, it does not matter that all these names in fact just
> accidently denote the same entity, they are not bound to do this each
> time.

Wrong. The example was *not* a case of implementation through renaming. In
which case you were right. For example:

-- This is not Ada!
package A is
   End_Error : exception is private; -- Will be defined later
private
   End_Error : exception renames Ada.IO_Exceptions.End_Error;

> Remember that Ada is about software engineering and this includes
> being able to compile something even without having the actual
> implementation of some other packages as long as the interface is
> known.

This has nothing to do with renaming [*].

>>>the compiler could figure this out by itself. But if
>>>it would really do that, it then would be me to call this behaviour
>>>inconsistent.
>>
>>Don't you agree that there is a difference between views and viewed
>>things?
> 
> Well, sort of. Yes.

Then re-read your arguments, and choose something! (:-))

>>How could names indicating the same thing conflict?
> 
> Because they are not in the same view.
> 
> Just because someone writes "Foo : constant Some_Type;" and another
> "Bar : constant Some_Type;" and in the private part they *are* the
> same that doesn't mean, you will *not* sooner or later run into
> problems when you just randomly interchange them in your code.

There is absolutely no problem with that, if you mean Foo privately renaming
Bar. In public view there are two *different* Some_Type, because you have
an implementation through renaming. On the contrary in private view there
should be only one object!

>>What is overloaded here to cause the conflict?
> 
> Common sense?
> 
> Who tells you that A.End_Error and B.End_Error have to remain the same
> in all eternity,

They were declared as such. This is the contract, because it happened in the
public part.

> just because they were at the very moment you used
> them?

See above. If the program designer had an intention to keep them separate
he/she should have chosen other design.

>>What is the sense of the
>>conflict? Something unresolved, ambiguous, what?
> 
> The possibility that a simple change would break the project that
> compiled perfectly.

The project will cease to compile. This is what we have *NOW*. And, well,
hire better programmers! (:-))

>>then you should have gone further:
>>"Never use child packages, they are globally using their parents!"
> 
> Yes, they do. Of course they do: Logically such a package hierarchy is
> just a big single package. The fact that you *do* break it into more
> small packages and thus be able to control the views into it in some
> finer granularity doesn't break anything here.
> 
> A subroutine inside a soubroutine can see its "parent", too. I don't
> see any problem involved here.

Child packages are just a form of "with/use".

---
*) Except view changing renamings, which alas are also inconsistent in Ada.

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[relevance 3%]

* Re: Manifesto against Vector
  2004-05-06 13:30  0%                   ` Vinzent 'Gadget' Hoefler
@ 2004-05-07  8:23  0%                     ` Dmitry A. Kazakov
    0 siblings, 1 reply; 195+ results
From: Dmitry A. Kazakov @ 2004-05-07  8:23 UTC (permalink / raw)


On Thu, 06 May 2004 15:30:42 +0200, Vinzent 'Gadget' Hoefler
<nntp-2004-05@t-domaingrabbing.de> wrote:

>Dmitry A. Kazakov wrote:
>
>>On Thu, 06 May 2004 11:41:11 +0200, Vinzent 'Gadget' Hoefler
>><nntp-2004-05@t-domaingrabbing.de> wrote:
>>
>>>Dmitry A. Kazakov wrote:
>>>
>>>>Why that should be told? I'd say that "with" is superfluous.
>>>
>>>No! If at all then it is "use" which is superfluous. ;-)
>>
>>How so? "Use" has some semantical sense. It changes visibility. You
>>might claim that this is not necessary, but that would be another
>>story. On the contrary "with" has no other sense than being just a
>>hint to the compiler/linker.
>
>And a idea to me which packages another one is using.

Either you agree on that IDE could tell you that better, or I would
claim that all packages with-ed implicitly should be made explicit!
(:-))

>This is
>especially useful with some of the more "evil" parts of Ada like
>Unchecked_Conversion. :)

Then it it should be "without"!

BTW Ada will now have a notion of profile (like Ravenscar). It would
be nice to have an ability to define a profile, a contract of using
some definite subset of Ada. Like one without instantiations of
Unchecked_Conversion.

>>It could well be just a pragma, like the
>>elaboration control ones.
>
>Yes. Or like the C pragmas that tells the Preprocessor which files it
>should include to get all the prototype-declarations. Well, sometimes
>it even works without these, yes. Do you really *want* it to work in a
>similar way? I don't.

ARM does not specify how unit library works. So even if you write
"with X", it does not warranty that X will be with-ed, especially when
it is not in the library. (:-)) You have to set up the project, use -I
key in gnatmake etc. The point is, if this work has to be done in one
place, why should it be repeated in the source again?

>(BTW, for that discussion it might be funny to note that these days
>even more and more of the C++-folks consider "using some_namespace;"
>to be evil. And now we want to encourage to do exactly the opposite of
>that in Ada?)

Because Ada was designed with "use" in mind! The difference is that
Ada allows view management. To drop this idea, essential for building
and maintaining large layered system, just because of a moss-grown
language where types and subroutines are global, that would be at
least unwise.

>For me it is still the same principle: Make something as local as you
>can. No matter if it is a variable, a procedure, ... or a namespace.

I didn't object this principle.

>>Then semantics of renaming is inconsitent with one of "use", or better
>>to say, simply inconsistent. This is the source of numerous problems:
>>
>>with Ada.IO_Exceptions;
>>package A is
>>   End_Error : exception renames Ada.IO_Exceptions.End_Error;
>>   X_Error : exception;
>>end A;
>>--------
>>with A;
>>package B renames A;
>>--------
>>with A; use A;
>>with B; use B;
>>with Ada.IO_Exceptions; use Ada.IO_Exceptions;
>>procedure C is
>>begin
>>   ...
>>exception
>>   when X_Error =>
>>      -- This is OK, multiple views of same thing
>>      ...
>>   when End_Error =>
>>      -- This is illegal, viewing two different views of one thing!
>>      ...
>>end C;
>
>See. That's a perfect example for a "use"-Problem, which I simply want
>to avoid (and which I want to do consistently):

No, "use" is consistent. When you use something twice, that does not
create additional views. What is inconsistent, is that renaming of an
exception creates a view colliding with a view of the renamed thing.

[...]

>I don't know what this has to do with renaming. If you'd declare
>End_Error separately in the packages you would run into the same
>problem, so in fact it is a "use" problem.

>Well, you might argue, just because you renamed it and thus in fact is
>exactly the same,

Yes I do.

>the compiler could figure this out by itself. But if
>it would really do that, it then would be me to call this behaviour
>inconsistent.

Don't you agree that there is a difference between views and viewed
things? How could names indicating the same thing conflict? What is
overloaded here to cause the conflict? What is the sense of the
conflict? Something unresolved, ambiguous, what? 

>>>It's much more simple: Never use "use". :)
>>
>>Once I will become a rich man, I will buy a LCD with horizontal
>>resolution of 10240 pixels, install small fonts, get spectacles ...
>>(:-))
>
>Considering I don't use "use" globally[0] and even restrict myself to
>72 columns, I don't really understand that part of the problem. :)

There is no problem. Just if you were consistently against any view
management, then you should have gone further:

"Never use child packages, they are globally using their parents!"

--
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[relevance 0%]

* Re: Manifesto against Vector
  2004-05-06 12:44  6%                 ` Dmitry A. Kazakov
@ 2004-05-06 13:30  0%                   ` Vinzent 'Gadget' Hoefler
  2004-05-07  8:23  0%                     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Vinzent 'Gadget' Hoefler @ 2004-05-06 13:30 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

>On Thu, 06 May 2004 11:41:11 +0200, Vinzent 'Gadget' Hoefler
><nntp-2004-05@t-domaingrabbing.de> wrote:
>
>>Dmitry A. Kazakov wrote:
>>
>>>Why that should be told? I'd say that "with" is superfluous.
>>
>>No! If at all then it is "use" which is superfluous. ;-)
>
>How so? "Use" has some semantical sense. It changes visibility. You
>might claim that this is not necessary, but that would be another
>story. On the contrary "with" has no other sense than being just a
>hint to the compiler/linker.

And a idea to me which packages another one is using. This is
especially useful with some of the more "evil" parts of Ada like
Unchecked_Conversion. :)

>It could well be just a pragma, like the
>elaboration control ones.

Yes. Or like the C pragmas that tells the Preprocessor which files it
should include to get all the prototype-declarations. Well, sometimes
it even works without these, yes. Do you really *want* it to work in a
similar way? I don't.

(BTW, for that discussion it might be funny to note that these days
even more and more of the C++-folks consider "using some_namespace;"
to be evil. And now we want to encourage to do exactly the opposite of
that in Ada?)

>>>Maybe, but it should be placed at the beginning of the context. So it
>>>is just one line difference. Not a big issue, IMO.
>>
>>It is more than a single line. Consider this:
>>
>>|with Interfaces;
>> ^^^^
>>|
>>|package body Timer is
>>|
>>[...]
>>|   function Hi_Byte (Value : in Interfaces.Unsigned_16)
>>|     return Interfaces.Unsigned_8 is
>>|      use type Interfaces.Unsigned_16;
>>       ^^^
>>|   begin
>>|      return Interfaces.Unsigned_8 (
>>|          Interfaces.Shift_Right (Value, 8) and 16#FF#);
>>|   end Hi_Byte;
>
>We have no "with type" clause, so this example is incorrect.

Well, then read "use Interfaces;" instead and imagine all the packages
prefixes would go away then.

For me it is still the same principle: Make something as local as you
can. No matter if it is a variable, a procedure, ... or a namespace.

>>>with Foo;
>>>procedure P (<something here needs visibility of Foo>);
>>
>>Simple: Use the full name there. If it's too long for you, I'd say
>>rename it.
>
>It cannot be. P is a unit! (:-))

Hmm, what the heck? I was under the impression that

|subtype Sys_Addr is System.Address;
|
|procedure (foo : Sys_Addr)

would work.

>Then semantics of renaming is inconsitent with one of "use", or better
>to say, simply inconsistent. This is the source of numerous problems:
>
>with Ada.IO_Exceptions;
>package A is
>   End_Error : exception renames Ada.IO_Exceptions.End_Error;
>   X_Error : exception;
>end A;
>--------
>with A;
>package B renames A;
>--------
>with A; use A;
>with B; use B;
>with Ada.IO_Exceptions; use Ada.IO_Exceptions;
>procedure C is
>begin
>   ...
>exception
>   when X_Error =>
>      -- This is OK, multiple views of same thing
>      ...
>   when End_Error =>
>      -- This is illegal, viewing two different views of one thing!
>      ...
>end C;

See. That's a perfect example for a "use"-Problem, which I simply want
to avoid (and which I want to do consistently):

|c.adb:12:09: "End_Error" is not visible
|c.adb:12:09: multiple use clauses cause hiding
                       ^^^^^^^^^^^
|c.adb:12:09: hidden declaration at a.ads:3
|c.adb:12:09: hidden declaration at a-ioexce.ads:26
|gnatmake: "c.adb" compilation error

when you specify:

|   when A.End_Error =>

instead it surprisingly works. And if you always do that, there is
even no inconsistency that you sometimes use the short name and
sometimes the fully specified name "randomly" all over a package, just
depending on which packages you've just had to use and where the
compiler complained about not wanting to know what to do.

I don't know what this has to do with renaming. If you'd declare
End_Error separately in the packages you would run into the same
problem, so in fact it is a "use" problem.

Well, you might argue, just because you renamed it and thus in fact is
exactly the same, the compiler could figure this out by itself. But if
it would really do that, it then would be me to call this behaviour
inconsistent.

>>It's much more simple: Never use "use". :)
>
>Once I will become a rich man, I will buy a LCD with horizontal
>resolution of 10240 pixels, install small fonts, get spectacles ...
>(:-))

Considering I don't use "use" globally[0] and even restrict myself to
72 columns, I don't really understand that part of the problem. :)


Vinzent.

[0] And even locally I use "use" in relatively seldom circumstances,
the above "use type" is just because I consider the line
  | return Interfaces.Unsigned_8 (
  |   Interfaces."and" (Interfaces.Shift_Right (Value, 8), 16#FF#));
a little bit to much overkill even for my attitude to not using "use"
as much as I can't. Especially because this whole messy line just
compiles to a single "shrw $8, %ax". :)



^ permalink raw reply	[relevance 0%]

* Re: Manifesto against Vector
  @ 2004-05-06 12:44  6%                 ` Dmitry A. Kazakov
  2004-05-06 13:30  0%                   ` Vinzent 'Gadget' Hoefler
  0 siblings, 1 reply; 195+ results
From: Dmitry A. Kazakov @ 2004-05-06 12:44 UTC (permalink / raw)


On Thu, 06 May 2004 11:41:11 +0200, Vinzent 'Gadget' Hoefler
<nntp-2004-05@t-domaingrabbing.de> wrote:

>Dmitry A. Kazakov wrote:
>
>>On Thu, 6 May 2004 09:03:54 +0200, "Jean-Pierre Rosen"
>><rosen@adalog.fr> wrote:
>>
>>>Since you asked for it... (but I'll try to have reasonable objections).
>>>Note that I am known for being strongly *in favor* of the use clause.
>>>
>>>I would strongly oppose this proposal for a very simple reason: it
>>>defeats the main goal of having separated with from use.
>>>With is a library level clause; it tells: "this unit, somewhere needs
>>>that unit".
>>
>>Why that should be told? I'd say that "with" is superfluous.
>
>No! If at all then it is "use" which is superfluous. ;-)

How so? "Use" has some semantical sense. It changes visibility. You
might claim that this is not necessary, but that would be another
story. On the contrary "with" has no other sense than being just a
hint to the compiler/linker. It could well be just a pragma, like the
elaboration control ones.

>>Maybe, but it should be placed at the beginning of the context. So it
>>is just one line difference. Not a big issue, IMO.
>
>It is more than a single line. Consider this:
>
>|with Interfaces;
> ^^^^
>|
>|package body Timer is
>|
>[...]
>|   function Hi_Byte (Value : in Interfaces.Unsigned_16)
>|     return Interfaces.Unsigned_8 is
>|      use type Interfaces.Unsigned_16;
>       ^^^
>|   begin
>|      return Interfaces.Unsigned_8 (
>|          Interfaces.Shift_Right (Value, 8) and 16#FF#);
>|   end Hi_Byte;

We have no "with type" clause, so this example is incorrect.

>>with Foo;
>>procedure P (<something here needs visibility of Foo>);
>
>Simple: Use the full name there. If it's too long for you, I'd say
>rename it.

It cannot be. P is a unit! (:-))

Then semantics of renaming is inconsitent with one of "use", or better
to say, simply inconsistent. This is the source of numerous problems:

with Ada.IO_Exceptions;
package A is
   End_Error : exception renames Ada.IO_Exceptions.End_Error;
   X_Error : exception;
end A;
--------
with A;
package B renames A;
--------
with A; use A;
with B; use B;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
procedure C is
begin
   ...
exception
   when X_Error =>
      -- This is OK, multiple views of same thing
      ...
   when End_Error =>
      -- This is illegal, viewing two different views of one thing!
      ...
end C;

>>>Allowing with/use would simply encourage a style that should be
>>>discouraged altogether. QED.
>>
>>Oh, Use is Use, and With is With, and never the twain shall meet, ...
>>(:-))
>
>It's much more simple: Never use "use". :)

Once I will become a rich man, I will buy a LCD with horizontal
resolution of 10240 pixels, install small fonts, get spectacles ...
(:-))

--
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Error-names.
  2004-02-29 23:43  4%       ` Error-names tmoran
@ 2004-03-01 11:20  0%         ` Martin Klaiber
  0 siblings, 0 replies; 195+ results
From: Martin Klaiber @ 2004-03-01 11:20 UTC (permalink / raw)


tmoran@acm.org wrote:

>  It would not be hard to leave out, or have multiple uses of, an error
> code, as in:
>    Constraint_Error_Code : constant Exception_Codes := -10;
>    Program_Error_Code    : constant Exception_Codes := -9;
>    Storage_Error_Code    : constant Exception_Codes := -9;
>    Status_Error_Code     : constant Exception_Codes := -7;
>    My_Special_Error_Code : constant Exception_Codes := -5;
>    ...
> Similarly, a new exception might be added, but someone forgets to
> add it to the if-elsif list.

> With the if-elsif style you can only hope that neither of those happens.
> But if you do

>    Coded_Exception_List : constant array(Exception_Codes)
>    of Ada.Exceptions.Exception_ID
>      := (Constraint_Error_Code => Constraint_Error'Identity,
>          Program_Error_Code    => Program_Error'Identity,
>          Storage_Error_Code    => Storage_Error'Identity,
>          IO_Status_Error_Code  => Ada.IO_Exceptions.Status_Error'Identity,
>          My_Special_Error_Code => My_Special_Exception'Identity,
>          ...
> then the compiler will warn you if two of your error codes are the
> same, or if you've left any out in the Exception_Codes range.

This is right but how can I export the constants then?  At the moment
I use in the spec-file:

   -- No error:
   No_Error_Code : constant C_Integer := 0;
   pragma export (C, No_Error_Code, "no_error_code");

   -- Fallback:
   General_Error_Code : constant C_Integer := -1;
   pragma export (C, General_Error_Code, "general_error_code");

and so on.  The reason is that I want the C-programmer to use the
constants-names instead of the values, because I can't guarantee that
the values will not change in the future.

BTW: does someone know why these constants are not recognized by the
C-program as constants?  They are declared as constants and in the C
header-file I put:

   /* error-codes */

   extern const int no_error_code;
   extern const int general_error_code;
   ...

But if I want to use it in a switch-command like that:

   int year;
   ...
   for (year = 2003; year <= 2005; ++year) {
      switch (set_year (year)) {
      case no_error_code :
         set_lzz (1);
         ...
                         
the compiler says:

   test_c.c:20: case label does not reduce to an integer constant

Is my exporting wrong?  Or is this a C-problem?  When I use "case 0"
instead of "case no_error_code" it works ok, but this is what I want
to avoid.

Thanks,
Martin



^ permalink raw reply	[relevance 0%]

* Re: Error-names.
  2004-02-29 20:33  0%     ` Error-names Martin Klaiber
@ 2004-02-29 23:43  4%       ` tmoran
  2004-03-01 11:20  0%         ` Error-names Martin Klaiber
  0 siblings, 1 reply; 195+ results
From: tmoran @ 2004-02-29 23:43 UTC (permalink / raw)


>   function Get_Error_Code (E : Exception_Occurrence) return C_Integer is
>   begin
>       if Exception_Identity (E) = Program_Error'Identity then
>           return Program_Error_Code;
>       elsif Exception_Identity (E) = Constraint_Error'Identity then
>           return Constraint_Error_Code;
>       elsif ...
  "Use the Force, Luke", or more specifically, Let the Ada compiler
help you find and eliminate errors.

  It would not be hard to leave out, or have multiple uses of, an error
code, as in:
    Constraint_Error_Code : constant Exception_Codes := -10;
    Program_Error_Code    : constant Exception_Codes := -9;
    Storage_Error_Code    : constant Exception_Codes := -9;
    Status_Error_Code     : constant Exception_Codes := -7;
    My_Special_Error_Code : constant Exception_Codes := -5;
    ...
Similarly, a new exception might be added, but someone forgets to
add it to the if-elsif list.

With the if-elsif style you can only hope that neither of those happens.
But if you do

    Coded_Exception_List : constant array(Exception_Codes)
    of Ada.Exceptions.Exception_ID
      := (Constraint_Error_Code => Constraint_Error'Identity,
          Program_Error_Code    => Program_Error'Identity,
          Storage_Error_Code    => Storage_Error'Identity,
          IO_Status_Error_Code  => Ada.IO_Exceptions.Status_Error'Identity,
          My_Special_Error_Code => My_Special_Exception'Identity,
          ...
then the compiler will warn you if two of your error codes are the
same, or if you've left any out in the Exception_Codes range.
  It also has the (possible) advantage that you can trivially translate
a code back into an exception:
  Ada.Exceptions.Raise_Exception(Coded_Exception_List(Code), Message);



^ permalink raw reply	[relevance 4%]

* Re: Error-names.
  2004-02-29 19:03  0%   ` Error-names Jeffrey Carter
@ 2004-02-29 20:33  0%     ` Martin Klaiber
  2004-02-29 23:43  4%       ` Error-names tmoran
  0 siblings, 1 reply; 195+ results
From: Martin Klaiber @ 2004-02-29 20:33 UTC (permalink / raw)


Jeffrey Carter <spam@spam.com> wrote:
> tmoran@acm.org wrote:

>>   subtype Exception_Codes is Interfaces.C.Int range -10 .. 1;

>>   Coded_Exception_List : constant array(Exception_Codes)
>>     := (Constraint_Error'Identity,
>>         Program_Error'Identity,
>>         Storage_Error'Identity,
>>         Tasking_Error'Identity,
>>         Ada.IO_Exceptions.Status_Error'Identity,
>>         Ada.IO_Exceptions.Mode_Error'Identity,
>>         Ada.IO_Exceptions.Name_Error'Identity,
>>         ...

>>   function Error_Code_Of(E : Ada.Exceptions.Exception_Occurrence)
>>   return Exception_Codes is
>>     use Ada.Exceptions;
>>   begin
>>     for i in Coded_Exception_List'range loop
>>       if Exception_Identity(E) = Coded_Exception_List(i) then
>>         return i;
>>       end if;
>>     end loop;
>>     raise; -- we have no code for this exception!  re-raise it
>>   end Error_Code_Of;

> This is pretty much what I would have suggested if Moran hadn't beat me 
> to it. However, I think you can't use "raise" here without an exception 
> name, since we're not necessarily in an exception handler. You could use 
> Ada.Exceptions.Raise_Exception (E), but I suspect what is really wanted, 
> based on the OP's earlier messages, is to return General_Error_Code.

Yes, General_Error_Code shall be a fallback in case there is no special
handler for a certain exception.  I implemented it like this:

    function Get_Error_Code (E : Exception_Occurrence) return C_Integer is
    begin
        if Exception_Identity (E) = Program_Error'Identity then
            return Program_Error_Code;
        elsif Exception_Identity (E) = Constraint_Error'Identity then
            return Constraint_Error_Code;
        elsif ...
            ...
        else
            return General_Error_Code;
        end if;
    end Get_Error_Code;

Not as elegant as Toms(?) code with the array but it works ok.

It's a pity that I can't use "case" instead of "if".  The compiler
moans that Exception_Id is not a discrete type.

Martin



^ permalink raw reply	[relevance 0%]

* Re: Error-names.
  2004-02-28 19:47  6% ` Error-names tmoran
@ 2004-02-29 19:03  0%   ` Jeffrey Carter
  2004-02-29 20:33  0%     ` Error-names Martin Klaiber
  0 siblings, 1 reply; 195+ results
From: Jeffrey Carter @ 2004-02-29 19:03 UTC (permalink / raw)


tmoran@acm.org wrote:
> 
>   subtype Exception_Codes is Interfaces.C.Int range -10 .. 1;
> 
>   Coded_Exception_List : constant array(Exception_Codes)
>     := (Constraint_Error'Identity,
>         Program_Error'Identity,
>         Storage_Error'Identity,
>         Tasking_Error'Identity,
>         Ada.IO_Exceptions.Status_Error'Identity,
>         Ada.IO_Exceptions.Mode_Error'Identity,
>         Ada.IO_Exceptions.Name_Error'Identity,
>         ...
> 
>   function Error_Code_Of(E : Ada.Exceptions.Exception_Occurrence)
>   return Exception_Codes is
>     use Ada.Exceptions;
>   begin
>     for i in Coded_Exception_List'range loop
>       if Exception_Identity(E) = Coded_Exception_List(i) then
>         return i;
>       end if;
>     end loop;
>     raise; -- we have no code for this exception!  re-raise it
>   end Error_Code_Of;

This is pretty much what I would have suggested if Moran hadn't beat me 
to it. However, I think you can't use "raise" here without an exception 
name, since we're not necessarily in an exception handler. You could use 
Ada.Exceptions.Raise_Exception (E), but I suspect what is really wanted, 
based on the OP's earlier messages, is to return General_Error_Code.

-- 
Jeff Carter
"No one is to stone anyone until I blow this whistle,
do you understand? Even--and I want to make this
absolutely clear--even if they do say, 'Jehova.'"
Monty Python's Life of Brian
74




^ permalink raw reply	[relevance 0%]

* Re: Error-names.
  @ 2004-02-28 19:47  6% ` tmoran
  2004-02-29 19:03  0%   ` Error-names Jeffrey Carter
  0 siblings, 1 reply; 195+ results
From: tmoran @ 2004-02-28 19:47 UTC (permalink / raw)


>Well, if I understand it right, I still have to distinguish between
>the different exceptions before I call Error_Code_Of, is this right?
 No.
> > when E : others => return Error_Code_Of (E);
works fine.

  subtype Exception_Codes is Interfaces.C.Int range -10 .. 1;

  Coded_Exception_List : constant array(Exception_Codes)
    := (Constraint_Error'Identity,
        Program_Error'Identity,
        Storage_Error'Identity,
        Tasking_Error'Identity,
        Ada.IO_Exceptions.Status_Error'Identity,
        Ada.IO_Exceptions.Mode_Error'Identity,
        Ada.IO_Exceptions.Name_Error'Identity,
        ...

  function Error_Code_Of(E : Ada.Exceptions.Exception_Occurrence)
  return Exception_Codes is
    use Ada.Exceptions;
  begin
    for i in Coded_Exception_List'range loop
      if Exception_Identity(E) = Coded_Exception_List(i) then
        return i;
      end if;
    end loop;
    raise; -- we have no code for this exception!  re-raise it
  end Error_Code_Of;

then
    function Set_Parameter_A...  return Interfaces.C.Int is
    begin
       ...
       return ...   -- return legitimate, non-exception, result
    exception
       when E : others => return Error_Code_Of(E); -- return exception code
    end Set...



^ permalink raw reply	[relevance 6%]

* Re: Clause "with and use"
  2003-11-19 17:46  0%                       ` Warren W. Gay VE3WWG
@ 2003-11-20  8:26  0%                         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2003-11-20  8:26 UTC (permalink / raw)


On Wed, 19 Nov 2003 12:46:23 -0500, "Warren W. Gay VE3WWG"
<ve3wwg@cogeco.ca> wrote:

>Dmitry A. Kazakov wrote:
>
>> On Mon, 17 Nov 2003 11:42:45 -0500, "Warren W. Gay VE3WWG"
>> <ve3wwg@cogeco.ca> wrote:
>> 
>>>Dmitry A. Kazakov wrote:
>>>
>>>>On Fri, 14 Nov 2003 09:51:33 -0500, "Warren W. Gay VE3WWG"
>>>><ve3wwg@cogeco.ca> wrote:
>>>>
>>>>>Dmitry A. Kazakov wrote:
>>>>>
>>>>>>On Thu, 13 Nov 2003 12:51:51 -0500, "Warren W. Gay VE3WWG"
>>>>>><ve3wwg@cogeco.ca> wrote:
>>>
>>>...
>>>
>>>>There should be something wrong with the language, if the following is
>>>>illegal:
>>>>
>>>>with Ada.Io_Exceptions;
>>>>package A is
>>>>   End_Error : exception renames Ada.Io_Exceptions.End_Error;
>>>>end A;
>>>>
>>>>with Ada.Io_Exceptions;
>>>>package B is
>>>>   End_Error : exception renames Ada.Io_Exceptions.End_Error;
>>>>end B;
>>>
>>>This is more sillyness. When you USE both packages, you take
>>>a hierarchical name space and flatten it. So what else would
>>>you expect if there were clashes?
>> 
>> 
>> I expect renaming be renaming. So A.End_Error and B.End_Error should
>> not clash in any context. Compare it with :
>> 
>> package A is
>>    X : Integer;
>> end A;
>> 
>> with A;
>> package B renames A;
>> 
>> with A; use A;
>> with B; use B;
>> procedure Test is
>> begin
>>    X := 1; -- This is OK
>> end Test;
>> 
>> This example illustrates the fact that package renaming *is* a
>> renaming.
>> 
>> The example with End_Error shows that object renaming is something
>> very different.
>
>OK, I see where you're going with this now. I did overlook
>the renames clause. I don't have an issue with this myself,
>given that the "ending point" refers to the same thing.
>
>While resolving this specific issue would help, it would not
>resolve the general problem with other name clashes.

I suppose there could be much less name clashes if object renaming be
true renaming and if types could be renamed instead of dubious
"subtype X is Y;"

Further, if all types would be tagged, then almost all non-class-wide
operations would be primitive. So instead of a plethora of
overloadings we would have overridings, which do not clash.

Further, if multiple dispatch would be supported, then many cases of
class-wide subprograms would become primitive operations and again
name clashes would disappear.

--
Regards,
Dmitry Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 0%]

* Re: Clause "with and use"
  2003-11-18  8:49  0%                     ` Dmitry A. Kazakov
@ 2003-11-19 17:46  0%                       ` Warren W. Gay VE3WWG
  2003-11-20  8:26  0%                         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Warren W. Gay VE3WWG @ 2003-11-19 17:46 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

> On Mon, 17 Nov 2003 11:42:45 -0500, "Warren W. Gay VE3WWG"
> <ve3wwg@cogeco.ca> wrote:
> 
>>Dmitry A. Kazakov wrote:
>>
>>>On Fri, 14 Nov 2003 09:51:33 -0500, "Warren W. Gay VE3WWG"
>>><ve3wwg@cogeco.ca> wrote:
>>>
>>>>Dmitry A. Kazakov wrote:
>>>>
>>>>>On Thu, 13 Nov 2003 12:51:51 -0500, "Warren W. Gay VE3WWG"
>>>>><ve3wwg@cogeco.ca> wrote:
>>
>>...
>>
>>>There should be something wrong with the language, if the following is
>>>illegal:
>>>
>>>with Ada.Io_Exceptions;
>>>package A is
>>>   End_Error : exception renames Ada.Io_Exceptions.End_Error;
>>>end A;
>>>
>>>with Ada.Io_Exceptions;
>>>package B is
>>>   End_Error : exception renames Ada.Io_Exceptions.End_Error;
>>>end B;
>>
>>This is more sillyness. When you USE both packages, you take
>>a hierarchical name space and flatten it. So what else would
>>you expect if there were clashes?
> 
> 
> I expect renaming be renaming. So A.End_Error and B.End_Error should
> not clash in any context. Compare it with :
> 
> package A is
>    X : Integer;
> end A;
> 
> with A;
> package B renames A;
> 
> with A; use A;
> with B; use B;
> procedure Test is
> begin
>    X := 1; -- This is OK
> end Test;
> 
> This example illustrates the fact that package renaming *is* a
> renaming.
> 
> The example with End_Error shows that object renaming is something
> very different.

OK, I see where you're going with this now. I did overlook
the renames clause. I don't have an issue with this myself,
given that the "ending point" refers to the same thing.

While resolving this specific issue would help, it would not
resolve the general problem with other name clashes.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




^ permalink raw reply	[relevance 0%]

* Re: Clause "with and use"
  2003-11-17 16:42  0%                   ` Warren W. Gay VE3WWG
@ 2003-11-18  8:49  0%                     ` Dmitry A. Kazakov
  2003-11-19 17:46  0%                       ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 195+ results
From: Dmitry A. Kazakov @ 2003-11-18  8:49 UTC (permalink / raw)


On Mon, 17 Nov 2003 11:42:45 -0500, "Warren W. Gay VE3WWG"
<ve3wwg@cogeco.ca> wrote:

>Dmitry A. Kazakov wrote:
>> On Fri, 14 Nov 2003 09:51:33 -0500, "Warren W. Gay VE3WWG"
>> <ve3wwg@cogeco.ca> wrote:
>>>Dmitry A. Kazakov wrote:
>>>>On Thu, 13 Nov 2003 12:51:51 -0500, "Warren W. Gay VE3WWG"
>>>><ve3wwg@cogeco.ca> wrote:
>...
>> There should be something wrong with the language, if the following is
>> illegal:
>> 
>> with Ada.Io_Exceptions;
>> package A is
>>    End_Error : exception renames Ada.Io_Exceptions.End_Error;
>> end A;
>> 
>> with Ada.Io_Exceptions;
>> package B is
>>    End_Error : exception renames Ada.Io_Exceptions.End_Error;
>> end B;
>
>This is more sillyness. When you USE both packages, you take
>a hierarchical name space and flatten it. So what else would
>you expect if there were clashes?

I expect renaming be renaming. So A.End_Error and B.End_Error should
not clash in any context. Compare it with :

package A is
   X : Integer;
end A;

with A;
package B renames A;

with A; use A;
with B; use B;
procedure Test is
begin
   X := 1; -- This is OK
end Test;

This example illustrates the fact that package renaming *is* a
renaming.

The example with End_Error shows that object renaming is something
very different.

--
Regards,
Dmitry Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 0%]

* Re: Clause "with and use"
  2003-11-17  9:22  7%                 ` Dmitry A. Kazakov
@ 2003-11-17 16:42  0%                   ` Warren W. Gay VE3WWG
  2003-11-18  8:49  0%                     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 195+ results
From: Warren W. Gay VE3WWG @ 2003-11-17 16:42 UTC (permalink / raw)


Dmitry A. Kazakov wrote:
> On Fri, 14 Nov 2003 09:51:33 -0500, "Warren W. Gay VE3WWG"
> <ve3wwg@cogeco.ca> wrote:
>>Dmitry A. Kazakov wrote:
>>>On Thu, 13 Nov 2003 12:51:51 -0500, "Warren W. Gay VE3WWG"
>>><ve3wwg@cogeco.ca> wrote:
...
>>I think we have to remember that USE is primarily a language
>>construct for convenience. It is strictly unnecessary for
>>writing a program successfully. It only saves the program
>>writer (and reader) from having to specify (or read) the entire
>>hierarchical name.
> 
> After all Ada itself is just for convenience. We can still use
> hexadecimal machine codes! (:-))

That's silly, but I see the smiley.

> Let me propose a design principle for all standard and semi-standard
> Ada libraries:
> 
> "Any program should remain compilable if all of them are "use"-d."
>  
> Scared? (:-))
> 
>>Misuse that convenience, and you'll experience problems.
>>Conclusion: there is nothing wrong with the language
>>feature, but only the application thereof. ;-)
> 
> There should be something wrong with the language, if the following is
> illegal:
> 
> with Ada.Io_Exceptions;
> package A is
>    End_Error : exception renames Ada.Io_Exceptions.End_Error;
> end A;
> 
> with Ada.Io_Exceptions;
> package B is
>    End_Error : exception renames Ada.Io_Exceptions.End_Error;
> end B;

This is more sillyness. When you USE both packages, you take
a hierarchical name space and flatten it. So what else would
you expect if there were clashes?

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




^ permalink raw reply	[relevance 0%]

* Re: Clause "with and use"
  @ 2003-11-17  9:22  7%                 ` Dmitry A. Kazakov
  2003-11-17 16:42  0%                   ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 195+ results
From: Dmitry A. Kazakov @ 2003-11-17  9:22 UTC (permalink / raw)


On Fri, 14 Nov 2003 09:51:33 -0500, "Warren W. Gay VE3WWG"
<ve3wwg@cogeco.ca> wrote:

>Dmitry A. Kazakov wrote:
>> On Thu, 13 Nov 2003 12:51:51 -0500, "Warren W. Gay VE3WWG"
>> <ve3wwg@cogeco.ca> wrote:
>> 
>>>I agree with this whole-heartedly for anything more than
>>>a simple "hello world" program. This keeps the name
>>>clashes to a minimum, and it prevents unintended
>>>references to functions/procedures in the wrong package.
>>>There may be some exceptions to this, but these should be
>>>kept to a bare minimum, IMHO.
>> 
>> Does anybody a statistics of name clashes in Ada?
>
>I don't have statistics to offer, but here is one that
>I regularly run into (and there are others like this
>one):
>
>USE ADA.STRINGS;
>
>If this is done in the wrong place (like at the top), then
>then the names Left and Right come into conflict (ie.
>Ada.Strings.Left). Left and Right are perfectly acceptable
>names to use in programming.
>
> >What percent is caused by the language design problems:
>...
> >I have a feeling that hatred towards "use" is largely caused by
> >outside reasons like A. and B.
>
>I think we have to remember that USE is primarily a language
>construct for convenience. It is strictly unnecessary for
>writing a program successfully. It only saves the program
>writer (and reader) from having to specify (or read) the entire
>hierarchical name.

After all Ada itself is just for convenience. We can still use
hexadecimal machine codes! (:-))

Let me propose a design principle for all standard and semi-standard
Ada libraries:

"Any program should remain compilable if all of them are "use"-d."
 
Scared? (:-))

>Misuse that convenience, and you'll experience problems.
>Conclusion: there is nothing wrong with the language
>feature, but only the application thereof. ;-)

There should be something wrong with the language, if the following is
illegal:

with Ada.Io_Exceptions;
package A is
   End_Error : exception renames Ada.Io_Exceptions.End_Error;
end A;

with Ada.Io_Exceptions;
package B is
   End_Error : exception renames Ada.Io_Exceptions.End_Error;
end B;

with A; use A;
with B; use B;
procedure Test1 is
begin
   null;
exception
   when End_Error =>
      -- Compile error! A.End_Error clashes with B.End_Error
      null;
end Test1;

--
Regards,
Dmitry Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 7%]

* Eachus' Measure of Goodness (was: Clause "with and use")
  @ 2003-11-11 19:46  4%                     ` Jeffrey Carter
  0 siblings, 0 replies; 195+ results
From: Jeffrey Carter @ 2003-11-11 19:46 UTC (permalink / raw)


Robert I. Eachus wrote:

> If you want a single number to measure the "goodness" of the design, I 
> have been comfortable with (2S + B)/(N * ln(N)) where N is the total 
> number of compilation units and subunits, S is the number of with 
> clauses on package specs (including generic package specs) and B is the 
> number of with clauses on other units.  Some people may disagree with 
> including separate subunits in N, but I seldom find designs abusing 
> that.  There is a problem though is some compilation units are too 
> small, so I get concerned when the average size of compilation units is 
> outside the 100 to 1000 NCSLOC (non-comment source lines of code) range.

Interesting. What are good values of this metric, and what indicates a 
problem? How do you deal with Ada.*, System.*, and Interfaces.* units? 
What about other "standard" libraries?

For example, I have a simple program I run every day (it creates my 
signature file). It has a procedure body only, with 4 with clauses:

with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
with Gnat.OS_Lib;
with PragmARC.Get_Line;

What are S, B, and N for this example? Do I count the

with Ada.Text_IO;

on the spec of PragmARC.Get_Line? What about any with clauses for 
Gnat.OS_Lib? What about those units? Do I count the

with Ada.IO_Exceptions;

on the spec of Ada.Text_IO? What about the 3 other with clauses on the 
spec of the GNAT implementation of Ada.Text_IO?

To my mind this has S = 0, B = 4, and N = 1, giving G (for goodness) = 
4, but to another person N may be greater than 10, counting all the 
parent packages and following every path until you reach units with no 
with clauses.

Sorry for all the questions, but I like metrics, and always want to try 
out new ones.

-- 
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41




^ permalink raw reply	[relevance 4%]

* Re: windows ada compiler error
  2003-10-14  5:19  4% ` tmoran
  2003-10-14 15:29  0%   ` Andrew
@ 2003-10-14 15:35  0%   ` Andrew
  1 sibling, 0 replies; 195+ results
From: Andrew @ 2003-10-14 15:35 UTC (permalink / raw)




tmoran@acm.org wrote:
>>red hat 9.0 linux computer it runs just fine.. but if I try to compile
>>it on a windows xp computer I get the following error.
> 
>   I think you mean it compiles fine, but it doesn't execute fine.
> 
> 
>>raised ADA.IO_EXCEPTION.NAME_ERROR : s-fileio.adb:869
> 
>   You might look at file s-fileio.adb, line 869, and see what it's
> trying to do.  Better yet, use the Gnat facilities for printing a
> walkback so it will show what line of your program caused the problem.
> I used a compiler that prints walkbacks of user, not library, code
> and got:
> 
> ** Unhandled ADA.IO_EXCEPTIONS.NAME_ERROR
>    File not found on open - Map
> On Line Number 159 In MAZECREATE
> 
> You probably want a Create, not an Open.
> 
>   Your prof or TA should be helping you out.

i just typed man gnat and man gnatmake
what would I type to be able to read how to use the gnat facilities?
and also what would the command line be to do the walkback?




^ permalink raw reply	[relevance 0%]

* Re: windows ada compiler error
  2003-10-14  5:19  4% ` tmoran
@ 2003-10-14 15:29  0%   ` Andrew
  2003-10-14 15:35  0%   ` Andrew
  1 sibling, 0 replies; 195+ results
From: Andrew @ 2003-10-14 15:29 UTC (permalink / raw)




tmoran@acm.org wrote:
>>red hat 9.0 linux computer it runs just fine.. but if I try to compile
>>it on a windows xp computer I get the following error.
> 
>   I think you mean it compiles fine, but it doesn't execute fine.
> 
> 
>>raised ADA.IO_EXCEPTION.NAME_ERROR : s-fileio.adb:869
> 
>   You might look at file s-fileio.adb, line 869, and see what it's
> trying to do.  Better yet, use the Gnat facilities for printing a
> walkback so it will show what line of your program caused the problem.
> I used a compiler that prints walkbacks of user, not library, code
> and got:
> 
> ** Unhandled ADA.IO_EXCEPTIONS.NAME_ERROR
>    File not found on open - Map
> On Line Number 159 In MAZECREATE
> 
> You probably want a Create, not an Open.
> 
>   Your prof or TA should be helping you out.

thanks for the tip .. I'll look into it

as for a prof *L* I've been out of college for a few years now, and 
decided to try programming in Ada and a lot of what I used to know I've 
forgotten.  Although it is very much like riding a bike.. once you 
learn, and quite riding for a few years you can never forget all the 
ways to fall off of bike.




^ permalink raw reply	[relevance 0%]

* Re: windows ada compiler error
  @ 2003-10-14  5:19  4% ` tmoran
  2003-10-14 15:29  0%   ` Andrew
  2003-10-14 15:35  0%   ` Andrew
  0 siblings, 2 replies; 195+ results
From: tmoran @ 2003-10-14  5:19 UTC (permalink / raw)


>red hat 9.0 linux computer it runs just fine.. but if I try to compile
>it on a windows xp computer I get the following error.
  I think you mean it compiles fine, but it doesn't execute fine.

>raised ADA.IO_EXCEPTION.NAME_ERROR : s-fileio.adb:869
  You might look at file s-fileio.adb, line 869, and see what it's
trying to do.  Better yet, use the Gnat facilities for printing a
walkback so it will show what line of your program caused the problem.
I used a compiler that prints walkbacks of user, not library, code
and got:

** Unhandled ADA.IO_EXCEPTIONS.NAME_ERROR
   File not found on open - Map
On Line Number 159 In MAZECREATE

You probably want a Create, not an Open.

  Your prof or TA should be helping you out.



^ permalink raw reply	[relevance 4%]

* Re: Catching a DEVICE_ERROR?
  2003-06-11 13:31  6% Catching a DEVICE_ERROR? Tony Danezis
@ 2003-06-11 13:49  0% ` David C. Hoos
  0 siblings, 0 replies; 195+ results
From: David C. Hoos @ 2003-06-11 13:49 UTC (permalink / raw)



"Tony Danezis" <antonis01@in.gr> wrote in message
news:5771e505.0306110531.2df2d93a@posting.google.com...
> Hello..
>
> I am looking for assistance on how to catch a DEVICE_ERROR when
> printing to LPT1. My Code seems to be correct and I print fine when
> the printer (HP laserjet 1200)is ON, but the exception is not raised
> when the printer is unplugged or not powered on.
> (Using win 2000 and The GNAT Integrated Environment version 3.14a1)
>
> thanks for any insight and assistance
> Snippet of code follows:

Why not make your exception handler like this:

exception
    when e: others =>
        Ada.Text_IO.Put_Line
           (Ada.Text_IO.Standard_Error,
            Ada.Exceptions.Exception_Information (e));
end Printer_Test;

Now, no matter what the exception, information about it will
be sent to the standard error file.

>
> with ADA.IO_EXCEPTIONS; use ADA.IO_EXCEPTIONS;
> with TERMINAL;          use TERMINAL;
> with Ada.Text_IO;       use Ada.Text_IO;
>
> procedure Printer_Test is
>   use Text;
>   PrFile : TEXT.File_Type;
>
> begin
>   Create (File => PrFile, Mode => Out_File, Name => "LPT1:");
>   Put_Line (File => PrFile, Item => "Here is a line for the printer");
>   New_Page (File => PrFile);
>   Close (File => PrFile);
>
>   Put_Line("DONE CODE");
>
>    exception
>       when Text.Status_Error =>
>         Text.Put_Line("Status_Error");
>
>       when Text.Mode_Error   =>
>         Text.Put_Line("Mode_Error");
>
>       when Text.Device_Error =>
>         Text.Put_Line("Device_Error");
>
>       when others =>
>         Text.Put_Line("Unknown_Error");
>
> end Printer_Test;
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>





^ permalink raw reply	[relevance 0%]

* Catching a DEVICE_ERROR?
@ 2003-06-11 13:31  6% Tony Danezis
  2003-06-11 13:49  0% ` David C. Hoos
  0 siblings, 1 reply; 195+ results
From: Tony Danezis @ 2003-06-11 13:31 UTC (permalink / raw)


Hello..

I am looking for assistance on how to catch a DEVICE_ERROR when
printing to LPT1. My Code seems to be correct and I print fine when
the printer (HP laserjet 1200)is ON, but the exception is not raised
when the printer is unplugged or not powered on.
(Using win 2000 and The GNAT Integrated Environment version 3.14a1)

thanks for any insight and assistance
Snippet of code follows:

with ADA.IO_EXCEPTIONS; use ADA.IO_EXCEPTIONS;
with TERMINAL;          use TERMINAL;
with Ada.Text_IO;       use Ada.Text_IO;

procedure Printer_Test is
  use Text;
  PrFile : TEXT.File_Type;

begin
  Create (File => PrFile, Mode => Out_File, Name => "LPT1:");
  Put_Line (File => PrFile, Item => "Here is a line for the printer");
  New_Page (File => PrFile);
  Close (File => PrFile);

  Put_Line("DONE CODE");

   exception
      when Text.Status_Error =>
        Text.Put_Line("Status_Error");

      when Text.Mode_Error   =>
        Text.Put_Line("Mode_Error");
  
      when Text.Device_Error =>
        Text.Put_Line("Device_Error");

      when others =>
        Text.Put_Line("Unknown_Error");

end Printer_Test;



^ permalink raw reply	[relevance 6%]

* Re: MI in Ada 200X
  @ 2003-05-31  9:27  7%             ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2003-05-31  9:27 UTC (permalink / raw)


Karel Miklav wrote:

> Dmitry A. Kazakov wrote:
>> Wesley Groleau wrote:
>>>>>Mário Amado Alves wrote:
>>>>>
>>>>>>Everybody wants class MI. The reasons it was left out of Ada 95 and
>>>
>>>I don't!
>> 
>> OK. Bill Gates once said that nobody would need more than 64K RAM. Or was
>> it 640K? I do not remember. Anyway, never say never. (:-))
> 
> I don't see how this is related to MI. What do you think about the
> diamond problem and other evils of MI?

Incest? A bad thing, you know. However, I would not call a problem anything 
that can be detected at compile-time. Anyway we have a lot of 
diamond-things in present Ada. Consider:

with Ada.IO_Exceptions;
package B is
   End_Error : exception renames IO_Exceptions.End_Error;
   ...
end B;

with Ada.IO_Exceptions;
package C is
   End_Error : exception renames IO_Exceptions.End_Error;
   ...
end C;

with B; use B;
with C; use C;

procedure D is
   ...
exception
   when End_Error => -- which End_Error?

exception renaming is not 'renaming', but a new view. In C++ terms it is 
sort of "B : public A", not "B : public virtual A" (as a naive programmer 
might think).

> Besides, where do or would you use this feature?

First from the stack: to make a stream object controlled. (*)

> MI might look like a good idea in a simple project, but when things
> start to get messy and you're caught into inheritance net, you can
> forget who your own mother is :) I vote NO for MI and other inventions
> of marketing departments but YES for interfaces.

(*) Ada.Streams.Root_Stream_Type is not a [public] descendant of 
Ada.Finalization.Limited_Controlled.

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[relevance 7%]

* Re: It's been a while...
  2003-05-29 21:18  6% It's been a while Luke A. Guest
@ 2003-05-30  2:13  0% ` Steve
  0 siblings, 0 replies; 195+ results
From: Steve @ 2003-05-30  2:13 UTC (permalink / raw)


You might try adding: pragma Discard_Names to your source.

If you haven't already checked, look for settings in the GNAT User's Guide
and the GNAT Reference Manual for hints on how to reduce the size of the
executable.

It also looks like full exception traceback information is included.  You
can probably turn that off as well (if you really want to).

Steve
(The Duck)

"Luke A. Guest" <laguest@__n_o_s_p_a_m__abyss2.demon.co.uk______> wrote in
message
news:pan.2003.05.29.21.18.46.518854@__n_o_s_p_a_m__abyss2.demon.co.uk______.
..
> Hi,
>
> I learned Ada at University around 1995 and I've been interested in
> getting back into it. Now, I have a simple "hello" app and it is huge.
> Now, I don't want to have a load of people telling me not to judge Ada on
> the size, but I really want to know how to get the app size down. The app
> is:
>
> -rwxr-xr-x    1 laguest  users      200492 2003-05-29 22:16 hello
>
> This is an example program from the sources, compiled with:
>
> gnatmake -O3
>
> and Ihave used "strip" to get rid of the debug symbols, and the app size
> is:
>
> -rwxr-xr-x    1 laguest  users       73292 2003-05-29 22:17 hello
>
> but, if I do this:
>
> strings hello, I get the following:
>
> /lib/ld-linux.so.2
> libc.so.6
> strcpy
> waitpid
> stdout
> utime
> ungetc
> sigemptyset
> getenv
> getpid
> memcpy
> setvbuf
> readlink
> feof
> malloc
> isatty
> __frame_state_for
> readdir
> fflush
> putenv
> abort
> fprintf
> strcat
> __deregister_frame_info
> fseek
> stdin
> mktime
> ferror
> strstr
> strncpy
> unlink
> realloc
> _IO_getc
> fork
> execv
> sigaction
> fread
> symlink
> localtime
> memset
> clearerr
> getppid
> tcgetattr
> ttyname
> getcwd
> fgetc
> sprintf
> fclose
> scanf
> stderr
> mkstemp
> fputc
> localtime_r
> fwrite
> __xstat
> rewind
> freopen
> __fxstat
> fopen
> atoi
> _IO_putc
> fileno
> _IO_stdin_used
> _exit
> gmtime
> __libc_start_main
> __register_frame_info_table
> tcsetattr
> __register_frame_info
> free
> __gnat_handler_installed
> __gl_wc_encoding
> __dummy
> program_error
> __gl_unreserve_all_interrupts
> gnat_argc
> gnat_envp
> __gl_exception_tracebacks
> __gl_restrictions
> __gl_main_priority
> __gl_locking_policy
> __gl_task_dispatching_policy
> system__soft_links__get_machine_state_addr
> max_path_len
> gnat_argv
> __gl_zero_cost_exceptions
> __gl_queuing_policy
> __gl_time_slice_val
> gnat_exit_status
> constraint_error
> storage_error
> __gmon_start__
> GLIBC_2.1
> GLIBC_2.0
> PTRh
> j j j jbj
> (WVS
>         ~&V
> gfff
> gfff
> 8C9M
> \WVS
> (WVS
> 0WVS
> PRQh
> PRQh
> PRQh
> PRQS
> TWVS
> gfff
> gfff
> \WVS
> $WVS
> 8_t5
> 8_u;
> j;h8z
> t!VS
> t_WV
> t*WS
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPh<
> RPht
> RPhL
> RPh<
> RPht
> RPhL
> RPh<
> RPht
> RPhL
> RPh<
> RPht
> RPhL
> RPh<
> RPht
> RPhL
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPht
> 9C0~
> RPh<
> RPht
> 9P0~
> RPh<
> RPht
> t29u
> RPh<
> RPht
> 9G,~
> G,PVW
> RPht
> RPht
> 9s0~
> 9s0|
> RPhL
> RPh<
> RPht
> RPh<
> RPht
> 9s,tiS
> 9s,~    S
> 9s,}%
> 9s,|
> 9s,u
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPht
> RPh<
> RPht
> RPhL
> RPh<
> RPht
> RPhL
> RPht
> t!VS
> t_WV
> t*WS
> $WVS
> WVSj
> jGh(}
> RPh<
> RPh<
> RPht
> RPh<
> RPht
>  WVS
> RPh<
> RPh<
> RPhL
> j8PR
> RPh<
> RPh<
> RPh<
> RPht
> RPh<
> RPht
>  WVS
> jzhd
>  WVS
> $hd
>  WVS
>  WVS
> $h|1
> $hl5
> j.h%
> j7h%
> j@h%
> <Pu$
> TWVS
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> RPhL
> 4WVS
> WVSf
> ,WVS
>  WVS
> PRQS
> Pj/V
> 80t-@80t(@80t#@
> 80t-@80t(@80t#@
> 80t-@80t(@80t#@
> 80t-@80t(@80t#@
> 8(t-@8(t(@8(t#@
> 8"t+B8"t&B8"t!B
> BB+U
> 8(t-@8(t(@8(t#@
> t}</u
> 80t-@80t(@80t#@
> 80t-@80t(@80t#@
> 8*t-B8*t(B8*t#B
> BB+U
> <:t
> 80t-@80t(@80t#@
> 8"t+B8"t&B8"t!B
> 80t-@80t(@80t#@
> 81t-A81t(A81t#A
> 8(t-@8(t(@8(t#@
> 81t-A81t(A81t#A
> 8(t-@8(t(@8(t#@
> ?/t<
> PRQV
> PRQV
> tD9U
> t%VWG
> 8&t+F8&t&F8&t!F
> _ada_hello
> nnvvnnnvnnnnnvvvvvvnvvvnvnnvnnnvnvvnnnnnnvvvnnnnvvnn
> hello
> access check failed
> access parameter is null
> discriminant check failed
> divide by zero
> explicit raise
> index check failed
> invalid data
> length check failed
> overflow check failed
> partition check failed
> range check failed
> tag check failed
> access before elaboration
> accessibility check failed
> all guards closed
> finalize raised exception
> misaligned address value
> missing return
> potentially blocking operation
> stubbed subprogram called
> unchecked union restriction
> empty storage pool
> infinite recursion
> object too large
> restriction violation
>
URC_NO_REASONURC_FOREIGN_EXCEPTION_CAUGHTURC_PHASE2_ERRORURC_PHASE1_ERRORURC
_NORMAL_STOPURC_END_OF_STACKURC_HANDLER_FOUNDURC_INSTALL_CONTEXTURC_CONTINUE
_UNWIND
> 0123456789abcdefException name:
> Message:
> PID:
> Call stack traceback locations:
> a-except.adb
> bad exception occurrence in stream input
> PID:Exception raised
> Execution terminated by abort of environment task
> raised
> Execution terminated by unhandled exception
> a-finali.ads
> FALSETRUE
> unknown tagged type:
> @IN_FILEOUT_FILEAPPEND_FILE
> LOWER_CASEUPPER_CASE
> a-textio.ads
> s-fileio.adb:166
>
s-fileio.adb:168s-fileio.adb:477s-fileio.adb:179s-fileio.adb:181s-fileio.adb
:639a-textio.adb:396a-textio.adb:449a-textio.adb:501a-textio.adb:503a-textio
.adb:553a-textio.adb:556a-textio.adb:617a-textio.adb:712a-textio.adb
> a-textio.adb:896a-textio.adb:901a-textio.adb:983a-textio.adb:1000
>
a-textio.adb:1110a-textio.adb:1130a-textio.adb:1188a-textio.adb:1211a-textio
.adb:1265a-textio.adb:1281a-textio.adb:1353a-textio.adb:1472a-textio.adb:155
9a-textio.adb:1664a-textio.adb:1707a-textio.adb:1725a-textio.adb:1732a-texti
o.adb:1741
> %IN_FILEINOUT_FILEOUT_FILEAPPEND_FILE
> %YESNONONE
> s-fileio.adb
> s-fileio.adb:122
>
s-fileio.adb:155s-fileio.adb:166s-fileio.adb:168s-fileio.adb:179s-fileio.adb
:181s-fileio.adb:271s-fileio.adb:284s-fileio.adb:298s-fileio.adb:374s-fileio
.adb:477s-fileio.adb:508s-fileio.adb:536s-fileio.adb:542s-fileio.adb:639s-fi
leio.adb:652s-fileio.adb:709shared
>
yesnos-fileio.adb:743s-fileio.adb:763s-fileio.adb:769s-fileio.adb:798s-filei
o.adb:828s-fileio.adb:869s-fileio.adb:889s-fileio.adb:891s-fileio.adb:934s-f
ileio.adb:937s-fileio.adb:940s-fileio.adb:955s-fileio.adb:989s-fileio.adb:10
12
> s-fileio.adb:1037
> s-finimp.ads
> s-stratt.adb:458
>
s-stratt.adb:440s-stratt.adb:422s-stratt.adb:404s-stratt.adb:386s-stratt.adb
:368s-stratt.adb:350s-stratt.adb:332s-stratt.adb:314s-stratt.adb:296s-stratt
.adb:278s-stratt.adb:260s-stratt.adb:242s-stratt.adb:224s-stratt.adb:206s-st
ratt.adb:188s-stratt.adb:170s-stratt.adb:152s-stratt.adb:134s-finimp.adb
>  raised during finalization
> exception
> s-finroo.ads
> s-finroo.adb
> EAXECXEDXEBXESPEBPESIEDI
> UWORDBYTE
>         CONSTRAINT_ERROR
> PROGRAM_ERROR
> STORAGE_ERROR
> TASKING_ERROR
> _ABORT_SIGNAL
> NUMERIC_ERROR
> RM_CONVENTIONEVERY_RAISEUNHANDLED_RAISE
> s-stratt.adb:134
> s-stratt.adb:152
>
s-stratt.adb:170s-stratt.adb:188s-stratt.adb:206s-stratt.adb:224s-stratt.adb
:242s-stratt.adb:260
>
s-stratt.adb:278s-stratt.adb:296s-stratt.adb:314s-stratt.adb:332s-stratt.adb
:350s-stratt.adb:368s-stratt.adb:386s-stratt.adb:404s-stratt.adb:422s-stratt
.adb:440s-stratt.adb:458main_task
> object too large
> heap exhausted
> lib*.a
> %s%c%s
> %s-%d-%d
> GNAT-XXXXXX
> TMPDIR
> /tmp/gnat-XXXXXX
> %s/gnat-XXXXXX
> %s=%s
> PATH
> a-init.c
> SIGSEGV
> stack overflow (or erroneous memory access)
> SIGBUS
> SIGFPE
> unhandled signal
> GNAT_STACK_LIMIT
> s-stache.adb:172
> stack overflow detected
> GNAT Version: 3.15p  (20020523)_ada_hello
> q#*a
> ^X7,
> {_      uD{
> divide by zero
> explicit raise
> invalid data
> explicit raise
> invalid data
> missing return
> explicit raise
> ADA.FINALIZATION.LIST_CONTROLLER.SIMPLE_LIST_CONTROLLER
> ADA.FINALIZATION.LIST_CONTROLLER.LIST_CONTROLLER
> ADA.FINALIZATION.CONTROLLED
> ADA.FINALIZATION.LIMITED_CONTROLLED
> ADA.IO_EXCEPTIONS.STATUS_ERROR
> ADA.IO_EXCEPTIONS.MODE_ERROR
> ADA.IO_EXCEPTIONS.NAME_ERROR
> ADA.IO_EXCEPTIONS.USE_ERROR
> ADA.IO_EXCEPTIONS.DEVICE_ERROR
> ADA.IO_EXCEPTIONS.END_ERROR
> ADA.IO_EXCEPTIONS.DATA_ERROR
> ADA.IO_EXCEPTIONS.LAYOUT_ERROR
> ADA.STREAMS.ROOT_STREAM_TYPE
> ADA.TAGS.TAG_ERROR
> FALSETRUE
> ADA.TEXT_IO.TEXT_AFCB
> *stderr
> *stdin
> *stdout
> %YESNONONE
> SYSTEM.FILE_CONTROL_BLOCK.AFCB
> SYSTEM.FILE_IO.FILE_IO_CLEAN_UP_TYPE
> SYSTEM.FINALIZATION_IMPLEMENTATION.LIMITED_RECORD_CONTROLLER
> SYSTEM.FINALIZATION_IMPLEMENTATION.RECORD_CONTROLLER
> SYSTEM.FINALIZATION_ROOT.EMPTY_ROOT_CONTROLLED
> SYSTEM.FINALIZATION_ROOT.ROOT_CONTROLLED
> PROGRAM_ERROR
> STORAGE_ERROR
> TASKING_ERROR
> _ABORT_SIGNAL
> NUMERIC_ERROR
> n
> G. A.$B.(H.
>
> Now, surely the app doesn't need this info and it must be taking up a lot
> of space. Do I need to go into the linker scripts to strip this info out?
>
> Thanks,
> Luke.
>
>
>





^ permalink raw reply	[relevance 0%]

* It's been a while...
@ 2003-05-29 21:18  6% Luke A. Guest
  2003-05-30  2:13  0% ` Steve
  0 siblings, 1 reply; 195+ results
From: Luke A. Guest @ 2003-05-29 21:18 UTC (permalink / raw)


Hi,

I learned Ada at University around 1995 and I've been interested in
getting back into it. Now, I have a simple "hello" app and it is huge.
Now, I don't want to have a load of people telling me not to judge Ada on
the size, but I really want to know how to get the app size down. The app
is:

-rwxr-xr-x    1 laguest  users      200492 2003-05-29 22:16 hello

This is an example program from the sources, compiled with:

	gnatmake -O3

and Ihave used "strip" to get rid of the debug symbols, and the app size
is:

-rwxr-xr-x    1 laguest  users       73292 2003-05-29 22:17 hello

but, if I do this:

	strings hello, I get the following:

/lib/ld-linux.so.2
libc.so.6
strcpy
waitpid
stdout
utime
ungetc
sigemptyset
getenv
getpid
memcpy
setvbuf
readlink
feof
malloc
isatty
__frame_state_for
readdir
fflush
putenv
abort
fprintf
strcat
__deregister_frame_info
fseek
stdin
mktime
ferror
strstr
strncpy
unlink
realloc
_IO_getc
fork
execv
sigaction
fread
symlink
localtime
memset
clearerr
getppid
tcgetattr
ttyname
getcwd
fgetc
sprintf
fclose
scanf
stderr
mkstemp
fputc
localtime_r
fwrite
__xstat
rewind
freopen
__fxstat
fopen
atoi
_IO_putc
fileno
_IO_stdin_used
_exit
gmtime
__libc_start_main
__register_frame_info_table
tcsetattr
__register_frame_info
free
__gnat_handler_installed
__gl_wc_encoding
__dummy
program_error
__gl_unreserve_all_interrupts
gnat_argc
gnat_envp
__gl_exception_tracebacks
__gl_restrictions
__gl_main_priority
__gl_locking_policy
__gl_task_dispatching_policy
system__soft_links__get_machine_state_addr
max_path_len
gnat_argv
__gl_zero_cost_exceptions
__gl_queuing_policy
__gl_time_slice_val
gnat_exit_status
constraint_error
storage_error
__gmon_start__
GLIBC_2.1
GLIBC_2.0
PTRh
j j j jbj
(WVS
        ~&V
gfff
gfff
8C9M
\WVS
(WVS
0WVS
PRQh
PRQh
PRQh
PRQS
TWVS
gfff
gfff
\WVS
$WVS
8_t5
8_u;
j;h8z
t!VS
t_WV
t*WS
RPh<
RPht
RPh<
RPht
RPh<
RPht
RPh<
RPh<
RPht
RPhL
RPh<
RPht
RPhL
RPh<
RPht
RPhL
RPh<
RPht
RPhL
RPh<
RPht
RPhL
RPh<
RPht
RPh<
RPht
RPh<
RPh<
RPht
RPh<
RPht
RPh<
RPht
RPh<
RPht
9C0~
RPh<
RPht
9P0~
RPh<
RPht
t29u
RPh<
RPht
9G,~
G,PVW
RPht
RPht
9s0~
9s0|
RPhL
RPh<
RPht
RPh<
RPht
9s,tiS
9s,~    S
9s,}%
9s,|
9s,u
RPh<
RPht
RPh<
RPht
RPh<
RPht
RPh<
RPht
RPhL
RPh<
RPht
RPhL
RPht
t!VS
t_WV
t*WS
$WVS
WVSj
jGh(}
RPh<
RPh<
RPht
RPh<
RPht
 WVS
RPh<
RPh<
RPhL
j8PR
RPh<
RPh<
RPh<
RPht
RPh<
RPht
 WVS
jzhd
 WVS
$hd
 WVS
 WVS
$h|1
$hl5
j.h%
j7h%
j@h%
<Pu$
TWVS
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
RPhL
4WVS
WVSf
,WVS
 WVS
PRQS
Pj/V
80t-@80t(@80t#@
80t-@80t(@80t#@
80t-@80t(@80t#@
80t-@80t(@80t#@
8(t-@8(t(@8(t#@
8"t+B8"t&B8"t!B
BB+U
8(t-@8(t(@8(t#@
t}</u
80t-@80t(@80t#@
80t-@80t(@80t#@
8*t-B8*t(B8*t#B
BB+U
<:t
80t-@80t(@80t#@
8"t+B8"t&B8"t!B
80t-@80t(@80t#@
81t-A81t(A81t#A
8(t-@8(t(@8(t#@
81t-A81t(A81t#A
8(t-@8(t(@8(t#@
?/t<
PRQV
PRQV
tD9U
t%VWG
8&t+F8&t&F8&t!F
_ada_hello
nnvvnnnvnnnnnvvvvvvnvvvnvnnvnnnvnvvnnnnnnvvvnnnnvvnn
hello
access check failed
access parameter is null
discriminant check failed
divide by zero
explicit raise
index check failed
invalid data
length check failed
overflow check failed
partition check failed
range check failed
tag check failed
access before elaboration
accessibility check failed
all guards closed
finalize raised exception
misaligned address value
missing return
potentially blocking operation
stubbed subprogram called
unchecked union restriction
empty storage pool
infinite recursion
object too large
restriction violation
URC_NO_REASONURC_FOREIGN_EXCEPTION_CAUGHTURC_PHASE2_ERRORURC_PHASE1_ERRORURC_NORMAL_STOPURC_END_OF_STACKURC_HANDLER_FOUNDURC_INSTALL_CONTEXTURC_CONTINUE_UNWIND
0123456789abcdefException name:
Message:
PID:
Call stack traceback locations:
a-except.adb
bad exception occurrence in stream input
PID:Exception raised
Execution terminated by abort of environment task
raised
Execution terminated by unhandled exception
a-finali.ads
FALSETRUE
unknown tagged type:
@IN_FILEOUT_FILEAPPEND_FILE
LOWER_CASEUPPER_CASE
a-textio.ads
s-fileio.adb:166
s-fileio.adb:168s-fileio.adb:477s-fileio.adb:179s-fileio.adb:181s-fileio.adb:639a-textio.adb:396a-textio.adb:449a-textio.adb:501a-textio.adb:503a-textio.adb:553a-textio.adb:556a-textio.adb:617a-textio.adb:712a-textio.adb
a-textio.adb:896a-textio.adb:901a-textio.adb:983a-textio.adb:1000
a-textio.adb:1110a-textio.adb:1130a-textio.adb:1188a-textio.adb:1211a-textio.adb:1265a-textio.adb:1281a-textio.adb:1353a-textio.adb:1472a-textio.adb:1559a-textio.adb:1664a-textio.adb:1707a-textio.adb:1725a-textio.adb:1732a-textio.adb:1741
%IN_FILEINOUT_FILEOUT_FILEAPPEND_FILE
%YESNONONE
s-fileio.adb
s-fileio.adb:122
s-fileio.adb:155s-fileio.adb:166s-fileio.adb:168s-fileio.adb:179s-fileio.adb:181s-fileio.adb:271s-fileio.adb:284s-fileio.adb:298s-fileio.adb:374s-fileio.adb:477s-fileio.adb:508s-fileio.adb:536s-fileio.adb:542s-fileio.adb:639s-fileio.adb:652s-fileio.adb:709shared
yesnos-fileio.adb:743s-fileio.adb:763s-fileio.adb:769s-fileio.adb:798s-fileio.adb:828s-fileio.adb:869s-fileio.adb:889s-fileio.adb:891s-fileio.adb:934s-fileio.adb:937s-fileio.adb:940s-fileio.adb:955s-fileio.adb:989s-fileio.adb:1012
s-fileio.adb:1037
s-finimp.ads
s-stratt.adb:458
s-stratt.adb:440s-stratt.adb:422s-stratt.adb:404s-stratt.adb:386s-stratt.adb:368s-stratt.adb:350s-stratt.adb:332s-stratt.adb:314s-stratt.adb:296s-stratt.adb:278s-stratt.adb:260s-stratt.adb:242s-stratt.adb:224s-stratt.adb:206s-stratt.adb:188s-stratt.adb:170s-stratt.adb:152s-stratt.adb:134s-finimp.adb
 raised during finalization
exception
s-finroo.ads
s-finroo.adb
EAXECXEDXEBXESPEBPESIEDI
UWORDBYTE
        CONSTRAINT_ERROR
PROGRAM_ERROR
STORAGE_ERROR
TASKING_ERROR
_ABORT_SIGNAL
NUMERIC_ERROR
RM_CONVENTIONEVERY_RAISEUNHANDLED_RAISE
s-stratt.adb:134
s-stratt.adb:152
s-stratt.adb:170s-stratt.adb:188s-stratt.adb:206s-stratt.adb:224s-stratt.adb:242s-stratt.adb:260
s-stratt.adb:278s-stratt.adb:296s-stratt.adb:314s-stratt.adb:332s-stratt.adb:350s-stratt.adb:368s-stratt.adb:386s-stratt.adb:404s-stratt.adb:422s-stratt.adb:440s-stratt.adb:458main_task
object too large
heap exhausted
lib*.a
%s%c%s
%s-%d-%d
GNAT-XXXXXX
TMPDIR
/tmp/gnat-XXXXXX
%s/gnat-XXXXXX
%s=%s
PATH
a-init.c
SIGSEGV
stack overflow (or erroneous memory access)
SIGBUS
SIGFPE
unhandled signal
GNAT_STACK_LIMIT
s-stache.adb:172
stack overflow detected
GNAT Version: 3.15p  (20020523)_ada_hello
q#*a
^X7,
{_      uD{
divide by zero
explicit raise
invalid data
explicit raise
invalid data
missing return
explicit raise
ADA.FINALIZATION.LIST_CONTROLLER.SIMPLE_LIST_CONTROLLER
ADA.FINALIZATION.LIST_CONTROLLER.LIST_CONTROLLER
ADA.FINALIZATION.CONTROLLED
ADA.FINALIZATION.LIMITED_CONTROLLED
ADA.IO_EXCEPTIONS.STATUS_ERROR
ADA.IO_EXCEPTIONS.MODE_ERROR
ADA.IO_EXCEPTIONS.NAME_ERROR
ADA.IO_EXCEPTIONS.USE_ERROR
ADA.IO_EXCEPTIONS.DEVICE_ERROR
ADA.IO_EXCEPTIONS.END_ERROR
ADA.IO_EXCEPTIONS.DATA_ERROR
ADA.IO_EXCEPTIONS.LAYOUT_ERROR
ADA.STREAMS.ROOT_STREAM_TYPE
ADA.TAGS.TAG_ERROR
FALSETRUE
ADA.TEXT_IO.TEXT_AFCB
*stderr
*stdin
*stdout
%YESNONONE
SYSTEM.FILE_CONTROL_BLOCK.AFCB
SYSTEM.FILE_IO.FILE_IO_CLEAN_UP_TYPE
SYSTEM.FINALIZATION_IMPLEMENTATION.LIMITED_RECORD_CONTROLLER
SYSTEM.FINALIZATION_IMPLEMENTATION.RECORD_CONTROLLER
SYSTEM.FINALIZATION_ROOT.EMPTY_ROOT_CONTROLLED
SYSTEM.FINALIZATION_ROOT.ROOT_CONTROLLED
PROGRAM_ERROR
STORAGE_ERROR
TASKING_ERROR
_ABORT_SIGNAL
NUMERIC_ERROR
n
G. A.$B.(H.

Now, surely the app doesn't need this info and it must be taking up a lot
of space. Do I need to go into the linker scripts to strip this info out?

Thanks,
Luke.






^ permalink raw reply	[relevance 6%]

* Re: GNAT.Sockets Problems
  2003-05-09 19:46  2% GNAT.Sockets Problems file13
  2003-05-11  0:51  2% ` Craig Carey
@ 2003-05-12 11:38  0% ` Simon Clubley
  1 sibling, 0 replies; 195+ results
From: Simon Clubley @ 2003-05-12 11:38 UTC (permalink / raw)


In article <28d8936a.0305091146.18a4dd57@posting.google.com>, file13@qlippoth.zzn.com (file13) writes:
> Howdy all, I've been tinkering with GNAT.Sockets on Mandrake 9.1 using
> the Gnat-3.15p linux binary and I'm simply trying to write the first
> day time client from Stevens UNIX Network Programming book with it and
> I can't seem to figure out what I'm doing wrong.
> 
> so far in Ada I have:
> 
> with Ada.Exceptions; use Ada.Exceptions;
> with Ada.Text_IO; use Ada.Text_IO;
> with GNAT.Sockets; use GNAT.Sockets;
> 
> procedure Daytime_Client is
>    Target  : Inet_Addr_Type := Inet_Addr ("127.0.0.1");
>    Socket  : Socket_Type;
>    Server  : Sock_Addr_Type;
>    Channel : Stream_Access;
> begin
>    Initialize;
>    Create_Socket (Socket);
>    Server := (Family_Inet, Target, 13);
> 
>    Connect_Socket (Socket, Server);
> 
>    Channel := Stream (Socket, Server);
>    Put_Line (String'Input (Channel));
               ^^^^^^

That's your problem. 'Input is trying to read the dope information for the
String datatype; so this will never work.

> 
>    Shutdown_Socket (Socket);
>    Close_Socket (Socket);
>    Finalize;
> 
> exception when E : others =>
>    Put_Line (Exception_Name (E)
>              & ": " & Exception_Message (E));
> end Daytime_Client;
> 
> It appears to connect just fine because if I turn off the server it
> gives me:
> 
> $ ./daytime_client
> GNAT.SOCKETS.SOCKET_ERROR: [111] Connection refused
> 
> but if it's on I'm getting the following error:
> 
> $ ./daytime_client
> ADA.IO_EXCEPTIONS.END_ERROR: s-stratt.adb:188
> 
> Also if I change the port to something else open like 22 I get a
> segmentation fault:
> 
> $ ./daytime_client
> Segmentation fault
> 
> Why wouldn't it get a similar error if it's only ripping the banner
> off of the server port?
> 
> Am I doing something wrong with the streams (this is the first time
> I've used Ada's streams) or do I need to GNAT.Sockets.Receive_Socket? 

As it happens, I have also been looking at GNAT.Sockets for the first time
this weekend (and, as a result, Ada.Streams for the first time as well.)

I also tried String'Input before realising why that would not work, and
also got a segmentation fault, presumably because the GNAT runtime is trusting
the information that's it's reading as the dope information, which I found
disappointing as that's the kind of thing that I would expect from C and
not Ada.

> If so can anyone provide me with an example?  I know in C you have to
> use a loop, but I didn't know if that was necessary with Ada.Streams. 
> I tried it with Receive_Socket also, but I could not figure out how to
> print the output to regular stdout....
> 

You could always do a (maybe unchecked) conversion and then treat the
Stream_Elements as a stream of characters. I ended up doing that in order
to get it working with Receive_Socket.

And now for a request of my own:

I have been looking at GNAT.Sockets as part of some investigations into
deciding if my next project will be written in Ada or C. I am finding
GNAT.Sockets to be cumbersome when it comes to reading data, and I am
wondering how others use it.

In case it makes a difference, I am using GNAT.Sockets with GtkAda and am
passing the socket file descriptor to GtkAda so that a callback can be
called when data is available to read, so I must not block in the callback.

Thanks for any information,

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP       
VMS advocate: One who makes a Mac advocate look like a beginner at advocacy.



^ permalink raw reply	[relevance 0%]

* Re: GNAT.Sockets Problems
  2003-05-09 19:46  2% GNAT.Sockets Problems file13
@ 2003-05-11  0:51  2% ` Craig Carey
  2003-05-12 11:38  0% ` Simon Clubley
  1 sibling, 0 replies; 195+ results
From: Craig Carey @ 2003-05-11  0:51 UTC (permalink / raw)




>ADA.IO_EXCEPTIONS.END_ERROR: s-stratt.adb:188

Here is file "s-stratt.adb:188" from the cvs site:

| package body System.Stream_Attributes is     * GNAT of "GCC 3.4" *
|    Err : exception renames Ada.IO_Exceptions.End_Error;
|    ...
|    function I_C (Stream : access RST) return Character is
|       T : S_C;
|       L : SEO;
|    begin
|       Ada.Streams.Read (Stream.all, T, L);
|       if L < T'Last then
L188>      raise Err;
|       else
|          return To_C (T);
|       end if;
|    end I_C;

I doubt that fast Ada programs handle data with a procedure call for each
byte.

I have some personal bindings to GNAT.Sockets here, in file "ptun1.adb":
http://www.ijs.co.nz/code/ada95_http_hdrs.zip (or of a similar name).

------------------------------------
Inset: * Browsing through the abuse officer's censoring proxy *:
 I released a TCP multiplexing proxy named (Ptunnel 2) that allows
 browsing through a censoring proxy. The proxy differs from HTTPort in
 that only 2 log file lines are left behind and it is in Ada and also
 the connections are out to port 80. Port 119 Usenet I/O can be downloaded
 through the proxy, and then all the messages are in a long "stream".
------------------------------------

The I_C() procedure is not something a fast well designed program would
need to contain. Ada's Streams are available and it seems very likely
that only Ada beginners use Streams for efficient code. There were about
passing binary data portably. However maybe outstanding programs convert
variant record data to ASCII text and then compress it. I don't know if
Streams are that essential. One thing that is missing from Ada is an
ability to read from the Standard Input and read directly into an array.

Back to Ada's streams. Strings can be used instead. I do't like I_C():

(1) I_C() reads character by character which is slower than it could be;

(2) I_C() raises exceptions. Some well running TCP programs have the
TCP connect fail often (e.g. 4 times a second). GDB can stop on all of
those exceptions.

Adasocket's TCP connect routine also raises exceptions so the package
is not a solution but it replicates the problem. Here is some of the
Adasockets code (from v1.6):

|   procedure Connect (Socket : in Socket_FD; Host : in String; Port ...
|   ...
|      if C_Connect (Socket.FD, Sin'Address, Sin'Size / 8) = Failure then
|         Current_Errno := Thin.Errno;
|         if Current_Errno = Constants.Econnrefused then
|            raise Connection_Refused;
|         else
|            Raise_With_Message
|              ("Connection failed (errno was" &
|               Integer'Image (Current_Errno) & ')',
|              False);

What would be faster than returning data Character by Character, is to
return the data in a string. Ada's Unbounded Strings is not a serious
option (since I have a faster "Seafood" fast strings package for use
with fast TCP proxies). But few know just how fast the secret Ada
string type is; i.e. the one that passes around strings explaining
exceptions. That unknown string type would be carrying away the Adasockets
error, "Connection failed...".

I had to write a lot of bindings to GNAT.Sockets. 


On 9 May 2003 12:46:48 -0700, file13@qlippoth.zzn.com (file13) wrote:

>Howdy all, I've been tinkering with GNAT.Sockets on Mandrake 9.1 using
>the Gnat-3.15p linux binary and I'm simply trying to write ...
...
>procedure Daytime_Client is
>   Target  : Inet_Addr_Type := Inet_Addr ("127.0.0.1");
>   Socket  : Socket_Type;
>   Server  : Sock_Addr_Type;
>   Channel : Stream_Access;
>begin
>   Initialize;
>   Create_Socket (Socket);
>   Server := (Family_Inet, Target, 13);
>   Connect_Socket (Socket, Server);
>   Channel := Stream (Socket, Server);
>   Put_Line (String'Input (Channel));
>   Shutdown_Socket (Socket);
>   Close_Socket (Socket);
>   Finalize;
...
>$ ./daytime_client
>ADA.IO_EXCEPTIONS.END_ERROR: s-stratt.adb:188
...
>http://www.qlippoth.com/ripban.py [...]
>file13: http://www.qlippoth.com/

Some of that Python code (immediately above) uses Unix signals to timeout
TCP connects. Maybe for Windows, a task would be used instead. Anyway,
signals can cause core dumps. This Python code attempts to kill anything
rather than just one socket:

|        except socket.error:
|            print "Connection refused"
|            sys.exit(1)
|        if os.name == "posix":
|            signal.signal(signal.SIGALRM, alarm_handler)
|            signal.alarm(timeout)
|        banner = sock.recv(1024)

I found that porting TCP code from Windows to Linux, can be slowed a
lot by these issues:
(1) tasks must be carefully unblocked by the program itself, and  Ctrl-C
  SIGTERM, and exit() (GNAT's OS_Exit()) can convert the Linux program
  into a zombie. Badbly designed Ada Linux programs may fail to close.
  It seems to be fixable (despite 1+ GNAT runtime bugs that show up only
  once the program has fully finished).
(2) SO_REUSEADDR needs to be handled correctly (Linux port numbers lock
 up).


Craig Carey








^ permalink raw reply	[relevance 2%]

* GNAT.Sockets Problems
@ 2003-05-09 19:46  2% file13
  2003-05-11  0:51  2% ` Craig Carey
  2003-05-12 11:38  0% ` Simon Clubley
  0 siblings, 2 replies; 195+ results
From: file13 @ 2003-05-09 19:46 UTC (permalink / raw)


Howdy all, I've been tinkering with GNAT.Sockets on Mandrake 9.1 using
the Gnat-3.15p linux binary and I'm simply trying to write the first
day time client from Stevens UNIX Network Programming book with it and
I can't seem to figure out what I'm doing wrong.  The server I've
tested on is the following one from Steven's book (it's in C):

#include        <sys/types.h>   /* basic system data types */
#include        <sys/socket.h>  /* basic socket definitions */
#include        <netinet/in.h>  /* sockaddr_in{} and other Internet
defns */
#include        <arpa/inet.h>   /* inet(3) functions */
#include        <unistd.h>
#include        <stdio.h>
#include        <stdlib.h>
#include        <string.h>
#include        <time.h>

#define MAXLINE         4096    /* max text line length */
#define SA      struct sockaddr
#define LISTENQ         1024    /* 2nd argument to listen() */

int main(int argc, char **argv) {
  int listenfd, connfd;
  struct sockaddr_in servaddr;
  char buff[MAXLINE];
  time_t ticks;

  listenfd = socket(AF_INET, SOCK_STREAM, 0);

  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family      = AF_INET;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port        = htons(13); /* daytime server */


  bind(listenfd, (SA *) &servaddr, sizeof(servaddr));

  listen(listenfd, LISTENQ);

  for ( ; ; ) {
    connfd = accept(listenfd, (SA *) NULL, NULL);

    ticks = time(NULL);
    snprintf(buff, sizeof(buff), "%.24s\r\n", ctime(&ticks));
    write(connfd, buff, strlen(buff));

    close(connfd);
  }
}

I've tested it with the following accompanying C client code and it
works fine:

#include        <sys/types.h>   /* basic system data types */
#include        <sys/socket.h>  /* basic socket definitions */
#include        <netinet/in.h>  /* sockaddr_in{} and other Internet
defns */
#include        <arpa/inet.h>   /* inet(3) functions */
#include        <unistd.h>
#include        <stdio.h>
#include        <stdlib.h>
#include        <string.h>

#define MAXLINE         4096    /* max text line length */
#define SA      struct sockaddr

int main(int argc, char **argv) {
  int sockfd, n;
  char recvline[MAXLINE + 1];
  struct sockaddr_in    servaddr;

  if (argc != 2)
    puts("usage: a.out <IPaddress>");

  if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    puts("socket error");

  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_port   = htons(13);      /* daytime server */
  if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0)
    printf("inet_pton error for %s", argv[1]);

  if (connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) < 0)
    puts("connect error");

  while ( (n = read(sockfd, recvline, MAXLINE)) > 0) {
    recvline[n] = 0;    /* null terminate */
    if (fputs(recvline, stdout) == EOF)
      puts("fputs error");
  }
  if (n < 0)
    puts("read error");

  exit(0);
}

$ ./daytimetcpcli 127.0.0.1
Fri May  9 14:37:41 2003

so far in Ada I have:

with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure Daytime_Client is
   Target  : Inet_Addr_Type := Inet_Addr ("127.0.0.1");
   Socket  : Socket_Type;
   Server  : Sock_Addr_Type;
   Channel : Stream_Access;
begin
   Initialize;
   Create_Socket (Socket);
   Server := (Family_Inet, Target, 13);

   Connect_Socket (Socket, Server);

   Channel := Stream (Socket, Server);
   Put_Line (String'Input (Channel));

   Shutdown_Socket (Socket);
   Close_Socket (Socket);
   Finalize;

exception when E : others =>
   Put_Line (Exception_Name (E)
             & ": " & Exception_Message (E));
end Daytime_Client;

It appears to connect just fine because if I turn off the server it
gives me:

$ ./daytime_client
GNAT.SOCKETS.SOCKET_ERROR: [111] Connection refused

but if it's on I'm getting the following error:

$ ./daytime_client
ADA.IO_EXCEPTIONS.END_ERROR: s-stratt.adb:188

Also if I change the port to something else open like 22 I get a
segmentation fault:

$ ./daytime_client
Segmentation fault

Why wouldn't it get a similar error if it's only ripping the banner
off of the server port?

Am I doing something wrong with the streams (this is the first time
I've used Ada's streams) or do I need to GNAT.Sockets.Receive_Socket? 
If so can anyone provide me with an example?  I know in C you have to
use a loop, but I didn't know if that was necessary with Ada.Streams. 
I tried it with Receive_Socket also, but I could not figure out how to
print the output to regular stdout....

BTW: I have looked at Samuel Tardieu's AdaSockets but I ran into
compilation problems on Mac 10.2.6 (my home box) so I decided to stick
with GNAT.Sockets since the ultimate goal is to eventually get some
portable socket functions, the first of which I would like to get
similar to a simple Python program:

http://www.qlippoth.com/ripban.py

Any help or guidance would be greatly appreciated.  Thanks!

file13
http://www.qlippoth.com/



^ permalink raw reply	[relevance 2%]

* Re: What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean?
  2003-01-27 10:32 12% What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean? Fatafa
  2003-01-27 13:05 10% ` Colin Paul Gloster
@ 2003-01-27 18:33  6% ` Stephen Leake
  1 sibling, 0 replies; 195+ results
From: Stephen Leake @ 2003-01-27 18:33 UTC (permalink / raw)


jul_tuf@hotmail.com (Fatafa) writes:

> I ran a compiled Ada program and got back the error :
> 
> raised ADA.IO_EXCEPTIONS.DATA_ERROR
> 
> Does anyone know what this means?

Run it again under the debugger, and set a break on exceptions. Then
you will be shown the exact line that is causing the problem

Or, if using GNAT, add an exception handler that dumps the stack
symbolically; then you can see the exact line without the debugger.

-- 
-- Stephe



^ permalink raw reply	[relevance 6%]

* Re: What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean?
  2003-01-27 10:32 12% What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean? Fatafa
@ 2003-01-27 13:05 10% ` Colin Paul Gloster
  2003-01-27 18:33  6% ` Stephen Leake
  1 sibling, 0 replies; 195+ results
From: Colin Paul Gloster @ 2003-01-27 13:05 UTC (permalink / raw)


Fatafa said today:
"I ran a compiled Ada program and got back the error :

raised ADA.IO_EXCEPTIONS.DATA_ERROR

Does anyone know what this means?"

When giving input to your program, you probably gave it something it was
not designed to (e.g. maybe it needed a number and you typed in text).

From HTTP://WWW.AdaIC.org/standards/95lrm/html/RM-A-13.html :

"[..]

The exception Data_Error can be propagated by the procedure Read (or by
the Read attribute) if the element read cannot be
interpreted as a value of the required subtype. This exception is also
propagated by a procedure Get (defined in the package
Text_IO) if the input character sequence fails to satisfy the required
syntax, or if the value input does not belong to the range of the
required subtype.

[..]"



^ permalink raw reply	[relevance 10%]

* Re: What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean?
@ 2003-01-27 11:18  6% Grein, Christoph
  0 siblings, 0 replies; 195+ results
From: Grein, Christoph @ 2003-01-27 11:18 UTC (permalink / raw)
  To: comp.lang.ada

> I ran a compiled Ada program and got back the error :
> 
> raised ADA.IO_EXCEPTIONS.DATA_ERROR
> 
> Does anyone know what this means?

Get a text book on Ada. Anybody using Ada knows what this means.

See RM A.13(13) You probably read a data item from a file or keyboard input that 
does not have the expected type.



^ permalink raw reply	[relevance 6%]

* What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean?
@ 2003-01-27 10:32 12% Fatafa
  2003-01-27 13:05 10% ` Colin Paul Gloster
  2003-01-27 18:33  6% ` Stephen Leake
  0 siblings, 2 replies; 195+ results
From: Fatafa @ 2003-01-27 10:32 UTC (permalink / raw)


I ran a compiled Ada program and got back the error :

raised ADA.IO_EXCEPTIONS.DATA_ERROR

Does anyone know what this means?

Thanks



^ permalink raw reply	[relevance 12%]

* Re: advantages or disadvantages of ADA over pascal or modula
  @ 2003-01-05 14:12  6%       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 195+ results
From: Dmitry A. Kazakov @ 2003-01-05 14:12 UTC (permalink / raw)


Steve wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:av6gr5$cgael$1@ID-77047.news.dfncis.de...
>> Steve wrote:
>>
>> >   Ada has no equivalent to Pascal's "with" statement (if you've
> maintained
>> >   a
>> > lot of Pascal code, you know why this is an advantage).
>>
>> In fact Ada 95 has an equivalent of Pascal's "with":
>>
>> X : Some_Type renames An.Extremely.Long.Path.Name.Object;
> 
> After maintaining both Pascal and Ada code, I wholeheartedly disagree that
> Ada's renaming is equivalent to Pascal's with.
> 
> If you're trying to analyze Pascal code that looks something like:
> 
>   with a, b, c, d do
>     begin
>        field1 := fieldA
>     end;
> 
> Tracking down where the !@** field1 and fieldA come from is non trivial. 
> In fact if these fields exist in more than one of the a, b, c, d records
> it may be compiler dependent.
> 
> With Ada's renaming you can easily track a field back to its source.  You
> may have to sift through a few renamings, but in practice this is easy to
> do.

I agree that Ada's "rename" is better than Pascal's "with". However they 
both are responses to same problem. And neither is ideal. For example, 
people often write something like:

with Ada.IO_Exceptions;
package My_IO is
   End_Error : exception renames Ada.IO_Exception.End_Error;

and run into troubles when both Ada.IO_Exceptions and My_IO are "used". This 
causes some people to believe that "use" is inherently bad, which is not 
true.

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: A suggestion, completely unrelated to the original topic
  2002-12-02 19:29  0%   ` A suggestion, completely unrelated to the original topic Wes Groleau
@ 2002-12-02 23:21  0%     ` David C. Hoos, Sr.
  0 siblings, 0 replies; 195+ results
From: David C. Hoos, Sr. @ 2002-12-02 23:21 UTC (permalink / raw)



"Wes Groleau" <wesgroleau@despammed.com> wrote in message
news:4wOG9.2144$c6.2494@bos-service2.ext.raytheon.com...
> When I see something like:
>
> > exception
> >    when A: Ada.Io_Exceptions.Status_Error =>
> >       T_Io.Put_Line("Status_Error in Char_Sets_Test.");
> >       T_Io.Put_Line(Ada.Exceptions.Exception_Information(A));
> >    when O: others =>
> >       T_Io.Put_Line("Others_Error in Char_Sets_Test.");
> >       T_Io.Put_Line(Ada.Exceptions.Exception_Information(O));
>
> I generally think it would be easier to use:
>
> exception
>     when E : others =>
>        T_Io.Put_Line(Ada.Exceptions.Exception_Name(E) &
>                      " in Char_Sets_Test.");
>        T_Io.Put_Line(Ada.Exceptions.Exception_Information(E));
>
Exception_Information repeats the Exception_Name if the implementation
advice is followed, so explicitly outputting the name is probably
redundant.  I think it's also good practice to write information about
exceptions to the Standard_Error file instead of the Standard_Output,
as this makes it easier for the execution environment (e.g., a shell)
to separate exception information from normal output.

Just my $0.02 worth





^ permalink raw reply	[relevance 0%]

* A suggestion, completely unrelated to the original topic
  2002-11-29 20:37  3% ` Robert C. Leif
@ 2002-12-02 19:29  0%   ` Wes Groleau
  2002-12-02 23:21  0%     ` David C. Hoos, Sr.
  0 siblings, 1 reply; 195+ results
From: Wes Groleau @ 2002-12-02 19:29 UTC (permalink / raw)


When I see something like:

> exception
>    when A: Ada.Io_Exceptions.Status_Error =>
>       T_Io.Put_Line("Status_Error in Char_Sets_Test.");
>       T_Io.Put_Line(Ada.Exceptions.Exception_Information(A));
>    when O: others =>
>       T_Io.Put_Line("Others_Error in Char_Sets_Test.");
>       T_Io.Put_Line(Ada.Exceptions.Exception_Information(O));

I generally think it would be easier to use:

exception
    when E : others =>
       T_Io.Put_Line(Ada.Exceptions.Exception_Name(E) &
                     " in Char_Sets_Test.");
       T_Io.Put_Line(Ada.Exceptions.Exception_Information(E));




^ permalink raw reply	[relevance 0%]

* RE: Character Sets (plain text police report)
  @ 2002-11-29 20:37  3% ` Robert C. Leif
  2002-12-02 19:29  0%   ` A suggestion, completely unrelated to the original topic Wes Groleau
  0 siblings, 1 reply; 195+ results
From: Robert C. Leif @ 2002-11-29 20:37 UTC (permalink / raw)


Oops. My apologies.
Bob Leif
The correct text version is below. 
Addendum: The solution is the creation of versions of Ada.Strings.Bounded for 16 and 32 bit characters. The 32 bit Unicode characters allow direct comparison of characters based on their position in Unicode.

-----Original Message-----
From: comp.lang.ada-admin@ada.eu.org [mailto:comp.lang.ada-admin@ada.eu.org] On Behalf Of Warren W. Gay VE3WWG
Sent: Thursday, November 28, 2002 10:09 AM
To: comp.lang.ada@ada.eu.org
Subject: Re: Character Sets (plain text police report)

Hmmm... I guess since Robert Dewar is avoiding this group these
days, we also lost our "plain text" police force ;-)

In case you were not aware of it, you are posting HTML to this
news group. This is generally discouraged so that others who
are not using HTML capable news readers, are still able to make
sense of your posting.
--------------------------------------------------------
Christoph Grein responded to my inquiry by stating that,
" Latin_9.Euro_Sign is a name for a character. The same character in Latin_1 has a different name, it is the Currency_Sign." "So why do you expect this character not to be in the set only because you use a different name for it?" The Euro_Sign and the Currency_Sign have a different representation according to The ISO 8859 Alphabet Soup http://czyborra.com/charsets/iso8859.html
------------------------------------------------
GNAT Latin_9 (ISO-8859-15)includes the following:
   -- Summary of Changes from Latin-1 => Latin-9 --
   ------------------------------------------------

   --   164     Currency                => Euro_Sign
   --   166     Broken_Bar              => UC_S_Caron
   --   168     Diaeresis               => LC_S_Caron
   --   180     Acute                   => UC_Z_Caron
   --   184     Cedilla                 => LC_Z_Caron
   --   188     Fraction_One_Quarter    => UC_Ligature_OE
   --   189     Fraction_One_Half       => LC_Ligature_OE
   --   190     Fraction_Three_Quarters => UC_Y_Diaeresis
Since these are changes, they should not be the same character. Below are the results of an extension of my original program that now tests the characters of Latin_9 from character number 164 through 190 and prints them out. I understand that choice of the Windows font will change their representation. The correct glyphs can be found at The ISO 8859 Alphabet Soup. For anyone interested, I have put my program at the end of this note. I suspect that the best solution would be to introduce UniCode, ISO/IEC 10646, into the Ada standard. The arguments for this are contained in W3C Character Model for the World Wide Web 1.0, W3C Working Draft 30 April 2002 http://www.w3.org/TR/charmod/ "The choice of Unicode was motivated by the fact that Unicode: is the only universal character repertoire available, covers the widest possible range, provides a way of referencing characters independent of the encoding of a resource, is being updated/completed carefully, is widely accepted and implemented by industry." "W3C adopted Unicode as the document character set for HTML in [HTML 4.0]. The same approach was later used for specifications such as XML 1.0 [XML 1.0] and CSS2 [CSS2]. Unicode now serves as a common reference for W3C specifications and applications." "The IETF has adopted some policies on the use of character sets on the Internet (see [RFC 2277])." Bob Leif ------------------------Starting Test----------------------- Latin_9_Diff is ñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛

The Character ñ is in Latin_1 is TRUE. Its position is  164
The Character Ñ is in Latin_1 is TRUE. Its position is  165
The Character ª is in Latin_1 is TRUE. Its position is  166
The Character º is in Latin_1 is TRUE. Its position is  167
The Character ¿ is in Latin_1 is TRUE. Its position is  168
The Character ⌐ is in Latin_1 is TRUE. Its position is  169
The Character ¬ is in Latin_1 is TRUE. Its position is  170
The Character ½ is in Latin_1 is TRUE. Its position is  171
The Character ¼ is in Latin_1 is TRUE. Its position is  172
The Character ¡ is in Latin_1 is TRUE. Its position is  173
The Character « is in Latin_1 is TRUE. Its position is  174
The Character » is in Latin_1 is TRUE. Its position is  175
The Character ░ is in Latin_1 is TRUE. Its position is  176
The Character ▒ is in Latin_1 is TRUE. Its position is  177
The Character ▓ is in Latin_1 is TRUE. Its position is  178
The Character │ is in Latin_1 is TRUE. Its position is  179
The Character ┤ is in Latin_1 is TRUE. Its position is  180
The Character ╡ is in Latin_1 is TRUE. Its position is  181
The Character ╢ is in Latin_1 is TRUE. Its position is  182
The Character ╖ is in Latin_1 is TRUE. Its position is  183
The Character ╕ is in Latin_1 is TRUE. Its position is  184
The Character ╣ is in Latin_1 is TRUE. Its position is  185
The Character ║ is in Latin_1 is TRUE. Its position is  186
The Character ╗ is in Latin_1 is TRUE. Its position is  187
The Character ╝ is in Latin_1 is TRUE. Its position is  188
The Character ╜ is in Latin_1 is TRUE. Its position is  189
The Character ╛ is in Latin_1 is TRUE. Its position is  190 ------------------------Ending Test----------------------- --Robert C. Leif, Ph.D & Ada_Med Copyright all rights reserved. --Main Procedure 
--Created 27 November 2002
with Ada.Text_Io;
with Ada.Io_Exceptions;
with Ada.Exceptions;
with Ada.Strings;
with Ada.Strings.Maps;
with  Ada.Characters.Latin_1;
with  Ada.Characters.Latin_9;
procedure Char_Sets_Test is 
   ------------------Table of Contents------------- 
   package T_Io renames Ada.Text_Io;
   package Str_Maps renames Ada.Strings.Maps;
   package Latin_1 renames Ada.Characters.Latin_1;
   package Latin_9 renames Ada.Characters.Latin_9;
   subtype Character_Set_Type is Str_Maps.Character_Set;
   subtype Character_Sequence_Type is Str_Maps.Character_Sequence;

   -----------------End Table of Contents-------------
   Latin_1_Range    : constant Str_Maps.Character_Range
      := (Low => Latin_1.Nul, High => Latin_1.Lc_Y_Diaeresis);  
   Latin_1_Char_Set :          Character_Set_Type      
      := Str_Maps.To_Set (Span => Latin_1_Range);  
   --Standard for Ada '95
   -- Latin_9 Differences: Euro_Sign, Uc_S_Caron, Lc_S_Caron, Uc_Z_Caron, 
   -- Lc_Z_Caron, Uc_Ligature_Oe, Lc_Ligature_Oe, Uc_Y_Diaeresis.
   Latin_9_Diff_Latin_1_Super_Range  : constant Str_Maps.Character_Range
      := (Low => Latin_9.Euro_Sign, High => Latin_9.Uc_Y_Diaeresis);  
   Latin_9_Diff_Latin_1_Super_Set    :          Character_Set_Type      
      := Str_Maps.To_Set (Span => Latin_9_Diff_Latin_1_Super_Range);  
   Latin_9_Diff_Latin_1_Super_String :          Character_Sequence_Type 
      := Str_Maps.To_Sequence (Latin_9_Diff_Latin_1_Super_Set);  
   Character_Set_Name                :          String                 
      := "Latin_1";  
   ---------------------------------------------   
   procedure Test_Character_Sets (
         Character_Sequence_Var : in     Character_Sequence_Type; 
         Set                    : in     Character_Set_Type       ) is 
      Is_In_Character_Set : Boolean   := False;  
      Char                : Character := 'X';  
      Character_Set_Position : Positive := 164; -- Euro_Sign   
   begin--Test_Character_Sets
      T_Io.Put_Line("Latin_9_Diff is " & Latin_9_Diff_Latin_1_Super_String);
      T_Io.Put_Line("");
      Test_Chars:
         for I in Character_Sequence_Var'range loop
         Char:= Character_Sequence_Var(I);
         Is_In_Character_Set:= Str_Maps.Is_In(
            Element => Char,            
            Set     => Latin_1_Char_Set);
         T_Io.Put_Line("The Character " & Char & " is in " & Character_Set_Name
            &  " is " & Boolean'Image (
               Is_In_Character_Set) & ". Its position is "
                  & Positive'Image(Character_Set_Position));
         Character_Set_Position:= Character_Set_Position + 1;
      end loop Test_Chars;
   end Test_Character_Sets;
   ---------------------------------------------     
begin--Bd_W_Char_Sets_Test
   T_Io.Put_Line("----------------------Starting Test---------------------);
   Test_Character_Sets (
      Character_Sequence_Var => Latin_9_Diff_Latin_1_Super_String, 
      Set                    => Latin_1_Char_Set);
   ---------------------------------------------
   T_Io.Put_Line("------------------------Ending Test---------------------);

exception
   when A: Ada.Io_Exceptions.Status_Error =>
      T_Io.Put_Line("Status_Error in Char_Sets_Test.");
      T_Io.Put_Line(Ada.Exceptions.Exception_Information(A));
   when O: others =>
      T_Io.Put_Line("Others_Error in Char_Sets_Test.");
      T_Io.Put_Line(Ada.Exceptions.Exception_Information(O));

end Char_Sets_Test;




^ permalink raw reply	[relevance 3%]

* Re: Character Sets
@ 2002-11-28 17:53  3% Robert C. Leif
  0 siblings, 0 replies; 195+ results
From: Robert C. Leif @ 2002-11-28 17:53 UTC (permalink / raw)


Christoph Grein responded to my inquiry by stating that,
" Latin_9.Euro_Sign is a name for a character. The same character in Latin_1 has a different name, it is the Currency_Sign."
"So why do you expect this character not to be in the set only because you use a different name for it?"
The Euro_Sign and the Currency_Sign have a different representation according to The ISO 8859 Alphabet Soup http://czyborra.com/charsets/iso8859.html
------------------------------------------------
GNAT Latin_9 (ISO-8859-15)includes the following:
   -- Summary of Changes from Latin-1 => Latin-9 --
   ------------------------------------------------

   --   164     Currency                => Euro_Sign
   --   166     Broken_Bar              => UC_S_Caron
   --   168     Diaeresis               => LC_S_Caron
   --   180     Acute                   => UC_Z_Caron
   --   184     Cedilla                 => LC_Z_Caron
   --   188     Fraction_One_Quarter    => UC_Ligature_OE
   --   189     Fraction_One_Half       => LC_Ligature_OE
   --   190     Fraction_Three_Quarters => UC_Y_Diaeresis
Since these are changes, they should not be the same character.
Below are the results of an extension of my original program that now tests the characters of Latin_9 from character number 164 through 190 and prints them out. I understand that choice of the Windows font will change their representation. The correct glyphs can be found at The ISO 8859 Alphabet Soup. For anyone interested, I have put my program at the end of this note.
I suspect that the best solution would be to introduce UniCode, ISO/IEC 10646, into the Ada standard. The arguments for this are contained in W3C Character Model for the World Wide Web 1.0, W3C Working Draft 30 April 2002
http://www.w3.org/TR/charmod/
"The choice of Unicode was motivated by the fact that Unicode: is the only universal character repertoire available, covers the widest possible range, provides a way of referencing characters independent of the encoding of a resource, is being updated/completed carefully, is widely accepted and implemented by industry."
"W3C adopted Unicode as the document character set for HTML in [HTML 4.0]. The same approach was later used for specifications such as XML 1.0 [XML 1.0] and CSS2 [CSS2]. Unicode now serves as a common reference for W3C specifications and applications."
"The IETF has adopted some policies on the use of character sets on the Internet (see [RFC 2277])."
Bob Leif
------------------------Starting Test-----------------------
Latin_9_Diff is ñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛

The Character ñ is in Latin_1 is TRUE. Its position is  164
The Character Ñ is in Latin_1 is TRUE. Its position is  165
The Character ª is in Latin_1 is TRUE. Its position is  166
The Character º is in Latin_1 is TRUE. Its position is  167
The Character ¿ is in Latin_1 is TRUE. Its position is  168
The Character ⌐ is in Latin_1 is TRUE. Its position is  169
The Character ¬ is in Latin_1 is TRUE. Its position is  170
The Character ½ is in Latin_1 is TRUE. Its position is  171
The Character ¼ is in Latin_1 is TRUE. Its position is  172
The Character ¡ is in Latin_1 is TRUE. Its position is  173
The Character « is in Latin_1 is TRUE. Its position is  174
The Character » is in Latin_1 is TRUE. Its position is  175
The Character ░ is in Latin_1 is TRUE. Its position is  176
The Character ▒ is in Latin_1 is TRUE. Its position is  177
The Character ▓ is in Latin_1 is TRUE. Its position is  178
The Character │ is in Latin_1 is TRUE. Its position is  179
The Character ┤ is in Latin_1 is TRUE. Its position is  180
The Character ╡ is in Latin_1 is TRUE. Its position is  181
The Character ╢ is in Latin_1 is TRUE. Its position is  182
The Character ╖ is in Latin_1 is TRUE. Its position is  183
The Character ╕ is in Latin_1 is TRUE. Its position is  184
The Character ╣ is in Latin_1 is TRUE. Its position is  185
The Character ║ is in Latin_1 is TRUE. Its position is  186
The Character ╗ is in Latin_1 is TRUE. Its position is  187
The Character ╝ is in Latin_1 is TRUE. Its position is  188
The Character ╜ is in Latin_1 is TRUE. Its position is  189
The Character ╛ is in Latin_1 is TRUE. Its position is  190
------------------------Ending Test-----------------------
--Robert C. Leif, Ph.D & Ada_Med Copyright all rights reserved.
--Main Procedure 
--Created 27 November 2002
with Ada.Text_Io;
with Ada.Io_Exceptions;
with Ada.Exceptions;
with Ada.Strings;
with Ada.Strings.Maps;
with  Ada.Characters.Latin_1;
with  Ada.Characters.Latin_9;
procedure Char_Sets_Test is 
   ------------------Table of Contents------------- 
   package T_Io renames Ada.Text_Io;
   package Str_Maps renames Ada.Strings.Maps;
   package Latin_1 renames Ada.Characters.Latin_1;
   package Latin_9 renames Ada.Characters.Latin_9;
   subtype Character_Set_Type is Str_Maps.Character_Set;
   subtype Character_Sequence_Type is Str_Maps.Character_Sequence;

   -----------------End Table of Contents-------------
   Latin_1_Range    : constant Str_Maps.Character_Range
      := (Low => Latin_1.Nul, High => Latin_1.Lc_Y_Diaeresis);  
   Latin_1_Char_Set :          Character_Set_Type      
      := Str_Maps.To_Set (Span => Latin_1_Range);  
   --Standard for Ada '95
   -- Latin_9 Differences: Euro_Sign, Uc_S_Caron, Lc_S_Caron, Uc_Z_Caron, 
   -- Lc_Z_Caron, Uc_Ligature_Oe, Lc_Ligature_Oe, Uc_Y_Diaeresis.
   Latin_9_Diff_Latin_1_Super_Range  : constant Str_Maps.Character_Range
      := (Low => Latin_9.Euro_Sign, High => Latin_9.Uc_Y_Diaeresis);  
   Latin_9_Diff_Latin_1_Super_Set    :          Character_Set_Type      
      := Str_Maps.To_Set (Span => Latin_9_Diff_Latin_1_Super_Range);  
   Latin_9_Diff_Latin_1_Super_String :          Character_Sequence_Type 
      := Str_Maps.To_Sequence (Latin_9_Diff_Latin_1_Super_Set);  
   Character_Set_Name                :          String                 
      := "Latin_1";  
   ---------------------------------------------   
   procedure Test_Character_Sets (
         Character_Sequence_Var : in     Character_Sequence_Type; 
         Set                    : in     Character_Set_Type       ) is 
      Is_In_Character_Set : Boolean   := False;  
      Char                : Character := 'X';  
      Character_Set_Position : Positive := 164; -- Euro_Sign   
   begin--Test_Character_Sets
      T_Io.Put_Line("Latin_9_Diff is " & Latin_9_Diff_Latin_1_Super_String);
      T_Io.Put_Line("");
      Test_Chars:
         for I in Character_Sequence_Var'range loop
         Char:= Character_Sequence_Var(I);
         Is_In_Character_Set:= Str_Maps.Is_In(
            Element => Char,            
            Set     => Latin_1_Char_Set);
         T_Io.Put_Line("The Character " & Char & " is in " & Character_Set_Name
            &  " is " & Boolean'Image (
               Is_In_Character_Set) & ". Its position is "
                  & Positive'Image(Character_Set_Position));
         Character_Set_Position:= Character_Set_Position + 1;
      end loop Test_Chars;
   end Test_Character_Sets;
   ---------------------------------------------     
begin--Bd_W_Char_Sets_Test
   T_Io.Put_Line("----------------------Starting Test---------------------);
   Test_Character_Sets (
      Character_Sequence_Var => Latin_9_Diff_Latin_1_Super_String, 
      Set                    => Latin_1_Char_Set);
   ---------------------------------------------
   T_Io.Put_Line("------------------------Ending Test---------------------);

exception
   when A: Ada.Io_Exceptions.Status_Error =>
      T_Io.Put_Line("Status_Error in Char_Sets_Test.");
      T_Io.Put_Line(Ada.Exceptions.Exception_Information(A));
   when O: others =>
      T_Io.Put_Line("Others_Error in Char_Sets_Test.");
      T_Io.Put_Line(Ada.Exceptions.Exception_Information(O));

end Char_Sets_Test;




^ permalink raw reply	[relevance 3%]

* Re: Character Sets
@ 2002-11-27  9:00  0% Grein, Christoph
  0 siblings, 0 replies; 195+ results
From: Grein, Christoph @ 2002-11-27  9:00 UTC (permalink / raw)


> From: Bob Leif
> I am trying to test if a character is not in the Latin_1 character set.
> I choose the Euro because it is in Latin_9 and not in Latin_1. I tested
> the function Ada.Strings.Maps.Is_In. It returns that the Euro_Sign is in
> the Latin_1 character set. What have I done wrong?
> My test program, which compiled and executed under GNAT 3.15p under
> Windows XP, produced:
> ------------------------Starting Test-----------------------
> Is_In_Character_Set is TRUE
> ------------------------Ending Test-----------------------
>  The test program is as follows:
> ---------------------------------------------------------
> with Ada.Text_Io;
> with Ada.Io_Exceptions;
> with Ada.Exceptions;
> with Ada.Strings;
> with Ada.Strings.Maps;
> with  Ada.Characters.Latin_1;
> with  Ada.Characters.Latin_9;
> procedure Char_Sets_Test is 
>    ------------------Table of Contents------------- 
>    package T_Io renames Ada.Text_Io;
>    package Str_Maps renames Ada.Strings.Maps;
>    package Latin_1 renames Ada.Characters.Latin_1;
>    package Latin_9 renames Ada.Characters.Latin_9;
>    subtype Character_Set_Type is Str_Maps.Character_Set;
>    -----------------End Table of Contents-------------
>    Latin_1_Range    : constant Str_Maps.Character_Range
> 	 := (Low => Latin_1.Nul, High => Latin_1.Lc_Y_Diaeresis);  

This is the full range of type Character, isn't it.

>    Latin_1_Char_Set :          Character_Set_Type       :=
> Str_Maps.To_Set 	(Span => Latin_1_Range);  

So this is the set of all characters.

>    --Standard for Ada '95
>    Is_In_Character_Set : Boolean := False;  
>    ---------------------------------------------
> begin--Bd_W_Char_Sets_Test
>    T_Io.Put_Line("-----------------------Starting
> Test--------------------);
>    ---------------------------------------------
>    --Test Character_Sets
>    Is_In_Character_Set:=Ada.Strings.Maps.Is_In (
>       Element => Latin_9.Euro_Sign, 
>       Set     => Latin_1_Char_Set);

Latin_9.Euro_Sign is a name for a character. The same character in Latin1 has a 
different name, it is the Currency_Sign.

So why do you expect this character not to be in the set only because you use a 
different name for it?

>    T_Io.Put_Line("Is_In_Character_Set is " & Boolean'Image
> (Is_In_Character_Set));
>    ---------------------------------------------   
>    ---------------------------------------------
>    T_Io.Put_Line("-----------------------Ending
> Test----------------------);
> 
> exception
>    when A: Ada.Io_Exceptions.Status_Error =>
>       T_io.Put_Line("Status_Error in Char_Sets_Test.");
>       T_Io.Put_Line(Ada.Exceptions.Exception_Information(A));
>    when O: others =>
>       T_Io.Put_Line("Others_Error in Char_Sets_Test.");
>       T_Io.Put_Line(Ada.Exceptions.Exception_Information(O));
> end Char_Sets_Test;
> 
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada



^ permalink raw reply	[relevance 0%]

* Character Sets
@ 2002-11-26 21:41  5% Robert C. Leif
  0 siblings, 0 replies; 195+ results
From: Robert C. Leif @ 2002-11-26 21:41 UTC (permalink / raw)


From: Bob Leif
I am trying to test if a character is not in the Latin_1 character set.
I choose the Euro because it is in Latin_9 and not in Latin_1. I tested
the function Ada.Strings.Maps.Is_In. It returns that the Euro_Sign is in
the Latin_1 character set. What have I done wrong?
My test program, which compiled and executed under GNAT 3.15p under
Windows XP, produced:
------------------------Starting Test-----------------------
Is_In_Character_Set is TRUE
------------------------Ending Test-----------------------
 The test program is as follows:
---------------------------------------------------------
with Ada.Text_Io;
with Ada.Io_Exceptions;
with Ada.Exceptions;
with Ada.Strings;
with Ada.Strings.Maps;
with  Ada.Characters.Latin_1;
with  Ada.Characters.Latin_9;
procedure Char_Sets_Test is 
   ------------------Table of Contents------------- 
   package T_Io renames Ada.Text_Io;
   package Str_Maps renames Ada.Strings.Maps;
   package Latin_1 renames Ada.Characters.Latin_1;
   package Latin_9 renames Ada.Characters.Latin_9;
   subtype Character_Set_Type is Str_Maps.Character_Set;
   -----------------End Table of Contents-------------
   Latin_1_Range    : constant Str_Maps.Character_Range
	 := (Low => Latin_1.Nul, High => Latin_1.Lc_Y_Diaeresis);  
   Latin_1_Char_Set :          Character_Set_Type       :=
Str_Maps.To_Set 	(Span => Latin_1_Range);  
   --Standard for Ada '95
   Is_In_Character_Set : Boolean := False;  
   ---------------------------------------------
begin--Bd_W_Char_Sets_Test
   T_Io.Put_Line("-----------------------Starting
Test--------------------);
   ---------------------------------------------
   --Test Character_Sets
   Is_In_Character_Set:=Ada.Strings.Maps.Is_In (
      Element => Latin_9.Euro_Sign, 
      Set     => Latin_1_Char_Set);
   T_Io.Put_Line("Is_In_Character_Set is " & Boolean'Image
(Is_In_Character_Set));
   ---------------------------------------------   
   ---------------------------------------------
   T_Io.Put_Line("-----------------------Ending
Test----------------------);

exception
   when A: Ada.Io_Exceptions.Status_Error =>
      T_io.Put_Line("Status_Error in Char_Sets_Test.");
      T_Io.Put_Line(Ada.Exceptions.Exception_Information(A));
   when O: others =>
      T_Io.Put_Line("Others_Error in Char_Sets_Test.");
      T_Io.Put_Line(Ada.Exceptions.Exception_Information(O));
end Char_Sets_Test;




^ permalink raw reply	[relevance 5%]

* Re: Thought this was interesting (OT)
  @ 2002-08-27 20:07  5%       ` Chad R. Meiners
  0 siblings, 0 replies; 195+ results
From: Chad R. Meiners @ 2002-08-27 20:07 UTC (permalink / raw)



"Hyman Rosen" <hyrosen@mail.com> wrote in message
news:1030464758.505647@master.nyc.kbcfp.com...
> Apropos of this, if you have access to a Windows system,
> try running the following simple program there. Make sure
> to save all important work first! It just prints out a
> string over and over again. It couldn't do anything bad,
> could it? Especially not on WinNT or WIn2K, right?
> Especially if you have no special privileges, right? :-)
>
> with text_io; use text_io;
> with ada.characters.latin_1; use ada.characters.latin_1;
> procedure crash is
> begin
>    loop
>      put("Hung up!" & HT & BS & BS & BS & BS & BS & BS);
>    end loop;
> end;
>

hmm...   All I get is some garbage followed by a

raised ADA.IO_EXCEPTIONS.DEVICE_ERROR : s-fileio.adb:987

which although is a rather strange error, it doesn't crash my Win2K system.
:)

-CRM





^ permalink raw reply	[relevance 5%]

* Re: Fill string with multiple lines from standard_input
  @ 2002-08-16 17:33  3% ` Alexei Polkhanov
  0 siblings, 0 replies; 195+ results
From: Alexei Polkhanov @ 2002-08-16 17:33 UTC (permalink / raw)


Did you consider using POSIX library like Florist ? Like this code I use in
order to read
configuration parameters:

----------------------------------------------------------------------------
----
    -- Read configuration parameters from file
    ------------------------------------------------------------------------
--------
    procedure Read_Configuration(File : in String; Options : in out
Service_Options)
    is
        ConfigFile         : POSIX.IO.File_Descriptor;
        ConfigPathname     : POSIX.Pathname :=
           POSIX.To_POSIX_String(File & ASCII.NUL);

        LineNum            : Integer := 0;
        Total              : POSIX.IO_Count := 0; -- total characters read
    begin

        declare

            Use  POSIX;

            Buffer          : POSIX.IO.IO_Buffer(1..Read_Block_Size); --
read buffer
            LineBuffer      : POSIX.IO.IO_Buffer(1..256); -- temporary
buffer to skim line
            Last            : POSIX.IO_Count; -- last character in read
buffer

            CopyFromPosition: Integer := 0;
            PasteAtPosition : Integer := 1;
            CharactersToCopy: Integer := 0;

            -- copy characters from read buffer into line buffer
            procedure AddCharactersToLine is
            begin
                LineBuffer(PasteAtPosition..(PasteAtPosition +
CharactersToCopy - 1 )) :=
                    Buffer(CopyFromPosition..(CopyFromPosition +
CharactersToCopy - 1 ));
            end AddCharactersToLine;

            ParamName : Token;
            ParamValue: Token;

        begin
            ConfigFile := POSIX.IO.Open(ConfigPathname, POSIX.IO.Read_Only);

            while true loop

                 POSIX.IO.Read(ConfigFile, Buffer, Last);

                 CopyFromPosition := 0;
                 CharactersToCopy := 0;

                 for BufferPos in 1..Last loop
                     if Buffer(Integer(BufferPos)) = LF then

                         if CharactersToCopy > 0 then
                             AddCharactersToLine;

                             declare
                                Line : String :=
POSIX.To_String(LineBuffer(LineBuffer'First..CharactersToCopy));
                             begin
                                Split(Line, ParamName, ParamValue);
                                UpdateValue(Line, ParamName, ParamValue);

                                -- if ParamName.exists and ParamValue.exists
then
                                --   Put_Line(Integer'Image(LineNum) & ": "
                                --      &
Line(ParamName.first..ParamName.last)
                                --      & " =[" &
Line(ParamValue.first..ParamValue.last) & "]");
                                -- else
                                --   null;
                                -- end if;

                             end;

                             CharactersToCopy := 0;
                             CopyFromPosition := 0;
                             PasteAtPosition := 1;

                         else
                             null;
                         end if;

                         LineNum := LineNum + 1;
                      else
                             if CopyFromPosition = 0 then
                                 CopyFromPosition := Integer(BufferPos);
                             else
                                 null;
                             end if;
                             CharactersToCopy := CharactersToCopy + 1;
                      end if;
                  end loop;

                  if CharactersToCopy > 0 then
                      AddCharactersToLine;
                      PasteAtPosition := CharactersToCopy;
                  else
                      null;
                  end if;

                  Total := Total + Last;

              end loop;

            exception
                -- when Ada.Io_Exceptions.End_Error =>
                --    POSIX.IO.Close(ConfigFile);
                when others =>
                    POSIX.IO.Close(ConfigFile);
        end;

        exception
            when others =>
                Put_Line("Exception rethrown");

    end Read_Configuration;


Cheers,

---
Alexei Polkhanov,
Sr. Software Engineer,
Incognito Software Inc,
Vancouver, Canada

"Vincent Smeets" <No@Spam.org> wrote in message
news:ajebhb$ndl$01$1@news.t-online.com...
> Hallo,
>
> How can I fill a string with multiple lines from the standard_input? I
want
> to have all the characters read from the input till a end of file in a
> string.
>
> In C I can do it like this:
>     char buffer[1024];
>     ssize_t length;
>
>     length = read (1, buffer, sizeof (buffer));
>     if (length < 0) {
>         perror ("read");
>         exit (1);
>     }
>
> I can do it with Get_Immediate:
>     Buffer : String (1 .. 1024);
>     Length : Natural;
>
>     Length := 0;
>     while not Ent_Of_File and Length < Buffer'Last loop
>         Length := Length + 1;
>         Get_Immediate (Buffer (Length));
>     end loop;
> This works but is very slow with GNAT 3.13p on Windows 2000.
>
> I haven't tried sequential IO, but that is also character by character. I
> want something to read a buffer at once. I have been thinking about using
> streams. Something like:
>     Buffer : String (1 .. 1024);
>
>     String'Read (
>         Text_IO.Text_Streams.Stream (Text_IO.Standard_Input),
>         Buffer);
> But here I don't know how much of the Buffer has been filled.
>
> The last non portable design is to use a pragma import for the C "read"
> function. It will work but I don't like it because it isn't portable.
>
> Is the a nice Ada95 way to do this?
>
>





^ permalink raw reply	[relevance 3%]

* Output to Printer Problems
@ 2002-06-09 15:29  4% Pheet
  0 siblings, 0 replies; 195+ results
From: Pheet @ 2002-06-09 15:29 UTC (permalink / raw)


Hiya,

I am having problems printing with ada. I'm using GNAT 3.13p
(GCC 2.8.1) on a Win98 box (yes, I know, don't ask).

I'm trying code along these lines:

with Text_IO;
use Text_io;

...

Procedure Print is
File:FIle_Type;
Begin
        open (File, Out_Mode, "LPT1");
        put(File, "Hello Printer!");
        close(File);
...
end print;

My printer is definitely called LPT1 'cause it's there in the
hardware
profile and i can do:
>type test.txt > LPT1 
from the dos prompt and this works as expected.

The error I get is always ADA.IO_EXCEPTIONS.STATUS_ERROR , not a
name
error.

Any ideas or suggestions on this would be greatfully appreciated, as
it's starting to irritate me now! :-)

TIA,

Pheet



^ permalink raw reply	[relevance 4%]

* Output to Printer Problems
@ 2002-06-09 14:39  4% Pheet
  0 siblings, 0 replies; 195+ results
From: Pheet @ 2002-06-09 14:39 UTC (permalink / raw)


Hiya,

I am having problems printing with ada. I'm using GNAT 3.13p
(GCC 2.8.1) on a Win98 box (yes, I know, don't ask).

I'm trying code along these lines:

with Text_IO;
use Text_io;

...

Procedure Print is
File:FIle_Type;
Begin
	open (File, Out_Mode, "LPT1");
	put(File, "Hello Printer!");
	close(File);
...
end print;

My printer is definitely called LPT1 'cause it's there in the hardware
profile and i can do:
>type test.txt > LPT1 
from the dos prompt and this works as expected.

The error I get is always ADA.IO_EXCEPTIONS.STATUS_ERROR , not a name
error.

Any ideas or suggestions on this would be greatfully appreciated, as
it's starting to irritate me now! :-)

TIA,

Pheet



^ permalink raw reply	[relevance 4%]

* Re: Exceptions in GNAT
  2002-06-02 11:04  6% ` David Rasmussen
@ 2002-06-02 12:39  0%   ` Jeffrey Creem
  0 siblings, 0 replies; 195+ results
From: Jeffrey Creem @ 2002-06-02 12:39 UTC (permalink / raw)


The only exceptions you are getting are coming from the IO (Data_Error) when
you enter
integers larger then the largest integer. There is explicit code hiding in
the body of text_IO.integer_IOt
that is finding that your data is not appropriate for the type.

What you want is integer overflow checking enabled. GNAT/GCC require a few
options to get
LRM compliant checks "On". GNAT does have many checks enabled by default bit
integer
overflow is not one of them. Check the google history of this group for the
"best" recommended options.

When in the heat of development, I usually use something like :

gnatmake -g -gnato -fstack-check  my_program_name

You need to read through the GNAT users guide to get the rest of the options
for your other questions (since I am not entirely clear how many of these
questions
are part of the assignment and how many are personal knowledge requests).







"David Rasmussen" <pinkfloydhomer@yahoo.com> wrote in message
news:3CF9FBC1.7040701@yahoo.com...
> David Rasmussen wrote:
> > I am learning Ada, and in one exercise I am told to find out how large
> > and integer I can use on my system, before it overflows. The exercise
> > just tells me to add two larger and larger numbers and see when an
> > exception occurs. I have just compiled my program with gnatmake with no
> > options, and I am using gcc 3.1 . When the numbers get large enough, the
> > result is just a negative number because of wrap-around. Shouldn't I get
> > an exception, unless I turn it off? How do I compile for with most
> > checks for debug builds, and how do I compile with everything turned off
> > for performance intensive release builds?
> >
> > /David
> >
>
> D'oh.... This is weird:
>
> Enter two integers: 2100000000 0
> The sum is 2100000000
> david@amadeus-T23:~/src/Ada/Ex21$ ./sum
> Enter two integers: 2200000000 0
>
>
> raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at
> a-inteio.ads:20
> david@amadeus-T23:~/src/Ada/Ex21$ ./sum
> Enter two integers: 2147483648 0
>
>
> raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at
> a-inteio.ads:20
> david@amadeus-T23:~/src/Ada/Ex21$ ./sum
> Enter two integers: 2147483647 0
> The sum is 2147483647
> david@amadeus-T23:~/src/Ada/Ex21$ ./sum
> Enter two integers: 2147483647 1
> The sum is-2147483648
> david@amadeus-T23:~/src/Ada/Ex21$ ./sum
> Enter two integers: 2147483647 2
> The sum is-2147483647
> david@amadeus-T23:~/src/Ada/Ex21$
>
> Sometimes there's an exception, and sometimes there isn't... What's
> happening??
>
> /David
>





^ permalink raw reply	[relevance 0%]

* Re: Exceptions in GNAT
  @ 2002-06-02 11:04  6% ` David Rasmussen
  2002-06-02 12:39  0%   ` Jeffrey Creem
  0 siblings, 1 reply; 195+ results
From: David Rasmussen @ 2002-06-02 11:04 UTC (permalink / raw)


David Rasmussen wrote:
> I am learning Ada, and in one exercise I am told to find out how large 
> and integer I can use on my system, before it overflows. The exercise 
> just tells me to add two larger and larger numbers and see when an 
> exception occurs. I have just compiled my program with gnatmake with no 
> options, and I am using gcc 3.1 . When the numbers get large enough, the 
> result is just a negative number because of wrap-around. Shouldn't I get 
> an exception, unless I turn it off? How do I compile for with most 
> checks for debug builds, and how do I compile with everything turned off 
> for performance intensive release builds?
> 
> /David
> 

D'oh.... This is weird:

Enter two integers: 2100000000 0
The sum is 2100000000
david@amadeus-T23:~/src/Ada/Ex21$ ./sum
Enter two integers: 2200000000 0


raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at 
a-inteio.ads:20
david@amadeus-T23:~/src/Ada/Ex21$ ./sum
Enter two integers: 2147483648 0


raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at 
a-inteio.ads:20
david@amadeus-T23:~/src/Ada/Ex21$ ./sum
Enter two integers: 2147483647 0
The sum is 2147483647
david@amadeus-T23:~/src/Ada/Ex21$ ./sum
Enter two integers: 2147483647 1
The sum is-2147483648
david@amadeus-T23:~/src/Ada/Ex21$ ./sum
Enter two integers: 2147483647 2
The sum is-2147483647
david@amadeus-T23:~/src/Ada/Ex21$

Sometimes there's an exception, and sometimes there isn't... What's 
happening??

/David




^ permalink raw reply	[relevance 6%]

* Constraint error help..
@ 2002-05-20 23:09  5% tr4ck
  0 siblings, 0 replies; 195+ results
From: tr4ck @ 2002-05-20 23:09 UTC (permalink / raw)


I am getting a constraint error for this line Word_Array(I) := Word; and I
can't figure out why, the program compiles fine.  Below is the code for the
program.  The program reads in a text file, say the file has the line, This
is a test, it just reads character by character seeing if the item is
actually a character if so it puts it into a string called word.  Then the
word gets put into an word_Array.  This is something simple that I am
trying, so it just returns if the item is not a character or if their are
spaces.  Can someone tell my why I am getting a constaint error?

Thanks.
WITH Ada.Text_IO;
WITH Ada.Characters.Handling;
WITH Ada.IO_Exceptions;
PROCEDURE FileArray IS

  FileName  : String(1..80);
  MaxName   : CONSTANT Positive := 80;
  SUBTYPE NameRange IS Positive RANGE 1..MaxName;
  Length    : NameRange;
  DataFile  : Ada.Text_IO.File_Type;
  Letter    : Character;
  Word      : String(1..10);
  I         : Integer := 0;
  Word_Array : ARRAY(1..30) OF String(1..10);

PROCEDURE OpenFile IS --Opens a file

BEGIN

  LOOP
    BEGIN
      Ada.Text_IO.Put(Item => "Enter the name of the file > ");
      Ada.Text_IO.Get_Line(Item => FileName, Last => Length);
      Ada.Text_IO.Open(File => DataFile, Mode => Ada.Text_IO.In_File, Name
=> FileName(1..Length));
      Ada.Text_IO.Put("File Opened");
      EXIT;

      EXCEPTION
      WHEN Constraint_Error =>
      Ada.Text_IO.Put(Item => "Constraint Error! ");
      Ada.Text_IO.Skip_Line;

      WHEN Ada.Text_IO.Data_Error =>
      Ada.Text_IO.Put(Item => "Data Error! ");
      Ada.Text_IO.Skip_Line;

      WHEN Ada.Text_IO.End_Error =>
      Ada.Text_IO.Put(Item => "End Error! ");
      Ada.Text_IO.Skip_Line;

      WHEN Ada.IO_Exceptions.Status_Error => Ada.Text_IO.Skip_Line;
      WHEN Ada.IO_Exceptions.Name_Error =>
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Cannot Open " & FileName(1..Length) & "!");
      Ada.Text_IO.New_Line;
    END;
  END LOOP;
END OpenFile;

PROCEDURE Convert IS -- Changes the characters to lowercase

BEGIN

  LOOP
    EXIT WHEN Ada.Text_IO.End_Of_File(File => DataFile);
    LOOP
      EXIT WHEN Ada.Text_IO.End_Of_Line(File => DataFile);
      Ada.Text_IO.Get(File => DataFile, Item => Letter);
      Letter := Ada.Characters.Handling.To_Lower(Item => Letter);
    END LOOP;
    Ada.Text_IO.Skip_Line(File => DataFile);
  END LOOP;

END Convert;

PROCEDURE CheckChar IS -- Check one item at a time to see if its a
character,
                       -- if it is then it puts it in the word string

BEGIN

  LOOP
   IF Letter IN 'a'..'z' THEN
      Word(I) := Letter;
    ELSE
      RETURN;
    END IF;
  I := I + 1;
  END LOOP;

END CheckChar;

PROCEDURE Store IS -- Puts the words in the word_array

BEGIN

    I := 0;
  LOOP
    IF I <= 30 THEN
      Word_Array(I) := Word;
    ELSE
      RETURN;
    END IF;
  I := I + 1;
  END LOOP;

END Store;

PROCEDURE Display IS  -- Displays the contents of the word array

BEGIN

  I := 1;
  LOOP
    Ada.Text_IO.Put(Item => Word_Array(I));
    I := I + 1;
  END LOOP;

END Display;

BEGIN

  OpenFile;
  Convert;
  CheckChar;
  Store;
  Display;

END FileArray;









^ permalink raw reply	[relevance 5%]

* Re: Reading raw disks (Windows)
  2002-04-29  1:11  5% ` Steve Doiel
@ 2002-04-29  2:06  0%   ` Larry Hazel
  0 siblings, 0 replies; 195+ results
From: Larry Hazel @ 2002-04-29  2:06 UTC (permalink / raw)


Steve Doiel wrote:
> 
> I haven't tried it, but after looking at the Win32 documentation it appears
> you may have better luck with:
>   \\.\Z:
> at least on NT/W2K

On Windows 98 SE I get a NAME_ERROR.  Maybe it's not possible.

Larry
> 
> SteveD
> 
> "Larry Hazel" <lhhazel@otelco.net> wrote in message
> news:3CCAC0DB.32090922@otelco.net...
> > Is there any way to open a raw disk for reading under Windows?  I tried
> opening
> > "Z:" with sequential_io, but got
> >
> > raised ADA.IO_EXCEPTIONS.USE_ERROR : s-fileio.adb:833
> >
> > Using GNAT 3.14p.  By the way, shouldn't that be
> Ada.IO_EXCEPTIONS.USE_ERROR?
> > We chide everyone else about proper capitalization of Ada.
> >
> > Larry


-- 
Larry Hazel
480 West Point Loop
Somerville, AL 35670-5533



^ permalink raw reply	[relevance 0%]

* Re: Reading raw disks (Windows)
  2002-04-27 15:16  6% Reading raw disks (Windows) Larry Hazel
@ 2002-04-29  1:11  5% ` Steve Doiel
  2002-04-29  2:06  0%   ` Larry Hazel
  0 siblings, 1 reply; 195+ results
From: Steve Doiel @ 2002-04-29  1:11 UTC (permalink / raw)


I haven't tried it, but after looking at the Win32 documentation it appears
you may have better luck with:
  \\.\Z:
at least on NT/W2K

SteveD

"Larry Hazel" <lhhazel@otelco.net> wrote in message
news:3CCAC0DB.32090922@otelco.net...
> Is there any way to open a raw disk for reading under Windows?  I tried
opening
> "Z:" with sequential_io, but got
>
> raised ADA.IO_EXCEPTIONS.USE_ERROR : s-fileio.adb:833
>
> Using GNAT 3.14p.  By the way, shouldn't that be
Ada.IO_EXCEPTIONS.USE_ERROR?
> We chide everyone else about proper capitalization of Ada.
>
> Larry





^ permalink raw reply	[relevance 5%]

* Re: How to find directory where the program is?
  @ 2002-04-27 21:12  6%             ` Nick Roberts
  0 siblings, 0 replies; 195+ results
From: Nick Roberts @ 2002-04-27 21:12 UTC (permalink / raw)


On 27 Apr 2002 09:39:03 -0500, Kilgallen@SpamCop.net (Larry Kilgallen)
strongly typed:

>In article <aabjie$pru$1@nh.pace.co.uk>, "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org> writes:
>
>> Most OS's have some means for keeping that kind of thing around somewhere,
>> just that it isn't going to be a "portable" answer. Its the sort of thing
>> that Ada has been very good at hiding in the past - maybe that's something
>> that needs to be in an OS Interface package?
>
>But sometimes there will not be an answer, if you are expecting a
>disk location.  On VMS the program you are running might be on
>magnetic tape.

I think we might consider that a bit of a pathological case, nowadays,
Larry!

Besides, I think Marin was suggesting a standard way to obtain
configuration data (not necessarily anything to do with where the
executable is located).

May I propose:

   with Ada.IO_Exceptions;
   package Ada.Program_Environment is

      type Mechanism is (...);
      -- implementation defined enumeration type

      Default_Mechanism: Mechanism := ...;
      -- may be initialised statically or dynamically

      function Get_Item (Name: in Wide_String;
                         Via:  in Mechanism := Default_Mechanism)
         return Wide_String;
      -- returns "" if item not found

      procedure Set_Item (Name, Value: in Wide_String;
                          Via:         in Mechanism := Default_Mechanism);
      -- may or may not delete if Value=""

      procedure Delete_Item (Name: in Wide_String;
                             Via:  in Mechanism := Default_Mechanism);
      -- deletes or (if cannot) sets to ""

      Name_Error:   exception renames Ada.IO_Exceptions.Name_Error;
      Use_Error:    exception renames Ada.IO_Exceptions.Use_Error;
      Device_Error: exception renames Ada.IO_Exceptions.Device_Error;

   end Ada.Program_Environment;

The different mechanisms for Windows (32-bit) might be:

   ( Environment_Variables,
     Windows_INI_File,
     Program_Home_INI_File,
     Registry_User,
     Registry_Local,
     Registry_System );

Just a thought.

PS: The syntax of names is intended to be left implementation-defined (just
like file names). However, it might be necessary to single out one
punctuation character that must be usable (as a delimiter) with impunity.
Perhaps '.' would be best for this. PPS: '=' is likely to be unusable.

-- 
Nick Roberts



^ permalink raw reply	[relevance 6%]

* Reading raw disks (Windows)
@ 2002-04-27 15:16  6% Larry Hazel
  2002-04-29  1:11  5% ` Steve Doiel
  0 siblings, 1 reply; 195+ results
From: Larry Hazel @ 2002-04-27 15:16 UTC (permalink / raw)


Is there any way to open a raw disk for reading under Windows?  I tried opening
"Z:" with sequential_io, but got 

raised ADA.IO_EXCEPTIONS.USE_ERROR : s-fileio.adb:833

Using GNAT 3.14p.  By the way, shouldn't that be Ada.IO_EXCEPTIONS.USE_ERROR? 
We chide everyone else about proper capitalization of Ada.

Larry



^ permalink raw reply	[relevance 6%]

* Re: Read booleans from streams
       [not found]     ` <3C9E85F6.8EDF3AAD@myob.com>
@ 2002-03-25 10:46  0%   ` Erik Sigra
  0 siblings, 0 replies; 195+ results
From: Erik Sigra @ 2002-03-25 10:46 UTC (permalink / raw)


Thanks for your reply!

m�ndagen den 25 mars 2002 03.05 skrev du:
> >raised ADA.IO_EXCEPTIONS.END_ERROR : s-stratt.adb:170
>
> Your loop doesn't do an EOF test.

That was expected. It was the reading I wanted to investigate, so I didn't 
bother with an EOF test.


> >data
> >====
> >02027203
>
> Which looks like
>
> 0000_0000,0000_0010,0000_0000,0000_0010,
>         ^         ^         ^         ^
>         0         0         0         0
>
> 0000_0111,0000_0010,0000_0000,0000_0011
>         ^         ^         ^         ^
>         1         0         0         1
>
>
> And your results look like
>
> 0 0 0 0 1 0 0 1
>
> Interesting, I havn't checked it but how about
> changing

Actually it were the characters '0', '2' and '7' that were stored in the 
file, so it was rather

0001_1000,0001_1010,0001_1000,0001_1010,
        ^         ^         ^         ^
        0         0         0         0
0001_1111,0001_1010,0001_1000,0001_1011
        ^         ^         ^         ^
        1         0         0         1

but that's essentially the same in this matter.


>
> "for Boolean_Aggregate'Component_Size use 1;"
>
> to
>
> "pragma Pack (Boolean_Aggregate);" and if
> that doesn't work, try

I already tried that.


>
> "for Boolean_Aggregate'Component_Size use 1;"
> "for Boolean_Aggregate'Size use 8";

And I tried that too. I even used the test

   Put_Line ("Boolean_Aggregate'Size = " & Boolean_Aggregate'Size'Img);

in the program and it showed "Boolean_Aggregate'Size =  8". I use gnat-3.13p. 
Any other suggestions?



^ permalink raw reply	[relevance 0%]

* Re: Read booleans from streams
  2002-03-24 23:18  4% Read booleans from streams Erik Sigra
@ 2002-03-25  3:57  0% ` Eric G. Miller
  0 siblings, 0 replies; 195+ results
From: Eric G. Miller @ 2002-03-25  3:57 UTC (permalink / raw)


In <mailman.1017011702.18089.comp.lang.ada@ada.eu.org>, Erik Sigra wrote:

> I tried to read bytes from a stream and interpret each bit as a Boolean. But
> it did not work as expected. It reads 1 byte for each bit. How should I do
> instead?
> 
> 
> streamtest.adb
> ==============
> with Ada.Text_IO;           use Ada.Text_IO;
> with Ada.Streams;           use Ada.Streams;
> with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
> 
> procedure Streamtest is
>    type Boolean_Aggregate is array (0 .. 7) of Boolean;
>    for Boolean_Aggregate'Component_Size use 1;
> 
>    Current_Byte : Boolean_Aggregate;
> 
>    The_File : Stream_IO.File_Type;
> 
>    The_Stream : Stream_Access;
> 
> begin
> 
>    Open (The_File, In_File, "data");
> 
>    The_Stream := Stream (The_File);
> 
>    loop
>       Boolean_Aggregate'Read (The_Stream, Current_Byte);
>       for I in Boolean_Aggregate'Range loop
>          Put(Current_Byte (I)'Img & ' ');
>       end loop;
>       New_Line;
>    end loop;
> end Streamtest;
> 
> 
> data
> ====
> 02027203
> 
> 
> user > ./streamtest
> FALSE FALSE FALSE FALSE TRUE FALSE FALSE TRUE
> 
> raised ADA.IO_EXCEPTIONS.END_ERROR : s-stratt.adb:170
> 
> 
> I have checked that the size of Boolean_Aggregate is 8 and not 64.

I think the problem is in the read procedure.  It sees an array of 8 elements,
so wants to read 8 bytes.  I think you need a 'Read wrapper to read a single
byte (type Byte is mod 2**8), and then do an Unchecked_Conversion:

   function To_Boolean_Aggregate is new
	Ada.Unchecked_Conversion(Byte,Boolean_Aggregate);

   procedure Read_Boolean_Aggregate
        (Stream : Stream_Access; Data : in out Boolean_Aggregate) is
        
        Item : Byte;
   begin
        Byte'Read (Stream, Item);
        Data := To_Boolean_Aggregate (Item);
   end Read_Boolean_Aggregate;

...

   while not End_Of_File (File_Type) loop
        Read_Boolean_Aggregate (Stream, Data);

        ...
   end loop;



^ permalink raw reply	[relevance 0%]

* Re: Read booleans from streams
       [not found]     <200203242318.g2ONIkc12876@a77.ib.student.liu.se>
@ 2002-03-25  2:05  0% ` sk
       [not found]     ` <3C9E85F6.8EDF3AAD@myob.com>
  1 sibling, 0 replies; 195+ results
From: sk @ 2002-03-25  2:05 UTC (permalink / raw)


Hi,

>raised ADA.IO_EXCEPTIONS.END_ERROR : s-stratt.adb:170

Your loop doesn't do an EOF test.

Your other issue ?

>data
>====
>02027203

Which looks like 

0000_0000,0000_0010,0000_0000,0000_0010,
        ^         ^         ^         ^
        0         0         0         0

0000_0111,0000_0010,0000_0000,0000_0011
        ^         ^         ^         ^
        1         0         0         1


And your results look like 

0 0 0 0 1 0 0 1

Interesting, I havn't checked it but how about 
changing 

"for Boolean_Aggregate'Component_Size use 1;"

to 

"pragma Pack (Boolean_Aggregate);" and if
that doesn't work, try

"for Boolean_Aggregate'Component_Size use 1;"
"for Boolean_Aggregate'Size use 8"; 

if 

"for Boolean_Aggregate'Size use 8"; 

doesn't work by itself.


-- 
-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
 k i e k c c m
-------------------------------------



^ permalink raw reply	[relevance 0%]

* Read booleans from streams
@ 2002-03-24 23:18  4% Erik Sigra
  2002-03-25  3:57  0% ` Eric G. Miller
  0 siblings, 1 reply; 195+ results
From: Erik Sigra @ 2002-03-24 23:18 UTC (permalink / raw)


I tried to read bytes from a stream and interpret each bit as a Boolean. But 
it did not work as expected. It reads 1 byte for each bit. How should I do 
instead?


streamtest.adb
==============
with Ada.Text_IO;           use Ada.Text_IO;
with Ada.Streams;           use Ada.Streams;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;

procedure Streamtest is
   type Boolean_Aggregate is array (0 .. 7) of Boolean;
   for Boolean_Aggregate'Component_Size use 1;

   Current_Byte : Boolean_Aggregate;

   The_File : Stream_IO.File_Type;

   The_Stream : Stream_Access;

begin

   Open (The_File, In_File, "data");

   The_Stream := Stream (The_File);

   loop
      Boolean_Aggregate'Read (The_Stream, Current_Byte);
      for I in Boolean_Aggregate'Range loop
         Put(Current_Byte (I)'Img & ' ');
      end loop;
      New_Line;
   end loop;
end Streamtest;


data
====
02027203


user > ./streamtest
FALSE FALSE FALSE FALSE TRUE FALSE FALSE TRUE

raised ADA.IO_EXCEPTIONS.END_ERROR : s-stratt.adb:170


I have checked that the size of Boolean_Aggregate is 8 and not 64.



^ permalink raw reply	[relevance 4%]

* Re: Interactivity Question
  2002-03-14  6:15  0% Christoph Grein
@ 2002-03-14  6:24  0% ` Casey Jones
  0 siblings, 0 replies; 195+ results
From: Casey Jones @ 2002-03-14  6:24 UTC (permalink / raw)



Christoph Grein <christoph.grein@eurocopter.com> wrote:
>> raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tienio.adb:61 instantiated at
>> file.adb:29
>> 
>
>From what you give as information, it's hard to provide an answer. a-tienio is 
>Ada.Text_IO.Enumeration_IO I guess, so you presumably input a string that cannot 
>be evaluated as a value of the enumeration type you used to instantiate the 
>generic.

Thanks for your answer, you are right it is enumeration.
But I have fixed the problem now, so I'm okay!
Thank you.



^ permalink raw reply	[relevance 0%]

* Re: Interactivity Question
@ 2002-03-14  6:15  0% Christoph Grein
  2002-03-14  6:24  0% ` Casey Jones
  0 siblings, 1 reply; 195+ results
From: Christoph Grein @ 2002-03-14  6:15 UTC (permalink / raw)


> raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tienio.adb:61 instantiated at
> file.adb:29
> 

From what you give as information, it's hard to provide an answer. a-tienio is 
Ada.Text_IO.Enumeration_IO I guess, so you presumably input a string that cannot 
be evaluated as a value of the enumeration type you used to instantiate the 
generic.



^ permalink raw reply	[relevance 0%]

* Interactivity Question
@ 2002-03-14  3:29  4% Casey Jones
  0 siblings, 0 replies; 195+ results
From: Casey Jones @ 2002-03-14  3:29 UTC (permalink / raw)



I'm currently writing a program whereby the final product will allow the
user to input his/her information.  One of the questions asked to the
user is "No. of sizes wanted:" but when I run the program and input my
number of sizes wanted I get the error:

raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tienio.adb:61 instantiated at
file.adb:29

So from this I know there is something wrong with my code in regards to
the acceptance of input for the no. of sizes wanted.  I've tried a few
different things: instantsiation, Min_Value Max_Value, etc. but nothing
seems to work.

(BTW, I am using Ada95 on Windows 98....)

Your help is greatly needed, thank you.



^ permalink raw reply	[relevance 4%]

* Re: Probl�me avec des get(fichier, integer)
  @ 2002-01-03 17:56  4% ` Nick Roberts
  0 siblings, 0 replies; 195+ results
From: Nick Roberts @ 2002-01-03 17:56 UTC (permalink / raw)


"M. A. Alves" <maa@liacc.up.pt> wrote in message
news:mailman.1010072881.27934.comp.lang.ada@ada.eu.org...

> ...
> Seems like a GNAT bug to me.

It's not a GNAT bug! Poor GNAT seems to get wrongly accused too often.

In a dark corner of the reference manual - RM95 J.2 (3) - you will see that
the '#' hashes in a based numeric literal are permitted to be replaced by
':' colons. (This is an obsolescent feature, and so may be removed by a
future revision.)

Thus, standard Ada.Integer_Text_IO.Get interprets a ':' character as part of
the numeric literal (and if it gets to the end of the line before finding
the next one, raises Ada.IO_Exceptions.Data_Error).

So GNAT behaves absolutely pukka here.

--
Nick Roberts






^ permalink raw reply	[relevance 4%]

* Re: List Strawman JC01
  @ 2001-12-06 16:11  2%     ` Ted Dennison
  0 siblings, 0 replies; 195+ results
From: Ted Dennison @ 2001-12-06 16:11 UTC (permalink / raw)


In article <3C0EB851.77E7172A@boeing.com>, Jeffrey Carter says...
>
>Ted Dennison wrote:
>> be better to put this information in a matrix in the parent pacakge so that
>Except we're talking about one package for unbounded lists. In the case
>of this strawman, there's no parent package.

Not true. Since the name is "Containers.Lists.Unbounded", there are actually
*two* parent packages. I'm compiling the strawman before I post it, so those
packages do exist. Its just that there isn't anything in them to look at yet, so
I haven't bothered to post them. :-)

How about I add a 1-row "matrix" to the top of the package for now, with a note
that it will get moved to the parent when there are more rows?

>that, we can decide what notation to adopt. If we want a bounded list
>package at some point with similar semantics, we probably will need list
>parameters.

That may be an issue, but it doesn't have to be done that way. We could decide
to still keep a pointer to the list in the iterator, which would allow the same
iterface as the current Unbounded strawman. But that's a discussion for another
time.

>> >   Storage_Exhausted : exception;
>> 
>> Why is this considered superior to STORAGE_ERROR? Do you have plans to do
>> something here other than just handle STORAGE_ERROR and raise Storage_Exhausted?
>
>As a general principle, a package should not be propagating predefined
>exceptions to its clients. Also, this helps allow differing

By "predefined" I take it you mean "declared in the standard Ada libarary
somewhere". Considering that the ultimate goal of this facility is to be part of
the standard Ada library, I don't think your principle applies here. :-)

Personally I don't really subscribe to that principle anyway. You should
certianly change the exception if the one raised isn't at the appropriate level
of abstraction for the user. This will, in practice, amount to the same
principle as yours. For instance, I wouldn't allow Ada.IO_Exceptions.Name_Error
to be propagated out of a log file facility. I'd change it to something like
Logfile.Unavailable or Logfile.Installation_Error, because those better describe
the condition causing the problem. Also, the fact that Ada's IO facilities are
used (rather than system calls or something) is an implementation detail that
the user doesn't care about. By this same principle you clearly wouldn't want to
allow Contraint_Error due to in internal calculation out of your routine either.
But this is quite different. Dynamic allocation is clearly going on here, and
Ada.Storage_Error perfectly describes the problem (as evidenced by the fact that
your name for it is hardly different at all).

>This is much less clear than "<". Everyone knows what "<" does.
>"Swap_Items (L, R ...) return Boolean;" is meaningless.

In the context of a boolean expression, yes everyone knows. In the context of
the internals of a sort routine, its completely undefined. Is the "Left"
parameter the "Front" side or the "Back" side? Does a "True" result mean its out
of order or in order? You can supply answers to these questions I'm sure, but
the answers will be fairly arbitrary. They are certianly not self-evident.

>Is the array
>
>(1, 2, 3, 4)
>
>in ascending order? The answer is obvious to most people, because an
>array is a sequence.

No, its obvious to most people because the array is indexed by a discrete type,
upon which the "<" operator is defined. Thus the convention that ascending order
is the order in which items whose indexes return True for ">" will also have
values return true for ">" can be applied.

We have no such relationship for our doubly-linked list. "<" is not defined on
iterators. "Next" requires a direction parameter to disambiguate. The only
ordering a doubly-linked list has is the one the user puts upon it. I could look
at the list left to right, right to left, top to bottom, bottom to top, and no
one can say my view is wrong. I can iterate from front to back or back to front
and it won't make any real difference.

The only directional terminology we have at all is "Front" and "Back". For
anything directional to make sense at all, it *must* be cast in those terms. "<"
is not cast in those terms.

>the First element, the Next element, the Next element, ... , the Last
..
>First and Second are perfectly well defined for a list. The first
>element in List is designated by First (List); the second by Next (First

You are probably thinking of a singly-linked list. That makes a bit of sense for
a singly-linked list because there is only one way you can iterate. Therefore we
know what ascending order is, because there's only one direction to traverse the
list. For a doubly-linked list, either end is equal. There may be an ordering,
but the direction of it is entirely imposed by the user. I'll ask you to go look
at the spec again. There is no "First" function, only a "Side" function, which
takes a directional parameter to disambiguate. "Next" also requires a
directional parameter to disambigute.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[relevance 2%]

* Re: Text_IO.End_Of_File Problem
  2001-11-25 22:42  3% Text_IO.End_Of_File Problem Hambut
@ 2001-11-26  1:53  0% ` Jeffrey Carter
  0 siblings, 0 replies; 195+ results
From: Jeffrey Carter @ 2001-11-26  1:53 UTC (permalink / raw)


Hambut wrote:
> 
> Hi,
> 
> I'm getting an exception with the attached code, and I can't see what
> I'm doing wrong, or why it's falling over.

It's not falling over, it's terminating with an unhandled exception.

> The output I get from executing the code is:
> 
> "
>  13
>  13
> 
> raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:394
> "
> 
> =====Code Follows======
> 
> with Text_Io;
> with Ada.Sequential_Io;
> procedure Eof_Fails is
> 
>    package Io is new Ada.Sequential_Io( Character );
> 
>    Test_File_Name : constant String := "Test_fails";
>    Sequential_File : Io.File_Type;
>    Text_File : Text_Io.File_Type;
> 
>    Failure_Characters : constant String := ( 1 => Ascii.CR,
>                                              2 => Ascii.CR,
>                                              3 => Ascii.LF,
>                                              4 => Ascii.CR,
>                                              5 => Ascii.CR,
>                                              6 => Ascii.LF,
>                                              7 => Ascii.CR,
>                                              8 => Ascii.LF );

What you are doing is writing characters that contain embedded within
them what your specific system considers line terminators. Based on your
sample output, I would guess you're running under Win32. On such
systems, a line terminator is a CR followed by an LF. So you have (in
Text_IO terms) 3 lines. The first 2 lines contain a single character,
which is a CR; the 3rd line is null.

Next, note how Ada.Text_IO.Get (Character) works. It skips any line
terminators looking for a character. So your first call to Get reads
item 1 above. The second skips a line terminator (items 2 & 3) and reads
item 4. You are not now at the end of the file, so End_Of_File returns
False. Your 3rd call to get skips 2 line terminators (items 5-8), which
brings you to the end of the file, raising End_Error.

Note that on a different system, with (a) different character(s)
representing a line terminator, you would get different results, but you
could still define a value for Failure_Characters that would cause the
program to raise End_Error even though End_Of_File is False.

> 
> -- These seem to work OK.
> --       Failure_Characters : constant String := ( 1 => Ascii.CR,
> --                                                 2 => Ascii.CR,
> --                                                 3 => Ascii.LF,
> --                                                 4 => Ascii.CR );

This would work on Win32 because after the 2nd call to Get (which reads
item 4), you are at the end of the file, so End_Of_File returns True.

> 
>    C : Character;
> begin
>    -- First set up the test file
>    --
>    Io.Create( File => Sequential_File,
>               Name => Test_File_Name );
> 
>    for I in Failure_Characters'First..Failure_Characters'Last loop

Note that X'First .. X'Last is equivalent to X'range, which is clearer.

>       Io.Write( File => Sequential_File,
>                 Item => Failure_Characters(I) );
>    end loop;
> 
>    Io.Close( File => Sequential_File );
> 
>    -- Now try and read in as a text file
>    --
>    Text_Io.Open( File => Text_File,
>                  Mode => Text_Io.In_File,
>                  Name => Test_File_Name );
> 
>    while not Text_Io.End_Of_File( File => Text_File ) loop
>       Text_Io.Get( File => Text_File,
>                    Item => C );
>       Text_Io.Put_Line( Integer'Image( Character'Pos(C)));
>     end loop;
> 
>    Text_Io.Close( File => Text_File );
> exception
>    when others =>
>       Text_Io.Close( File => Text_File );
>       raise;
> end Eof_fails;

The basic lesson is that Text_IO interprets the characters in your file,
and in the process does not return every character to you. This can
result in some operations reading past the end of the file, although
End_Of_File has just returned False.

-- 
Jeff Carter
"We call your door-opening request a silly thing."
Monty Python & the Holy Grail



^ permalink raw reply	[relevance 0%]

* Text_IO.End_Of_File Problem
@ 2001-11-25 22:42  3% Hambut
  2001-11-26  1:53  0% ` Jeffrey Carter
  0 siblings, 1 reply; 195+ results
From: Hambut @ 2001-11-25 22:42 UTC (permalink / raw)


Hi,

I'm getting an exception with the attached code, and I can't see what
I'm doing wrong, or why it's falling over.

The code basically:

1.  Opens a file (sequential IO)
2.  Fills it with a sequence of Ascii.LF's and ASCII.CR's
3.  Closes it and reopens it as text_io
4.  reads each character in and outputs it's Ascii value to screen.

What *seems* to be happening is that text_io.end_of_file is not
detecting the end of file properly in this case [or I've made some
elementary error (having spent lots of time correcting my errors up to
now I know which option my money's on :-)].  

I'd appreciate it if someone on here could have a peer at this and
give me a pointer as to where I'm going wrong.

The output I get from executing the code is:

"
 13
 13

raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:394
"

Thanks in advance for any help.

Cheers,

Hambut.

=====Code Follows======

with Text_Io;
with Ada.Sequential_Io;
procedure Eof_Fails is

   package Io is new Ada.Sequential_Io( Character );

   Test_File_Name : constant String := "Test_fails";
   Sequential_File : Io.File_Type;
   Text_File : Text_Io.File_Type;

   Failure_Characters : constant String := ( 1 => Ascii.CR,
					     2 => Ascii.CR,
					     3 => Ascii.LF,
					     4 => Ascii.CR,
					     5 => Ascii.CR,
					     6 => Ascii.LF,
					     7 => Ascii.CR,
					     8 => Ascii.LF );
    
-- These seem to work OK.
--       Failure_Characters : constant String := ( 1 => Ascii.CR,
--                                                 2 => Ascii.CR,
--                                                 3 => Ascii.LF,
--                                                 4 => Ascii.CR );

   C : Character;
begin
   -- First set up the test file
   --
   Io.Create( File => Sequential_File,
              Name => Test_File_Name );

   for I in Failure_Characters'First..Failure_Characters'Last loop
      Io.Write( File => Sequential_File,
                Item => Failure_Characters(I) );
   end loop;

   Io.Close( File => Sequential_File );

   -- Now try and read in as a text file
   --
   Text_Io.Open( File => Text_File,
                 Mode => Text_Io.In_File,
                 Name => Test_File_Name );

   while not Text_Io.End_Of_File( File => Text_File ) loop
      Text_Io.Get( File => Text_File,
                   Item => C );
      Text_Io.Put_Line( Integer'Image( Character'Pos(C)));
    end loop;

   Text_Io.Close( File => Text_File );
exception
   when others =>
      Text_Io.Close( File => Text_File );
      raise;
end Eof_fails;



^ permalink raw reply	[relevance 3%]

* Re: List container strawman
  @ 2001-11-07 19:07  4%                   ` ramatthews
  0 siblings, 0 replies; 195+ results
From: ramatthews @ 2001-11-07 19:07 UTC (permalink / raw)


In article <bgR13FMw5mIK@eisner.encompasserve.org>, Kilgallen@SpamCop.net (Larry Kilgallen) wrote:
> In article <3BE58FDD.E1FB1815@san.rr.com>, Darren New <dnew@san.rr.com> writes:
> 
>> If you really want it to be foolproof,
> 
> Yes please.


While I see a foolproof list does not have universal appeal I have
been successfully using one for some time so I thought its 
specification would help discussions.

Robert Matthews

-----------------------------------------------------
with Ada.Finalization;
with Ada.IO_Exceptions;
with Ada.Streams;
with Ada.Tags;

generic
   type Data_Type (<>) is private;
package Containers.Lists.Unbounded is

   --  This package provides facilities for manipulating simple list structures.
   --
   --  A list is an ordered sequence of data elements. It can also be empty,
   --  containing no data elements.
   --
   --  Client software creates an empty list by declaring a variable of type
   --  List_Type. Data elements can then be added to the list via the subprograms
   --  Prepend and Append. Note that data is copied into the list - pointers are not
   --  retained to the original data.
   --
   --  All data elements can be removed from a list via subprogram Delete_All.
   --  Applying this subprogram to an already empty list will have no effect.
   --
   --  When applied to an empty list, Is_Empty will return True, otherwise it will
   --  return False.
   --
   --  A list can be assigned to another. The target list will be emptied then loaded with
   --  a copy of each data element in the source list. The copying will be done such that
   --  the ordering of the data elements in each list will be the same.
   --  Note that if the source list is empty, then the target will be set empty.
   --
   --  Two lists can be compared for equality. To be equal they must have equal data elements
   --  at corresponding positions. Two empty lists are considered equal.
   --
   --  The elements in a list can be accessed via an enumerator: the client software
   --  declares a variable of type Enumerator_Type which it then attaches to a list via
   --  the function New_Enumerator.
   --
   --  At any one time an enumerator denotes a single element in its associated list. This
   --  element is termed the "current" element. Initially current will be set to the first
   --  element in the list; the following subprograms allow current to move to a different
   --  element: Goto_Next, Goto_Previous, Goto_First, Goto_Last.
   --
   --  The following subprograms allow an enumerator's current element to be retrieved,
   --  changed, or deleted: Current, Update, Delete. Note that after Delete, current
   --  still denotes the same point in the list, even though the associated data
   --  element no longer exists.
   --
   --  The subprogram Insert allows a new data element to be added to the list either
   --  before or after the current element. Note that if the list is empty then this
   --  subprogram will still insert the data even though current does not exist.
   --  Alternatively if current has been deleted then Insert will insert the data at
   --  the point in the list from which current was deleted.
   --  After the insertion, current will be set to the new data element.
   --
   --  When current is at the start of a list, Is_First will return True,
   --  otherwise it will return False.
   --  When current is at the end of a list,   Is_Last  will return True,
   --  otherwise it will return False.
   --
   --  If current exists Current_Exists will return True, otherwise it will return False
   --  (current will not exist if the element denoted by current has been deleted, or if
   --  the associated list is empty).
   --
   --  If the list associated with an enumerator exists List_Exists will return True, otherwise
   --  it will return False (a list can cease to exist if the list's variable goes out of scope).
   --
   --  An enumerator can be assigned to another enumerator. The target enumerator will then
   --  be associated with the same list and denote the same current element. Note that
   --  if the source enumerator's list and/or current do not exist then these characteristics
   --  will be transferred to the target enumerator.
   --
   --  Two enumerators can be compared for equality. They must be associated with the same
   --  list and their current elements must be the same element. Note that two enumerators whose
   --  lists do not exist are deemed equal. Also two enumerators whose lists exist but whose current
   --  elements do not, are deemed equal if:
   --   1) the lists are the same and empty; or
   --   2) the lists are the same and non-empty, and each current denotes the same point in the list.
   --
   --  Note that two or more enumerators can change the same list; changes made via one enumerator
   --  will be visible to the other enumerators. Similarly changes made directly to a list will be
   --  visible to its enumerators. However, concurrent access from more than one task is not supported;
   --  concurrent access may well lead to list and enumerator corruption.
   --
   --  Note also that the storage associated with lists and enumerators is automatically deallocated
   --  when their variables go out of scope.
   --
   --  Stream input/output can be used with lists via the stream oriented attributes List_Type'Write
   --  and List_Type'Read.
   --  For the Write attribute, each data element in the list is sent to the stream via
   --  Data_Type'Output.
   --  For the Read attribute, data elements are extracted from the stream (via Data_Type'Input)
   --  and inserted into the list. Note that any data elements previously in the list will be deleted.
   --  Note also that an empty list will be suitably flagged in the stream data, and so will be
   --  correctly handled when read back in.
   --
   --
   --  When applied to an empty list, the following will raise No_Data:
   --   Goto_First, Goto_Last, Goto_Next, Goto_Previous, Is_First, Is_Last.
   --
   --  When current is the last  data element in a list, Goto_Next     will raise No_Data.
   --  When current is the first data element in a list, Goto_Previous will raise No_Data.
   --
   --  When current does not exist, the following will raise No_Data:
   --   Delete, Current, Update.
   --
   --  When an enumerator's list does not exist, the following will raise No_List:
   --   Insert, Delete, Current, Update, Goto_First, Goto_Last, Goto_Next, Goto_Previous,
   --   Is_First, Is_Last, Current_Exists, Is_Empty[Enumerator_Type].
   --
   --  When the stream I/O attributes are used, the following exceptions may be raised:
   --    Device_Error, Data_Error, Constraint_Error, Tag_Error, End_Error and Mode_Error.
   --  See the Ada Reference Manual for details.
   --
   ------------------------------------------------------------------------------------------------

   type List_Type       is tagged private;
   type Enumerator_Type is        private;

   --  Subprograms for directly dealing with lists...

   procedure Prepend       (List  : in out List_Type; Data : in Data_Type);   -- Insert data at start of list.
   procedure Append        (List  : in out List_Type; Data : in Data_Type);   -- Insert data at end of list.
   procedure Delete_All    (List  : in out List_Type);                        -- Delete all data from list.

   function  Is_Empty      (List  : in     List_Type) return Boolean;
   function  "="           (Left  : in     List_Type;                   -- Check lists have equal.
                            Right : in     List_Type) return Boolean;   -- elements at matching positions.

   function New_Enumerator (List  : in     List_Type'Class) return Enumerator_Type;
   --  Enumerator will denote the list and its current will be the first in the list.

   --  Note: can also assign list to list: target list will contain a copy of all the elements in the source
   --  list, with each element and its copy having the same position in their respective lists.
   ----------------------------------------------------------------------

   --  Subprograms for dealing with the current element of an enumerator...

   type Position_Type is (Before_Current, After_Current);

   procedure Insert         (Enumerator : in out Enumerator_Type;
                                   Data : in Data_Type;
                                   Position : in Position_Type);
   procedure Delete         (Enumerator : in     Enumerator_Type);
   function  Current        (Enumerator : in     Enumerator_Type) return Data_Type; 

   procedure Update         (Enumerator : in out Enumerator_Type; Data : in Data_Type);
   --  Update current element.
   --  Note that if new data is larger, then new data will be loaded into a new element that replaces
   --  the old in the list. The location in the list will not have changed but current will now denote
   --  that new data element - hence the in out mode.

   procedure Goto_First     (Enumerator : in out Enumerator_Type); 
   procedure Goto_Last      (Enumerator : in out Enumerator_Type);
   procedure Goto_Next      (Enumerator : in out Enumerator_Type);
   procedure Goto_Previous  (Enumerator : in out Enumerator_Type);

   function  Is_First       (Enumerator : in     Enumerator_Type) return Boolean;
   function  Is_Last        (Enumerator : in     Enumerator_Type) return Boolean;

   function  Current_Exists (Enumerator : in     Enumerator_Type) return Boolean;
   function  List_Exists    (Enumerator : in     Enumerator_Type) return Boolean;

   function  Is_Empty       (Enumerator : in     Enumerator_Type) return Boolean;
   -- Is the associated list empty.


   function  "="            (Left       : in     Enumerator_Type; 
                             Right      : in     Enumerator_Type) return Boolean;

   --  Note: can also assign enumerator to enumerator: target will denote same list
   --  and have same current as source.
   --------------------------------------------------------

   --  The subprograms can raise the following exceptions:

   No_Data      : exception;
   No_List      : exception;
   
   --  And for stream I/O...
   
   Device_Error : exception renames Ada.IO_Exceptions.Device_Error;
   Data_Error   : exception renames Ada.IO_Exceptions.Data_Error;
   End_Error    : exception renames Ada.IO_Exceptions.End_Error;
   Mode_Error   : exception renames Ada.IO_Exceptions.Mode_Error;
   Tag_Error    : exception renames Ada.Tags.Tag_Error;
   --  Also Constraint_Error may be raised.

   ---------------------------------------------------

private
   type Data_Access_Type is access Data_Type;

   type Data_Envelope_Type;
   type Data_Envelope_Access_Type is access Data_Envelope_Type;

   type Enumerator_Envelope_Type;
   type Enumerator_Envelope_Access_Type is access Enumerator_Envelope_Type;

   type List_Header_Type;
   type List_Header_Access_Type is access List_Header_Type;

   type Data_Envelope_Type is record
      Data     : Data_Access_Type;
      Next     : Data_Envelope_Access_Type;
      Previous : Data_Envelope_Access_Type;
   end record;

   type List_Header_Type is
   record
      First       : Data_Envelope_Access_Type;
      Last        : Data_Envelope_Access_Type;
      Enumerators : Enumerator_Envelope_Access_Type;   -- Sub-list of enumerators attached to this List.
   end record;

   type List_Type is new Ada.Finalization.Controlled with
   record
      Header : List_Header_Access_Type;
   end record;

   procedure Initialize (List : in out List_Type);
   procedure Adjust     (List : in out List_Type);
   procedure Finalize   (List : in out List_Type);

   procedure List_Write (Stream : access Ada.Streams.Root_Stream_Type'Class; Item : in  List_Type);
   for List_Type'Write use List_Write;
   
   procedure List_Read  (Stream : access Ada.Streams.Root_Stream_Type'Class; Item : out List_Type);
   for List_Type'Read use List_Read;


   type Enumerator_Envelope_Type is
   record
      List_Header         : List_Header_Access_Type;           -- List that Enumerator applies to.
      Current             : Data_Envelope_Access_Type;         -- List element that Enumerator denotes.
      Next_Enumerator     : Enumerator_Envelope_Access_Type;   -- Enumerators are linked in their own sub-list,
      Previous_Enumerator : Enumerator_Envelope_Access_Type;   --  within the relevant List.
      Next_Data           : Data_Envelope_Access_Type;         -- List element that follows current.
      Previous_Data       : Data_Envelope_Access_Type;         -- List element that precedes current.
   end record;
   --  Note that in the above record, components Next_Data and Previous_Data duplicate the Next and Previous
   --  components of the record referenced by Current. This duplication is necessary for the case when Current
   --  is Null (ie. the corresponding data element has been deleted), Next_Data and Previous_Data then indicate
   --  where in the list the enumerator is.

   type Enumerator_Type is new Ada.Finalization.Controlled with
   record
      Header : Enumerator_Envelope_Access_Type;
   end record;

   procedure Initialize (Enumerator : in out Enumerator_Type);
   procedure Adjust     (Enumerator : in out Enumerator_Type);
   procedure Finalize   (Enumerator : in out Enumerator_Type);

end Containers.Lists.Unbounded;
-------------------------------------------------------------





^ permalink raw reply	[relevance 4%]

* Re: Questions on implementations and specs
  2001-10-11 18:31  0% ` chris.danx
@ 2001-10-11 22:39  0%   ` chris.danx
  0 siblings, 0 replies; 195+ results
From: chris.danx @ 2001-10-11 22:39 UTC (permalink / raw)



"chris.danx" <chris.danx@ntlworld.com> wrote in message
news:vzlx7.5831$i14.735621@news2-win.server.ntlworld.com...
>
> "chris.danx" <chris.danx@ntlworld.com> wrote in message
> news:Ahkx7.4857$i14.643289@news2-win.server.ntlworld.com...
> > Hi,
>
> > p.s.  In the case of XMLAda, I've just noted that it does propagate this
> > exception by putting it as a renaming in the file (adding Name_Error :
> > exception renames Ada.IO_Exceptions.Name_Error at the top of
> > input_sources.file (spec)).  This isn't a big deal, and I don't want it
to
> > turn into one.
>
> Further investigation of the XMLAda packages reveals that this isn't
> correct.  Name_Error doesn't appear propagated at all,

It's not a good day, and I feel really stupid for making this mistake but
the exception is propagated (found out when attempted to open a file that
was mispelled).  My mistake doubled.  I appologise for any confusion and
will try to not get confused and distracted and then write wrong information
on public newsgroups in future.


My appologies,
Chris





^ permalink raw reply	[relevance 0%]

* Re: Questions on implementations and specs
  2001-10-11 17:03  3% Questions on implementations and specs chris.danx
@ 2001-10-11 18:31  0% ` chris.danx
  2001-10-11 22:39  0%   ` chris.danx
  0 siblings, 1 reply; 195+ results
From: chris.danx @ 2001-10-11 18:31 UTC (permalink / raw)



"chris.danx" <chris.danx@ntlworld.com> wrote in message
news:Ahkx7.4857$i14.643289@news2-win.server.ntlworld.com...
> Hi,

> p.s.  In the case of XMLAda, I've just noted that it does propagate this
> exception by putting it as a renaming in the file (adding Name_Error :
> exception renames Ada.IO_Exceptions.Name_Error at the top of
> input_sources.file (spec)).  This isn't a big deal, and I don't want it to
> turn into one.

Further investigation of the XMLAda packages reveals that this isn't
correct.  Name_Error doesn't appear propagated at all, my appologies to the
XMLAda folks!

I'm still interested to know what the advice on the issue of documenting
propagation of exceptions is.


Chris




^ permalink raw reply	[relevance 0%]

* Questions on implementations and specs
@ 2001-10-11 17:03  3% chris.danx
  2001-10-11 18:31  0% ` chris.danx
  0 siblings, 1 reply; 195+ results
From: chris.danx @ 2001-10-11 17:03 UTC (permalink / raw)


Hi,

I'm working with XMLAda and would like to be able to detect if a file could
not opened, but I see XMLAda provides no such exception or routine.  XMLAda
uses the package direct io (in input_sources.file), which means that a
name_error will be raised should opening the file not be possible.  Should I
rely on the fact that it is based on direct io and therefore will raise the
name_error exception or should I do something else?

I'm not knocking XMLAda for not providing an exception in it's spec for this
condition, it's just I've seen that sometimes an assumption is made that
standard exception will be propagated from standard routines and expect the
user to know this or look at the implementation (i.e. the exception is not
documented).  I was under the impression that the programmer should not need
to look at the implementation *in most cases* (of course there are cases
when we do need to look at the implementation).

Is it common to assume this implicitly?  I recognise that the designer(s) of
XMLAda may have chosen this deliberately or haven't got to this yet (since
it's a beta), I'm curious about this in general.



Chris Campbell

p.s.  In the case of XMLAda, I've just noted that it does propagate this
exception by putting it as a renaming in the file (adding Name_Error :
exception renames Ada.IO_Exceptions.Name_Error at the top of
input_sources.file (spec)).  This isn't a big deal, and I don't want it to
turn into one.







^ permalink raw reply	[relevance 3%]

* Re: Positive Floating Range?
  @ 2001-05-01 20:40  4% ` Georg Bauhaus
  0 siblings, 0 replies; 195+ results
From: Georg Bauhaus @ 2001-05-01 20:40 UTC (permalink / raw)


Dr Nancy's Sweetie (kilroy@copland.rowan.edu) wrote:


: 	Put(Float'succ(0.0));
: gave me:
: 	0.00000E+00

: ...
: So it looks like I get what I want with:

:       subtype Foo is Float range Float'Succ(0.0)..Float'Last;

I've tried this:

with ada.text_IO; use Ada.Text_IO;
procedure floats is

  subtype Pos_Float is Float range Float'Succ(0.0) .. float'last;
  package pfloat is new Ada.text_IO.Float_IO(pos_float);
  f: pos_float;

begin
   pfloat.put(Pos_Float'First); new_line;
   pfloat.get(f);
end floats;

teppich:~$ ./floats
 1.40130E-45
0.0

raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiflio.adb:70 instantiated at floats.adb:5
teppich:~$

Hm... That's all of my 2c.

There has been some talk about one compiler using
80 hardware bits where available, so you should at
least get long floats. Nothing in the compiler docs?


Georg



^ permalink raw reply	[relevance 4%]

* Re: text_io is not a predefined library
  @ 2001-03-13 10:47  6%   ` David C. Hoos, Sr.
  0 siblings, 0 replies; 195+ results
From: David C. Hoos, Sr. @ 2001-03-13 10:47 UTC (permalink / raw)


Using Text_IO in place of Ada.TextIO is not the problem.

Note the following from RM95, J.1;
The following library_unit_renaming_declarations exist:

2 with Ada.Unchecked_Conversion;
generic function Unchecked_Conversion renames Ada.Unchecked_Conversion;
3 with Ada.Unchecked_Deallocation;
generic procedure Unchecked_Deallocation renames Ada.Unchecked_Deallocation;
4 with Ada.Sequential_IO;
generic package Sequential_IO renames Ada.Sequential_IO;
5 with Ada.Direct_IO;
generic package Direct_IO renames Ada.Direct_IO;

6 with Ada.Text_IO;
package Text_IO renames Ada.Text_IO;
7 with Ada.IO_Exceptions;
package IO_Exceptions renames Ada.IO_Exceptions;
8 with Ada.Calendar;
package Calendar renames Ada.Calendar;
9 with System.Machine_Code;
package Machine_Code renames System.Machine_Code; -- If supported.

The earlier suggestion by Jeff Creem that it is a GNAT installation
problem is the correct explanation for the phenomenon.

"DuckE" <nospam_steved94@home.com> wrote in message
news:dKhr6.559748$U46.16631404@news1.sttls1.wa.home.com...
> Text_Io is a child of Ada.
>
> Try:
>   with Ada.Text_Io;
>   use Ada.Text_Io;
>
> SteveD
>
> "Andrew Busolin" <abusolin@chariot.net.au> wrote in message
> news:3aad6b31_5@news.chariot.net.au...
> > Hi there,
> >
> > I have written a little hello world program in an effort to test out the
> ada
> > compiler I have recently downloaded. I am able to compile it using
> > gcc -c -gnats -c hello.adb, however when I try to gnatmake it using
> > gnatmake -c hello.adb it returns "ada.text_io" is not a predefined
library
> > unit
> > compilation abandoned!!!
> >
> > Can someone please tell me why this is and how I can fix it!
> >
> > Best Regards
> >
> > Andrew Busolin
> >
> >
> > with Text_Io;
> > use Text_Io;
> >
> > procedure hello is
> > begin
> > Put("hello");
> > end hello;
> >
> >
>
>




^ permalink raw reply	[relevance 6%]

* Re: Possible gnat and ObjectAda bugs?
  @ 2000-11-26  0:00  6% ` Preben Randhol
  0 siblings, 0 replies; 195+ results
From: Preben Randhol @ 2000-11-26  0:00 UTC (permalink / raw)


On Sat, 25 Nov 2000 08:23:05 -0600, David C. Hoos, Sr. wrote:
>The code at the end of this message produces strange results with GNAT
>3.13p,
>and even more bizarre results with ObjectAda 7.1:
>
>What is strange is that when Standard Input is from the keyboard, the
>program
>does not enter the loop until the enter key has been pressed.
>
>Is this a bug, or am I missing something here?

Looks like Ada.Text_IO.Current_Input expects input that are terminated
by a new_line. Though your code would raise an exception if one hit \x04
(EOF) from the keyboard. I think I would have done something like this:


with Ada.Text_IO;
with Ada.IO_Exceptions;
procedure Echo
is
   C : Character;
begin
  loop
    begin
      Ada.Text_IO.Put_Line
        (Ada.Text_IO.Standard_Error,
         "Waiting for character...");
      Ada.Text_IO.Get_Immediate (C);

      Ada.Text_IO.Put_Line
      (Ada.Text_IO.Standard_Error,
       "Got character at position" &
       Integer'Image (Character'Pos (C)));
      Ada.Text_IO.Put (Ada.Text_IO.Current_Output, C);
    exception
      when Ada.Io_Exceptions.End_Error =>
        Ada.Text_IO.Put_Line
          (Ada.Text_IO.Standard_Error,
            "Ending...");
      exit;
    end;
   end loop;
end Echo;

-- 
Preben Randhol ---------------- http://www.pvv.org/~randhol/ --
iMy favorite editor is Emacs!<ESC>bcwVim<ESC>
                                         -- vim best-editor.txt




^ permalink raw reply	[relevance 6%]

* Re: Automatic issue of carriage return
  @ 2000-11-22  0:00  3% ` Egil Harald Hoevik
  0 siblings, 0 replies; 195+ results
From: Egil Harald Hoevik @ 2000-11-22  0:00 UTC (permalink / raw)


mountainman wrote:
> 
> Thanks for all that responded to my last message. I have another one
> for you all. It should be pretty simple for you ada guru's out there.
> I would like to recieve a user's input to a prompt and then
> automatically issue a CR or LF. so the user does not have to hit the
> enter key
> 
> Im using a subtype as variable (example)
> type continue_type is (y,n)
> package continue_IO is new text_io.enumeration_IO(continue_type);
> 
> continue_IO.get(flag);
> ????
> any help would be helpfull
> Thanks

In ada.text_io there is a procedure Get_Immediate, which gets one
character from the 
keyboard, and returns without you having to press enter. You could
perhaps create 
your own package, with a procedure doing the same for your enumeration
type by using this procedure.

	Example:

	with ada.text_io;

	procedure enumerate is
	
	generic
	   type Enum is (<>);
	  package my_enumeration_io is
	    package convert is new ada.text_io.enumeration_io(Enum);
	-- new procedure handling enumeration types
	    procedure my_get(Item : out Enum);
	  end my_enumeration_io; 

	  package body my_enumeration_io is
	    procedure my_get(Item : out Enum) is
	      input : character;
	      last : positive; -- dummy; we only handle single-value
enumerations
	    begin
	-- get one character from the keyboard with get_immediate
	      ada.text_io.get_immediate(input);
	-- convert the string to your enumeration type
	      convert.get(input & "", Item, last);
	    end my_get;
	  end my_enumeration_io;


Then this should work:

	 type continue_type is (y,n);
	 package continue_IO is new my_enumeration_IO(continue_type);
	 flag : continue_type;
	begin
	 continue_IO.my_get(flag);
	end enumerate;

This package has limits, of course.
In your case you have simple, single-character values in your
enumeration (y,n).
You would have to do some more work with enumerations of
multiple-character values (yes,no). If you need such functionality, mail
me, I'll see what I can do.

Note: If you type in a value not part of the enumeration (any other
character than y,n),
the program will raise ada.io_exceptions.data_error. So you should have
an exception handler that perhaps prompts the user again if he/she types
wrong.


~egilhh
-- 
"The world we have made as a result of the level of thinking
we have done this far, creates problems that we cannot solve
at the same level at which we created them."
Albert Einstein.




^ permalink raw reply	[relevance 3%]

* input/output exceptions
@ 2000-11-18  0:00  4% Jean Cohen
  0 siblings, 0 replies; 195+ results
From: Jean Cohen @ 2000-11-18  0:00 UTC (permalink / raw)


Hi all,

I have a question regarding input/output exceptions. Suppose the following 
procedure:


with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;

procedure Test_Type_IO is

	First,	Second	: Integer := 0;

begin

	Get(First);
	Get(Second);

	Put(First);
	Put(Second);
	
end Test_Type_IO;


One should expect, that an input value which is not an integer (eg. a float) 
will raise an exception. However by executing the program I only get an 
exception [1] if the first value is not an integer. If the second one is not 
an integer, it seems, as if it is treated as one [2]:

3
2.54
          3          2

Why does the second value not raise an exception?

(The program is compiled by GNAT 3.13p on Debian GNU/Linux.)

Thank you,
Jean Cohen

(English is not my native language. I apologize for any misunderstandings 
that 
result of this reason.)


--------------------------

[1]	raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at 
a-inteio.ads:20

[2]	This is not the case if for instance strings are used - then the 
exceptions occur in every case.





^ permalink raw reply	[relevance 4%]

* Exception handling problem
@ 2000-03-06  0:00  2% Amun-Ra
  0 siblings, 0 replies; 195+ results
From: Amun-Ra @ 2000-03-06  0:00 UTC (permalink / raw)


Hi all!

I have a big problem handling exceptions with Ada95 using GNAT.
I need to enter a number and, if something else is entered, the raised
exception
Ada.IO_Exceptions.Data_Error has to be handled and the asking for a
number 
should continue (I guess the problem is probably simple, but I don't see
a 
solution yet). The code I am worrying about is the following:

    -- Procedure "RAS_AskBreakpoint":
    -- Asks if a breakpoint should be set or unset. It returns 0 if the
    -- breakpoint should be unset, 1 if it should be set and also
returns the 
    -- entered breakpoint value as out-argument.
    --
    procedure RAS_AskBreakpoint (Input: out Long_Long_Integer; Mode: out
Integer) is
        Keystroke:      Character;
    begin
        RAS_Set_Position (Position => (Col => 1, Line => 10)); 
        Put (EmptyLine);
        RAS_Set_Position (Position => (Col => 1, Line => 10)); 
        Put ("Do you want to set <S> or unset <U> a breakpoint?");
        RAS_Set_Position (Position => (Col => 1, Line => 10));
        loop
            Get_Immediate (Keystroke);
            if Keystroke = 'S' or Keystroke = 's' then
                Mode := 1;
                Put (EmptyLine);
                RAS_Set_Position (Position => (Col => 1, Line => 10));
                Put ("Set breakpoint at which instruction (<0 to abort):
");
                Get (Input);
                exit;
            elsif Keystroke = 'U' or Keystroke = 'u' then
                Mode := 0;
                Put (EmptyLine);
                RAS_Set_Position (Position => (Col => 1, Line => 10));
                Put ("Unset which breakpoint (<0 to abort): ");
                Get (Input);
                exit;
            end if;
        end loop;
        RAS_Set_Position (Position => (Col => 1, Line => 10));
        Put (EmptyLine);
        RAS_Set_Position (Position => (Col => 1, Line => 11));
    end RAS_AskBreakpoint;

This procedure can be called many times and of course the only inputs
that need
to be done are a 'S'|'s' or 'U'|'u' and subsequently a number of type 
Long_Long_Integer. The only lines where the Data_Error can occur, are
the 
"Get (Input);"-lines. However, if a Data_Error is raised, the asking for
a 
number should continue until the user enters a valid number.

I already tried handling the exception by declaring another block inside
the
loop...end loop-section with own exception handler:

        loop
            begin
                Get_Immediate (Keystroke);
                if Keystroke = 'S' or Keystroke = 's' then
                    Mode := 1;
                    Put (EmptyLine);
                    RAS_Set_Position (Position => (Col => 1, Line =>
10));
                    Put ("Set breakpoint at which instruction (<0 to
abort): ");
                    Get (Input);
                    exit;
                elsif Keystroke = 'U' or Keystroke = 'u' then
                    Mode := 0;
                    Put (EmptyLine);
                    RAS_Set_Position (Position => (Col => 1, Line =>
10));
                    Put ("Unset which breakpoint (<0 to abort): ");
                    Get (Input);
                    exit;
                end if;
            exception
                when others => Put_Line ("Enter a number!");
            end;
        end loop;

as well as trying to localize the exception handling down to the
Get-Instruction:

                    loop
                        begin
                            Get (Input);
                            exit;
                        exception
                            when others => Put_Line ("Enter a number!");
                        end;
                    end loop;

The behaviour of the procedure then (regardless of where in the loop I
put the
handler) is always the same: 
If I enter a number as wanted, I can call the procedure as often as I
want and 
it works perfectly. However, if I enter something else, like a letter (I
want to
trap typing errors), upon subsequent calls of the procedure, the "Get
(Input)"-
Statements are no longer executed (the Put-Statements immediately in
front of 
them are executed), so I cannot enter a number anymore. And strange
enough, the
Put_Line-statement in the exception handler is not executed in the first
code
snippet, but leads to an infinite loop in the second one.
I already thought of doing a "Flush;" in the exception handler, but that
did not
work either.

Does anyone know why that strange behaviour occurs, why after giving
wrong Input
the "Get (Input);"s are no longer executed upon calling the procedure
again and
why the exception is not handled as wanted???
Can anyone tell me, where I made a mistake and how the code must be
written so
that I can keep asking for a number if I mistyped???

I would appreciate any hints!!!

Thanks in advance!!!

Andreas

P.S. Could you please also send answers via e-mail to: Amun_Ra72@gmx.net
Thanks!




^ permalink raw reply	[relevance 2%]

* Re: Number into String
  @ 2000-01-06  0:00  5%       ` reason67
  0 siblings, 0 replies; 195+ results
From: reason67 @ 2000-01-06  0:00 UTC (permalink / raw)


In article <852dmq$vad$1@nnrp1.deja.com>,
  Robert Dewar <robert_dewar@my-deja.com> wrote:
> In article <852crn$umf$1@nnrp1.deja.com>,
>   reason67@my-deja.com wrote:
> > In article <851a0e$tp7$1@green.kreonet.re.kr>,
> >   "Jeong, Lae Hyung" <lovelace@dreamwiz.com> wrote:
> > >     I've found !!
> > >
> > >     S : String := Integer'Image(NUM);
> >
> > This thread is kinds fortunate for me to ask a question. I
> often have
> > the case where I need to put a number into a string of fixed
> length.
>
> So use the facilities in Text_IO!

Can't do that. The reason why is stated in the last line of the comment
I supplied at the beginning of my procedure:

     -- If
     -- the length of Number String is greater than the Length
     -- provided, the left most portion of the Number that can fit
     -- in the result is returned.
     --

Text_IO returns a layout_error in this case.

----------
----------

with Ada.IO_Exceptions;
with Ada.Text_IO;

procedure Aaa_Test_It is

    package Int_IO is new Ada.Text_IO.Integer_IO (Integer);

    Number : Integer := 5000;
    Str1   : String (1 .. 3);
begin
    Int_IO.Put (To   => Str1,
                Item => Number);

    Ada.Text_IO.Put_Line (Str1);
exception
    when Ada.IO_Exceptions.Layout_Error =>
        Ada.Text_IO.Put_Line ("Str1 will not work");
end Aaa_Test_It;


I could do the text_io on a larger string than is required and then copy
it into the smaller string, but that is essentially the same thing as I
am doing with the 'image so it does not gain me anything.
---
Jeffrey Blatt



Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[relevance 5%]

* Re: Help ... CONSTRAINT_ERROR
  @ 1999-12-02  0:00  4% ` Stephen Leake
  0 siblings, 0 replies; 195+ results
From: Stephen Leake @ 1999-12-02  0:00 UTC (permalink / raw)


"jxredi" <jxredi@gecms.com.au> writes:

> Hi,
> I was wondering if you could help me out with this problem (using ADA83) :
> 
> package R_IO is new TEXT_IO.FLOAT_IO(Float);
> NUM : STRING :=   "hi there";
> FNUM : Float := 0.75;
> R_IO.PUT(NUM,FNUM);   -- this is where the problem is ... but what's wrong
> ??

I cleaned this up as:

with Text_IO;
procedure Jxredi is
   package R_IO is new Text_IO.Float_IO (Float);
   NUM : STRING :=   "hi there";
   FNUM : Float := 0.75;
begin
   R_IO.Put (NUM, FNUM);
end Jxredi;

compiling and running with GNAT gives:

./jxredi.exe  > jxredi.out

raised ADA.IO_EXCEPTIONS.LAYOUT_ERROR : a-tiflau.adb:218

Since GNAT comes with source code, I looked at 'a-tiflau.adb:218'
(cool!). The problem is that the string NUM is too short for the
canonical representation of FNUM.

Note that the call to R_IO.Put writes the image of FNUM into the
string NUM; is that what you wanted it to do? If you are used to C
printf, you probably wanted the following output:

hello there 0.75

Here's a program that does that:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
procedure Jxredi is
   NUM : String := "hello there";
   FNUM : Float := 0.75;
begin
   Put (NUM);
   Put (FNUM, Fore => 2, Aft => 2, Exp => 0);
end Jxredi;

./jxredi.exe 
hello there 0.75


-- Stephe




^ permalink raw reply	[relevance 4%]

* Re: Safely converting String to Float ?
    1999-11-03  0:00  4% ` Robert Dewar
@ 1999-11-03  0:00  4% ` Robert Dewar
  1 sibling, 0 replies; 195+ results
From: Robert Dewar @ 1999-11-03  0:00 UTC (permalink / raw)


In article <m3n1svbw6t.fsf@kiuk0156.chembio.ntnu.no>,
  Preben Randhol <randhol@pvv.org> wrote:

> it will dump core


If this dumps core, you have an installation problem. This
program should raise Data_Error and certainly does when I
run it:

   raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiflau.adb:88

Of course since you have no handler for data error, the
program is terminated. Go study the use of exception handlers
in whatever text or tutorial you are reading, that's what you
need here!


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[relevance 4%]

* Re: Safely converting String to Float ?
  @ 1999-11-03  0:00  4% ` Robert Dewar
  1999-11-03  0:00  4%   ` Preben Randhol
  1999-11-03  0:00  4% ` Robert Dewar
  1 sibling, 1 reply; 195+ results
From: Robert Dewar @ 1999-11-03  0:00 UTC (permalink / raw)


In article <m3n1svbw6t.fsf@kiuk0156.chembio.ntnu.no>,
  Preben Randhol <randhol@pvv.org> wrote:

> it will dump core


If this dumps core, you have an installation problem. This
program should raise Data_Error and certainly does when I
run it:

   raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiflau.adb:88

Of course since you have no handler for data error, the
program is terminated. Go study the use of exception handlers
in whatever text or tutorial you are reading, that's what you
need here!


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[relevance 4%]

* Re: Safely converting String to Float ?
  1999-11-03  0:00  4% ` Robert Dewar
@ 1999-11-03  0:00  4%   ` Preben Randhol
  0 siblings, 0 replies; 195+ results
From: Preben Randhol @ 1999-11-03  0:00 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-deja.com> writes:
 
| If this dumps core, you have an installation problem. This
| program should raise Data_Error and certainly does when I
| run it:
| 
|    raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiflau.adb:88

Hmm. I have only installed the Gnat 3.12p RPM from
http://www.gnuada.org/rpms312p.html

Maybe I forgot to install something.

| Of course since you have no handler for data error, the
| program is terminated. Go study the use of exception handlers
| in whatever text or tutorial you are reading, that's what you
| need here!

Yes, but you'r saying that it should not dump core even if I don't use
exceptions here, right?

-- 
Preben Randhol                 Affliction is enamoured of thy parts, 
[randhol@pvv.org]              And thou art wedded to calamity. 
[http://www.pvv.org/~randhol/]                    -- W. Shakespeare 




^ permalink raw reply	[relevance 4%]

* Ada and Java. different behaviour. casting long to int problem.
@ 1999-06-12  0:00  3% nabbasi
  1999-06-12  0:00  0% ` nabbasi
  0 siblings, 1 reply; 195+ results
From: nabbasi @ 1999-06-12  0:00 UTC (permalink / raw)



This below shows that Ada detected at compile time a basic problem
that the Java compiler missed. (this might be specific problem
with the Java compiler I am using), it also could be a 
mis-understanding on my part of the Java semantics when it 
comes to this, but the bottom line is that Java produced, 
what for me, can only be a wrong result.

Please do not make this thread a language-war, (I happen to
like both Java and Ada), but I am really only interested in 
someone explaining the justification behind this Java behavior.

In the example, I cast a long integer literal, outside the range
of an integer, into an integer variable.  Java allows this,
and produces the wrong result. Ada compiler detect this as an error
at compile time, and it also detects the same thing at run-time.

fyi: a 64 bit signed long range is -9223372036854775808 .. 9223372036854775807 
and an 32 bit signed integer range is  -2147483648 .. 2147483647

In the example, I cast the literal 3200000000, which is clearly outside
the range of an integer, into an integer. I expect the compiler or
the run-time, to detect this. Ada does, Java did not. Is this by 'design'
on the part of Java? i.e. is this how Java supposed to behave? becuase
this can result in very wrong calculations if not detected.

env:
----
OS: linux 2.0.36
Java compiler: free JDK from http://www.blackdown.org 1.2, also 1.1.7B
Ada compiler : free ada95 GNAT compiler from http://www.gnat.com, version 3.11p

---------------- java example 1-----------------------------
class test_cast
{
   public static void main(String args[])
   {
      long n= 3200000000L;
      int  m= (int) n;
      System.err.println("long n =" + n + " int m=" + m);
   }
}

$javac  ./test_cast.java      <-- compile OK

$java test_cast               <--- runs OK and produces 'wrong' result.
long n =3200000000 int m=-1094967296
$
----------------------------- Ada example 2 -----------------
with Ada.Text_Io;         USE Ada.Text_Io;

procedure Test_Cast is
   n : Long_Integer := 3200000000;
   m : Integer      := Integer (N);
begin
      Put_Line (   "long n ="  &  Long_integer'Image(N)
                 & "int  m ="  &  Integer'Image(M) );
end Test_Cast;

$gnatmake test_cast.adb
gnatgcc -c test_cast.adb
test_cast.adb:5:24: value not in range of type "Standard.Long_Integer"
test_cast.adb:5:24: static expression raises "Constraint_Error"
gnatmake: "test_cast.adb" compilation error
$

--------------------------------------------------------------------

Now, lets try the same idea as above, but do not use a literal
number (so to not allow the ada compiler the chance to detect this
at compile time) and try to do the same at run-time.


------------------- ada example 2 -----------------------------

with Ada.Text_Io;         USE Ada.Text_Io;

procedure Test_Cast is
   N  : Long_Integer;
   M  : Integer;
   package Long_Int_Io  is new Ada.Text_Io.Integer_Io(Long_Integer);
begin
   Long_Int_Io.Get(N);
   M := Integer (N);

   Put_Line (   "long n ="  &  Long_integer'Image(N)
              & "int  m ="  &  Integer'Image(M) );
end Test_Cast;

$gnatmake -gnatf test_cast.adb    <-- compile OK
gnatgcc -c -gnatf test_cast.adb
gnatbind -x test_cast.ali
gnatlink test_cast.ali

$./test_cast                  <--- run
3200000000

raised ADA.IO_EXCEPTIONS.DATA_ERROR   <-- exception raised
-------------------------------------------------------------


comments?

Nasser





^ permalink raw reply	[relevance 3%]

* Re: Ada and Java. different behaviour. casting long to int problem.
  1999-06-12  0:00  3% Ada and Java. different behaviour. casting long to int problem nabbasi
@ 1999-06-12  0:00  0% ` nabbasi
  0 siblings, 0 replies; 195+ results
From: nabbasi @ 1999-06-12  0:00 UTC (permalink / raw)


In article <7jt2c0$vrb@drn.newsguy.com>, nabbasi@pacbell.net says...
 
>In the example, I cast a long integer literal, outside the range
>of an integer, into an integer variable.  Java allows this,
>and produces the wrong result. Ada compiler detect this as an error
>at compile time, and it also detects the same thing at run-time.
>                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

actually that was an error of mine, it did not detect it at run-time,
only at compile time. see below
 
>------------------- ada example 2 -----------------------------
>
>with Ada.Text_Io;         USE Ada.Text_Io;
>
>procedure Test_Cast is
>   N  : Long_Integer;
>   M  : Integer;
>   package Long_Int_Io  is new Ada.Text_Io.Integer_Io(Long_Integer);
>begin
>   Long_Int_Io.Get(N);
>   M := Integer (N);
>
>   Put_Line (   "long n ="  &  Long_integer'Image(N)
>              & "int  m ="  &  Integer'Image(M) );
>end Test_Cast;
>

>$./test_cast                  <--- run
>3200000000
>
>raised ADA.IO_EXCEPTIONS.DATA_ERROR   <-- exception raised
>-------------------------------------------------------------
 
This was an input error which I do not understand now why.

This is a modified Ada program, that shows Ada did not detect at
run-time the overflow (I think may be I am not using the correct 
GNAT flag to enable run-time chekcing? I need to check more on this)

-------------------------------------
with Ada.Text_Io;         USE Ada.Text_Io;

procedure Test_Cast is
   N  : Long_Integer;
   M  : Integer;
   package Long_Int_Io  is new Ada.Text_Io.Integer_Io(Long_Integer);
begin
   N := 2000000000;
   M := Integer (N);
   M := M*2;

   Put_Line (   "long n ="  &  Long_integer'Image(N)
              & "int  m ="  &  Integer'Image(M) );
end Test_Cast;
------------------------------------------
 
$./test_cast
long n = 2000000000int  m =-294967296
                        ^^^^^^^^^^^^^^ 
                            ???
Nasser
    





^ permalink raw reply	[relevance 0%]

* Re: Temporary files in Ada95.
  @ 1999-03-29  0:00  4%         ` Jeffrey D. Cherry
  0 siblings, 0 replies; 195+ results
From: Jeffrey D. Cherry @ 1999-03-29  0:00 UTC (permalink / raw)


Larry Kilgallen wrote:

> So what happens if the user running the program does not have write
> access to the root directory of the current drive ?

Great question!!  I ran the executable on our NT machine (no one except
the Administrator has write permission for the root directory on any
partition) and got the following output:

raised ADA.IO_EXCEPTIONS.NAME_ERROR

Yuk!  Perhaps there is a way to get the GNAT compiler to use the system
TEMP directory for temporary files?  

Thanks for catching that problem in my code.  I guess it's always better
to be safe than sorry, so if I ever use a temporary file, I won't assume
it will be created safely.  Pardon me while I go slap my forehead and
say "duh".

Regards,
Jeff Cherry




^ permalink raw reply	[relevance 4%]

* Re: Stream_io / records with default discriminants
  @ 1999-02-14  0:00  4%   ` Bernd Ragutt
  0 siblings, 0 replies; 195+ results
From: Bernd Ragutt @ 1999-02-14  0:00 UTC (permalink / raw)



Matthew Heaney wrote...

>You must post the smallest fragment of compilable code that illustrates
>the behavior you observe.  Without code, we can only guess what is
>going on.

Here is the fragment of code.
The code runs with GNAT/NT; with Apex/AIX  I get an exception (constraint
error).

Thanks.

Bernd Ragutt
from Munich
----------------------
BerndRagutt@csi.com



###################

--  ************ Types
    ...
    subtype Lstring_Length is Natural range 0 .. 25;

    type Lstring (Len : Lstring_Length := 0) is
        record
            Str : String (1 .. Len) := (others => ' ');
        end record;

    type Test_Enumeration is (Eins, Zwei, Drei);

    type Test_Records
            (Indicator : Test_Enumeration := Test_Enumeration'First) is
        record
            case Indicator is
                when Eins =>
                    Eins_Int : Integer := 1;
                when Zwei =>
                    Zwei_String : Lstring;
                when Drei =>
                    Drei_Int : Integer := 3;
                    Drei_String : Lstring;
            end case;
        end record;
    ...
--  ***********
    ...
    function Input_From_Stream return Test_Records is
    begin
        return Test_Records'Input (Date_File_Stream);
    exception
        when Ada.Streams.Stream_Io.End_Error =>
            raise Eof;
    end Input_From_Stream;
    ...
--  ************

with Text_Io;
with Ada.Io_Exceptions;
with Ada.Tags;

procedure Record_Io.Test2 is

    use Ada;

    Test_Record1 : Test_Records (Indicator => Eins);
    Test_Record2 : Test_Records := (Eins, 321);

    Test_Record3 : Test_Records :=
       (Indicator => Drei, Drei_Int => 999, Drei_String => (4, "AbcD"));

    Test_Record4 : Test_Records :=
       (Indicator => Zwei, Zwei_String => (5, "vWXYz"));

begin
    Open_Stream;

    Output_To_Stream (Test_Record1);
    Output_To_Stream (Test_Record1);
    Output_To_Stream (Test_Record2);
    Output_To_Stream (Test_Record3);
    Output_To_Stream (Test_Record4);

    Reset_To_Instream;

    loop
        declare
        begin
            -- ***
     declare
                Readed_Record : Test_Records
                      := Input_From_Stream;
                     --################################
                      -- Constraint Error when reading Test_Record2
            begin
                Text_Io.Put_Line
                   (Test_Enumeration'Image (Readed_Record.Indicator) & "
readed");
            exception
                when Eof =>
                    Text_Io.Put_Line ("EoF!");
                    exit;
            end;
     -- ***
        exception
         ...
        end;
    end loop;
end Record_Io.Test2;










^ permalink raw reply	[relevance 4%]

* Re: egcs1.1b and gnat3.10p
  1998-12-01  0:00  5% egcs1.1b and gnat3.10p grave
@ 1998-12-02  0:00  0% ` Juergen Pfeifer
  0 siblings, 0 replies; 195+ results
From: Juergen Pfeifer @ 1998-12-02  0:00 UTC (permalink / raw)


I don't believe that the patch is good enough.
One suspicious line is Line# 2720. There is

+           TYPE_SIZE (new_type) = TYPE_SIZE_UNIT (right_type);

and I believe it should be

+           TYPE_SIZE_UNIT (new_type) = TYPE_SIZE_UNIT (right_type);

Maybe there are more such locations. When I applied the patch and built
it on my Linux box using the bootstrap target of the Makefile, I got
errors in one of the higher stages in the object file comparision.
So I decided not to use that. I'm quite happy with my egcs-1.03 based
GNAT 3.10p on RedHat 5.1 which I built myself.

Cheers
Juergen

grave wrote:
> 
> Hi all,
> 
> After compiling egcs-1.1b (on a solaris 2.6) with the following patch :
> http://www.teaser.fr/~fabiven/gnat-3.10p-patch/egcs-1.1b-patch.gz
> 
> I tryed to compile the examples given with the sources of gnat
> the example diners give the following error :
> raised STORAGE_ERROR
> example tgef doesn't do anything and
> example text_io_example give :
> raised ADA.IO_EXCEPTIONS.DATA_ERROR
> 
> any help possible on such kind of problem ?
> 
> xavier

-- 
http://home.t-online.de/home/Juergen.Pfeifer




^ permalink raw reply	[relevance 0%]

* egcs1.1b and gnat3.10p
@ 1998-12-01  0:00  5% grave
  1998-12-02  0:00  0% ` Juergen Pfeifer
  0 siblings, 1 reply; 195+ results
From: grave @ 1998-12-01  0:00 UTC (permalink / raw)


Hi all,

After compiling egcs-1.1b (on a solaris 2.6) with the following patch :
http://www.teaser.fr/~fabiven/gnat-3.10p-patch/egcs-1.1b-patch.gz

I tryed to compile the examples given with the sources of gnat
the example diners give the following error :
raised STORAGE_ERROR
example tgef doesn't do anything and
example text_io_example give :
raised ADA.IO_EXCEPTIONS.DATA_ERROR

any help possible on such kind of problem ?        

xavier




^ permalink raw reply	[relevance 5%]

* One for the Apex guys.
@ 1998-11-09  0:00  4% Roga Danar
  0 siblings, 0 replies; 195+ results
From: Roga Danar @ 1998-11-09  0:00 UTC (permalink / raw)


Hi,

  I am still attempting to simply write to a port using Apex Ada
exclusively.  I found some code in the Predefined Subsystem that looked
like it would allow me to do what I wanted.

  Other suggestion solution worked fine but I am require to stay with
Apex.

  I am using Rational Apex Ada95.  The comments tell me that the
Initailize procedure needs to called in elaboration to setup default
files.

Below is the code and the error message I am getting.

Thanks in advance for any help.

######################################  Elaboration code
###################################


package Test_Comm_Elab is

    Ns : constant String := "";

    function Null_Str return String;

end Test_Comm_Elab;

--
-- File Name: test_comm_elab.2.ada
--

with Apex_Predefined_Io_Implementation;
use Apex_Predefined_Io_Implementation;

with Apex_Predefined_Io_Implementation.Text_Io_Support;
use Apex_Predefined_Io_Implementation.Text_Io_Support;

with Ada.Text_Io;
with Ada.Exceptions;
use Ada.Exceptions;

package body Test_Comm_Elab is

    procedure Pl (Item : String) renames Ada.Text_Io.Put_Line;

    function Null_Str return String is
    begin
        return Ns;
    end Null_Str;

begin

    Initialize (Client => Text_Io);

exception
    when E: others =>
        Pl ("Error during elaboration or Initialization call ** " &
            Ada.Exceptions.Exception_Name (E));
end Test_Comm_Elab;


####################################### Main Test Driver
########################################
--
-- File Name: test_comm.2.ada
--

with Apex_Predefined_Io_Implementation;
with Apex_Predefined_Io_Implementation.Common_Io;
with Apex_Predefined_Io_Implementation.Text_Io_Support;

with Apex_Predefined_Io_Implementation.Os_Dependent_Io;

--with Win_Show;
with Port_Des;

with Ada;
with Ada.Text_Io;
with Ada.Exceptions;

with Test_Comm_Elab;

pragma Elaborate (Test_Comm_Elab);
procedure Test_Comm is

    package Io_Imp renames Apex_Predefined_Io_Implementation;
    package Common_Io renames Io_Imp.Common_Io;
    package Os_Dep_Id renames Io_Imp.Os_Dependent_Io;

    package T_Io renames Io_Imp.Text_Io_Support;

    use Io_Imp;

    procedure Create (File : in out Common_Io.File_Type;
                      Mode : in File_Mode;
                      Kind : in File_Kind;
                      Name : in String := "";
                      Form : in String := "";
                      Client : in Client_Kind := Unknown)
       renames Common_Io.Create;

    Com1_Name : Port_Des.Port_Name_Type := Port_Des.Port_Com1;
    Com2_Name : Port_Des.Port_Name_Type := Port_Des.Port_Com2;
    Com3_Name : Port_Des.Port_Name_Type := Port_Des.Port_Com3;
    Com4_Name : Port_Des.Port_Name_Type := Port_Des.Port_Com4;

    type Port_Info_Rec is
        record
            Port_File_Kind : Io_Imp.File_Kind := Io_Imp.Associated;
            Port_File_Mode : Io_Imp.File_Mode := Io_Imp.Inout_File;
            Com_Port_File : Common_Io.File_Type := Common_Io.Null_File;
            Com_Port_Name : Port_Des.Port_Name_Type := Com1_Name;
            Com_Port_Client : Client_Kind := Text_Io;
        end record;

    P_Rec : Port_Info_Rec;

    Com1_Info : constant Port_Info_Rec := P_Rec;

    Com2_Info : constant Port_Info_Rec :=
       (Port_File_Kind => P_Rec.Port_File_Kind,
        Port_File_Mode => P_Rec.Port_File_Mode,
        Com_Port_File => Common_Io.Null_File,
        Com_Port_Client => Text_Io,
        Com_Port_Name => Com2_Name);

    Com3_Info : constant Port_Info_Rec :=
       (Port_File_Kind => P_Rec.Port_File_Kind,
        Port_File_Mode => P_Rec.Port_File_Mode,
        Com_Port_File => Common_Io.Null_File,
        Com_Port_Client => Text_Io,
        Com_Port_Name => Com3_Name);

    Com4_Info : constant Port_Info_Rec :=
       (Port_File_Kind => P_Rec.Port_File_Kind,
        Port_File_Mode => P_Rec.Port_File_Mode,
        Com_Port_File => Common_Io.Null_File,
        Com_Port_Client => Text_Io,
        Com_Port_Name => Com4_Name);

    type Port_Info_Array is array (Port_Des.Ports_Type) of
Port_Info_Rec;

    Port_Info : Port_Info_Array := (Port_Des.Com1 => Com1_Info,
                                    Port_Des.Com2 => Com2_Info,
                                    Port_Des.Com3 => Com3_Info,
                                    Port_Des.Com4 => Com4_Info);

    Control_Block : Os_Dep_Id.Os_Control_Block :=
Os_Dep_Id.Null_Control_Block;

--    procedure Show (S : String;
--                    Caption : in String := " *** Testing *** ")
--      renames Win_Show.Display;

    procedure Putl (Item : String) renames Ada.Text_Io.Put_Line;

begin

--    T_Io.Initialize (Client => Text_Io);

    for Port in Port_Des.Com1 .. Port_Des.Com4 loop -- ports loop

-- Get a lock
--
        Putl ("# Getting Lock for: " & Port_Des.Ports_Type'Image
(Port));
        Common_Io.Acquire (Port_Info (Port).Com_Port_File);

-- Open the port
--
        Putl ("Creating File on port");
        Create_Block:
            begin

                Create (File => Port_Info (Port).Com_Port_File,
                        Mode => Port_Info (Port).Port_File_Mode,
                        Kind => Io_Imp.Associated,
                        Name => Port_Info (Port).Com_Port_Name,
                        Client => Text_Io);


                -- T_Io.Create (File => Port_Info (Port).Com_Port_File,
                --              Mode => Port_Info (Port).Port_File_Mode,

                --              Name => Port_Info (Port).Com_Port_Name,
                --              Client => Text_Io);
                --
                declare

                    procedure Pl (File : T_Io.File_Type; Item : String)
                       renames T_Io.String_Io.Put_Line;

                begin

                    Putl ("# Writing to port #");
                    Pl (File => Port_Info (Port).Com_Port_File,
                        Item => " ### This is Port testing string ###
");

                exception
                    when E: others =>
                        Putl ("Write failed: " &
                              Ada.Exceptions.Exception_Name (E));
                        raise;
                end;

            exception
                when E: others =>
                    Putl ("Create failed: " &
                          Ada.Exceptions.Exception_Name (E));
            end Create_Block;

            --
            --       Control_Block := Common_Io.Os_Dependent_Control;
            --
            -- Os_Dep_Id.Write (Ctrl => Control_Block,
            --                              Item =>
    end loop;

    Putl ("Test DONE!");

exception
    when E: others =>
        Putl ("Unknown exception: " & Ada.Exceptions.Exception_Name
(E));
end Test_Comm;


######################## ERROR MESSAGE ###############################

z:\project\sdf\communication\design\apex.ss\mvs_test.wrk\win_sockets>test_comm

Error during elaboration or Initialization call **
ADA.IO_EXCEPTIONS.STATUS_ERROR
# Getting Lock for: COM4
Creating File on port
Create failed: ADA.IO_EXCEPTIONS.USE_ERROR
Test DONE!





^ permalink raw reply	[relevance 4%]

* Re: Image processing File I/O
  @ 1998-09-24  0:00  2%   ` Michael F Brenner
  0 siblings, 0 replies; 195+ results
From: Michael F Brenner @ 1998-09-24  0:00 UTC (permalink / raw)



In addition to Sequential IO on an 8-bit NUMERICAL byte type in 
the old Ada 83, you could use Stream IO in Ada. Here is a package
that permits you to read and write binary data using Stream IO
in DOS, Windows, and Linux (you need to change the one line
that is marked for the directory separator, forward or backwards
slash).

The package HAND below makes stream IO streams look like ordinary
files by giving them handle numbers you can open, close, read from,
and right to. The two features used in Ada that were not present
in the old Ada 83 are the streams themselves, and 8-bit characters.

Of course, Ada still permits you to do sequential IO on files of
numerical 8-bit bytes, but timing tests on Solaris, DOS, and 
Windows NT (using the DOS compiler) all show that, in these
environments, stream IO is now quicker. (Earlier versions of 
gnat had sequential IO quicker).

-----------------------------------------------------------------

package string_control is
  pragma pure (string_control);

 -- Ordinary String control

 function  caselessly_equal (left, right: character)
                             return boolean;
 function  caselessly_equal (object: string; start, length: natural;
                             pattern: string)
                             return boolean;
 procedure concat           (message:  character;
                             onto: in out string;
                             length:   in out natural);
 procedure concat           (message:  string;
                             onto: in out string;
                             length:   in out natural);

 -- First-missing and first-occurring return 0 when not found.

 function  first_missing    (message: string;
                             pattern: character := ' ')
                             return integer;
 function  first_occurring  (message: string;
                             pattern: character := ' ')
                             return integer;
 function  first_occurring  (message: string;
                             pattern: string)
                             return integer;
 function  image            (message: string)
                             return string;
 procedure in_place_insert  (message: in out string;
                             message_length: in out natural;
                             insertion: string;
                             after: natural);
 function  indent           (message: string)
                             return string;

 function  length           (message: string)
                             return natural;

 -- Last-missing and last-occuring return 0 when not found.

 function  last_missing     (message: string;
                             pattern: character := ' ')
                             return integer;
 function  last_occurring   (message: string;
                             pattern: character := ' ')
                             return integer;
 function  left_trim        (message: string;
                             pattern: character := ' ')
                             return string;
 procedure lower_case       (message: in out string;
                             start: natural;
                             finish: natural);
 function  lower_case       (c: character)
                             return character;
 function  lower_case       (message: string)
                             return string;
 function  right_trim       (message: string;
                             pattern: character := ' ')
                             return string;
 function  quotes_are_good  (message: string;
                             quote:   character := '"')
                             return boolean;
 procedure quotes_inserted  (message: string;
                             result:  in out string; -- 2+2*message'length
                             length:  out natural;
                             quote:   character := '"');
 procedure quotes_removed   (message: string;
                             result:  in out string; -- message'length
                             length:  out natural;
                             quote:   character := '"');
 function  same             (left, right: string)
                             return boolean;
 function  substitute       (base_string: string;
                             search_string: string;
                             replace_string: string)
                             return string;
 procedure upper_case       (message: in out string;
                             start: natural;
                             finish: natural);
 function  upper_case       (c: character)
                             return character;
 function  upper_case       (message: string)
                             return string;

  -- http://email:port/disk:file1/file2/.../filen#anchor?arg1?arg2?...?argk
  --
  -- @ Separators (://, :, /, #, ?)
  -- @ Words (protocol, email, port, disk, file, anchor, arg)
  -- @ Nonquoted words may contain alphanumerics, ~, _, !, @, -, and periods.
  -- @ Quoted words may contain anything, doubling the quotes

  procedure url_break_apart (url: string;
                             protocol_start:  out natural;
                             protocol_finish: out natural;
                             internet_start:  out natural;
                             internet_finish: out natural;
                             port_start:      out natural;
                             port_finish:     out natural;
                             disk_start:      out natural;
                             disk_finish:     out natural;
                             file_start:      out natural;
                             file_finish:     out natural;
                             anchor_start:    out natural;
                             anchor_finish:   out natural;
                             args_start:      out natural;
                             args_finish:     out natural);

  -- Lexical classes are sets of characters, here represented as bits.

  type classes is array(character) of boolean;
  pragma pack (classes);

  small_letter_class: constant classes :=
    (character'first .. character'val (96) => false,
     'a' .. 'z' => true,
     '{' .. character'last => false);

  capital_letter_class: constant classes :=
    (character'first .. '@' => false,
     'A' .. 'Z' => true,
     '[' .. character'last => false);

  alphabetic_class: constant classes :=
    (character'first .. '@' => false,
     'A' .. 'Z' => true,
     '[' .. character'val (96) => false,
     'a' .. 'z' => true,
     '{' .. character'last => false);

  digit_class: constant classes :=
    (character'first .. '/' => false,
     '0'..'9' => true,
     ':'..character'last => false);

  sign_class: constant classes :=
    (character'first .. character'pred ('+') => false,
     '+' => true,
     character'succ('+')..character'pred('-') => false,
     '-' => true,
     character'succ('-').. character'last => false);

  digit_or_sign_class: constant classes :=
    (character'first .. character'pred ('+') => false,
     '+' => true,
     character'succ('+')..character'pred('-') => false,
     '-' => true,
     character'succ('-')..character'pred('0') => false,
     '0'..'9' => true,
     character'succ('9')..character'last => false);



  underline_class: constant classes :=
    (character'first .. '^' => false,
     '_' => true,
     character'val (96) ..character'last => false);

  alphanumeric_class: constant classes :=
    (character'first .. '@' => false,
     'A' .. 'Z' => true,
     '[' .. '^' => false,
     '_' => true,
     character'val (96) => false,
     'a' .. 'z' => true,
     '{' .. character'last => false);

  null_class: constant classes := (others => false);

  -- The MATCH method searches for a character class in the MESSAGE,
  -- returning the column in which the pattern was found,
  -- otherwise returning zero.

  type recognitions is record
    RSTART, RLENGTH: natural;
  end record;

  function match (message: string; class: classes) return recognitions;

end string_control;


package body string_control is

 function  caselessly_equal (left, right: character) return boolean is
 begin
   return
     left=right or else
     (left in 'A'..'Z' and then right=character'val(character'pos(left)+32))
     or else
     (left in 'a'..'z' and then right=character'val(character'pos(left)-32));
 end caselessly_equal;

 function  caselessly_equal (object: string; start, length: natural;
                             pattern: string) return boolean is
 begin
   if length /= pattern'length then return FALSE;
   else
     for i in 1..length loop
       if not caselessly_equal (object  (start         + i - 1),
                                pattern (pattern'first + i - 1)) then
          return FALSE;
       end if;
     end loop;
   end if;
   return TRUE;
 end caselessly_equal;

 procedure concat (message:  character;
                   onto: in out string;
                   length:   in out natural) is
   concat_too_long: exception;
 begin
   if length + 1 > onto'length then
     raise concat_too_long;
   end if;
   onto (length + 1) := message;
   length := length + 1;
 end concat;

 procedure concat (message:  string;
                   onto: in out string;
                   length:   in out natural) is
   concat_too_long: exception;
 begin
   if length + message'length > onto'length then
     raise concat_too_long;
   end if;
   onto (length + 1 .. length + message'length) := message;
   length := length + message'length;
 end concat;

 function first_missing (message: string;
                         pattern: character := ' ') return integer is
 begin
   for i in message'range loop
     if message(i) /= pattern then
       return i;
     end if;                -- message (message'first..i) are patterns.
   end loop;
   return 0;                -- Returns the first column without PATTERN.
 end first_missing;

 function first_occurring (message: string;
                           pattern: character := ' ') return integer is
 begin
   for i in message'range loop
     if message(i)  = pattern then
       return i;            -- message contains the pattern
     end if;                -- message (message'first..i) contains no pattern
   end loop;
   return 0;                -- message contains no pattern
 end first_occurring;

 function first_occurring (message: string; pattern: string)
                           return integer is
   upto: natural := message'first;
   last: integer := message'last + 1 - pattern'length;
   in_first_occuring_the_pattern_is_null: exception;
   RSTART:  natural := 0;
 begin
   RSTART := 0;

   if pattern="" then
      raise in_first_occuring_the_pattern_is_null;
   end if;

   loop
     exit when upto>last;

     if message(upto..upto+pattern'length-1)=pattern then
       RSTART := upto;
       return RSTART;
     end if;

     upto := upto + 1;
   end loop;
   return 0;
 end first_occurring;

 function image (message: string) return string is
   hold: string (1..message'length) := message;
 begin
   return hold;
 end image;

 procedure in_place_insert (message: in out string;
                            message_length: in out natural;
                            insertion: string;
                            after: natural) is
   string_control_in_place_insert_ml_plus_il_gt_ml: exception;
 begin
   if message_length + insertion'length > message'length then
     raise string_control_in_place_insert_ml_plus_il_gt_ml;
   end if;
   message(insertion'length + 1 + after .. message_length+insertion'length) :=
     message(after+1..message_length);
   message(after+1..after+insertion'length) := insertion;
   message_length := message_length + insertion'length;
 end in_place_insert;

 function indent(message: string) return string is
 begin
   return (1..message'length + 1 => ' ');
 end indent;

 function last_missing (message: string;
                        pattern: character := ' ') return integer is
 begin
   for i in reverse message'range loop
     if message(i) /= pattern then
       return i;
     end if;                -- message (i..message'last) are patterns.
   end loop;
   return 0;                -- Returns the last column without PATTERN.
 end last_missing;

 function last_occurring (message: string;
                          pattern: character := ' ') return integer is
 begin
   for i in reverse message'range loop
     if message (i) = pattern then
       return i;
     end if;                -- message (i..message'last) contains no pattern
   end loop;
   return 0;                -- Returns the last column with PATTERN.
 end last_occurring;

 function left_trim (message: string;
                     pattern: character := ' ') return string is
   left_trim_last: constant natural := first_missing (message, pattern);
 begin
   if left_trim_last = 0 then
     return ""; -- blank not found at all means null string
   else
     return message (left_trim_last .. message'last);
   end if;
 end left_trim;

 function length (message: string) return natural is
 begin
   return message'length;
 end length;

 function lower_case (c: character) return character is
 begin
   if c in 'A'..'Z' then
     return character'val (character'pos (c) + 32);
   end if;
   return c;
 end lower_case;

 procedure lower_case (message: in out string;
                       start: natural; finish: natural) is
 begin
   for i in start..finish loop
     if message (i) in 'A'..'Z' then
       message (i) := character'val (character'pos (message (i)) + 32);
     end if;
   end loop;
 end lower_case;

 function lower_case (message: string) return string is
   hold_message: string (1..message'length) := message;
   ch:           character;
   offset: constant := character'pos ('a') - character'pos ('A');
 begin
   for c in hold_message'range loop
     ch := hold_message (c);
     if ch in 'A'..'Z' then
       hold_message (c) := character'val (character'pos (ch) + offset);
     end if;            -- MESSAGE (FIRST..C) is in lower_case.
   end loop;
   return hold_message; -- MESSAGE is in lower_case.
 end lower_case;

 function match (message: string; class: classes) return recognitions is
   recognition: recognitions;
   RSTART:  natural renames recognition.RSTART;
   RLENGTH: natural renames recognition.RLENGTH;
   upto: natural := message'first;
 begin
   RSTART := 0;
   loop
      exit when upto > message'last;
      exit when class (message (upto)) ;
      upto := upto + 1;
   end loop;
   if upto > message'last then
     return (0, 0);
   else
     RSTART := upto;
   end if;
   loop
     exit when upto > message'last;
     exit when not class (message (upto));
     upto := upto + 1;
   end loop;
   RLENGTH := upto - RSTART;
   return recognition;
 end match;

 function  quotes_are_good  (message: string;
                             quote:   character := '"')
                             return boolean is
   input: natural := message'first + 1;
 begin
   if message'length<2 or else
      message(message'first)/=quote or else
      message(message'last) /=quote then
     return false;
   end if;
   loop
     exit when input >= message'length;
     if message(input)/='"' then
       input:=input+1;
     elsif message(input+1)/='"' then
       return false;
     elsif input=message'length-1 then
       return false;
     else
       input:=input+2;
     end if;
   end loop;
   return true;
 end quotes_are_good;

 procedure quotes_inserted  (message: string;
                             result:  in out string; -- 2+2*message'length
                             length:  out natural;
                             quote:   character := '"') is
   output: natural := 0;
 begin
   concat (quote, result, output);
   for input in message'range loop
     if message(input) = quote then
       concat (quote, result, output);
       concat (quote, result, output);
     else
       concat (message(input), result, output);
     end if;
   end loop;
   concat (quote, result, output);
   length := output;
 end quotes_inserted;

 procedure quotes_removed   (message: string;
                             result:  in out string; -- message'length
                             length:  out natural;
                             quote:   character := '"') is
   output: natural := result'first - 1;
   input:  natural := message'first+1;
   quotation_is_not_proper1: exception;
   quotation_is_not_proper2: exception;
 begin
   if    message'length < 2 or else
         message(message'first) /= quote or else
         message(message'last)  /= quote then
     output := message'length;
     result(result'first-1+1..result'first-1+message'length) := message;
   else
     loop
       exit when input>=message'last; -- Since message(message'last)=quote.
       if    message(input)/=quote then
         concat(message(input), result, output);
       elsif message(input+1) /= quote then
         raise quotation_is_not_proper2;
       else -- Two quotes in a row
         concat(message(input), result, output);
         input:=input+1;
       end if;
       input:=input+1;
     end loop;
   end if;
   length := output;
 end quotes_removed;

 function right_trim (message: string;
                      pattern: character := ' ') return string is
   right_trim_last: constant natural := last_missing (message, pattern);
 begin
   return message (message'first .. right_trim_last);
 end right_trim;

 function same (left, right: string)  return boolean is

   -- String Comparison: Semantically, left=right.

 begin
   return left'length = right'length and then
          left = right;
 end same;

 function substitute (base_string: string;
                      search_string: string;
                      replace_string: string)
                      return string is

   location: constant natural := first_occurring (base_string, search_string);
 begin
   if location = 0 then
     return base_string;
   elsif location = 1 then -- this requires the base_string to start at 1
     return replace_string &
            base_string (location+
                         search_string'length..
                         base_string'last);
   elsif location = base_string'last + 1 - search_string'length then
     return base_string (base_string'first..
                         base_string'last-search_string'length) &
            replace_string;
   else
     declare
       left_part: constant string :=
         base_string (base_string'first..location - 1);
     begin
       return left_part &
              replace_string &
              base_string (location + search_string'length ..
                           base_string'last);
     end;
   end if;
 end substitute;

 function upper_case (c: character) return character is
 begin
   if c in 'a'..'z' then
     return character'val (character'pos (c) - 32);
   end if;
   return c;
 end upper_case;

 procedure upper_case (message: in out string;
                       start: natural; finish: natural) is
 begin
   for i in start..finish loop
     if message (i) in 'a'..'z' then
       message (i) := character'val (character'pos (message (i)) - 32);
     end if;
   end loop;
 end upper_case;

 function upper_case (message: string) return string is
   hold_message:          string (1..message'length) := message;
   ch:                    character;
   offset: constant := character'pos ('a') - character'pos ('A');
 begin
   for c in hold_message'range loop
     ch := hold_message (c);
     if ch in 'a'..'z' then
       hold_message (c) := character'val (character'pos (ch) - offset);
     end if;            -- MESSAGE (FIRST..C) is in upper_case.
   end loop;
   return hold_message; -- MESSAGE is in upper case.
 end upper_case;

 procedure get_url_word (message: string;
                         message_start:    natural;
                         message_finish:   natural;
                         word_start:       out natural;
                         word_finish:      out natural;
                         separator_start:  out natural;
                         separator_finish: out natural;
                         separators: string := ":/#?") is

   -- Example 1: ~_.!a.7.@
   -- Example 2: "http://email.address/cgi/bin#query?""what """" quote"""

   c:          character;
   hold_quote: character := ascii.nul;
   upto:       natural   := message_start;
   something_cannot_arise_from_nothing: exception;
   unclosed_quote:                      exception;
   single_quote: constant character    := ''';
   double_quote: constant character    := '"';
   quotes:       constant string(1..2) := single_quote & double_quote;
 begin
   word_start := message_start;
   if message_start  > message_finish or
      message_finish < message'first  or
      message_start  > message'last then
     raise something_cannot_arise_from_nothing;
   end if;

   -- The range message_start..message_finish in contained in MESSAGE.

   if first_occurring (quotes, message (message_start)) /= 0 then
       -- Quote at start.
     hold_quote := message (upto);
     upto := upto + 1;
     loop
       exit when upto > message_finish;
       c := message (upto);
       if c = hold_quote then
         if upto < message_finish and then
            message (upto+1) = hold_quote then
           upto := upto + 1;
         else
           word_finish := upto;
           separator_start := upto+1;
           separator_finish := upto+1;
           return;
         end if;
       end if;
       upto := upto + 1;
     end loop;
     raise unclosed_quote;

   else -- No quote at start.
     loop
       exit when upto > message_finish;
       c := message (upto);
       if first_occurring (separators, c) /= 0 then
         word_finish := upto-1;
         separator_start := upto;
         loop
           exit when upto > message_finish;
           c := message (upto);
           exit when first_occurring (separators, c) = 0;
           upto := upto + 1;
         end loop;
         separator_finish := upto - 1;
         return;
       end if;
       upto := upto + 1;
     end loop;
     word_finish := upto - 1;
     separator_start := upto;
     separator_finish := 0;
   end if;
 end get_url_word;

 procedure url_break_apart (url: string;
                            protocol_start:  out natural;
                            protocol_finish: out natural;
                            internet_start:  out natural;
                            internet_finish: out natural;
                            port_start:      out natural;
                            port_finish:     out natural;
                            disk_start:      out natural;
                            disk_finish:     out natural;
                            file_start:      out natural;
                            file_finish:     out natural;
                            anchor_start:    out natural;
                            anchor_finish:   out natural;
                            args_start:      out natural;
                            args_finish:     out natural) is

   -- Under NT 4.0 the following rules apply:
   --   @ the file part goes up to 255 characters long
   --   @ permit as many periods anywhere in the file
   --   @ forbid characters: question mark and asterisk in a file
   --   @ permit as many blanks in the middle of the file
   --   @ strip off all blanks at the beginning and end of the file's name
   --
   -- This code currently compiles under the first two rules, and
   -- does not enforce the other 3 rules.

   ws, wf, ss, sf: natural;
   sl: integer;
   type separators is (error, colon_slash_slash, colon, other, none);
   separator: separators := error;
   separator_c: character;
   not_a_url: exception;

   procedure ts_get_url_word is -- for unit test only
     type expected_results is array (1..4) of natural;
     ws, wf, ss, sf: natural; -- set by get_word
     message1: constant string (2..19) := "~_.!a.7.@://aaa#b?";
     message2: constant string (1..15) := """what """" quote""";
     ts_get_url_word_failed: exception;
   begin
     get_url_word (message1, 2, 12, ws, wf, ss, sf);
     if    ws /=  2 then raise ts_get_url_word_failed;
     elsif wf /= 10 then raise ts_get_url_word_failed;
     elsif ss /= 11 then raise ts_get_url_word_failed;
     elsif sf /= 12 then raise ts_get_url_word_failed;
     end if;

     get_url_word (message1, 15, 19, ws, wf, ss, sf);
     if ws /= 15 or wf /=16 or ss /= 17 or sf /= 17 then
       raise ts_get_url_word_failed;
     end if;

     get_url_word (message2, 1, 15, ws, wf, ss, sf);
     if    ws /=  1 then raise ts_get_url_word_failed;
     elsif wf /= 15 then raise ts_get_url_word_failed;
     elsif ss /= 16 then raise ts_get_url_word_failed;
     elsif sf /= 16 then raise ts_get_url_word_failed;
     end if;
   end ts_get_url_word;
 begin
   ts_get_url_word;
   protocol_start := 0;
   protocol_finish := 0;
   internet_start := 0;
   internet_finish := 0;
   port_start := 0;
   port_finish := 0;
   disk_start := 0;
   disk_finish := 0;
   file_start := 0;
   file_finish := 0;
   anchor_start := 0;
   anchor_finish := 0;
   args_start := 0;
   args_finish := 0;

   get_url_word (url, url'first, url'last, ws, wf, ss, sf);

   sl:=sf+1-ss;
   if    ss not in url'first..url'last then
     separator := none;
   elsif sl=3 and then url (ss..sf) = "://" then -- it is a full URL
     separator := colon_slash_slash;
   elsif sl=1 and then url (ss) = ':' then -- it is a disk drive
     separator := colon;
   else
     separator := other;
   end if;

   case separator is
     when error => raise not_a_url;
     when colon_slash_slash =>
       protocol_start := ws;
       protocol_finish := wf;
       get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
       internet_start := ws;
       internet_finish := wf;
       if ss in url'range and then ss=sf and then url (ss) = ':' then -- port
         get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
         port_start := ws;
         port_finish := wf;
       end if;
       if ss not in url'range or else ss/=sf or else url (ss) /= '/' then
         return;
       end if;
       get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
     when colon => null;
     when none  => null;
     when other => null;
   end case;

   if ss=sf and ss in url'range then
     separator_c := url (ss);
   else
     separator_c := ascii.lf;
   end if;

   if separator_c = ':' then
     disk_start := ws;
     disk_finish := wf;
     get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
   end if;

   if ss=sf and ss in url'range then
     separator_c := url (ss);
   else
     separator_c := ascii.lf;
   end if;

   file_start := ws;
   loop
     file_finish := wf;
     exit when separator_c /= '/';
     get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
     if ss=sf and ss in url'range then
       separator_c := url (ss);
     else
       separator_c := ascii.lf;
     end if;
   end loop;

   if separator_c = '#' then -- that is, the PRIOR separator
     get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
     if ss=sf and ss in url'range then
       separator_c := url (ss);
     else
       separator_c := ascii.lf;
     end if;
     anchor_start := ws;
     anchor_finish := wf;
   end if;

   if separator_c = '?' then -- that is, the PRIOR separator
     get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
     args_start := ws;
     loop
       get_url_word (url, sf+1, url'last, ws, wf, ss, sf);
       exit when ss /= sf or else ss not in url'range or else url (ss) /= '?';
     end loop;
     args_finish := wf;
   end if;
 end url_break_apart;

end string_control;


package variable_string_control is
   pragma pure (variable_string_control);

-- Variable strings are each allocated to any maximum length, and vary
-- from 0 to that maximum in length. Compiler enforces specifying that
-- maximum length when each variable is declared.

   type variable_strings (size: positive) is limited private;

-- The concatenation of variable strings is an unconstrained string.

  function "&" (left: variable_strings;
                right: variable_strings)
                return string;
  function "&" (left: string;
                right: variable_strings)
                return string;
  function "&" (left: variable_strings;
                right: string)
                return string;

-- When strings agree up to the minimum of their lengths,
-- the shorter string is considered less than the longer string.

  function "<"  (left, right: variable_strings) return boolean;
  function ">"  (left, right: variable_strings) return boolean;
  function "<=" (left, right: variable_strings) return boolean;
  function ">=" (left, right: variable_strings) return boolean;

-- COPY is used to change variable strings.

  procedure copy (source: variable_strings; target: in out variable_strings);
  procedure copy (source: string; target: in out variable_strings);

-- The concatenation method is used to append onto the end of a v string.

  procedure concat(appendage: string;
                   onto: in out variable_strings);
  procedure concat(appendage: variable_strings;
                   onto: in out variable_strings);

-- The ELEMENT method returns a column of a variable string just like
-- array references get columns from ordinary_strings.

  function element (message: variable_strings;
                    col: natural) return character;

-- The IMAGE method returns the string image of a variable string.

  function image (message: variable_strings) return string;

-- The in_place_lower_case function converts
-- alphabetic character from upper to lower
-- case, ignoring all other characters.

  procedure in_place_lower_case (message: in out variable_strings);

-- The in_place_truncate method is a procedure instead of a function,
-- for efficiency.

  procedure in_place_truncate (message: in out variable_strings;
                               ch: character := ' ');

-- The in_place_upper_case function converts
-- alphabetic character from lower to upper
-- case, ignoring all other characters.

  procedure in_place_upper_case (message: in out variable_strings);

-- The LENGTH method returns the length of the variablestring.

  function length (message: variable_strings) return natural;

-- The length_allocated returns the maximum length of the v string.

  function length_allocated (message: variable_strings) return natural;

-- The SAME method is the equality operator for variable strings. To
-- be equal, the two strings must be of the same length, and agree
-- for each of their characters.

  function same (left, right: variable_strings) return boolean;
  function same (left: variable_strings; right: string) return boolean;

-- The set_element method sets a character in a single column
-- of a variable string like array references do for character
-- strings.

  procedure set_element (message: in out variable_strings;
                         col: natural;
                         value:  character);

-- The set_length method truncates a string to a given length or else
-- extends its current length with blanks.

  procedure set_length (message: in out variable_strings;
                        new_length: natural);

-- The SLICE method emulates array slices for variable strings. The
-- SUBSTR method is similar, but based on length instead of final column.
-- The two-argument SUBSTR gets all characters on or after the given column.
-- All of these permit the START argument to take on a value equal to the
-- length of the variable string plus 1, returning the null ordinary_string.

  function slice  (message: variable_strings;
                   start, finish: natural) return string;
  function substr (message: variable_strings;
                   start, length: natural) return string;
  function substr (message: variable_strings;
                   start: natural) return string;
private
  type variable_strings (size: positive) is record
    length: integer := -1; -- Causes arrays of strings to fully Allocate.
    list:   string (1..size);
  end record;
end variable_string_control;                                             


ith string_control;
package body variable_string_control is

 procedure is_okay (message: variable_strings) is
   varstring_never_init: exception;
 begin
   if message.length < 0 then
     raise varstring_never_init;
   end if;
 end is_okay;

 function "&" (left: variable_strings;
               right: variable_strings)
               return string is
   hold: variable_strings (left.length + right.length);
 begin
   is_okay (left);
   is_okay (right);
   copy (left, hold);
   concat (right.list(1..right.length), onto=>hold);
   return hold.list(1..hold.length);
 end "&";

 function "&" (left: string; right: variable_strings) return string is
   hold: variable_strings (left'length + right.length);
 begin
   is_okay (right);
   copy (left, hold);
   concat (right.list(1..right.length), onto=>hold);
   return hold.list(1..hold.length);
 end "&";

 function "&" (left: variable_strings; right: string) return string is
   hold: variable_strings (left.length + right'length);
 begin
   is_okay (left);
   copy (left, hold);
   concat (right, onto=>hold);
   return hold.list(1..hold.length);
 end "&";

 function "<" (left, right: variable_strings) return boolean is
 begin
   is_okay(left);
   is_okay(right);
   if    left.length < right.length then
     return left.list(1..left.length)  <= right.list(1..left.length);
   elsif left.length = right.length then
     return left.list(1..left.length)  <  right.list(1..left.length);
   else -- left.length > right.length
     return left.list(1..right.length) <  right.list(1..right.length);
   end if;
 end "<";

 function ">" (left, right: variable_strings) return boolean is
 begin
   is_okay(left);
   is_okay(right);
   if    left.length < right.length then
     return left.list(1..left.length)  >  right.list(1..left.length);
   elsif left.length = right.length then
     return left.list(1..left.length)  >  right.list(1..left.length);
   else -- left.length > right.length
     return left.list(1..right.length) >= right.list(1..right.length);
   end if;
 end ">";

 function "<=" (left, right: variable_strings) return boolean is
 begin
   return left < right or else left = right;
 end "<=";

 function ">=" (left, right: variable_strings) return boolean is
 begin
   return left > right or else left = right;
 end ">=";

 procedure concat(appendage: string; onto: in out variable_strings) is
   new_length: constant integer := onto.length + appendage'length;
   concat_string_onto_varstring_too_long: exception;
 begin
   is_okay (onto);
   if new_length > onto.size then
     raise concat_string_onto_varstring_too_long;
   end if;
   onto.list(onto.length+1..new_length) := appendage;
   onto.length := new_length;
 end concat;

 procedure concat(appendage: variable_strings;
                  onto: in out variable_strings) is
   new_length: constant integer := onto.length + appendage.length;
   concat_varstring_onto_varstring_too_long: exception;
 begin
   is_okay (onto);
   if new_length > onto.size then
     raise concat_varstring_onto_varstring_too_long;
   end if;
   onto.list(onto.length+1..new_length) :=
     appendage.list(1..appendage.length);
   onto.length := new_length;
 end concat;

 procedure copy (source: variable_strings; target: in out variable_strings) is
   copy_varstring_to_varstring_too_long: exception;
 begin
   is_okay (source);
   if source.length > target.size then
     raise copy_varstring_to_varstring_too_long;
   end if;
   target.length := source.length;
   target.list (1..source.length) := source.list (1..source.length);
 end copy;

 procedure copy (source: string; target: in out variable_strings) is
   copy_string_to_varstring_too_long: exception;
 begin
   if source'length > target.size then
     raise copy_string_to_varstring_too_long;
   end if;
   target.length := source'length;
   if source'length>0 then
     target.list (1..source'length) := source;
   end if;
 end copy;

 function element (message: variable_strings;
                   col: natural) return character is
   varstring_element_out_of_range: exception;
 begin
   is_okay (message);
   if    col not in 1..message.length then
     raise varstring_element_out_of_range;
   end if;
   return message.list (col);
 end element;

 function image (message: variable_strings) return string is
 begin
   is_okay (message);
   if message.length=0 then return "";
   else                     return message.list (1..message.length);
   end if;
 end image;


 procedure in_place_lower_case (message: in out variable_strings) is
 begin
   is_okay (message);
   for i in 1..message.length loop
     message.list(i) := string_control.lower_case (message.list(i));
   end loop;
 end in_place_lower_case;

 procedure in_place_truncate (message: in out variable_strings;
                              ch: character := ' ') is
 begin
   is_okay (message);
   loop
     exit when message.length = 0;
     exit when message.list (message.length) /= ch;
     message.length := message.length - 1;
   end loop;
 end in_place_truncate;

 procedure in_place_upper_case (message: in out variable_strings) is
 begin
   is_okay (message);
   for i in 1..message.length loop
     message.list(i) := string_control.upper_case (message.list(i));
   end loop;
 end in_place_upper_case;

 function length (message: variable_strings) return natural is
 begin
   is_okay (message);
   return message.length;
 end length;

 function length_allocated (message: variable_strings) return natural is
 begin
   return message.size;
 end length_allocated;

 function same (left, right: variable_strings) return boolean is
 begin
   is_okay (left);
   is_okay(right);
   return left.length=right.length and then
          left.list(1..left.length) = right.list(1..left.length);
 end same;

 function same   (left: variable_strings; right: string) return boolean is
 begin
   is_okay (left);
   return left.length=right'length and then
          left.list(1..left.length) = right;
 end same;

 procedure set_element (message: in out variable_strings;
                        col: natural;
                        value: character) is
   varstring_set_element_index_out_of_range: exception;
   varstring_set_element_index_way_out_of_range: exception;
 begin
   is_okay (message);
   if    col > message.size then
     raise varstring_set_element_index_way_out_of_range;
   elsif col = message.length+1 then
     message.length     := message.length + 1;
     message.list (col) := value;
   elsif col > message.length then
     raise varstring_set_element_index_out_of_range;
   else
     message.list (col) := value;
   end if;
 end set_element;

 procedure set_length (message: in out variable_strings;
                       new_length: natural) is
   hold_length: integer := message.length;
   varstring_set_length_too_long: exception;
 begin
   if hold_length > message.size then
     raise varstring_set_length_too_long;
   end if;
   message.length := new_length;
   if hold_length < 0 then
     for i in 1..message.size loop
       message.list (i) := ' ';
     end loop;
   end if;
   if    hold_length > 0 then
     for i in hold_length+1 .. new_length loop
       message.list (i) := ' ';
     end loop;
   end if;
 end set_length;

 function slice (message: variable_strings;
                 start, finish: natural) return string is
   varstring_slice_start_out_of_range: exception;
   varstring_slice_finish_out_of_range: exception;
 begin
   is_okay (message);
   if    start not in 1..message.length then
     raise varstring_slice_start_out_of_range;
   elsif finish not in 0..message.length then
     raise varstring_slice_finish_out_of_range;
   end if;
   if finish < start then
     return "";
   else
     declare
       hold: constant string (1..finish+1-start) :=
                        message.list(start..finish);
     begin
       return hold;
     end;
   end if;
 end slice;

 function substr (message: variable_strings;
                  start, length: natural) return string is
 begin
   is_okay (message);
   return slice (message, start, start+length-1);
 end substr;

 function substr (message: variable_strings;
                  start: natural)
                  return string is
 begin
   is_okay (message);
   return slice (message, start, message.length);
 end substr;

end variable_string_control;
with system;
package hand is
  pragma elaborate_body;

  --  Purpose:
  --
  --    Provide OS binding to file open, read, write, position, close
  --
  --  Warning: To compute the system.address do this: message(1)'address
  --
  --
  --  Architecture:
  --
  --     ADO (Abstract Data Object)
  --     SIS (Semantically Independent Specification)

  type handles is range -1..32;
  for handles'size use 16;

  null_handle:     constant handles := 0;
  broken_handle:   constant handles := -1; -- File does not exist.
  standard_input:  constant handles := 0;
  standard_output: constant handles := 1;
  standard_error:  constant handles := 2;

  type    open_methods   is (read_open, write_open, append_open);
  type    seek_methods   is (from_BOF, from_current, from_EOF);
  type    file_positions is range -2147483648 .. 2147483647;
  subtype string_8       is string (1..8);
  subtype string_12      is string (1..12);

  already_internally_open:      exception;
  could_not_check:              exception;
  could_not_create:             exception;
  could_not_open:               exception;
  could_not_read:               exception;
  could_not_reposition:         exception;
  could_not_seek:               exception;
  missing_slash_at_end_of_path: exception;

  procedure close         (handle: handles);
  procedure commit        (handle: handles);
  function  create        (name:   string)
                           return handles;
  procedure create_unique (path: string;
                           name:   out string;
                           handle: out handles);
  function  image         (handle: handles)
                           return string;
  function  is_standard_input (handle: handles)
                           return boolean;
  function  is_standard_output (handle: handles)
                           return boolean;
  function  open          (name: string;
                           open_method: open_methods)
                           return handles;
  function  position      (handle: handles)
                           return file_positions;
  procedure read          (whereto: system.address;
                           length: in out file_positions;
                           handle: handles);
  function  seek          (handle: handles;
                           position: file_positions;
                           seek_method: seek_methods)
                           return file_positions;
  function  size          (handle: handles)
                           return file_positions;
  procedure write         (whereto: system.address;
                           length:  in out file_positions;
                           handle:  handles);
end hand;


with Ada.IO_exceptions;
with Ada.streams.stream_io;
with Ada.text_io.text_streams;
with variable_string_control;
package body hand is
  -- compiler_this_package_is_dependent_on: constant string := "any Ada 95";
  use Ada.streams.stream_io;

  directory_separator: constant character := '\'; -- change to '/' for Linux

  type unique_counts is mod 4;
  unique_count: unique_counts := 0;

  -- Streams

  type selfs is record
    soul:       file_type;
    incarnated: boolean:=false;
  end record;

  subtype usable_handles is handles range 3 .. handles'last;
  type universes is array (usable_handles) of selfs;
  self: universes;
  handle_is_not_incarnated: exception;

  procedure check (handle: handles; message: string) is
  begin
    if handle in usable_handles then
      if not self (handle).incarnated then
        raise handle_is_not_incarnated;
      end if;
    end if;
  end check;

  function stream (handle: handles) return stream_access is
    broken_handle_detected: exception;
  begin
    case handle is
      when standard_input=>
        return Ada.streams.stream_io.stream_access(
          Ada.text_io.text_streams.stream(Ada.text_io.standard_input));
      when standard_output=>
        return Ada.streams.stream_io.stream_access(
          Ada.text_io.text_streams.stream(Ada.text_io.standard_output));
      when standard_error =>
        return Ada.streams.stream_io.stream_access(
          Ada.text_io.text_streams.stream(Ada.text_io.standard_error));
      when broken_handle=>
        raise broken_handle_detected;
      when usable_handles=>
        return stream (self (handle).soul);
    end case;
  end stream;

  function available return handles is
  begin
    for handle in usable_handles loop
      if not self (handle).incarnated then
        self (handle).incarnated := true;
        return handle;
      end if;
    end loop;
    raise could_not_create;
  end available;

  procedure commit (handle: handles) is
  begin
    check (handle, "commit");
    if handle in usable_handles then
      flush (self (handle).soul);
    else
      null;
    end if;
  end commit;

  procedure close (handle: handles) is
  begin
    if handle in usable_handles then
        -- Handle is not checked, so failed-open handles can be closed.
      if self (handle).incarnated then
        close (self (handle).soul);
        self (handle).incarnated := false;
      end if;
    end if;
  exception
    when Ada.IO_exceptions.status_error =>
      self (handle).incarnated := false;
  end close;

  function image (handle: handles) return string is
  begin
    return handles'image (handle);
  end image;

  function is_standard_input (handle: handles) return boolean is
  begin
    return handle=standard_input;
  end is_standard_input;

  function is_standard_output (handle: handles) return boolean is
  begin
    return handle=standard_output;
  end is_standard_output;

  function create (name: string) return handles is
    handle: handles;
    could_neither_create_it_nor_open_it_for_output: exception;
    use variable_string_control;
  begin
    if name'length=0 then
      handle := standard_output;
    else
      handle := available;
      create (self (handle).soul, out_file, name);
    end if;
    return handle;
  exception
    when Ada.IO_exceptions.name_error =>
      open (self (handle).soul, out_file, name);
      return handle;
    when Ada.IO_exceptions.use_error =>
      begin
        open (self (handle).soul, out_file, name);
        return handle;
      exception
        when Ada.IO_exceptions.use_error =>
          raise could_neither_create_it_nor_open_it_for_output;
          return broken_handle;
      end;
  end create;

  procedure create_unique (path: string;
                           name: out string;
                           handle: out handles) is

    unique_image: string:=unique_counts'image(unique_count);
    random_string: constant string := "tempxxx" &
        unique_image(unique_image'first + 1) & ".tmp";  -- 9 only ?
    -- random_string: constant string := "tempxxxx.tmp";
    full_path: string := path & random_string;

  begin
    unique_count := unique_count + 1;
    if path'length /= 0 and then
       path (path'last) /= directory_separator then
      raise missing_slash_at_end_of_path;
    end if;
    handle := create (full_path);
    name   := full_path (path'length+1 .. path'length+random_string'length);
  end create_unique;

  function open (name: string;
                 open_method: open_methods)
                 return handles is

    handle:        handles;
    file_position: file_positions := 0;
    use variable_string_control;
  begin
    if name'length=0 then
      case open_method is
        when read_open =>
          handle := standard_input;
        when write_open =>
          handle := standard_output;
        when append_open=>
          handle := standard_output;
      end case;
    else
      handle := available;
      case open_method is
        when read_open =>
          open (self (handle).soul, in_file, name);
        when write_open =>
          open (self (handle).soul, out_file, name);
        when append_open=>
          open (self (handle).soul, append_file, name);
          file_position := seek (handle, 0, from_EOF);
          -- redundant because of bug in gnat 3.10. Needed in gnat3.11?
      end case;
    end if;
    return handle;
  exception
    when Ada.IO_exceptions.name_error =>
      self (handle).incarnated := false;
      return broken_handle;
  end open;

  function position (handle: handles) return file_positions is
    standard_handles_cannot_be_positioned: exception;
  begin
    check (handle, "position");
    if handle not in usable_handles then
      raise standard_handles_cannot_be_positioned;
    end if;
    return file_positions (index (self(handle).soul)) - 1;
  end position;

  procedure read (whereto: system.address;
                  length: in out file_positions;
                  handle: handles) is

    use Ada.streams;
    subtype buffers is stream_element_array(1..stream_element_offset(length));
    buffer: buffers;
    for buffer use at whereto;
    seo: stream_element_offset:=stream_element_offset(length);
  begin
    check (handle, "read");
    read(stream (handle).all, buffer, seo);
    length:=file_positions(seo);
  end read;

  function is_keyboard_device (handle: handles) return boolean is
  begin
    return false; --?
  end is_keyboard_device;

  function seek (handle: handles;
                 position: file_positions;
                 seek_method: seek_methods)
                 return file_positions is

    cannot_seek_standard_handles: exception;
    p: constant file_positions := position + 1;
    here: constant file_positions := hand.position (handle);
  begin
    check (handle, "seek");
    if handle in usable_handles then
      declare
        file: file_type renames self(handle).soul;
      begin
        case seek_method is
          when from_BOF=>
            set_index (file, positive_count (p));
          when from_EOF=>
            set_index (file, positive_count (file_positions(size(file)) + p));
          when from_current=>
            set_index (file, positive_count (here + P));
        end case;
        return file_positions(index (file))-1;
      end;
    else
      raise cannot_seek_standard_handles;
    end if;
  end seek;

  function size (handle: handles) return file_positions is
    my_size: count;
    signed_size: file_positions;
  begin
    check (handle, "size");
    if handle in usable_handles then
      my_size := size (self (handle).soul);
      signed_size := file_positions(my_size);
      return signed_size;
    else
      return 0;
    end if;
  end size;

  procedure write (whereto: system.address;
                   length:  in out file_positions;
                   handle:  handles) is
    use Ada.streams;
    subtype buffers is stream_element_array(1..stream_element_offset(length));
    buffer: buffers;
    for buffer use at whereto;
  begin
    check (handle, "write");
    write (stream (handle).all, buffer);
  end write;

end hand;

-------------------------------------------------------------------------------





^ permalink raw reply	[relevance 2%]

* problem with the compilation of gnat 3.10p
@ 1998-09-09  0:00  4% grave
  0 siblings, 0 replies; 195+ results
From: grave @ 1998-09-09  0:00 UTC (permalink / raw)


Hi,

I have built with gnat-3.10p-sparc-sun-solaris2.5.1-bin gnat3.10p with
two version of gcc
gcc 2.7.2 and gcc 2.8.1 on a sparc with solaris 2.6

With the first one I don't have any problem but with the second one I
have the following problem :
the example text_io_example in directory gnat3.10p-src/examples
compile but give the following exception :
ADA.IO_EXCEPTIONS.DATA_ERROR

and the diners example doesn't start, i.e I can compile it but nothing
more.

There is a patch in gnat3.10-src/src for the version 2.7.2 of gcc but
not for the 2.8.1 version does the problem come from this ?

any help will be welcome.

xavier




^ permalink raw reply	[relevance 4%]

* Re: Size of 0..255 is not 8 bits?
  @ 1998-05-14  0:00  6%       ` Robert Dewar
  0 siblings, 0 replies; 195+ results
From: Robert Dewar @ 1998-05-14  0:00 UTC (permalink / raw)



Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk> wrote:

>Other question: If the rest of a stream is too short for a
>T'Read to succeed, what is supposed to happen? Constraint error?


Quoting the GNAT sources ... (s-stratt.adb)

   Err : exception renames Ada.IO_Exceptions.End_Error;
   --  Exception raised if insufficient data read (note that the RM implies
   --  that Data_Error might be the appropriate choice, but AI195-00132
   --  decides with a binding interpretation that End_Error is preferred).

Note that it is a little odd that streams (which have nothing to do with
IO) should raise an exception in Ada.IO_Exceptions, but the AI is clear
as to the preference for this.





^ permalink raw reply	[relevance 6%]

* Re: Dynamic Instantiation in Ada95 ?
  @ 1998-04-16  0:00  5%   ` Matthew Heaney
  0 siblings, 0 replies; 195+ results
From: Matthew Heaney @ 1998-04-16  0:00 UTC (permalink / raw)



In article <353625E8.3809@gsfc.nasa.gov>, Stephen.Leake@gsfc.nasa.gov wrote:

>with System.Address_To_Access_Conversions;
>with Ada.Streams; use Ada.Streams;
>package SAL.Memory_Streams is
>   pragma Preelaborate;
>
>   -- we can't use IO_Exceptions, because that package doesn't have
>Preelaborate.

It doesn't have Preelaborate, because it's Pure.  So you can legally with
package Ada.IO_Exceptions.

>   Status_Error : exception;
>   End_Error : exception;




^ permalink raw reply	[relevance 5%]

* GNAT exception traceback
@ 1997-06-11  0:00  4% Steve Gibson
  0 siblings, 0 replies; 195+ results
From: Steve Gibson @ 1997-06-11  0:00 UTC (permalink / raw)



I have a question regarding exception tracing under the GNAT Ada95
compiler.

Running GNAT 3.05 on DOS 6.x and GNAT 3.07 on Solaris 2.5.1. On both
platforms, when an exception is raised and propagated to the top level
procedure ("main") and not caught, the code generated by the GNAT
compiler, correctly, reports "raised ADA.IO_EXCEPTIONS.DEVICE_ERROR" for
instance.
My question is, without running gdb or adding additional exception
handlers, is it possible to generate traceback information to determine
which line of code in which package generated the exception, and if so
how ?

For example:
    CONSTRAINT_ERROR exception raised in package XXX line i
    CONSTRAINT_ERROR exception propagated out of package YYY line j
    CONSTRAINT_ERROR exception propagated out of package Main line k

Thanks for any help.  

-- 
Steve Gibson
ADI Limited, CCIS Systems Group 
Email: gibson@ccis.adisys.com.au
Snail: 22 Stirling Hwy
       Nedlands
       Western Australia
Nbrs : (tel) +61 9 333 8917    (fax) +61 9 333 8889




^ permalink raw reply	[relevance 4%]

* Is there an integer in "0: abc"?
@ 1997-04-17  0:00  4% Bob Collins
  0 siblings, 0 replies; 195+ results
From: Bob Collins @ 1997-04-17  0:00 UTC (permalink / raw)



I get Data_Error when I try to "Get" a number from
the string "0: abc" and "1: abc" but not "2: abc".
I assume (Annex J) that the colon is substituting for
the sharp symbol # used in a based integer, and,
of course, 0 and 1 can't be bases. But there is no
corresponding closing : anywhere. Have I run afoul
of some basic Ada rules? Or is this an error in my
favorite Macintosh Ada compiler? (BTW, I always get
an error for "2:abc", and this behavior is also
present when "Get"ting from files.)

Here's a code example:

   with Ada.Integer_Text_IO, Ada.Text_IO;
   use  Ada.Integer_Text_IO, Ada.Text_IO;
   procedure Test is
      Last   : Natural;
      Number : Integer;
   begin
      Get ("2: abc", Number, Last);
      Put (Number); New_Line;
      Get ("1: abc", Number, Last);
      Put (Number); New_Line;
   exception
      when Data_Error =>
         Put_Line ("Data_Error raised.");
         Get ("0: abc", Number, Last);
         Put (Number); New_Line;
   end Test;

Here is what happens:

   ny > gnatmake -v test

   GNATMAKE 3.09 (970121) Copyright 1995 Free Software Foundation, Inc.
     "test.ali" being checked ...
     -> "test.ali" missing.
   gcc -c test.adb
   gnatbind -x test.ali
   gnatlink test.ali
   ny > test
             2
   Data_Error raised.

   raised ADA.IO_EXCEPTIONS.DATA_ERROR

                         Bob Collins, collins@cs.wm.edu




^ permalink raw reply	[relevance 4%]

* Ada vs C++ for numeric IO (integers)
@ 1996-07-22  0:00  2% Nasser Abbasi
  0 siblings, 0 replies; 195+ results
From: Nasser Abbasi @ 1996-07-22  0:00 UTC (permalink / raw)




hi,

I was playing with integer IO to see how C++ and Ada handle it.
I noticed couple of things, I show the Ada and the C++ examples, 
and have a question on each language. 

I post this in one article just to show the difference between the 2 cases,
and may be have a discussion on how each langauge approaches this area.

Ada case:
========
I noticed that constraint error is not raised for short_integer if 
I input a value outside short_integer range in an IO operation for 
example. I check the LRM, and it does say that in 3.5.4.20 .

But this kind'a made me think this is not too nice, as I expected 
an exception to be raised from Ada.

Any thought on this, why does not a derived type inherit a new
constraint range for its new type range? Now this means one have 
to figure a way to check for this case themselves instead of letting the
run-time do it.

for example:

with Ada.Text_Io; use Ada.Text_Io;
procedure Main is
 package Short_Io is new Ada.Text_Io.Integer_Io(Short_Integer); use Short_Io;
 I: Short_Integer;

begin
   loop
      Put("i ? ");
      Get(I);
      Put("you typed: "); Put(I);
      New_line;
   end loop;
end Main;

and runnning the above program:


i ? 32768   <--- I typed this expecting to get constraint error
you typed: -32768  <-- it did not! , it wrapped around instead !
i ? 2147483648 <-- now, typed in value outside range of BASE type

raised ADA.IO_EXCEPTIONS.DATA_ERROR <--- now we get the constraint error


C++ case
========

C++ does not raise exceptions here, at least not with the
compiler I am using now.

Behaviour is The same with Ada for values outside range of 
-32768..32767, actually the same for range (-2147483647-1) ..2147483647 ,
i.e. no error is detected for short int IO, if one type a value larger
than 32767 it wrappes around.  But in C++, If I type in a value
larger than 2147483647, say 2147483648, it still wrappes (moves -1 
to my variable), and the cin stream is still in good state, while in 
Ada a constraint error is raised here.

Example:


#include <iostream.h>
#include <limits.h>

main()
{

short int i;

cin.unsetf(ios::skipws);

for(;;)
  {
   cout<<"Enter i and hit return: "<<flush;

   for(;;)
   {
     cin>>i;
     if( cin )
     {
        cin.ignore(INT_MAX,'\n');
        cout<<endl<<"input was good. you typed "<<i<<endl;
        break;
     }
     cin.clear();   // clear error state
     cin.ignore(INT_MAX,'\n');
     cout<<"error in read, try again"<<flush;
   }
  }
   return 0;
}


running the above program:

Enter i and hit return: 32768   <--- larger than SHRT_MAX
input was good. you typed -32768  <--- wrapped around

Enter i and hit return: 2147483647 

input was good. you typed -1

Enter i and hit return: 2147483648 <--- larger than INT_MAX
input was good. you typed 0 <--- wrapped around

Enter i and hit return: 2147483649 
input was good. you typed 1

Enter i and hit return: 999999999999999999999999999999999999999999999999
input was good. you typed -1  <--- oh well, cin still is good !
                                   but I think something went wrong, -1
                                   looks weired value

Well, I guess I don't understand integer IO much in C++, I could not
figure a way how to detect overflow input in this example. Does any
one know the best way to handle integer IO in C++ so that if someone
types in a value larger than MAX_INT for example, it will be
detected? I did check for cin.bad() and cin.fail() also, but those
passed the test. 


thanks,
Nasser
-- 
Nasser Abbasi. C/C++/Ada Solaris. GeneAssist - A client/server application 
for Nucleic acid and protein sequence search and analysis. 
Perkin Elmer - Applied BioSystem division. email:  nasser@apldbio.com   
MSEE(control), MSCS, MSCE, FM (Fide Chess Master).







^ permalink raw reply	[relevance 2%]

* Re: Common Error/Exception Handler
  @ 1996-04-22  0:00  3%   ` Laurent Guerby
  0 siblings, 0 replies; 195+ results
From: Laurent Guerby @ 1996-04-22  0:00 UTC (permalink / raw)


John Cupak:
: Wouldn't it be possible with the Ada 95 exception mechanisms to create a
: package of standard exceptions and a common error message procedure,
: import/rename the exceptions where appropriate, and let the common error
: message procedure take care of the details? 

Robert A Duff wrote:
: I suppose it's possible, but it doesn't seem desirable.  The abstraction
: in question ought to define what sort of things are errors, and what
: exceptions are therefore raised.  Clients can then decide how to handle
: those errors.  Why do you think this information ought to be more
: global?

John Cupak wrote:
:I was thinking that a "global error/exception handler" package would be easier
: to maintain, since *all* error definitions and messages would be in a single
: place. 
: 
: Comments?

   I don't think  you (John) are  talking about exceptions in  general
(like Bob), but about exceptions that  get propagated to the main unit
and are "user" reported as a console message or in a log file.

   In this  last case, a global  mechanism is desirable and  simple to
implement in Ada 95 as a global  error reporting package using new Ada
(95) features in this area.

   You should have a look at RM95-A.13, and see that in Ada 95, all IO
exceptions are  defined in a   single package, Ada.IO_Exceptions,  and
renamed when needed   elsewhere ;-).  In Ada   95  a message  can   be
associated to an exception occurence, see RM95-11.4.1, Ada.Exceptions.
   
-- 
--  Laurent Guerby, student at Telecom Bretagne (France), Team Ada.
--  "Use the Source, Luke. The Source will be with you, always (GPL)."
--  http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project).
--  Try GNAT, the GNU Ada 95 compiler (ftp://cs.nyu.edu/pub/gnat).




^ permalink raw reply	[relevance 3%]

Results 1-195 of 195 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
1996-04-19  0:00     Common Error/Exception Handler John Cupak
1996-04-19  0:00     ` Robert A Duff
1996-04-22  0:00  3%   ` Laurent Guerby
1996-07-22  0:00  2% Ada vs C++ for numeric IO (integers) Nasser Abbasi
1997-04-17  0:00  4% Is there an integer in "0: abc"? Bob Collins
1997-06-11  0:00  4% GNAT exception traceback Steve Gibson
1998-04-15  0:00     Dynamic Instantiation in Ada95 ? Matthias Oltmanns
1998-04-16  0:00     ` Stephen Leake
1998-04-16  0:00  5%   ` Matthew Heaney
1998-05-14  0:00     Size of 0..255 is not 8 bits? Markus Kuhn
1998-05-13  0:00     ` Matthew Heaney
1998-05-14  0:00       ` Markus Kuhn
1998-05-14  0:00         ` John McCabe
1998-05-14  0:00  6%       ` Robert Dewar
1998-09-09  0:00  4% problem with the compilation of gnat 3.10p grave
1998-09-24  0:00     Image processing File I/O Jeong, Laehyung
1998-09-24  0:00     ` Dale Stanbrough
1998-09-24  0:00  2%   ` Michael F Brenner
1998-11-09  0:00  4% One for the Apex guys Roga Danar
1998-12-01  0:00  5% egcs1.1b and gnat3.10p grave
1998-12-02  0:00  0% ` Juergen Pfeifer
1999-02-14  0:00     Stream_io / records with default discriminants Bernd Ragutt
1999-02-14  0:00     ` Matthew Heaney
1999-02-14  0:00  4%   ` Bernd Ragutt
1999-03-26  0:00     Temporary files in Ada95 robert_dewar
1999-03-25  0:00     ` jboulais
1999-03-26  0:00       ` Boulais, Jeffrey M
1999-03-26  0:00         ` Jeffrey D. Cherry
1999-03-26  0:00           ` Larry Kilgallen
1999-03-29  0:00  4%         ` Jeffrey D. Cherry
1999-06-12  0:00  3% Ada and Java. different behaviour. casting long to int problem nabbasi
1999-06-12  0:00  0% ` nabbasi
1999-11-03  0:00     Safely converting String to Float ? Preben Randhol
1999-11-03  0:00  4% ` Robert Dewar
1999-11-03  0:00  4%   ` Preben Randhol
1999-11-03  0:00  4% ` Robert Dewar
1999-11-30  0:00     Help ... CONSTRAINT_ERROR jxredi
1999-12-02  0:00  4% ` Stephen Leake
2000-01-06  0:00     Number into String Jeong, Lae Hyung
2000-01-06  0:00     ` Jeong, Lae Hyung
2000-01-06  0:00       ` reason67
2000-01-06  0:00         ` Robert Dewar
2000-01-06  0:00  5%       ` reason67
2000-03-06  0:00  2% Exception handling problem Amun-Ra
2000-11-18  0:00  4% input/output exceptions Jean Cohen
2000-11-22  6:07     Automatic issue of carriage return mountainman
2000-11-22  0:00  3% ` Egil Harald Hoevik
2000-11-25  0:00     Possible gnat and ObjectAda bugs? David C. Hoos, Sr.
2000-11-26  0:00  6% ` Preben Randhol
2001-03-13  0:35     text_io is not a predefined library Andrew Busolin
2001-03-13  4:54     ` DuckE
2001-03-13 10:47  6%   ` David C. Hoos, Sr.
2001-04-21  3:21     Positive Floating Range? Dr Nancy's Sweetie
2001-05-01 20:40  4% ` Georg Bauhaus
2001-10-11 17:03  3% Questions on implementations and specs chris.danx
2001-10-11 18:31  0% ` chris.danx
2001-10-11 22:39  0%   ` chris.danx
2001-11-02  3:56     List container strawman Ted Dennison
     [not found]     ` <3BE29AF4.80804@telepath.com>
2001-11-02 13:14       ` Ted Dennison
2001-11-02 17:44         ` Jeffrey Carter
2001-11-02 20:07           ` Ted Dennison
2001-11-02 23:19             ` Jeffrey Carter
2001-11-03  6:56               ` Ted Dennison
2001-11-03 19:22                 ` Jeffrey Carter
2001-11-04 18:58                   ` Darren New
2001-11-04 19:40                     ` Larry Kilgallen
2001-11-07 19:07  4%                   ` ramatthews
2001-11-25 22:42  3% Text_IO.End_Of_File Problem Hambut
2001-11-26  1:53  0% ` Jeffrey Carter
2001-12-05  6:08     List Strawman JC01 Jeffrey Carter
2001-12-05 19:14     ` Ted Dennison
2001-12-06  0:14       ` Jeffrey Carter
2001-12-06 16:11  2%     ` Ted Dennison
2002-01-03 15:47     Problème avec des get(fichier, integer) M. A. Alves
2002-01-03 17:56  4% ` Probl�me " Nick Roberts
2002-03-14  3:29  4% Interactivity Question Casey Jones
2002-03-14  6:15  0% Christoph Grein
2002-03-14  6:24  0% ` Casey Jones
2002-03-24 23:18  4% Read booleans from streams Erik Sigra
2002-03-25  3:57  0% ` Eric G. Miller
     [not found]     <200203242318.g2ONIkc12876@a77.ib.student.liu.se>
2002-03-25  2:05  0% ` sk
     [not found]     ` <3C9E85F6.8EDF3AAD@myob.com>
2002-03-25 10:46  0%   ` Erik Sigra
2002-04-23 18:28     How to find directory where the program is? Preben Randhol
2002-04-24 15:38     ` Hyman Rosen
2002-04-24 23:08       ` Nick Roberts
2002-04-25  7:28         ` Preben Randhol
2002-04-26 12:18           ` Jacob Sparre Andersen
2002-04-26 13:09             ` Marin David Condic
2002-04-27 14:39               ` Larry Kilgallen
2002-04-27 21:12  6%             ` Nick Roberts
2002-04-27 15:16  6% Reading raw disks (Windows) Larry Hazel
2002-04-29  1:11  5% ` Steve Doiel
2002-04-29  2:06  0%   ` Larry Hazel
2002-05-20 23:09  5% Constraint error help tr4ck
2002-06-02 11:01     Exceptions in GNAT David Rasmussen
2002-06-02 11:04  6% ` David Rasmussen
2002-06-02 12:39  0%   ` Jeffrey Creem
2002-06-09 14:39  4% Output to Printer Problems Pheet
2002-06-09 15:29  4% Pheet
2002-08-14 19:34     Fill string with multiple lines from standard_input Vincent Smeets
2002-08-16 17:33  3% ` Alexei Polkhanov
2002-08-23 19:10     Thought this was interesting Darren New
2002-08-25  3:27     ` tmoran
2002-08-26 14:01       ` Marin D. Condic
2002-08-27 16:13         ` Hyman Rosen
2002-08-27 20:07  5%       ` Thought this was interesting (OT) Chad R. Meiners
2002-11-26 21:41  5% Character Sets Robert C. Leif
2002-11-27  9:00  0% Grein, Christoph
2002-11-28 17:53  3% Robert C. Leif
2002-11-28 18:08     Character Sets (plain text police report) Warren W. Gay VE3WWG
2002-11-29 20:37  3% ` Robert C. Leif
2002-12-02 19:29  0%   ` A suggestion, completely unrelated to the original topic Wes Groleau
2002-12-02 23:21  0%     ` David C. Hoos, Sr.
2003-01-03 15:57     advantages or disadvantages of ADA over pascal or modula karl bowl
2003-01-04  2:56     ` Steve
2003-01-04 11:34       ` Dmitry A. Kazakov
2003-01-04 17:35         ` Steve
2003-01-05 14:12  6%       ` Dmitry A. Kazakov
2003-01-27 10:32 12% What does "raised ADA.IO_EXCEPTIONS.DATA_ERROR" mean? Fatafa
2003-01-27 13:05 10% ` Colin Paul Gloster
2003-01-27 18:33  6% ` Stephen Leake
2003-01-27 11:18  6% Grein, Christoph
2003-05-09 19:46  2% GNAT.Sockets Problems file13
2003-05-11  0:51  2% ` Craig Carey
2003-05-12 11:38  0% ` Simon Clubley
2003-05-23 23:05     Suggestion for Ada 200x - Interface inheritance Steve
2003-05-28 13:57     ` MI in Ada 200X (was: Suggestion for Ada 200x - Interface inheritance) Mário Amado Alves
2003-05-28 15:05       ` Preben Randhol
2003-05-29  9:17         ` Dmitry A. Kazakov
2003-05-30  2:50           ` MI in Ada 200X Wesley Groleau
2003-05-30  7:38             ` Dmitry A. Kazakov
2003-05-30 12:20               ` Karel Miklav
2003-05-31  9:27  7%             ` Dmitry A. Kazakov
2003-05-29 21:18  6% It's been a while Luke A. Guest
2003-05-30  2:13  0% ` Steve
2003-06-11 13:31  6% Catching a DEVICE_ERROR? Tony Danezis
2003-06-11 13:49  0% ` David C. Hoos
2003-10-14  4:05     windows ada compiler error Andrew
2003-10-14  5:19  4% ` tmoran
2003-10-14 15:29  0%   ` Andrew
2003-10-14 15:35  0%   ` Andrew
2003-10-31 21:02     Clause "with and use" Gautier Write-only
2003-11-06 13:03     ` Hyman Rosen
2003-11-06 17:26       ` Warren W. Gay VE3WWG
2003-11-06 20:38         ` Gautier Write-only
2003-11-07  8:48           ` Preben Randhol
2003-11-08 10:56             ` Gautier Write-only
2003-11-08 19:40               ` Russ
2003-11-10  7:38                 ` Preben Randhol
2003-11-10 13:03                   ` Marin David Condic
2003-11-11  7:20                     ` Russ
2003-11-11 15:36                       ` Robert I. Eachus
2003-11-11 19:46  4%                     ` Eachus' Measure of Goodness (was: Clause "with and use") Jeffrey Carter
2003-11-11 14:35     Clause "with and use" Hyman Rosen
2003-11-11 15:04     ` Preben Randhol
2003-11-11 20:01       ` Russ
2003-11-12 12:41         ` Preben Randhol
2003-11-13  6:27           ` Chad R. Meiners
2003-11-13  7:32             ` Anders Wirzenius
2003-11-13 17:51               ` Warren W. Gay VE3WWG
2003-11-14  8:32                 ` Dmitry A. Kazakov
2003-11-14 14:51                   ` Warren W. Gay VE3WWG
2003-11-17  9:22  7%                 ` Dmitry A. Kazakov
2003-11-17 16:42  0%                   ` Warren W. Gay VE3WWG
2003-11-18  8:49  0%                     ` Dmitry A. Kazakov
2003-11-19 17:46  0%                       ` Warren W. Gay VE3WWG
2003-11-20  8:26  0%                         ` Dmitry A. Kazakov
2004-02-28 18:31     Error-names Martin Klaiber
2004-02-28 19:47  6% ` Error-names tmoran
2004-02-29 19:03  0%   ` Error-names Jeffrey Carter
2004-02-29 20:33  0%     ` Error-names Martin Klaiber
2004-02-29 23:43  4%       ` Error-names tmoran
2004-03-01 11:20  0%         ` Error-names Martin Klaiber
2004-05-04  3:20     Manifesto against Vector Alexander E. Kopilovich
2004-05-04 17:16     ` Jeffrey Carter
2004-05-04 18:24       ` Marius Amado Alves
2004-05-05  5:28         ` Russ
2004-05-05 17:37           ` Martin Dowie
2004-05-06  3:42             ` Russ
2004-05-06  7:03               ` Jean-Pierre Rosen
2004-05-06  9:29                 ` Dmitry A. Kazakov
2004-05-06  9:41                   ` Vinzent 'Gadget' Hoefler
2004-05-06 12:44  6%                 ` Dmitry A. Kazakov
2004-05-06 13:30  0%                   ` Vinzent 'Gadget' Hoefler
2004-05-07  8:23  0%                     ` Dmitry A. Kazakov
2004-05-07 12:38                           ` Vinzent 'Gadget' Hoefler
2004-05-09 20:34  3%                         ` Dmitry A. Kazakov
2004-05-10  8:26                               ` Vinzent 'Gadget' Hoefler
2004-05-10 12:13  6%                             ` Dmitry A. Kazakov
2005-04-13 15:07     Using GNAT.Sockets markwork66
2005-04-13 15:43     ` Duncan Sands
2005-04-15  9:04       ` markp
2005-04-15  9:25         ` Duncan Sands
2005-04-18  9:01           ` markp
2005-04-18 13:23             ` Michael Paus
2005-04-18 14:32               ` markp
2005-04-18 15:14                 ` Adrien Plisson
2005-04-18 15:35                   ` markp
2005-04-18 15:48                     ` Adrien Plisson
2005-04-18 17:06                       ` markp
2005-04-18 18:23  5%                     ` markp
2005-05-23 10:48     gnat: symbolic traceback on exceptions Manuel Collado
2005-05-23 18:20     ` Bernd Specht
2005-05-24 11:05  4%   ` Manuel Collado
2005-05-27 15:00  3% ASIS and gnatelim : Will I make it work ? J�r�me Haguet
2005-05-27 15:05  0% ` Ludovic Brenta
2005-06-07  6:01  4% Ada call from vc++ Matthias
2005-06-07 16:41  0% ` James Alan Farrell
2005-06-07 20:45  0% ` Björn Persson
2005-11-04 15:25     Advice on abort REH
2005-11-04 18:21     ` Dmitry A. Kazakov
2005-11-05 18:33  4%   ` Simon Wright
2005-11-05 21:23  0%     ` REH
2006-07-13 17:38  5% Ada.Directories and multibyte-filename Y.Tomino
2007-01-15 13:44     Structured exception information Maciej Sobczak
2007-01-16 13:30     ` Stephen Leake
2007-01-16 14:33       ` Maciej Sobczak
2007-01-17 12:10         ` Stephen Leake
2007-01-17 14:05           ` Maciej Sobczak
2007-01-19  9:47             ` Stephen Leake
2007-01-19 13:36               ` Maciej Sobczak
2007-01-20 15:33                 ` Stephen Leake
2007-01-22  9:28                   ` Maciej Sobczak
2007-01-23  9:46                     ` Stephen Leake
2007-01-23 14:18                       ` Maciej Sobczak
2007-01-25  2:32                         ` Stephen Leake
2007-01-25  8:53                           ` Maciej Sobczak
2007-01-26  9:35                             ` Stephen Leake
2007-01-26 13:46                               ` Georg Bauhaus
2007-01-27 18:17                                 ` Stephen Leake
2007-01-28 12:39  5%                               ` Simon Wright
2007-04-02  6:13     STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW andrew.carroll
2007-04-02 10:10     ` Stephen Leake
2007-04-02 14:11  4%   ` andrew.carroll
2008-02-19 14:02     GNAT Project Manager and DLLs marcelo.batera
2008-02-19 21:16     ` Simon Wright
2008-02-19 22:59       ` marcelo.batera
2008-02-20 20:38         ` Simon Wright
2008-02-21 18:10  5%       ` marcelo.batera
2008-04-19 11:27     Shared library in Ada Sebastien
2008-04-19 11:52     ` Ludovic Brenta
2008-04-19 11:55       ` Sebastien
2008-04-19 12:47  4%     ` Sebastien
2008-06-11 18:21     GNAT GPL 2008 is out qunying
2008-06-12 14:31  5% ` Maxim Reznik
2008-06-12 16:33  0%   ` qunying
2008-06-12 23:43  0%     ` Anh Vo
2008-06-13 11:39  0%       ` Anh Vo
2009-05-05 23:42  4% GNAT Ada.Directories implementation and Windows file name Hibou57 (Yannick Duchêne)
2009-05-25 19:13  4% Large files on 32 and 64 bits ystem Olivier Scalbert
2009-05-25 23:23  0% ` Ludovic Brenta
2009-05-26  0:49  0% ` anon
2009-08-01 12:21     Ada Shootout program for K-Nucleotide (patches) Georg Bauhaus
2009-08-01 15:21     ` Ludovic Brenta
2009-08-03  8:56       ` Jacob Sparre Andersen
2009-08-03 11:43         ` Georg Bauhaus
2009-08-03 12:36           ` Jacob Sparre Andersen
2009-08-03 18:31             ` Isaac Gouy
2009-08-03 20:29               ` Robert A Duff
2009-08-04 15:43                 ` Isaac Gouy
2009-08-04 16:06                   ` Isaac Gouy
2009-08-04 17:08                     ` Georg Bauhaus
2009-08-05 15:58                       ` Isaac Gouy
2009-08-05 21:18 14%                     ` Georg Bauhaus
2009-08-05 22:04  0%                       ` Ludovic Brenta
2009-08-05 22:31  0%                         ` Georg Bauhaus
2009-08-06  7:51  0%                           ` Dmitry A. Kazakov
2010-01-04 13:40     Atomic file creation vlc
2010-01-04 14:24  6% ` vlc
2010-01-05  4:16  0%   ` Stephen Leake
2010-07-17 10:43  4% Ada.Directories and network shares Dmitry A. Kazakov
2010-08-01 12:17     S-expression I/O in Ada Natacha Kerensikova
2010-08-01 16:01     ` Ludovic Brenta
2010-08-09 18:49       ` Ludovic Brenta
2010-08-09 19:59         ` Natacha Kerensikova
2010-08-10 15:48           ` Ludovic Brenta
2010-08-10 15:59             ` Georg Bauhaus
2010-08-12  7:53  3%           ` Ludovic Brenta
2010-08-12 20:22  0%             ` Ludovic Brenta
2010-08-20 23:23     Binary opperations under Ada? Trogdor
2010-08-28 20:14  6% ` Gerd
2010-12-27 18:26     An Example for Ada.Execution_Time anon
2010-12-28  2:31     ` BrianG
2010-12-29  3:10  4%   ` Randy Brukardt
2010-12-30 23:51  3%     ` BrianG
2011-01-01  0:07  0%       ` Randy Brukardt
2011-01-20 20:21     problems with interfacing c Stoik
2011-01-20 20:56     ` Dmitry A. Kazakov
2011-01-28  0:39       ` Stoik
2011-01-28  9:41  5%     ` Ludovic Brenta
2011-10-14 14:19  3% xmlada validate schema trickery björn lundin
2011-11-03  8:52  6% How does Ada.Text_IO.Enumeration_IO work? Jerry
2011-11-03 14:52  0% ` Adam Beneschan
2011-11-04 22:46  0%   ` Jerry
2012-01-12 22:41  3% Data_Error and Enumeration_IO John McCormick
2013-01-29  1:24     When is a rename not a rename? Adam Beneschan
2013-02-01 10:44     ` Ada novice
2013-02-01 11:27  6%   ` Dmitry A. Kazakov
2013-07-07 18:37     GCC 4.8.1 for Mac OS X Simon Wright
2013-07-17 19:57     ` Felix Krause
2013-07-17 21:00  3%   ` Simon Wright
2013-12-07 12:24     Will Ada-95 Programs Written in MS Windows Run in MacOS and Linux Without Some Tweaking Austin Obyrne
2013-12-07 13:16     ` Simon Wright
2013-12-07 14:01       ` Austin Obyrne
2013-12-07 17:18  4%     ` Simon Wright
2013-12-07 18:26  0%       ` Austin Obyrne
2013-12-08 17:17  3%         ` Simon Wright
2013-12-08 18:44  0%           ` Austin Obyrne
2013-12-10  6:37               ` Randy Brukardt
2013-12-11  0:34  3%             ` Simon Wright
2013-12-11  1:01  6%               ` Jeffrey Carter
2013-12-11  8:38  0%                 ` Simon Wright
2013-12-11 17:07  0%                   ` Simon Wright
2013-12-07 22:49  0%       ` Austin Obyrne
2014-03-04  9:46     Reading data from file Laurent
2014-03-04 18:08     ` Mike H
2014-03-04 21:27  3%   ` Laurent
2014-03-04 21:42  0%     ` Niklas Holsti
2014-03-05 13:59         ` Mike H
2014-03-05 20:33           ` Laurent
2014-03-05 21:00             ` Jeffrey Carter
2014-03-05 21:13               ` Laurent
2014-03-05 21:25                 ` Niklas Holsti
2014-03-05 21:56                   ` Laurent
2014-03-06  8:35                     ` Dmitry A. Kazakov
2014-03-07 21:55  4%                   ` Laurent
2014-03-08  6:56  0%                     ` Dmitry A. Kazakov
2015-04-06 17:27  4% ANN: STM32F4 GNAT Run Time Systems 20150406 Simon Wright
2015-07-17 15:47  5% Error "exception not permitted here" when putting EXCEPTION in a loop Trish Cayetano
2015-07-17 15:58  0% ` G.B.
2015-07-18  8:14  5%   ` Trish Cayetano
2015-07-18 10:08         ` Björn Lundin
2015-07-18 12:41  6%       ` Trish Cayetano
2015-07-18 13:56             ` Björn Lundin
2015-07-18 14:32  6%           ` Trish Cayetano
2015-07-18 14:59  6%             ` Björn Lundin
2015-07-17 16:02  0% ` Björn Lundin
2015-10-28 17:31     Create in a root directory (Linux) comicfanzine
2015-10-28 20:12     ` Simon Wright
2015-10-28 23:01       ` Paul Rubin
2015-10-29  6:41  5%     ` comicfanzine
2015-10-29  6:50  4%     ` comicfanzine
2016-01-06 15:55     Re-write a file in Ada comicfanzine
2016-01-10 16:54  5% ` comicfanzine
2016-01-10 18:59  0%   ` Björn Lundin
2016-01-11 17:16  0%   ` Brian Drummond
2016-01-18 15:05  0%     ` gautier_niouzes
2016-01-19 12:24  0%       ` Brian Drummond
2016-01-19  5:11     End of a file comicfanzine
2016-01-19  7:20  5% ` comicfanzine
2016-02-07 22:45  4% ANN: Cortex GNAT RTS 20160207 Simon Wright
2016-02-08  4:50     Line-Terminator-Independent Text I/O (Mostly) PragmAda Software Engineering
2016-02-14 17:39  4% ` comicfanzine
2016-02-14 18:20  0%   ` Jeffrey R. Carter
2016-02-14 21:14  0%   ` PragmAda Software Engineering
2016-03-14 17:42  4% ANN: Cortex GNAT RTS 20160314 Simon Wright
2016-05-22 14:20  3% ANN: Cortex GNAT RTS 20160522 Simon Wright
2016-07-27 16:28  6% ADA.IO_EXCEPTIONS.USE_ERROR thrown by Ada.Directories.More_Entries WBull
2016-07-28 11:07  7% ` AdaMagica
2017-04-26  7:38  4% Weird Bug in Get_Line Brian Kolden
2017-04-26  8:28  0% ` Brian Drummond
2017-04-26 10:58  0% ` Simon Wright
2017-04-26 17:03  0% ` Jeffrey R. Carter
2017-10-21  2:05  4% Finding the end of a stream from a socket Andrew Shvets
2017-10-21  8:44  0% ` Dmitry A. Kazakov
2017-10-21 13:45  4%   ` Andrew Shvets
2017-10-21 18:11  0%     ` Dennis Lee Bieber
2017-10-21 17:34  0%   ` Andrew Shvets
2017-10-21 19:18  0%     ` Andrew Shvets
2018-03-01  0:27     CONSTRAINT ERROR? access check failed Mehdi Saada
2018-03-01  8:07     ` Niklas Holsti
2018-03-01 14:06       ` Mehdi Saada
2018-03-01 14:31  4%     ` Mehdi Saada
2018-05-26 21:43     Strings with discriminated records NiGHTS
2018-05-27 17:11     ` NiGHTS
2018-05-27 18:25       ` Dmitry A. Kazakov
2018-05-27 22:44         ` NiGHTS
2018-05-28  7:42           ` Simon Wright
2018-05-28 18:38             ` Shark8
2018-05-28 21:15               ` Mehdi Saada
2018-05-28 21:48                 ` Shark8
2018-05-28 22:27                   ` Mehdi Saada
2018-05-29  7:49                     ` Dmitry A. Kazakov
2018-05-29 13:40                       ` Dan'l Miller
2018-05-29 14:04  4%                     ` Dmitry A. Kazakov
2018-05-29 22:41  0%                       ` Randy Brukardt
2018-05-30  5:00  6%                         ` J-P. Rosen
2018-05-30 20:09  0%                           ` Randy Brukardt
2018-12-14 17:50     gnatcol json vs network read Stephen Leake
2018-12-14 21:58     ` Per Sandberg
2018-12-15  9:41  5%   ` Stephen Leake
2022-04-05 16:26     Ada_GUI AdaMagica
2022-04-05 19:30     ` Ada_GUI Jeffrey R.Carter
2022-04-06  7:21       ` Ada_GUI Jeffrey R.Carter
2022-04-06 15:29  4%     ` Ada_GUI AdaMagica
2022-04-06 15:38  0%       ` Ada_GUI Jeffrey R.Carter
2022-10-21  0:39     components_4_64 python Test_Class Build Fails Roger Mc
2022-10-21 16:52  4% ` Simon Wright
2022-10-21 18:39  0%   ` Dmitry A. Kazakov
2023-06-30 19:28     GNAT Community 2020 (20200818-93): Big_Integer Frank Jørgen Jørgensen
2023-06-30 21:07  3% ` Dmitry A. Kazakov
2023-08-04 20:09     ALR unable to get many packages Kenneth Wolcott
2023-08-05  7:28     ` Simon Wright
2023-08-05 21:02       ` Kenneth Wolcott
2023-08-05 22:12         ` Simon Wright
2023-08-05 22:41           ` Kenneth Wolcott
2023-08-06 11:30             ` Simon Wright
2023-08-06 23:20               ` Kenneth Wolcott
2023-08-06 23:29  1%             ` Kenneth Wolcott
2023-09-22 19:30  3% Weird behavior of Get character with trailing new lines Blady
2023-09-22 19:52  0% ` Niklas Holsti
2023-12-14 23:49  5% spurious error with GNAT 13.2.0 on Intel macOS 17.2 moi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox