From d10f6a7b3e20bf142cca4fe854c4f63b389700c4 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Thu, 25 Aug 2005 21:45:17 +0000 Subject: Update. --- gl/Makefile.am | 2 +- gl/getpass.c | 115 ++++++++++++++++++++++++++++---------------------------- gl/m4/gnulib.m4 | 12 +++--- gl/m4/minmax.m4 | 17 +++++---- 4 files changed, 75 insertions(+), 71 deletions(-) diff --git a/gl/Makefile.am b/gl/Makefile.am index 5ab718ca13..ec00cdaa1f 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # # Generated by gnulib-tool. # Invoked as: gnulib-tool --import -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --libtool --lgpl alloca-opt error getdelim getline getpass isascii memmem memmove minmax readline size_max snprintf stdbool vasnprintf xsize +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=build-aux --libtool --lgpl alloca-opt error getdelim getline getpass isascii memmem memmove minmax readline size_max snprintf stdbool vasnprintf xsize AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies diff --git a/gl/getpass.c b/gl/getpass.c index e139537a86..caa7200b26 100644 --- a/gl/getpass.c +++ b/gl/getpass.c @@ -23,59 +23,7 @@ #include -#ifdef WIN32 - -/* Windows implementation by Martin Lambers , - improved by Simon Josefsson. */ - -/* For PASS_MAX. */ -#include - -#ifndef PASS_MAX -# define PASS_MAX 512 -#endif - -char *getpass(const char *prompt) -{ - char getpassbuf[PASS_MAX + 1]; - size_t i = 0; - int c; - - if (prompt) - { - fputs (prompt, stderr); - fflush (stderr); - } - - for (;;) - { - c = _getch(); - if (c == '\r') - { - getpassbuf[i] = '\0'; - break; - } - else if (i < PASS_MAX) - { - getpassbuf[i++] = c; - } - - if (i >= PASS_MAX) - { - getpassbuf[i] = '\0'; - break; - } - } - - if (prompt) - { - fputs ("\r\n", stderr); - fflush (stderr); - } - - return strdup (getpassbuf); -} -#else /* WIN32 */ +#if !defined WIN32 #include @@ -83,7 +31,7 @@ char *getpass(const char *prompt) # include #endif #if !HAVE___FSETLOCKING -# define __fsetlocking(stream, type) /* empty */ +# define __fsetlocking(stream, type) /* empty */ #endif #if HAVE_TERMIOS_H @@ -170,8 +118,8 @@ getpass (const char *prompt) /* Save the old one. */ s = t; /* Tricky, tricky. */ - t.c_lflag &= ~(ECHO|ISIG); - tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0); + t.c_lflag &= ~(ECHO | ISIG); + tty_changed = (tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &t) == 0); } #endif @@ -212,7 +160,7 @@ getpass (const char *prompt) /* Restore the original setting. */ #if TCSETATTR if (tty_changed) - tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s); + tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &s); #endif funlockfile (out); @@ -222,4 +170,57 @@ getpass (const char *prompt) return buf; } +#else /* WIN32 */ + +/* Windows implementation by Martin Lambers , + improved by Simon Josefsson. */ + +/* For PASS_MAX. */ +#include + +#ifndef PASS_MAX +# define PASS_MAX 512 +#endif + +char * +getpass (const char *prompt) +{ + char getpassbuf[PASS_MAX + 1]; + size_t i = 0; + int c; + + if (prompt) + { + fputs (prompt, stderr); + fflush (stderr); + } + + for (;;) + { + c = _getch (); + if (c == '\r') + { + getpassbuf[i] = '\0'; + break; + } + else if (i < PASS_MAX) + { + getpassbuf[i++] = c; + } + + if (i >= PASS_MAX) + { + getpassbuf[i] = '\0'; + break; + } + } + + if (prompt) + { + fputs ("\r\n", stderr); + fflush (stderr); + } + + return strdup (getpassbuf); +} #endif diff --git a/gl/m4/gnulib.m4 b/gl/m4/gnulib.m4 index fb46b520bc..65585421a6 100644 --- a/gl/m4/gnulib.m4 +++ b/gl/m4/gnulib.m4 @@ -8,7 +8,7 @@ # Generated by gnulib-tool. # # Invoked as: gnulib-tool --import -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --libtool --lgpl alloca-opt error getdelim getline getpass isascii memmem memmove minmax readline size_max snprintf stdbool vasnprintf xsize +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=build-aux --libtool --lgpl alloca-opt error getdelim getline getpass isascii memmem memmove minmax readline size_max snprintf stdbool vasnprintf xsize AC_DEFUN([gl_EARLY], [ @@ -34,19 +34,19 @@ AC_DEFUN([gl_INIT], gl_XSIZE ]) -dnl Usage: gl_MODULES(module1 module2 ...) +dnl Usage: gl_MODULES([module1 module2 ...]) AC_DEFUN([gl_MODULES], []) -dnl Usage: gl_AVOID(module1 module2 ...) +dnl Usage: gl_AVOID([module1 module2 ...]) AC_DEFUN([gl_AVOID], []) -dnl Usage: gl_SOURCE_BASE(DIR) +dnl Usage: gl_SOURCE_BASE([DIR]) AC_DEFUN([gl_SOURCE_BASE], []) -dnl Usage: gl_M4_BASE(DIR) +dnl Usage: gl_M4_BASE([DIR]) AC_DEFUN([gl_M4_BASE], []) -dnl Usage: gl_LIB(LIBNAME) +dnl Usage: gl_LIB([LIBNAME]) AC_DEFUN([gl_LIB], []) dnl Usage: gl_LGPL diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4 index 6c6b72b773..bbd1ba0b84 100644 --- a/gl/m4/minmax.m4 +++ b/gl/m4/minmax.m4 @@ -1,9 +1,11 @@ -# minmax.m4 serial 1 +# minmax.m4 serial 2 dnl Copyright (C) 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +AC_PREREQ(2.52) + AC_DEFUN([gl_MINMAX], [ AC_REQUIRE([gl_PREREQ_MINMAX]) @@ -17,12 +19,13 @@ AC_DEFUN([gl_PREREQ_MINMAX], ]) dnl gl_MINMAX_IN_HEADER(HEADER) +dnl The parameter has to be a literal header name; it cannot be macro, +dnl nor a shell variable. (Because autoheader collects only AC_DEFINE +dnl invocations with a literal macro name.) AC_DEFUN([gl_MINMAX_IN_HEADER], [ - define([header],[translit([$1],[./-], - [___])]) - define([HEADER],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + m4_pushdef([header], AS_TR_SH([$1])) + m4_pushdef([HEADER], AS_TR_CPP([$1])) AC_CACHE_CHECK([whether <$1> defines MIN and MAX], [gl_cv_minmax_in_]header, [AC_TRY_COMPILE([#include <$1> @@ -33,6 +36,6 @@ int x = MIN (42, 17);], [], AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, [Define to 1 if <$1> defines the MIN and MAX macros.]) fi - undefine([HEADER]) - undefine([header]) + m4_popdef([HEADER]) + m4_popdef([header]) ]) -- cgit v1.2.1