On Feb 6, 11:56 pm, [EMAIL PROTECTED] (Hein van den Heuvel)
wrote:

> The getpos _should_ return an opaque value (likely to be 2 int).
> It doesn't.
I a parallel thread I erroneously created Craig explains how the perl
getpos reverts to tell, unless it was build with /define=_LARGEFILE

See: http://www.nntp.perl.org/group/perl.perl5.porters/2008/02/msg134073.html


> What is worse, the same formula is
> used for indexed files where that 'byte offset' (rab$w_rfa4) is really
> a record ID which typically is less than 100 or so, but for certain
> usages can be several thousands, up to 65K. So the 'offset' can add
> into the vbn space.

I can confirm this is a restriction/bug in the C-rtl.
Present in 8.3, and likely to remain there as permanent restirctions.

A test program with output below.
Same problem with ftell as well as ftello, whether your build /
define=_PARALLEL or not.

Look at the output lines for records 8 and 10.
Different records, same tell output and thus currently the same perl
getpos output.

Cheers,
Hein.

----------------------------------------------------------------


#include <stdio.h>
#include <stdlib.h>
#include <rms.h>

struct RAB *rab;

int acc_callback(int *first_arg, struct FAB *fab, struct RAB *the_rab)
{
rab = the_rab; // stash it away
return 0;
}

int main(int argc, char *argv[]) {
FILE *fp;
int stat, i=0, *p;
char buffer[2048], ch;
fpos_t posit;
off_t offset = 0;


printf ("sizeof off_t=%d\n", sizeof offset);
/* Open a file for reading . */
if ((fp = fopen(argv[1], "r", "acc", &acc_callback)) == NULL) {
  perror("open");
  exit(1);
  }

/* Get the beginning position in the file. */
p = (void *) &posit;  // Helper for opaque item hex printout
while (i++ < 100) {
  if (fgetpos(fp, &posit) != 0) perror("fgetpos");
  offset = ftello(fp);
  printf ("%5d, Tell: %ld, pos: %08x %08x  rfa: %08x,%04x\n",
        i, offset, p[0], p[1], rab->rab$l_rfa0, rab->rab$w_rfa4);

/* read some data prom the file. */
  if (!fgets(buffer, sizeof buffer, fp)) break ;
  }
}


----- Silly DCL used to 'create the condition:

$ typ tmp.com
$close/nolog tmp
$open/read/write tmp tmp.idx
$loop:
$read/dele/key="1007" tmp record
$write/symb tmp record
$p1 = p1 - 1
$if p1.gt.0 then goto loop
$close tmp

--------------

$ mcr sys$Login:GETPOS tmp.idx
sizeof off_t=8
    1, Tell: 1025, pos: 00000002 00000001  rfa: 00000003,0001
    2, Tell: 1026, pos: 00000002 00000002  rfa: 00000003,0002
    3, Tell: 1027, pos: 00000002 00000003  rfa: 00000003,0003
    4, Tell: 1028, pos: 00000002 00000004  rfa: 00000003,0004
    5, Tell: 1029, pos: 00000002 00000005  rfa: 00000003,0005
    6, Tell: 1030, pos: 00000002 00000006  rfa: 00000003,0006
    7, Tell: 1031, pos: 00000002 00000007  rfa: 00000003,0007
    8, Tell: 3073, pos: 00000002 00000801  rfa: 00000003,0801
    9, Tell: 1033, pos: 00000002 00000009  rfa: 00000003,0009
   10, Tell: 3073, pos: 00000006 00000001  rfa: 00000007,0001
   11, Tell: 3074, pos: 00000006 00000002  rfa: 00000007,0002
   12, Tell: 3075, pos: 00000006 00000003  rfa: 00000007,0003
   13, Tell: 3076, pos: 00000006 00000004  rfa: 00000007,0004
   14, Tell: 3077, pos: 00000006 00000005  rfa: 00000007,0005
   15, Tell: 3078, pos: 00000006 00000006  rfa: 00000007,0006
   16, Tell: 3079, pos: 00000006 00000007  rfa: 00000007,0007
   17, Tell: 3080, pos: 00000006 00000008  rfa: 00000007,0008
   18, Tell: 3081, pos: 00000006 00000009  rfa: 00000007,0009
   19, Tell: 4097, pos: 00000008 00000001  rfa: 00000009,0001
   20, Tell: 4098, pos: 00000008 00000002  rfa: 00000009,0002
   21, Tell: 4099, pos: 00000008 00000003  rfa: 00000009,0003


Reply via email to