-------------------------------------------------------------------------------
Copyright (C) 2002-2007 Andrew Tridgell
- Copyright (C) 2009-2018 Joel Rosdahl
+ Copyright (C) 2009-2019 Joel Rosdahl
-------------------------------------------------------------------------------
<body class="article">\r
<div id="header">\r
<h1>ccache copyright and license</h1>\r
-<span id="revnumber">version 3.5</span>\r
+<span id="revnumber">version 3.5.1</span>\r
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
<div class="listingblock">\r
<div class="content">\r
<pre><code> Copyright (C) 2002-2007 Andrew Tridgell\r
- Copyright (C) 2009-2018 Joel Rosdahl</code></pre>\r
+ Copyright (C) 2009-2019 Joel Rosdahl</code></pre>\r
</div></div>\r
</div>\r
</div>\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.5<br />\r
+Version 3.5.1<br />\r
Last updated\r
- 2018-09-26 22:34:27 CEST\r
+ 2019-01-03 19:29:09 CET\r
</div>\r
</div>\r
</body>\r
src/cleanup.c \
src/compopt.c \
src/conf.c \
+ src/confitems.c \
src/counters.c \
src/execute.c \
src/exitfn.c \
src/version.c
3pp_sources = \
@getopt_long_c@ \
+ src/confitems_lookup.c \
+ src/envtoconfitems_lookup.c \
src/hashtable.c \
src/hashtable_itr.c \
src/murmurhashneutral2.c \
ccache$(EXEEXT): $(ccache_objs) $(extra_libs)
$(if $(quiet),@echo " LD $@")
- $(Q)$(CC) $(all_cflags) -o $@ $(ccache_objs) $(LDFLAGS) $(extra_libs) $(LIBS)
+ $(Q)$(CC) -o $@ $(ccache_objs) $(LDFLAGS) $(extra_libs) $(LIBS)
ccache.1: doc/ccache.1
$(if $(quiet),@echo " CP $@")
clean:
rm -rf $(files_to_clean)
-conf.c: confitems_lookup.c envtoconfitems_lookup.c
-
+src/snprintf.o: CFLAGS += @no_implicit_fallthrough_warning@
$(zlib_objs): CPPFLAGS += -include config.h
$(zlib_objs): CFLAGS += @no_implicit_fallthrough_warning@
unittest/run$(EXEEXT): $(base_objs) $(test_objs) $(extra_libs)
$(if $(quiet),@echo " LD $@")
- $(Q)$(CC) $(all_cflags) -o $@ $(base_objs) $(test_objs) $(LDFLAGS) $(extra_libs) $(LIBS)
+ $(Q)$(CC) -o $@ $(base_objs) $(test_objs) $(LDFLAGS) $(extra_libs) $(LIBS)
unittest/main.o: unittest/suites.h
LDFLAGS
CFLAGS
CC
-disable_man
test_suites
+no_implicit_fallthrough_warning
+more_warnings
include_dev_mk
getopt_long_c
-no_implicit_fallthrough_warning
extra_libs
+disable_man
host_os
host_vendor
host_cpu
+
# The later defininition of _XOPEN_SOURCE disables certain features
# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
CFLAGS="$CFLAGS -O"
fi
+more_warnings="-Wextra -Wpedantic"
+if test "$ac_compiler_clang" = yes; then
+ more_warnings="$more_warnings -Weverything"
+ more_warnings="$more_warnings -Wno-conversion"
+ more_warnings="$more_warnings -Wno-disabled-macro-expansion"
+ more_warnings="$more_warnings -Wno-format-nonliteral"
+ more_warnings="$more_warnings -Wno-padded"
+ more_warnings="$more_warnings -Wno-shorten-64-to-32"
+ more_warnings="$more_warnings -Wno-sign-conversion"
+fi
+
# Check whether --enable-more_warnings was given.
if test "${enable_more_warnings+set}" = set; then :
enableval=$enable_more_warnings;
fi
if test x${enable_more_warnings} = xyes; then
- CFLAGS="$CFLAGS -Wextra -Wpedantic"
- if test "$ac_compiler_clang" = yes; then
- CFLAGS="$CFLAGS -Weverything"
- CFLAGS="$CFLAGS -Wno-padded -Wno-disabled-macro-expansion -Wno-format-nonliteral"
- CFLAGS="$CFLAGS -Wno-double-promotion -Wno-float-conversion"
- CFLAGS="$CFLAGS -Wno-conversion -Wno-shorten-64-to-32 -Wno-sign-conversion"
- fi
+ CFLAGS="$CFLAGS $more_warnings"
fi
;;
esac
+AC_SUBST(disable_man)
AC_SUBST(extra_libs)
-AC_SUBST(no_implicit_fallthrough_warning)
AC_SUBST(getopt_long_c)
AC_SUBST(include_dev_mk)
+AC_SUBST(more_warnings)
+AC_SUBST(no_implicit_fallthrough_warning)
AC_SUBST(test_suites)
-AC_SUBST(disable_man)
m4_include(m4/feature_macros.m4)
m4_include(m4/clang.m4)
CFLAGS="$CFLAGS -O"
fi
+more_warnings="-Wextra -Wpedantic"
+if test "$ac_compiler_clang" = yes; then
+ more_warnings="$more_warnings -Weverything"
+ more_warnings="$more_warnings -Wno-conversion"
+ more_warnings="$more_warnings -Wno-disabled-macro-expansion"
+ more_warnings="$more_warnings -Wno-format-nonliteral"
+ more_warnings="$more_warnings -Wno-padded"
+ more_warnings="$more_warnings -Wno-shorten-64-to-32"
+ more_warnings="$more_warnings -Wno-sign-conversion"
+fi
+
AC_ARG_ENABLE(more_warnings,
[AS_HELP_STRING([--enable-more-warnings],
[enable more compiler warnings])])
if test x${enable_more_warnings} = xyes; then
- CFLAGS="$CFLAGS -Wextra -Wpedantic"
- if test "$ac_compiler_clang" = yes; then
- CFLAGS="$CFLAGS -Weverything"
- CFLAGS="$CFLAGS -Wno-padded -Wno-disabled-macro-expansion -Wno-format-nonliteral"
- CFLAGS="$CFLAGS -Wno-double-promotion -Wno-float-conversion"
- CFLAGS="$CFLAGS -Wno-conversion -Wno-shorten-64-to-32 -Wno-sign-conversion"
- fi
+ CFLAGS="$CFLAGS $more_warnings"
fi
AC_HEADER_DIRENT
# GNU make syntax reigns in this file.
-all_cflags += -Werror
+all_cflags += -Werror @more_warnings@
all_cppflags += -MD -MP -MF .deps/$(subst .._,,$(subst /,_,$<)).d
A2X = a2x
src/ccache.h \
src/compopt.h \
src/conf.h \
+ src/confitems.h \
src/counters.h \
+ src/envtoconfitems.h \
src/getopt_long.h \
src/hash.h \
src/hashtable.h \
src/confitems_lookup.c \
src/envtoconfitems.gperf \
src/envtoconfitems_lookup.c \
+ src/getopt_long.c \
src/main.c \
src/zlib/*.c \
src/zlib/*.h \
%_lookup.c: %.gperf
$(if $(quiet),@echo " GPERF $@")
- $(Q)$(GPERF) $< | awk '/#ifdef __GNUC__/ { ++i; if (i == 2) { print "static"; }} {print}' >$@
- $(Q)echo "static const size_t $$(echo $(notdir $*) | tr a-z A-Z)_TOTAL_KEYWORDS = $$(sed -nr 's/.*TOTAL_KEYWORDS = ([0-9]+).*/\1/p' $@);" >>$@
+ $(Q)$(GPERF) $< >$@
+ $(Q)echo "size_t $$(echo '$(notdir $*)_count(void)') { return $$(sed -nr 's/.*TOTAL_KEYWORDS = (.+),.*/\1/p' $@); }" >>$@
.PHONY: dist
dist: $(dist_archives)
tar -c $$tarcompression -f $(CURDIR)/$@ $(dist_dir)) && \
rm -rf $$tmpdir
-.PHONY: distcheck
-distcheck: $(firstword $(dist_archives))
+# $(1): extra configure options
+define do_distcheck
tmpdir=$$(mktemp -d /tmp/tmp-ccache-distcheck.XXXXXX) && \
(cd $$tmpdir && \
tar xf $(CURDIR)/$< && \
chmod -R a-w $(dist_dir) && \
chmod u+w $(dist_dir)/build && \
cd $(dist_dir)/build && \
- ../configure --prefix=$$tmpdir/root && \
- $(MAKE) install && \
+ ../configure --enable-more-warnings --prefix=$$tmpdir/root $(1) && \
+ $(MAKE) install CFLAGS=-Werror V=1 && \
$(MAKE) installcheck) && \
chmod -R u+w $$tmpdir/$(dist_dir) && \
rm -rf $$tmpdir
+endef
- tmpdir=$$(mktemp -d /tmp/tmp-ccache-distcheck.XXXXXX) && \
- (cd $$tmpdir && \
- tar xf $(CURDIR)/$< && \
- mkdir -p $(dist_dir)/build && \
- chmod -R a-w $(dist_dir) && \
- chmod u+w $(dist_dir)/build && \
- cd $(dist_dir)/build && \
- ../configure --prefix=$$tmpdir/root --with-bundled-zlib && \
- $(MAKE) install && \
- $(MAKE) installcheck) && \
- chmod -R u+w $$tmpdir/$(dist_dir) && \
- rm -rf $$tmpdir
+.PHONY: distcheck
+distcheck: $(firstword $(dist_archives))
+ $(call do_distcheck, --without-bundled-zlib)
+ $(call do_distcheck, --with-bundled-zlib)
+ $(call do_distcheck, CC=clang)
.PHONY: docs
docs: $(generated_docs)
cppcheck:
$(CPPCHECK) --suppressions-list=$(CPPCHECK_SUPPRESSIONS) \
--inline-suppr -q --enable=all --force -I . \
+ --template='cppcheck: warning: {id}:{file}:{line}: {message}' \
$(non_3pp_sources) src/main.c $(test_sources)
.PHONY: shellcheck
* Ville Skyttä <ville.skytta@iki.fi>
* William S Fulton <wsf@fultondesigns.co.uk>
* Wilson Snyder <wsnyder@wsnyder.org>
-* Xavier RENE-CORAIL <xavier.renecorail@gmail.com>
+* Xavier René-Corail <xavier.renecorail@gmail.com>
* Yiding Jia <yiding@fb.com>
Thanks!
<body class="article">\r
<div id="header">\r
<h1>ccache authors</h1>\r
-<span id="revnumber">version 3.5</span>\r
+<span id="revnumber">version 3.5.1</span>\r
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</li>\r
<li>\r
<p>\r
-Xavier RENE-CORAIL <<a href="mailto:xavier.renecorail@gmail.com">xavier.renecorail@gmail.com</a>>\r
+Xavier René-Corail <<a href="mailto:xavier.renecorail@gmail.com">xavier.renecorail@gmail.com</a>>\r
</p>\r
</li>\r
<li>\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.5<br />\r
+Version 3.5.1<br />\r
Last updated\r
- 2018-10-15 21:28:32 CEST\r
+ 2019-01-03 21:16:50 CET\r
</div>\r
</div>\r
</body>\r
<body class="article">\r
<div id="header">\r
<h1>CCACHE(1)</h1>\r
-<span id="revnumber">version 3.5</span>\r
+<span id="revnumber">version 3.5.1</span>\r
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.5<br />\r
+Version 3.5.1<br />\r
Last updated\r
- 2018-10-07 20:43:01 CEST\r
+ 2019-01-03 21:16:33 CET\r
</div>\r
</div>\r
</body>\r
ccache news
===========
+ccache 3.5.1
+------------
+Release date: 2019-01-02
+
+Changes
+~~~~~~~
+
+- Added missing getopt_long.c source file to release archive.
+
+- Fixed (harmless) compiler warnings when building ccache object files.
+
+- CFLAGS is no longer passed to the linker when linking ccache.
+
+- Improved development mode build flags.
+
+
ccache 3.5
----------
Release date: 2018-10-15
<body class="article">\r
<div id="header">\r
<h1>ccache news</h1>\r
-<span id="revnumber">version 3.5</span>\r
+<span id="revnumber">version 3.5.1</span>\r
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>\r
<div id="content">\r
<div class="sect1">\r
+<h2 id="_ccache_3_5_1">ccache 3.5.1</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>Release date: 2019-01-02</p></div>\r
+<div class="sect2">\r
+<h3 id="_changes">Changes</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+Added missing getopt_long.c source file to release archive.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Fixed (harmless) compiler warnings when building ccache object files.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+CFLAGS is no longer passed to the linker when linking ccache.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Improved development mode build flags.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
<h2 id="_ccache_3_5">ccache 3.5</h2>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2018-10-15</p></div>\r
<div class="sect2">\r
-<h3 id="_changes">Changes</h3>\r
+<h3 id="_changes_2">Changes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.5<br />\r
+Version 3.5.1<br />\r
Last updated\r
- 2018-10-15 21:28:32 CEST\r
+ 2019-01-03 21:16:33 CET\r
</div>\r
</div>\r
</body>\r
.\" Title: ccache
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\" Date: 10/15/2018
+.\" Date: 01/03/2019
.\" Manual: ccache Manual
-.\" Source: ccache 3.5
+.\" Source: ccache 3.5.1
.\" Language: English
.\"
-.TH "CCACHE" "1" "10/15/2018" "ccache 3\&.5" "ccache Manual"
+.TH "CCACHE" "1" "01/03/2019" "ccache 3\&.5\&.1" "ccache Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
// ccache -- a fast C/C++ compiler cache
//
// Copyright (C) 2002-2007 Andrew Tridgell
-// Copyright (C) 2009-2018 Joel Rosdahl
+// Copyright (C) 2009-2019 Joel Rosdahl
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
MYNAME " version %s\n"
"\n"
"Copyright (C) 2002-2007 Andrew Tridgell\n"
- "Copyright (C) 2009-2018 Joel Rosdahl\n"
+ "Copyright (C) 2009-2019 Joel Rosdahl\n"
"\n"
"This program is free software; you can redistribute it and/or modify it under\n"
"the terms of the GNU General Public License as published by the Free Software\n"
void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
void cc_bulklog(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
void cc_log_argv(const char *prefix, char **argv);
-bool cc_dump_log_buffer(const char *path);
+void cc_dump_log_buffer(const char *path);
void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2) ATTR_NORETURN;
void warn(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "conf.h"
+#include "confitems.h"
+#include "envtoconfitems.h"
#include "ccache.h"
-typedef bool (*conf_item_parser)(const char *str, void *result, char **errmsg);
-typedef bool (*conf_item_verifier)(void *value, char **errmsg);
-typedef const char *(*conf_item_formatter)(void *value);
-
-struct conf_item {
- const char *name;
- size_t number;
- conf_item_parser parser;
- size_t offset;
- conf_item_verifier verifier;
- conf_item_formatter formatter;
-};
-
-struct env_to_conf_item {
- const char *env_name;
- const char *conf_name;
-};
-
-static bool
-parse_bool(const char *str, void *result, char **errmsg)
-{
- bool *value = (bool *)result;
-
- if (str_eq(str, "true")) {
- *value = true;
- return true;
- } else if (str_eq(str, "false")) {
- *value = false;
- return true;
- } else {
- *errmsg = format("not a boolean value: \"%s\"", str);
- return false;
- }
-}
-
-static const char *
-bool_to_string(bool value)
-{
- return value ? "true" : "false";
-}
-
-static const char *
-format_bool(void *value)
-{
- bool *b = (bool *)value;
- return x_strdup(bool_to_string(*b));
-}
-
-static bool
-parse_env_string(const char *str, void *result, char **errmsg)
-{
- char **value = (char **)result;
- free(*value);
- *value = subst_env_in_string(str, errmsg);
- return *value != NULL;
-}
-
-static const char *
-format_string(void *value)
-{
- char **str = (char **)value;
- return x_strdup(*str);
-}
-
-static const char *
-format_env_string(void *value)
-{
- return format_string(value);
-}
-
-static bool
-parse_float(const char *str, void *result, char **errmsg)
-{
- float *value = (float *)result;
- errno = 0;
- char *endptr;
- float x = strtof(str, &endptr);
- if (errno == 0 && *str != '\0' && *endptr == '\0') {
- *value = x;
- return true;
- } else {
- *errmsg = format("invalid floating point: \"%s\"", str);
- return false;
- }
-}
-
-static const char *
-format_float(void *value)
-{
- float *x = (float *)value;
- return format("%.1f", *x);
-}
-
-static bool
-parse_size(const char *str, void *result, char **errmsg)
-{
- uint64_t *value = (uint64_t *)result;
- uint64_t size;
- if (parse_size_with_suffix(str, &size)) {
- *value = size;
- return true;
- } else {
- *errmsg = format("invalid size: \"%s\"", str);
- return false;
- }
-}
-
-static const char *
-format_size(void *value)
-{
- uint64_t *size = (uint64_t *)value;
- return format_parsable_size_with_suffix(*size);
-}
-
-static bool
-parse_sloppiness(const char *str, void *result, char **errmsg)
-{
- unsigned *value = (unsigned *)result;
- if (!str) {
- return *value;
- }
-
- char *p = x_strdup(str);
- char *q = p;
- char *word;
- char *saveptr = NULL;
- while ((word = strtok_r(q, ", ", &saveptr))) {
- if (str_eq(word, "file_macro")) {
- *value |= SLOPPY_FILE_MACRO;
- } else if (str_eq(word, "file_stat_matches")) {
- *value |= SLOPPY_FILE_STAT_MATCHES;
- } else if (str_eq(word, "file_stat_matches_ctime")) {
- *value |= SLOPPY_FILE_STAT_MATCHES_CTIME;
- } else if (str_eq(word, "include_file_ctime")) {
- *value |= SLOPPY_INCLUDE_FILE_CTIME;
- } else if (str_eq(word, "include_file_mtime")) {
- *value |= SLOPPY_INCLUDE_FILE_MTIME;
- } else if (str_eq(word, "no_system_headers")) {
- *value |= SLOPPY_NO_SYSTEM_HEADERS;
- } else if (str_eq(word, "pch_defines")) {
- *value |= SLOPPY_PCH_DEFINES;
- } else if (str_eq(word, "time_macros")) {
- *value |= SLOPPY_TIME_MACROS;
- } else {
- *errmsg = format("unknown sloppiness: \"%s\"", word);
- free(p);
- return false;
- }
- q = NULL;
- }
- free(p);
- return true;
-}
-
-static const char *
-format_sloppiness(void *value)
-{
- unsigned *sloppiness = (unsigned *)value;
- char *s = x_strdup("");
- if (*sloppiness & SLOPPY_FILE_MACRO) {
- reformat(&s, "%sfile_macro, ", s);
- }
- if (*sloppiness & SLOPPY_INCLUDE_FILE_MTIME) {
- reformat(&s, "%sinclude_file_mtime, ", s);
- }
- if (*sloppiness & SLOPPY_INCLUDE_FILE_CTIME) {
- reformat(&s, "%sinclude_file_ctime, ", s);
- }
- if (*sloppiness & SLOPPY_TIME_MACROS) {
- reformat(&s, "%stime_macros, ", s);
- }
- if (*sloppiness & SLOPPY_PCH_DEFINES) {
- reformat(&s, "%spch_defines, ", s);
- }
- if (*sloppiness & SLOPPY_FILE_STAT_MATCHES) {
- reformat(&s, "%sfile_stat_matches, ", s);
- }
- if (*sloppiness & SLOPPY_FILE_STAT_MATCHES_CTIME) {
- reformat(&s, "%sfile_stat_matches_ctime, ", s);
- }
- if (*sloppiness & SLOPPY_NO_SYSTEM_HEADERS) {
- reformat(&s, "%sno_system_headers, ", s);
- }
- if (*sloppiness) {
- // Strip last ", ".
- s[strlen(s) - 2] = '\0';
- }
- return s;
-}
-
-static bool
-parse_string(const char *str, void *result, char **errmsg)
-{
- (void)errmsg;
-
- char **value = (char **)result;
- free(*value);
- *value = x_strdup(str);
- return true;
-}
-
-static bool
-parse_umask(const char *str, void *result, char **errmsg)
-{
- unsigned *value = (unsigned *)result;
- if (str_eq(str, "")) {
- *value = UINT_MAX;
- return true;
- }
-
- errno = 0;
- char *endptr;
- *value = strtoul(str, &endptr, 8);
- if (errno == 0 && *str != '\0' && *endptr == '\0') {
- return true;
- } else {
- *errmsg = format("not an octal integer: \"%s\"", str);
- return false;
- }
-}
-
-static const char *
-format_umask(void *value)
-{
- unsigned *umask = (unsigned *)value;
- if (*umask == UINT_MAX) {
- return x_strdup("");
- } else {
- return format("%03o", *umask);
- }
-}
-
-static bool
-parse_unsigned(const char *str, void *result, char **errmsg)
-{
- unsigned *value = (unsigned *)result;
- errno = 0;
- char *endptr;
- long x = strtol(str, &endptr, 10);
- if (errno == 0 && x >= 0 && *str != '\0' && *endptr == '\0') {
- *value = x;
- return true;
- } else {
- *errmsg = format("invalid unsigned integer: \"%s\"", str);
- return false;
- }
-}
-
-static const char *
-format_unsigned(void *value)
-{
- unsigned *i = (unsigned *)value;
- return format("%u", *i);
-}
-
-static bool
-verify_absolute_path(void *value, char **errmsg)
-{
- char **path = (char **)value;
- assert(*path);
- if (str_eq(*path, "")) {
- // The empty string means "disable" in this case.
- return true;
- } else if (is_absolute_path(*path)) {
- return true;
- } else {
- *errmsg = format("not an absolute path: \"%s\"", *path);
- return false;
- }
-}
-
-static bool
-verify_dir_levels(void *value, char **errmsg)
-{
- unsigned *levels = (unsigned *)value;
- assert(levels);
- if (*levels >= 1 && *levels <= 8) {
- return true;
- } else {
- *errmsg = format("cache directory levels must be between 1 and 8");
- return false;
- }
-}
-
-#define ITEM(name, type) \
- parse_ ## type, offsetof(struct conf, name), NULL, format_ ## type
-#define ITEM_V(name, type, verification) \
- parse_ ## type, offsetof(struct conf, name), \
- verify_ ## verification, format_ ## type
-
-#include "confitems_lookup.c"
-#include "envtoconfitems_lookup.c"
-
static const struct conf_item *
find_conf(const char *name)
{
return false;
}
- if (from_env_variable && item->parser == parse_bool) {
+ if (from_env_variable && item->parser == confitem_parse_bool) {
// Special rule for boolean settings from the environment: "0", "false",
// "disable" and "no" (case insensitive) are invalid, and all other values
// mean true.
conf->hash_dir = true;
conf->ignore_headers_in_manifest = x_strdup("");
conf->keep_comments_cpp = false;
- conf->limit_multiple = 0.8f;
+ conf->limit_multiple = 0.8;
conf->log_file = x_strdup("");
conf->max_files = 0;
conf->max_size = (uint64_t)5 * 1000 * 1000 * 1000;
conf->temporary_dir = x_strdup("");
conf->umask = UINT_MAX; // Default: don't set umask.
conf->unify = false;
- conf->item_origins = x_malloc(CONFITEMS_TOTAL_KEYWORDS * sizeof(char *));
- for (size_t i = 0; i < CONFITEMS_TOTAL_KEYWORDS; ++i) {
+ conf->item_origins = x_malloc(confitems_count() * sizeof(char *));
+ for (size_t i = 0; i < confitems_count(); ++i) {
conf->item_origins[i] = "default";
}
return conf;
return false;
}
void *value = (char *)conf + item->offset;
- char *str = (char *)item->formatter(value);
+ char *str = item->formatter(value);
fprintf(file, "%s\n", str);
free(str);
return true;
return false;
}
void *value = (char *)conf + item->offset;
- char *str = (char *)item->formatter(value);
+ char *str = item->formatter(value);
char *buf = x_strdup("");
reformat(&buf, "%s = %s", key, str);
printer(buf, conf->item_origins[item->number], context);
bool hash_dir;
char *ignore_headers_in_manifest;
bool keep_comments_cpp;
- float limit_multiple;
+ double limit_multiple;
char *log_file;
unsigned max_files;
uint64_t max_size;
--- /dev/null
+// Copyright (C) 2018 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program 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 General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+#include "confitems.h"
+#include "ccache.h"
+
+static char *
+format_string(void *value)
+{
+ char **str = (char **)value;
+ return x_strdup(*str);
+}
+
+bool
+confitem_parse_bool(const char *str, void *result, char **errmsg)
+{
+ bool *value = (bool *)result;
+
+ if (str_eq(str, "true")) {
+ *value = true;
+ return true;
+ } else if (str_eq(str, "false")) {
+ *value = false;
+ return true;
+ } else {
+ *errmsg = format("not a boolean value: \"%s\"", str);
+ return false;
+ }
+}
+
+char *
+confitem_format_bool(void *value)
+{
+ bool *b = (bool *)value;
+ return x_strdup(*b ? "true" : "false");
+}
+
+bool
+confitem_parse_env_string(const char *str, void *result, char **errmsg)
+{
+ char **value = (char **)result;
+ free(*value);
+ *value = subst_env_in_string(str, errmsg);
+ return *value != NULL;
+}
+
+char *
+confitem_format_env_string(void *value)
+{
+ return format_string(value);
+}
+
+bool
+confitem_parse_double(const char *str, void *result, char **errmsg)
+{
+ double *value = (double *)result;
+ errno = 0;
+ char *endptr;
+ double x = strtod(str, &endptr);
+ if (errno == 0 && *str != '\0' && *endptr == '\0') {
+ *value = x;
+ return true;
+ } else {
+ *errmsg = format("invalid floating point: \"%s\"", str);
+ return false;
+ }
+}
+
+char *
+confitem_format_double(void *value)
+{
+ double *x = (double *)value;
+ return format("%.1f", *x);
+}
+
+bool
+confitem_parse_size(const char *str, void *result, char **errmsg)
+{
+ uint64_t *value = (uint64_t *)result;
+ uint64_t size;
+ if (parse_size_with_suffix(str, &size)) {
+ *value = size;
+ return true;
+ } else {
+ *errmsg = format("invalid size: \"%s\"", str);
+ return false;
+ }
+}
+
+char *
+confitem_format_size(void *value)
+{
+ uint64_t *size = (uint64_t *)value;
+ return format_parsable_size_with_suffix(*size);
+}
+
+bool
+confitem_parse_sloppiness(const char *str, void *result, char **errmsg)
+{
+ unsigned *value = (unsigned *)result;
+ if (!str) {
+ return *value;
+ }
+
+ char *p = x_strdup(str);
+ char *q = p;
+ char *word;
+ char *saveptr = NULL;
+ while ((word = strtok_r(q, ", ", &saveptr))) {
+ if (str_eq(word, "file_macro")) {
+ *value |= SLOPPY_FILE_MACRO;
+ } else if (str_eq(word, "file_stat_matches")) {
+ *value |= SLOPPY_FILE_STAT_MATCHES;
+ } else if (str_eq(word, "file_stat_matches_ctime")) {
+ *value |= SLOPPY_FILE_STAT_MATCHES_CTIME;
+ } else if (str_eq(word, "include_file_ctime")) {
+ *value |= SLOPPY_INCLUDE_FILE_CTIME;
+ } else if (str_eq(word, "include_file_mtime")) {
+ *value |= SLOPPY_INCLUDE_FILE_MTIME;
+ } else if (str_eq(word, "no_system_headers")) {
+ *value |= SLOPPY_NO_SYSTEM_HEADERS;
+ } else if (str_eq(word, "pch_defines")) {
+ *value |= SLOPPY_PCH_DEFINES;
+ } else if (str_eq(word, "time_macros")) {
+ *value |= SLOPPY_TIME_MACROS;
+ } else {
+ *errmsg = format("unknown sloppiness: \"%s\"", word);
+ free(p);
+ return false;
+ }
+ q = NULL;
+ }
+ free(p);
+ return true;
+}
+
+char *
+confitem_format_sloppiness(void *value)
+{
+ unsigned *sloppiness = (unsigned *)value;
+ char *s = x_strdup("");
+ if (*sloppiness & SLOPPY_FILE_MACRO) {
+ reformat(&s, "%sfile_macro, ", s);
+ }
+ if (*sloppiness & SLOPPY_INCLUDE_FILE_MTIME) {
+ reformat(&s, "%sinclude_file_mtime, ", s);
+ }
+ if (*sloppiness & SLOPPY_INCLUDE_FILE_CTIME) {
+ reformat(&s, "%sinclude_file_ctime, ", s);
+ }
+ if (*sloppiness & SLOPPY_TIME_MACROS) {
+ reformat(&s, "%stime_macros, ", s);
+ }
+ if (*sloppiness & SLOPPY_PCH_DEFINES) {
+ reformat(&s, "%spch_defines, ", s);
+ }
+ if (*sloppiness & SLOPPY_FILE_STAT_MATCHES) {
+ reformat(&s, "%sfile_stat_matches, ", s);
+ }
+ if (*sloppiness & SLOPPY_FILE_STAT_MATCHES_CTIME) {
+ reformat(&s, "%sfile_stat_matches_ctime, ", s);
+ }
+ if (*sloppiness & SLOPPY_NO_SYSTEM_HEADERS) {
+ reformat(&s, "%sno_system_headers, ", s);
+ }
+ if (*sloppiness) {
+ // Strip last ", ".
+ s[strlen(s) - 2] = '\0';
+ }
+ return s;
+}
+
+bool
+confitem_parse_string(const char *str, void *result, char **errmsg)
+{
+ (void)errmsg;
+
+ char **value = (char **)result;
+ free(*value);
+ *value = x_strdup(str);
+ return true;
+}
+
+char *
+confitem_format_string(void *value)
+{
+ return format_string(value);
+}
+
+bool
+confitem_parse_umask(const char *str, void *result, char **errmsg)
+{
+ unsigned *value = (unsigned *)result;
+ if (str_eq(str, "")) {
+ *value = UINT_MAX;
+ return true;
+ }
+
+ errno = 0;
+ char *endptr;
+ *value = strtoul(str, &endptr, 8);
+ if (errno == 0 && *str != '\0' && *endptr == '\0') {
+ return true;
+ } else {
+ *errmsg = format("not an octal integer: \"%s\"", str);
+ return false;
+ }
+}
+
+char *
+confitem_format_umask(void *value)
+{
+ unsigned *umask = (unsigned *)value;
+ if (*umask == UINT_MAX) {
+ return x_strdup("");
+ } else {
+ return format("%03o", *umask);
+ }
+}
+
+bool
+confitem_parse_unsigned(const char *str, void *result, char **errmsg)
+{
+ unsigned *value = (unsigned *)result;
+ errno = 0;
+ char *endptr;
+ long x = strtol(str, &endptr, 10);
+ if (errno == 0 && x >= 0 && *str != '\0' && *endptr == '\0') {
+ *value = x;
+ return true;
+ } else {
+ *errmsg = format("invalid unsigned integer: \"%s\"", str);
+ return false;
+ }
+}
+
+char *
+confitem_format_unsigned(void *value)
+{
+ unsigned *i = (unsigned *)value;
+ return format("%u", *i);
+}
+
+bool
+confitem_verify_absolute_path(void *value, char **errmsg)
+{
+ char **path = (char **)value;
+ assert(*path);
+ if (str_eq(*path, "")) {
+ // The empty string means "disable" in this case.
+ return true;
+ } else if (is_absolute_path(*path)) {
+ return true;
+ } else {
+ *errmsg = format("not an absolute path: \"%s\"", *path);
+ return false;
+ }
+}
+
+bool
+confitem_verify_dir_levels(void *value, char **errmsg)
+{
+ unsigned *levels = (unsigned *)value;
+ assert(levels);
+ if (*levels >= 1 && *levels <= 8) {
+ return true;
+ } else {
+ *errmsg = format("cache directory levels must be between 1 and 8");
+ return false;
+ }
+}
%readonly-tables
%define hash-function-name confitems_hash
%define lookup-function-name confitems_get
-%define initializer-suffix ,0,NULL,0,NULL,NULL
+%define initializer-suffix ,0,0,NULL,NULL,NULL
+%{
+#include "confitems.h"
+#include "conf.h"
+
+#undef bool
+#define ITEM_ENTRY(name, type, verify_fn) \
+ offsetof(struct conf, name), confitem_parse_ ## type, \
+ confitem_format_ ## type, verify_fn
+#define ITEM(name, type) \
+ ITEM_ENTRY(name, type, NULL)
+#define ITEM_V(name, type, verification) \
+ ITEM_ENTRY(name, type, confitem_verify_ ## verification)
+%}
struct conf_item;
%%
base_dir, 0, ITEM_V(base_dir, env_string, absolute_path)
hash_dir, 13, ITEM(hash_dir, bool)
ignore_headers_in_manifest, 14, ITEM(ignore_headers_in_manifest, env_string)
keep_comments_cpp, 15, ITEM(keep_comments_cpp, bool)
-limit_multiple, 16, ITEM(limit_multiple, float)
+limit_multiple, 16, ITEM(limit_multiple, double)
log_file, 17, ITEM(log_file, env_string)
max_files, 18, ITEM(max_files, unsigned)
max_size, 19, ITEM(max_size, size)
--- /dev/null
+#ifndef CONFITEMS_H
+#define CONFITEMS_H
+
+#include "system.h"
+
+typedef bool (*conf_item_parser)(const char *str, void *result, char **errmsg);
+typedef bool (*conf_item_verifier)(void *value, char **errmsg);
+typedef char *(*conf_item_formatter)(void *value);
+
+struct conf_item {
+ const char *name;
+ size_t number;
+ size_t offset;
+ conf_item_parser parser;
+ conf_item_formatter formatter;
+ conf_item_verifier verifier;
+};
+
+bool confitem_parse_bool(const char *str, void *result, char **errmsg);
+char *confitem_format_bool(void *value);
+
+bool confitem_parse_env_string(const char *str, void *result, char **errmsg);
+char *confitem_format_env_string(void *value);
+
+bool confitem_parse_double(const char *str, void *result, char **errmsg);
+char *confitem_format_double(void *value);
+
+bool confitem_parse_size(const char *str, void *result, char **errmsg);
+char *confitem_format_size(void *value);
+
+bool confitem_parse_sloppiness(const char *str, void *result, char **errmsg);
+char *confitem_format_sloppiness(void *value);
+
+bool confitem_parse_string(const char *str, void *result, char **errmsg);
+char *confitem_format_string(void *value);
+
+bool confitem_parse_umask(const char *str, void *result, char **errmsg);
+char *confitem_format_umask(void *value);
+
+bool confitem_parse_unsigned(const char *str, void *result, char **errmsg);
+char *confitem_format_unsigned(void *value);
+
+bool confitem_verify_absolute_path(void *value, char **errmsg);
+bool confitem_verify_dir_levels(void *value, char **errmsg);
+
+const struct conf_item *confitems_get(const char *str, size_t len);
+size_t confitems_count(void);
+
+#endif
-/* ANSI-C code produced by gperf version 3.0.4 */
+/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf src/confitems.gperf */
/* Computed positions: -k'1-2' */
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
-#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
#line 8 "src/confitems.gperf"
+
+#include "confitems.h"
+#include "conf.h"
+
+#undef bool
+#define ITEM_ENTRY(name, type, verify_fn) \
+ offsetof(struct conf, name), confitem_parse_ ## type, \
+ confitem_format_ ## type, verify_fn
+#define ITEM(name, type) \
+ ITEM_ENTRY(name, type, NULL)
+#define ITEM_V(name, type, verification) \
+ ITEM_ENTRY(name, type, confitem_verify_ ## verification)
+#line 21 "src/confitems.gperf"
struct conf_item;
/* maximum key range = 48, duplicates = 0 */
#endif
#endif
static unsigned int
-confitems_hash (register const char *str, register unsigned int len)
+confitems_hash (register const char *str, register size_t len)
{
static const unsigned char asso_values[] =
{
return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]];
}
-static
-#ifdef __GNUC__
-__inline
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
const struct conf_item *
-confitems_get (register const char *str, register unsigned int len)
+confitems_get (register const char *str, register size_t len)
{
enum
{
static const struct conf_item wordlist[] =
{
- {"",0,NULL,0,NULL,NULL}, {"",0,NULL,0,NULL,NULL},
- {"",0,NULL,0,NULL,NULL}, {"",0,NULL,0,NULL,NULL},
-#line 30 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
+ {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
+#line 43 "src/confitems.gperf"
{"path", 20, ITEM(path, env_string)},
- {"",0,NULL,0,NULL,NULL}, {"",0,NULL,0,NULL,NULL},
- {"",0,NULL,0,NULL,NULL},
-#line 13 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
+ {"",0,0,NULL,NULL,NULL},
+#line 26 "src/confitems.gperf"
{"compiler", 3, ITEM(compiler, string)},
-#line 11 "src/confitems.gperf"
+#line 24 "src/confitems.gperf"
{"cache_dir", 1, ITEM(cache_dir, env_string)},
- {"",0,NULL,0,NULL,NULL},
-#line 15 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL},
+#line 28 "src/confitems.gperf"
{"compression", 5, ITEM(compression, bool)},
- {"",0,NULL,0,NULL,NULL},
-#line 17 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL},
+#line 30 "src/confitems.gperf"
{"cpp_extension", 7, ITEM(cpp_extension, string)},
-#line 14 "src/confitems.gperf"
+#line 27 "src/confitems.gperf"
{"compiler_check", 4, ITEM(compiler_check, string)},
-#line 18 "src/confitems.gperf"
+#line 31 "src/confitems.gperf"
{"debug", 8, ITEM(debug, bool)},
-#line 12 "src/confitems.gperf"
+#line 25 "src/confitems.gperf"
{"cache_dir_levels", 2, ITEM_V(cache_dir_levels, unsigned, dir_levels)},
-#line 16 "src/confitems.gperf"
+#line 29 "src/confitems.gperf"
{"compression_level", 6, ITEM(compression_level, unsigned)},
-#line 27 "src/confitems.gperf"
+#line 40 "src/confitems.gperf"
{"log_file", 17, ITEM(log_file, env_string)},
-#line 32 "src/confitems.gperf"
+#line 45 "src/confitems.gperf"
{"prefix_command", 22, ITEM(prefix_command, env_string)},
-#line 39 "src/confitems.gperf"
+#line 52 "src/confitems.gperf"
{"stats", 29, ITEM(stats, bool)},
-#line 31 "src/confitems.gperf"
+#line 44 "src/confitems.gperf"
{"pch_external_checksum", 21, ITEM(pch_external_checksum, bool)},
-#line 36 "src/confitems.gperf"
+#line 49 "src/confitems.gperf"
{"recache", 26, ITEM(recache, bool)},
-#line 33 "src/confitems.gperf"
+#line 46 "src/confitems.gperf"
{"prefix_command_cpp", 23, ITEM(prefix_command_cpp, env_string)},
-#line 34 "src/confitems.gperf"
+#line 47 "src/confitems.gperf"
{"read_only", 24, ITEM(read_only, bool)},
-#line 38 "src/confitems.gperf"
+#line 51 "src/confitems.gperf"
{"sloppiness", 28, ITEM(sloppiness, sloppiness)},
- {"",0,NULL,0,NULL,NULL},
-#line 25 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL},
+#line 38 "src/confitems.gperf"
{"keep_comments_cpp", 15, ITEM(keep_comments_cpp, bool)},
-#line 29 "src/confitems.gperf"
+#line 42 "src/confitems.gperf"
{"max_size", 19, ITEM(max_size, size)},
-#line 28 "src/confitems.gperf"
+#line 41 "src/confitems.gperf"
{"max_files", 18, ITEM(max_files, unsigned)},
-#line 42 "src/confitems.gperf"
+#line 55 "src/confitems.gperf"
{"unify", 32, ITEM(unify, bool)},
-#line 35 "src/confitems.gperf"
+#line 48 "src/confitems.gperf"
{"read_only_direct", 25, ITEM(read_only_direct, bool)},
-#line 20 "src/confitems.gperf"
+#line 33 "src/confitems.gperf"
{"disable", 10, ITEM(disable, bool)},
-#line 40 "src/confitems.gperf"
+#line 53 "src/confitems.gperf"
{"temporary_dir", 30, ITEM(temporary_dir, env_string)},
-#line 37 "src/confitems.gperf"
+#line 50 "src/confitems.gperf"
{"run_second_cpp", 27, ITEM(run_second_cpp, bool)},
- {"",0,NULL,0,NULL,NULL},
-#line 19 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL},
+#line 32 "src/confitems.gperf"
{"direct_mode", 9, ITEM(direct_mode, bool)},
- {"",0,NULL,0,NULL,NULL},
-#line 23 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL},
+#line 36 "src/confitems.gperf"
{"hash_dir", 13, ITEM(hash_dir, bool)},
-#line 22 "src/confitems.gperf"
+#line 35 "src/confitems.gperf"
{"hard_link", 12, ITEM(hard_link, bool)},
-#line 41 "src/confitems.gperf"
+#line 54 "src/confitems.gperf"
{"umask", 31, ITEM(umask, umask)},
- {"",0,NULL,0,NULL,NULL}, {"",0,NULL,0,NULL,NULL},
-#line 10 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
+#line 23 "src/confitems.gperf"
{"base_dir", 0, ITEM_V(base_dir, env_string, absolute_path)},
-#line 21 "src/confitems.gperf"
+#line 34 "src/confitems.gperf"
{"extra_files_to_hash", 11, ITEM(extra_files_to_hash, env_string)},
- {"",0,NULL,0,NULL,NULL}, {"",0,NULL,0,NULL,NULL},
- {"",0,NULL,0,NULL,NULL}, {"",0,NULL,0,NULL,NULL},
-#line 26 "src/confitems.gperf"
- {"limit_multiple", 16, ITEM(limit_multiple, float)},
- {"",0,NULL,0,NULL,NULL},
-#line 24 "src/confitems.gperf"
+ {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
+ {"",0,0,NULL,NULL,NULL}, {"",0,0,NULL,NULL,NULL},
+#line 39 "src/confitems.gperf"
+ {"limit_multiple", 16, ITEM(limit_multiple, double)},
+ {"",0,0,NULL,NULL,NULL},
+#line 37 "src/confitems.gperf"
{"ignore_headers_in_manifest", 14, ITEM(ignore_headers_in_manifest, env_string)}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = confitems_hash (str, len);
+ register unsigned int key = confitems_hash (str, len);
- if (key <= MAX_HASH_VALUE && key >= 0)
+ if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;
}
return 0;
}
-static const size_t CONFITEMS_TOTAL_KEYWORDS = 33;
+size_t confitems_count(void) { return 33; }
%define lookup-function-name envtoconfitems_get
%define slot-name env_name
%define initializer-suffix ,""
+%{
+#include "envtoconfitems.h"
+%}
struct env_to_conf_item;
%%
BASEDIR, "base_dir"
--- /dev/null
+#ifndef ENVTOCONFITEMS_H
+#define ENVTOCONFITEMS_H
+
+#include "system.h"
+
+struct env_to_conf_item {
+ const char *env_name;
+ const char *conf_name;
+};
+
+const struct env_to_conf_item *envtoconfitems_get(const char *str, size_t len);
+size_t envtoconfitems_count(void);
+
+#endif
-/* ANSI-C code produced by gperf version 3.0.4 */
+/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf src/envtoconfitems.gperf */
/* Computed positions: -k'4-5' */
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
-#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
#line 9 "src/envtoconfitems.gperf"
+
+#include "envtoconfitems.h"
+#line 12 "src/envtoconfitems.gperf"
struct env_to_conf_item;
/* maximum key range = 52, duplicates = 0 */
#endif
#endif
static unsigned int
-envtoconfitems_hash (register const char *str, register unsigned int len)
+envtoconfitems_hash (register const char *str, register size_t len)
{
static const unsigned char asso_values[] =
{
54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
54, 54, 54, 54, 54, 54
};
- register int hval = len;
+ register unsigned int hval = len;
switch (hval)
{
return hval;
}
-static
-#ifdef __GNUC__
-__inline
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
const struct env_to_conf_item *
-envtoconfitems_get (register const char *str, register unsigned int len)
+envtoconfitems_get (register const char *str, register size_t len)
{
enum
{
static const struct env_to_conf_item wordlist[] =
{
{"",""}, {"",""},
-#line 12 "src/envtoconfitems.gperf"
+#line 15 "src/envtoconfitems.gperf"
{"CC", "compiler"},
-#line 19 "src/envtoconfitems.gperf"
+#line 22 "src/envtoconfitems.gperf"
{"DIR", "cache_dir"},
-#line 17 "src/envtoconfitems.gperf"
- {"CPP2", "run_second_cpp"},
#line 20 "src/envtoconfitems.gperf"
+ {"CPP2", "run_second_cpp"},
+#line 23 "src/envtoconfitems.gperf"
{"DEBUG", "debug"},
{"",""},
-#line 42 "src/envtoconfitems.gperf"
+#line 45 "src/envtoconfitems.gperf"
{"TEMPDIR", "temporary_dir"},
-#line 13 "src/envtoconfitems.gperf"
+#line 16 "src/envtoconfitems.gperf"
{"COMPILER", "compiler"},
-#line 33 "src/envtoconfitems.gperf"
+#line 36 "src/envtoconfitems.gperf"
{"PATH", "path"},
-#line 40 "src/envtoconfitems.gperf"
+#line 43 "src/envtoconfitems.gperf"
{"SLOPPINESS", "sloppiness"},
{"",""},
-#line 26 "src/envtoconfitems.gperf"
+#line 29 "src/envtoconfitems.gperf"
{"HASHDIR", "hash_dir"},
-#line 14 "src/envtoconfitems.gperf"
+#line 17 "src/envtoconfitems.gperf"
{"COMPILERCHECK", "compiler_check"},
-#line 28 "src/envtoconfitems.gperf"
+#line 31 "src/envtoconfitems.gperf"
{"LIMIT_MULTIPLE", "limit_multiple"},
-#line 44 "src/envtoconfitems.gperf"
+#line 47 "src/envtoconfitems.gperf"
{"UNIFY", "unify"},
-#line 35 "src/envtoconfitems.gperf"
+#line 38 "src/envtoconfitems.gperf"
{"PREFIX", "prefix_command"},
-#line 29 "src/envtoconfitems.gperf"
+#line 32 "src/envtoconfitems.gperf"
{"LOGFILE", "log_file"},
-#line 30 "src/envtoconfitems.gperf"
+#line 33 "src/envtoconfitems.gperf"
{"MAXFILES", "max_files"},
{"",""},
-#line 36 "src/envtoconfitems.gperf"
+#line 39 "src/envtoconfitems.gperf"
{"PREFIX_CPP", "prefix_command_cpp"},
-#line 21 "src/envtoconfitems.gperf"
+#line 24 "src/envtoconfitems.gperf"
{"DIRECT", "direct_mode"},
-#line 11 "src/envtoconfitems.gperf"
+#line 14 "src/envtoconfitems.gperf"
{"BASEDIR", "base_dir"},
-#line 15 "src/envtoconfitems.gperf"
+#line 18 "src/envtoconfitems.gperf"
{"COMPRESS", "compression"},
-#line 23 "src/envtoconfitems.gperf"
+#line 26 "src/envtoconfitems.gperf"
{"EXTENSION", "cpp_extension"},
-#line 41 "src/envtoconfitems.gperf"
+#line 44 "src/envtoconfitems.gperf"
{"STATS", "stats"},
{"",""},
-#line 31 "src/envtoconfitems.gperf"
+#line 34 "src/envtoconfitems.gperf"
{"MAXSIZE", "max_size"},
-#line 16 "src/envtoconfitems.gperf"
+#line 19 "src/envtoconfitems.gperf"
{"COMPRESSLEVEL", "compression_level"},
{"",""},
-#line 34 "src/envtoconfitems.gperf"
+#line 37 "src/envtoconfitems.gperf"
{"PCH_EXTSUM", "pch_external_checksum"},
{"",""},
-#line 39 "src/envtoconfitems.gperf"
+#line 42 "src/envtoconfitems.gperf"
{"RECACHE", "recache"},
-#line 37 "src/envtoconfitems.gperf"
+#line 40 "src/envtoconfitems.gperf"
{"READONLY", "read_only"},
{"",""},
-#line 43 "src/envtoconfitems.gperf"
+#line 46 "src/envtoconfitems.gperf"
{"UMASK", "umask"},
{"",""},
-#line 32 "src/envtoconfitems.gperf"
+#line 35 "src/envtoconfitems.gperf"
{"NLEVELS", "cache_dir_levels"},
-#line 18 "src/envtoconfitems.gperf"
+#line 21 "src/envtoconfitems.gperf"
{"COMMENTS", "keep_comments_cpp"},
{"",""},
-#line 38 "src/envtoconfitems.gperf"
+#line 41 "src/envtoconfitems.gperf"
{"READONLY_DIRECT", "read_only_direct"},
{"",""},
-#line 22 "src/envtoconfitems.gperf"
- {"DISABLE", "disable"},
#line 25 "src/envtoconfitems.gperf"
+ {"DISABLE", "disable"},
+#line 28 "src/envtoconfitems.gperf"
{"HARDLINK", "hard_link"},
{"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""},
-#line 24 "src/envtoconfitems.gperf"
+#line 27 "src/envtoconfitems.gperf"
{"EXTRAFILES", "extra_files_to_hash"},
{"",""}, {"",""},
-#line 27 "src/envtoconfitems.gperf"
+#line 30 "src/envtoconfitems.gperf"
{"IGNOREHEADERS", "ignore_headers_in_manifest"}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = envtoconfitems_hash (str, len);
+ register unsigned int key = envtoconfitems_hash (str, len);
- if (key <= MAX_HASH_VALUE && key >= 0)
+ if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].env_name;
}
return 0;
}
-static const size_t ENVTOCONFITEMS_TOTAL_KEYWORDS = 34;
+size_t envtoconfitems_count(void) { return 34; }
--- /dev/null
+/*
+ * getopt_long() -- long options parser
+ *
+ * Portions Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Portions Copyright (c) 2003
+ * PostgreSQL Global Development Group
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#ifndef HAVE_GETOPT_LONG
+
+#include "getopt_long.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#define BADCH '?'
+#define BADARG ':'
+#define EMSG ""
+
+int
+getopt_long(int argc, char *const argv[],
+ const char *optstring,
+ const struct option * longopts, int *longindex)
+{
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (!*place)
+ { /* update scanning pointer */
+ if (optind >= argc)
+ {
+ place = EMSG;
+ return -1;
+ }
+
+ place = argv[optind];
+
+ if (place[0] != '-')
+ {
+ place = EMSG;
+ return -1;
+ }
+
+ place++;
+
+ if (place[0] == '-' && place[1] == '\0')
+ { /* found "--" */
+ ++optind;
+ place = EMSG;
+ return -1;
+ }
+
+ if (place[0] == '-' && place[1])
+ {
+ /* long option */
+ size_t namelen;
+ int i;
+
+ place++;
+
+ namelen = strcspn(place, "=");
+ for (i = 0; longopts[i].name != NULL; i++)
+ {
+ if (strlen(longopts[i].name) == namelen
+ && strncmp(place, longopts[i].name, namelen) == 0)
+ {
+ if (longopts[i].has_arg)
+ {
+ if (place[namelen] == '=')
+ optarg = place + namelen + 1;
+ else if (optind < argc - 1)
+ {
+ optind++;
+ optarg = argv[optind];
+ }
+ else
+ {
+ if (optstring[0] == ':')
+ return BADARG;
+ if (opterr)
+ fprintf(stderr,
+ "%s: option requires an argument -- %s\n",
+ argv[0], place);
+ place = EMSG;
+ optind++;
+ return BADCH;
+ }
+ }
+ else
+ {
+ optarg = NULL;
+ if (place[namelen] != 0)
+ {
+ /* XXX error? */
+ }
+ }
+
+ optind++;
+
+ if (longindex)
+ *longindex = i;
+
+ place = EMSG;
+
+ if (longopts[i].flag == NULL)
+ return longopts[i].val;
+ else
+ {
+ *longopts[i].flag = longopts[i].val;
+ return 0;
+ }
+ }
+ }
+
+ if (opterr && optstring[0] != ':')
+ fprintf(stderr,
+ "%s: illegal option -- %s\n", argv[0], place);
+ place = EMSG;
+ optind++;
+ return BADCH;
+ }
+ }
+
+ /* short option */
+ optopt = (int) *place++;
+
+ oli = strchr(optstring, optopt);
+ if (!oli)
+ {
+ if (!*place)
+ ++optind;
+ if (opterr && *optstring != ':')
+ fprintf(stderr,
+ "%s: illegal option -- %c\n", argv[0], optopt);
+ return BADCH;
+ }
+
+ if (oli[1] != ':')
+ { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else
+ { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (argc <= ++optind)
+ { /* no arg */
+ place = EMSG;
+ if (*optstring == ':')
+ return BADARG;
+ if (opterr)
+ fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ argv[0], optopt);
+ return BADCH;
+ }
+ else
+ /* white space */
+ optarg = argv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return optopt;
+}
+
+#endif /* HAVE_GETOPT_LONG */
{
mdfour_update(&hash->md, (const unsigned char *)s, len);
if (len > 0 && hash->debug_binary) {
- fwrite(s, 1, len, hash->debug_binary);
+ (void) fwrite(s, 1, len, hash->debug_binary);
}
}
do_debug_text(struct hash *hash, const void *s, size_t len)
{
if (len > 0 && hash->debug_text) {
- fwrite(s, 1, len, hash->debug_text);
+ (void) fwrite(s, 1, len, hash->debug_text);
}
}
// Statistics fields in display order.
static struct {
enum stats stat;
- char *message;
+ const char *message;
format_fn *format_fn; // NULL -> use plain integer format
unsigned flags;
} stats_info[] = {
unsigned hit = direct + preprocessed;
unsigned miss = counters->data[STATS_TOCACHE];
unsigned total = hit + miss;
- double percent = total > 0 ? (100.0f * hit) / total : 0.0f;
+ double percent = total > 0 ? (100.0 * hit) / total : 0.0;
printf("cache hit rate %6.2f %%\n", percent);
}
}
#include "ccache.h"
#include "hash.h"
+#include "unify.h"
static bool print_unified = true;
}
// Copy the current log memory buffer to an output file.
-bool
+void
cc_dump_log_buffer(const char *path)
{
FILE *file = fopen(path, "w");
- fwrite(logbuffer, 1, logsize, file);
+ (void) fwrite(logbuffer, 1, logsize, file);
fclose(file);
- return true;
}
// Something went badly wrong!
-extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "3.5";
+extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "3.5.1";
}
bool
-cct_check_float_eq(const char *file, int line, const char *expression,
- double expected, double actual)
+cct_check_double_eq(const char *file, int line, const char *expression,
+ double expected, double actual)
{
if (fabs(expected - actual) < DBL_EPSILON) {
cct_check_passed(file, line, expression);
return true;
} else {
- char *exp_str = format("%.1f", (double)expected);
- char *act_str = format("%.1f", (double)actual);
+ char *exp_str = format("%.1f", expected);
+ char *act_str = format("%.1f", actual);
cct_check_failed(file, line, expression, exp_str, act_str);
free(exp_str);
free(act_str);
// ============================================================================
-#define CHECK_FLOAT_EQ(expected, actual) \
+#define CHECK_DOUBLE_EQ(expected, actual) \
do { \
- if (!cct_check_float_eq(__FILE__, __LINE__, #actual, (expected), \
- (actual))) { \
+ if (!cct_check_double_eq(__FILE__, __LINE__, #actual, (expected), \
+ (actual))) { \
cct_test_end(); \
cct_suite_end(); \
return _test_counter; \
void cct_check_passed(const char *file, int line, const char *assertion);
void cct_check_failed(const char *file, int line, const char *assertion,
const char *expected, const char *actual);
-bool cct_check_float_eq(const char *file, int line, const char *expression,
- double expected, double actual);
+bool cct_check_double_eq(const char *file, int line, const char *expression,
+ double expected, double actual);
bool cct_check_int_eq(const char *file, int line, const char *expression,
int64_t expected, int64_t actual);
bool cct_check_str_eq(const char *file, int line, const char *expression,
CHECK(conf->hash_dir);
CHECK_STR_EQ("", conf->ignore_headers_in_manifest);
CHECK(!conf->keep_comments_cpp);
- CHECK_FLOAT_EQ(0.8f, conf->limit_multiple);
+ CHECK_DOUBLE_EQ(0.8, conf->limit_multiple);
CHECK_STR_EQ("", conf->log_file);
CHECK_INT_EQ(0, conf->max_files);
CHECK_INT_EQ((uint64_t)5 * 1000 * 1000 * 1000, conf->max_size);
CHECK(!conf->hash_dir);
CHECK_STR_EQ("a:b/c", conf->ignore_headers_in_manifest);
CHECK(conf->keep_comments_cpp);
- CHECK_FLOAT_EQ(1.0, conf->limit_multiple);
+ CHECK_DOUBLE_EQ(1.0, conf->limit_multiple);
CHECK_STR_EQ_FREE1(format("%s%s", user, user), conf->log_file);
CHECK_INT_EQ(17, conf->max_files);
CHECK_INT_EQ(123 * 1000 * 1000, conf->max_size);
FILE *log = fopen("log", "r");
CHECK(log);
char buf[100];
- CHECK(fgets(buf, 100, log));
+ CHECK(fgets(buf, sizeof(buf), log));
CHECK_STR_EQ("42\n", buf);
fclose(log);
}
FILE *log = fopen("log", "r");
CHECK(log);
char buf[100];
- CHECK(!fgets(buf, 100, log));
+ CHECK(!fgets(buf, sizeof(buf), log));
fclose(log);
}
conf_free(conf);