]> code.delx.au - gnu-emacs/blobdiff - src/search.c
Pacify gcc -Wparentheses
[gnu-emacs] / src / search.c
index 9eed390244fc47ab2309d0002b03d885a85c8128..2e9c992dc24f8889f7d2bb1f39bf92969475eef0 100644 (file)
@@ -1,6 +1,6 @@
 /* String search routines for GNU Emacs.
 
-Copyright (C) 1985-1987, 1993-1994, 1997-1999, 2001-2014 Free Software
+Copyright (C) 1985-1987, 1993-1994, 1997-1999, 2001-2015 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -985,6 +985,24 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
   return shortage;
 }
 
+/* Like above, but always scan from point and report the
+   resulting position in *CHARPOS and *BYTEPOS.  */
+
+ptrdiff_t
+scan_newline_from_point (ptrdiff_t count, ptrdiff_t *charpos,
+                        ptrdiff_t *bytepos)
+{
+  ptrdiff_t shortage;
+
+  if (count <= 0)
+    *charpos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
+                            &shortage, bytepos, 1);
+  else
+    *charpos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
+                            &shortage, bytepos, 1);
+  return shortage;
+}
+
 /* Like find_newline, but doesn't allow QUITting and doesn't return
    SHORTAGE.  */
 ptrdiff_t