[git] Pinentry - branch, master, updated. pinentry-0.8.1-5-gb2f95de

by Werner Koch cvs at cvs.gnupg.org
Wed Aug 10 15:47:48 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".

The branch, master has been updated
       via  b2f95de90094bd4f6cf96d8831f9f43bae8effe9 (commit)
       via  e2b89cbdcba7475047ca3c46fc7d03825355b3ff (commit)
      from  671a1a70eceb7a31feb0df997fbc8eb25f722895 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b2f95de90094bd4f6cf96d8831f9f43bae8effe9
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Aug 10 15:07:07 2011 +0200

    Fix autoconf/m4 stuff.
    
    Also add a gitignore file.

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..872e4af
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,37 @@
+*.lo
+*.o
+.deps/
+.libs/
+/aclocal.m4
+/autom4te.cache
+/config.h.in
+/config.h
+/config.log
+/config.status
+/configure
+/Makefile.in
+autom4te.cache/
+assuan/Makefile.in
+assuan/Makefile
+curses/Makefile.in
+curses/Makefile
+doc/Makefile.in
+doc/Makefile
+doc/pinentry.info
+doc/stamp-vti
+doc/version.texi
+gtk+-2/Makefile.in
+gtk+-2/Makefile
+gtk/Makefile.in
+gtk/Makefile
+pinentry/Makefile.in
+pinentry/Makefile
+qt/Makefile.in
+qt/Makefile
+qt4/Makefile.in
+qt4/Makefile
+secmem/Makefile.in
+secmem/Makefile
+w32/Makefile.in
+w32/Makefile
+
diff --git a/ChangeLog b/ChangeLog
index 9b208d9..8805399 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-08-10  Werner Koch  <wk at g10code.com>
+
+	* configure.ac: Change bug report address to the BTS.  Fix
+	autoconf warnings.
+
 2011-06-28  Werner Koch  <wk at g10code.com>
 
 	* gtk+-2/gtksecentry.c (PROP_EDITING_CANCELED): New.
diff --git a/configure.ac b/configure.ac
index bcbe26e..abe4167 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,23 +1,23 @@
 # configure.ac
 # Copyright (C) 1999 Robert Bihlmeyer <robbe at orcus.priv.at>
 # Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
-# 
+#
 # This file is part of PINENTRY.
-# 
+#
 # PINENTRY is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # PINENTRY is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- 
+
 # (Process this file with autoconf to produce a configure script.)
 AC_PREREQ(2.57)
 min_automake_version="1.10"
@@ -38,12 +38,12 @@ m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \
            | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)]))
 m4_define([git_revision], m4_esyscmd([git branch -v 2>/dev/null \
           | awk '/^\* / {printf "%s",$3}']))
+m4_define([my_full_version], [my_version[]m4_if(my_issvn,[yes],
+          [m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])])
+
 # Remember to remove the "-cvs" suffix *before* a release and to bump the
 # version number immediately *after* a release and to re-append the suffix.
-AC_INIT(pinentry,
-        [my_version[]m4_if(my_issvn,[yes],
-        [m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])],
-	[gnupg-devel at gnupg.org])
+AC_INIT([pinentry],[my_full_version],[http://bugs.gnupg.org])
 AM_CONFIG_HEADER(config.h)
 AC_CONFIG_SRCDIR(pinentry/pinentry.h)
 AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
@@ -96,7 +96,7 @@ case "${host}" in
                   [Set this to limit filenames to the 8.3 format])
         have_dosish_system=yes
         have_w32_system=yes
-        case "${host}" in 
+        case "${host}" in
           *-mingw32ce*)
             have_w32ce_system=yes
             ;;
@@ -121,7 +121,7 @@ esac
 
 if test "$have_dosish_system" = yes; then
    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
-             [Defined if we run on some of the PCDOS like systems 
+             [Defined if we run on some of the PCDOS like systems
               (DOS, Windoze. OS/2) with special properties like
               no file modes])
 fi
@@ -147,7 +147,7 @@ if test "$GCC" = yes; then
     AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
     _gcc_cflags_save=$CFLAGS
     CFLAGS="-Wno-pointer-sign"
-    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no)
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
     AC_MSG_RESULT($_gcc_psign)
     CFLAGS=$_gcc_cflags_save;
     if test x"$_gcc_psign" = xyes ; then
@@ -364,7 +364,7 @@ if test $have_qt = "no"; then
 *** end of config.log.$missing_qt_mt
 ***]])
 	else
-	  pinentry_qt="no"	  
+	  pinentry_qt="no"
 	fi
 fi
 if test $have_moc = "no"; then
@@ -380,7 +380,7 @@ if test $have_moc = "no"; then
 *** configure.
 ***]])
 	else
-	  pinentry_qt="no"	  
+	  pinentry_qt="no"
 	fi
 fi
 fi

commit e2b89cbdcba7475047ca3c46fc7d03825355b3ff
Author: Daiki Ueno <ueno at unixuser.org>
Date:   Wed Aug 10 12:50:43 2011 +0900

    Add wide-char support to pinentry-curses.

diff --git a/configure.ac b/configure.ac
index 4b8ed79..bcbe26e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,7 +158,7 @@ fi
 
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h)
+AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h wchar.h)
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(seteuid stpcpy mmap)
diff --git a/m4/curses.m4 b/m4/curses.m4
index 1e1cb4f..3a01881 100644
--- a/m4/curses.m4
+++ b/m4/curses.m4
@@ -28,7 +28,13 @@ AC_DEFUN([IU_LIB_NCURSES], [
   AC_ARG_ENABLE(ncurses,    [  --disable-ncurses       don't prefer -lncurses over -lcurses],
               , enable_ncurses=yes)
   if test "$enable_ncurses" = yes; then
-    AC_CHECK_LIB(ncurses, initscr, LIBNCURSES="-lncurses")
+    AC_CHECK_LIB(ncursesw, initscr, LIBNCURSES="-lncursesw",
+      AC_CHECK_LIB(ncurses, initscr, LIBNCURSES="-lncurses"))
+    if test "$ac_cv_lib_ncursesw_initscr" = yes; then
+      have_ncursesw=yes
+    else
+      have_ncursesw=no
+    fi
     if test "$LIBNCURSES"; then
       # Use ncurses header files instead of the ordinary ones, if possible;
       # is there a better way of doing this, that avoids looking in specific
@@ -53,9 +59,14 @@ AC_DEFUN([IU_LIB_NCURSES], [
       else
 	AC_CACHE_CHECK(for ncurses include dir,
 		       inetutils_cv_includedir_ncurses,
+          if test "$have_ncursesw" = yes; then
+            ncursesdir=ncursesw
+          else
+            ncursesdir=ncurses
+          fi
 	  for D in $includedir $prefix/include /local/include /usr/local/include /include /usr/include; do
-	    if test -d $D/ncurses; then
-	      inetutils_cv_includedir_ncurses="$D/ncurses"
+	    if test -d $D/$ncursesdir; then
+	      inetutils_cv_includedir_ncurses="$D/$ncursesdir"
 	      break
 	    fi
 	    test "$inetutils_cv_includedir_ncurses" \
@@ -68,6 +79,9 @@ AC_DEFUN([IU_LIB_NCURSES], [
         NCURSES_INCLUDE="-I$inetutils_cv_includedir_ncurses"
       fi
     fi
+    if test $have_ncursesw = yes; then
+      AC_DEFINE(HAVE_NCURSESW, 1, [Define if you have working ncursesw])
+    fi
   fi
   AC_SUBST(NCURSES_INCLUDE)
   AC_SUBST(LIBNCURSES)])dnl
diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 76ddbdd..585059f 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -42,6 +42,10 @@
 
 #include <memory.h>
 
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif /*HAVE_WCHAR_H*/
+
 #include "pinentry.h"
 
 /* FIXME: We should allow configuration of these button labels and in
@@ -94,6 +98,24 @@ struct dialog
 typedef struct dialog *dialog_t;
 
 
+#ifdef HAVE_NCURSESW
+typedef wchar_t CH;
+#define STRLEN(x) wcslen (x)
+#define ADDCH(x) addnwstr (&x, 1);
+#define CHWIDTH(x) wcwidth (x)
+#define NULLCH L'\0'
+#define NLCH L'\n'
+#define SPCH L' '
+#else
+typedef char CH;
+#define STRLEN(x) strlen (x)
+#define ADDCH(x) addch ((unsigned char) x)
+#define CHWIDTH(x) 1
+#define NULLCH '\0'
+#define NLCH '\n'
+#define SPCH ' '
+#endif
+
 /* Return the next line up to MAXLEN columns wide in START and LEN.
    The first invocation should have 0 as *LEN.  If the line ends with
    a \n, it is a normal line that will be continued.  If it is a '\0'
@@ -101,40 +123,95 @@ typedef struct dialog *dialog_t;
    there is a forced line break.  A full line is returned and will be
    continued in the next line.  */
 static void
-collect_line (int maxlen, char **start_p, int *len_p)
+collect_line (int maxwidth, wchar_t **start_p, int *len_p)
 {
   int last_space = 0;
   int len = *len_p;
-  char *end;
+  int width = 0;
+  CH *end;
 
   /* Skip to next line.  */
   *start_p += len;
   /* Skip leading space.  */
-  while (**start_p == ' ')
+  while (**start_p == SPCH)
     (*start_p)++;
 
   end = *start_p;
   len = 0;
 
-  while (len < maxlen - 1 && *end && *end != '\n')
+  while (width < maxwidth - 1 && *end != NULLCH && *end != NLCH)
     {
       len++;
       end++;
-      if (*end == ' ')
+      if (*end == SPCH)
 	last_space = len;
+      width += CHWIDTH (*end);
     }
 
-  if (*end && *end != '\n' && last_space != 0)
+  if (*end != NULLCH && *end != NLCH && last_space != 0)
     {
       /* We reached the end of the available space, but still have
 	 characters to go in this line.  We can break the line into
 	 two parts at a space.  */
       len = last_space;
-      (*start_p)[len] = '\n';
+      (*start_p)[len] = NLCH;
     }
   *len_p = len + 1;
 }
 
+#ifdef HAVE_NCURSESW
+static CH *
+utf8_to_local (char *lc_ctype, char *string)
+{
+  mbstate_t ps;
+  size_t len;
+  char *local;
+  const char *p;
+  wchar_t *wcs = NULL;
+  char *old_ctype = NULL;
+
+  local = pinentry_utf8_to_local (lc_ctype, string);
+  if (!local)
+    return NULL;
+
+  old_ctype = strdup (setlocale (LC_CTYPE, NULL));
+  setlocale (LC_CTYPE, lc_ctype? lc_ctype : "");
+
+  p = local;
+  memset (&ps, 0, sizeof(mbstate_t));
+  len = mbsrtowcs (NULL, &p, strlen (string), &ps);
+  if (len == (size_t)-1)
+    {
+      free (local);
+      goto leave;
+    }
+  wcs = calloc (len + 1, sizeof(wchar_t));
+  if (!wcs)
+    {
+      free (local);
+      goto leave;
+    }
+
+  p = local;
+  memset (&ps, 0, sizeof(mbstate_t));
+  mbsrtowcs (wcs, &p, len, &ps);
+
+ leave:
+  if (old_ctype)
+    {
+      setlocale (LC_CTYPE, old_ctype);
+      free (old_ctype);
+    }
+
+  return wcs;
+}
+#else
+static CH *
+utf8_to_local (const char *lc_ctype, const char *string)
+{
+  return pinentry_utf8_to_local (lc_ctype, string);
+}
+#endif
 
 static int
 dialog_create (pinentry_t pinentry, dialog_t dialog)
@@ -148,16 +225,15 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
   int xpos;
   int description_x = 0;
   int error_x = 0;
-  char *description = NULL;
-  char *error = NULL;
-  char *prompt = NULL;
+  CH *description = NULL;
+  CH *error = NULL;
+  CH *prompt = NULL;
 
 #define COPY_OUT(what)							\
   do									\
     if (pinentry->what)							\
       {									\
-        what = pinentry_utf8_to_local (pinentry->lc_ctype,		\
-				       pinentry->what);			\
+        what = utf8_to_local (pinentry->lc_ctype, pinentry->what);	\
         if (!what)							\
 	  {								\
 	    err = 1;							\
@@ -214,7 +290,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
   y = 1;		/* Top frame.  */
   if (description)
     {
-      char *start = description;
+      CH *start = description;
       int len = 0;
 
       do
@@ -232,7 +308,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
     {
       if (error)
 	{
-	  char *p = error;
+	  CH *p = error;
 	  int err_x = 0;
 
 	  while (*p)
@@ -287,7 +363,9 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
 
       new_x = MIN_PINENTRY_LENGTH;
       if (prompt)
-	new_x += strlen (prompt) + 1;	/* One space after prompt.  */
+	{
+	  new_x += STRLEN (prompt) + 1;	/* One space after prompt.  */
+	}
       if (new_x > size_x - 4)
 	new_x = size_x - 4;
       if (new_x > x)
@@ -335,7 +413,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
   ypos++;
   if (description)
     {
-      char *start = description;
+      CH *start = description;
       int len = 0;
 
       do
@@ -347,9 +425,11 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
 	  addch (' ');
 	  collect_line (size_x - 4, &start, &len);
 	  for (i = 0; i < len - 1; i++)
-	    addch ((unsigned char) start[i]);
-	  if (start[len - 1] && start[len - 1] != '\n')
-	    addch ((unsigned char) start[len - 1]);
+	    {
+	      ADDCH (start[i]);
+	    }
+	  if (start[len - 1] != NULLCH && start[len - 1] != NLCH)
+	    ADDCH (start[len - 1]);
 	  ypos++;
 	}
       while (start[len - 1]);
@@ -363,7 +443,7 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
 
       if (error)
 	{
-	  char *p = error;
+	  CH *p = error;
 	  i = 0;
 
 	  while (*p)
@@ -378,11 +458,11 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
 		}
 	      else
 		standout ();
-	      for (;*p && *p != '\n'; p++)
+	      for (;*p && *p != NLCH; p++)
 		if (i < x - 4)
 		  {
 		    i++;
-		    addch ((unsigned char) *p);
+		    ADDCH (*p);
 		  }
 	      if (USE_COLORS && pinentry->color_so != PINENTRY_COLOR_NONE)
 		{
@@ -410,14 +490,16 @@ dialog_create (pinentry_t pinentry, dialog_t dialog)
       dialog->pin_size = x - 4;
       if (prompt)
 	{
-	  char *p = prompt;
-	  i = strlen (prompt);
+	  CH *p = prompt;
+	  i = STRLEN (prompt);
 	  if (i > x - 4 - MIN_PINENTRY_LENGTH)
 	    i = x - 4 - MIN_PINENTRY_LENGTH;
 	  dialog->pin_x += i + 1;
 	  dialog->pin_size -= i + 1;
 	  while (i-- > 0)
-	    addch ((unsigned char) *(p++));
+	    {
+	      ADDCH (*(p++));
+	    }
 	  addch (' ');
 	}
       for (i = 0; i < dialog->pin_size; i++)
@@ -631,6 +713,17 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
   SCREEN *screen = 0;
   int done = 0;
   char *pin_utf8;
+#ifdef HAVE_NCURSESW
+  char *old_ctype = NULL;
+
+  if (pinentry->lc_ctype)
+    {
+      old_ctype = strdup (setlocale (LC_CTYPE, NULL));
+      setlocale (LC_CTYPE, pinentry->lc_ctype);
+    }
+  else
+    setlocale (LC_CTYPE, "");
+#endif
 
   /* Open the desired terminal if necessary.  */
   if (tty_name)
@@ -804,6 +897,13 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
   if (screen)
     delscreen (screen);
 
+#ifdef HAVE_NCURSESW
+  if (old_ctype)
+    {
+      setlocale (LC_CTYPE, old_ctype);
+      free (old_ctype);
+    }
+#endif
   if (ttyfi)
     fclose (ttyfi);
   if (ttyfo)

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                 |   37 +++++++++++
 ChangeLog                  |    5 ++
 configure.ac               |   30 +++++-----
 m4/curses.m4               |   20 +++++-
 pinentry/pinentry-curses.c |  150 ++++++++++++++++++++++++++++++++++++-------
 5 files changed, 199 insertions(+), 43 deletions(-)
 create mode 100644 .gitignore


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list