Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
4f432e05
Commit
4f432e05
authored
Jul 01, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a new list of defined symbols when parsing a file, to allow
recursive parsing of multiple files.
parent
4433f155
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
33 deletions
+118
-33
preproc.c
libs/wpp/preproc.c
+62
-28
wpp.c
libs/wpp/wpp.c
+54
-5
wpp_private.h
libs/wpp/wpp_private.h
+2
-0
No files found.
libs/wpp/preproc.c
View file @
4f432e05
...
...
@@ -33,15 +33,22 @@
struct
pp_status
pp_status
;
#define HASHKEY 2039
static
pp_entry_t
*
pp_defines
[
HASHKEY
];
typedef
struct
pp_def_state
{
struct
pp_def_state
*
next
;
pp_entry_t
*
defines
[
HASHKEY
];
}
pp_def_state_t
;
static
pp_def_state_t
*
pp_def_state
;
#define MAXIFSTACK 64
static
pp_if_state_t
if_stack
[
MAXIFSTACK
];
static
int
if_stack_idx
=
0
;
#if 0
void pp_status(void) __attribute__((destructor));
void pp_status(void)
void pp_
print_
status(void) __attribute__((destructor));
void pp_
print_
status(void)
{
int i;
int sum;
...
...
@@ -52,10 +59,10 @@ void pp_status(void)
for(i = 0; i < HASHKEY; i++)
{
sum = 0;
for(ppp = pp_defines[i]; ppp; ppp = ppp->next)
for(ppp = pp_def
_state->def
ines[i]; ppp; ppp = ppp->next)
sum++;
total += sum;
fprintf(stderr, "%4d, %3d\n", i, sum);
if (sum)
fprintf(stderr, "%4d, %3d\n", i, sum);
}
fprintf(stderr, "Total defines: %d\n", total);
}
...
...
@@ -112,7 +119,7 @@ pp_entry_t *pplookup(const char *ident)
int
idx
=
pphash
(
ident
);
pp_entry_t
*
ppp
;
for
(
ppp
=
pp_defines
[
idx
];
ppp
;
ppp
=
ppp
->
next
)
for
(
ppp
=
pp_def
_state
->
def
ines
[
idx
];
ppp
;
ppp
=
ppp
->
next
)
{
if
(
!
strcmp
(
ident
,
ppp
->
ident
))
return
ppp
;
...
...
@@ -120,22 +127,10 @@ pp_entry_t *pplookup(const char *ident)
return
NULL
;
}
void
pp_del_define
(
const
char
*
name
)
static
void
free_pp_entry
(
pp_entry_t
*
ppp
,
int
idx
)
{
int
idx
;
pp_entry_t
*
ppp
;
if
((
ppp
=
pplookup
(
name
))
==
NULL
)
{
if
(
pp_status
.
pedantic
)
ppwarning
(
"%s was not defined"
,
name
);
return
;
}
if
(
ppp
->
iep
)
{
if
(
pp_status
.
debug
)
fprintf
(
stderr
,
"pp_del_define: %s:%d: includelogic removed, include_ppp='%s', file=%s
\n
"
,
pp_status
.
input
,
pp_status
.
line_number
,
name
,
ppp
->
iep
->
filename
);
if
(
ppp
->
iep
==
pp_includelogiclist
)
{
pp_includelogiclist
=
ppp
->
iep
->
next
;
...
...
@@ -152,12 +147,11 @@ void pp_del_define(const char *name)
free
(
ppp
->
iep
);
}
idx
=
pphash
(
name
);
if
(
pp_defines
[
idx
]
==
ppp
)
if
(
pp_def_state
->
defines
[
idx
]
==
ppp
)
{
pp_defines
[
idx
]
=
ppp
->
next
;
if
(
pp_defines
[
idx
])
pp_defines
[
idx
]
->
prev
=
NULL
;
pp_def
_state
->
def
ines
[
idx
]
=
ppp
->
next
;
if
(
pp_def
_state
->
def
ines
[
idx
])
pp_def
_state
->
def
ines
[
idx
]
->
prev
=
NULL
;
}
else
{
...
...
@@ -167,6 +161,46 @@ void pp_del_define(const char *name)
}
free
(
ppp
);
}
/* push a new (empty) define state */
void
pp_push_define_state
(
void
)
{
pp_def_state_t
*
state
=
pp_xmalloc
(
sizeof
(
*
state
)
);
memset
(
state
->
defines
,
0
,
sizeof
(
state
->
defines
)
);
state
->
next
=
pp_def_state
;
pp_def_state
=
state
;
}
/* pop the current define state */
void
pp_pop_define_state
(
void
)
{
int
i
;
pp_entry_t
*
ppp
;
pp_def_state_t
*
state
;
for
(
i
=
0
;
i
<
HASHKEY
;
i
++
)
{
while
((
ppp
=
pp_def_state
->
defines
[
i
])
!=
NULL
)
free_pp_entry
(
ppp
,
i
);
}
state
=
pp_def_state
;
pp_def_state
=
state
->
next
;
free
(
state
);
}
void
pp_del_define
(
const
char
*
name
)
{
pp_entry_t
*
ppp
;
if
((
ppp
=
pplookup
(
name
))
==
NULL
)
{
if
(
pp_status
.
pedantic
)
ppwarning
(
"%s was not defined"
,
name
);
return
;
}
free_pp_entry
(
ppp
,
pphash
(
name
)
);
if
(
pp_status
.
debug
)
printf
(
"Deleted (%s, %d) <%s>
\n
"
,
pp_status
.
input
,
pp_status
.
line_number
,
name
);
...
...
@@ -192,8 +226,8 @@ pp_entry_t *pp_add_define(char *def, char *text)
ppp
->
subst
.
text
=
text
;
ppp
->
filename
=
pp_status
.
input
?
pp_xstrdup
(
pp_status
.
input
)
:
"<internal or cmdline>"
;
ppp
->
linenumber
=
pp_status
.
input
?
pp_status
.
line_number
:
0
;
ppp
->
next
=
pp_defines
[
idx
];
pp_defines
[
idx
]
=
ppp
;
ppp
->
next
=
pp_def
_state
->
def
ines
[
idx
];
pp_def
_state
->
def
ines
[
idx
]
=
ppp
;
if
(
ppp
->
next
)
ppp
->
next
->
prev
=
ppp
;
if
(
text
)
...
...
@@ -236,8 +270,8 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
ppp
->
subst
.
mtext
=
exp
;
ppp
->
filename
=
pp_status
.
input
?
pp_xstrdup
(
pp_status
.
input
)
:
"<internal or cmdline>"
;
ppp
->
linenumber
=
pp_status
.
input
?
pp_status
.
line_number
:
0
;
ppp
->
next
=
pp_defines
[
idx
];
pp_defines
[
idx
]
=
ppp
;
ppp
->
next
=
pp_def
_state
->
def
ines
[
idx
];
pp_def
_state
->
def
ines
[
idx
]
=
ppp
;
if
(
ppp
->
next
)
ppp
->
next
->
prev
=
ppp
;
...
...
libs/wpp/wpp.c
View file @
4f432e05
...
...
@@ -30,6 +30,25 @@
int
ppdebug
;
struct
define
{
struct
define
*
next
;
char
*
name
;
char
*
value
;
};
static
struct
define
*
cmdline_defines
;
static
void
add_cmdline_defines
(
void
)
{
struct
define
*
def
;
for
(
def
=
cmdline_defines
;
def
;
def
=
def
->
next
)
{
if
(
def
->
value
)
pp_add_define
(
pp_xstrdup
(
def
->
name
),
pp_xstrdup
(
def
->
value
)
);
}
}
static
void
add_special_defines
(
void
)
{
time_t
now
=
time
(
NULL
);
...
...
@@ -53,15 +72,42 @@ static void add_special_defines(void)
/* add a define to the preprocessor list */
void
wpp_add_define
(
const
char
*
name
,
const
char
*
value
)
{
struct
define
*
def
;
if
(
!
value
)
value
=
""
;
pp_add_define
(
pp_xstrdup
(
name
),
pp_xstrdup
(
value
)
);
for
(
def
=
cmdline_defines
;
def
;
def
=
def
->
next
)
{
if
(
!
strcmp
(
def
->
name
,
name
))
{
if
(
def
->
value
)
free
(
def
->
value
);
def
->
value
=
pp_xstrdup
(
value
);
return
;
}
}
def
=
pp_xmalloc
(
sizeof
(
*
def
)
);
def
->
next
=
cmdline_defines
;
def
->
name
=
pp_xstrdup
(
name
);
def
->
value
=
pp_xstrdup
(
value
);
cmdline_defines
=
def
;
}
/* undefine a previously added definition */
void
wpp_del_define
(
const
char
*
valu
e
)
void
wpp_del_define
(
const
char
*
nam
e
)
{
pp_del_define
(
value
);
struct
define
*
def
;
for
(
def
=
cmdline_defines
;
def
;
def
=
def
->
next
)
{
if
(
!
strcmp
(
def
->
name
,
name
))
{
if
(
def
->
value
)
free
(
def
->
value
);
def
->
value
=
NULL
;
return
;
}
}
}
...
...
@@ -71,8 +117,8 @@ void wpp_add_cmdline_define( const char *value )
char
*
str
=
pp_xstrdup
(
value
);
char
*
p
=
strchr
(
str
,
'='
);
if
(
p
)
*
p
++
=
0
;
else
p
=
""
;
pp_add_define
(
str
,
pp_xstrdup
(
p
)
);
wpp_add_define
(
str
,
p
)
;
free
(
str
);
}
...
...
@@ -97,6 +143,8 @@ int wpp_parse( const char *input, FILE *output )
{
int
ret
;
pp_push_define_state
();
add_cmdline_defines
();
add_special_defines
();
if
(
!
input
)
ppin
=
stdin
;
...
...
@@ -114,6 +162,7 @@ int wpp_parse( const char *input, FILE *output )
ret
=
ppparse
();
if
(
input
)
fclose
(
ppin
);
pp_pop_define_state
();
return
ret
;
}
...
...
libs/wpp/wpp_private.h
View file @
4f432e05
...
...
@@ -195,6 +195,8 @@ void *pp_xmalloc(size_t);
void
*
pp_xrealloc
(
void
*
,
size_t
);
char
*
pp_xstrdup
(
const
char
*
str
);
pp_entry_t
*
pplookup
(
const
char
*
ident
);
void
pp_push_define_state
(
void
);
void
pp_pop_define_state
(
void
);
pp_entry_t
*
pp_add_define
(
char
*
def
,
char
*
text
);
pp_entry_t
*
pp_add_macro
(
char
*
ident
,
marg_t
*
args
[],
int
nargs
,
mtext_t
*
exp
);
void
pp_del_define
(
const
char
*
name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment