changeset 111544:107fd4b37e9d

Clean up src/systty.h macros. * systty.h (EMACS_GET_TTY_PGRP, EMACS_SET_TTY_PGRP, EMACS_GET_TTY) (EMACS_SET_TTY): Remove unneeded abstraction, instead inline the definition in all uses. (EMACS_TTY_TABS_OK): Remove, it has a single user. * src/sysdep.c (discard_tty_input, child_setup_tty) (init_sys_modes, tabs_safe_p, reset_sys_modes): * src/emacs.c (shut_down_emacs): * src/callproc.c (child_setup): * src/term.c (dissociate_if_controlling_tty): Inline removed macros.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 14 Nov 2010 22:10:35 -0800
parents 317ffffec7f3
children a112abc60888
files src/ChangeLog src/callproc.c src/emacs.c src/sysdep.c src/systty.h src/term.c
diffstat 6 files changed, 33 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Nov 14 21:52:58 2010 -0800
+++ b/src/ChangeLog	Sun Nov 14 22:10:35 2010 -0800
@@ -1,5 +1,16 @@
 2010-11-15  Dan Nicolaescu  <dann@ics.uci.edu>
 
+	Clean up systty.h macros.
+	* systty.h (EMACS_GET_TTY_PGRP, EMACS_SET_TTY_PGRP, EMACS_GET_TTY)
+	(EMACS_SET_TTY): Remove unneeded abstraction, instead inline the
+	definition in all uses.
+	(EMACS_TTY_TABS_OK): Remove, it has a single user.
+	* sysdep.c (discard_tty_input, child_setup_tty)
+	(init_sys_modes, tabs_safe_p, reset_sys_modes):
+	* emacs.c (shut_down_emacs):
+	* callproc.c (child_setup):
+	* term.c (dissociate_if_controlling_tty): Inline removed macros.
+
 	* data.c (sign_extend_temp, sign_extend_lisp_int): Remove, unused.
 
 2010-11-14  Chong Yidong  <cyd@stupidchicken.com>
--- a/src/callproc.c	Sun Nov 14 21:52:58 2010 -0800
+++ b/src/callproc.c	Sun Nov 14 22:10:35 2010 -0800
@@ -1221,7 +1221,7 @@
   return cpid;
 #else /* not WINDOWSNT */
   /* setpgrp_of_tty is incorrect here; it uses input_fd.  */
-  EMACS_SET_TTY_PGRP (0, &pid);
+  tcsetpgrp (0, pid);
 
   /* execvp does not accept an environment arg so the only way
      to pass this environment is to set environ.  Our caller
@@ -1609,5 +1609,3 @@
   defsubr (&Scall_process_region);
 }
 
-/* arch-tag: 769b8045-1df7-4d2b-8968-e3fb49017f95
-   (do not change this comment) */
--- a/src/emacs.c	Sun Nov 14 21:52:58 2010 -0800
+++ b/src/emacs.c	Sun Nov 14 22:10:35 2010 -0800
@@ -2053,10 +2053,8 @@
 #ifndef DOS_NT
   {
     int pgrp = EMACS_GETPGRP (0);
-
-    int tpgrp;
-    if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1
-	&& tpgrp == pgrp)
+    int tpgrp = tcgetpgrp (0);
+    if ((tpgrp != -1) && tpgrp == pgrp)
       {
 	reset_all_sys_modes ();
 	if (sig && sig != SIGTERM)
--- a/src/sysdep.c	Sun Nov 14 21:52:58 2010 -0800
+++ b/src/sysdep.c	Sun Nov 14 22:10:35 2010 -0800
@@ -229,8 +229,8 @@
       {
         if (tty->input)         /* Is the device suspended? */
           {
-            EMACS_GET_TTY (fileno (tty->input), &buf);
-            EMACS_SET_TTY (fileno (tty->input), &buf, 0);
+            emacs_get_tty (fileno (tty->input), &buf);
+            emacs_set_tty (fileno (tty->input), &buf, 0);
           }
       }
   }
@@ -366,7 +366,7 @@
 #ifndef WINDOWSNT
   struct emacs_tty s;
 
-  EMACS_GET_TTY (out, &s);
+  emacs_get_tty (out, &s);
   s.main.c_oflag |= OPOST;	/* Enable output postprocessing */
   s.main.c_oflag &= ~ONLCR;	/* Disable map of NL to CR-NL on output */
 #ifdef NLDLY
@@ -444,7 +444,7 @@
   s.main.c_cc[VTIME] = 0;
 #endif
 
-  EMACS_SET_TTY (out, &s, 0);
+  emacs_set_tty (out, &s, 0);
 #endif /* not WINDOWSNT */
 }
 #endif	/* not MSDOS */
@@ -856,7 +856,7 @@
   if (! tty_out->old_tty)
     tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
 
-  EMACS_GET_TTY (fileno (tty_out->input), tty_out->old_tty);
+  emacs_get_tty (fileno (tty_out->input), tty_out->old_tty);
 
   tty = *tty_out->old_tty;
 
@@ -1002,7 +1002,7 @@
   dos_ttraw (tty_out);
 #endif
 
-  EMACS_SET_TTY (fileno (tty_out->input), &tty, 0);
+  emacs_set_tty (fileno (tty_out->input), &tty, 0);
 
   /* This code added to insure that, if flow-control is not to be used,
      we have an unlocked terminal at the start. */
@@ -1094,8 +1094,16 @@
 {
   struct emacs_tty etty;
 
-  EMACS_GET_TTY (fd, &etty);
-  return EMACS_TTY_TABS_OK (&etty);
+  emacs_get_tty (fd, &etty);
+#ifndef DOS_NT
+#ifdef TABDLY
+  return ((etty.main.c_oflag & TABDLY) != TAB3);
+#else /* not TABDLY */
+  return 1;
+#endif /* not TABDLY */
+#else /* DOS_NT */
+  return 0;
+#endif /* DOS_NT */
 }
 
 /* Get terminal size from system.
@@ -1257,7 +1265,7 @@
 #endif /* F_SETFL */
 
   if (tty_out->old_tty)
-    while (EMACS_SET_TTY (fileno (tty_out->input),
+    while (emacs_set_tty (fileno (tty_out->input),
                           tty_out->old_tty, 0) < 0 && errno == EINTR)
       ;
 
--- a/src/systty.h	Sun Nov 14 21:52:58 2010 -0800
+++ b/src/systty.h	Sun Nov 14 22:10:35 2010 -0800
@@ -86,17 +86,6 @@
 
 /* Manipulate a terminal's current process group.  */
 
-/* EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
-   current process group.  Return -1 if there is an error.
-
-   EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
-   current process group to *PGID.  Return -1 if there is an error.  */
-
-#ifndef DOS_NT
-#define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
-#define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid)))
-#endif /* not DOS_NT */
-
 /* EMACS_GETPGRP (arg) returns the process group of the process.  */
 
 #if defined (GETPGRP_VOID)
@@ -112,21 +101,7 @@
    state, for example a struct tchars, a struct sgttyb, a struct
    tchars, a struct ltchars, and a struct pagechars, struct
    emacs_tty should contain an element for each parameter struct
-   that Emacs may change.
-
-   EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the parameters
-   of the tty on FD in *P.  Return zero if all's well, or -1 if we ran
-   into an error we couldn't deal with.
-
-   EMACS_SET_TTY (int FD, struct emacs_tty *P, int flushp)
-   sets the parameters of the tty on FD according to the contents of
-   *P.  If flushp is non-zero, we discard queued input to be
-   written before making the change.
-   Return 0 if all went well, and -1 if anything failed.
-
-   EMACS_TTY_TABS_OK (struct emacs_tty *P) is false if the kernel
-   expands tabs to spaces upon output; in that case, there is no
-   advantage to using tabs over spaces.  */
+   that Emacs may change.  */
 
 
 /* For each tty parameter structure that Emacs might want to save and restore,
@@ -145,31 +120,6 @@
 #endif /* DOS_NT */
 };
 
-/* Define EMACS_GET_TTY and EMACS_SET_TTY,
-   the macros for reading and setting parts of `struct emacs_tty'.
-
-   These got pretty unmanageable (huge macros are hard to debug), and
-   finally needed some code which couldn't be done as part of an
-   expression, so we moved them out to their own functions in sysdep.c.  */
-#define EMACS_GET_TTY(fd, p)        (emacs_get_tty ((fd), (p)))
-#define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
 extern int emacs_get_tty (int, struct emacs_tty *);
 extern int emacs_set_tty (int, struct emacs_tty *, int);
 
-
-/* Define EMACS_TTY_TABS_OK.  */
-
-#ifndef DOS_NT
-
-#ifdef TABDLY
-#define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
-#else /* not TABDLY */
-#define EMACS_TTY_TABS_OK(p) 1
-#endif /* not TABDLY */
-
-#else /* DOS_NT */
-#define EMACS_TTY_TABS_OK(p) 0
-#endif /* DOS_NT */
-
-/* arch-tag: cf4b90bc-be41-401c-be98-40619178a712
-   (do not change this comment) */
--- a/src/term.c	Sun Nov 14 21:52:58 2010 -0800
+++ b/src/term.c	Sun Nov 14 22:10:35 2010 -0800
@@ -3087,8 +3087,7 @@
 dissociate_if_controlling_tty (int fd)
 {
 #ifndef DOS_NT
-  int pgid;
-  EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
+  int pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */
   if (pgid != -1)
     {
 #if defined (USG5)
@@ -3832,7 +3831,3 @@
   encode_terminal_dst = NULL;
 }
 
-
-
-/* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193
-   (do not change this comment) */