]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Get rid of the ARGS typedef; use struct args explicitly
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 17 Jul 2010 14:58:55 +0000 (16:58 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 17 Jul 2010 16:31:56 +0000 (18:31 +0200)
args.c
ccache.c
ccache.h
test/framework.c
test/framework.h

diff --git a/args.c b/args.c
index dde787d10817ecad13eb9d78a2c6ca51d31c3d99..82e6dbd1f9e3a413ce5c7dddb9710f4f526c43e2 100644 (file)
--- a/args.c
+++ b/args.c
 #include <stdlib.h>
 #include <string.h>
 
-ARGS *args_init(int init_argc, char **init_args)
+struct args *
+args_init(int init_argc, char **init_args)
 {
-       ARGS *args;
+       struct args *args;
        int i;
-       args = (ARGS *)x_malloc(sizeof(ARGS));
+       args = (struct args *)x_malloc(sizeof(struct args));
        args->argc = 0;
        args->argv = (char **)x_malloc(sizeof(char *));
        args->argv[0] = NULL;
@@ -35,9 +36,10 @@ ARGS *args_init(int init_argc, char **init_args)
        return args;
 }
 
-ARGS *args_init_from_string(const char *command)
+struct args *
+args_init_from_string(const char *command)
 {
-       ARGS *args;
+       struct args *args;
        char *p = x_strdup(command);
        char *q = p;
        char *word;
@@ -52,12 +54,14 @@ ARGS *args_init_from_string(const char *command)
        return args;
 }
 
-ARGS *args_copy(ARGS *args)
+struct args *
+args_copy(struct args *args)
 {
        return args_init(args->argc, args->argv);
 }
 
-void args_free(ARGS *args)
+void
+args_free(struct args *args)
 {
        int i;
        for (i = 0; i < args->argc; ++i) {
@@ -69,7 +73,8 @@ void args_free(ARGS *args)
        free(args);
 }
 
-void args_add(ARGS *args, const char *s)
+void
+args_add(struct args *args, const char *s)
 {
        args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
        args->argv[args->argc] = x_strdup(s);
@@ -78,7 +83,8 @@ void args_add(ARGS *args, const char *s)
 }
 
 /* pop the last element off the args list */
-void args_pop(ARGS *args, int n)
+void
+args_pop(struct args *args, int n)
 {
        while (n--) {
                args->argc--;
@@ -88,7 +94,8 @@ void args_pop(ARGS *args, int n)
 }
 
 /* remove the first element of the argument list */
-void args_remove_first(ARGS *args)
+void
+args_remove_first(struct args *args)
 {
        free(args->argv[0]);
        memmove(&args->argv[0],
@@ -98,7 +105,8 @@ void args_remove_first(ARGS *args)
 }
 
 /* add an argument into the front of the argument list */
-void args_add_prefix(ARGS *args, const char *s)
+void
+args_add_prefix(struct args *args, const char *s)
 {
        args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
        memmove(&args->argv[1], &args->argv[0],
@@ -108,7 +116,8 @@ void args_add_prefix(ARGS *args, const char *s)
 }
 
 /* strip any arguments beginning with the specified prefix */
-void args_strip(ARGS *args, const char *prefix)
+void
+args_strip(struct args *args, const char *prefix)
 {
        int i;
        for (i=0; i<args->argc; ) {
@@ -128,7 +137,8 @@ void args_strip(ARGS *args, const char *prefix)
  * Format args to a space-separated string. Does not quote spaces. Caller
  * frees.
  */
-char *args_to_string(ARGS *args)
+char *
+args_to_string(struct args *args)
 {
        char *result;
        char **p;
@@ -147,7 +157,8 @@ char *args_to_string(ARGS *args)
 }
 
 /* Returns 1 if args1 equals args2, else 0. */
-int args_equal(ARGS *args1, ARGS *args2)
+int
+args_equal(struct args *args1, struct args *args2)
 {
        int i;
        if (args1->argc != args2->argc) {
index e573b4204fbe089abb22d8d2b757fe013419e52e..c5f6a02ff5ec94e4a7258a710444bf0e19c91e95 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -90,7 +90,7 @@ char *cache_logfile = NULL;
 static char *base_dir;
 
 /* the original argument list */
-static ARGS *orig_args;
+static struct args *orig_args;
 
 /* the source file */
 static char *input_file;
@@ -581,7 +581,7 @@ language_is_preprocessed(const char *language)
 }
 
 /* run the real compiler and put the result in cache */
-static void to_cache(ARGS *args)
+static void to_cache(struct args *args)
 {
        char *tmp_stdout, *tmp_stderr, *tmp_obj;
        struct stat st;
@@ -757,7 +757,7 @@ static void to_cache(ARGS *args)
  * Returns the hash as a heap-allocated hex string.
  */
 static struct file_hash *
-get_object_name_from_cpp(ARGS *args, struct mdfour *hash)
+get_object_name_from_cpp(struct args *args, struct mdfour *hash)
 {
        char *input_base;
        char *tmp;
@@ -881,7 +881,7 @@ static void update_cached_result_globals(struct file_hash *hash)
  * Update a hash sum with information common for the direct and preprocessor
  * modes.
  */
-static void calculate_common_hash(ARGS *args, struct mdfour *hash)
+static void calculate_common_hash(struct args *args, struct mdfour *hash)
 {
        struct stat st;
        const char *compilercheck;
@@ -960,8 +960,8 @@ static void calculate_common_hash(ARGS *args, struct mdfour *hash)
  * modes and calculate the object hash. Returns the object hash on success,
  * otherwise NULL. Caller frees.
  */
-static struct file_hash *calculate_object_hash(
-       ARGS *args, struct mdfour *hash, int direct_mode)
+static struct file_hash *
+calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
 {
        int i;
        char *manifest_name;
@@ -1298,7 +1298,8 @@ static void find_compiler(int argc, char **argv)
  * -E; this is added later. Returns 0 on failure, otherwise 1.
  */
 int
-cc_process_args(ARGS *orig_args, ARGS **preprocessor_args, ARGS **compiler_args)
+cc_process_args(struct args *orig_args, struct args **preprocessor_args,
+                struct args **compiler_args)
 {
        int i;
        int found_c_opt = 0;
@@ -1313,7 +1314,7 @@ cc_process_args(ARGS *orig_args, ARGS **preprocessor_args, ARGS **compiler_args)
        int dependency_filename_specified = 0;
        /* is the dependency makefile target name specified with -MT or -MQ? */
        int dependency_target_specified = 0;
-       ARGS *stripped_args;
+       struct args *stripped_args;
        int argc = orig_args->argc;
        char **argv = orig_args->argv;
 
@@ -1815,10 +1816,10 @@ static void ccache(int argc, char *argv[])
        struct mdfour cpp_hash;
 
        /* Arguments (except -E) to send to the preprocessor. */
-       ARGS *preprocessor_args;
+       struct args *preprocessor_args;
 
        /* Arguments to send to the real compiler. */
-       ARGS *compiler_args;
+       struct args *compiler_args;
 
        find_compiler(argc, argv);
 
index 55f8393348934264b219574dd7eb03014c74c68d..03a5ae1ca92e655a9bd3a8d2b4e288d0ecbabe36 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -155,28 +155,32 @@ char *find_executable(const char *name, const char *exclude_name);
 void print_command(FILE *fp, char **argv);
 void print_executed_command(FILE *fp, char **argv);
 
-typedef struct {
+/* ------------------------------------------------------------------------- */
+/* args */
+
+struct args {
        char **argv;
        int argc;
-} ARGS;
+};
 
+struct args *args_init(int, char **);
+struct args *args_init_from_string(const char *);
+struct args *args_copy(struct args *args);
+void args_free(struct args *args);
+void args_add(struct args *args, const char *s);
+void args_add_prefix(struct args *args, const char *s);
+void args_pop(struct args *args, int n);
+void args_strip(struct args *args, const char *prefix);
+void args_remove_first(struct args *args);
+char *args_to_string(struct args *args);
+int args_equal(struct args *args1, struct args *args2);
 
-ARGS *args_init(int , char **);
-ARGS *args_init_from_string(const char *);
-ARGS *args_copy(ARGS *args);
-void args_free(ARGS *args);
-void args_add(ARGS *args, const char *s);
-void args_add_prefix(ARGS *args, const char *s);
-void args_pop(ARGS *args, int n);
-void args_strip(ARGS *args, const char *prefix);
-void args_remove_first(ARGS *args);
-char *args_to_string(ARGS *args);
-int args_equal(ARGS *args1, ARGS *args2);
+/* ------------------------------------------------------------------------- */
 
 int
-cc_process_args(ARGS *orig_args,
-                ARGS **preprocessor_args,
-                ARGS **compiler_args);
+cc_process_args(struct args *orig_args,
+                struct args **preprocessor_args,
+                struct args **compiler_args);
 
 #if HAVE_COMPAR_FN_T
 #define COMPAR_FN_T __compar_fn_t
index 30dfc4fa85f4d4f8031710a764ed7630914c60ab..f6a9a902f48ce1405690c0fb2e23eb2369436717 100644 (file)
@@ -237,7 +237,8 @@ cct_check_str_eq(const char *file, int line, const char *expression,
 
 int
 cct_check_args_eq(const char *file, int line, const char *expression,
-                  ARGS *expected, ARGS *actual, int free1, int free2)
+                  struct args *expected, struct args *actual,
+                  int free1, int free2)
 {
        int result;
 
index 8c8b19fce45c8d3f1b2632253b29c1364a1231e2..d12c031cf59292306bfdb80979e7bbcdbc5c3c1d 100644 (file)
@@ -130,6 +130,7 @@ int cct_check_uns_eq(const char *file, int line, const char *expression,
 int cct_check_str_eq(const char *file, int line, const char *expression,
                      char *expected, char *actual, int free1, int free2);
 int cct_check_args_eq(const char *file, int line, const char *expression,
-                      ARGS *expected, ARGS *actual, int free1, int free2);
+                      struct args *expected, struct args *actual,
+                      int free1, int free2);
 
 #endif