On Tue, 2004-06-01 at 04:15, Jignesh Jani wrote:
> I forsee a potential bug in swish-e for windows. Correct me if i am wrong.
> Swish-e uses two routines PACKLONG and UNPACKLONG to write and read an
> unsigned long number in the index files. According to my testing in case of
> a number like 1133082 this routine will generate a value that contains
> ctrl-Z. Which in fact is the EOF for window environment.
Control-Z is the character Windows uses in text-mode to signify
end-of-file. When doing binary file I/O a physical end-of-file
signifies end-of-file.
SWISH-E operates in binary mode on Windows: rb, wb, rb+
Here is a simple test program...
$ cat test.c
#include <windows.h>
#include <stdio.h>
int main(void){
FILE *fp;
int c;
fp = fopen("test.idx", "rb");
while(c = getc(fp)){
if(c == EOF){
return 0;
}
printf("%c", c);
}
return 1;
}
$ gcc test.c
$ a.exe
There is a control-z here and here and here and none are treated as
EOF.
$ cat test.idx
There is a control-z here and here and here and none are treated as
an EOF.
--
David Norris
http://www.webaugur.com/dave/
ICQ - 412039
Received on Tue Jun 1 13:17:26 2004