]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
merge with 1.9.1a
authorJim Meyering <jim@meyering.net>
Sat, 20 Nov 1993 17:00:37 +0000 (17:00 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 20 Nov 1993 17:00:37 +0000 (17:00 +0000)
old/sh-utils/ChangeLog
old/sh-utils/NEWS
src/expr.c
src/printf.c
src/stty.c
src/who.c

index c3e31484096f92fefa242fb8873f89910946aa33..0dee1d0eeda70d10d7e9171c5224bb2461e62164 100644 (file)
@@ -1,3 +1,40 @@
+Fri Nov 19 23:08:03 1993  Jim Meyering  (meyering@comco.com)
+
+       * who.c (print_entry): Produce reasonably formatted output even when
+       sizeof (this->ut_name,ut_line) are much larger than 8.  For Solaris
+       and other SysVr4.  With help from Arne H. Juul.
+       * configure.in (HAVE_UTMPX_H): New test; combined with test for the
+       ut_host field.  From Arne H. Juul.
+
+       * memcmp.c: New file.
+       * lib/Makefile.in [SOURCES]: Add memcmp.c.
+       * configure.in (AC_REPLACE_FUNCS): Add memcmp.
+       Add test for 8-bit clean memcmp.
+
+       * configure.in (AC_HAVE_FUNCS): Add isascii.
+       * expr.c [!defined (isascii) || defined (STDC_HEADERS)]: This failed
+       on AIX PS/2 1.3 systems because isascii is a function and it is used
+       in definitions (with the necessary side effect of assigning to a
+       global variable) of the is* macros.  Also test HAVE_ISASCII and
+       redefine ISASCII(c) instead of isascii.
+       Reported by Minh Tran-Le (tranle@intellicorp.com).
+       * printf.c: Ditto.
+
+       * configure.in (AC_HAVE_HEADERS): Add sys/timeb.h; getdate.y tests
+       HAVE_SYS_TIMEB_H.
+
+       * stty.c (main): Detect the case in which POSIX-conformant tcsetattr
+       fails and still returns zero.
+
+Wed Nov 17 21:05:10 1993  Jim Meyering  (meyering@comco.com)
+
+       * yes.c (main): Complete my half-finished Nov 2 change.
+       yes with arguments did not print newlines.  From Andreas Schwab
+       (ls5.informatik.uni-dortmund.de).
+
+       * stty.c (wrapf): Fix off-by-one error that could make `stty -a'
+       output lines one character too long.  From Andreas Schwab.
+
 Sat Nov 13 00:11:19 1993  Jim Meyering  (meyering@comco.com)
 
        * Version 1.9.1.
index 4b3f4c3d5547bc17c5035b36f3b27e16e501ba21..68e493af1ec8c1c8998b067509a40268b7a5adaa 100644 (file)
@@ -1,3 +1,8 @@
+User visible changes in release 1.9.2:
+* fix a minor problem in formatting of output from `stty -a'
+* yes with arguments outputs newlines again
+* partial stty failures are reported
+\f
 Major changes in release 1.9.1:
 * stty can be built on Suns again
 * minor fix for who -q
index 26c4ffa0d2af0a9b0ad41c7cdea27e8f7eacf97a..e5549140ff8c2de554bc28b8602a63a20a22594d 100644 (file)
 #include "version.h"
 #include "long-options.h"
 
-#if !defined (isascii) || defined (STDC_HEADERS)
-#undef isascii
-#define isascii(c) 1
+#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
+#define ISASCII(c) 1
+#else
+#define ISASCII(c) isascii(c)
 #endif
 
-#define ISDIGIT(c) (isascii (c) && isdigit (c))
+#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
 
 #define NEW(type) ((type *) xmalloc (sizeof (type)))
 #define OLD(x) free ((char *) x)
index 43cc0dec3f2cd97dc45f1e1cac368ee8c2d1ac06..0fe108fb665bcbaa12fb9159bc7c9d44793c31d3 100644 (file)
 #include "version.h"
 #include "long-options.h"
 
-#if !defined (isascii) || defined (STDC_HEADERS)
-#undef isascii
-#define isascii(c) 1
+#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
+#define ISASCII(c) 1
+#else
+#define ISASCII(c) isascii(c)
 #endif
 
-#define ISDIGIT(c) (isascii (c) && isdigit (c))
-#define ISXDIGIT(c) (isascii (c) && isxdigit (c))
+#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
+#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
 
 #ifndef STDC_HEADERS
 double strtod ();
index 60f2ec9f1dff067af624bc3cda20625c00b7567b..fc44cd35d38b976041bf4cf1e4a945853c1c7b79 100644 (file)
@@ -428,7 +428,7 @@ wrapf (message, va_alist)
   vsprintf (buf, message, args);
   va_end (args);
   buflen = strlen (buf);
-  if (current_col + buflen >= max_col)
+  if (current_col + (current_col > 0) + buflen >= max_col)
     {
       putchar ('\n');
       current_col = 0;
@@ -624,6 +624,7 @@ main (argc, argv)
      char **argv;
 {
   struct termios mode;
+  struct termios new_mode;
   enum output_type output_type = changed;
   int optc;
 
@@ -661,6 +662,9 @@ done:;
   if (show_help)
     usage (0);
 
+  /* Initialize to all zeroes so there is no risk memcmp will report a
+     spurious difference in uninitialized portion of the structure.  */
+  bzero (&mode, sizeof (mode));
   if (tcgetattr (0, &mode))
     error (1, errno, "standard input");
 
@@ -795,6 +799,29 @@ done:;
   if (tcsetattr (0, TCSADRAIN, &mode))
     error (1, errno, "standard input");
 
+  /* POSIX (according to Zlotnick's book) tcsetattr returns zero if it
+     performs *any* of the requested operations.  This means it can report
+     `success' when it has actually failed to perform some proper subset
+     of the requested operations.  To detect this partial failure, get the
+     current terminal attributes and compare them to the requested ones.  */
+
+  /* Initialize to all zeroes so there is no risk memcmp will report a
+     spurious difference in uninitialized portion of the structure.  */
+  bzero (&new_mode, sizeof (new_mode));
+  if (tcgetattr (0, &new_mode))
+    error (1, errno, "standard input");
+
+  /* Normally, one shouldn't use memcmp to compare structures that
+     may have `holes' containing uninitialized data, but we have been
+     careful to initialize the storage of these two variables to all
+     zeroes.  One might think it more efficient simply to compare the
+     modified fields, but that would require enumerating those fields --
+     and not all systems have the same fields in this structure.  */
+
+  if (memcmp (&mode, &new_mode, sizeof (mode)) != 0)
+    error (1, 0,
+          "standard input: unable to perform all requested operations");
+
   exit (0);
 }
 
index 8ef2749f4f7b7bdaf28e080afc103b349b89698d..b7f800b9003edc4342f4647e418a5310bb2221f8 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -297,15 +297,17 @@ print_entry (this)
       last_change = 0;
     }
   
-  printf ("%-*.*s",
-         (int) sizeof (this->ut_name), (int) sizeof (this->ut_name),
-         this->ut_name);
+  printf ("%-8.*s", (int) sizeof (this->ut_name), this->ut_name);
   if (include_mesg)
     printf ("  %c  ", mesg);
-  printf (" %-*.*s",
-         (int) sizeof (this->ut_line), (int) sizeof (this->ut_line),
-         this->ut_line);
+  printf (" %-8.*s", (int) sizeof (this->ut_line), this->ut_line);
+
+#ifdef HAVE_UTMPX_H
+  printf (" %-12.12s", ctime (&this->ut_tv.tv_sec) + 4);
+#else
   printf (" %-12.12s", ctime (&this->ut_time) + 4);
+#endif
+
   if (include_idle)
     {
       if (last_change)
@@ -362,12 +364,10 @@ list_entries (n)
 static void
 print_heading ()
 {
-  STRUCT_UTMP *ut;
-
-  printf ("%-*s ", (int) sizeof (ut->ut_name), "USER");
+  printf ("%-8s ", "USER");
   if (include_mesg)
     printf ("MESG ");
-  printf ("%-*s ", (int) sizeof (ut->ut_line), "LINE");
+  printf ("%-8s ", "LINE");
   printf ("LOGIN-TIME   ");
   if (include_idle)
     printf ("IDLE  ");