Author: marvin
Date: Wed Jun 13 14:22:50 2012
New Revision: 1349866
URL: http://svn.apache.org/viewvc?rev=1349866&view=rev
Log:
Set error flag within CC_set_warnings_as_errors.
Consolidate duplicated code setting the error_flag directly into the
setter which has 100% control over it.
Modified:
lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c
Modified: lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c?rev=1349866&r1=1349865&r2=1349866&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c Wed Jun 13 14:22:50
2012
@@ -51,7 +51,16 @@ static int warnings_as_errors = 0;
void
CC_set_warnings_as_errors(const int flag) {
warnings_as_errors = flag;
- strcpy(error_flag, " ");
+ if (warnings_as_errors) {
+ if (defines__MSC_VER) {
+ strcpy(error_flag, "/WX");
+ } else {
+ strcpy(error_flag, "-Werror");
+ }
+ }
+ else {
+ strcpy(error_flag, "");
+ }
}
void
@@ -177,13 +186,6 @@ CC_compile_exe(const char *source_path,
char *junk = (char*)malloc(junk_buf_size);
size_t exe_file_buf_len = sprintf(exe_file, "%s%s", exe_name, exe_ext);
char *inc_dir_string = S_inc_dir_string();
- if (warnings_as_errors) {
- if (defines__MSC_VER) {
- strcpy(error_flag, "/WX");
- } else {
- strcpy(error_flag, "-Werror");
- }
- }
size_t command_max_size = strlen(cc_command)
+ strlen(error_flag)
+ strlen(source_path)
@@ -243,14 +245,6 @@ CC_compile_obj(const char *source_path,
char *obj_file = (char*)malloc(obj_file_buf_size);
size_t obj_file_buf_len = sprintf(obj_file, "%s%s", obj_name, obj_ext);
char *inc_dir_string = S_inc_dir_string();
- if (warnings_as_errors) {
- if (defines__MSC_VER) {
- strcpy(error_flag, "/WX");
- } else {
- strcpy(error_flag, "-Werror");
- }
- }
-
size_t command_max_size = strlen(cc_command)
+ strlen(error_flag)
+ strlen(source_path)