Repository: lucy
Updated Branches:
  refs/heads/0.4 481653b59 -> 647973cee


Regenerate charmonizer.c for whitespace fix


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/647973ce
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/647973ce
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/647973ce

Branch: refs/heads/0.4
Commit: 647973cee818c8c55e9f751ac42657847f083da3
Parents: 481653b
Author: Nick Wellnhofer <[email protected]>
Authored: Fri Sep 5 21:37:22 2014 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Fri Sep 5 21:42:53 2014 +0200

----------------------------------------------------------------------
 common/charmonizer.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/647973ce/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index c18f77f..3e776f8 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -4496,6 +4496,7 @@ chaz_Make_list_files(const char *dir, const char *ext,
 #include <stdarg.h>
 #include <ctype.h>
 #include <time.h>
+#include <errno.h>
 
 /* #include "Charmonizer/Core/Compiler.h" */
 /* #include "Charmonizer/Core/Util.h" */
@@ -4948,6 +4949,7 @@ chaz_Util_can_open_file(const char *file_path) {
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 /* #include "Charmonizer/Probe.h" */
 /* #include "Charmonizer/Core/HeaderChecker.h" */
 /* #include "Charmonizer/Core/ConfWriter.h" */
@@ -5000,11 +5002,30 @@ chaz_Probe_parse_cli_args(int argc, const char *argv[],
             args->code_coverage = 1;
         }
         else if (memcmp(arg, "--cc=", 5) == 0) {
-            if (strlen(arg) > CHAZ_PROBE_MAX_CC_LEN - 5) {
+            size_t len = strlen(arg);
+            size_t l   = 5;
+            size_t r   = len;
+            size_t trimmed_len;
+
+            if (len > CHAZ_PROBE_MAX_CC_LEN - 5) {
                 fprintf(stderr, "Exceeded max length for compiler command");
                 exit(1);
             }
-            strcpy(args->cc, arg + 5);
+
+            /*
+             * Some Perl setups have a 'cc' config value with leading
+             * whitespace.
+             */
+            while (isspace(arg[l])) {
+                ++l;
+            }
+            while (r > l && isspace(arg[r-1])) {
+                --r;
+            }
+
+            trimmed_len = r - l;
+            memcpy(args->cc, arg + l, trimmed_len);
+            args->cc[trimmed_len] = '\0';
         }
     } /* preserve value of i */
 

Reply via email to