emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/raeburn-startup 5c337b4 01/17: Use getc_unlocked.


From: Ken Raeburn
Subject: [Emacs-diffs] scratch/raeburn-startup 5c337b4 01/17: Use getc_unlocked.
Date: Thu, 15 Dec 2016 11:33:17 +0000 (UTC)

branch: scratch/raeburn-startup
commit 5c337b45e2b64a3601437093455c7b0412ed0529
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>

    Use getc_unlocked.
    
    * configure.ac: Check for getc_unlocked.
    * src/charset.c (read_hex, load_charset_map_from_file): Use
    getc_unlocked instead of getc.
    (getc_unlocked) [!HAVE_GETC_UNLOCKED]: Fall back to getc.
    * src/lread.c (readbyte_from_file, Fget_file_char, read1,
    getc_unlocked): Likewise.
---
 configure.ac  |    2 +-
 src/charset.c |   14 +++++++++-----
 src/lread.c   |   12 ++++++++----
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2d116de..425e338 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4158,7 +4158,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h)
 
 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
 
-AC_CHECK_FUNCS_ONCE([sbrk tzset])
+AC_CHECK_FUNCS_ONCE([getc_unlocked sbrk tzset])
 
 ok_so_far=yes
 AC_CHECK_FUNC(socket, , ok_so_far=no)
diff --git a/src/charset.c b/src/charset.c
index ff937bc..e6226ce 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -198,6 +198,10 @@ static struct
 
 #define GET_TEMP_CHARSET_WORK_DECODER(CODE)    \
   (temp_charset_work->table.decoder[(CODE)])
+
+#ifndef HAVE_GETC_UNLOCKED
+#define getc_unlocked getc
+#endif
 
 
 /* Set to 1 to warn that a charset map is loaded and thus a buffer
@@ -416,15 +420,15 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
   int c;
   unsigned n;
 
-  while ((c = getc (fp)) != EOF)
+  while ((c = getc_unlocked (fp)) != EOF)
     {
       if (c == '#')
        {
-         while ((c = getc (fp)) != EOF && c != '\n');
+         while ((c = getc_unlocked (fp)) != EOF && c != '\n');
        }
       else if (c == '0')
        {
-         if ((c = getc (fp)) == EOF || c == 'x')
+         if ((c = getc_unlocked (fp)) == EOF || c == 'x')
            break;
        }
     }
@@ -434,7 +438,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
       return 0;
     }
   n = 0;
-  while (c_isxdigit (c = getc (fp)))
+  while (c_isxdigit (c = getc_unlocked (fp)))
     {
       if (INT_LEFT_SHIFT_OVERFLOW (n, 4))
        *overflow = 1;
@@ -508,7 +512,7 @@ load_charset_map_from_file (struct charset *charset, 
Lisp_Object mapfile,
       from = read_hex (fp, &eof, &overflow);
       if (eof)
        break;
-      if (getc (fp) == '-')
+      if (getc_unlocked (fp) == '-')
        to = read_hex (fp, &eof, &overflow);
       else
        to = from;
diff --git a/src/lread.c b/src/lread.c
index eab9b8b..ada5cbf 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -72,6 +72,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #define file_tell ftell
 #endif
 
+#ifndef HAVE_GETC_UNLOCKED
+#define getc_unlocked getc
+#endif
+
 /* The association list of objects read with the #n=object form.
    Each member of the list has the form (n . object), and is used to
    look up the object for the corresponding #n# construct.
@@ -445,7 +449,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
     }
 
   block_input ();
-  c = getc (instream);
+  c = getc_unlocked (instream);
 
   /* Interrupted reads have been observed while reading over the network.  */
   while (c == EOF && ferror (instream) && errno == EINTR)
@@ -454,7 +458,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
       QUIT;
       block_input ();
       clearerr (instream);
-      c = getc (instream);
+      c = getc_unlocked (instream);
     }
 
   unblock_input ();
@@ -759,7 +763,7 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 
0, 0,
 {
   register Lisp_Object val;
   block_input ();
-  XSETINT (val, getc (instream));
+  XSETINT (val, getc_unlocked (instream));
   unblock_input ();
   return val;
 }
@@ -2847,7 +2851,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
              /* Copy that many characters into saved_doc_string.  */
              block_input ();
              for (i = 0; i < nskip && c >= 0; i++)
-               saved_doc_string[i] = c = getc (instream);
+               saved_doc_string[i] = c = getc_unlocked (instream);
              unblock_input ();
 
              saved_doc_string_length = i;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]