Omit some unnecessary casts.
[bpt/emacs.git] / src / termcap.c
index 7256eef..aa225d9 100644 (file)
@@ -213,8 +213,8 @@ tgetst1 (char *ptr, char **area)
      abbreviation expansion makes that effort a little more hairy than
      its worth; this is cleaner.  */
   {
-    register int last_p_param = 0;
-    int remove_p_params = 1;
+    int last_p_param = 0;
+    bool remove_p_params = 1;
     struct { char *beg; int len; } cut[11];
 
     for (cut[0].beg = p = ret; p < r - 3; p++)
@@ -318,26 +318,26 @@ struct termcap_buffer
     char *beg;
     ptrdiff_t size;
     char *ptr;
-    int ateof;
+    bool ateof;
     ptrdiff_t full;
   };
 
 /* Forward declarations of static functions.  */
 
-static int scan_file (char *str, int fd, register struct termcap_buffer *bufp);
-static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end);
-static int compare_contin (register char *str1, register char *str2);
-static int name_match (char *line, char *name);
+static bool scan_file (char *, int, struct termcap_buffer *);
+static char *gobble_line (int, struct termcap_buffer *, char *);
+static bool compare_contin (char *, char *);
+static bool name_match (char *, char *);
 
-#ifdef MSDOS /* MW, May 1993 */
-static int
+static bool
 valid_filename_p (char *fn)
 {
+#ifdef MSDOS
   return *fn == '/' || fn[1] == ':';
-}
 #else
-#define valid_filename_p(fn) (*(fn) == '/')
+  return *fn == '/';
 #endif
+}
 
 /* Find the termcap entry data for terminal type NAME
    and store it in the block that BP points to.
@@ -360,10 +360,10 @@ tgetent (char *bp, const char *name)
   char *tc_search_point;
   char *term;
   ptrdiff_t malloc_size = 0;
-  register int c;
+  int c;
   char *tcenv = NULL;          /* TERMCAP value, if it contains :tc=.  */
   char *indirect = NULL;       /* Terminal type in :tc= in TERMCAP value.  */
-  int filep;
+  bool filep;
 
 #ifdef INTERNAL_TERMINAL
   /* For the internal terminal we don't want to read any termcap file,
@@ -406,7 +406,7 @@ tgetent (char *bp, const char *name)
 
   if (termcap_name && !filep && !strcmp (name, getenv ("TERM")))
     {
-      indirect = tgetst1 (find_capability (termcap_name, "tc"), (char **) 0);
+      indirect = tgetst1 (find_capability (termcap_name, "tc"), 0);
       if (!indirect)
        {
          if (!bp)
@@ -455,7 +455,7 @@ tgetent (char *bp, const char *name)
       /* Scan the file, reading it via buf, till find start of main entry.  */
       if (scan_file (term, fd, &buf) == 0)
        {
-         close (fd);
+         emacs_close (fd);
          xfree (buf.beg);
          if (malloc_size)
            xfree (bp);
@@ -490,10 +490,10 @@ tgetent (char *bp, const char *name)
       /* Does this entry refer to another terminal type's entry?
         If something is found, copy it into heap and null-terminate it.  */
       tc_search_point = find_capability (tc_search_point, "tc");
-      term = tgetst1 (tc_search_point, (char **) 0);
+      term = tgetst1 (tc_search_point, 0);
     }
 
-  close (fd);
+  emacs_close (fd);
   xfree (buf.beg);
 
   if (malloc_size)
@@ -510,10 +510,10 @@ tgetent (char *bp, const char *name)
    Return 1 if successful, with that line in BUFP,
    or 0 if no entry is found in the file.  */
 
-static int
-scan_file (char *str, int fd, register struct termcap_buffer *bufp)
+static bool
+scan_file (char *str, int fd, struct termcap_buffer *bufp)
 {
-  register char *end;
+  char *end;
 
   bufp->ptr = bufp->beg;
   bufp->full = 0;
@@ -544,13 +544,13 @@ scan_file (char *str, int fd, register struct termcap_buffer *bufp)
   return 0;
 }
 
-/* Return nonzero if NAME is one of the names specified
+/* Return true if NAME is one of the names specified
    by termcap entry LINE.  */
 
-static int
+static bool
 name_match (char *line, char *name)
 {
-  register char *tem;
+  char *tem;
 
   if (!compare_contin (line, name))
     return 1;
@@ -562,18 +562,18 @@ name_match (char *line, char *name)
   return 0;
 }
 
-static int
-compare_contin (register char *str1, register char *str2)
+static bool
+compare_contin (char *str1, char *str2)
 {
-  register int c1, c2;
   while (1)
     {
-      c1 = *str1++;
-      c2 = *str2++;
+      int c1 = *str1++;
+      int c2 = *str2++;
       while (c1 == '\\' && *str1 == '\n')
        {
          str1++;
-         while ((c1 = *str1++) == ' ' || c1 == '\t');
+         while ((c1 = *str1++) == ' ' || c1 == '\t')
+           continue;
        }
       if (c2 == '\0')
        {
@@ -647,57 +647,3 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
     }
   return end + 1;
 }
-\f
-#ifdef TEST
-
-#include <stdio.h>
-
-static void
-tprint (char *cap)
-{
-  char *x = tgetstr (cap, 0);
-  register char *y;
-
-  printf ("%s: ", cap);
-  if (x)
-    {
-      for (y = x; *y; y++)
-       if (*y <= ' ' || *y == 0177)
-         printf ("\\%0o", *y);
-       else
-         putchar (*y);
-      free (x);
-    }
-  else
-    printf ("none");
-  putchar ('\n');
-}
-
-int
-main (int argc, char **argv)
-{
-  char *term;
-  char *buf;
-
-  term = argv[1];
-  printf ("TERM: %s\n", term);
-
-  buf = (char *) tgetent (0, term);
-  if ((int) buf <= 0)
-    {
-      printf ("No entry.\n");
-      return 0;
-    }
-
-  printf ("Entry: %s\n", buf);
-
-  tprint ("cm");
-  tprint ("AL");
-
-  printf ("co: %d\n", tgetnum ("co"));
-  printf ("am: %d\n", tgetflag ("am"));
-
-  return 0;
-}
-
-#endif /* TEST */