-2011-10-08 Paul Eggert <eggert@cs.ucla.edu>
+2011-10-11 Paul Eggert <eggert@cs.ucla.edu>
Fix integer width and related issues.
* alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp):
* process.c (Fdelete_process): Don't assume pid fits into EMACS_INT.
(Fset_process_window_size, Fformat_network_address)
(get_lisp_to_sockaddr_size, set_socket_option, Fmake_network_process)
- (Fsignal_process, sigchld_handler):
+ (sigchld_handler):
Check that fixnums are in proper range for system types.
+ (Fsignal_process): Simplify by avoiding a goto.
+ Treat out-of-range process numbers just like invalid numbers
+ that fit into the pid_t range, and return -1.
(Fformat_network_address, read_process_output, send_process)
(Fprocess_send_region, status_notify):
Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough.
{
pid_t pid;
- if (INTEGERP (process))
- {
- CHECK_TYPE_RANGED_INTEGER (pid_t, process);
- pid = XINT (process);
- goto got_it;
- }
-
- if (FLOATP (process))
- {
- double v = XFLOAT_DATA (process);
- if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0))
- args_out_of_range_3 (process,
- make_fixnum_or_float (TYPE_MINIMUM (pid_t)),
- make_fixnum_or_float (TYPE_MAXIMUM (pid_t)));
- pid = v;
- goto got_it;
- }
-
if (STRINGP (process))
{
Lisp_Object tem = Fget_process (process);
if (NILP (tem))
{
- EMACS_INT v = XINT (Fstring_to_number (process, make_number (10)));
- if (0 < v && v <= TYPE_MAXIMUM (pid_t))
- {
- pid = v;
- goto got_it;
- }
+ Lisp_Object process_number =
+ string_to_number (SSDATA (process), 10, 1);
+ if (INTEGERP (process_number) || FLOATP (process_number))
+ tem = process_number;
}
process = tem;
}
- else
+ else if (!NUMBERP (process))
process = get_process (process);
if (NILP (process))
return process;
- CHECK_PROCESS (process);
- pid = XPROCESS (process)->pid;
- if (pid <= 0)
- error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
-
- got_it:
+ if (INTEGERP (process))
+ {
+ EMACS_INT v = XINT (process);
+ if (! (TYPE_MINIMUM (pid_t) <= v && v <= TYPE_MAXIMUM (pid_t)))
+ return make_number (-1);
+ pid = v;
+ }
+ else if (FLOATP (process))
+ {
+ double v = XFLOAT_DATA (process);
+ if (! (TYPE_MINIMUM (pid_t) <= v && v < TYPE_MAXIMUM (pid_t) + 1.0))
+ return make_number (-1);
+ pid = v;
+ if (pid != v)
+ return make_number (-1);
+ }
+ else
+ {
+ CHECK_PROCESS (process);
+ pid = XPROCESS (process)->pid;
+ if (pid <= 0)
+ error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
+ }
#define parse_signal(NAME, VALUE) \
else if (!xstrcasecmp (name, NAME)) \