Re: [PATCH/RFC v7 1/2] Add infrastructure for translating Git with gettext

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

 



On Sat, Jun 5, 2010 at 03:38, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
> Ævar Arnfjörð Bjarmason wrote:
>> On Sat, Jun 5, 2010 at 03:01, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
>
>>>  #ifdef NO_GETTEXT
>>>  static inline void git_setup_gettext(void) {}
>>>  #endif
>>>
>>> and
>>>
>>>  ifndef NO_GETTEXT
>>>  LIB_OBJS += gettext.o
>>>  endif
>>
>> Sure, but that would be putting code in a header file, which is
>> usually taboo. It looks like there's some prior art on that though.
>> Like strbuf.h.
>>
>> I don't care either way, what do you think?
>
> This is what ‘inline’ is for.  I think using it for stubs like this
> is perfectly acceptable and improves readability.

Great. I've fixed this in my local copy. Now I don't compile gettext.c
when NO_GETTEXT is set, and it'll be defined as static inline in the
header file.

It'll become part of the next patch. Here's the diff:

diff --git a/Makefile b/Makefile
index 3040000..e21f7f0 100644
--- a/Makefile
+++ b/Makefile
@@ -578,7 +578,9 @@ LIB_OBJS += entry.o
 LIB_OBJS += environment.o
 LIB_OBJS += exec_cmd.o
 LIB_OBJS += fsck.o
+ifndef NO_GETTEXT
 LIB_OBJS += gettext.o
+endif
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
 LIB_OBJS += hash.o
diff --git a/gettext.c b/gettext.c
index 22cdcc1..4825799 100644
--- a/gettext.c
+++ b/gettext.c
@@ -1,11 +1,8 @@
-#ifdef NO_GETTEXT
-void git_setup_gettext(void) {}
-#else
 #include "exec_cmd.h"
 #include <libintl.h>
 #include <stdlib.h>

-void git_setup_gettext(void) {
+inline void git_setup_gettext(void) {
 	char *podir;
 	char *envdir = getenv("GIT_TEXTDOMAINDIR");

@@ -22,4 +19,3 @@ void git_setup_gettext(void) {
 	(void)setlocale(LC_CTYPE, "");
 	(void)textdomain("git");
 }
-#endif
diff --git a/gettext.h b/gettext.h
index a99da6a..8d44808 100644
--- a/gettext.h
+++ b/gettext.h
@@ -1,7 +1,11 @@
 #ifndef GETTEXT_H
 #define GETTEXT_H

-void git_setup_gettext(void);
+#ifdef NO_GETTEXT
+static inline void git_setup_gettext(void) {}
+#else
+inline void git_setup_gettext(void);
+#endif

 #ifdef NO_GETTEXT
 #define _(s) (s)
--
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]