]> code.delx.au - gnu-emacs/blobdiff - src/cm.c
* test/lisp/help-fns-tests.el: Add several tests for 'describe-function'.
[gnu-emacs] / src / cm.c
index 7bb715e21b5b0f780b3c716100872af68da5be50..e135889f17c4b5a7377ee0cb7551e4dd168166d9 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -1,14 +1,13 @@
 /* Cursor motion subroutines for GNU Emacs.
-   Copyright (C) 1985, 1995, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+   Copyright (C) 1985, 1995, 2001-2016 Free Software Foundation, Inc.
     based primarily on public domain code written by Chris Torek
 
 This file is part of GNU Emacs.
 
 GNU Emacs 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 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,37 +20,19 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
-#include <setjmp.h>
 
 #include "lisp.h"
-#include "frame.h"
 #include "cm.h"
-#include "termhooks.h"
 #include "termchar.h"
+#include "tparam.h"
 
-
-/* For now, don't try to include termcap.h.  On some systems,
-   configure finds a non-standard termcap.h that the main build
-   won't find.  */
-
-#if defined HAVE_TERMCAP_H && 0
-#include <termcap.h>
-#else
-extern void tputs P_ ((const char *, int, int (*)(int)));
-extern char *tgoto P_ ((const char *, int, int));
-#endif
-
-#define        BIG     9999            /* 9999 good on VAXen.  For 16 bit machines
-                                  use about 2000.... */
-
-extern char *BC, *UP;
+#define        BIG     9999            /* Good on 32-bit hosts.  */
 
 int cost;              /* sums up costs */
 
 /* ARGSUSED */
 int
-evalcost (c)
-     char c;
+evalcost (int c)
 {
   cost++;
   return c;
@@ -61,8 +42,7 @@ evalcost (c)
 struct tty_display_info *current_tty;
 
 int
-cmputc (c)
-     char c;
+cmputc (int c)
 {
   if (current_tty->termscript)
     putc (c & 0177, current_tty->termscript);
@@ -135,7 +115,7 @@ cmcheckmagic (struct tty_display_info *tty)
   if (curX (tty) == FrameCols (tty))
     {
       if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
-       abort ();
+       emacs_abort ();
       if (tty->termscript)
        putc ('\r', tty->termscript);
       putc ('\r', tty->output);
@@ -207,7 +187,7 @@ calccost (struct tty_display_info *tty,
             tabx,
             tab2x,
             tabcost;
-    register char  *p;
+    register const char *p;
 
     /* If have just wrapped on a terminal with xn,
        don't believe the cursor position: give up here
@@ -230,8 +210,9 @@ calccost (struct tty_display_info *tty,
     }
     totalcost = c * deltay;
     if (doit)
-       while (--deltay >= 0)
+      do
           emacs_tputs (tty, p, 1, cmputc);
+      while (--deltay > 0);
 x:
     if ((deltax = dstx - srcx) == 0)
        goto done;
@@ -312,14 +293,16 @@ fail:
     }
     totalcost += c * deltax;
     if (doit)
-       while (--deltax >= 0)
+      do
           emacs_tputs (tty, p, 1, cmputc);
+      while (--deltax > 0);
 done:
     return totalcost;
 }
 
 #if 0
-losecursor ()
+void
+losecursor (void)
 {
   curY = -1;
 }
@@ -331,18 +314,16 @@ losecursor ()
 #define        USECR   3
 
 void
-cmgoto (tty, row, col)
-     struct tty_display_info *tty;
-     int row, col;
+cmgoto (struct tty_display_info *tty, int row, int col)
 {
     int     homecost,
             crcost,
             llcost,
             relcost,
             directcost;
-    int     use;
-    char   *p,
-           *dcm;
+    int use UNINIT;
+    char *p;
+    const char *dcm;
 
   /* First the degenerate case */
     if (row == curY (tty) && col == curX (tty)) /* already there */
@@ -439,7 +420,7 @@ cmgoto (tty, row, col)
 void
 Wcm_clear (struct tty_display_info *tty)
 {
-  bzero (tty->Wcm, sizeof (struct cm));
+  memset (tty->Wcm, 0, sizeof (struct cm));
   UP = 0;
   BC = 0;
 }
@@ -470,6 +451,3 @@ Wcm_init (struct tty_display_info *tty)
     return - 2;
   return 0;
 }
-
-/* arch-tag: bcf64c02-00f6-44ef-94b6-c56eab5b3dc4
-   (do not change this comment) */