Commit efe200c1 authored by Ken Raeburn's avatar Ken Raeburn

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.
parent 6af67b4a
......@@ -4218,7 +4218,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h)
AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
AC_CHECK_FUNCS_ONCE([sbrk])
AC_CHECK_FUNCS_ONCE([getc_unlocked sbrk])
ok_so_far=yes
AC_CHECK_FUNC(socket, , ok_so_far=no)
......
......@@ -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;
......
......@@ -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)
maybe_quit ();
block_input ();
clearerr (instream);
c = getc (instream);
c = getc_unlocked (instream);
}
unblock_input ();
......@@ -757,7 +761,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;
}
......@@ -2901,7 +2905,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment