Repository: lucy-clownfish Updated Branches: refs/heads/0.4 20f6b9100 -> 393b9c3f2
Regenerate charmonizer.c for whitespace fix Part of CLOWNFISH-4. Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/cb7ff745 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/cb7ff745 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/cb7ff745 Branch: refs/heads/0.4 Commit: cb7ff7451388b2e278142a1488907cd664f6f528 Parents: 20f6b91 Author: Nick Wellnhofer <[email protected]> Authored: Fri Sep 5 21:22:35 2014 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Fri Sep 5 21:33:46 2014 +0200 ---------------------------------------------------------------------- compiler/common/charmonizer.c | 25 +++++++++++++++++++++++-- runtime/common/charmonizer.c | 25 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cb7ff745/compiler/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c index 8a20531..b83481a 100644 --- a/compiler/common/charmonizer.c +++ b/compiler/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 */ http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cb7ff745/runtime/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c index dff9b8d..e953486 100644 --- a/runtime/common/charmonizer.c +++ b/runtime/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 */
