tb0041.pp 920 B

1234567891011121314151617181920212223242526272829303132333435
  1. { %FAIL }
  2. { Old file: tbf0205.pp }
  3. { and parsing bugs, generates wrong code (tp7 gives parser error) OK 0.99.11 (PM) }
  4. program bug_show;
  5. { By PAV ([email protected]) }
  6. function bad_uppercase(s:string):string;
  7. var i:integer;
  8. begin
  9. for i:=1 to length(s) do
  10. if (ord(s[i])>=97 and ord(s[i])<=122) then s[i]:=chr(ord(s[i])-97+65);
  11. bad_uppercase:=s;
  12. end;
  13. function good_uppercase(s:string):string;
  14. var i:integer;
  15. begin
  16. for i:=1 to length(s) do
  17. if (ord(s[i])>=97) and (ord(s[i])<=122) then s[i]:=chr(ord(s[i])-97+65);
  18. good_uppercase:=s;
  19. end;
  20. const cadena='Free Paskal Compiler 0.99.8 !!! (bug)';
  21. begin
  22. writeln('This is the original string before convert it');
  23. writeln(cadena);
  24. writeln();
  25. writeln('This is a bad result, using "if ( and )"');
  26. writeln(bad_uppercase(cadena));
  27. writeln();
  28. writeln('This is a good result, using "if () and ()"');
  29. writeln(good_uppercase(cadena));
  30. writeln();
  31. end.