From owner-p4-projects@FreeBSD.ORG Wed Apr 19 02:17:07 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3417316A406; Wed, 19 Apr 2006 02:17:07 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 098F616A402 for ; Wed, 19 Apr 2006 02:17:07 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BC2143D46 for ; Wed, 19 Apr 2006 02:17:06 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3J2H6JF069296 for ; Wed, 19 Apr 2006 02:17:06 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3J2H6DX069293 for perforce@freebsd.org; Wed, 19 Apr 2006 02:17:06 GMT (envelope-from jb@freebsd.org) Date: Wed, 19 Apr 2006 02:17:06 GMT Message-Id: <200604190217.k3J2H6DX069293@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 95571 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2006 02:17:07 -0000 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) {