In pursuance of my previously
mentioned UNICODE project, I have been trying to debug Chris
Lilley's code such that it will hopefully compile. Aside from a
problem with some non-POINTER opaque types which needed to be
moved from the implementation file to the definition file, and
fixing all of the hexadecimal numbers, the main issue I am having
is in the function 'ASCIIToUNICHAR()' ('ASCIIToUChar()' in
Lilley's original).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PROCEDURE ASCIIToUNICHAR (a: CHAR): UNICHAR;
(*
ASCIIToUNICHAR - converts a single ASCII printable char, a,
into
a Unicode character in the Basic Latin block.
For GM2, a Modula-2 char is a gcc char which is
8 bits;
printable ASCII values take up the lower half
of the
codespace in GM2.
If the ordinal value of a is outside the
printable
ASCII range, the Unicode character
'REPLACEMENT CHARACTER' is returned.
The size and encoding of a Modula-2 char is
undefined
in both PIM and ISO Modula-2.
*)
VAR
ASCIIRange : [32..127];
cp: CARDINAL; (* Unicode codepoint of the passed ASCII
character *)
BEGIN
cp := ORD(a);
(* if the locale is ASCII, or an ASCII superset like Latin-1,
cp will be the code point of the expected character.
if the locale is a code-switching set, or EBCIDIC or
something,
then you get what you get, and should not be claiming it
covers ASCII.
*)
IF (cp IN ASCIIRange) THEN
RETURN cp;
ELSE
RETURN Replacement;
END;
END ASCIIToUNICHAR;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When compiled with no language version specifier, I get the
following compiler error:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<library
path>/gcc/x86_64-pc-linux-gnu/13.2.1/m2/m2pim/COROUTINES.def:37:1:
error: In procedure ‘ASCIIToUNICHAR’: unable to obtain the MIN
value for type the ZType
<library path>/gcc/x86_64-pc-linux-gnu/13.2.1/m2/m2pim/COROUTINES.def:37:1:
error: unable to obtain the MAX value for type the ZType
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Curiously, when I
specify '-fiso', the error comes out as:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unicode.mod: In function
‘Unicode_ASCIIToUNICHAR’:
Unicode.mod:178:13: error: In procedure ‘ASCIIToUNICHAR’: unable
to obtain the MIN value for type the ZType
178 | END Unicode.
| ^
Unicode.mod:178:13: error: unable to obtain the MAX value for type
the ZType
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Aside from the
difference, and setting aside the question of why it is pointing
to the end of the file rather then the location of the error, the
error seems to stem from either the declaration of 'ASCIIRange',
or the application of IN to same.
The only reference to 'ZType' anywhere in the library source is a
comment in SYSTEM.def, regarding the internal procedure 'SIZE()'.
Can anyone familiar with the error explain what is actually
happening here, please?