Waldek Hebisch wrote:
Adriaan van Os wrote:
Peter Schorn wrote:
The following program crashes the compiler (gpc345u2 on Mac OS 10.4.4):
program rs;
{ compile with gpc rs.pas }
var a: integer;
begin readstring(a); { internal compiler error: Bus error } end.
Hmm, I think I caused this error, by adding ReadString to predef.def
diff -urN gcc-3.4.5-orig/gcc/p/predef.def gcc-3.4.5/gcc/p/predef.def @@ -436,6 +442,7 @@ PREDEF_ROUTINE (Read, "-,|", ER_IOCRITICAL, ANY_PASCAL) PREDEF_ROUTINE (ReadLn, "-,|", ER_IOCRITICAL, ANY_PASCAL) PREDEF_ROUTINE (ReadStr, "-x,|", 0, E_O_PASCAL) +PREDEF_ALIAS (ReadString, ReadStr, "-x,|", 0, MAC_PASCAL) PREDEF_ROUTINE_NO_ID (Read_Init, "-Fi", 0) PREDEF_ROUTINE_NO_ID (ReadStr_Init, "psi", 0) PREDEF_ROUTINE_NO_ID (ReadWriteStr_Done, "-F", 0)
without patching predef.c (and possibly elsewhere)
Is it just a single routine ("ReadString") or does Mac Pascal have also "WriteString"?
MacPascal doesn't have WriteString. It does have StringOf, which is somewhat comparable.
(from the CodeWarrior Pascal Library Reference)
StringOf
Description Returns the character representations of its arguments as a character string.
Compatibility ANS Pascal, MPW Pascal
Prototype FUNCTION StringOf( v1 [; v2; ...; vn]) : STRING;
Remarks The StringOf function converts its arguments into character representations and concatenates them, in order, into a item of type STRING.
StringOf accepts parameters like the Write procedure, including width and precision specifications. For example, StringOf(383) returns ' 383'. In this case, StringOf used its default formatting settings, a width of 8 characters for integer numbers, since width and precision values weren't specified. The expression StringOf(3.14:12:4) returns ' 3.1400' because a width of 12 and a precision of 4 were used. For a complete description of how StringOf handles its parameters, see Write on page 120. To change the default settings StringOf uses to format its arguments, see PLStringOfGet, PLStringOfSet.
Returns StringOf returns an item of type STRING containing a character representation of its parameters.
See also PLStringOfGet, PLStringOfSet, StrOf, Write.
Regards,
Adriaan van Os