Some more bugs

Mon, 10 Mar 1997 15:10:53 GMT



Hi everyone!

I've got a few more bugs:

1. For loops with chars don't seem to work:

PROGRAM p;
VAR c:Char;
BEGIN
  c:='A'; {OK}
  c:='Z'; {OK}
  FOR c:='A' TO 'Z' DO {"incompatible types in assignment"}
END.

2. Under DJGPP, program arguments don't work correctly, as the following
   program shows. Under Linux it seems to work ok. However, the problem
   seems to have something to do with Pascal, since gcc programs under
   DJGPP don't show the problem.

{Call the compiled program as "p longparam 2 3" or similar}

PROGRAM p;

{From info/gpc.i7, slightly modified:}
     CONST
        Max_length = 255;     { Max length of each argument.
                                If some arg is longer, the run time system
                                traps it. }

     TYPE
       Arg_type = String(Max_length);

       FUNCTION _p_paramcount : Integer; C;
       FUNCTION _p_paramstr (num: Integer; VAR str: String): Boolean; C;

       FUNCTION ParamCount: Integer;
       BEGIN
          ParamCount := _p_paramcount;
       END; { ParamCount }

       FUNCTION ParamStr (arg_num: integer): Arg_type;

       VAR
        Str       : Arg_type;
        Success     : Boolean;

       BEGIN
          Success := _p_paramstr (arg_num, Str);

          (* Should perhaps do something else on failure.
           *
           * Now it returns the empty string, which is also a valid
           * parameter.
           *)
          IF Success THEN
             ParamStr := Str
          else
             ParamStr := '';
       END; { ParamStr }
{}

VAR a:Integer;
BEGIN
  FOR a:=1 TO ParamCount DO Writeln(ParamStr(a))
END.

The result is something like:
longparam[some other chars]
2ongparam[some other chars]
3ongparam[some other chars]

Obviously the length is not set correctly.

Frank
-- 
Frank Heckenbach, Erlangen, Germany
heckenb@mi.uni-erlangen.de
Turbo Pascal:   http://www.mi.uni-erlangen.de/~heckenb/programs.htm
Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm


Frank Heckenbach (heckenb@mi.uni-erlangen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es