Re: [PATCH 01/72] gettext.h: add no-op _() and N_() wrappers

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

 



Hi Ãvar,

Ãvar ArnfjÃrà Bjarmason wrote:

> Add a new header called gettext.h which is currently a no-op.

Thanks.  I'd suggest squashing this with patch #2 (#including
gettext.h in cache.h).

> --- /dev/null
> +++ b/gettext.h
> @@ -0,0 +1,9 @@
> +/*
> + * Copyright (c) 2010 Ãvar ArnfjÃrà Bjarmason

Is such a simple header file copyrightable?  But I don't mind.

> + *
> + * This is a skeleton no-op implementation of gettext for Git. It'll
> + * be replaced by something that uses libintl.h and wraps gettext() in
> + * a future patch series.
> + */
> +#define N_(s) (s)

Might be nice to make this an inline function, for type safety.

> +#define _(s) (s)

This one can't be a function, though, since it needs to transform
literals to literals.

Some possible tweaks:

 - protect against double inclusion
 - make _ into a function
 - add a comment vaguely explaining N_
 - avoid confusing errors if some other header has pre-defined _.

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 gettext.h |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gettext.h b/gettext.h
index c68bbe9..2f806cb 100644
--- a/gettext.h
+++ b/gettext.h
@@ -1,3 +1,10 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+#ifdef _
+#error "namespace conflict: '_' is pre-defined?"
+#endif
+
 /*
  * Copyright (c) 2010 Ãvar ArnfjÃrà Bjarmason
  *
@@ -5,5 +12,13 @@
  * be replaced by something that uses libintl.h and wraps gettext() in
  * a future patch series.
  */
-#define N_(s) (s)
-#define _(s) (s)
+
+static inline const char *_(const char *msgid)
+{
+	return msgid;
+}
+
+/* Mark msgid for translation but do not translate it. */
+#define N_(msgid) (msgid)
+
+#endif
-- 
1.7.4.1

--
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]