diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 19 | ||||
| -rw-r--r-- | src/callproc.c | 13 | ||||
| -rw-r--r-- | src/fileio.c | 22 | ||||
| -rw-r--r-- | src/frame.c | 162 |
4 files changed, 110 insertions, 106 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a6ba03a0069..d9e566eae69 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2012-12-06 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Avoid code duplication between prev_frame and next_frame. | ||
| 4 | * frame.c (candidate_frame): New function. Add comment. | ||
| 5 | (prev_frame, next_frame): Use it. Adjust comment. | ||
| 6 | |||
| 7 | 2012-12-06 Eli Zaretskii <eliz@gnu.org> | ||
| 8 | |||
| 9 | * callproc.c (Fcall_process_region) [!HAVE_MKSTEMP]: If mktemp | ||
| 10 | fails, signal an error instead of continuing with an empty | ||
| 11 | string. (Bug#13079) | ||
| 12 | Encode expanded temp file pattern before passing it to mkstemp or | ||
| 13 | mktemp. | ||
| 14 | |||
| 15 | * fileio.c (file_name_as_directory, directory_file_name) [DOS_NT]: | ||
| 16 | Encode the file name before passing it to dostounix_filename, in | ||
| 17 | case it will downcase it (under w32-downcase-file-names). | ||
| 18 | (Bug#12933) | ||
| 19 | |||
| 1 | 2012-12-05 Paul Eggert <eggert@cs.ucla.edu> | 20 | 2012-12-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 21 | ||
| 3 | Minor call-process cleanups. | 22 | Minor call-process cleanups. |
diff --git a/src/callproc.c b/src/callproc.c index 2c3d31ba052..6153bc1b6c6 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -977,8 +977,9 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 977 | { | 977 | { |
| 978 | USE_SAFE_ALLOCA; | 978 | USE_SAFE_ALLOCA; |
| 979 | Lisp_Object pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); | 979 | Lisp_Object pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); |
| 980 | char *tempfile = SAFE_ALLOCA (SBYTES (pattern) + 1); | 980 | Lisp_Object encoded_tem = ENCODE_FILE (pattern); |
| 981 | memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1); | 981 | char *tempfile = SAFE_ALLOCA (SBYTES (encoded_tem) + 1); |
| 982 | memcpy (tempfile, SDATA (encoded_tem), SBYTES (encoded_tem) + 1); | ||
| 982 | coding_systems = Qt; | 983 | coding_systems = Qt; |
| 983 | 984 | ||
| 984 | #ifdef HAVE_MKSTEMP | 985 | #ifdef HAVE_MKSTEMP |
| @@ -995,7 +996,15 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 995 | close (fd); | 996 | close (fd); |
| 996 | } | 997 | } |
| 997 | #else | 998 | #else |
| 999 | errno = 0; | ||
| 998 | mktemp (tempfile); | 1000 | mktemp (tempfile); |
| 1001 | if (!*tempfile) | ||
| 1002 | { | ||
| 1003 | if (!errno) | ||
| 1004 | errno = EEXIST; | ||
| 1005 | report_file_error ("Failed to open temporary file using pattern", | ||
| 1006 | Fcons (pattern, Qnil)); | ||
| 1007 | } | ||
| 999 | #endif | 1008 | #endif |
| 1000 | 1009 | ||
| 1001 | filename_string = build_string (tempfile); | 1010 | filename_string = build_string (tempfile); |
diff --git a/src/fileio.c b/src/fileio.c index 9edd88ca64f..de3b84ba95d 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -455,7 +455,7 @@ get a current directory to run processes in. */) | |||
| 455 | 455 | ||
| 456 | /* Convert from file name SRC of length SRCLEN to directory name | 456 | /* Convert from file name SRC of length SRCLEN to directory name |
| 457 | in DST. On UNIX, just make sure there is a terminating /. | 457 | in DST. On UNIX, just make sure there is a terminating /. |
| 458 | Return the length of DST. */ | 458 | Return the length of DST in bytes. */ |
| 459 | 459 | ||
| 460 | static ptrdiff_t | 460 | static ptrdiff_t |
| 461 | file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen) | 461 | file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen) |
| @@ -477,7 +477,14 @@ file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen) | |||
| 477 | srclen++; | 477 | srclen++; |
| 478 | } | 478 | } |
| 479 | #ifdef DOS_NT | 479 | #ifdef DOS_NT |
| 480 | dostounix_filename (dst); | 480 | { |
| 481 | Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1); | ||
| 482 | |||
| 483 | tem_fn = ENCODE_FILE (tem_fn); | ||
| 484 | dostounix_filename (SSDATA (tem_fn)); | ||
| 485 | tem_fn = DECODE_FILE (tem_fn); | ||
| 486 | memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1); | ||
| 487 | } | ||
| 481 | #endif | 488 | #endif |
| 482 | return srclen; | 489 | return srclen; |
| 483 | } | 490 | } |
| @@ -519,7 +526,7 @@ For a Unix-syntax file name, just appends a slash. */) | |||
| 519 | 526 | ||
| 520 | /* Convert from directory name SRC of length SRCLEN to | 527 | /* Convert from directory name SRC of length SRCLEN to |
| 521 | file name in DST. On UNIX, just make sure there isn't | 528 | file name in DST. On UNIX, just make sure there isn't |
| 522 | a terminating /. Return the length of DST. */ | 529 | a terminating /. Return the length of DST in bytes. */ |
| 523 | 530 | ||
| 524 | static ptrdiff_t | 531 | static ptrdiff_t |
| 525 | directory_file_name (char *dst, char *src, ptrdiff_t srclen) | 532 | directory_file_name (char *dst, char *src, ptrdiff_t srclen) |
| @@ -538,7 +545,14 @@ directory_file_name (char *dst, char *src, ptrdiff_t srclen) | |||
| 538 | srclen--; | 545 | srclen--; |
| 539 | } | 546 | } |
| 540 | #ifdef DOS_NT | 547 | #ifdef DOS_NT |
| 541 | dostounix_filename (dst); | 548 | { |
| 549 | Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1); | ||
| 550 | |||
| 551 | tem_fn = ENCODE_FILE (tem_fn); | ||
| 552 | dostounix_filename (SSDATA (tem_fn)); | ||
| 553 | tem_fn = DECODE_FILE (tem_fn); | ||
| 554 | memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1); | ||
| 555 | } | ||
| 542 | #endif | 556 | #endif |
| 543 | return srclen; | 557 | return srclen; |
| 544 | } | 558 | } |
diff --git a/src/frame.c b/src/frame.c index 3501fc36675..d94164e0c14 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -895,13 +895,58 @@ DEFUN ("frame-list", Fframe_list, Sframe_list, | |||
| 895 | return frames; | 895 | return frames; |
| 896 | } | 896 | } |
| 897 | 897 | ||
| 898 | /* Return the next frame in the frame list after FRAME. | 898 | /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the |
| 899 | If MINIBUF is nil, exclude minibuffer-only frames. | 899 | same tty (for tty frames) or among frames which uses FRAME's keyboard. |
| 900 | If MINIBUF is a window, include only its own frame | 900 | If MINIBUF is nil, do not consider minibuffer-only candidate. |
| 901 | and any frame now using that window as the minibuffer. | 901 | If MINIBUF is `visible', do not consider an invisible candidate. |
| 902 | If MINIBUF is `visible', include all visible frames. | 902 | If MINIBUF is a window, consider only its own frame and candidate now |
| 903 | If MINIBUF is 0, include all visible and iconified frames. | 903 | using that window as the minibuffer. |
| 904 | Otherwise, include all frames. */ | 904 | If MINIBUF is 0, consider candidate if it is visible or iconified. |
| 905 | Otherwise consider any candidate and return nil if CANDIDATE is not | ||
| 906 | acceptable. */ | ||
| 907 | |||
| 908 | static Lisp_Object | ||
| 909 | candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf) | ||
| 910 | { | ||
| 911 | struct frame *c = XFRAME (candidate), *f = XFRAME (frame); | ||
| 912 | |||
| 913 | if ((!FRAME_TERMCAP_P (c) && !FRAME_TERMCAP_P (f) | ||
| 914 | && FRAME_KBOARD (c) == FRAME_KBOARD (f)) | ||
| 915 | || (FRAME_TERMCAP_P (c) && FRAME_TERMCAP_P (f) | ||
| 916 | && FRAME_TTY (c) == FRAME_TTY (f))) | ||
| 917 | { | ||
| 918 | if (NILP (minibuf)) | ||
| 919 | { | ||
| 920 | if (!FRAME_MINIBUF_ONLY_P (c)) | ||
| 921 | return candidate; | ||
| 922 | } | ||
| 923 | else if (EQ (minibuf, Qvisible)) | ||
| 924 | { | ||
| 925 | FRAME_SAMPLE_VISIBILITY (c); | ||
| 926 | if (FRAME_VISIBLE_P (c)) | ||
| 927 | return candidate; | ||
| 928 | } | ||
| 929 | else if (WINDOWP (minibuf)) | ||
| 930 | { | ||
| 931 | if (EQ (FRAME_MINIBUF_WINDOW (c), minibuf) | ||
| 932 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), candidate) | ||
| 933 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), | ||
| 934 | FRAME_FOCUS_FRAME (c))) | ||
| 935 | return candidate; | ||
| 936 | } | ||
| 937 | else if (XFASTINT (minibuf) == 0) | ||
| 938 | { | ||
| 939 | FRAME_SAMPLE_VISIBILITY (c); | ||
| 940 | if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c)) | ||
| 941 | return candidate; | ||
| 942 | } | ||
| 943 | else | ||
| 944 | return candidate; | ||
| 945 | } | ||
| 946 | return Qnil; | ||
| 947 | } | ||
| 948 | |||
| 949 | /* Return the next frame in the frame list after FRAME. */ | ||
| 905 | 950 | ||
| 906 | static Lisp_Object | 951 | static Lisp_Object |
| 907 | next_frame (Lisp_Object frame, Lisp_Object minibuf) | 952 | next_frame (Lisp_Object frame, Lisp_Object minibuf) |
| @@ -910,72 +955,24 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf) | |||
| 910 | int passed = 0; | 955 | int passed = 0; |
| 911 | 956 | ||
| 912 | /* There must always be at least one frame in Vframe_list. */ | 957 | /* There must always be at least one frame in Vframe_list. */ |
| 913 | if (! CONSP (Vframe_list)) | 958 | eassert (CONSP (Vframe_list)); |
| 914 | emacs_abort (); | ||
| 915 | |||
| 916 | /* If this frame is dead, it won't be in Vframe_list, and we'll loop | ||
| 917 | forever. Forestall that. */ | ||
| 918 | CHECK_LIVE_FRAME (frame); | ||
| 919 | 959 | ||
| 920 | while (1) | 960 | while (passed < 2) |
| 921 | FOR_EACH_FRAME (tail, f) | 961 | FOR_EACH_FRAME (tail, f) |
| 922 | { | 962 | { |
| 923 | if (passed | 963 | if (passed) |
| 924 | && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) | ||
| 925 | && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) | ||
| 926 | || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame)) | ||
| 927 | && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))) | ||
| 928 | { | 964 | { |
| 929 | /* Decide whether this frame is eligible to be returned. */ | 965 | f = candidate_frame (f, frame, minibuf); |
| 930 | 966 | if (!NILP (f)) | |
| 931 | /* If we've looped all the way around without finding any | ||
| 932 | eligible frames, return the original frame. */ | ||
| 933 | if (EQ (f, frame)) | ||
| 934 | return f; | ||
| 935 | |||
| 936 | /* Let minibuf decide if this frame is acceptable. */ | ||
| 937 | if (NILP (minibuf)) | ||
| 938 | { | ||
| 939 | if (! FRAME_MINIBUF_ONLY_P (XFRAME (f))) | ||
| 940 | return f; | ||
| 941 | } | ||
| 942 | else if (EQ (minibuf, Qvisible)) | ||
| 943 | { | ||
| 944 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); | ||
| 945 | if (FRAME_VISIBLE_P (XFRAME (f))) | ||
| 946 | return f; | ||
| 947 | } | ||
| 948 | else if (INTEGERP (minibuf) && XINT (minibuf) == 0) | ||
| 949 | { | ||
| 950 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); | ||
| 951 | if (FRAME_VISIBLE_P (XFRAME (f)) | ||
| 952 | || FRAME_ICONIFIED_P (XFRAME (f))) | ||
| 953 | return f; | ||
| 954 | } | ||
| 955 | else if (WINDOWP (minibuf)) | ||
| 956 | { | ||
| 957 | if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) | ||
| 958 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f) | ||
| 959 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), | ||
| 960 | FRAME_FOCUS_FRAME (XFRAME (f)))) | ||
| 961 | return f; | ||
| 962 | } | ||
| 963 | else | ||
| 964 | return f; | 967 | return f; |
| 965 | } | 968 | } |
| 966 | |||
| 967 | if (EQ (frame, f)) | 969 | if (EQ (frame, f)) |
| 968 | passed++; | 970 | passed++; |
| 969 | } | 971 | } |
| 972 | return frame; | ||
| 970 | } | 973 | } |
| 971 | 974 | ||
| 972 | /* Return the previous frame in the frame list before FRAME. | 975 | /* Return the previous frame in the frame list before FRAME. */ |
| 973 | If MINIBUF is nil, exclude minibuffer-only frames. | ||
| 974 | If MINIBUF is a window, include only its own frame | ||
| 975 | and any frame now using that window as the minibuffer. | ||
| 976 | If MINIBUF is `visible', include all visible frames. | ||
| 977 | If MINIBUF is 0, include all visible and iconified frames. | ||
| 978 | Otherwise, include all frames. */ | ||
| 979 | 976 | ||
| 980 | static Lisp_Object | 977 | static Lisp_Object |
| 981 | prev_frame (Lisp_Object frame, Lisp_Object minibuf) | 978 | prev_frame (Lisp_Object frame, Lisp_Object minibuf) |
| @@ -989,43 +986,9 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf) | |||
| 989 | { | 986 | { |
| 990 | if (EQ (frame, f) && !NILP (prev)) | 987 | if (EQ (frame, f) && !NILP (prev)) |
| 991 | return prev; | 988 | return prev; |
| 992 | 989 | f = candidate_frame (f, frame, minibuf); | |
| 993 | if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) | 990 | if (!NILP (f)) |
| 994 | && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) | 991 | prev = f; |
| 995 | || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame)) | ||
| 996 | && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))) | ||
| 997 | { | ||
| 998 | /* Decide whether this frame is eligible to be returned, | ||
| 999 | according to minibuf. */ | ||
| 1000 | if (NILP (minibuf)) | ||
| 1001 | { | ||
| 1002 | if (! FRAME_MINIBUF_ONLY_P (XFRAME (f))) | ||
| 1003 | prev = f; | ||
| 1004 | } | ||
| 1005 | else if (WINDOWP (minibuf)) | ||
| 1006 | { | ||
| 1007 | if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) | ||
| 1008 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f) | ||
| 1009 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), | ||
| 1010 | FRAME_FOCUS_FRAME (XFRAME (f)))) | ||
| 1011 | prev = f; | ||
| 1012 | } | ||
| 1013 | else if (EQ (minibuf, Qvisible)) | ||
| 1014 | { | ||
| 1015 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); | ||
| 1016 | if (FRAME_VISIBLE_P (XFRAME (f))) | ||
| 1017 | prev = f; | ||
| 1018 | } | ||
| 1019 | else if (XFASTINT (minibuf) == 0) | ||
| 1020 | { | ||
| 1021 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); | ||
| 1022 | if (FRAME_VISIBLE_P (XFRAME (f)) | ||
| 1023 | || FRAME_ICONIFIED_P (XFRAME (f))) | ||
| 1024 | prev = f; | ||
| 1025 | } | ||
| 1026 | else | ||
| 1027 | prev = f; | ||
| 1028 | } | ||
| 1029 | } | 992 | } |
| 1030 | 993 | ||
| 1031 | /* We've scanned the entire list. */ | 994 | /* We've scanned the entire list. */ |
| @@ -1056,7 +1019,6 @@ Otherwise, include all frames. */) | |||
| 1056 | { | 1019 | { |
| 1057 | if (NILP (frame)) | 1020 | if (NILP (frame)) |
| 1058 | frame = selected_frame; | 1021 | frame = selected_frame; |
| 1059 | |||
| 1060 | CHECK_LIVE_FRAME (frame); | 1022 | CHECK_LIVE_FRAME (frame); |
| 1061 | return next_frame (frame, miniframe); | 1023 | return next_frame (frame, miniframe); |
| 1062 | } | 1024 | } |