|
Joined: Dec 2003
Posts: 61
Babel fish
|
OP
Babel fish
Joined: Dec 2003
Posts: 61 |
It seems like if you cut off a binvar, $bfind searches from the Nth postion to the end + 1. A 'ghost'-character at the end of the binvar from a previous truncation.
In this example i have a binvar of 121 122 123 124 125. Then i copy postion 1-4 to 1-4 and chop off the rest of the binvar. (Which practicly removes 124 and 125). So i keep 121 122 123 over. Then i try to search for 124 and it finds it on postion 4, while the binvar is only 3 long and 124 isn't in the binvar. And i search for 125 and returns 0 as it should.
This happens not only with 124 but with every character.
To reproduce: alias bin { !bset &z 1 121 122 123 124 125 echo -a Before: $bvar(&z,1,100) !bcopy -c &z 1 &z 1 $calc($bvar(&z,0) - 2) echo -a After: $bvar(&z,1,100) echo -a Location 124: $bfind(&z,1,124) echo -a Location 125: $bfind(&z,1,125) }
Last edited by Aeron; 30/05/05 06:50 AM.
|
|
|
|
Joined: Dec 2002
Posts: 208
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 208 |
Verified here on 6.16/XP+SP2. Also, I thought I'd point out that the wording in the help file on the -c switch to /bcopy isn't quite as accurate as it could be: If you specify the -c switch, the first &binvar is chopped to length N + M. Makes me think that if N is 1, and M is 1, (copy one byte to position 1) it will end with a length of 2 bytes. Indeed, it seems to do just that, except that $bvar doesn't agree. I am assuming that my interpretation of the help file isn't what it's supposed to do, and that the bug is with $bfind, or possibly /bcopy, and not with $bvar.
If I knew now what I will know then... maybe things will have been different...
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Looks like a bug to me, odd thing is is its actually scanning to the correct length the HELP file says it should be. your line for example... /bcopy -c &z 1 &z 1 3 and the help file... /bcopy [-zc] <&binvar> <N> <&binvar> <S> <M> This copies M bytes from position S in the second &binvar to the first &binvar at position N. This can also be used to copy overlapping parts of a &binvar to itself. If you specify the -z switch, the bytes in the second &binvar that were copied are zero-filled after the copy. If you specify the -c switch, the first &binvar is chopped to length N + M. So N(1) + M(3) = 4 This is of course is wrong as the length actually becomes 3, however it maybe a source of the phantom character being retained, namely at some point N + M is used as the size of data to gather/shift/?do something with, and thus it manages to be retained. *** actually after doing some more snooping around there are some real odd results. ANYONE CORRECT ME if im wrong but all the blue lines seem to be wrong answers alias bin {
!bset &z 1 121 122 123 124 125
echo -a Before: $bvar(&z,1,100)
echo -a Location 121: $bfind(&z,1,121)
echo -a Location 122: $bfind(&z,1,122)
echo -a Location 123: $bfind(&z,1,123)
echo -a Location 124: $bfind(&z,1,124)
echo -a Location 125: $bfind(&z,1,125)
echo -a $!bfind(&z,2,121) = $bfind(&z,2,121)
echo -a $!bfind(&z,3,122) = $bfind(&z,3,122)
echo -a $!bfind(&z,4,123) = $bfind(&z,4,123)
echo -a $!bfind(&z,5,124) = $bfind(&z,5,124)
echo -a $!bfind(&z,6,125) = $bfind(&z,6,125)
echo -a !bcopy -c &z 1 &z 1 $calc($bvar(&z,0) - 2)
!bcopy -c &z 1 &z 1 $calc($bvar(&z,0) - 2)
echo -a After: $bvar(&z,1,100)
echo -a Location 121: $bfind(&z,1,121)
echo -a Location 122: $bfind(&z,1,122)
echo -a Location 123: $bfind(&z,1,123)
echo -a Location 124: $bfind(&z,1,124)
echo -a Location 125: $bfind(&z,1,125)
echo -a $!bfind(&z,2,121) = $bfind(&z,2,121)
echo -a $!bfind(&z,3,122) = $bfind(&z,3,122)
echo -a $!bfind(&z,4,123) = $bfind(&z,4,123)
echo -a $!bfind(&z,5,124) = $bfind(&z,5,124)
echo -a $!bfind(&z,6,125) = $bfind(&z,6,125)
} Before: 121 122 123 124 125 Location 121: 1 Location 122: 2 Location 123: 3 Location 124: 4 Location 125: 5 $bfind(&z,2,121) = 0 $bfind(&z,3,122) = 0 $bfind(&z,4,123) = 0 $bfind(&z,5,124) = 0 $bfind(&z,6,125) = 5 (ummm how did i get 5 as a result when starting at 6?) !bcopy -c &z 1 &z 1 3 After: 121 122 123 Location 121: 1 Location 122: 2 Location 123: 3 Location 124: 4 (heres yours the phantom extra byte) Location 125: 0 $bfind(&z,2,121) = 0 $bfind(&z,3,122) = 0 $bfind(&z,4,123) = 3 (again a find from beyond the end and beyond the result gets a earlier number) $bfind(&z,5,124) = 4 (and now mine and yours together, a find beyond the end and beyond the result locates the phantom byte!) $bfind(&z,6,125) = 0
|
|
|
|
|