From 99519ae375667dcc78694df6c6ff8cad232277e9 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 4 Nov 2002 16:12:19 +0000
Subject: [PATCH] second attempt at ngettext() fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1318 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    | 3 +++
 configure.ac | 8 ++------
 files.c      | 8 ++++----
 nano.h       | 6 ++----
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 001e5072..3771a101 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@ CVS code -
 	  $SYSCONFDIR/nanorc but not ~/.nanorc. (DLR)
 	- Change all references to /etc/nanorc in the documentation to
 	  $SYSCONFDIR/nanorc. (DLR)
+	- Minor cosmetic tweaks to the ngettext() macro, and fix to
+	  properly detect systems lacking ngettext() and correctly
+	  compile on them; the previous fix didn't work. (DLR)
   nano.c:
   version()
 	- Remove obsolete reference to --enable-undo. (David Benbennick)
diff --git a/configure.ac b/configure.ac
index c1acfae1..a2cc159f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,11 +223,7 @@ AC_MSG_WARN([*** Can not use slang when cross-compiling])),
     esac], [AC_MSG_RESULT(no)])
 
 dnl Checks for functions
-AC_CHECK_FUNCS(ngettext snprintf vsnprintf)
-if test "x$ac_cv_func_ngettext" = "xno"
-then
-	AC_DEFINE(NO_NGETTEXT, 1, [Defined if ngettext() is unavailable])
-fi
+AC_CHECK_FUNCS(snprintf vsnprintf)
 if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
 then
 	AM_PATH_GLIB(1.2.4,,
@@ -319,7 +315,7 @@ then
 fi
 
 dnl i18n stuff - pretty incomplete for now
-AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT([external], [need-ngettext])
 
 AC_CONFIG_FILES([Makefile m4/Makefile po/Makefile.in nano.spec])
 AC_OUTPUT
diff --git a/files.c b/files.c
index 036848ca..2995dd0b 100644
--- a/files.c
+++ b/files.c
@@ -301,16 +301,16 @@ int read_file(FILE *f, const char *filename, int quiet)
 
 #ifndef NANO_SMALL
     if (fileformat == 2)
-	statusbar(ngettext("Read %d line (Converted from Mac format)",
+	statusbar(__("Read %d line (Converted from Mac format)",
 			"Read %d lines (Converted from Mac format)",
 			num_lines), num_lines);
     else if (fileformat == 1)
-	statusbar(ngettext("Read %d line (Converted from DOS format)",
+	statusbar(__("Read %d line (Converted from DOS format)",
 			"Read %d lines (Converted from DOS format)",
 			num_lines), num_lines);
     else
 #endif
-	statusbar(ngettext("Read %d line", "Read %d lines", num_lines),
+	statusbar(__("Read %d line", "Read %d lines", num_lines),
 			num_lines);
 
     totlines += num_lines;
@@ -1646,7 +1646,7 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
 	/* Update originalfilestat to reference the file as it is now. */
 	stat(filename, &originalfilestat);
 #endif
-	statusbar(ngettext("Wrote %d line", "Wrote %d lines", lineswritten),
+	statusbar(__("Wrote %d line", "Wrote %d lines", lineswritten),
 			lineswritten);
 	UNSET(MODIFIED);
 	titlebar(NULL);
diff --git a/nano.h b/nano.h
index bceb2a8d..840cb6fa 100644
--- a/nano.h
+++ b/nano.h
@@ -51,12 +51,10 @@
 #    include <libintl.h>
 #  endif
 #  define _(string) gettext(string)
-#  ifdef NO_NGETTEXT
-#    define ngettext(singular, plural, number) gettext(number == 1 ? singular : plural)
-#  endif
+#  define __(singular, plural, number) ngettext(singular, plural, number)
 #else
 #  define _(string) (string)
-#  define ngettext(singular, plural, number) number == 1 ? singular : plural
+#  define __(singular, plural, number) (number == 1 ? singular : plural)
 #endif
 
 #include <sys/types.h>
-- 
GitLab