{NULL, NULL}};
/*
- * A list of languages and the equivalent language
- * after it has been preprocessed.
+ * A list of languages and the corresponding language after it has been
+ * preprocessed.
*/
static const struct {
- const char *language;
- const char *preprocessed_language;
+ const char *language;
+ const char *preprocessed_language;
} preprocessed_languages[] = {
- {"c", "cpp-output"},
- {"c++", "c++-cpp-output"},
- {"objective-c", "objc-cpp-output"},
- {"objective-c++", "objc++-cpp-output"},
- {NULL, NULL}};
+ {"c", "cpp-output"},
+ {"c++", "c++-cpp-output"},
+ {"objective-c", "objc-cpp-output"},
+ {"objective-c++", "objc++-cpp-output"},
+ {NULL, NULL}};
enum fromcache_call_mode {
FROMCACHE_DIRECT_MODE,
return 1;
}
-/* Try to guess the language of a file based on its extension.
- * Return NULL if the extension is unknown.
+/*
+ * Try to guess the language of a file based on its extension. Returns NULL if
+ * the extension is unknown.
*/
static const char *language_for_file(const char *fname)
{
return NULL;
}
-/* For a given language, return the language of the preprocessed file. */
+/*
+ * For a given language, return the language of the preprocessed file, or NULL
+ * if unknown.
+ */
static const char *preprocessed_language(const char *language, int *direct_i)
{
int i;
*direct_i = 1;
}
return preprocessed_languages[i].preprocessed_language;
- }
- }
- return NULL;
+ }
+ }
+ return NULL;
}
-/* Return the default file extension for a language */
+/* Return the default file extension for a language, or NULL if unknown. */
static const char *extension_for_language(const char *language)
{
int i;
const char *extension = getenv("CCACHE_EXTENSION");
if (extension) return extension;
- if (language == NULL) return NULL;
+ if (!language) return NULL;
for (i=0; extensions[i].extension; i++) {
if (strcmp(language, extensions[i].language) == 0) {
if (strcmp(args->argv[i], "-x") == 0) {
i++;
if (i < args->argc) {
- char* language = args->argv[i];
- const char* prepr_language = preprocessed_language(language, NULL);
- if (prepr_language == NULL) {
+ char *language = args->argv[i];
+ const char *prepr_language = preprocessed_language(language, NULL);
+ if (!prepr_language) {
failed();
}
args->argv[i] = x_strdup(prepr_language);
}
/* -x can change the extension for the next input file */
- if ((strcmp(argv[i], "-x") == 0) && !input_file) {
+ if (strcmp(argv[i], "-x") == 0 && !input_file) {
found_x_opt = 1;
input_language = argv[i+1];
}
failed();
}
- if ((input_language == NULL) || (strcmp(input_language, "none") == 0)) {
- input_language = language_for_file(input_file);
- }
- i_extension = extension_for_language(preprocessed_language(input_language, &direct_i_file));
- if (i_extension == NULL) {
+ if (!input_language || strcmp(input_language, "none") == 0) {
+ input_language = language_for_file(input_file);
+ }
+ i_extension = extension_for_language(
+ preprocessed_language(input_language, &direct_i_file));
+ if (!i_extension) {
cc_log("Not a C/C++ file: %s", input_file);
stats_update(STATS_NOTC);
failed();
- }
+ }
if (!found_c_opt) {
cc_log("No -c option found");
failed();
}
-
/* don't try to second guess the compilers heuristics for stdout handling */
if (output_obj && strcmp(output_obj, "-") == 0) {
stats_update(STATS_OUTSTDOUT);