wpp will currently silently drop non-preprocessor stuff (typedefs, function
prototypes etc.) when #including a .c or .h file. However, if you preprocess
e.g. a .rc file externally and then feed it to wrc (which in turn will feed
it through wpp) the non-preprocessor stuff isn't removed. The patch below
changes that, by looking at the filename on the #line directive. If it ends in
.c or .h, no output is generated (but the file is still parsed for preproc
statements ofcourse).
We need this for ReactOS, it doesn't hurt Wine (yes, I've tested it <g>) and
including it in Wine would make my monthly job of merging Wine and ReactOS a
tad easier. If there are no objections I'll submit to wine-patches in a few
days.
We also have another change in wpp, which adds support for #include_next (can't
take credit for that, Filip Navara wrote it). Since you can't use that
#include_next in Wine anyway (not every compiler supports it) I'm not going
to bother creating and testing a Wine patch for it. If I misjudged and there
is interest in this from the Wine side just let me know.
Ge van Geldorp.
Index: libs/wpp/ppl.l
===================================================================
RCS file: /home/wine/wine/libs/wpp/ppl.l,v
retrieving revision 1.4
diff -u -r1.4 ppl.l
--- libs/wpp/ppl.l 21 Oct 2003 23:57:25 -0000 1.4
+++ libs/wpp/ppl.l 20 Feb 2005 15:12:10 -0000
@@ -232,6 +232,7 @@
static void newline(int);
static int make_number(int radix, YYSTYPE *val, const char *str, int len);
static void put_buffer(const char *s, int len);
+static int is_c_h_include(char *fname, int quoted);
/* Buffer management */
static void push_buffer(pp_entry_t *ppp, char *filename, char *incname, int pop);
static bufferstackentry_t *pop_buffer(void);
@@ -551,11 +552,15 @@
case pp_define:
case pp_mbody:
case pp_inc:
- case pp_line:
case RCINCL:
if (yy_current_state()==RCINCL) yy_pop_state();
pplval.cptr = get_string();
return tDQSTRING;
+ case pp_line:
+ pplval.cptr = get_string();
+ if (is_c_h_include(pplval.cptr, 1)) pass_data=0;
+ else pass_data=1;
+ return tDQSTRING;
default:
put_string();
}
@@ -1404,12 +1409,12 @@
* Include management
*-------------------------------------------------------------------------
*/
-static int is_c_h_include(char *fname)
+static int is_c_h_include(char *fname, int quoted)
{
int sl=strlen(fname);
- if (sl < 2) return 0;
- if ((toupper(fname[sl-1])!='H') && (toupper(fname[sl-1])!='C')) return 0;
- if (fname[sl-2]!='.') return 0;
+ if (sl < 2 + 2 * quoted) return 0;
+ if ((toupper(fname[sl-1-quoted])!='H') && (toupper(fname[sl-1-quoted])!='C')) return 0;
+ if (fname[sl-2-quoted]!='.') return 0;
return 1;
}
@@ -1448,7 +1453,7 @@
pp_incl_state.seen_junk = 0;
pp_incl_state.state = 0;
pp_incl_state.ppp = NULL;
- if (is_c_h_include(newpath)) pass_data=0;
+ if (is_c_h_include(newpath, 0)) pass_data=0;
else pass_data=1;
if(pp_status.debug)