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
97ca9f8a
Commit
97ca9f8a
authored
Sep 28, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Add a shared header for common helper functions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e4766cad
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
226 additions
and
694 deletions
+226
-694
configure
configure
+1
-1
configure.ac
configure.ac
+1
-1
make_xftmpl.c
tools/make_xftmpl.c
+8
-11
makedep.c
tools/makedep.c
+1
-150
sfnt2fon.c
tools/sfnt2fon/sfnt2fon.c
+5
-8
tools.h
tools/tools.h
+204
-0
utils.c
tools/widl/utils.c
+0
-63
utils.h
tools/widl/utils.h
+0
-21
widl.h
tools/widl/widl.h
+1
-0
build.h
tools/winebuild/build.h
+1
-33
utils.c
tools/winebuild/utils.c
+0
-116
utils.c
tools/winegcc/utils.c
+0
-114
utils.h
tools/winegcc/utils.h
+1
-26
utils.c
tools/wmc/utils.c
+0
-63
utils.h
tools/wmc/utils.h
+1
-12
utils.c
tools/wrc/utils.c
+0
-63
utils.h
tools/wrc/utils.h
+0
-12
wpp_private.h
tools/wrc/wpp_private.h
+1
-0
wrc.h
tools/wrc/wrc.h
+1
-0
No files found.
configure
View file @
97ca9f8a
...
...
@@ -21997,7 +21997,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
wine_fn_output_makedep ()
{
as_dir=tools; as_fn_mkdir_p
$CC
-Iinclude -I
$srcdir
/include -D__WINESRC__
$EXTRACFLAGS
$CPPFLAGS
$CFLAGS
-o tools/makedep
$ac_exeext
$srcdir
/tools/makedep.c
$LDFLAGS
$CC
-I
$srcdir
/tools -I
include -I
$srcdir
/include -D__WINESRC__
$EXTRACFLAGS
$CPPFLAGS
$CFLAGS
-o tools/makedep
$ac_exeext
$srcdir
/tools/makedep.c
$LDFLAGS
}
wine_fn_output_makefile ()
{
...
...
configure.ac
View file @
97ca9f8a
...
...
@@ -4013,7 +4013,7 @@ then
[wine_fn_output_makedep ()
{
AS_MKDIR_P(tools)
$CC -Iinclude -I$srcdir/include -D__WINESRC__ $EXTRACFLAGS $CPPFLAGS $CFLAGS -o tools/makedep$ac_exeext $srcdir/tools/makedep.c $LDFLAGS
$CC -I
$srcdir/tools -I
include -I$srcdir/include -D__WINESRC__ $EXTRACFLAGS $CPPFLAGS $CFLAGS -o tools/makedep$ac_exeext $srcdir/tools/makedep.c $LDFLAGS
}])
fi
...
...
tools/make_xftmpl.c
View file @
97ca9f8a
...
...
@@ -34,6 +34,7 @@
#include "windef.h"
#include "guiddef.h"
#include "tools.h"
#define TOKEN_NAME 1
#define TOKEN_STRING 2
...
...
@@ -104,10 +105,6 @@ static FILE *outfile;
static
BYTE
*
output_data
;
static
UINT
output_pos
,
output_size
;
#ifndef __GNUC__
#define __attribute__(x)
#endif
static
void
fatal_error
(
const
char
*
msg
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
static
void
fatal_error
(
const
char
*
msg
,
...
)
...
...
@@ -362,12 +359,12 @@ static BOOL parse_token(void)
if
(
!
strcmp
(
tok
,
"name"
))
{
tok
=
strtok
(
NULL
,
"
\t
"
);
if
(
tok
&&
!
option_inc_var_name
)
option_inc_var_name
=
strdup
(
tok
);
if
(
tok
&&
!
option_inc_var_name
)
option_inc_var_name
=
x
strdup
(
tok
);
}
else
if
(
!
strcmp
(
tok
,
"size"
))
{
tok
=
strtok
(
NULL
,
"
\t
"
);
if
(
tok
&&
!
option_inc_size_name
)
option_inc_size_name
=
strdup
(
tok
);
if
(
tok
&&
!
option_inc_size_name
)
option_inc_size_name
=
x
strdup
(
tok
);
}
return
TRUE
;
...
...
@@ -438,13 +435,13 @@ static char **parse_options(int argc, char **argv)
break
;
case
'i'
:
option_header
=
TRUE
;
option_inc_var_name
=
strdup
(
optarg
);
option_inc_var_name
=
x
strdup
(
optarg
);
break
;
case
'o'
:
option_outfile_name
=
strdup
(
optarg
);
option_outfile_name
=
x
strdup
(
optarg
);
break
;
case
's'
:
option_inc_size_name
=
strdup
(
optarg
);
option_inc_size_name
=
x
strdup
(
optarg
);
break
;
}
}
...
...
@@ -539,9 +536,9 @@ int main(int argc, char **argv)
header_name
=
strrchr
(
option_outfile_name
,
'/'
);
if
(
header_name
)
header_name
=
strdup
(
header_name
+
1
);
header_name
=
x
strdup
(
header_name
+
1
);
else
header_name
=
strdup
(
option_outfile_name
);
header_name
=
x
strdup
(
option_outfile_name
);
if
(
!
header_name
)
{
fprintf
(
stderr
,
"Out of memory
\n
"
);
goto
error
;
...
...
tools/makedep.c
View file @
97ca9f8a
...
...
@@ -39,15 +39,9 @@
#include <io.h>
#define mkdir(path,mode) mkdir(path)
#endif
#include "tools.h"
#include "wine/list.h"
struct
strarray
{
unsigned
int
count
;
/* strings in use */
unsigned
int
size
;
/* total allocated size */
const
char
**
str
;
};
enum
incl_type
{
INCL_NORMAL
,
/* #include "foo.h" */
...
...
@@ -130,8 +124,6 @@ static const struct
static
struct
list
files
[
HASH_SIZE
];
static
const
struct
strarray
empty_strarray
;
enum
install_rules
{
INSTALL_LIB
,
INSTALL_DEV
,
NB_INSTALL_RULES
};
/* variables common to all makefiles */
...
...
@@ -256,10 +248,6 @@ static const char Usage[] =
" -fxxx Store output in file 'xxx' (default: Makefile)
\n
"
;
#ifndef __GNUC__
#define __attribute__(x)
#endif
static
void
fatal_error
(
const
char
*
msg
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
static
void
fatal_perror
(
const
char
*
msg
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
static
void
output
(
const
char
*
format
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
...
...
@@ -326,76 +314,6 @@ static void exit_on_signal( int sig )
/*******************************************************************
* xmalloc
*/
static
void
*
xmalloc
(
size_t
size
)
{
void
*
res
;
if
(
!
(
res
=
malloc
(
size
?
size
:
1
)))
fatal_error
(
"Virtual memory exhausted.
\n
"
);
return
res
;
}
/*******************************************************************
* xrealloc
*/
static
void
*
xrealloc
(
void
*
ptr
,
size_t
size
)
{
void
*
res
;
assert
(
size
);
if
(
!
(
res
=
realloc
(
ptr
,
size
)))
fatal_error
(
"Virtual memory exhausted.
\n
"
);
return
res
;
}
/*******************************************************************
* xstrdup
*/
static
char
*
xstrdup
(
const
char
*
str
)
{
char
*
res
=
strdup
(
str
);
if
(
!
res
)
fatal_error
(
"Virtual memory exhausted.
\n
"
);
return
res
;
}
/*******************************************************************
* strmake
*/
static
char
*
strmake
(
const
char
*
fmt
,
...
)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
for
(;;)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
xrealloc
(
p
,
n
+
1
);
free
(
p
);
}
}
/*******************************************************************
* strendswith
*/
static
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
size_t
l
=
strlen
(
str
);
size_t
m
=
strlen
(
end
);
return
l
>=
m
&&
strcmp
(
str
+
l
-
m
,
end
)
==
0
;
}
/*******************************************************************
* output
*/
static
void
output
(
const
char
*
format
,
...
)
...
...
@@ -413,64 +331,6 @@ static void output( const char *format, ... )
/*******************************************************************
* strarray_add
*/
static
void
strarray_add
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
array
->
count
==
array
->
size
)
{
if
(
array
->
size
)
array
->
size
*=
2
;
else
array
->
size
=
16
;
array
->
str
=
xrealloc
(
array
->
str
,
sizeof
(
array
->
str
[
0
])
*
array
->
size
);
}
array
->
str
[
array
->
count
++
]
=
str
;
}
/*******************************************************************
* strarray_addall
*/
static
void
strarray_addall
(
struct
strarray
*
array
,
struct
strarray
added
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
added
.
count
;
i
++
)
strarray_add
(
array
,
added
.
str
[
i
]
);
}
/*******************************************************************
* strarray_exists
*/
static
int
strarray_exists
(
const
struct
strarray
*
array
,
const
char
*
str
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
array
->
count
;
i
++
)
if
(
!
strcmp
(
array
->
str
[
i
],
str
))
return
1
;
return
0
;
}
/*******************************************************************
* strarray_add_uniq
*/
static
void
strarray_add_uniq
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
!
strarray_exists
(
array
,
str
))
strarray_add
(
array
,
str
);
}
/*******************************************************************
* strarray_addall_uniq
*/
static
void
strarray_addall_uniq
(
struct
strarray
*
array
,
struct
strarray
added
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
added
.
count
;
i
++
)
strarray_add_uniq
(
array
,
added
.
str
[
i
]
);
}
/*******************************************************************
* strarray_get_value
*
* Find a value in a name/value pair string array.
...
...
@@ -520,15 +380,6 @@ static void strarray_set_value( struct strarray *array, const char *name, const
/*******************************************************************
* strarray_set_qsort
*/
static
void
strarray_qsort
(
struct
strarray
*
array
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
)
{
if
(
array
->
count
)
qsort
(
array
->
str
,
array
->
count
,
sizeof
(
*
array
->
str
),
(
void
*
)
func
);
}
/*******************************************************************
* normalize_arch
*/
static
const
char
*
normalize_arch
(
const
char
*
arch
)
...
...
tools/sfnt2fon/sfnt2fon.c
View file @
97ca9f8a
...
...
@@ -45,6 +45,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "basetsd.h"
#include "../tools.h"
#include "pshpack1.h"
...
...
@@ -449,10 +450,6 @@ static void usage(char **argv)
fprintf
(
stderr
,
" -s Single .fnt file mode
\n
"
);
}
#ifndef __GNUC__
#define __attribute__(X)
#endif
/* atexit handler to cleanup files */
static
void
cleanup
(
void
)
{
...
...
@@ -580,7 +577,7 @@ static struct fontinfo *fill_fontinfo( const char *face_name, int ppem, int enc,
fprintf
(
stderr
,
"Can't find EBLC table
\n
"
);
else
{
eblc
=
malloc
(
needed
);
eblc
=
x
malloc
(
needed
);
FT_Load_Sfnt_Table
(
face
,
TTAG_EBLC
,
0
,
(
FT_Byte
*
)
eblc
,
&
needed
);
num_sizes
=
GET_BE_DWORD
(
&
eblc
->
numSizes
);
...
...
@@ -841,7 +838,7 @@ static char **parse_options( int argc, char **argv )
option_defchar
=
atoi
(
optarg
);
break
;
case
'o'
:
option_output
=
strdup
(
optarg
);
option_output
=
x
strdup
(
optarg
);
break
;
case
'q'
:
option_quiet
=
1
;
...
...
@@ -903,7 +900,7 @@ int main(int argc, char **argv)
if
(
option_fnt_mode
&&
num_files
>
1
)
error
(
"can only specify one font in .fnt mode
\n
"
);
info
=
malloc
(
num_files
*
sizeof
(
*
info
)
);
info
=
x
malloc
(
num_files
*
sizeof
(
*
info
)
);
for
(
i
=
0
;
i
<
num_files
;
i
++
)
{
int
ppem
,
enc
,
avg_width
;
...
...
@@ -978,7 +975,7 @@ int main(int argc, char **argv)
char
*
p
=
strrchr
(
input_file
,
'/'
);
if
(
p
)
p
++
;
else
p
=
input_file
;
option_output
=
malloc
(
strlen
(
p
)
+
sizeof
(
".fon"
)
);
option_output
=
x
malloc
(
strlen
(
p
)
+
sizeof
(
".fon"
)
);
strcpy
(
option_output
,
p
);
p
=
strrchr
(
option_output
,
'.'
);
if
(
!
p
)
p
=
option_output
+
strlen
(
option_output
);
...
...
tools/tools.h
0 → 100644
View file @
97ca9f8a
/*
* Helper functions for the Wine tools
*
* Copyright 2021 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_TOOLS_H
#define __WINE_TOOLS_H
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(__GNUC__) && !defined(__attribute__)
#define __attribute__(x)
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
static
inline
void
*
xmalloc
(
size_t
size
)
{
void
*
res
=
malloc
(
size
?
size
:
1
);
if
(
res
==
NULL
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
exit
(
1
);
}
return
res
;
}
static
inline
void
*
xrealloc
(
void
*
ptr
,
size_t
size
)
{
void
*
res
=
realloc
(
ptr
,
size
);
if
(
size
&&
res
==
NULL
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
exit
(
1
);
}
return
res
;
}
static
inline
char
*
xstrdup
(
const
char
*
str
)
{
return
strcpy
(
xmalloc
(
strlen
(
str
)
+
1
),
str
);
}
static
inline
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
int
l
=
strlen
(
str
);
int
m
=
strlen
(
end
);
return
l
>=
m
&&
!
strcmp
(
str
+
l
-
m
,
end
);
}
static
char
*
strmake
(
const
char
*
fmt
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
static
inline
char
*
strmake
(
const
char
*
fmt
,
...
)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
for
(;;)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
p
;
free
(
p
);
}
}
/* string array functions */
struct
strarray
{
unsigned
int
count
;
/* strings in use */
unsigned
int
size
;
/* total allocated size */
const
char
**
str
;
};
static
const
struct
strarray
empty_strarray
;
static
inline
void
strarray_add
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
array
->
count
==
array
->
size
)
{
if
(
array
->
size
)
array
->
size
*=
2
;
else
array
->
size
=
16
;
array
->
str
=
xrealloc
(
array
->
str
,
sizeof
(
array
->
str
[
0
])
*
array
->
size
);
}
array
->
str
[
array
->
count
++
]
=
str
;
}
static
inline
void
strarray_addall
(
struct
strarray
*
array
,
struct
strarray
added
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
added
.
count
;
i
++
)
strarray_add
(
array
,
added
.
str
[
i
]
);
}
static
inline
int
strarray_exists
(
const
struct
strarray
*
array
,
const
char
*
str
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
array
->
count
;
i
++
)
if
(
!
strcmp
(
array
->
str
[
i
],
str
))
return
1
;
return
0
;
}
static
inline
void
strarray_add_uniq
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
!
strarray_exists
(
array
,
str
))
strarray_add
(
array
,
str
);
}
static
inline
void
strarray_addall_uniq
(
struct
strarray
*
array
,
struct
strarray
added
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
added
.
count
;
i
++
)
strarray_add_uniq
(
array
,
added
.
str
[
i
]
);
}
static
inline
struct
strarray
strarray_fromstring
(
const
char
*
str
,
const
char
*
delim
)
{
struct
strarray
array
=
empty_strarray
;
char
*
buf
=
xstrdup
(
str
);
const
char
*
tok
;
for
(
tok
=
strtok
(
buf
,
delim
);
tok
;
tok
=
strtok
(
NULL
,
delim
))
strarray_add
(
&
array
,
xstrdup
(
tok
));
free
(
buf
);
return
array
;
}
static
inline
struct
strarray
strarray_frompath
(
const
char
*
path
)
{
if
(
!
path
)
return
empty_strarray
;
#if defined(_WIN32) && !defined(__CYGWIN__)
return
strarray_fromstring
(
path
,
";"
);
#else
return
strarray_fromstring
(
path
,
":"
);
#endif
}
static
inline
char
*
strarray_tostring
(
struct
strarray
array
,
const
char
*
sep
)
{
char
*
str
;
unsigned
int
i
,
len
=
1
+
(
array
.
count
-
1
)
*
strlen
(
sep
);
if
(
!
array
.
count
)
return
xstrdup
(
""
);
for
(
i
=
0
;
i
<
array
.
count
;
i
++
)
len
+=
strlen
(
array
.
str
[
i
]
);
str
=
xmalloc
(
len
);
strcpy
(
str
,
array
.
str
[
0
]
);
for
(
i
=
1
;
i
<
array
.
count
;
i
++
)
{
strcat
(
str
,
sep
);
strcat
(
str
,
array
.
str
[
i
]
);
}
return
str
;
}
static
inline
void
strarray_qsort
(
struct
strarray
*
array
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
)
{
if
(
array
->
count
)
qsort
(
array
->
str
,
array
->
count
,
sizeof
(
*
array
->
str
),
(
void
*
)
func
);
}
static
inline
const
char
*
strarray_bsearch
(
const
struct
strarray
*
array
,
const
char
*
str
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
)
{
char
**
res
=
NULL
;
if
(
array
->
count
)
res
=
bsearch
(
&
str
,
array
->
str
,
array
->
count
,
sizeof
(
*
array
->
str
),
(
void
*
)
func
);
return
res
?
*
res
:
NULL
;
}
#endif
/* __WINE_TOOLS_H */
tools/widl/utils.c
View file @
97ca9f8a
...
...
@@ -198,53 +198,6 @@ size_t widl_getline(char **linep, size_t *lenp, FILE *fp)
return
n
;
}
void
*
xmalloc
(
size_t
size
)
{
void
*
res
;
assert
(
size
>
0
);
res
=
malloc
(
size
);
if
(
res
==
NULL
)
{
error
(
"Virtual memory exhausted.
\n
"
);
}
memset
(
res
,
0x55
,
size
);
return
res
;
}
void
*
xrealloc
(
void
*
p
,
size_t
size
)
{
void
*
res
;
assert
(
size
>
0
);
res
=
realloc
(
p
,
size
);
if
(
res
==
NULL
)
{
error
(
"Virtual memory exhausted.
\n
"
);
}
return
res
;
}
char
*
strmake
(
const
char
*
fmt
,
...
)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
for
(;;)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
p
;
free
(
p
);
}
}
size_t
strappend
(
char
**
buf
,
size_t
*
len
,
size_t
pos
,
const
char
*
fmt
,
...)
{
size_t
size
;
...
...
@@ -282,22 +235,6 @@ size_t strappend(char **buf, size_t *len, size_t pos, const char* fmt, ...)
return
n
;
}
char
*
xstrdup
(
const
char
*
str
)
{
char
*
s
;
assert
(
str
!=
NULL
);
s
=
xmalloc
(
strlen
(
str
)
+
1
);
return
strcpy
(
s
,
str
);
}
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
int
l
=
strlen
(
str
);
int
m
=
strlen
(
end
);
return
l
>=
m
&&
strcmp
(
str
+
l
-
m
,
end
)
==
0
;
}
/*******************************************************************
* buffer management
*
...
...
tools/widl/utils.h
View file @
97ca9f8a
...
...
@@ -23,19 +23,6 @@
#include "widltypes.h"
#include <stddef.h>
/* size_t */
void
*
xmalloc
(
size_t
);
void
*
xrealloc
(
void
*
,
size_t
);
char
*
xstrdup
(
const
char
*
str
);
int
strendswith
(
const
char
*
str
,
const
char
*
end
);
#ifndef __GNUC__
#define __attribute__(X)
#endif
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
void
parser_error
(
const
char
*
s
)
__attribute__
((
noreturn
));
int
parser_warning
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
void
error_loc
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)))
__attribute__
((
noreturn
));
...
...
@@ -44,7 +31,6 @@ void error_loc_info(const loc_info_t *, const char *s, ...) __attribute__((forma
void
warning
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
void
warning_loc_info
(
const
loc_info_t
*
,
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
2
,
3
)));
void
chat
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
char
*
strmake
(
const
char
*
fmt
,
...)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
size_t
strappend
(
char
**
buf
,
size_t
*
len
,
size_t
pos
,
const
char
*
fmt
,
...)
__attribute__
((
__format__
(
__printf__
,
4
,
5
)));
char
*
dup_basename
(
const
char
*
name
,
const
char
*
ext
);
...
...
@@ -79,11 +65,4 @@ extern void align_output( unsigned int align );
#define MAJORVERSION(version) ((version) & 0xffff)
#define MINORVERSION(version) (((version) >> 16) & 0xffff)
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif
tools/widl/widl.h
View file @
97ca9f8a
...
...
@@ -21,6 +21,7 @@
#ifndef __WIDL_WIDL_H
#define __WIDL_WIDL_H
#include "../tools.h"
#include "widltypes.h"
#include <time.h>
...
...
tools/winebuild/build.h
View file @
97ca9f8a
...
...
@@ -29,16 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#include "../tools.h"
typedef
enum
{
...
...
@@ -169,13 +160,6 @@ static inline int is_pe(void)
return
target_platform
==
PLATFORM_MINGW
||
target_platform
==
PLATFORM_WINDOWS
;
}
struct
strarray
{
unsigned
int
count
;
/* strings in use */
unsigned
int
size
;
/* total allocated size */
const
char
**
str
;
};
/* entry point flags */
#define FLAG_NORELAY 0x0001
/* don't use relay debugging for this function */
#define FLAG_NONAME 0x0002
/* don't export function by name */
...
...
@@ -229,10 +213,6 @@ struct strarray
/* global functions */
#ifndef __GNUC__
#define __attribute__(X)
#endif
#ifndef DECLSPEC_NORETURN
# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
# define DECLSPEC_NORETURN __declspec(noreturn)
...
...
@@ -240,19 +220,7 @@ struct strarray
# define DECLSPEC_NORETURN __attribute__((noreturn))
# endif
#endif
extern
void
*
xmalloc
(
size_t
size
);
extern
void
*
xrealloc
(
void
*
ptr
,
size_t
size
);
extern
char
*
xstrdup
(
const
char
*
str
);
extern
char
*
strupper
(
char
*
s
);
extern
int
strendswith
(
const
char
*
str
,
const
char
*
end
);
extern
char
*
strmake
(
const
char
*
fmt
,
...)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
extern
struct
strarray
strarray_fromstring
(
const
char
*
str
,
const
char
*
delim
);
extern
void
strarray_add
(
struct
strarray
*
array
,
const
char
*
str
);
extern
void
strarray_addall
(
struct
strarray
*
array
,
struct
strarray
args
);
extern
void
strarray_qsort
(
struct
strarray
*
array
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
);
extern
const
char
*
strarray_bsearch
(
const
struct
strarray
*
array
,
const
char
*
str
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
);
extern
DECLSPEC_NORETURN
void
fatal_error
(
const
char
*
msg
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
extern
DECLSPEC_NORETURN
void
fatal_perror
(
const
char
*
msg
,
...
)
...
...
tools/winebuild/utils.c
View file @
97ca9f8a
...
...
@@ -37,7 +37,6 @@
#include "build.h"
static
struct
strarray
tmp_files
;
static
struct
strarray
empty_strarray
;
static
const
char
*
output_file_source_name
;
static
const
struct
...
...
@@ -71,41 +70,6 @@ void cleanup_tmp_files(void)
}
void
*
xmalloc
(
size_t
size
)
{
void
*
res
;
res
=
malloc
(
size
?
size
:
1
);
if
(
res
==
NULL
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
exit
(
1
);
}
return
res
;
}
void
*
xrealloc
(
void
*
ptr
,
size_t
size
)
{
void
*
res
=
realloc
(
ptr
,
size
);
if
(
size
&&
res
==
NULL
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
exit
(
1
);
}
return
res
;
}
char
*
xstrdup
(
const
char
*
str
)
{
char
*
res
=
strdup
(
str
);
if
(
!
res
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
exit
(
1
);
}
return
res
;
}
char
*
strupper
(
char
*
s
)
{
char
*
p
;
...
...
@@ -113,86 +77,6 @@ char *strupper(char *s)
return
s
;
}
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
int
l
=
strlen
(
str
);
int
m
=
strlen
(
end
);
return
l
>=
m
&&
strcmp
(
str
+
l
-
m
,
end
)
==
0
;
}
char
*
strmake
(
const
char
*
fmt
,
...
)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
for
(;;)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
p
;
free
(
p
);
}
}
void
strarray_add
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
array
->
count
==
array
->
size
)
{
if
(
array
->
size
)
array
->
size
*=
2
;
else
array
->
size
=
16
;
array
->
str
=
xrealloc
(
array
->
str
,
sizeof
(
array
->
str
[
0
])
*
array
->
size
);
}
array
->
str
[
array
->
count
++
]
=
str
;
}
void
strarray_addall
(
struct
strarray
*
array
,
struct
strarray
args
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
args
.
count
;
i
++
)
strarray_add
(
array
,
args
.
str
[
i
]
);
}
struct
strarray
strarray_fromstring
(
const
char
*
str
,
const
char
*
delim
)
{
const
char
*
tok
;
struct
strarray
array
=
empty_strarray
;
char
*
buf
=
xstrdup
(
str
);
for
(
tok
=
strtok
(
buf
,
delim
);
tok
;
tok
=
strtok
(
NULL
,
delim
))
strarray_add
(
&
array
,
xstrdup
(
tok
));
free
(
buf
);
return
array
;
}
static
struct
strarray
strarray_frompath
(
const
char
*
path
)
{
if
(
!
path
)
return
empty_strarray
;
#if defined(_WIN32) && !defined(__CYGWIN__)
return
strarray_fromstring
(
path
,
";"
);
#else
return
strarray_fromstring
(
path
,
":"
);
#endif
}
void
strarray_qsort
(
struct
strarray
*
array
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
)
{
if
(
array
->
count
)
qsort
(
array
->
str
,
array
->
count
,
sizeof
(
*
array
->
str
),
(
void
*
)
func
);
}
const
char
*
strarray_bsearch
(
const
struct
strarray
*
array
,
const
char
*
str
,
int
(
*
func
)(
const
char
**
,
const
char
**
)
)
{
char
**
res
=
NULL
;
if
(
array
->
count
)
res
=
bsearch
(
&
str
,
array
->
str
,
array
->
count
,
sizeof
(
*
array
->
str
),
(
void
*
)
func
);
return
res
?
*
res
:
NULL
;
}
void
fatal_error
(
const
char
*
msg
,
...
)
{
va_list
valist
;
...
...
tools/winegcc/utils.c
View file @
97ca9f8a
...
...
@@ -30,10 +30,6 @@
#include "utils.h"
#if !defined(min)
# define min(x,y) (((x) < (y)) ? (x) : (y))
#endif
int
verbose
=
0
;
void
error
(
const
char
*
s
,
...)
...
...
@@ -47,116 +43,6 @@ void error(const char* s, ...)
exit
(
2
);
}
void
*
xmalloc
(
size_t
size
)
{
void
*
p
;
if
((
p
=
malloc
(
size
))
==
NULL
)
error
(
"Could not malloc %d bytes
\n
"
,
size
);
return
p
;
}
void
*
xrealloc
(
void
*
p
,
size_t
size
)
{
void
*
p2
=
realloc
(
p
,
size
);
if
(
size
&&
!
p2
)
error
(
"Could not realloc %d bytes
\n
"
,
size
);
return
p2
;
}
char
*
xstrdup
(
const
char
*
str
)
{
char
*
res
=
strdup
(
str
);
if
(
!
res
)
error
(
"Virtual memory exhausted.
\n
"
);
return
res
;
}
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
int
l
=
strlen
(
str
);
int
m
=
strlen
(
end
);
return
l
>=
m
&&
strcmp
(
str
+
l
-
m
,
end
)
==
0
;
}
char
*
strmake
(
const
char
*
fmt
,
...)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
while
(
1
)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
p
;
free
(
p
);
}
}
void
strarray_add
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
array
->
count
==
array
->
size
)
{
if
(
array
->
size
)
array
->
size
*=
2
;
else
array
->
size
=
16
;
array
->
str
=
xrealloc
(
array
->
str
,
sizeof
(
array
->
str
[
0
])
*
array
->
size
);
}
array
->
str
[
array
->
count
++
]
=
str
;
}
void
strarray_addall
(
struct
strarray
*
array
,
struct
strarray
added
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
added
.
count
;
i
++
)
strarray_add
(
array
,
added
.
str
[
i
]
);
}
struct
strarray
strarray_fromstring
(
const
char
*
str
,
const
char
*
delim
)
{
struct
strarray
array
=
empty_strarray
;
char
*
buf
=
xstrdup
(
str
);
const
char
*
tok
;
for
(
tok
=
strtok
(
buf
,
delim
);
tok
;
tok
=
strtok
(
NULL
,
delim
))
strarray_add
(
&
array
,
xstrdup
(
tok
));
free
(
buf
);
return
array
;
}
static
struct
strarray
strarray_frompath
(
const
char
*
path
)
{
if
(
!
path
)
return
empty_strarray
;
#if defined(_WIN32) && !defined(__CYGWIN__)
return
strarray_fromstring
(
path
,
";"
);
#else
return
strarray_fromstring
(
path
,
":"
);
#endif
}
char
*
strarray_tostring
(
struct
strarray
array
,
const
char
*
sep
)
{
char
*
str
;
unsigned
int
i
,
len
=
1
+
(
array
.
count
-
1
)
*
strlen
(
sep
);
if
(
!
array
.
count
)
return
xstrdup
(
""
);
for
(
i
=
0
;
i
<
array
.
count
;
i
++
)
len
+=
strlen
(
array
.
str
[
i
]
);
str
=
xmalloc
(
len
);
strcpy
(
str
,
array
.
str
[
0
]
);
for
(
i
=
1
;
i
<
array
.
count
;
i
++
)
{
strcat
(
str
,
sep
);
strcat
(
str
,
array
.
str
[
i
]
);
}
return
str
;
}
char
*
get_basename
(
const
char
*
file
)
{
const
char
*
name
;
...
...
tools/winegcc/utils.h
View file @
97ca9f8a
...
...
@@ -20,10 +20,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __GNUC__
#define __attribute__(X)
#endif
#include "../tools.h"
#ifndef DECLSPEC_NORETURN
# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
...
...
@@ -35,8 +32,6 @@
# endif
#endif
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
enum
target_cpu
{
CPU_x86
,
CPU_x86_64
,
CPU_POWERPC
,
CPU_ARM
,
CPU_ARM64
...
...
@@ -55,26 +50,6 @@ enum target_platform
void
DECLSPEC_NORETURN
error
(
const
char
*
s
,
...);
void
*
xmalloc
(
size_t
size
);
void
*
xrealloc
(
void
*
p
,
size_t
size
);
char
*
xstrdup
(
const
char
*
str
);
char
*
strmake
(
const
char
*
fmt
,
...)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
int
strendswith
(
const
char
*
str
,
const
char
*
end
);
struct
strarray
{
unsigned
int
count
;
/* strings in use */
unsigned
int
size
;
/* total allocated size */
const
char
**
str
;
};
static
const
struct
strarray
empty_strarray
;
void
strarray_add
(
struct
strarray
*
array
,
const
char
*
str
);
void
strarray_addall
(
struct
strarray
*
array
,
struct
strarray
added
);
struct
strarray
strarray_fromstring
(
const
char
*
str
,
const
char
*
delim
);
char
*
strarray_tostring
(
struct
strarray
array
,
const
char
*
sep
);
typedef
enum
{
file_na
,
file_other
,
file_obj
,
file_res
,
file_rc
,
file_arh
,
file_dll
,
file_so
,
file_def
,
file_spec
...
...
tools/wmc/utils.c
View file @
97ca9f8a
...
...
@@ -145,69 +145,6 @@ char *dup_basename(const char *name, const char *ext)
return
base
;
}
void
*
xmalloc
(
size_t
size
)
{
void
*
res
;
assert
(
size
>
0
);
res
=
malloc
(
size
);
if
(
res
==
NULL
)
{
error
(
"Virtual memory exhausted.
\n
"
);
}
memset
(
res
,
0x55
,
size
);
return
res
;
}
void
*
xrealloc
(
void
*
p
,
size_t
size
)
{
void
*
res
;
assert
(
size
>
0
);
res
=
realloc
(
p
,
size
);
if
(
res
==
NULL
)
{
error
(
"Virtual memory exhausted.
\n
"
);
}
return
res
;
}
char
*
xstrdup
(
const
char
*
str
)
{
char
*
s
;
assert
(
str
!=
NULL
);
s
=
xmalloc
(
strlen
(
str
)
+
1
);
return
strcpy
(
s
,
str
);
}
char
*
strmake
(
const
char
*
fmt
,
...
)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
for
(;;)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
p
;
free
(
p
);
}
}
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
int
l
=
strlen
(
str
);
int
m
=
strlen
(
end
);
return
l
>=
m
&&
!
strcmp
(
str
+
l
-
m
,
end
);
}
int
unistrlen
(
const
WCHAR
*
s
)
{
int
n
;
...
...
tools/wmc/utils.h
View file @
97ca9f8a
...
...
@@ -21,19 +21,9 @@
#ifndef __WMC_UTILS_H
#define __WMC_UTILS_H
#include <stddef.h>
/* size_t */
#include "../tools.h"
#include "wmctypes.h"
void
*
xmalloc
(
size_t
);
void
*
xrealloc
(
void
*
,
size_t
);
char
*
xstrdup
(
const
char
*
str
);
#ifndef __GNUC__
#define __attribute__(X)
#endif
char
*
strmake
(
const
char
*
fmt
,
...)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
int
mcy_error
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
int
xyyerror
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
int
mcy_warning
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
...
...
@@ -43,7 +33,6 @@ void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void
warning
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
char
*
dup_basename
(
const
char
*
name
,
const
char
*
ext
);
int
strendswith
(
const
char
*
str
,
const
char
*
end
);
WCHAR
*
xunistrdup
(
const
WCHAR
*
str
);
WCHAR
*
unistrcpy
(
WCHAR
*
dst
,
const
WCHAR
*
src
);
...
...
tools/wrc/utils.c
View file @
97ca9f8a
...
...
@@ -153,69 +153,6 @@ char *dup_basename(const char *name, const char *ext)
return
base
;
}
void
*
xmalloc
(
size_t
size
)
{
void
*
res
;
assert
(
size
>
0
);
res
=
malloc
(
size
);
if
(
res
==
NULL
)
{
error
(
"Virtual memory exhausted.
\n
"
);
}
memset
(
res
,
0x55
,
size
);
return
res
;
}
void
*
xrealloc
(
void
*
p
,
size_t
size
)
{
void
*
res
;
assert
(
size
>
0
);
res
=
realloc
(
p
,
size
);
if
(
res
==
NULL
)
{
error
(
"Virtual memory exhausted.
\n
"
);
}
return
res
;
}
char
*
strmake
(
const
char
*
fmt
,
...
)
{
int
n
;
size_t
size
=
100
;
va_list
ap
;
for
(;;)
{
char
*
p
=
xmalloc
(
size
);
va_start
(
ap
,
fmt
);
n
=
vsnprintf
(
p
,
size
,
fmt
,
ap
);
va_end
(
ap
);
if
(
n
==
-
1
)
size
*=
2
;
else
if
((
size_t
)
n
>=
size
)
size
=
n
+
1
;
else
return
p
;
free
(
p
);
}
}
char
*
xstrdup
(
const
char
*
str
)
{
char
*
s
;
assert
(
str
!=
NULL
);
s
=
xmalloc
(
strlen
(
str
)
+
1
);
return
strcpy
(
s
,
str
);
}
int
strendswith
(
const
char
*
str
,
const
char
*
end
)
{
int
l
=
strlen
(
str
);
int
m
=
strlen
(
end
);
return
l
>=
m
&&
!
strcmp
(
str
+
l
-
m
,
end
);
}
int
compare_striA
(
const
char
*
str1
,
const
char
*
str2
)
{
for
(;;)
...
...
tools/wrc/utils.h
View file @
97ca9f8a
...
...
@@ -21,22 +21,10 @@
#ifndef __WRC_UTILS_H
#define __WRC_UTILS_H
#include <stddef.h>
/* size_t */
#include "wrctypes.h"
void
*
xmalloc
(
size_t
);
void
*
xrealloc
(
void
*
,
size_t
);
char
*
xstrdup
(
const
char
*
str
);
#ifndef __GNUC__
#define __attribute__(X)
#endif
int
compare_striA
(
const
char
*
str1
,
const
char
*
str2
);
int
compare_striW
(
const
WCHAR
*
str1
,
const
WCHAR
*
str2
);
char
*
strmake
(
const
char
*
fmt
,
...)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
int
strendswith
(
const
char
*
str
,
const
char
*
end
);
int
parser_error
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
int
parser_warning
(
const
char
*
s
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
void
fatal_perror
(
const
char
*
msg
,
...
)
__attribute__
((
format
(
printf
,
1
,
2
),
noreturn
));
...
...
tools/wrc/wpp_private.h
View file @
97ca9f8a
...
...
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include "../tools.h"
#include "wine/list.h"
extern
void
wpp_del_define
(
const
char
*
name
);
...
...
tools/wrc/wrc.h
View file @
97ca9f8a
...
...
@@ -21,6 +21,7 @@
#ifndef __WRC_WRC_H
#define __WRC_WRC_H
#include "../tools.h"
#include "wrctypes.h"
/* From wrc.c */
...
...
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