Skip to content

Commit

Permalink
Allow using locales when gettext is absent
Browse files Browse the repository at this point in the history
Previously, if configure did not detect dgettext(), we disabled
anything that smelled like localization, inadvertently including
setlocale().  Now that we use setlocale(LC_ALL, ""), we have
localized dates available as well as messages, so we should not
disable calls to setlocale() any more.
Since the routines from locale.h are only used in a relatively
small number of places, just include the header directly in those
files and remove it from k5-platform.h.
  • Loading branch information
kaduk committed Jul 6, 2012
1 parent a7a0fb3 commit 7afeca0
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/clients/kdestroy/kdestroy.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "k5-platform.h"
#include <krb5.h>
#include <com_err.h>
#include <locale.h>
#include <string.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
Expand Down
1 change: 1 addition & 0 deletions src/clients/kinit/kinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "k5-platform.h" /* for asprintf */
#include <krb5.h>
#include "extern.h"
#include <locale.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
Expand Down
1 change: 1 addition & 0 deletions src/clients/klist/klist.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "k5-int.h"
#include <krb5.h>
#include <com_err.h>
#include <locale.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions src/clients/kpasswd/kpasswd.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include <locale.h>
#include <stdio.h>
#include <sys/types.h>
#include "k5-platform.h"
Expand Down
1 change: 1 addition & 0 deletions src/clients/kswitch/kswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* or implied warranty.
*/

#include <locale.h>
#include "k5-int.h"

extern int optind;
Expand Down
1 change: 1 addition & 0 deletions src/clients/kvno/kvno.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include "k5-platform.h"
Expand Down
8 changes: 3 additions & 5 deletions src/include/k5-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* + mkstemp
* + zap (support function; macro is in k5-int.h)
* + path manipulation
* + _, N_, dgettext, bindtextdomain, setlocale (for localization)
* + _, N_, dgettext, bindtextdomain (for localization)
*/

#ifndef K5_PLATFORM_H
Expand Down Expand Up @@ -1061,21 +1061,19 @@ int k5_path_isabs(const char *path);

/*
* Localization macros. If we have gettext, define _ appropriately for
* translating a string. If we do not have gettext, define _, bindtextdomain,
* and setlocale as no-ops. N_ is always a no-op; it marks a string for
* translating a string. If we do not have gettext, define _ and
* bindtextdomain as no-ops. N_ is always a no-op; it marks a string for
* extraction to pot files but does not translate it.
*/
#ifdef ENABLE_NLS
#include <libintl.h>
#include <locale.h>
#define KRB5_TEXTDOMAIN "mit-krb5"
#define _(s) dgettext(KRB5_TEXTDOMAIN, s)
#else
#define _(s) s
#define dgettext(d, m) m
#define ngettext(m1, m2, n) (((n) == 1) ? m1 : m2)
#define bindtextdomain(p, d)
#define setlocale(c, l)
#endif
#define N_(s) s

Expand Down
1 change: 1 addition & 0 deletions src/kadmin/cli/ss_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <krb5.h>
#include <k5-platform.h>
#include <locale.h>
#include <ss/ss.h>
#include "kadmin.h"

Expand Down
1 change: 1 addition & 0 deletions src/kadmin/dbutil/kdb5_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <stdio.h>
#include <k5-int.h>
#include <kadm5/admin.h>
#include <locale.h>
#include <adm_proto.h>
#include <time.h>
#include "kdb5_util.h"
Expand Down
1 change: 1 addition & 0 deletions src/kadmin/ktutil/ktutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "k5-int.h"
#include "ktutil.h"
#include <com_err.h>
#include <locale.h>
#include "adm_proto.h"
#include <ss/ss.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions src/kadmin/server/ovsec_kadmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <signal.h>
#include <syslog.h>
Expand Down
1 change: 1 addition & 0 deletions src/kdc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <locale.h>
#include <stdio.h>
#include <syslog.h>
#include <signal.h>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <locale.h>
#include <stdio.h>
#include <time.h>

Expand Down
1 change: 1 addition & 0 deletions src/slave/kprop.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/file.h>
Expand Down
1 change: 1 addition & 0 deletions src/slave/kpropd.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
*/


#include <locale.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/file.h>
Expand Down
1 change: 1 addition & 0 deletions src/slave/kproplog.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* This module will parse the update logs on the master or slave servers.
*/

#include <locale.h>
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
Expand Down

0 comments on commit 7afeca0

Please sign in to comment.