Alexandre Julliard : wmc: Set the output format from the output file name.
Alexandre Julliard
julliard at winehq.org
Thu Feb 6 15:44:16 CST 2020
Module: wine
Branch: master
Commit: 8247686c106fca0098d22bd6b182942b2597dfde
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8247686c106fca0098d22bd6b182942b2597dfde
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Feb 6 15:05:48 2020 +0100
wmc: Set the output format from the output file name.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/makedep.c | 15 ++++++---------
tools/wmc/utils.c | 7 +++++++
tools/wmc/utils.h | 1 +
tools/wmc/wmc.c | 12 ++++++++++++
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c
index 4cc0e784c7..e5628712cc 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -2757,11 +2757,15 @@ static void output_source_rc( struct makefile *make, struct incl_file *source, c
static void output_source_mc( struct makefile *make, struct incl_file *source, const char *obj )
{
unsigned int i;
+ char *obj_path = obj_dir_path( make, obj );
strarray_add( &make->res_files, strmake( "%s.res", obj ));
strarray_add( &make->clean_files, strmake( "%s.pot", obj ));
- output( "%s.res: %s\n", obj_dir_path( make, obj ), source->filename );
- output( "\t%s -U -O res -o $@ %s", tools_path( make, "wmc" ), source->filename );
+ output( "%s.pot %s.res: %s", obj_path, obj_path, source->filename );
+ output_filename( tools_path( make, "wmc" ));
+ output_filenames( source->dependencies );
+ output( "\n" );
+ output( "\t%s -u -o $@ %s", tools_path( make, "wmc" ), source->filename );
if (linguas.count)
{
char *po_dir = top_obj_dir_path( make, "po" );
@@ -2772,13 +2776,6 @@ static void output_source_mc( struct makefile *make, struct incl_file *source, c
output_filename( strmake( "%s/%s.mo", po_dir, linguas.str[i] ));
}
output( "\n" );
- output( "%s.pot: %s\n", obj_dir_path( make, obj ), source->filename );
- output( "\t%s -O pot -o $@ %s", tools_path( make, "wmc" ), source->filename );
- output( "\n" );
- output( "%s.pot %s.res:", obj_dir_path( make, obj ), obj_dir_path( make, obj ));
- output_filename( tools_path( make, "wmc" ));
- output_filenames( source->dependencies );
- output( "\n" );
}
diff --git a/tools/wmc/utils.c b/tools/wmc/utils.c
index e3da5422d7..7261fe715a 100644
--- a/tools/wmc/utils.c
+++ b/tools/wmc/utils.c
@@ -200,6 +200,13 @@ char *strmake( const char* fmt, ... )
}
}
+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;
diff --git a/tools/wmc/utils.h b/tools/wmc/utils.h
index 48f47ee751..e4c546765d 100644
--- a/tools/wmc/utils.h
+++ b/tools/wmc/utils.h
@@ -43,6 +43,7 @@ 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);
diff --git a/tools/wmc/wmc.c b/tools/wmc/wmc.c
index 89c8d6e8e9..93c029d751 100644
--- a/tools/wmc/wmc.c
+++ b/tools/wmc/wmc.c
@@ -126,6 +126,7 @@ FILE *yyin;
static enum
{
+ FORMAT_UNKNOWN,
FORMAT_RC,
FORMAT_RES,
FORMAT_POT
@@ -287,6 +288,15 @@ int main(int argc,char *argv[])
input_name = argv[optind];
}
+ /* Guess output format */
+ if (output_format == FORMAT_UNKNOWN)
+ {
+ if (output_name && strendswith( output_name, ".res" )) output_format = FORMAT_RES;
+ else if (output_name && strendswith( output_name, ".pot" )) output_format = FORMAT_POT;
+ else output_format = FORMAT_RC;
+ }
+ if (output_format == FORMAT_RES) unicodeout = 1;
+
/* Generate appropriate outfile names */
if(!output_name)
{
@@ -340,6 +350,8 @@ int main(int argc,char *argv[])
case FORMAT_POT:
write_pot_file( output_name );
break;
+ default:
+ break;
}
output_name = NULL;
header_name = NULL;
More information about the wine-cvs
mailing list