Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
46caa0d2
Commit
46caa0d2
authored
Feb 07, 2011
by
Matteo Bruni
Committed by
Alexandre Julliard
Feb 21, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wpp: Let pp_add_define take the responsibility of copying strings (Valgrind).
parent
e32598b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
22 deletions
+29
-22
ppy.y
libs/wpp/ppy.y
+1
-1
preproc.c
libs/wpp/preproc.c
+22
-15
wpp.c
libs/wpp/wpp.c
+5
-5
wpp_private.h
libs/wpp/wpp_private.h
+1
-1
No files found.
libs/wpp/ppy.y
View file @
46caa0d2
...
@@ -275,7 +275,7 @@ preprocessor
...
@@ -275,7 +275,7 @@ preprocessor
}
}
}
}
| tUNDEF tIDENT tNL { pp_del_define($2); free($2); }
| tUNDEF tIDENT tNL { pp_del_define($2); free($2); }
| tDEFINE opt_text tNL { pp_add_define($1, $2); }
| tDEFINE opt_text tNL { pp_add_define($1, $2);
free($1); free($2);
}
| tMACRO res_arg allmargs tMACROEND opt_mtexts tNL {
| tMACRO res_arg allmargs tMACROEND opt_mtexts tNL {
pp_add_macro($1, macro_args, nmacro_args, $5);
pp_add_macro($1, macro_args, nmacro_args, $5);
}
}
...
...
libs/wpp/preproc.c
View file @
46caa0d2
...
@@ -319,7 +319,7 @@ void pp_del_define(const char *name)
...
@@ -319,7 +319,7 @@ void pp_del_define(const char *name)
printf
(
"Deleted (%s, %d) <%s>
\n
"
,
pp_status
.
input
,
pp_status
.
line_number
,
name
);
printf
(
"Deleted (%s, %d) <%s>
\n
"
,
pp_status
.
input
,
pp_status
.
line_number
,
name
);
}
}
pp_entry_t
*
pp_add_define
(
c
har
*
def
,
char
*
text
)
pp_entry_t
*
pp_add_define
(
c
onst
char
*
def
,
const
char
*
text
)
{
{
int
len
;
int
len
;
char
*
cptr
;
char
*
cptr
;
...
@@ -339,38 +339,45 @@ pp_entry_t *pp_add_define(char *def, char *text)
...
@@ -339,38 +339,45 @@ pp_entry_t *pp_add_define(char *def, char *text)
if
(
!
ppp
)
if
(
!
ppp
)
return
NULL
;
return
NULL
;
memset
(
ppp
,
0
,
sizeof
(
*
ppp
)
);
memset
(
ppp
,
0
,
sizeof
(
*
ppp
)
);
ppp
->
ident
=
def
;
ppp
->
ident
=
pp_xstrdup
(
def
);
if
(
!
ppp
->
ident
)
goto
error
;
ppp
->
type
=
def_define
;
ppp
->
type
=
def_define
;
ppp
->
subst
.
text
=
text
;
ppp
->
subst
.
text
=
text
?
pp_xstrdup
(
text
)
:
NULL
;
if
(
text
&&
!
ppp
->
subst
.
text
)
goto
error
;
ppp
->
filename
=
pp_xstrdup
(
pp_status
.
input
?
pp_status
.
input
:
"<internal or cmdline>"
);
ppp
->
filename
=
pp_xstrdup
(
pp_status
.
input
?
pp_status
.
input
:
"<internal or cmdline>"
);
if
(
!
ppp
->
filename
)
if
(
!
ppp
->
filename
)
{
goto
error
;
free
(
ppp
);
return
NULL
;
}
ppp
->
linenumber
=
pp_status
.
input
?
pp_status
.
line_number
:
0
;
ppp
->
linenumber
=
pp_status
.
input
?
pp_status
.
line_number
:
0
;
ppp
->
next
=
pp_def_state
->
defines
[
idx
];
ppp
->
next
=
pp_def_state
->
defines
[
idx
];
pp_def_state
->
defines
[
idx
]
=
ppp
;
pp_def_state
->
defines
[
idx
]
=
ppp
;
if
(
ppp
->
next
)
if
(
ppp
->
next
)
ppp
->
next
->
prev
=
ppp
;
ppp
->
next
->
prev
=
ppp
;
if
(
text
)
if
(
ppp
->
subst
.
text
)
{
{
/* Strip trailing white space from subst text */
/* Strip trailing white space from subst text */
len
=
strlen
(
text
);
len
=
strlen
(
ppp
->
subst
.
text
);
while
(
len
&&
strchr
(
"
\t\r\n
"
,
text
[
len
-
1
]))
while
(
len
&&
strchr
(
"
\t\r\n
"
,
ppp
->
subst
.
text
[
len
-
1
]))
{
{
text
[
--
len
]
=
'\0'
;
ppp
->
subst
.
text
[
--
len
]
=
'\0'
;
}
}
/* Strip leading white space from subst text */
/* Strip leading white space from subst text */
for
(
cptr
=
text
;
*
cptr
&&
strchr
(
"
\t\r
"
,
*
cptr
);
cptr
++
)
for
(
cptr
=
ppp
->
subst
.
text
;
*
cptr
&&
strchr
(
"
\t\r
"
,
*
cptr
);
cptr
++
)
;
;
if
(
text
!=
cptr
)
if
(
ppp
->
subst
.
text
!=
cptr
)
memmove
(
text
,
cptr
,
strlen
(
cptr
)
+
1
);
memmove
(
ppp
->
subst
.
text
,
cptr
,
strlen
(
cptr
)
+
1
);
}
}
if
(
pp_status
.
debug
)
if
(
pp_status
.
debug
)
printf
(
"Added define (%s, %d) <%s> to <%s>
\n
"
,
pp_status
.
input
,
pp_status
.
line_number
,
ppp
->
ident
,
text
?
text
:
"(null)"
);
printf
(
"Added define (%s, %d) <%s> to <%s>
\n
"
,
pp_status
.
input
,
pp_status
.
line_number
,
ppp
->
ident
,
ppp
->
subst
.
text
?
ppp
->
subst
.
text
:
"(null)"
);
return
ppp
;
return
ppp
;
error
:
free
(
ppp
->
ident
);
free
(
ppp
->
subst
.
text
);
free
(
ppp
);
return
NULL
;
}
}
pp_entry_t
*
pp_add_macro
(
char
*
id
,
marg_t
*
args
[],
int
nargs
,
mtext_t
*
exp
)
pp_entry_t
*
pp_add_macro
(
char
*
id
,
marg_t
*
args
[],
int
nargs
,
mtext_t
*
exp
)
...
...
libs/wpp/wpp.c
View file @
46caa0d2
...
@@ -45,7 +45,7 @@ static void add_cmdline_defines(void)
...
@@ -45,7 +45,7 @@ static void add_cmdline_defines(void)
for
(
def
=
cmdline_defines
;
def
;
def
=
def
->
next
)
for
(
def
=
cmdline_defines
;
def
;
def
=
def
->
next
)
{
{
if
(
def
->
value
)
pp_add_define
(
pp_xstrdup
(
def
->
name
),
pp_xstrdup
(
def
->
value
)
);
if
(
def
->
value
)
pp_add_define
(
def
->
name
,
def
->
value
);
}
}
}
}
...
@@ -56,16 +56,16 @@ static void add_special_defines(void)
...
@@ -56,16 +56,16 @@ static void add_special_defines(void)
char
buf
[
32
];
char
buf
[
32
];
strftime
(
buf
,
sizeof
(
buf
),
"
\"
%b %d %Y
\"
"
,
localtime
(
&
now
));
strftime
(
buf
,
sizeof
(
buf
),
"
\"
%b %d %Y
\"
"
,
localtime
(
&
now
));
pp_add_define
(
pp_xstrdup
(
"__DATE__"
),
pp_xstrdup
(
buf
)
);
pp_add_define
(
"__DATE__"
,
buf
);
strftime
(
buf
,
sizeof
(
buf
),
"
\"
%H:%M:%S
\"
"
,
localtime
(
&
now
));
strftime
(
buf
,
sizeof
(
buf
),
"
\"
%H:%M:%S
\"
"
,
localtime
(
&
now
));
pp_add_define
(
pp_xstrdup
(
"__TIME__"
),
pp_xstrdup
(
buf
)
);
pp_add_define
(
"__TIME__"
,
buf
);
ppp
=
pp_add_define
(
pp_xstrdup
(
"__FILE__"
),
pp_xstrdup
(
""
)
);
ppp
=
pp_add_define
(
"__FILE__"
,
""
);
if
(
ppp
)
if
(
ppp
)
ppp
->
type
=
def_special
;
ppp
->
type
=
def_special
;
ppp
=
pp_add_define
(
pp_xstrdup
(
"__LINE__"
),
pp_xstrdup
(
""
)
);
ppp
=
pp_add_define
(
"__LINE__"
,
""
);
if
(
ppp
)
if
(
ppp
)
ppp
->
type
=
def_special
;
ppp
->
type
=
def_special
;
}
}
...
...
libs/wpp/wpp_private.h
View file @
46caa0d2
...
@@ -204,7 +204,7 @@ char *pp_xstrdup(const char *str);
...
@@ -204,7 +204,7 @@ char *pp_xstrdup(const char *str);
pp_entry_t
*
pplookup
(
const
char
*
ident
);
pp_entry_t
*
pplookup
(
const
char
*
ident
);
int
pp_push_define_state
(
void
);
int
pp_push_define_state
(
void
);
void
pp_pop_define_state
(
void
);
void
pp_pop_define_state
(
void
);
pp_entry_t
*
pp_add_define
(
c
har
*
def
,
char
*
text
);
pp_entry_t
*
pp_add_define
(
c
onst
char
*
def
,
const
char
*
text
);
pp_entry_t
*
pp_add_macro
(
char
*
ident
,
marg_t
*
args
[],
int
nargs
,
mtext_t
*
exp
);
pp_entry_t
*
pp_add_macro
(
char
*
ident
,
marg_t
*
args
[],
int
nargs
,
mtext_t
*
exp
);
void
pp_del_define
(
const
char
*
name
);
void
pp_del_define
(
const
char
*
name
);
void
*
pp_open_include
(
const
char
*
name
,
const
char
*
parent_name
,
char
**
newpath
);
void
*
pp_open_include
(
const
char
*
name
,
const
char
*
parent_name
,
char
**
newpath
);
...
...
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