Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: why is this in h2ph Message-ID: <11216@jpl-devvax.JPL.NASA.GOV> Date: 29 Jan 91 17:12:51 GMT References: <1991Jan8.073648.7186@uvaarpa.Virginia.EDU> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 52 In article <1991Jan8.073648.7186@uvaarpa.Virginia.EDU> marc@mit.edu writes: : In h2ph, there is this piece of code: : : elsif ($isatype{$id}) { : $new .= "'$id'"; : } : : What is it good for? The only time I've ever seen it match is when : there is a cast in a #define. For example: : : #define lettera ((char) 65) : : becomes : : sub lettera {(('char') 65);} : : This causes perl to have fits, of course. : : Is there a reason that one of the matches in expr can't look like : : s/^\(((un)?signed\s+)?[_a-zA-Z]\w*\)//; : : If I understand h2ph correctly, this will have the useful effect of : just stripping casts from #defines. Since perl doesn't do any kind of : real types, if you're casting into something besides char, short, int, : or long you're likely to lose anyway, so an error from the .ph file is : probably appropriate. Basically, the intent is that casts, which are : fairly common, not cause h2ph to lose. The subsidiary intent is that : I not have to edit a lot of .ph files :-) The lettera definition is unlikely to do you much good in Perl, so the correct way for h2ph to protect it would be to enclose it in an eval. The intent of the $isatype{} code is to translate sizeof() reasonably, since many implementations of ioctl encode the size of the structure to be passed in the second argument. Thus sizeof(int) turns into $sizeof{'int'} h2ph doesn't attempt to define %sizeof, however. Tom's h2pl/mksizes program will try to do that for you. But it's all jiggery-pokery. Hopefully we'll get something based on C's debugging stabs that will be a bit more robust. The whole "include" paradigm is somewhat undisciplined, however, even in C. There's probably several research projects in there. Larry