From owner-p4-projects@FreeBSD.ORG Wed Jul 12 02:45:36 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 B4A9616A4E2; Wed, 12 Jul 2006 02:45:36 +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 7370F16A4DF for ; Wed, 12 Jul 2006 02:45:36 +0000 (UTC) (envelope-from swhitman@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2F8EC43D49 for ; Wed, 12 Jul 2006 02:45:36 +0000 (GMT) (envelope-from swhitman@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6C2ja30045663 for ; Wed, 12 Jul 2006 02:45:36 GMT (envelope-from swhitman@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6C2jaQb045660 for perforce@freebsd.org; Wed, 12 Jul 2006 02:45:36 GMT (envelope-from swhitman@FreeBSD.org) Date: Wed, 12 Jul 2006 02:45:36 GMT Message-Id: <200607120245.k6C2jaQb045660@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to swhitman@FreeBSD.org using -f From: Spencer Whitman To: Perforce Change Reviews Cc: Subject: PERFORCE change 101320 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, 12 Jul 2006 02:45:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=101320 Change 101320 by swhitman@swhitman_joethecat on 2006/07/12 02:44:37 Work on #define Affected files ... .. //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/cpp.c#10 edit .. //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/k.c#10 edit .. //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/k.h#7 edit .. //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/lexer.c#8 edit Differences ... ==== //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/cpp.c#10 (text+ko) ==== @@ -45,7 +45,10 @@ }; struct define { - TAILQ_ENTRY(defines) list; + const char *name; /* Name of the macro */ + /* Arguments of the macro */ + /* Value of the macro */ + TAILQ_ENTRY(defines) list; /* Link to list of macros */ }; static TAILQ_HEAD(,iarg) iarg = TAILQ_HEAD_INITIALIZER(iarg); @@ -88,23 +91,23 @@ static const char * skipspace(struct cppfilestate *cfs, const char *s, const char *e) { - /* skip leading spaces, including line continuation */ - while (s < e) { - /* XXX This code will choke on single \'s or /'s */ - /* XXX Not sure if this is what needs to be edited */ - if (*s == '\\' && s + 1 < e && isvert(s[1])) { - s++; - continue; - } - if (*s == '/') { - s = skipcomment(cfs, s, e); - s++; - } - if (!isspace(*s)) - break; - s++; - } - return (s); + /* skip leading spaces, including line continuation */ + while (s < e) { + /* XXX This code will choke on single \'s or /'s */ + /* XXX Not sure if this is what needs to be edited */ + if (*s == '\\' && s + 1 < e && isvert(s[1])) { + s++; + continue; + } + if (*s == '/') { + s = skipcomment(cfs, s, e); + s++; + } + if (!isspace(*s)) + break; + s++; + } + return (s); } static const char * @@ -229,14 +232,39 @@ /* * Define statment should be of the form: * #define NAME(vars) value - * If value continues along more than one line, it should end with a \\n + * If it continues along more than one line, the line should end with a \\n + * (this may already be taken care of). vars and value are both optional. */ static void cpp_define(CPP_ARGS) { /* struct cppfilestate *cfs __unused, const char *h __unused, const char *b __unused, const char *e __unused */ + const char * name_b; + const char * name_e; + printf("#define of %V\n",String(b,e)); + + /* The first token is the macro name */ + name_b = skipspace(cfs, b, e); + + /* Find the end of the name by finding the first white space char or '(' */ + for(name_e = name_b; (name_e < e); name_e++) { + /* Object like macro */ + if ((isspace(*name_e)) || + /* XXX This is ugly; any better way to do this? */ + ((name_e + 1 < e) && ((name_e[1] == '\\') && (name_e[2] == 's')))) { + + printf("Defining object macro name %V\n",String(name_b,name_e)); + } + /* Function like macro */ + else if (*name_e == '(') { + printf("Defining function macro name %V\n",String(name_b,name_e)); + } + else + continue; + } + } static void @@ -245,6 +273,7 @@ /* struct cppfilestate *cfs __unused, const char *h __unused, const char *b __unused, const char *e __unused */ printf("#undef of %V\n",String(b,e)); + } static void ==== //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/k.c#10 (text+ko) ==== ==== //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/k.h#7 (text+ko) ==== ==== //depot/projects/soc2006/swhitman-K_Kernel_Meta-Language/k/lexer.c#8 (text+ko) ==== @@ -149,7 +149,7 @@ un_hash(const char *s, const char *e) { const char *r; - char *p; /*, *q;*/ /* XXX Q seems unneccessary (just a memory leak) */ + char *p; /*, *q;*/ /* XXX q seems unneccessary (just a memory leak) */ int same = 1; /*q =*/ p = malloc(1 + (e - s)); @@ -283,7 +283,7 @@ continue; case '#': - /* XXX Not quite sure what this case does */ + /* Stringification (?) */ printf("# %V\n", String(b, e)); u = strtoul(b + 1, &q, 0); if (q == NULL)