Path: utzoo!attcan!uunet!airgun!lampshir From: lampshir@airgun.wg.waii.com (gregory b. lampshir) Newsgroups: comp.unix.questions Subject: Lex and redefining the i/o macros Keywords: Lex, Unix, Yacc Message-ID: <859@airgun.wg.waii.com> Date: 10 Jul 90 17:45:59 GMT Organization: Western Geophysical, Houston Lines: 47 To someone who knows lex....., I need to rewrite the input(), output(), and unput() macros that lex normally supplies so I can accept a binary file. I will strip out the funny control characters found in the binary file so I am not worried about any recognition problems. I am, however, having trouble rewriting the macros into functions. What I have know is this .... int filePointerIn; main() { filePointerIn=open(argv[1],O_RDONLY,0); while(1) yylex(); } char input() { int pos; char *ch; pos=read(filePointerIn,ch,1); /* Some code to strip the funny characters you get from reading binary files a character at a time. Yes there are ints and other misc. chars in the file, but the text is o.k. somewhere inside there. */ if(pos==0) return(0); /* needed by lex to signal eof */ else return(*ch); } void unput(c) char c; { lseek(filePointerIn,-1,L_INCR); } Can any of you lex wizards help me with this one? What am I doing wrong? gregory lampshire | Searching for the computer which can western geophysical | do it all.....