[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] refs/scratch/raeburn/startup 3e9395f 4/5: Use getc_unlocke
From: |
Ken Raeburn |
Subject: |
[Emacs-diffs] refs/scratch/raeburn/startup 3e9395f 4/5: Use getc_unlocked. |
Date: |
Sun, 30 Oct 2016 14:16:47 +0000 (UTC) |
reference: refs/scratch/raeburn/startup
commit 3e9395f17735e26e1ae6038ce208d9e18deea0f6
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 46fd434..de34cd3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4137,7 +4137,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h)
AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
-AC_CHECK_FUNCS_ONCE(tzset)
+AC_CHECK_FUNCS_ONCE(getc_unlocked 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 dec0df0..5cdae12 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;