mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-23 20:38:33 +02:00

and 4080. The compatibility differences are: a) writing a chararray which is zero-based but not zero- terminated does not cause a buffer overflow b) non-zero-based chararrays can also be read The difference was that previously, all chararrays were treated as pchars. In TP/Delphi (and now also in FPC), this is only done for zero-based chararrays. For non-zero-based ones, the entire contents of the array should always be used (including #0's). The default parameters in the system unit for the chararray helpers are to avoid having to use a define for bootstrapping. git-svn-id: trunk@2152 -
50 lines
792 B
ObjectPascal
50 lines
792 B
ObjectPascal
program tw4080;
|
|
{$i+}
|
|
|
|
{$ifdef unix}
|
|
uses
|
|
cwstring;
|
|
{$endif unix}
|
|
|
|
var
|
|
S, S2 : array [1..15] of char;
|
|
f: text;
|
|
f2: file;
|
|
l: longint;
|
|
str: shortstring;
|
|
astr: ansistring;
|
|
wstr: widestring;
|
|
begin
|
|
S := 'string1'#0'string2';
|
|
assign(f,'tw4080.out');
|
|
rewrite(f);
|
|
write (f,S);
|
|
close(f);
|
|
assign(f2,'tw4080.out');
|
|
reset(f2,1);
|
|
if (filesize(f2) <> 15) then
|
|
halt(1);
|
|
blockread(f2,s2,sizeof(s2));
|
|
close(f2);
|
|
erase(f2);
|
|
for l := low(s) to high(s) do
|
|
if s[l] <> s2[l] then
|
|
halt(1);
|
|
|
|
str := s;
|
|
for l := low(s) to high(s) do
|
|
if s[l] <> str[l] then
|
|
halt(1);
|
|
|
|
astr := s;
|
|
for l := low(s) to high(s) do
|
|
if s[l] <> astr[l] then
|
|
halt(1);
|
|
wstr := s;
|
|
for l := low(s) to high(s) do
|
|
if s[l] <> wstr[l] then
|
|
halt(1);
|
|
end.
|
|
|
|
|