[PATCH 4/6] Initialize gettext for test programs that may use it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gettext poison was a macro and _() always returned
"# GETTEXT POISON #". Now that we use real gettext(),
it has to be initialized or it won't work.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 test-date.c             | 1 +
 test-delta.c            | 1 +
 test-dump-cache-tree.c  | 5 ++++-
 test-index-version.c    | 1 +
 test-match-trees.c      | 1 +
 test-mergesort.c        | 1 +
 test-parse-options.c    | 1 +
 test-path-utils.c       | 1 +
 test-revision-walking.c | 1 +
 test-scrap-cache-tree.c | 4 +++-
 test-sha1.c             | 1 +
 test-subprocess.c       | 1 +
 12 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/test-date.c b/test-date.c
index 10afaab..3881d33 100644
--- a/test-date.c
+++ b/test-date.c
@@ -48,6 +48,7 @@ int main(int argc, char **argv)
 	struct timeval now;
 	const char *x;
 
+	git_setup_gettext();
 	x = getenv("TEST_DATE_NOW");
 	if (x) {
 		now.tv_sec = atoi(x);
diff --git a/test-delta.c b/test-delta.c
index af40a3c..ac86cae 100644
--- a/test-delta.c
+++ b/test-delta.c
@@ -22,6 +22,7 @@ int main(int argc, char *argv[])
 	void *from_buf, *data_buf, *out_buf;
 	unsigned long from_size, data_size, out_size;
 
+	git_setup_gettext();
 	if (argc != 5 || (strcmp(argv[1], "-d") && strcmp(argv[1], "-p"))) {
 		fprintf(stderr, "Usage: %s\n", usage_str);
 		return 1;
diff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c
index a6ffdf3..2023475 100644
--- a/test-dump-cache-tree.c
+++ b/test-dump-cache-tree.c
@@ -56,7 +56,10 @@ static int dump_cache_tree(struct cache_tree *it,
 
 int main(int ac, char **av)
 {
-	struct cache_tree *another = cache_tree();
+	struct cache_tree *another;
+
+	git_setup_gettext();
+	another = cache_tree();
 	if (read_cache() < 0)
 		die("unable to read index file");
 	cache_tree_update(another, active_cache, active_nr, WRITE_TREE_DRY_RUN);
diff --git a/test-index-version.c b/test-index-version.c
index bfaad9e..703f4bd 100644
--- a/test-index-version.c
+++ b/test-index-version.c
@@ -5,6 +5,7 @@ int main(int argc, const char **argv)
 	struct cache_header hdr;
 	int version;
 
+	git_setup_gettext();
 	memset(&hdr,0,sizeof(hdr));
 	if (read(0, &hdr, sizeof(hdr)) != sizeof(hdr))
 		return 0;
diff --git a/test-match-trees.c b/test-match-trees.c
index a3c4688..5299292 100644
--- a/test-match-trees.c
+++ b/test-match-trees.c
@@ -6,6 +6,7 @@ int main(int ac, char **av)
 	unsigned char hash1[20], hash2[20], shifted[20];
 	struct tree *one, *two;
 
+	git_setup_gettext();
 	if (get_sha1(av[1], hash1))
 		die("cannot parse %s as an object name", av[1]);
 	if (get_sha1(av[2], hash2))
diff --git a/test-mergesort.c b/test-mergesort.c
index 3f388b4..2289cb1 100644
--- a/test-mergesort.c
+++ b/test-mergesort.c
@@ -27,6 +27,7 @@ int main(int argc, const char **argv)
 	struct line *line, *p = NULL, *lines = NULL;
 	struct strbuf sb = STRBUF_INIT;
 
+	git_setup_gettext();
 	for (;;) {
 		if (strbuf_getwholeline(&sb, stdin, '\n'))
 			break;
diff --git a/test-parse-options.c b/test-parse-options.c
index 3c9510a..4a94327 100644
--- a/test-parse-options.c
+++ b/test-parse-options.c
@@ -81,6 +81,7 @@ int main(int argc, const char **argv)
 	};
 	int i;
 
+	git_setup_gettext();
 	argc = parse_options(argc, argv, prefix, options, usage, 0);
 
 	printf("boolean: %d\n", boolean);
diff --git a/test-path-utils.c b/test-path-utils.c
index 3bc20e9..f3b4cee 100644
--- a/test-path-utils.c
+++ b/test-path-utils.c
@@ -2,6 +2,7 @@
 
 int main(int argc, char **argv)
 {
+	git_setup_gettext();
 	if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
 		char *buf = xmalloc(PATH_MAX + 1);
 		int rv = normalize_path_copy(buf, argv[2]);
diff --git a/test-revision-walking.c b/test-revision-walking.c
index 3ade02c..5f476c0 100644
--- a/test-revision-walking.c
+++ b/test-revision-walking.c
@@ -47,6 +47,7 @@ static int run_revision_walk(void)
 
 int main(int argc, char **argv)
 {
+	git_setup_gettext();
 	if (argc < 2)
 		return 1;
 
diff --git a/test-scrap-cache-tree.c b/test-scrap-cache-tree.c
index 4728013..67234e1 100644
--- a/test-scrap-cache-tree.c
+++ b/test-scrap-cache-tree.c
@@ -6,7 +6,9 @@ static struct lock_file index_lock;
 
 int main(int ac, char **av)
 {
-	int fd = hold_locked_index(&index_lock, 1);
+	int fd;
+	git_setup_gettext();
+	fd = hold_locked_index(&index_lock, 1);
 	if (read_cache() < 0)
 		die("unable to read index file");
 	active_cache_tree = NULL;
diff --git a/test-sha1.c b/test-sha1.c
index 80daba9..9a02ce8 100644
--- a/test-sha1.c
+++ b/test-sha1.c
@@ -7,6 +7,7 @@ int main(int ac, char **av)
 	unsigned bufsz = 8192;
 	char *buffer;
 
+	git_setup_gettext();
 	if (ac == 2)
 		bufsz = strtoul(av[1], NULL, 10) * 1024 * 1024;
 
diff --git a/test-subprocess.c b/test-subprocess.c
index f2d4c0d..9cf8e29 100644
--- a/test-subprocess.c
+++ b/test-subprocess.c
@@ -6,6 +6,7 @@ int main(int argc, const char **argv)
 	struct child_process cp;
 	int nogit = 0;
 
+	git_setup_gettext();
 	setup_git_directory_gently(&nogit);
 	if (nogit)
 		die("No git repo found");
-- 
1.7.12.rc2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]