aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2012-11-29 21:25:35 +0100
committerJoakim Verona2012-11-29 21:25:35 +0100
commit85157ae08526617681dc711f885a9ddc3078cfbf (patch)
tree8af0474402734784c39f035cfdb1b93b29fad337 /src
parente1abb9a1e78c6e3a55f39e041b9b8d4998b6ff54 (diff)
parent83e12fe07c18a6190c6c5ef6e959697eb0ac9f19 (diff)
downloademacs-85157ae08526617681dc711f885a9ddc3078cfbf.tar.gz
emacs-85157ae08526617681dc711f885a9ddc3078cfbf.zip
auto upstream
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog64
-rw-r--r--src/callproc.c89
-rw-r--r--src/dired.c46
-rw-r--r--src/dispextern.h12
-rw-r--r--src/fileio.c4
-rw-r--r--src/font.c15
-rw-r--r--src/fontset.c2
-rw-r--r--src/gmalloc.c8
-rw-r--r--src/gnutls.c14
-rw-r--r--src/keyboard.c5
-rw-r--r--src/lread.c2
-rw-r--r--src/process.c13
-rw-r--r--src/unexcoff.c6
-rw-r--r--src/xdisp.c81
14 files changed, 204 insertions, 157 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c612c4dd365..b19ecc926d0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,67 @@
12012-11-29 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * xdisp.c (window_outdated): Remove eassert since it hits
4 some suspicious corner cases (see Bug#13007 and Bug#13012).
5 (mode_line_update_needed): New function.
6 (redisplay_internal, redisplay_window): Use it.
7 (ensure_selected_frame): New function.
8 (redisplay_internal, unwind_redisplay): Use it.
9 (redisplay_internal): Move comment about buffer_shared...
10 (buffer_shared_and_changed): ...near to its real use.
11
122012-11-29 Paul Eggert <eggert@cs.ucla.edu>
13
14 * callproc.c (Fcall_process): Don't misreport vfork failure.
15
162012-11-28 Paul Eggert <eggert@cs.ucla.edu>
17
18 * callproc.c (Fcall_process): Fix vfork portability problems.
19 Do not assume that fd[0], count, filefd, and save_environ survive
20 vfork. Fix bug whereby wrong errno value could be reported for
21 pipe failure. Some minor cleanups, too, as follows. Move buf and
22 bufsize to the context where they're needed. Change new_argv to
23 be of type char **, as this is more convenient and avoids casts.
24 (CALLPROC_BUFFER_SIZE_MIN, CALLPROC_BUFFER_SIZE_MAX):
25 Now local constants, not macros.
26
272012-11-18 Kenichi Handa <handa@gnu.org>
28
29 * font.c (font_unparse_xlfd): Fix previous change. Keep "const"
30 for the variable "f".
31
322012-11-13 Kenichi Handa <handa@gnu.org>
33
34 * font.c (font_unparse_xlfd): Exclude special characters from the
35 generating XLFD name.
36
372012-11-27 Paul Eggert <eggert@cs.ucla.edu>
38
39 Assume POSIX 1003.1-1988 or later for grp.h, pwd.h.
40 * dired.c (stat_uname, stat_gname):
41 * fileio.c (Fexpand_file_name): Remove no-longer-needed casts.
42
43 Assume POSIX 1003.1-1988 or later for errno.h (Bug#12968).
44 * dired.c (directory_files_internal, file_name_completion):
45 Assume EAGAIN and EINTR are defined.
46
47 * fileio.c (Fcopy_file): Assume EISDIR is defined.
48 * gmalloc.c (ENOMEM, EINVAL): Assume they're defined.
49 * gnutls.c (emacs_gnutls_write): Assume EAGAIN is defined.
50 * lread.c (readbyte_from_file): Assume EINTR is defined.
51 * process.c (wait_reading_process_output, send_process) [subprocesses]:
52 Assume EIO and EAGAIN are defined.
53 * unexcoff.c (write_segment): Assume EFAULT is defined.
54
552012-11-27 Eli Zaretskii <eliz@gnu.org>
56
57 * fontset.c (Finternal_char_font): Return nil on non-GUI frames.
58 (Bug#11964)
59
60 * xdisp.c (draw_glyphs): Don't draw in mouse face if mouse
61 highlighting on the frame was cleared. Prevents assertion
62 violations when repeatedly clicking on the "Top" link of the
63 "bread-crumbs" in Info buffers.
64
12012-11-25 Paul Eggert <eggert@cs.ucla.edu> 652012-11-25 Paul Eggert <eggert@cs.ucla.edu>
2 66
3 * sysdep.c (sys_subshell): Don't assume pid_t fits in int. 67 * sysdep.c (sys_subshell): Don't assume pid_t fits in int.
diff --git a/src/callproc.c b/src/callproc.c
index c9a504746b3..167663a45c6 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -183,16 +183,11 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
183{ 183{
184 Lisp_Object infile, buffer, current_dir, path, cleanup_info_tail; 184 Lisp_Object infile, buffer, current_dir, path, cleanup_info_tail;
185 bool display_p; 185 bool display_p;
186 int fd[2]; 186 int fd0, fd1, filefd;
187 int filefd;
188#define CALLPROC_BUFFER_SIZE_MIN (16 * 1024)
189#define CALLPROC_BUFFER_SIZE_MAX (4 * CALLPROC_BUFFER_SIZE_MIN)
190 char buf[CALLPROC_BUFFER_SIZE_MAX];
191 int bufsize = CALLPROC_BUFFER_SIZE_MIN;
192 ptrdiff_t count = SPECPDL_INDEX (); 187 ptrdiff_t count = SPECPDL_INDEX ();
193 USE_SAFE_ALLOCA; 188 USE_SAFE_ALLOCA;
194 189
195 register const unsigned char **new_argv; 190 char **new_argv;
196 /* File to use for stderr in the child. 191 /* File to use for stderr in the child.
197 t means use same as standard output. */ 192 t means use same as standard output. */
198 Lisp_Object error_file; 193 Lisp_Object error_file;
@@ -204,6 +199,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
204#else 199#else
205 pid_t pid; 200 pid_t pid;
206#endif 201#endif
202 int vfork_errno;
207 int fd_output = -1; 203 int fd_output = -1;
208 struct coding_system process_coding; /* coding-system of process output */ 204 struct coding_system process_coding; /* coding-system of process output */
209 struct coding_system argument_coding; /* coding-system of arguments */ 205 struct coding_system argument_coding; /* coding-system of arguments */
@@ -432,12 +428,12 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
432 } 428 }
433 UNGCPRO; 429 UNGCPRO;
434 for (i = 4; i < nargs; i++) 430 for (i = 4; i < nargs; i++)
435 new_argv[i - 3] = SDATA (args[i]); 431 new_argv[i - 3] = SSDATA (args[i]);
436 new_argv[i - 3] = 0; 432 new_argv[i - 3] = 0;
437 } 433 }
438 else 434 else
439 new_argv[1] = 0; 435 new_argv[1] = 0;
440 new_argv[0] = SDATA (path); 436 new_argv[0] = SSDATA (path);
441 437
442#ifdef MSDOS /* MW, July 1993 */ 438#ifdef MSDOS /* MW, July 1993 */
443 439
@@ -466,29 +462,35 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
466 } 462 }
467 else 463 else
468 outfilefd = fd_output; 464 outfilefd = fd_output;
469 fd[0] = filefd; 465 fd0 = filefd;
470 fd[1] = outfilefd; 466 fd1 = outfilefd;
471#endif /* MSDOS */ 467#endif /* MSDOS */
472 468
473 if (INTEGERP (buffer)) 469 if (INTEGERP (buffer))
474 fd[1] = emacs_open (NULL_DEVICE, O_WRONLY, 0), fd[0] = -1; 470 {
471 fd0 = -1;
472 fd1 = emacs_open (NULL_DEVICE, O_WRONLY, 0);
473 }
475 else 474 else
476 { 475 {
477#ifndef MSDOS 476#ifndef MSDOS
478 errno = 0; 477 int fd[2];
479 if (pipe (fd) == -1) 478 if (pipe (fd) == -1)
480 { 479 {
480 int pipe_errno = errno;
481 emacs_close (filefd); 481 emacs_close (filefd);
482 errno = pipe_errno;
482 report_file_error ("Creating process pipe", Qnil); 483 report_file_error ("Creating process pipe", Qnil);
483 } 484 }
485 fd0 = fd[0];
486 fd1 = fd[1];
484#endif 487#endif
485 } 488 }
486 489
487 { 490 {
488 /* child_setup must clobber environ in systems with true vfork. 491 /* child_setup must clobber environ in systems with true vfork.
489 Protect it from permanent change. */ 492 Protect it from permanent change. */
490 register char **save_environ = environ; 493 char **save_environ = environ;
491 register int fd1 = fd[1];
492 int fd_error = fd1; 494 int fd_error = fd1;
493 495
494 if (fd_output >= 0) 496 if (fd_output >= 0)
@@ -520,8 +522,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
520 if (fd_error < 0) 522 if (fd_error < 0)
521 { 523 {
522 emacs_close (filefd); 524 emacs_close (filefd);
523 if (fd[0] != filefd) 525 if (fd0 != filefd)
524 emacs_close (fd[0]); 526 emacs_close (fd0);
525 if (fd1 >= 0) 527 if (fd1 >= 0)
526 emacs_close (fd1); 528 emacs_close (fd1);
527#ifdef MSDOS 529#ifdef MSDOS
@@ -538,8 +540,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
538 /* Note that on MSDOS `child_setup' actually returns the child process 540 /* Note that on MSDOS `child_setup' actually returns the child process
539 exit status, not its PID, so we assign it to `synch_process_retcode' 541 exit status, not its PID, so we assign it to `synch_process_retcode'
540 below. */ 542 below. */
541 pid = child_setup (filefd, outfilefd, fd_error, (char **) new_argv, 543 pid = child_setup (filefd, outfilefd, fd_error, new_argv, 0, current_dir);
542 0, current_dir);
543 544
544 /* Record that the synchronous process exited and note its 545 /* Record that the synchronous process exited and note its
545 termination status. */ 546 termination status. */
@@ -559,8 +560,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
559 { 560 {
560 /* Since CRLF is converted to LF within `decode_coding', we 561 /* Since CRLF is converted to LF within `decode_coding', we
561 can always open a file with binary mode. */ 562 can always open a file with binary mode. */
562 fd[0] = emacs_open (tempfile, O_RDONLY | O_BINARY, 0); 563 fd0 = emacs_open (tempfile, O_RDONLY | O_BINARY, 0);
563 if (fd[0] < 0) 564 if (fd0 < 0)
564 { 565 {
565 unlink (tempfile); 566 unlink (tempfile);
566 emacs_close (filefd); 567 emacs_close (filefd);
@@ -569,11 +570,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
569 } 570 }
570 } 571 }
571 else 572 else
572 fd[0] = -1; /* We are not going to read from tempfile. */ 573 fd0 = -1; /* We are not going to read from tempfile. */
573#else /* not MSDOS */ 574#else /* not MSDOS */
574#ifdef WINDOWSNT 575#ifdef WINDOWSNT
575 pid = child_setup (filefd, fd1, fd_error, (char **) new_argv, 576 pid = child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir);
576 0, current_dir);
577#else /* not WINDOWSNT */ 577#else /* not WINDOWSNT */
578 578
579 block_input (); 579 block_input ();
@@ -586,11 +586,15 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
586 bool volatile display_p_volatile = display_p; 586 bool volatile display_p_volatile = display_p;
587 bool volatile output_to_buffer_volatile = output_to_buffer; 587 bool volatile output_to_buffer_volatile = output_to_buffer;
588 bool volatile sa_must_free_volatile = sa_must_free; 588 bool volatile sa_must_free_volatile = sa_must_free;
589 int volatile fd0_volatile = fd0;
589 int volatile fd1_volatile = fd1; 590 int volatile fd1_volatile = fd1;
590 int volatile fd_error_volatile = fd_error; 591 int volatile fd_error_volatile = fd_error;
591 int volatile fd_output_volatile = fd_output; 592 int volatile fd_output_volatile = fd_output;
593 int volatile filefd_volatile = filefd;
594 ptrdiff_t volatile count_volatile = count;
592 ptrdiff_t volatile sa_count_volatile = sa_count; 595 ptrdiff_t volatile sa_count_volatile = sa_count;
593 unsigned char const **volatile new_argv_volatile = new_argv; 596 char **volatile new_argv_volatile = new_argv;
597 char **volatile new_save_environ = save_environ;
594 598
595 pid = vfork (); 599 pid = vfork ();
596 600
@@ -598,29 +602,33 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
598 coding_systems = coding_systems_volatile; 602 coding_systems = coding_systems_volatile;
599 current_dir = current_dir_volatile; 603 current_dir = current_dir_volatile;
600 display_p = display_p_volatile; 604 display_p = display_p_volatile;
605 output_to_buffer = output_to_buffer_volatile;
606 sa_must_free = sa_must_free_volatile;
607 fd0 = fd0_volatile;
601 fd1 = fd1_volatile; 608 fd1 = fd1_volatile;
602 fd_error = fd_error_volatile; 609 fd_error = fd_error_volatile;
603 fd_output = fd_output_volatile; 610 fd_output = fd_output_volatile;
604 output_to_buffer = output_to_buffer_volatile; 611 filefd = filefd_volatile;
605 sa_must_free = sa_must_free_volatile; 612 count = count_volatile;
606 sa_count = sa_count_volatile; 613 sa_count = sa_count_volatile;
607 new_argv = new_argv_volatile; 614 new_argv = new_argv_volatile;
615 save_environ = new_save_environ;
608 } 616 }
609 617
610 if (pid == 0) 618 if (pid == 0)
611 { 619 {
612 if (fd[0] >= 0) 620 if (fd0 >= 0)
613 emacs_close (fd[0]); 621 emacs_close (fd0);
614 622
615 setsid (); 623 setsid ();
616 624
617 /* Emacs ignores SIGPIPE, but the child should not. */ 625 /* Emacs ignores SIGPIPE, but the child should not. */
618 signal (SIGPIPE, SIG_DFL); 626 signal (SIGPIPE, SIG_DFL);
619 627
620 child_setup (filefd, fd1, fd_error, (char **) new_argv, 628 child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir);
621 0, current_dir);
622 } 629 }
623 630
631 vfork_errno = errno;
624 unblock_input (); 632 unblock_input ();
625 633
626#endif /* not WINDOWSNT */ 634#endif /* not WINDOWSNT */
@@ -632,7 +640,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
632 640
633 environ = save_environ; 641 environ = save_environ;
634 642
635 /* Close most of our fd's, but not fd[0] 643 /* Close most of our file descriptors, but not fd0
636 since we will use that to read input from. */ 644 since we will use that to read input from. */
637 emacs_close (filefd); 645 emacs_close (filefd);
638 if (fd_output >= 0) 646 if (fd_output >= 0)
@@ -643,15 +651,16 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
643 651
644 if (pid < 0) 652 if (pid < 0)
645 { 653 {
646 if (fd[0] >= 0) 654 if (fd0 >= 0)
647 emacs_close (fd[0]); 655 emacs_close (fd0);
656 errno = vfork_errno;
648 report_file_error ("Doing vfork", Qnil); 657 report_file_error ("Doing vfork", Qnil);
649 } 658 }
650 659
651 if (INTEGERP (buffer)) 660 if (INTEGERP (buffer))
652 { 661 {
653 if (fd[0] >= 0) 662 if (fd0 >= 0)
654 emacs_close (fd[0]); 663 emacs_close (fd0);
655 return Qnil; 664 return Qnil;
656 } 665 }
657 666
@@ -666,7 +675,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
666#endif /* not MSDOS */ 675#endif /* not MSDOS */
667 record_unwind_protect (call_process_cleanup, 676 record_unwind_protect (call_process_cleanup,
668 Fcons (Fcurrent_buffer (), 677 Fcons (Fcurrent_buffer (),
669 Fcons (INTEGER_TO_CONS (fd[0]), 678 Fcons (INTEGER_TO_CONS (fd0),
670 cleanup_info_tail))); 679 cleanup_info_tail)));
671 680
672 if (BUFFERP (buffer)) 681 if (BUFFERP (buffer))
@@ -723,6 +732,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
723 732
724 if (output_to_buffer) 733 if (output_to_buffer)
725 { 734 {
735 enum { CALLPROC_BUFFER_SIZE_MIN = 16 * 1024 };
736 enum { CALLPROC_BUFFER_SIZE_MAX = 4 * CALLPROC_BUFFER_SIZE_MIN };
737 char buf[CALLPROC_BUFFER_SIZE_MAX];
738 int bufsize = CALLPROC_BUFFER_SIZE_MIN;
726 int nread; 739 int nread;
727 bool first = 1; 740 bool first = 1;
728 EMACS_INT total_read = 0; 741 EMACS_INT total_read = 0;
@@ -739,7 +752,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
739 nread = carryover; 752 nread = carryover;
740 while (nread < bufsize - 1024) 753 while (nread < bufsize - 1024)
741 { 754 {
742 int this_read = emacs_read (fd[0], buf + nread, 755 int this_read = emacs_read (fd0, buf + nread,
743 bufsize - nread); 756 bufsize - nread);
744 757
745 if (this_read < 0) 758 if (this_read < 0)
diff --git a/src/dired.c b/src/dired.c
index 3530b74ecb4..bdb71c46364 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -193,19 +193,15 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
193 193
194 errno = 0; 194 errno = 0;
195 dp = readdir (d); 195 dp = readdir (d);
196 196 if (!dp)
197 if (dp == NULL && (0 197 {
198#ifdef EAGAIN 198 if (errno == EAGAIN || errno == EINTR)
199 || errno == EAGAIN 199 {
200#endif 200 QUIT;
201#ifdef EINTR 201 continue;
202 || errno == EINTR 202 }
203#endif 203 break;
204 )) 204 }
205 { QUIT; continue; }
206
207 if (dp == NULL)
208 break;
209 205
210 len = dirent_namelen (dp); 206 len = dirent_namelen (dp);
211 name = finalname = make_unibyte_string (dp->d_name, len); 207 name = finalname = make_unibyte_string (dp->d_name, len);
@@ -480,17 +476,15 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
480 476
481 errno = 0; 477 errno = 0;
482 dp = readdir (d); 478 dp = readdir (d);
483 if (dp == NULL && (0 479 if (!dp)
484# ifdef EAGAIN 480 {
485 || errno == EAGAIN 481 if (errno == EAGAIN || errno == EINTR)
486# endif 482 {
487# ifdef EINTR 483 QUIT;
488 || errno == EINTR 484 continue;
489# endif 485 }
490 )) 486 break;
491 { QUIT; continue; } 487 }
492
493 if (!dp) break;
494 488
495 len = dirent_namelen (dp); 489 len = dirent_namelen (dp);
496 490
@@ -826,7 +820,7 @@ stat_uname (struct stat *st)
826#ifdef WINDOWSNT 820#ifdef WINDOWSNT
827 return st->st_uname; 821 return st->st_uname;
828#else 822#else
829 struct passwd *pw = (struct passwd *) getpwuid (st->st_uid); 823 struct passwd *pw = getpwuid (st->st_uid);
830 824
831 if (pw) 825 if (pw)
832 return pw->pw_name; 826 return pw->pw_name;
@@ -841,7 +835,7 @@ stat_gname (struct stat *st)
841#ifdef WINDOWSNT 835#ifdef WINDOWSNT
842 return st->st_gname; 836 return st->st_gname;
843#else 837#else
844 struct group *gr = (struct group *) getgrgid (st->st_gid); 838 struct group *gr = getgrgid (st->st_gid);
845 839
846 if (gr) 840 if (gr)
847 return gr->gr_name; 841 return gr->gr_name;
diff --git a/src/dispextern.h b/src/dispextern.h
index 22fcee331c5..55fd852ea3b 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1582,12 +1582,12 @@ struct face
1582 /* Pixmap width and height. */ 1582 /* Pixmap width and height. */
1583 unsigned int pixmap_w, pixmap_h; 1583 unsigned int pixmap_w, pixmap_h;
1584 1584
1585 /* Non-zero means characters in this face have a box that thickness 1585 /* Non-zero means characters in this face have a box of that
1586 around them. If it is negative, the absolute value indicates the 1586 thickness around them. If this value is negative, its absolute
1587 thickness, and the horizontal lines of box (top and bottom) are 1587 value indicates the thickness, and the horizontal (top and
1588 drawn inside of characters glyph area. The vertical lines of box 1588 bottom) borders of box are drawn inside of the character glyphs'
1589 (left and right) are drawn as the same way as the case that this 1589 area. The vertical (left and right) borders of the box are drawn
1590 value is positive. */ 1590 in the same way as when this value is positive. */
1591 int box_line_width; 1591 int box_line_width;
1592 1592
1593 /* Type of box drawn. A value of FACE_NO_BOX means no box is drawn 1593 /* Type of box drawn. A value of FACE_NO_BOX means no box is drawn
diff --git a/src/fileio.c b/src/fileio.c
index 442c66550d3..48dbf20b88f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1042,7 +1042,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1042 o [p - nm] = 0; 1042 o [p - nm] = 0;
1043 1043
1044 block_input (); 1044 block_input ();
1045 pw = (struct passwd *) getpwnam (o + 1); 1045 pw = getpwnam (o + 1);
1046 unblock_input (); 1046 unblock_input ();
1047 if (pw) 1047 if (pw)
1048 { 1048 {
@@ -1995,10 +1995,8 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1995 { 1995 {
1996 if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode))) 1996 if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode)))
1997 { 1997 {
1998#if defined (EISDIR)
1999 /* Get a better looking error message. */ 1998 /* Get a better looking error message. */
2000 errno = EISDIR; 1999 errno = EISDIR;
2001#endif /* EISDIR */
2002 report_file_error ("Non-regular file", Fcons (file, Qnil)); 2000 report_file_error ("Non-regular file", Fcons (file, Qnil));
2003 } 2001 }
2004 } 2002 }
diff --git a/src/font.c b/src/font.c
index 41dbfd7a757..f6b6fa026c0 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1234,8 +1234,21 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
1234 f[j] = "*"; 1234 f[j] = "*";
1235 else 1235 else
1236 { 1236 {
1237 int c, k, l;
1238 ptrdiff_t alloc;
1239
1237 val = SYMBOL_NAME (val); 1240 val = SYMBOL_NAME (val);
1238 f[j] = SSDATA (val); 1241 alloc = SBYTES (val) + 1;
1242 if (nbytes <= alloc)
1243 return -1;
1244 f[j] = p = alloca (alloc);
1245 /* Copy the name while excluding '-', '?', ',', and '"'. */
1246 for (k = l = 0; k < alloc; k++)
1247 {
1248 c = SREF (val, k);
1249 if (c != '-' && c != '?' && c != ',' && c != '"')
1250 p[l++] = c;
1251 }
1239 } 1252 }
1240 } 1253 }
1241 1254
diff --git a/src/fontset.c b/src/fontset.c
index b76a216bac2..660ca432fad 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1876,6 +1876,8 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
1876 } 1876 }
1877 if (! CHAR_VALID_P (c)) 1877 if (! CHAR_VALID_P (c))
1878 return Qnil; 1878 return Qnil;
1879 if (!FRAME_WINDOW_P (f))
1880 return Qnil;
1879 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil); 1881 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
1880 face = FACE_FROM_ID (f, face_id); 1882 face = FACE_FROM_ID (f, face_id);
1881 if (face->font) 1883 if (face->font)
diff --git a/src/gmalloc.c b/src/gmalloc.c
index dc584955661..c325ca79910 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -1645,14 +1645,6 @@ memalign (size_t alignment, size_t size)
1645 return result; 1645 return result;
1646} 1646}
1647 1647
1648#ifndef ENOMEM
1649#define ENOMEM 12
1650#endif
1651
1652#ifndef EINVAL
1653#define EINVAL 22
1654#endif
1655
1656int 1648int
1657posix_memalign (void **memptr, size_t alignment, size_t size) 1649posix_memalign (void **memptr, size_t alignment, size_t size)
1658{ 1650{
diff --git a/src/gnutls.c b/src/gnutls.c
index e3d84a0b61b..03f753fa8cc 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -359,12 +359,7 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte)
359 359
360 if (proc->gnutls_initstage != GNUTLS_STAGE_READY) 360 if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
361 { 361 {
362#ifdef EWOULDBLOCK
363 errno = EWOULDBLOCK;
364#endif
365#ifdef EAGAIN
366 errno = EAGAIN; 362 errno = EAGAIN;
367#endif
368 return 0; 363 return 0;
369 } 364 }
370 365
@@ -384,14 +379,7 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte)
384 appropriately so that send_process retries the 379 appropriately so that send_process retries the
385 correct way instead of erroring out. */ 380 correct way instead of erroring out. */
386 if (rtnval == GNUTLS_E_AGAIN) 381 if (rtnval == GNUTLS_E_AGAIN)
387 { 382 errno = EAGAIN;
388#ifdef EWOULDBLOCK
389 errno = EWOULDBLOCK;
390#endif
391#ifdef EAGAIN
392 errno = EAGAIN;
393#endif
394 }
395 break; 383 break;
396 } 384 }
397 } 385 }
diff --git a/src/keyboard.c b/src/keyboard.c
index 5980ae89522..30b4db5e077 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6976,10 +6976,7 @@ tty_read_avail_input (struct terminal *terminal,
6976 an EAGAIN error. Does anybody know of a situation 6976 an EAGAIN error. Does anybody know of a situation
6977 where a retry is actually needed? */ 6977 where a retry is actually needed? */
6978#if 0 6978#if 0
6979 nread < 0 && (errno == EAGAIN 6979 nread < 0 && (errno == EAGAIN || errno == EFAULT
6980#ifdef EFAULT
6981 || errno == EFAULT
6982#endif
6983#ifdef EBADSLT 6980#ifdef EBADSLT
6984 || errno == EBADSLT 6981 || errno == EBADSLT
6985#endif 6982#endif
diff --git a/src/lread.c b/src/lread.c
index 6d0ff9f780e..6647382a254 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -440,7 +440,6 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
440 block_input (); 440 block_input ();
441 c = getc (instream); 441 c = getc (instream);
442 442
443#ifdef EINTR
444 /* Interrupted reads have been observed while reading over the network. */ 443 /* Interrupted reads have been observed while reading over the network. */
445 while (c == EOF && ferror (instream) && errno == EINTR) 444 while (c == EOF && ferror (instream) && errno == EINTR)
446 { 445 {
@@ -450,7 +449,6 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
450 clearerr (instream); 449 clearerr (instream);
451 c = getc (instream); 450 c = getc (instream);
452 } 451 }
453#endif
454 452
455 unblock_input (); 453 unblock_input ();
456 454
diff --git a/src/process.c b/src/process.c
index 0036ce595f5..b23f06fd025 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4432,14 +4432,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4432 total_nread += nread; 4432 total_nread += nread;
4433 got_some_input = 1; 4433 got_some_input = 1;
4434 } 4434 }
4435#ifdef EIO 4435 else if (nread == -1 && (errno == EIO || errno == EAGAIN))
4436 else if (nread == -1 && EIO == errno)
4437 break; 4436 break;
4438#endif
4439#ifdef EAGAIN
4440 else if (nread == -1 && EAGAIN == errno)
4441 break;
4442#endif
4443#ifdef EWOULDBLOCK 4437#ifdef EWOULDBLOCK
4444 else if (nread == -1 && EWOULDBLOCK == errno) 4438 else if (nread == -1 && EWOULDBLOCK == errno)
4445 break; 4439 break;
@@ -5517,13 +5511,10 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5517 5511
5518 if (rv < 0) 5512 if (rv < 0)
5519 { 5513 {
5520 if (0 5514 if (errno == EAGAIN
5521#ifdef EWOULDBLOCK 5515#ifdef EWOULDBLOCK
5522 || errno == EWOULDBLOCK 5516 || errno == EWOULDBLOCK
5523#endif 5517#endif
5524#ifdef EAGAIN
5525 || errno == EAGAIN
5526#endif
5527 ) 5518 )
5528 /* Buffer is full. Wait, accepting input; 5519 /* Buffer is full. Wait, accepting input;
5529 that may allow the program 5520 that may allow the program
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 966dd58cb6e..6e29951a962 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -332,11 +332,7 @@ write_segment (int new, const char *ptr, const char *end)
332 a gap between the old text segment and the old data segment. 332 a gap between the old text segment and the old data segment.
333 This gap has probably been remapped into part of the text segment. 333 This gap has probably been remapped into part of the text segment.
334 So write zeros for it. */ 334 So write zeros for it. */
335 if (ret == -1 335 if (ret == -1 && errno == EFAULT)
336#ifdef EFAULT
337 && errno == EFAULT
338#endif
339 )
340 { 336 {
341 /* Write only a page of zeros at once, 337 /* Write only a page of zeros at once,
342 so that we don't overshoot the start 338 so that we don't overshoot the start
diff --git a/src/xdisp.c b/src/xdisp.c
index f212c39607f..af83eba8544 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10948,16 +10948,18 @@ echo_area_display (int update_frame_p)
10948static int 10948static int
10949buffer_shared_and_changed (void) 10949buffer_shared_and_changed (void)
10950{ 10950{
10951 /* The variable buffer_shared is set in redisplay_window and
10952 indicates that we redisplay a buffer in different windows. */
10951 return (buffer_shared > 1 && UNCHANGED_MODIFIED < MODIFF); 10953 return (buffer_shared > 1 && UNCHANGED_MODIFIED < MODIFF);
10952} 10954}
10953 10955
10954/* Nonzero if W doesn't reflect the actual state of 10956/* Nonzero if W doesn't reflect the actual state of current buffer due
10955 current buffer due to its text or overlays change. */ 10957 to its text or overlays change. FIXME: this may be called when
10958 XBUFFER (w->buffer) != current_buffer, which looks suspicious. */
10956 10959
10957static int 10960static int
10958window_outdated (struct window *w) 10961window_outdated (struct window *w)
10959{ 10962{
10960 eassert (XBUFFER (w->buffer) == current_buffer);
10961 return (w->last_modified < MODIFF 10963 return (w->last_modified < MODIFF
10962 || w->last_overlay_modified < OVERLAY_MODIFF); 10964 || w->last_overlay_modified < OVERLAY_MODIFF);
10963} 10965}
@@ -10977,6 +10979,16 @@ window_buffer_changed (struct window *w)
10977 != !NILP (w->region_showing))); 10979 != !NILP (w->region_showing)));
10978} 10980}
10979 10981
10982/* Nonzero if W has %c in its mode line and mode line should be updated. */
10983
10984static int
10985mode_line_update_needed (struct window *w)
10986{
10987 return (!NILP (w->column_number_displayed)
10988 && !(PT == w->last_point && !window_outdated (w))
10989 && (XFASTINT (w->column_number_displayed) != current_column ()));
10990}
10991
10980/*********************************************************************** 10992/***********************************************************************
10981 Mode Lines and Frame Titles 10993 Mode Lines and Frame Titles
10982 ***********************************************************************/ 10994 ***********************************************************************/
@@ -13021,6 +13033,15 @@ select_frame_for_redisplay (Lisp_Object frame)
13021 } while (!EQ (frame, old) && (frame = old, 1)); 13033 } while (!EQ (frame, old) && (frame = old, 1));
13022} 13034}
13023 13035
13036/* Make sure that previously selected OLD_FRAME is selected unless it has been
13037 deleted (by an X connection failure during redisplay, for example). */
13038
13039static void
13040ensure_selected_frame (Lisp_Object old_frame)
13041{
13042 if (!EQ (old_frame, selected_frame) && FRAME_LIVE_P (XFRAME (old_frame)))
13043 select_frame_for_redisplay (old_frame);
13044}
13024 13045
13025#define STOP_POLLING \ 13046#define STOP_POLLING \
13026do { if (! polling_stopped_here) stop_polling (); \ 13047do { if (! polling_stopped_here) stop_polling (); \
@@ -13106,13 +13127,11 @@ redisplay_internal (void)
13106 /* Remember the currently selected window. */ 13127 /* Remember the currently selected window. */
13107 sw = w; 13128 sw = w;
13108 13129
13109 if (!EQ (old_frame, selected_frame) 13130 /* When running redisplay, we play a bit fast-and-loose and allow e.g.
13110 && FRAME_LIVE_P (XFRAME (old_frame))) 13131 selected_frame and selected_window to be temporarily out-of-sync so
13111 /* When running redisplay, we play a bit fast-and-loose and allow e.g. 13132 when we come back here via `goto retry', we need to resync because we
13112 selected_frame and selected_window to be temporarily out-of-sync so 13133 may need to run Elisp code (via prepare_menu_bars). */
13113 when we come back here via `goto retry', we need to resync because we 13134 ensure_selected_frame (old_frame);
13114 may need to run Elisp code (via prepare_menu_bars). */
13115 select_frame_for_redisplay (old_frame);
13116 13135
13117 pending = 0; 13136 pending = 0;
13118 reconsider_clip_changes (w, current_buffer); 13137 reconsider_clip_changes (w, current_buffer);
@@ -13198,21 +13217,13 @@ redisplay_internal (void)
13198 count1 = SPECPDL_INDEX (); 13217 count1 = SPECPDL_INDEX ();
13199 specbind (Qinhibit_point_motion_hooks, Qt); 13218 specbind (Qinhibit_point_motion_hooks, Qt);
13200 13219
13201 /* If %c is in the mode line, update it if needed. */ 13220 if (mode_line_update_needed (w))
13202 if (!NILP (w->column_number_displayed)
13203 /* This alternative quickly identifies a common case
13204 where no change is needed. */
13205 && !(PT == w->last_point && !window_outdated (w))
13206 && (XFASTINT (w->column_number_displayed) != current_column ()))
13207 w->update_mode_line = 1; 13221 w->update_mode_line = 1;
13208 13222
13209 unbind_to (count1, Qnil); 13223 unbind_to (count1, Qnil);
13210 13224
13211 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1; 13225 FRAME_SCROLL_BOTTOM_VPOS (XFRAME (w->frame)) = -1;
13212 13226
13213 /* The variable buffer_shared is set in redisplay_window and
13214 indicates that we redisplay a buffer in different windows. See
13215 there. */
13216 consider_all_windows_p = (update_mode_lines 13227 consider_all_windows_p = (update_mode_lines
13217 || buffer_shared_and_changed () 13228 || buffer_shared_and_changed ()
13218 || cursor_type_changed); 13229 || cursor_type_changed);
@@ -13594,14 +13605,11 @@ redisplay_internal (void)
13594 } 13605 }
13595 } 13606 }
13596 13607
13597 if (!EQ (old_frame, selected_frame) 13608 /* We played a bit fast-and-loose above and allowed selected_frame
13598 && FRAME_LIVE_P (XFRAME (old_frame))) 13609 and selected_window to be temporarily out-of-sync but let's make
13599 /* We played a bit fast-and-loose above and allowed selected_frame 13610 sure this stays contained. */
13600 and selected_window to be temporarily out-of-sync but let's make 13611 ensure_selected_frame (old_frame);
13601 sure this stays contained. */ 13612 eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window));
13602 select_frame_for_redisplay (old_frame);
13603 eassert (EQ (XFRAME (selected_frame)->selected_window,
13604 selected_window));
13605 13613
13606 if (!pending) 13614 if (!pending)
13607 { 13615 {
@@ -13820,17 +13828,13 @@ redisplay_preserve_echo_area (int from_where)
13820 13828
13821 13829
13822/* Function registered with record_unwind_protect in redisplay_internal. 13830/* Function registered with record_unwind_protect in redisplay_internal.
13823 Clear redisplaying_p. Also, select the previously 13831 Clear redisplaying_p. Also select the previously selected frame. */
13824 selected frame, unless it has been deleted (by an X connection
13825 failure during redisplay, for example). */
13826 13832
13827static Lisp_Object 13833static Lisp_Object
13828unwind_redisplay (Lisp_Object old_frame) 13834unwind_redisplay (Lisp_Object old_frame)
13829{ 13835{
13830 redisplaying_p = 0; 13836 redisplaying_p = 0;
13831 if (! EQ (old_frame, selected_frame) 13837 ensure_selected_frame (old_frame);
13832 && FRAME_LIVE_P (XFRAME (old_frame)))
13833 select_frame_for_redisplay (old_frame);
13834 return Qnil; 13838 return Qnil;
13835} 13839}
13836 13840
@@ -15626,12 +15630,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15626 if (BYTEPOS (opoint) < CHARPOS (opoint)) 15630 if (BYTEPOS (opoint) < CHARPOS (opoint))
15627 emacs_abort (); 15631 emacs_abort ();
15628 15632
15629 /* If %c is in mode line, update it if needed. */ 15633 if (mode_line_update_needed (w))
15630 if (!NILP (w->column_number_displayed)
15631 /* This alternative quickly identifies a common case
15632 where no change is needed. */
15633 && !(PT == w->last_point && !window_outdated (w))
15634 && (XFASTINT (w->column_number_displayed) != current_column ()))
15635 update_mode_line = 1; 15634 update_mode_line = 1;
15636 15635
15637 /* Count number of windows showing the selected buffer. An indirect 15636 /* Count number of windows showing the selected buffer. An indirect
@@ -23665,7 +23664,9 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
23665 23664
23666 /* If mouse highlighting is on, we may need to draw adjacent 23665 /* If mouse highlighting is on, we may need to draw adjacent
23667 glyphs using mouse-face highlighting. */ 23666 glyphs using mouse-face highlighting. */
23668 if (area == TEXT_AREA && row->mouse_face_p) 23667 if (area == TEXT_AREA && row->mouse_face_p
23668 && hlinfo->mouse_face_beg_row >= 0
23669 && hlinfo->mouse_face_end_row >= 0)
23669 { 23670 {
23670 struct glyph_row *mouse_beg_row, *mouse_end_row; 23671 struct glyph_row *mouse_beg_row, *mouse_end_row;
23671 23672