aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-02-02 19:19:08 +0000
committerKaroly Lorentey2004-02-02 19:19:08 +0000
commitd3a6748c5b378a86fc8408222c7dd26e47218af9 (patch)
tree33f9334088634447425b8c926dd45d1e83fa80e2 /src
parent465fc071a1aa48e87f37bff460410eec921eaa53 (diff)
parentd83a97ab5fbcde063e4a87042cd721a23f13fbe0 (diff)
downloademacs-d3a6748c5b378a86fc8408222c7dd26e47218af9.tar.gz
emacs-d3a6748c5b378a86fc8408222c7dd26e47218af9.zip
Merged in changes from CVS HEAD
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-57 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-58 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-59 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-60 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-61 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-62 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-63 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-64 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-65 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-66 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-67 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-68 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-69 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-71
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog70
-rw-r--r--src/alloca.c2
-rw-r--r--src/callproc.c17
-rw-r--r--src/coding.c3
-rw-r--r--src/fileio.c36
-rw-r--r--src/fns.c10
-rw-r--r--src/macterm.c6
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/process.c18
-rw-r--r--src/process.h3
-rw-r--r--src/search.c12
-rw-r--r--src/sysdep.c6
-rw-r--r--src/unexmacosx.c4
-rw-r--r--src/w32fns.c72
14 files changed, 220 insertions, 40 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a71cb27cf33..9a93ac894ca 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,73 @@
12004-02-02 Kenichi Handa <handa@m17n.org>
2
3 * coding.c (coding_restore_composition): Check invalid
4 composition data more rigidly.
5
62004-01-30 Luc Teirlinck <teirllm@auburn.edu>
7
8 * fileio.c (Fread_file_name_internal): Correctly handle the case
9 where insert-default-directory is nil.
10 (Fread_file_name): Always return an empty string if the user exits
11 with an empty minibuffer. Adapt the docstring accordingly.
12 (syms_of_fileio): Adapt the docstring of insert-default-directory
13 to the change in Fread_file_name.
14
152004-01-29 Eli Zaretskii <eliz@elta.co.il>
16
17 * alloca.c [!alloca]: Fix the prototype for xfree.
18
192004-01-29 Kenichi Handa <handa@m17n.org>
20
21 * fns.c (string_char_to_byte): Optimize for ASCII only string.
22 (string_byte_to_char): Likewise.
23
242004-01-28 Peter Runestig <peter@runestig.com>
25
26 * makefile.w32-in, w32fns.c: Add `default-printer-name' function.
27
282004-01-27 Steven Tamm <steventamm@mac.com>
29
30 * unexmacosx.c (unexec_copy): Do not copy more than was
31 requested to prevent overwriting during unexec.
32
332004-01-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
34
35 * process.c (sigchld_handler): Add comment about not calling malloc.
36
37 * process.h: Add extern to synch_process_termsig.
38
392004-01-27 Steven Tamm <steventamm@mac.com>
40
41 * macterm.c (make_mac_frame, make_mac_terminal_frame): Move
42 setting of scroll bars from make_mac_frame to
43 make_mac_terminal_frame to prevent clobbering of
44 scroll-bar-mode.
45
462004-01-26 Richard M. Stallman <rms@gnu.org>
47
48 * search.c (Freplace_match): Handle nonexistent
49 back-references properly.
50
512004-01-03 Richard M. Stallman <rms@gnu.org>
52
53 * window.c (decode_any_window): New function.
54 (Fwindow_height, Fwindow_width, Fwindow_edges)
55 (Fwindow_pixel_edges, Fwindow_inside_edges)
56 (Fwindow_inside_pixel_edges): Use decode_any_window.
57
582004-01-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
59
60 * process.h: synch_process_termsig new variable.
61
62 * callproc.c: Define synch_process_termsig.
63 (Fcall_process): Initiate synch_process_termsig to zero and
64 check if non-zero and get signal name after subprocess has ended.
65
66 * process.c (sigchld_handler): Set synch_process_termsig
67 if terminated by a signal. synch_process_death setting removed.
68
69 * sysdep.c (mkdir, rmdir): Also check synch_process_termsig.
70
12004-01-26 Andreas Schwab <schwab@suse.de> 712004-01-26 Andreas Schwab <schwab@suse.de>
2 72
3 * print.c (print_preprocess): Declare size as EMACS_INT to not 73 * print.c (print_preprocess): Declare size as EMACS_INT to not
diff --git a/src/alloca.c b/src/alloca.c
index 460d0ae9a54..e8c8319adc4 100644
--- a/src/alloca.c
+++ b/src/alloca.c
@@ -100,7 +100,7 @@ typedef POINTER_TYPE *pointer;
100# define free xfree 100# define free xfree
101 101
102void *xmalloc _P ((size_t)); 102void *xmalloc _P ((size_t));
103void xfree _P ((void *)) 103void xfree _P ((void *));
104 104
105/* Define STACK_DIRECTION if you know the direction of stack 105/* Define STACK_DIRECTION if you know the direction of stack
106 growth for your system; otherwise it will be automatically 106 growth for your system; otherwise it will be automatically
diff --git a/src/callproc.c b/src/callproc.c
index 00068a908fb..73d81d81b18 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -123,6 +123,9 @@ int synch_process_alive;
123/* Nonzero => this is a string explaining death of synchronous subprocess. */ 123/* Nonzero => this is a string explaining death of synchronous subprocess. */
124char *synch_process_death; 124char *synch_process_death;
125 125
126/* Nonzero => this is the signal number that terminated the subprocess. */
127int synch_process_termsig;
128
126/* If synch_process_death is zero, 129/* If synch_process_death is zero,
127 this is exit code of synchronous subprocess. */ 130 this is exit code of synchronous subprocess. */
128int synch_process_retcode; 131int synch_process_retcode;
@@ -506,6 +509,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
506 to avoid timing error if process terminates soon. */ 509 to avoid timing error if process terminates soon. */
507 synch_process_death = 0; 510 synch_process_death = 0;
508 synch_process_retcode = 0; 511 synch_process_retcode = 0;
512 synch_process_termsig = 0;
509 513
510 if (NILP (error_file)) 514 if (NILP (error_file))
511 fd_error = emacs_open (NULL_DEVICE, O_WRONLY, 0); 515 fd_error = emacs_open (NULL_DEVICE, O_WRONLY, 0);
@@ -977,6 +981,19 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
977 981
978 unbind_to (count, Qnil); 982 unbind_to (count, Qnil);
979 983
984 if (synch_process_termsig)
985 {
986 char *signame;
987
988 synchronize_system_messages_locale ();
989 signame = strsignal (synch_process_termsig);
990
991 if (signame == 0)
992 signame = "unknown";
993
994 synch_process_death = signame;
995 }
996
980 if (synch_process_death) 997 if (synch_process_death)
981 return code_convert_string_norecord (build_string (synch_process_death), 998 return code_convert_string_norecord (build_string (synch_process_death),
982 Vlocale_coding_system, 0); 999 Vlocale_coding_system, 0);
diff --git a/src/coding.c b/src/coding.c
index d9620b90722..7880e439e9d 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5458,6 +5458,9 @@ coding_restore_composition (coding, obj)
5458 if (method == COMPOSITION_WITH_RULE_ALTCHARS 5458 if (method == COMPOSITION_WITH_RULE_ALTCHARS
5459 && len % 2 == 0) 5459 && len % 2 == 0)
5460 len --; 5460 len --;
5461 if (len < 1)
5462 /* Invalid composition data. */
5463 break;
5461 for (j = 0; j < len; j++) 5464 for (j = 0; j < len; j++)
5462 args[j] = make_number (data[4 + j]); 5465 args[j] = make_number (data[4 + j]);
5463 components = (method == COMPOSITION_WITH_ALTCHARS 5466 components = (method == COMPOSITION_WITH_ALTCHARS
diff --git a/src/fileio.c b/src/fileio.c
index a2b207169cf..c7959b3672d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6095,6 +6095,7 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte
6095 if (SCHARS (name) == 0) 6095 if (SCHARS (name) == 0)
6096 return Qt; 6096 return Qt;
6097#endif /* VMS */ 6097#endif /* VMS */
6098 string = Fexpand_file_name (string, dir);
6098 if (!NILP (Vread_file_name_predicate)) 6099 if (!NILP (Vread_file_name_predicate))
6099 return call1 (Vread_file_name_predicate, string); 6100 return call1 (Vread_file_name_predicate, string);
6100 return Ffile_exists_p (string); 6101 return Ffile_exists_p (string);
@@ -6103,15 +6104,20 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte
6103DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0, 6104DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0,
6104 doc: /* Read file name, prompting with PROMPT and completing in directory DIR. 6105 doc: /* Read file name, prompting with PROMPT and completing in directory DIR.
6105Value is not expanded---you must call `expand-file-name' yourself. 6106Value is not expanded---you must call `expand-file-name' yourself.
6106Default name to DEFAULT-FILENAME if user enters a null string. 6107Default name to DEFAULT-FILENAME if user exits the minibuffer with
6108the same non-empty string that was inserted by this function.
6107 (If DEFAULT-FILENAME is omitted, the visited file name is used, 6109 (If DEFAULT-FILENAME is omitted, the visited file name is used,
6108 except that if INITIAL is specified, that combined with DIR is used.) 6110 except that if INITIAL is specified, that combined with DIR is used.)
6111If the user exits with an empty minibuffer, this function returns
6112an empty string. (This can only happen if the user erased the
6113pre-inserted contents or if `insert-default-directory' is nil.)
6109Fourth arg MUSTMATCH non-nil means require existing file's name. 6114Fourth arg MUSTMATCH non-nil means require existing file's name.
6110 Non-nil and non-t means also require confirmation after completion. 6115 Non-nil and non-t means also require confirmation after completion.
6111Fifth arg INITIAL specifies text to start with. 6116Fifth arg INITIAL specifies text to start with.
6112If optional sixth arg PREDICATE is non-nil, possible completions and the 6117If optional sixth arg PREDICATE is non-nil, possible completions and
6113resulting file name must satisfy (funcall PREDICATE NAME). 6118the resulting file name must satisfy (funcall PREDICATE NAME).
6114DIR defaults to current buffer's directory default. 6119DIR should be an absolute directory name. It defaults to the value of
6120`default-directory'.
6115 6121
6116If this command was invoked with the mouse, use a file dialog box if 6122If this command was invoked with the mouse, use a file dialog box if
6117`use-dialog-box' is non-nil, and the window system or X toolkit in use 6123`use-dialog-box' is non-nil, and the window system or X toolkit in use
@@ -6275,13 +6281,6 @@ provides a file dialog box. */)
6275 6281
6276 if (!NILP (tem) && !NILP (default_filename)) 6282 if (!NILP (tem) && !NILP (default_filename))
6277 val = default_filename; 6283 val = default_filename;
6278 else if (SCHARS (val) == 0 && NILP (insdef))
6279 {
6280 if (!NILP (default_filename))
6281 val = default_filename;
6282 else
6283 error ("No default file name");
6284 }
6285 val = Fsubstitute_in_file_name (val); 6284 val = Fsubstitute_in_file_name (val);
6286 6285
6287 if (replace_in_history) 6286 if (replace_in_history)
@@ -6457,7 +6456,20 @@ same format as a regular save would use. */);
6457 Vread_file_name_predicate = Qnil; 6456 Vread_file_name_predicate = Qnil;
6458 6457
6459 DEFVAR_BOOL ("insert-default-directory", &insert_default_directory, 6458 DEFVAR_BOOL ("insert-default-directory", &insert_default_directory,
6460 doc: /* *Non-nil means when reading a filename start with default dir in minibuffer. */); 6459 doc: /* *Non-nil means when reading a filename start with default dir in minibuffer.
6460If the initial minibuffer contents are non-empty, you can usually
6461request a default filename by typing RETURN without editing. For some
6462commands, exiting with an empty minibuffer has a special meaning,
6463such as making the current buffer visit no file in the case of
6464`set-visited-file-name'.
6465If this variable is non-nil, the minibuffer contents are always
6466initially non-empty and typing RETURN without editing will fetch the
6467default name, if one is provided. Note however that this default name
6468is not necessarily the name originally inserted in the minibuffer, if
6469that is just the default directory.
6470If this variable is nil, the minibuffer often starts out empty. In
6471that case you may have to explicitly fetch the next history element to
6472request the default name. */);
6461 insert_default_directory = 1; 6473 insert_default_directory = 1;
6462 6474
6463 DEFVAR_BOOL ("vms-stmlf-recfm", &vms_stmlf_recfm, 6475 DEFVAR_BOOL ("vms-stmlf-recfm", &vms_stmlf_recfm,
diff --git a/src/fns.c b/src/fns.c
index 6383e09302b..493d7ba2897 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -884,12 +884,11 @@ string_char_to_byte (string, char_index)
884 int best_below, best_below_byte; 884 int best_below, best_below_byte;
885 int best_above, best_above_byte; 885 int best_above, best_above_byte;
886 886
887 if (! STRING_MULTIBYTE (string))
888 return char_index;
889
890 best_below = best_below_byte = 0; 887 best_below = best_below_byte = 0;
891 best_above = SCHARS (string); 888 best_above = SCHARS (string);
892 best_above_byte = SBYTES (string); 889 best_above_byte = SBYTES (string);
890 if (best_above == best_above_byte)
891 return char_index;
893 892
894 if (EQ (string, string_char_byte_cache_string)) 893 if (EQ (string, string_char_byte_cache_string))
895 { 894 {
@@ -957,12 +956,11 @@ string_byte_to_char (string, byte_index)
957 int best_below, best_below_byte; 956 int best_below, best_below_byte;
958 int best_above, best_above_byte; 957 int best_above, best_above_byte;
959 958
960 if (! STRING_MULTIBYTE (string))
961 return byte_index;
962
963 best_below = best_below_byte = 0; 959 best_below = best_below_byte = 0;
964 best_above = SCHARS (string); 960 best_above = SCHARS (string);
965 best_above_byte = SBYTES (string); 961 best_above_byte = SBYTES (string);
962 if (best_above == best_above_byte)
963 return byte_index;
966 964
967 if (EQ (string, string_char_byte_cache_string)) 965 if (EQ (string, string_char_byte_cache_string))
968 { 966 {
diff --git a/src/macterm.c b/src/macterm.c
index a4124a0c7bc..9c7c497c00b 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -8205,9 +8205,6 @@ NewMacWindow (FRAME_PTR fp)
8205void 8205void
8206make_mac_frame (struct frame *f) 8206make_mac_frame (struct frame *f)
8207{ 8207{
8208 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8209 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8210
8211 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; 8208 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
8212 8209
8213 NewMacWindow(f); 8210 NewMacWindow(f);
@@ -8256,6 +8253,9 @@ make_mac_terminal_frame (struct frame *f)
8256 FRAME_COLS (f) = 96; 8253 FRAME_COLS (f) = 96;
8257 FRAME_LINES (f) = 4; 8254 FRAME_LINES (f) = 4;
8258 8255
8256 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8257 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8258
8259 make_mac_frame (f); 8259 make_mac_frame (f);
8260 8260
8261 x_make_gc (f); 8261 x_make_gc (f);
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index c8e9addff63..bd5ad98571c 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -140,6 +140,7 @@ LIBS = $(TLIB0) \
140 $(USER32) \ 140 $(USER32) \
141 $(MPR) \ 141 $(MPR) \
142 $(SHELL32) \ 142 $(SHELL32) \
143 $(WINSPOOL) \
143 $(libc) 144 $(libc)
144 145
145# 146#
diff --git a/src/process.c b/src/process.c
index 2114d333905..be6094438e9 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6094,7 +6094,10 @@ kill_buffer_processes (buffer)
6094 queued and the signal-catching function will be continually 6094 queued and the signal-catching function will be continually
6095 reentered until the queue is empty". Invoking signal() causes the 6095 reentered until the queue is empty". Invoking signal() causes the
6096 kernel to reexamine the SIGCLD queue. Fred Fish, UniSoft Systems 6096 kernel to reexamine the SIGCLD queue. Fred Fish, UniSoft Systems
6097 Inc. */ 6097 Inc.
6098
6099 ** Malloc WARNING: This should never call malloc either directly or
6100 indirectly; if it does, that is a bug */
6098 6101
6099SIGTYPE 6102SIGTYPE
6100sigchld_handler (signo) 6103sigchld_handler (signo)
@@ -6212,18 +6215,7 @@ sigchld_handler (signo)
6212 if (WIFEXITED (w)) 6215 if (WIFEXITED (w))
6213 synch_process_retcode = WRETCODE (w); 6216 synch_process_retcode = WRETCODE (w);
6214 else if (WIFSIGNALED (w)) 6217 else if (WIFSIGNALED (w))
6215 { 6218 synch_process_termsig = WTERMSIG (w);
6216 int code = WTERMSIG (w);
6217 char *signame;
6218
6219 synchronize_system_messages_locale ();
6220 signame = strsignal (code);
6221
6222 if (signame == 0)
6223 signame = "unknown";
6224
6225 synch_process_death = signame;
6226 }
6227 6219
6228 /* Tell wait_reading_process_input that it needs to wake up and 6220 /* Tell wait_reading_process_input that it needs to wake up and
6229 look around. */ 6221 look around. */
diff --git a/src/process.h b/src/process.h
index 2f46e74d4d0..6e2641d6b06 100644
--- a/src/process.h
+++ b/src/process.h
@@ -136,6 +136,9 @@ extern int synch_process_alive;
136/* Nonzero => this is a string explaining death of synchronous subprocess. */ 136/* Nonzero => this is a string explaining death of synchronous subprocess. */
137extern char *synch_process_death; 137extern char *synch_process_death;
138 138
139/* Nonzero => this is the signal number that terminated the subprocess. */
140extern int synch_process_termsig;
141
139/* If synch_process_death is zero, 142/* If synch_process_death is zero,
140 this is exit code of synchronous subprocess. */ 143 this is exit code of synchronous subprocess. */
141extern int synch_process_retcode; 144extern int synch_process_retcode;
diff --git a/src/search.c b/src/search.c
index 020573b75a1..c60d68b9374 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2366,13 +2366,21 @@ since only regular expressions have distinguished subexpressions. */)
2366 substart = search_regs.start[sub]; 2366 substart = search_regs.start[sub];
2367 subend = search_regs.end[sub]; 2367 subend = search_regs.end[sub];
2368 } 2368 }
2369 else if (c >= '1' && c <= '9' && c <= search_regs.num_regs + '0') 2369 else if (c >= '1' && c <= '9')
2370 { 2370 {
2371 if (search_regs.start[c - '0'] >= 0) 2371 if (search_regs.start[c - '0'] >= 0
2372 && c <= search_regs.num_regs + '0')
2372 { 2373 {
2373 substart = search_regs.start[c - '0']; 2374 substart = search_regs.start[c - '0'];
2374 subend = search_regs.end[c - '0']; 2375 subend = search_regs.end[c - '0'];
2375 } 2376 }
2377 else
2378 {
2379 /* If that subexp did not match,
2380 replace \\N with nothing. */
2381 substart = 0;
2382 subend = 0;
2383 }
2376 } 2384 }
2377 else if (c == '\\') 2385 else if (c == '\\')
2378 delbackslash = 1; 2386 delbackslash = 1;
diff --git a/src/sysdep.c b/src/sysdep.c
index d8422b839f9..2b7a029b5ba 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3832,7 +3832,8 @@ mkdir (dpath, dmode)
3832 wait_for_termination (cpid); 3832 wait_for_termination (cpid);
3833 } 3833 }
3834 3834
3835 if (synch_process_death != 0 || synch_process_retcode != 0) 3835 if (synch_process_death != 0 || synch_process_retcode != 0
3836 || synch_process_termsig != 0)
3836 { 3837 {
3837 errno = EIO; /* We don't know why, but */ 3838 errno = EIO; /* We don't know why, but */
3838 return -1; /* /bin/mkdir failed */ 3839 return -1; /* /bin/mkdir failed */
@@ -3878,7 +3879,8 @@ rmdir (dpath)
3878 wait_for_termination (cpid); 3879 wait_for_termination (cpid);
3879 } 3880 }
3880 3881
3881 if (synch_process_death != 0 || synch_process_retcode != 0) 3882 if (synch_process_death != 0 || synch_process_retcode != 0
3883 || synch_process_termsig != 0)
3882 { 3884 {
3883 errno = EIO; /* We don't know why, but */ 3885 errno = EIO; /* We don't know why, but */
3884 return -1; /* /bin/rmdir failed */ 3886 return -1; /* /bin/rmdir failed */
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index b8532325973..b41c586d2e0 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -192,6 +192,7 @@ static int
192unexec_copy (off_t dest, off_t src, ssize_t count) 192unexec_copy (off_t dest, off_t src, ssize_t count)
193{ 193{
194 ssize_t bytes_read; 194 ssize_t bytes_read;
195 ssize_t bytes_to_read;
195 196
196 char buf[UNEXEC_COPY_BUFSZ]; 197 char buf[UNEXEC_COPY_BUFSZ];
197 198
@@ -203,7 +204,8 @@ unexec_copy (off_t dest, off_t src, ssize_t count)
203 204
204 while (count > 0) 205 while (count > 0)
205 { 206 {
206 bytes_read = read (infd, buf, UNEXEC_COPY_BUFSZ); 207 bytes_to_read = count > UNEXEC_COPY_BUFSZ ? UNEXEC_COPY_BUFSZ : count;
208 bytes_read = read (infd, buf, bytes_to_read);
207 if (bytes_read <= 0) 209 if (bytes_read <= 0)
208 return 0; 210 return 0;
209 if (write (outfd, buf, bytes_read) != bytes_read) 211 if (write (outfd, buf, bytes_read) != bytes_read)
diff --git a/src/w32fns.c b/src/w32fns.c
index 7bffea34a28..1854c3908bd 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -51,6 +51,7 @@ Boston, MA 02111-1307, USA. */
51#include <commdlg.h> 51#include <commdlg.h>
52#include <shellapi.h> 52#include <shellapi.h>
53#include <ctype.h> 53#include <ctype.h>
54#include <winspool.h>
54 55
55#include <dlgs.h> 56#include <dlgs.h>
56#define FILE_NAME_TEXT_FIELD edt1 57#define FILE_NAME_TEXT_FIELD edt1
@@ -13921,6 +13922,76 @@ If the underlying system call fails, value is nil. */)
13921 return value; 13922 return value;
13922} 13923}
13923 13924
13925DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
13926 0, 0, 0, doc: /* Return the name of Windows default printer device. */)
13927 ()
13928{
13929 static char pname_buf[256];
13930 int err;
13931 HANDLE hPrn;
13932 PRINTER_INFO_2 *ppi2 = NULL;
13933 DWORD dwNeeded = 0, dwReturned = 0;
13934
13935 /* Retrieve the default string from Win.ini (the registry).
13936 * String will be in form "printername,drivername,portname".
13937 * This is the most portable way to get the default printer. */
13938 if (GetProfileString ("windows", "device", ",,", pname_buf, sizeof (pname_buf)) <= 0)
13939 return Qnil;
13940 /* printername precedes first "," character */
13941 strtok (pname_buf, ",");
13942 /* We want to know more than the printer name */
13943 if (!OpenPrinter (pname_buf, &hPrn, NULL))
13944 return Qnil;
13945 GetPrinter (hPrn, 2, NULL, 0, &dwNeeded);
13946 if (dwNeeded == 0)
13947 {
13948 ClosePrinter (hPrn);
13949 return Qnil;
13950 }
13951 /* Allocate memory for the PRINTER_INFO_2 struct */
13952 ppi2 = (PRINTER_INFO_2 *) xmalloc (dwNeeded);
13953 if (!ppi2)
13954 {
13955 ClosePrinter (hPrn);
13956 return Qnil;
13957 }
13958 /* Call GetPrinter() again with big enouth memory block */
13959 err = GetPrinter (hPrn, 2, (LPBYTE)ppi2, dwNeeded, &dwReturned);
13960 ClosePrinter (hPrn);
13961 if (!err)
13962 {
13963 xfree(ppi2);
13964 return Qnil;
13965 }
13966
13967 if (ppi2)
13968 {
13969 if (ppi2->Attributes & PRINTER_ATTRIBUTE_SHARED && ppi2->pServerName)
13970 {
13971 /* a remote printer */
13972 if (*ppi2->pServerName == '\\')
13973 _snprintf(pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName,
13974 ppi2->pShareName);
13975 else
13976 _snprintf(pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName,
13977 ppi2->pShareName);
13978 pname_buf[sizeof (pname_buf) - 1] = '\0';
13979 }
13980 else
13981 {
13982 /* a local printer */
13983 strncpy(pname_buf, ppi2->pPortName, sizeof (pname_buf));
13984 pname_buf[sizeof (pname_buf) - 1] = '\0';
13985 /* `pPortName' can include several ports, delimited by ','.
13986 * we only use the first one. */
13987 strtok(pname_buf, ",");
13988 }
13989 xfree(ppi2);
13990 }
13991
13992 return build_string (pname_buf);
13993}
13994
13924/*********************************************************************** 13995/***********************************************************************
13925 Initialization 13996 Initialization
13926 ***********************************************************************/ 13997 ***********************************************************************/
@@ -14373,6 +14444,7 @@ versions of Windows) characters. */);
14373 defsubr (&Sw32_find_bdf_fonts); 14444 defsubr (&Sw32_find_bdf_fonts);
14374 14445
14375 defsubr (&Sfile_system_info); 14446 defsubr (&Sfile_system_info);
14447 defsubr (&Sdefault_printer_name);
14376 14448
14377 /* Setting callback functions for fontset handler. */ 14449 /* Setting callback functions for fontset handler. */
14378 get_font_info_func = w32_get_font_info; 14450 get_font_info_func = w32_get_font_info;