MODULE TCStringProg; (* C string boundary regression: an ARRAY OF CHAR actual must arrive at a foreign C procedure as a NUL-terminated char *, not as the V3 descriptor address. Expected exit code: 42. *) FROM TCString IMPORT m2_c_strlen, m2_c_fill; VAR ExitCode : INTEGER; fixed : ARRAY [0..7] OF CHAR; raw : ARRAY [0..3] OF CHAR; out : ARRAY [0..7] OF CHAR; n : CARDINAL; PROCEDURE open_len (s : ARRAY OF CHAR) : CARDINAL; BEGIN RETURN m2_c_strlen(s) END open_len; BEGIN fixed := "hello"; raw[0] := 'a'; raw[1] := 'b'; raw[2] := 'c'; raw[3] := 'd'; n := m2_c_fill(out, 8, 'x'); IF (m2_c_strlen("hello") = 5) AND (m2_c_strlen(fixed) = 5) AND (m2_c_strlen(raw) = 4) AND (open_len("world") = 5) AND (n = 7) AND (out[0] = 'x') AND (out[6] = 'x') AND (out[7] = CHR(0)) THEN ExitCode := 42 ELSE ExitCode := 1 END END TCStringProg.