summary_charcat-convresults.md 2.1 KB

Step: CHAR-array + coverage + ISO ConvResults

Tag v3-charcat-convresults. Suite 139/139; fixpoint OK (image 2,156,095 bytes).

CHAR-array + (verified, test added)

String concatenation for ARRAY OF CHAR already worked end-to-end from the earlier string work (StrCompat treats two 1-D ARRAY OF CHAR as string-compatible; QbeGen.StrCat → m2strcat, and the result is assigned by content copy). It simply had no test:

  • a + b (both ARRAY OF CHAR),
  • a + "c" / "x" + a (a single-char literal is a CHAR operand, via DeclCharStr),
  • a + a + a (chained).

t_charcat.mod (exit 15) locks all four in.

Note: a single-character string literal is a CHAR in classic Modula-2, so b := "z" into a CHAR array is 210; write b := "zz" or assign b[0] := "z". Concatenation accepts the CHAR form directly (a + "c").

ISO ConvResults

Conversions now reports an ISO-style status instead of only a BOOLEAN:

TYPE ConvResults = (strAllRight, strOutOfRange,
                    strWrongFormat, strEmpty);
PROCEDURE StrToInt (s : ARRAY OF CHAR; VAR n : INTEGER) : ConvResults;
PROCEDURE StrToCard(s : ARRAY OF CHAR; VAR n : CARDINAL): ConvResults;
PROCEDURE StrToReal(VAR s : ARRAY OF CHAR; VAR x : REAL): ConvResults;
  • strAllRight / strOutOfRange / strWrongFormat / strEmpty.
  • strOutOfRange is detected before the 32-bit accumulate wraps (v > (IntMax - d) DIV 10), because V3 has no VAL(LONGINT, int) or long→int narrowing to use a wider accumulator.
  • The BOOLEAN shortcuts are retained under new names — IntVal/CardVal/RealVal — since the StrTo* results changed type. (ConvProg and Showcase14 were updated to them.)

convresults_prog.mod (exit 127) covers every status for StrToInt/StrToCard/StrToReal.

Tests

  • t_charcat.mod (15): CHAR-array +.
  • convresults_prog.mod (127): all ConvResults codes.
  • conv_prog.mod / showcase14.mod: switched to IntVal/RealVal.

Files

stdlib/conversions.def/.mod, compiler/tests/{t_charcat, convresults_prog,conv_prog,showcase14}.mod, compiler/run_tests.sh, docs/features.md.