"Anton Ertl" <[EMAIL PROTECTED]> writes: > Robert Epprecht wrote: >> I guess, that key?-file ( wfileid -- flag ) should return TRUE if >> it is possible to read at least one byte from the file. Is this right? > > Yes. > >> Is there a special treatment of an input byte with value zero? > > There should not be; I do not see any special treatment in the source > code, and testing reading from a disk file has revealed no special > treatment, either. > >> It looks to me as if key?-file would sometimes return FALSE even when >> there *is* a byte with value zero at /dev/midi. From this point on >> key?-file would always return FALSE even if I send other (non zero) >> bytes through the MIDI input to /dev/midi.
> Does this also occur when you read from a regular file? No. I had tested this before and could not reproduce the bug from a regular file (sorry for not mentioning it). I can even do s" cat /dev/midi > midi-in & " system and get the input from file midi-in to avoid the problem. I have done more tests today and can reproduce a situation now, where there *is* a zero byte at /dev/midi and key?-file gives FALSE. I can get the zero byte with key-file. So I can confirm what I assumed in my last message. Unfortunately I need my midi hardware to trigger the bug, but I will inquire more. I think it's not clear yet if it's gforth fault, or if it has something to do with some level below that (like driver, ALSA OSS emulation or whatever). > BTW, in testing I have found a bug in KEY?-FILE; if I successfully > KEY?-FILE from a regular file, and then KEY-FILE from somewhere else > (e.g., stdin), the latter gives me the character from the file. This > comes from using a global variable "pending" to remember the character > that was read in, instead of having one per file. I *did* use KEY? and KEY in my debugging. I hope this did not change the results of KEY?-FILE and KEY-FILE. Or do they also use the same variable? > The clean way to solve this would be to check if there is already a > character buffered by the FILE * structure, and if not, try to read > it, and then ungetc() it. Unfortunately, I don't know a portable way > to determine that there are buffered characters in a FILE *. If not portable, do you know a way to do this in gforth on linux on /dev/midi? I'd be glad to have a MIDI-IN? ( -- flag ) without using C for the time being, even if it wouldn't be portable. I did not start trying to solve my problem using the C interface yet. There's a lot to learn for me first, as I am not a C programmer. I have started to learn though. (If I want to use ALSA or JACK for my application later on, I will need that anyway). Robert Epprecht --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
