diff options
| author | Ken Raeburn | 2016-10-27 00:50:07 -0400 |
|---|---|---|
| committer | Ken Raeburn | 2017-06-21 22:34:33 -0400 |
| commit | efe200c10da02db68c6eeadc3cd82a8cc3108c96 (patch) | |
| tree | 9d194249f93b74a18eef167efad5a5d9b1f06ce8 /src | |
| parent | 6af67b4a8842fd3b949fa5bfb68811f62a521ae2 (diff) | |
| download | emacs-efe200c10da02db68c6eeadc3cd82a8cc3108c96.tar.gz emacs-efe200c10da02db68c6eeadc3cd82a8cc3108c96.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/charset.c | 14 | ||||
| -rw-r--r-- | src/lread.c | 12 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/charset.c b/src/charset.c index f0b41400843..9d15375dd79 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -198,6 +198,10 @@ static struct | |||
| 198 | 198 | ||
| 199 | #define GET_TEMP_CHARSET_WORK_DECODER(CODE) \ | 199 | #define GET_TEMP_CHARSET_WORK_DECODER(CODE) \ |
| 200 | (temp_charset_work->table.decoder[(CODE)]) | 200 | (temp_charset_work->table.decoder[(CODE)]) |
| 201 | |||
| 202 | #ifndef HAVE_GETC_UNLOCKED | ||
| 203 | #define getc_unlocked getc | ||
| 204 | #endif | ||
| 201 | 205 | ||
| 202 | 206 | ||
| 203 | /* Set to 1 to warn that a charset map is loaded and thus a buffer | 207 | /* 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) | |||
| 416 | int c; | 420 | int c; |
| 417 | unsigned n; | 421 | unsigned n; |
| 418 | 422 | ||
| 419 | while ((c = getc (fp)) != EOF) | 423 | while ((c = getc_unlocked (fp)) != EOF) |
| 420 | { | 424 | { |
| 421 | if (c == '#') | 425 | if (c == '#') |
| 422 | { | 426 | { |
| 423 | while ((c = getc (fp)) != EOF && c != '\n'); | 427 | while ((c = getc_unlocked (fp)) != EOF && c != '\n'); |
| 424 | } | 428 | } |
| 425 | else if (c == '0') | 429 | else if (c == '0') |
| 426 | { | 430 | { |
| 427 | if ((c = getc (fp)) == EOF || c == 'x') | 431 | if ((c = getc_unlocked (fp)) == EOF || c == 'x') |
| 428 | break; | 432 | break; |
| 429 | } | 433 | } |
| 430 | } | 434 | } |
| @@ -434,7 +438,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow) | |||
| 434 | return 0; | 438 | return 0; |
| 435 | } | 439 | } |
| 436 | n = 0; | 440 | n = 0; |
| 437 | while (c_isxdigit (c = getc (fp))) | 441 | while (c_isxdigit (c = getc_unlocked (fp))) |
| 438 | { | 442 | { |
| 439 | if (INT_LEFT_SHIFT_OVERFLOW (n, 4)) | 443 | if (INT_LEFT_SHIFT_OVERFLOW (n, 4)) |
| 440 | *overflow = 1; | 444 | *overflow = 1; |
| @@ -508,7 +512,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, | |||
| 508 | from = read_hex (fp, &eof, &overflow); | 512 | from = read_hex (fp, &eof, &overflow); |
| 509 | if (eof) | 513 | if (eof) |
| 510 | break; | 514 | break; |
| 511 | if (getc (fp) == '-') | 515 | if (getc_unlocked (fp) == '-') |
| 512 | to = read_hex (fp, &eof, &overflow); | 516 | to = read_hex (fp, &eof, &overflow); |
| 513 | else | 517 | else |
| 514 | to = from; | 518 | to = from; |
diff --git a/src/lread.c b/src/lread.c index a6d04ec5af7..b4ee3015e5d 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/>. */ | |||
| 72 | #define file_tell ftell | 72 | #define file_tell ftell |
| 73 | #endif | 73 | #endif |
| 74 | 74 | ||
| 75 | #ifndef HAVE_GETC_UNLOCKED | ||
| 76 | #define getc_unlocked getc | ||
| 77 | #endif | ||
| 78 | |||
| 75 | /* The association list of objects read with the #n=object form. | 79 | /* The association list of objects read with the #n=object form. |
| 76 | Each member of the list has the form (n . object), and is used to | 80 | Each member of the list has the form (n . object), and is used to |
| 77 | look up the object for the corresponding #n# construct. | 81 | look up the object for the corresponding #n# construct. |
| @@ -445,7 +449,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun) | |||
| 445 | } | 449 | } |
| 446 | 450 | ||
| 447 | block_input (); | 451 | block_input (); |
| 448 | c = getc (instream); | 452 | c = getc_unlocked (instream); |
| 449 | 453 | ||
| 450 | /* Interrupted reads have been observed while reading over the network. */ | 454 | /* Interrupted reads have been observed while reading over the network. */ |
| 451 | while (c == EOF && ferror (instream) && errno == EINTR) | 455 | while (c == EOF && ferror (instream) && errno == EINTR) |
| @@ -454,7 +458,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun) | |||
| 454 | maybe_quit (); | 458 | maybe_quit (); |
| 455 | block_input (); | 459 | block_input (); |
| 456 | clearerr (instream); | 460 | clearerr (instream); |
| 457 | c = getc (instream); | 461 | c = getc_unlocked (instream); |
| 458 | } | 462 | } |
| 459 | 463 | ||
| 460 | unblock_input (); | 464 | unblock_input (); |
| @@ -757,7 +761,7 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, | |||
| 757 | { | 761 | { |
| 758 | register Lisp_Object val; | 762 | register Lisp_Object val; |
| 759 | block_input (); | 763 | block_input (); |
| 760 | XSETINT (val, getc (instream)); | 764 | XSETINT (val, getc_unlocked (instream)); |
| 761 | unblock_input (); | 765 | unblock_input (); |
| 762 | return val; | 766 | return val; |
| 763 | } | 767 | } |
| @@ -2901,7 +2905,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2901 | /* Copy that many characters into saved_doc_string. */ | 2905 | /* Copy that many characters into saved_doc_string. */ |
| 2902 | block_input (); | 2906 | block_input (); |
| 2903 | for (i = 0; i < nskip && c >= 0; i++) | 2907 | for (i = 0; i < nskip && c >= 0; i++) |
| 2904 | saved_doc_string[i] = c = getc (instream); | 2908 | saved_doc_string[i] = c = getc_unlocked (instream); |
| 2905 | unblock_input (); | 2909 | unblock_input (); |
| 2906 | 2910 | ||
| 2907 | saved_doc_string_length = i; | 2911 | saved_doc_string_length = i; |