if (quoting) {
break;
}
- /* Fall through */
+ /* Fall through */
case '\0':
/* end of token */
}
dest->argv = (char **)x_realloc(
- dest->argv,
- (src->argc + dest->argc + 1 - offset) *
- sizeof(char *));
+ dest->argv,
+ (src->argc + dest->argc + 1 - offset) *
+ sizeof(char *));
/* Shift arguments over */
for (i = dest->argc; i >= index + offset; i--) {
}
if (str_startswith(p, ".nfs")) {
- /* Ignore temporary NFS files that may be left for open but deleted files. */
+ /* Ignore temporary NFS files that may be left for open but deleted
+ * files. */
goto out;
}
struct compopt key;
key.name = option;
return bsearch(
- &key, compopts, sizeof(compopts) / sizeof(compopts[0]),
- sizeof(compopts[0]), compare_compopts);
+ &key, compopts, sizeof(compopts) / sizeof(compopts[0]),
+ sizeof(compopts[0]), compare_compopts);
}
static const struct compopt *
struct compopt key;
key.name = option;
return bsearch(
- &key, compopts, sizeof(compopts) / sizeof(compopts[0]),
- sizeof(compopts[0]), compare_prefix_compopts);
+ &key, compopts, sizeof(compopts) / sizeof(compopts[0]),
+ sizeof(compopts[0]), compare_prefix_compopts);
}
/* Runs fn on the first two characters of option. */
}
}
-static const char*
+static const char *
bool_to_string(bool value)
{
return value ? "true" : "false";
}
#define ITEM(name, type) \
- parse_##type, offsetof(struct conf, name), NULL
+ parse_ ## type, offsetof(struct conf, name), NULL
#define ITEM_V(name, type, verification) \
- parse_##type, offsetof(struct conf, name), verify_##verification
+ parse_ ## type, offsetof(struct conf, name), verify_ ## verification
#include "confitems_lookup.c"
#include "envtoconfitems_lookup.c"
}
if (!handle_conf_setting(
- conf, env_to_conf_item->conf_name, q, &errmsg2, true, negate,
- "environment")) {
+ conf, env_to_conf_item->conf_name, q, &errmsg2, true, negate,
+ "environment")) {
*errmsg = format("%s: %s", key, errmsg2);
free(errmsg2);
free(key);
uncrustify_exclude_files = \
getopt_long.c \
hashtable.c \
- hashtable_itr.c
+ hashtable_itr.c \
+ snprintf.c
ifneq ($(shell sed 's/.*"\(.*\)".*/\1/' version.c 2>/dev/null),$(version))
$(shell echo 'const char CCACHE_VERSION[] = "$(version)";' >version.c)
DWORD dw = GetLastError();
FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf,
- 0, NULL);
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf,
+ 0, NULL);
lpDisplayBuf =
- (LPVOID) LocalAlloc(LMEM_ZEROINIT,
- (lstrlen((LPCTSTR) lpMsgBuf)
- + lstrlen((LPCTSTR) __FILE__) + 200)
- * sizeof(TCHAR));
+ (LPVOID) LocalAlloc(LMEM_ZEROINIT,
+ (lstrlen((LPCTSTR) lpMsgBuf)
+ + lstrlen((LPCTSTR) __FILE__) + 200)
+ * sizeof(TCHAR));
_snprintf((LPTSTR) lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("%s failed with error %d: %s"), __FILE__, dw, lpMsgBuf);
cc_log("can't execute %s; OS returned error: %s",
- full_path_win_ext, (char*)lpDisplayBuf);
+ full_path_win_ext, (char *)lpDisplayBuf);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
#else
-/*
- execute a compiler backend, capturing all output to the given paths
- the full path to the compiler to run is in argv[0]
-*/
+/* Execute a compiler backend, capturing all output to the given paths the full
+ * path to the compiler to run is in argv[0]. */
int
execute(char **argv, int fd_out, int fd_err)
{
/*
* Find an executable by name in $PATH. Exclude any that are links to
* exclude_name.
-*/
+ */
char *
find_executable(const char *name, const char *exclude_name)
{
static void
call_nullary_exit_function(void *context)
{
- struct nullary_exit_function *p = (struct nullary_exit_function*)context;
+ struct nullary_exit_function *p = (struct nullary_exit_function *)context;
p->function();
free(p);
}
void
hash_string_length(struct mdfour *md, const char *s, int length)
{
- hash_buffer(md, s, length);
+ hash_buffer(md, s, length);
}
void
file_hashes_equal(struct file_hash *fh1, struct file_hash *fh2)
{
return memcmp(fh1->hash, fh2->hash, 16) == 0
- && fh1->size == fh2->size;
+ && fh1->size == fh2->size;
}
/*
if (str[i - 5] == 'D' && str[i - 4] == 'A' &&
str[i - 3] == 'T') {
result |= HASH_SOURCE_CODE_FOUND_DATE;
- }
- else if (str[i - 5] == 'T' && str[i - 4] == 'I' &&
- str[i - 3] == 'M') {
+ } else if (str[i - 5] == 'T' && str[i - 4] == 'I' &&
+ str[i - 3] == 'M') {
result |= HASH_SOURCE_CODE_FOUND_TIME;
}
}
*/
int
hash_source_code_string(
- struct conf *conf, struct mdfour *hash, const char *str, size_t len,
- const char *path)
+ struct conf *conf, struct mdfour *hash, const char *str, size_t len,
+ const char *path)
{
int result = HASH_SOURCE_CODE_OK;
CreatePipe(&pipe_out[0], &pipe_out[1], &sa, 0);
SetHandleInformation(pipe_out[0], HANDLE_FLAG_INHERIT, 0);
si.hStdOutput = pipe_out[1];
- si.hStdError = pipe_out[1];
- si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
- si.dwFlags = STARTF_USESTDHANDLES;
+ si.hStdError = pipe_out[1];
+ si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ si.dwFlags = STARTF_USESTDHANDLES;
win32args = win32argvtos(sh, args->argv);
ret = CreateProcess(path, win32args, NULL, NULL, 1, 0, NULL, NULL, &si, &pi);
CloseHandle(pipe_out[1]);
{".HXX", "c++-header"},
{".tcc", "c++-header"},
{".TCC", "c++-header"},
- {NULL, NULL}};
+ {NULL, NULL}
+};
/*
* Supported languages and corresponding preprocessed languages.
{"objc++-cpp-output", "objective-c++-cpp-output"},
{"objective-c++-header", "objective-c++-cpp-output"},
{"objective-c++-cpp-output", "objective-c++-cpp-output"},
- {NULL, NULL}};
+ {NULL, NULL}
+};
/*
* Guess the language of a file based on its extension. Returns NULL if the
static const uint32_t MAX_MANIFEST_FILE_INFO_ENTRIES = 10000;
#define ccache_static_assert(e) \
- do { enum { ccache_static_assert__ = 1/(e) }; } while (false)
+ do { enum { ccache_static_assert__ = 1/(e) }; } while (false)
struct file_info {
/* Index to n_files. */
}
#define READ_BYTE(var) \
- do { \
+ do { \
int ch_; \
ch_ = gzgetc(f); \
if (ch_ == EOF) { \
} while (false)
#define READ_INT(size, var) \
- do { \
+ do { \
int ch_; \
size_t i_; \
(var) = 0; \
} while (false)
#define READ_STR(var) \
- do { \
+ do { \
char buf_[1024]; \
size_t i_; \
int ch_; \
} while (false)
#define READ_BYTES(n, var) \
- do { \
+ do { \
size_t i_; \
int ch_; \
for (i_ = 0; i_ < (n); i_++) { \
for (i = 0; i < mf->n_objects; i++) {
READ_INT(4, mf->objects[i].n_file_info_indexes);
mf->objects[i].file_info_indexes =
- x_calloc(mf->objects[i].n_file_info_indexes,
- sizeof(*mf->objects[i].file_info_indexes));
+ x_calloc(mf->objects[i].n_file_info_indexes,
+ sizeof(*mf->objects[i].file_info_indexes));
for (j = 0; j < mf->objects[i].n_file_info_indexes; j++) {
READ_INT(4, mf->objects[i].file_info_indexes[j]);
}
}
#define WRITE_INT(size, var) \
- do { \
+ do { \
uint8_t ch_; \
size_t i_; \
for (i_ = 0; i_ < (size); i_++) { \
} while (false)
#define WRITE_STR(var) \
- do { \
+ do { \
if (gzputs(f, var) == EOF || gzputc(f, '\0') == EOF) { \
goto error; \
} \
} while (false)
#define WRITE_BYTES(n, var) \
- do { \
+ do { \
size_t i_; \
for (i_ = 0; i_ < (n); i_++) { \
if (gzputc(f, (var)[i_]) == EOF) { \
&& MAX(st->mtime, st->ctime) >= time_of_compilation) {
cc_log("size/mtime/ctime hit for %s", path);
continue;
- }
- else {
+ } else {
cc_log("size/mtime/ctime miss for %s", path);
}
}
&& time_of_compilation > MAX(file_stat.st_mtime, file_stat.st_ctime)) {
fi.mtime = file_stat.st_mtime;
fi.ctime = file_stat.st_ctime;
- }
- else {
+ } else {
fi.mtime = -1;
fi.ctime = -1;
}
#define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32)))
#define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s)
-#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s)
-#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s)
+#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c, \
+ d) + M[k] + 0x5A827999)&MASK32,s)
+#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c, \
+ d) + M[k] + 0x6ED9EBA1)&MASK32,s)
/* this applies md4 to 64 byte chunks */
static void
for (i = 0; i < 16; i++)
M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
- (in[i*4+1]<<8) | (in[i*4+0]<<0);
+ (in[i*4+1]<<8) | (in[i*4+0]<<0);
#else
memcpy(M, in, 16*4);
#endif
#ifdef CCACHE_DEBUG_HASH
if (getenv("CCACHE_DEBUG_HASH")) {
- FILE* f = fopen("ccache-debug-hash.bin", "a");
+ FILE *f = fopen("ccache-debug-hash.bin", "a");
fwrite(in, 1, n, f);
fclose(f);
}
while (len >= 4) {
unsigned int k;
- k = data[0];
+ k = data[0];
k |= data[1] << 8;
k |= data[2] << 16;
k |= data[3] << 24;
case 3: h ^= data[2] << 16;
case 2: h ^= data[1] << 8;
case 1: h ^= data[0];
- h *= m;
+ h *= m;
};
h ^= h >> 13;
{ STATS_DEVICE, "output to a non-regular file ", NULL, 0 },
{ STATS_NOINPUT, "no input file ", NULL, 0 },
{ STATS_BADEXTRAFILE, "error hashing extra file ", NULL, 0 },
- { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS },
- { STATS_TOTALSIZE, "cache size ", display_size_times_1024 , FLAG_NOZERO|FLAG_ALWAYS },
- { STATS_OBSOLETE_MAXFILES, "OBSOLETE", NULL, FLAG_NOZERO|FLAG_NEVER},
- { STATS_OBSOLETE_MAXSIZE, "OBSOLETE", NULL, FLAG_NOZERO|FLAG_NEVER},
+ { STATS_NUMFILES, "files in cache ", NULL,
+ FLAG_NOZERO|FLAG_ALWAYS },
+ { STATS_TOTALSIZE, "cache size ",
+ display_size_times_1024, FLAG_NOZERO|FLAG_ALWAYS },
+ { STATS_OBSOLETE_MAXFILES, "OBSOLETE", NULL,
+ FLAG_NOZERO|FLAG_NEVER},
+ { STATS_OBSOLETE_MAXSIZE, "OBSOLETE", NULL,
+ FLAG_NOZERO|FLAG_NEVER},
{ STATS_NONE, NULL, NULL, 0 }
};
static const char COLOR_GREEN[] = "\x1b[32m";
static const char COLOR_RED[] = "\x1b[31m";
-#define COLOR(tty, color) ((tty) ? COLOR_##color : "")
+#define COLOR(tty, color) ((tty) ? COLOR_ ## color : "")
static int
is_tty(int fd)
#include "getopt_long.h"
#endif
-#define SUITE(name) unsigned suite_##name(unsigned);
+#define SUITE(name) unsigned suite_ ## name(unsigned);
#include "test/suites.h"
#undef SUITE
const char USAGE_TEXT[] =
- "Usage:\n"
- " test [options]\n"
- "\n"
- "Options:\n"
- " -h, --help print this help text\n"
- " -v, --verbose enable verbose logging of tests\n";
+ "Usage:\n"
+ " test [options]\n"
+ "\n"
+ "Options:\n"
+ " -h, --help print this help text\n"
+ " -v, --verbose enable verbose logging of tests\n";
int
main(int argc, char **argv)
{
suite_fn suites[] = {
-#define SUITE(name) &suite_##name,
+#define SUITE(name) &suite_ ## name,
#include "test/suites.h"
#undef SUITE
NULL
{
struct args *args;
const char *argtext =
- "first\rsec\\\tond\tthi\\\\rd\nfourth \tfif\\ th \"si'x\\\" th\""
- " 'seve\nth'\\";
+ "first\rsec\\\tond\tthi\\\\rd\nfourth \tfif\\ th \"si'x\\\" th\""
+ " 'seve\nth'\\";
create_file("gcc_atfile", argtext);
CHECK_INT_EQ(9, args->argc);
args_insert(args, 1, src5, false);
CHECK_STR_EQ_FREE2(
- "first one alpha beta gamma second beta gamma fourth fifth",
- args_to_string(args));
+ "first one alpha beta gamma second beta gamma fourth fifth",
+ args_to_string(args));
CHECK_INT_EQ(10, args->argc);
args_insert(args, 1, src6, false);
CHECK_STR_EQ_FREE2(
- "first one alpha beta gamma second beta gamma fourth fifth",
- args_to_string(args));
+ "first one alpha beta gamma second beta gamma fourth fifth",
+ args_to_string(args));
CHECK_INT_EQ(10, args->argc);
args_free(args);
" -include test.h -include-pch test.pch -iprefix . -iquote ." \
" -isysroot . -isystem . -iwithprefix . -iwithprefixbefore ." \
" -DTEST_MACRO -DTEST_MACRO2=1 -F. -trigraphs -fworking-directory" \
- " -fno-working-directory -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 "\
+ " -fno-working-directory -MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 " \
" -MQ mq1 -MQ mq2 -Wp,-MD,wpmd -Wp,-MMD,wpmmd"
struct args *orig = args_init_from_string(CMD " -c foo.c -o foo.o");
struct args *exp_cpp = args_init_from_string(CMD);
TEST(dependency_flags_that_take_an_argument_should_not_require_space_delimiter)
{
struct args *orig = args_init_from_string(
- "cc -c -MMD -MFfoo.d -MT mt -MTmt -MQmq foo.c -o foo.o");
+ "cc -c -MMD -MFfoo.d -MT mt -MTmt -MQmq foo.c -o foo.o");
struct args *exp_cpp = args_init_from_string(
- "cc -MMD -MFfoo.d -MT mt -MTmt -MQmq");
+ "cc -MMD -MFfoo.d -MT mt -MTmt -MQmq");
struct args *exp_cc = args_init_from_string("cc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
{
struct args *orig = args_init_from_string(
- "cc -c foo.c -o foo.o -MMD -MT bar -MFfoo.d");
+ "cc -c foo.c -o foo.o -MMD -MT bar -MFfoo.d");
struct args *exp_cpp = args_init_from_string(
- "cc -MMD -MT bar -MFfoo.d");
+ "cc -MMD -MT bar -MFfoo.d");
struct args *exp_cc = args_init_from_string("cc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MT_flag_with_immediate_argument_should_work_as_last_argument)
{
struct args *orig = args_init_from_string(
- "cc -c foo.c -o foo.o -MMD -MFfoo.d -MT foo -MTbar");
+ "cc -c foo.c -o foo.o -MMD -MFfoo.d -MT foo -MTbar");
struct args *exp_cpp = args_init_from_string(
- "cc -MMD -MFfoo.d -MT foo -MTbar");
+ "cc -MMD -MFfoo.d -MT foo -MTbar");
struct args *exp_cc = args_init_from_string("cc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument)
{
struct args *orig = args_init_from_string(
- "cc -c foo.c -o foo.o -MMD -MFfoo.d -MQ foo -MQbar");
+ "cc -c foo.c -o foo.o -MMD -MFfoo.d -MQ foo -MQbar");
struct args *exp_cpp = args_init_from_string(
- "cc -MMD -MFfoo.d -MQ foo -MQbar");
+ "cc -MMD -MFfoo.d -MQ foo -MQbar");
struct args *exp_cc = args_init_from_string("cc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj)
{
struct args *orig = args_init_from_string(
- "gcc -c -MD -MP -MFfoo.d -MQ foo.d foo.c");
+ "gcc -c -MD -MP -MFfoo.d -MQ foo.d foo.c");
struct args *exp_cpp = args_init_from_string(
- "gcc -MD -MP -MFfoo.d -MQ foo.d");
+ "gcc -MD -MP -MFfoo.d -MQ foo.d");
struct args *exp_cc = args_init_from_string("gcc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MT_flag_without_immediate_argument_should_not_add_MTobj)
{
struct args *orig = args_init_from_string(
- "gcc -c -MD -MP -MFfoo.d -MT foo.d foo.c");
+ "gcc -c -MD -MP -MFfoo.d -MT foo.d foo.c");
struct args *exp_cpp = args_init_from_string(
- "gcc -MD -MP -MFfoo.d -MT foo.d");
+ "gcc -MD -MP -MFfoo.d -MT foo.d");
struct args *exp_cc = args_init_from_string("gcc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj)
{
struct args *orig = args_init_from_string(
- "gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c");
+ "gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c");
struct args *exp_cpp = args_init_from_string(
- "gcc -MD -MP -MFfoo.d -MQfoo.d");
+ "gcc -MD -MP -MFfoo.d -MQfoo.d");
struct args *exp_cc = args_init_from_string("gcc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(MT_flag_with_immediate_argument_should_not_add_MQobj)
{
struct args *orig = args_init_from_string(
- "gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c");
+ "gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c");
struct args *exp_cpp = args_init_from_string(
- "gcc -MD -MP -MFfoo.d -MTfoo.d");
+ "gcc -MD -MP -MFfoo.d -MTfoo.d");
struct args *exp_cc = args_init_from_string("gcc -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path)
{
struct args *orig = args_init_from_string(
- "gcc -c -fprofile-generate=some/dir foo.c");
+ "gcc -c -fprofile-generate=some/dir foo.c");
struct args *exp_cpp = args_init_from_string("gcc");
struct args *exp_cc = args_init_from_string("gcc");
struct args *act_cpp = NULL, *act_cc = NULL;
TEST(fprofile_flag_with_nonexisting_dir_not_be_rewritten)
{
struct args *orig = args_init_from_string(
- "gcc -c -fprofile-generate=some/dir foo.c");
+ "gcc -c -fprofile-generate=some/dir foo.c");
struct args *exp_cpp = args_init_from_string(
- "gcc -fprofile-generate=some/dir");
+ "gcc -fprofile-generate=some/dir");
struct args *exp_cc = args_init_from_string(
- "gcc -fprofile-generate=some/dir -c");
+ "gcc -fprofile-generate=some/dir -c");
struct args *act_cpp = NULL, *act_cc = NULL;
create_file("foo.c", "");
user = getenv("USER");
CHECK_STR_EQ("rabbit", user);
create_file(
- "ccache.conf",
- "base_dir = /$USER/foo/${USER} \n"
- "cache_dir=\n"
- "cache_dir = $USER$/${USER}/.ccache\n"
- "\n"
- "\n"
- " #A comment\n"
- " cache_dir_levels = 4\n"
- "\t compiler = foo\n"
- "compiler_check = none\n"
- "compression=true\n"
- "compression_level= 2\n"
- "cpp_extension = .foo\n"
- "direct_mode = false\n"
- "disable = true\n"
- "extra_files_to_hash = a:b c:$USER\n"
- "hard_link = true\n"
- "hash_dir = true\n"
- "log_file = $USER${USER} \n"
- "max_files = 17\n"
- "max_size = 123M\n"
- "path = $USER.x\n"
- "prefix_command = x$USER\n"
- "read_only = true\n"
- "read_only_direct = true\n"
- "recache = true\n"
- "run_second_cpp = true\n"
- "sloppiness = file_macro ,time_macros, include_file_mtime,include_file_ctime,file_stat_matches pch_defines \n"
- "stats = false\n"
- "temporary_dir = ${USER}_foo\n"
- "umask = 777\n"
- "unify = true"); /* Note: no newline */
+ "ccache.conf",
+ "base_dir = /$USER/foo/${USER} \n"
+ "cache_dir=\n"
+ "cache_dir = $USER$/${USER}/.ccache\n"
+ "\n"
+ "\n"
+ " #A comment\n"
+ " cache_dir_levels = 4\n"
+ "\t compiler = foo\n"
+ "compiler_check = none\n"
+ "compression=true\n"
+ "compression_level= 2\n"
+ "cpp_extension = .foo\n"
+ "direct_mode = false\n"
+ "disable = true\n"
+ "extra_files_to_hash = a:b c:$USER\n"
+ "hard_link = true\n"
+ "hash_dir = true\n"
+ "log_file = $USER${USER} \n"
+ "max_files = 17\n"
+ "max_size = 123M\n"
+ "path = $USER.x\n"
+ "prefix_command = x$USER\n"
+ "read_only = true\n"
+ "read_only_direct = true\n"
+ "recache = true\n"
+ "run_second_cpp = true\n"
+ "sloppiness = file_macro ,time_macros, include_file_mtime,include_file_ctime,file_stat_matches pch_defines \n"
+ "stats = false\n"
+ "temporary_dir = ${USER}_foo\n"
+ "umask = 777\n"
+ "unify = true"); /* Note: no newline */
CHECK(conf_read(conf, "ccache.conf", &errmsg));
CHECK(!errmsg);
create_file("ccache.conf", "cache_dir_levels = 0");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
- CHECK_STR_EQ_FREE2("ccache.conf:1: cache directory levels must be between 1 and 8",
- errmsg);
+ CHECK_STR_EQ_FREE2(
+ "ccache.conf:1: cache directory levels must be between 1 and 8",
+ errmsg);
create_file("ccache.conf", "cache_dir_levels = 9");
CHECK(!conf_read(conf, "ccache.conf", &errmsg));
- CHECK_STR_EQ_FREE2("ccache.conf:1: cache directory levels must be between 1 and 8",
- errmsg);
+ CHECK_STR_EQ_FREE2(
+ "ccache.conf:1: cache directory levels must be between 1 and 8",
+ errmsg);
conf_free(conf);
}
true,
true,
SLOPPY_FILE_MACRO|SLOPPY_INCLUDE_FILE_MTIME|
- SLOPPY_INCLUDE_FILE_CTIME|SLOPPY_TIME_MACROS|
- SLOPPY_FILE_STAT_MATCHES,
+ SLOPPY_INCLUDE_FILE_CTIME|SLOPPY_TIME_MACROS|
+ SLOPPY_FILE_STAT_MATCHES,
false,
"td",
022,
CHECK_STR_EQ_FREE2("d9130a8164549fe818874806e1c7014b-14", hash_result(&h));
hash_start(&h);
- hash_string(&h, "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+ hash_string(
+ &h,
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
CHECK_STR_EQ_FREE2("e33b4ddc9c38f2199c3e7b164fcc0536-80", hash_result(&h));
}
TEST(check_for_temporal_macros)
{
const char time_start[] =
- "__TIME__\n"
- "int a;\n";
+ "__TIME__\n"
+ "int a;\n";
const char time_middle[] =
- "#define a __TIME__\n"
- "int a;\n";
+ "#define a __TIME__\n"
+ "int a;\n";
const char time_end[] =
- "#define a __TIME__";
+ "#define a __TIME__";
const char date_start[] =
- "__DATE__\n"
- "int ab;\n";
+ "__DATE__\n"
+ "int ab;\n";
const char date_middle[] =
- "#define ab __DATE__\n"
- "int ab;\n";
+ "#define ab __DATE__\n"
+ "int ab;\n";
const char date_end[] =
- "#define ab __DATE__";
+ "#define ab __DATE__";
const char no_temporal[] =
- "#define ab _ _DATE__\n"
- "#define ab __ DATE__\n"
- "#define ab __D ATE__\n"
- "#define ab __DA TE__\n"
- "#define ab __DAT E__\n"
- "#define ab __DATE __\n"
- "#define ab __DATE_ _\n"
- "#define ab _ _TIME__\n"
- "#define ab __ TIME__\n"
- "#define ab __T IME__\n"
- "#define ab __TI ME__\n"
- "#define ab __TIM E__\n"
- "#define ab __TIME __\n"
- "#define ab __TIME_ _\n";
+ "#define ab _ _DATE__\n"
+ "#define ab __ DATE__\n"
+ "#define ab __D ATE__\n"
+ "#define ab __DA TE__\n"
+ "#define ab __DAT E__\n"
+ "#define ab __DATE __\n"
+ "#define ab __DATE_ _\n"
+ "#define ab _ _TIME__\n"
+ "#define ab __ TIME__\n"
+ "#define ab __T IME__\n"
+ "#define ab __TI ME__\n"
+ "#define ab __TIM E__\n"
+ "#define ab __TIME __\n"
+ "#define ab __TIME_ _\n";
CHECK(check_for_temporal_macros(time_start + 0, sizeof(time_start) - 0));
CHECK(!check_for_temporal_macros(time_start + 1, sizeof(time_start) - 1));
TEST(format_hash_as_string)
{
unsigned char hash[16] = {
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"};
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ };
CHECK_STR_EQ_FREE2("00000000000000000000000000000000",
format_hash_as_string(hash, -1));
CHECK_STR_EQ_FREE2("1.0G",
format_parsable_size_with_suffix(1000 * 1000 * 1000));
CHECK_STR_EQ_FREE2(
- "17.1G",
- format_parsable_size_with_suffix(17.11 * 1000 * 1000 * 1000));
+ "17.1G",
+ format_parsable_size_with_suffix(17.11 * 1000 * 1000 * 1000));
}
TEST(parse_size_with_suffix)
* 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
-*/
+ */
/*
* C/C++ unifier
build_table();
- for (ofs = 0; ofs < size;) {
+ for (ofs = 0; ofs < size; ) {
if (p[ofs] == '#') {
if ((size-ofs) > 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) {
do {
pushchar(hash, p[ofs]);
ofs++;
} while (ofs < size &&
- ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.'));
+ ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.'));
if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) {
do {
pushchar(hash, p[ofs]);
/* hash a file that consists of preprocessor output, but remove any line
number information from the hash
-*/
+ */
int
unify_hash(struct mdfour *hash, const char *fname)
{
if (log_updated_time) {
gettimeofday(&tv, NULL);
#ifdef __MINGW64_VERSION_MAJOR
- tm = localtime((time_t*)&tv.tv_sec);
+ tm = localtime((time_t *)&tv.tv_sec);
#else
tm = localtime(&tv.tv_sec);
#endif
DWORD dw = last_error;
FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf, 0, NULL);
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf, 0, NULL);
lpDisplayBuf = (LPVOID) LocalAlloc(
- LMEM_ZEROINIT,
- (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 200)
- * sizeof(TCHAR));
+ LMEM_ZEROINIT,
+ (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 200)
+ * sizeof(TCHAR));
_snprintf((LPTSTR) lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("%s failed with error %d: %s"), __FILE__, dw,
lpMsgBuf);
- cc_log("can't get hostname OS returned error: %s", (char*)lpDisplayBuf);
+ cc_log("can't get hostname OS returned error: %s", (char *)lpDisplayBuf);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}
char const CACHEDIR_TAG[] =
- "Signature: 8a477f597d28d172789f06886806bc55\n"
- "# This file is a cache directory tag created by ccache.\n"
- "# For information about cache directory tags, see:\n"
- "# http://www.brynosaurus.com/cachedir/\n";
+ "Signature: 8a477f597d28d172789f06886806bc55\n"
+ "# This file is a cache directory tag created by ccache.\n"
+ "# For information about cache directory tags, see:\n"
+ "# http://www.brynosaurus.com/cachedir/\n";
int
create_cachedirtag(const char *dir)
return ptr;
}
-/*
- this is like strdup() but dies if the malloc fails
-*/
+/* This is like strdup() but dies if the malloc fails. */
char *
x_strdup(const char *s)
{
return ret;
}
-/*
- this is like strndup() but dies if the malloc fails
-*/
+/* This is like strndup() but dies if the malloc fails. */
char *
x_strndup(const char *s, size_t n)
{
return ret;
}
-/*
- this is like malloc() but dies if the malloc fails
-*/
+/* This is like malloc() but dies if the malloc fails. */
void *
x_malloc(size_t size)
{
return ret;
}
-/*
- this is like realloc() but dies if the malloc fails
-*/
+/* This is like realloc() but dies if the malloc fails. */
void *
x_realloc(void *ptr, size_t size)
{
}
-/*
- a sane realpath() function, trying to cope with stupid path limits and
- a broken API
-*/
+/* A sane realpath() function, trying to cope with stupid path limits and a
+ * broken API. */
char *
x_realpath(const char *path)
{
p = realpath(path, ret);
#elif defined(_WIN32)
path_handle = CreateFile(
- path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE != path_handle) {
GetFinalPathNameByHandle(path_handle, ret, maxlen, FILE_NAME_NORMALIZED);
CloseHandle(path_handle);
ret = strtok(str, delim);
if (ret) {
char *save = ret;
- while (*save++);
+ while (*save++) ;
if ((len + 1) == (intptr_t) (save - str))
save--;
*saveptr = save;
DWORD dw = GetLastError();
FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf,
- 0, NULL);
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf,
+ 0, NULL);
lpDisplayBuf = (LPVOID) LocalAlloc(
- LMEM_ZEROINIT,
- (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 40)
- * sizeof(TCHAR));
+ LMEM_ZEROINIT,
+ (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) __FILE__) + 40)
+ * sizeof(TCHAR));
_snprintf((LPTSTR) lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("%s failed with error %d: %s"), __FILE__, dw, lpMsgBuf);
cc_log("can't rename file %s to %s OS returned error: %s",
- oldpath, newpath, (char*) lpDisplayBuf);
+ oldpath, newpath, (char *) lpDisplayBuf);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);