File Sharing Mode Fails in Version 3.31

Product Version(s): 3.31 3.32
Operating System:   MS-DOS
Flags: ENDUSER | TAR53822 buglist3.31 fixlist3.32
Last Modified:  3-OCT-1988    ArticleIdent: Q12400

Reading and writing a file with file-sharing mode set will not work
correctly under Version 3.31 of Pascal.

If the mode of the file is set to sm_DENYNONE, it will read up to the
583rd byte of the record, then go back and read from the beginning
instead of reading the rest of the file. The problem does not appear
if the file sharing is not set. It does not matter if SHARE.EXE is
loaded or not.

This problem occurs when the share modes are sm_DENYWR, sm_DENYRD, and
sm_DENYNONE. It appears to work correctly under sm_COMPAT and
sm_DENYRW.

The sample program below writes 26 30-character strings in a 780-byte
direct-access record. Each of the 26 strings is filled with a
different letter of the alphabet.

The following code demonstrates this problem:

program testit(input,output);
type test_rec=record
              line:array[1..26] of string(30);
              end;

var
  i,j,k:integer;
  go_again:char;
  test:test_rec;
  test_file:file of test_rec;

begin
  assign(test_file,'testfile');
  test_file.mode:=direct;
  for i:=1 to 4 do begin
    for j:=1 to 26 do
      for k:=1 to 30 do
        test.line[j][k]:=chr(j +96);
    test_file.share:=sm_DENYRW;
    rewrite(test_file);
    seek(test_file,i);
    test_file^:=test;
    put(test_file);
    close(test_file);

    test_file.share:=sm_DENYNONE;
    reset(test_file);
    seek(test_file,i);
    get(test_file);
    test:=test_file^;
    close(test_file);

    writeln(output);
    writeln(output,'Record : ',i:2);
    writeln(output);
    for j:=1 to 13 do begin
      write(output,'  ',j:2,' : ',test.line[j]);
      writeln(output,'   ',(j+13):2, ' : ',test.line[j+13]);
    end;
    writeln(output);
    write(output,'enter a key to go to next record --> ');
    readln(iniput,go_again);
  end;  {for i:=1 to 4}
end.