Skip to content

Commit 4db66cd

Browse files
committed
Use UTF8, wide characters.
1 parent 15c66e9 commit 4db66cd

17 files changed

+281
-242
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ These card types have not been implemented (yet):
9797
As a minor change, lower case can be used: `n001 42` is
9898
acceptable (it stores 42 into column 1).
9999

100-
Multiplication and division can only be indicated by the `*`
101-
and `/` symbols (× and ÷ aren't supported).
100+
As in the [Fourmilab Java implementation][], multiplication can be
101+
indicated by `*` or `×`, division by `/` or `÷`.
102102

103103
[Fourmilab Java implementation]: https://www.fourmilab.ch/babbage/cards.html
104104

aes.gpr

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ project Aes is
3737
end Builder;
3838

3939
package Compiler is
40-
Switches := ("-gnatwa");
40+
Switches := ("-gnatwa", "-gnatW8");
4141
case Opt is
4242
when "debug" =>
4343
Switches := Switches & ("-gnatqQafoy", "-O0");

bernouilli.ae

+19-18
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
A bug in operation 4 has been fixed (the comment requires V4/V5,
1111
AAL's code does V5/V4).
1212

13-
Another bug was at operation 24: the value accumulated in V13 is *the
14-
negative* of the required value, see Note G Equation 9.
13+
Another bug was at operation 24: the value accumulated in V13 is ×the
14+
negative× of the required value, see Note G Equation 9.
1515

1616
useful constants
1717
n001 1
@@ -29,7 +29,7 @@ n022 -00333333333
2929
n023 00238095238
3030

3131
operation 1
32-
*
32+
×
3333
l002
3434
l003
3535
s004
@@ -49,14 +49,14 @@ l001
4949
s005
5050

5151
operation 4, with bug fixed
52-
/
52+
÷
5353
z004
5454
<10
5555
z005
5656
s011'
5757

5858
operation 5
59-
/
59+
÷
6060
z011
6161
l002
6262
s011'
@@ -79,14 +79,14 @@ l007
7979
s007
8080

8181
operation 9
82-
/
82+
÷
8383
l006
8484
<10
8585
l007
8686
s011'
8787

8888
operation 10, using b1 (v021)
89-
*
89+
×
9090
l021
9191
l011
9292
>10
@@ -117,14 +117,14 @@ z007
117117
s007
118118

119119
operation 15
120-
/
120+
÷
121121
l006
122122
<10
123123
l007
124124
s008'
125125

126126
operation 16
127-
*
127+
×
128128
z008
129129
z011
130130
>10
@@ -143,21 +143,21 @@ z007
143143
s007
144144

145145
operation 19
146-
/
146+
÷
147147
l006
148148
<10
149149
l007
150150
s009'
151151

152152
operation 20
153-
*
153+
×
154154
z009
155155
z011
156156
>10
157157
s011
158158

159159
operation 21, using b3 (v022)
160-
*
160+
×
161161
l022
162162
l011
163163
>10
@@ -188,14 +188,14 @@ z007
188188
s007
189189

190190
operation 15
191-
/
191+
÷
192192
l006
193193
<10
194194
l007
195195
s008'
196196

197197
operation 16
198-
*
198+
×
199199
z008
200200
z011
201201
>10
@@ -214,21 +214,21 @@ z007
214214
s007
215215

216216
operation 19
217-
/
217+
÷
218218
l006
219219
<10
220220
l007
221221
s009'
222222

223223
operation 20
224-
*
224+
×
225225
z009
226226
z011
227227
>10
228228
s011
229229

230230
operation 21 (NB using b5, v023 this time)
231-
*
231+
×
232232
l023
233233
l011
234234
>10
@@ -251,7 +251,8 @@ s010
251251
l024
252252
l013
253253
s024
254-
the result!!
254+
the result!! calculations were scaled by 10 places
255+
a write numbers as 9.9999999999
255256
p
256257

257258
operation 25

src/analytical_engine-annunciator_panel-command_line.adb

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
-- program; see the files COPYING3 and COPYING.RUNTIME respectively.
2020
-- If not, see <http://www.gnu.org/licenses/>.
2121

22-
with Ada.Text_IO; use Ada.Text_IO;
22+
with Ada.Wide_Text_IO; use Ada.Wide_Text_IO;
2323
package body Analytical_Engine.Annunciator_Panel.Command_Line is
2424

25-
procedure Log_Attendant_Message (Panel : Instance; Msg : String)
25+
procedure Log_Attendant_Message (Panel : Instance; Msg : Wide_String)
2626
is
2727
pragma Unreferenced (Panel);
2828
begin
2929
Put_Line (Msg);
3030
end Log_Attendant_Message;
3131

32-
procedure Log_Trace_Message (Panel : Instance; Msg : String)
32+
procedure Log_Trace_Message (Panel : Instance; Msg : Wide_String)
3333
is
3434
pragma Unreferenced (Panel);
3535
begin

src/analytical_engine-annunciator_panel-command_line.ads

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ package Analytical_Engine.Annunciator_Panel.Command_Line is
2424
type Instance is new Annunciator_Panel.Instance with private;
2525

2626
overriding
27-
procedure Log_Attendant_Message (Panel : Instance; Msg : String);
27+
procedure Log_Attendant_Message (Panel : Instance; Msg : Wide_String);
2828

2929
overriding
30-
procedure Log_Trace_Message (Panel : Instance; Msg : String);
30+
procedure Log_Trace_Message (Panel : Instance; Msg : Wide_String);
3131

3232
private
3333

src/analytical_engine-annunciator_panel.ads

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ package Analytical_Engine.Annunciator_Panel is
2626
type Class_P is access all Instance'Class;
2727

2828
procedure Log_Attendant_Message
29-
(This : Instance; Msg : String) is abstract;
29+
(This : Instance; Msg : Wide_String) is abstract;
3030

3131
procedure Log_Trace_Message
32-
(This : Instance; Msg : String) is abstract;
32+
(This : Instance; Msg : Wide_String) is abstract;
3333

3434
procedure Set_Tracing (This : in out Instance; To : Boolean);
3535

src/analytical_engine-card-attendant_request.adb

+21-23
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@
1919
-- program; see the files COPYING3 and COPYING.RUNTIME respectively.
2020
-- If not, see <http://www.gnu.org/licenses/>.
2121

22-
-- with Ada.Strings.Unbounded;
23-
-- private with Ada.Finalization;
24-
-- private with Analytical_Engine.Mill;
25-
-- private with Analytical_Engine.Store;
26-
-- private with GNATCOLL.GMP.Integers;
27-
-- private with System;
28-
29-
-- with Ada.Strings.Fixed;
22+
with Ada.Characters.Conversions;
23+
with Ada.Strings.Wide_Unbounded;
24+
3025
with Analytical_Engine.Framework;
26+
3127
with GNAT.Regpat;
3228

3329
package body Analytical_Engine.Card.Attendant_Request is
@@ -50,44 +46,45 @@ package body Analytical_Engine.Card.Attendant_Request is
5046

5147
Max_Parens : constant := 10; -- overkill
5248

53-
function Read (From : String) return Card'Class is
54-
-- First : Positive;
55-
-- Last : Natural;
49+
function "+" (Item : Wide_String) return String
50+
is (Ada.Characters.Conversions.To_String (Item, Substitute => ' '));
51+
52+
function Read (From : Wide_String) return Card'Class is
5653
Matches : GNAT.Regpat.Match_Array (0 .. Max_Parens);
5754
use type GNAT.Regpat.Match_Location;
5855
begin
59-
GNAT.Regpat.Match (Picture_Matcher, From, Matches);
56+
GNAT.Regpat.Match (Picture_Matcher, +From, Matches);
6057
if Matches (0) /= GNAT.Regpat.No_Match then
6158
return C : Picture_Card do
62-
C.Source := Ada.Strings.Unbounded.To_Unbounded_String (From);
59+
C.Source := To_Unbounded_Wide_String (From);
6360
C.Picture :=
64-
Ada.Strings.Unbounded.To_Unbounded_String
61+
To_Unbounded_Wide_String
6562
(From (Matches (1).First .. Matches (1).Last));
6663
end return;
6764
end if;
6865

69-
GNAT.Regpat.Match (Row_Column_Matcher, From, Matches);
66+
GNAT.Regpat.Match (Row_Column_Matcher, +From, Matches);
7067
if Matches (0) /= GNAT.Regpat.No_Match then
7168
return C : Row_Column_Card do
72-
C.Source := Ada.Strings.Unbounded.To_Unbounded_String (From);
69+
C.Source := To_Unbounded_Wide_String (From);
7370
C.In_Rows := From (Matches (1).First .. Matches (1).Last) = "rows";
7471
end return;
7572
end if;
7673

77-
GNAT.Regpat.Match (Annotation_Matcher, From, Matches);
74+
GNAT.Regpat.Match (Annotation_Matcher, +From, Matches);
7875
if Matches (0) /= GNAT.Regpat.No_Match then
7976
return C : Annotation_Card do
80-
C.Source := Ada.Strings.Unbounded.To_Unbounded_String (From);
77+
C.Source := To_Unbounded_Wide_String (From);
8178
C.Annotation :=
82-
Ada.Strings.Unbounded.To_Unbounded_String
79+
To_Unbounded_Wide_String
8380
(From (Matches (1).First .. Matches (1).Last));
8481
end return;
8582
end if;
8683

87-
GNAT.Regpat.Match (New_Line_Matcher, From, Matches);
84+
GNAT.Regpat.Match (New_Line_Matcher, +From, Matches);
8885
if Matches (0) /= GNAT.Regpat.No_Match then
8986
return C : New_Line_Card do
90-
C.Source := Ada.Strings.Unbounded.To_Unbounded_String (From);
87+
C.Source := To_Unbounded_Wide_String (From);
9188
end return;
9289
end if;
9390
raise Card_Error
@@ -119,14 +116,15 @@ package body Analytical_Engine.Card.Attendant_Request is
119116
procedure Execute (C : Annotation_Card;
120117
In_The_Framework : in out Framework.Instance) is
121118
begin
122-
In_The_Framework.Output.Output (To_String (C.Annotation));
119+
In_The_Framework.Output.Output (To_Wide_String (C.Annotation));
123120
end Execute;
124121

125122
procedure Execute (C : New_Line_Card;
126123
In_The_Framework : in out Framework.Instance) is
127124
pragma Unreferenced (C);
125+
use Ada.Characters.Conversions;
128126
begin
129-
In_The_Framework.Output.Output ((1 => ASCII.LF));
127+
In_The_Framework.Output.Output ((1 => To_Wide_Character (ASCII.LF)));
130128
end Execute;
131129

132130
-- Not_A_Request);

src/analytical_engine-card-attendant_request.ads

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private package Analytical_Engine.Card.Attendant_Request is
3333

3434
type Card is abstract new Analytical_Engine.Card.Card with private;
3535

36-
function Read (From : String) return Card'Class
36+
function Read (From : Wide_String) return Card'Class
3737
with Pre => From'Length > 0
3838
and then (From (From'First) = 'A'
3939
or else From (From'First) = 'a');
@@ -51,7 +51,7 @@ private
5151
-- Decimal_Place_Expansion,
5252

5353
type Picture_Card is new Card with record
54-
Picture : Ada.Strings.Unbounded.Unbounded_String;
54+
Picture : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
5555
end record;
5656
overriding
5757
procedure Execute (C : Picture_Card;
@@ -67,7 +67,7 @@ private
6767
In_The_Framework : in out Framework.Instance);
6868

6969
type Annotation_Card is new Card with record
70-
Annotation : Ada.Strings.Unbounded.Unbounded_String;
70+
Annotation : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
7171
end record;
7272
overriding
7373
procedure Execute (C : Annotation_Card;

0 commit comments

Comments
 (0)