Git fork

*.[ch]: remove extern from function declarations using sed

There has been a push to remove extern from function declarations.
Finish the job by removing all instances of "extern" for function
declarations in headers using sed.

This was done by running the following on my system with sed 4.2.2:

$ git ls-files \*.{c,h} |
grep -v ^compat/ |
xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/'

Files under `compat/` are intentionally excluded as some are directly
copied from external sources and we should avoid churning them as much
as possible.

Then, leftover instances of extern were found by running

$ git grep -w -C3 extern \*.{c,h}

and manually checking the output. No other instances were found.

Note that the regex used specifically excludes function variables which
_should_ be left as extern.

Not the most elegant way to do it but it gets the job done.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Denton Liu and committed by
Junio C Hamano
b199d714 55454427

+49 -49
+2 -2
cache.h
··· 1690 1690 /* IO helper functions */ 1691 1691 void maybe_flush_or_die(FILE *, const char *); 1692 1692 __attribute__((format (printf, 2, 3))) 1693 - extern void fprintf_or_die(FILE *, const char *fmt, ...); 1693 + void fprintf_or_die(FILE *, const char *fmt, ...); 1694 1694 1695 1695 #define COPY_READ_ERROR (-2) 1696 1696 #define COPY_WRITE_ERROR (-3) ··· 1724 1724 * write_file(path, "counter: %d", ctr); 1725 1725 */ 1726 1726 __attribute__((format (printf, 2, 3))) 1727 - extern void write_file(const char *path, const char *fmt, ...); 1727 + void write_file(const char *path, const char *fmt, ...); 1728 1728 1729 1729 /* pager.c */ 1730 1730 void setup_pager(void);
+1 -1
commit.h
··· 379 379 int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused); 380 380 381 381 LAST_ARG_MUST_BE_NULL 382 - extern int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...); 382 + int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...); 383 383 384 384 #endif /* COMMIT_H */
+1 -1
config.h
··· 265 265 enum config_scope scope; 266 266 }; 267 267 268 - extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); 268 + NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); 269 269 NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr); 270 270 271 271 #define LOOKUP_CONFIG(mapping, var) \
+1 -1
exec-cmd.h
··· 10 10 const char **prepare_git_cmd(struct argv_array *out, const char **argv); 11 11 int execv_git_cmd(const char **argv); /* NULL terminated */ 12 12 LAST_ARG_MUST_BE_NULL 13 - extern int execl_git_cmd(const char *cmd, ...); 13 + int execl_git_cmd(const char *cmd, ...); 14 14 char *system_path(const char *path); 15 15 16 16 #endif /* GIT_EXEC_CMD_H */
+10 -10
git-compat-util.h
··· 448 448 /* General helper functions */ 449 449 void vreportf(const char *prefix, const char *err, va_list params); 450 450 NORETURN void usage(const char *err); 451 - extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2))); 452 - extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2))); 453 - extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); 454 - extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); 455 - extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); 456 - extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); 457 - extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); 451 + NORETURN void usagef(const char *err, ...) __attribute__((format (printf, 1, 2))); 452 + NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2))); 453 + NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); 454 + int error(const char *err, ...) __attribute__((format (printf, 1, 2))); 455 + int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); 456 + void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); 457 + void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); 458 458 459 459 #ifndef NO_OPENSSL 460 460 #ifdef APPLE_COMMON_CRYPTO ··· 769 769 #undef snprintf 770 770 #endif 771 771 #define snprintf git_snprintf 772 - extern int git_snprintf(char *str, size_t maxsize, 772 + int git_snprintf(char *str, size_t maxsize, 773 773 const char *format, ...); 774 774 #ifdef vsnprintf 775 775 #undef vsnprintf ··· 855 855 void *xcalloc(size_t nmemb, size_t size); 856 856 void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); 857 857 void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset); 858 - extern int xopen(const char *path, int flags, ...); 858 + int xopen(const char *path, int flags, ...); 859 859 ssize_t xread(int fd, void *buf, size_t len); 860 860 ssize_t xwrite(int fd, const void *buf, size_t len); 861 861 ssize_t xpread(int fd, void *buf, size_t len, off_t offset); ··· 966 966 } 967 967 968 968 __attribute__((format (printf, 3, 4))) 969 - extern int xsnprintf(char *dst, size_t max, const char *fmt, ...); 969 + int xsnprintf(char *dst, size_t max, const char *fmt, ...); 970 970 971 971 #ifndef HOST_NAME_MAX 972 972 #define HOST_NAME_MAX 256
+7 -7
khash.h
··· 70 70 } kh_##name##_t; 71 71 72 72 #define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \ 73 - extern kh_##name##_t *kh_init_##name(void); \ 74 - extern void kh_destroy_##name(kh_##name##_t *h); \ 75 - extern void kh_clear_##name(kh_##name##_t *h); \ 76 - extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \ 77 - extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \ 78 - extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \ 79 - extern void kh_del_##name(kh_##name##_t *h, khint_t x); 73 + kh_##name##_t *kh_init_##name(void); \ 74 + void kh_destroy_##name(kh_##name##_t *h); \ 75 + void kh_clear_##name(kh_##name##_t *h); \ 76 + khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \ 77 + int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \ 78 + khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \ 79 + void kh_del_##name(kh_##name##_t *h, khint_t x); 80 80 81 81 #define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ 82 82 SCOPE kh_##name##_t *kh_init_##name(void) { \
+15 -15
path.h
··· 13 13 /* 14 14 * Return a statically allocated path. 15 15 */ 16 - extern const char *mkpath(const char *fmt, ...) 16 + const char *mkpath(const char *fmt, ...) 17 17 __attribute__((format (printf, 1, 2))); 18 18 19 19 /* 20 20 * Return a path. 21 21 */ 22 - extern char *mkpathdup(const char *fmt, ...) 22 + char *mkpathdup(const char *fmt, ...) 23 23 __attribute__((format (printf, 1, 2))); 24 24 25 25 /* 26 26 * Construct a path and place the result in the provided buffer `buf`. 27 27 */ 28 - extern char *mksnpath(char *buf, size_t n, const char *fmt, ...) 28 + char *mksnpath(char *buf, size_t n, const char *fmt, ...) 29 29 __attribute__((format (printf, 3, 4))); 30 30 31 31 /* ··· 37 37 * Constructs a path into the common git directory of repository `repo` and 38 38 * append it in the provided buffer `sb`. 39 39 */ 40 - extern void strbuf_git_common_path(struct strbuf *sb, 40 + void strbuf_git_common_path(struct strbuf *sb, 41 41 const struct repository *repo, 42 42 const char *fmt, ...) 43 43 __attribute__((format (printf, 3, 4))); ··· 46 46 * Return a statically allocated path into the main repository's 47 47 * (the_repository) common git directory. 48 48 */ 49 - extern const char *git_common_path(const char *fmt, ...) 49 + const char *git_common_path(const char *fmt, ...) 50 50 __attribute__((format (printf, 1, 2))); 51 51 52 52 ··· 66 66 /* 67 67 * Return a path into the git directory of repository `repo`. 68 68 */ 69 - extern char *repo_git_path(const struct repository *repo, 69 + char *repo_git_path(const struct repository *repo, 70 70 const char *fmt, ...) 71 71 __attribute__((format (printf, 2, 3))); 72 72 ··· 74 74 * Construct a path into the git directory of repository `repo` and append it 75 75 * to the provided buffer `sb`. 76 76 */ 77 - extern void strbuf_repo_git_path(struct strbuf *sb, 77 + void strbuf_repo_git_path(struct strbuf *sb, 78 78 const struct repository *repo, 79 79 const char *fmt, ...) 80 80 __attribute__((format (printf, 3, 4))); ··· 83 83 * Return a statically allocated path into the main repository's 84 84 * (the_repository) git directory. 85 85 */ 86 - extern const char *git_path(const char *fmt, ...) 86 + const char *git_path(const char *fmt, ...) 87 87 __attribute__((format (printf, 1, 2))); 88 88 89 89 /* 90 90 * Return a path into the main repository's (the_repository) git directory. 91 91 */ 92 - extern char *git_pathdup(const char *fmt, ...) 92 + char *git_pathdup(const char *fmt, ...) 93 93 __attribute__((format (printf, 1, 2))); 94 94 95 95 /* ··· 97 97 * and place it in the provided buffer `buf`, the contents of the buffer will 98 98 * be overridden. 99 99 */ 100 - extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...) 100 + char *git_path_buf(struct strbuf *buf, const char *fmt, ...) 101 101 __attribute__((format (printf, 2, 3))); 102 102 103 103 /* 104 104 * Construct a path into the main repository's (the_repository) git directory 105 105 * and append it to the provided buffer `sb`. 106 106 */ 107 - extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...) 107 + void strbuf_git_path(struct strbuf *sb, const char *fmt, ...) 108 108 __attribute__((format (printf, 2, 3))); 109 109 110 110 /* ··· 112 112 * 113 113 * If the repository doesn't have a worktree NULL is returned. 114 114 */ 115 - extern char *repo_worktree_path(const struct repository *repo, 115 + char *repo_worktree_path(const struct repository *repo, 116 116 const char *fmt, ...) 117 117 __attribute__((format (printf, 2, 3))); 118 118 ··· 122 122 * 123 123 * If the repository doesn't have a worktree nothing will be appended to `sb`. 124 124 */ 125 - extern void strbuf_repo_worktree_path(struct strbuf *sb, 125 + void strbuf_repo_worktree_path(struct strbuf *sb, 126 126 const struct repository *repo, 127 127 const char *fmt, ...) 128 128 __attribute__((format (printf, 3, 4))); ··· 131 131 * Return a path into a submodule's git directory located at `path`. `path` 132 132 * must only reference a submodule of the main repository (the_repository). 133 133 */ 134 - extern char *git_pathdup_submodule(const char *path, const char *fmt, ...) 134 + char *git_pathdup_submodule(const char *path, const char *fmt, ...) 135 135 __attribute__((format (printf, 2, 3))); 136 136 137 137 /* ··· 139 139 * append it to the provided buffer `sb`. `path` must only reference a 140 140 * submodule of the main repository (the_repository). 141 141 */ 142 - extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path, 142 + int strbuf_git_path_submodule(struct strbuf *sb, const char *path, 143 143 const char *fmt, ...) 144 144 __attribute__((format (printf, 3, 4))); 145 145
+1 -1
quote.h
··· 31 31 32 32 void sq_quote_buf(struct strbuf *, const char *src); 33 33 void sq_quote_argv(struct strbuf *, const char **argv); 34 - extern void sq_quotef(struct strbuf *, const char *fmt, ...); 34 + void sq_quotef(struct strbuf *, const char *fmt, ...); 35 35 36 36 /* 37 37 * These match their non-pretty variants, except that they avoid
+1 -1
run-command.h
··· 69 69 */ 70 70 const char *find_hook(const char *name); 71 71 LAST_ARG_MUST_BE_NULL 72 - extern int run_hook_le(const char *const *env, const char *name, ...); 72 + int run_hook_le(const char *const *env, const char *name, ...); 73 73 int run_hook_ve(const char *const *env, const char *name, va_list args); 74 74 75 75 #define RUN_COMMAND_NO_STDIN 1
+9 -9
trace.h
··· 28 28 #ifndef HAVE_VARIADIC_MACROS 29 29 30 30 __attribute__((format (printf, 1, 2))) 31 - extern void trace_printf(const char *format, ...); 31 + void trace_printf(const char *format, ...); 32 32 33 33 __attribute__((format (printf, 2, 3))) 34 - extern void trace_printf_key(struct trace_key *key, const char *format, ...); 34 + void trace_printf_key(struct trace_key *key, const char *format, ...); 35 35 36 36 __attribute__((format (printf, 2, 3))) 37 - extern void trace_argv_printf(const char **argv, const char *format, ...); 37 + void trace_argv_printf(const char **argv, const char *format, ...); 38 38 39 39 void trace_strbuf(struct trace_key *key, const struct strbuf *data); 40 40 41 41 /* Prints elapsed time (in nanoseconds) if GIT_TRACE_PERFORMANCE is enabled. */ 42 42 __attribute__((format (printf, 2, 3))) 43 - extern void trace_performance(uint64_t nanos, const char *format, ...); 43 + void trace_performance(uint64_t nanos, const char *format, ...); 44 44 45 45 /* Prints elapsed time since 'start' if GIT_TRACE_PERFORMANCE is enabled. */ 46 46 __attribute__((format (printf, 2, 3))) 47 - extern void trace_performance_since(uint64_t start, const char *format, ...); 47 + void trace_performance_since(uint64_t start, const char *format, ...); 48 48 49 49 __attribute__((format (printf, 1, 2))) 50 50 void trace_performance_leave(const char *format, ...); ··· 132 132 133 133 /* backend functions, use non-*fl macros instead */ 134 134 __attribute__((format (printf, 4, 5))) 135 - extern void trace_printf_key_fl(const char *file, int line, struct trace_key *key, 135 + void trace_printf_key_fl(const char *file, int line, struct trace_key *key, 136 136 const char *format, ...); 137 137 __attribute__((format (printf, 4, 5))) 138 - extern void trace_argv_printf_fl(const char *file, int line, const char **argv, 138 + void trace_argv_printf_fl(const char *file, int line, const char **argv, 139 139 const char *format, ...); 140 140 void trace_strbuf_fl(const char *file, int line, struct trace_key *key, 141 141 const struct strbuf *data); 142 142 __attribute__((format (printf, 4, 5))) 143 - extern void trace_performance_fl(const char *file, int line, 143 + void trace_performance_fl(const char *file, int line, 144 144 uint64_t nanos, const char *fmt, ...); 145 145 __attribute__((format (printf, 4, 5))) 146 - extern void trace_performance_leave_fl(const char *file, int line, 146 + void trace_performance_leave_fl(const char *file, int line, 147 147 uint64_t nanos, const char *fmt, ...); 148 148 static inline int trace_pass_fl(struct trace_key *key) 149 149 {
+1 -1
worktree.h
··· 104 104 * Similar to git_path() but can produce paths for a specified 105 105 * worktree instead of current one 106 106 */ 107 - extern const char *worktree_git_path(const struct worktree *wt, 107 + const char *worktree_git_path(const struct worktree *wt, 108 108 const char *fmt, ...) 109 109 __attribute__((format (printf, 2, 3))); 110 110