Date: Wed, 19 Apr 2006 02:17:06 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95571 for review Message-ID: <200604190217.k3J2H6DX069293@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95571 Change 95571 by jb@jb_freebsd2 on 2006/04/19 02:17:03 This code is nature's way of reminding me that I'm no lex whiz. The OpenSolaris code expects AT&T (SCO? Ugh) semantics. That means non-POSIX. Sigh. FreeBSD uses 'flex' as 'lex', so we turn on compatibility mode for as much as possible, but that still doesn't let us redefine input(). We have to define YY_INPUT, but this works ahead of time, buffering as many characters as possible for performance reasons. As a result, we can't check the states that the Solaris version does on a character by character basis. This at least lets us initialise dtrace(1) now. It now wants to know about providers, so we're heading in the right direction. Affected files ... .. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_lex.l#3 edit Differences ... ==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_lex.l#3 (text) ==== @@ -46,13 +46,34 @@ #undef input #undef unput #else -#undef yyinput -#define yyinput input +/* + * Define YY_INPUT for flex since input() can't be re-defined. + */ +#define YY_INPUT(buf,result,max_size) \ + if (yypcb->pcb_fileptr != NULL) { \ + int n; \ + for (n = 0; n < max_size && \ + ferror(yypcb->pcb_fileptr) == 0; n++) { \ + int c = fgetc(yypcb->pcb_fileptr); \ + if (c == EOF) \ + break; \ + buf[n] = c; \ + } \ + if (yypcb->pcb_fileptr != NULL && ferror(yypcb->pcb_fileptr)) \ + longjmp(yypcb->pcb_jmpbuf, EDT_FIO); \ + return n; \ + } else { \ + int n; \ + for (n = 0; n < max_size && \ + yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen; n++) \ + buf[n] = *yypcb->pcb_strptr++; \ + result = n; \ + } #endif static int id_or_type(const char *); +#if defined(sun) static int input(void); -#if defined(sun) static void unput(int); #endif @@ -794,17 +815,15 @@ return (ttok); } +#if defined(sun) static int -dtinput(void) +input(void) { int c; -#if defined(sun) if (yysptr > yysbuf) c = *--yysptr; - else -#endif - if (yypcb->pcb_fileptr != NULL) + else if (yypcb->pcb_fileptr != NULL) c = fgetc(yypcb->pcb_fileptr); else if (yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen) c = *yypcb->pcb_strptr++; @@ -829,7 +848,6 @@ return (0); /* EOF */ } -#if defined(sun) static void unput(int c) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604190217.k3J2H6DX069293>