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.
Best regards, Peter
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)
/* Read from files and strings. */ static tree build_read (int r_num, tree params, const char *r_name) { tree file, parm; if (r_num == p_ReadStr)
When, in your test program, you replace ReadString with ReadStr, you correctly get the error message the compiler should issue:
error: argument 1 to `ReadStr' must be the string to read from
Thanks for the report.
Regards,
Adriaan van Os
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"?
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
Adriaan van Os wrote:
Waldek Hebisch wrote:
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)
Prototype FUNCTION StringOf( v1 [; v2; ...; vn]) : STRING;
I have added "ReadString" to my version. Unfortunatly, "StringOf" requres some real effort so I can not do it quicky.
Waldek Hebisch wrote:
Adriaan van Os wrote:
Waldek Hebisch wrote:
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)
Prototype FUNCTION StringOf( v1 [; v2; ...; vn]) : STRING;
I have added "ReadString" to my version. Unfortunatly, "StringOf" requres some real effort so I can not do it quicky.
Thanks for the added routine.
Regards,
Adriaan van Os
Waldek Hebisch wrote:
Adriaan van Os wrote:
Waldek Hebisch wrote:
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)
Prototype FUNCTION StringOf( v1 [; v2; ...; vn]) : STRING;
I have added "ReadString" to my version. Unfortunatly, "StringOf" requres some real effort so I can not do it quicky.
It might be doable similar to `FormatString' (in fact, reusing much of its implementation), which uses an RTS helper doing some heap stuff. Perhaps not the most elegant way, but it should not be a real problem, as calls cannot be nested (note: `FormatString (... FormatString (...) ...)' is no nested call in this sense, as the compiler copies the inner result to a temp variable).
Frank
Frank Heckenbach wrote:
Waldek Hebisch wrote:
I have added "ReadString" to my version. Unfortunatly, "StringOf" requres some real effort so I can not do it quicky.
It might be doable similar to `FormatString' (in fact, reusing much of its implementation), which uses an RTS helper doing some heap stuff. Perhaps not the most elegant way, but it should not be a real problem, as calls cannot be nested (note: `FormatString (... FormatString (...) ...)' is no nested call in this sense, as the compiler copies the inner result to a temp variable).
I see. I have added "StringOf" now. I was able to reuse most of the code.
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
[snip]
Is it just a single routine ("ReadString") or does Mac Pascal have also "WriteString"?
Mac Pascal has function that is basicly a functional form of "WriteString". The function's name is "StringOf" and it returns a string-type. So the difference between the two is the method used to pass back to the caller the written to string. "WriteString" uses a required string-variable first parameter; whereas, doesn't use a required string-variable first parameter. Using ISO 10206 syntax notation, a syntax comparison would be:
ISO 10206: writestr(s, p1, ... , pn) versus Mac Pascal: s := stringof(p1, ... , pn)
I'll note that Mac Pascal's have a few extensions in the types of parameters allowed for Read and ReadString and THINK Pascal allows more types for Write and StringOf. All three traditional Mac Pascal compilers allow boolean type parameters for Read and ReadString which ISO doesn't allow. THINK Pascal extends allowed types to include any enumerated type for reading as well as writting. But to make that work reasonably well, THINK Pascal doesn't do field width truncation on the strings written out for boolean or enumerated types and thus avoids having to handle reading write truncated strings for those types.
Gale Paeper gpaeper@empirenet.com