[Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.28,2.29

Martin v. L?wis loewis@users.sourceforge.net
Wed, 27 Mar 2002 10:49:05 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv3702/Modules

Modified Files:
	_localemodule.c 
Log Message:
Expose C library's gettext. Fixes #516412.


Index: _localemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v
retrieving revision 2.28
retrieving revision 2.29
diff -C2 -d -r2.28 -r2.29
*** _localemodule.c	27 Mar 2002 12:15:57 -0000	2.28
--- _localemodule.c	27 Mar 2002 18:49:02 -0000	2.29
***************
*** 22,25 ****
--- 22,29 ----
  #endif
  
+ #ifdef HAVE_LIBINTL_H
+ #include <libintl.h>
+ #endif
+ 
  #if defined(MS_WIN32)
  #define WINDOWS_LEAN_AND_MEAN
***************
*** 522,526 ****
  }
  #endif /* HAVE_LANGINFO_H */
!     
  
  static struct PyMethodDef PyLocale_Methods[] = {
--- 526,609 ----
  }
  #endif /* HAVE_LANGINFO_H */
! 
! #ifdef HAVE_LIBINTL_H
! 
! static char gettext__doc__[]=
! "gettext(msg) -> string\n"
! "Return translation of msg.";
! 
! static PyObject*
! PyIntl_gettext(PyObject* self, PyObject *args)
! {
! 	char *in;
! 	if (!PyArg_ParseTuple(args, "z", &in))
! 		return 0;
! 	return PyString_FromString(gettext(in));
! }
! 
! static char dgettext__doc__[]=
! "dgettext(domain, msg) -> string\n"
! "Return translation of msg in domain.";
! 
! static PyObject*
! PyIntl_dgettext(PyObject* self, PyObject *args)
! {
! 	char *domain, *in;
! 	if (!PyArg_ParseTuple(args, "zz", &domain, &in))
! 		return 0;
! 	return PyString_FromString(dgettext(domain, in));
! }
! 
! static char dcgettext__doc__[]=
! "dcgettext(domain, msg, category) -> string\n"
! "Return translation of msg in domain and category.";
! 
! static PyObject*
! PyIntl_dcgettext(PyObject *self, PyObject *args)
! {
! 	char *domain, *msgid;
! 	int category;
! 	if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category))
! 		return 0;
! 	return PyString_FromString(dcgettext(domain,msgid,category));
! }
! 
! static char textdomain__doc__[]=
! "textdomain(domain) -> string\n"
! "Set the C library's textdmain to domain, returning the new domain.";
! 
! static PyObject*
! PyIntl_textdomain(PyObject* self, PyObject* args)
! {
! 	char *domain;
! 	if (!PyArg_ParseTuple(args, "z", &domain))
! 		return 0;
! 	domain = textdomain(domain);
! 	if (!domain) {
! 		PyErr_SetFromErrno(PyExc_OSError);
! 		return NULL;
! 	}
! 	return PyString_FromString(domain);
! }
! 
! static char bindtextdomain__doc__[]=
! "bindtextdomain(domain, dir) -> string\n"
! "Bind the C library's domain to dir.";
! 
! static PyObject*
! PyIntl_bindtextdomain(PyObject* self,PyObject*args)
! {
! 	char *domain,*dirname;
! 	if (!PyArg_ParseTuple(args, "zz", &domain, &dirname))
! 		return 0;
! 	dirname = bindtextdomain(domain, dirname);
! 	if (!dirname) {
! 		PyErr_SetFromErrno(PyExc_OSError);
! 		return NULL;
! 	}
! 	return PyString_FromString(dirname);
! }
! 
! #endif
  
  static struct PyMethodDef PyLocale_Methods[] = {
***************
*** 540,544 ****
     METH_VARARGS, nl_langinfo__doc__},
  #endif
!   
    {NULL, NULL}
  };
--- 623,638 ----
     METH_VARARGS, nl_langinfo__doc__},
  #endif
! #ifdef HAVE_LANGINFO_H
!   {"gettext",(PyCFunction)PyIntl_gettext,METH_VARARGS,
!     gettext__doc__},
!   {"dgettext",(PyCFunction)PyIntl_dgettext,METH_VARARGS,
!    dgettext__doc__},
!   {"dcgettext",(PyCFunction)PyIntl_dcgettext,METH_VARARGS,
!     dcgettext__doc__},
!   {"textdomain",(PyCFunction)PyIntl_textdomain,METH_VARARGS,
!    textdomain__doc__},
!   {"bindtextdomain",(PyCFunction)PyIntl_bindtextdomain,METH_VARARGS,
!    bindtextdomain__doc__},
! #endif  
    {NULL, NULL}
  };