summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-12-29 02:39:17 +0000
committerMiles Bader <miles@gnu.org>2007-12-29 02:39:17 +0000
commita0c92ed92d3d62d4926dafb1d595d87843df4688 (patch)
tree78f12dd6f97a0f96b846fbf08e3f8ce39a701f8e /src
parent9aeb99f00a02c695b14f2ee349141eb9641ca6da (diff)
parent870356897e927f380841268667a92b40fb9e6782 (diff)
downloademacs-a0c92ed92d3d62d4926dafb1d595d87843df4688.tar.gz
emacs-a0c92ed92d3d62d4926dafb1d595d87843df4688.tar.bz2
emacs-a0c92ed92d3d62d4926dafb1d595d87843df4688.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-306
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog85
-rw-r--r--src/callint.c5
-rw-r--r--src/dbusbind.c708
-rw-r--r--src/fileio.c3
-rw-r--r--src/macmenu.c3
-rw-r--r--src/process.c2
-rw-r--r--src/w32fns.c3
-rw-r--r--src/xdisp.c18
8 files changed, 696 insertions, 131 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d5edca82fe9..be2c5824f51 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,77 @@
+2007-12-24 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * process.c (make_process): Initialize pty_flag to Qnil instead of 0
+ as it is not a bit field on Emacs 22 yet.
+
+ * xdisp.c (phys_cursor_in_rect_p): Check if cursor is in fringe area.
+
+2007-12-22 Eli Zaretskii <eliz@gnu.org>
+
+ * callint.c (syms_of_callint) <command-history>: Add reference to
+ history-length in the doc string.
+
+2007-12-17 Jason Rumney <jasonr@gnu.org>
+
+ * w32fns.c (w32_wnd_proc) <WM_KEYDOWN>: Cast char to unsigned
+ before passing as wParam.
+
+2007-12-22 Michael Albinus <michael.albinus@gmx.de>
+
+ * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
+ DBUS_TYPE_INT16, DBUS_TYPE_UINT16, DBUS_TYPE_INT64,
+ DBUS_TYPE_UINT64, DBUS_TYPE_DOUBLE and DBUS_TYPE_SIGNATURE.
+ Return float when DBUS_TYPE_INT32 or DBUS_TYPE_UINT32 do not fit
+ as number.
+ (Fdbus_call_method): Fix docstring.
+
+2007-12-21 Michael Albinus <michael.albinus@gmx.de>
+
+ * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
+ New macros.
+ (XD_SYMBOL_TO_DBUS_TYPE): Renamed from
+ XD_LISP_SYMBOL_TO_DBUS_TYPE.
+ (XD_OBJECT_TO_DBUS_TYPE): Renamed from
+ XD_LISP_OBJECT_TO_DBUS_TYPE. Simplify.
+ (xd_signature): New function.
+ (xd_append_arg): Compute also signatures. Major rewrite.
+ (xd_retrieve_arg): Make debug messages friendly.
+ (Fdbus_call_method, Fdbus_send_signal): Extend docstring. Check
+ for signatures of arguments.
+
+2007-12-19 Michael Albinus <michael.albinus@gmx.de>
+
+ * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
+ (QCdbus_type_int16, QCdbus_type_uint16, QCdbus_type_int32)
+ (QCdbus_type_uint32, QCdbus_type_int64, QCdbus_type_uint64)
+ (QCdbus_type_double, QCdbus_type_string, QCdbus_type_object_path)
+ (QCdbus_type_signature, QCdbus_type_array, QCdbus_type_variant)
+ (QCdbus_type_struct, QCdbus_type_dict_entry): New D-Bus type
+ symbols.
+ (XD_LISP_SYMBOL_TO_DBUS_TYPE): New macro.
+ (XD_LISP_OBJECT_TO_DBUS_TYPE): Add compound types.
+ (xd_retrieve_value): Removed. Functionality included in ...
+ (xd_append_arg): New function.
+ (Fdbus_call_method, Fdbus_send_signal): Apply it.
+
+2007-12-16 Michael Albinus <michael.albinus@gmx.de>
+
+ * dbusbind.c (top): Include <stdio.h>.
+ (Fdbus_call_method, Fdbus_send_signal): Apply type cast in
+ dbus_message_new_method_call and dbus_message_new_signal.
+ (Fdbus_register_signal): Rename unique_name to uname. Check
+ handler for FUNCTIONP instead of CHECK_SYMBOL. Handle case of
+ non-existing unique name. Fix typos in matching rule. Return an
+ object which is useful in Fdbus_unregister_signal.
+ (Fdbus_unregister_signal): Reimplementation, in order to remove
+ only the corresponding entry.
+ (Vdbus_registered_functions_table): Change the order of entries.
+ Apply these changes in xd_read_message and Fdbus_register_signal.
+
+2007-12-16 Andreas Schwab <schwab@suse.de>
+
+ * fileio.c (Finsert_file_contents): Fix overflow check to not
+ depend on undefined integer overflow.
+
2007-12-14 Jason Rumney <jasonr@gnu.org>
* w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT
@@ -837,6 +911,12 @@
* msdos.c (dos_rawgetc): Undo last change (there's no ``leaving
selected frame'' on MSDOS).
+2007-10-12 Martin Rudalics <rudalics@gmx.at>
+
+ * frame.c (Qexplicit_name): New variable.
+ (x_report_frame_params): Report it in parameter alist.
+ (syms_of_frame): Intern and staticpro it.
+
2007-10-10 Patrick Mahan <mahan@mahan.org> (tiny change)
* macfns.c (x_create_tip_frame): Set terminal for frame.
@@ -864,6 +944,11 @@
* puresize.h (BASE_PURESIZE): Increase to 1170000.
+2007-10-09 Jason Rumney <jasonr@gnu.org>
+
+ * w32term.c (x_set_window_size): Disable code that attempts to tell
+ Lisp code about a size change before it actually happens.
+
2007-10-09 Richard Stallman <rms@gnu.org>
* xdisp.c (handle_invisible_prop): After setting up an ellipsis,
diff --git a/src/callint.c b/src/callint.c
index a19c424c899..2ac53105afb 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -941,7 +941,10 @@ This is what `(interactive \"P\")' returns. */);
DEFVAR_LISP ("command-history", &Vcommand_history,
doc: /* List of recent commands that read arguments from terminal.
-Each command is represented as a form to evaluate. */);
+Each command is represented as a form to evaluate.
+
+Maximum length of the history list is determined by the value
+of `history-length', which see. */);
Vcommand_history = Qnil;
DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status,
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 0ccccc8b22d..88f2ccdb3eb 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -22,6 +22,7 @@ Boston, MA 02110-1301, USA. */
#ifdef HAVE_DBUS
#include <stdlib.h>
+#include <stdio.h>
#include <dbus/dbus.h>
#include "lisp.h"
#include "frame.h"
@@ -42,6 +43,16 @@ Lisp_Object Qdbus_error;
/* Lisp symbols of the system and session buses. */
Lisp_Object QCdbus_system_bus, QCdbus_session_bus;
+/* Lisp symbols of D-Bus types. */
+Lisp_Object QCdbus_type_byte, QCdbus_type_boolean;
+Lisp_Object QCdbus_type_int16, QCdbus_type_uint16;
+Lisp_Object QCdbus_type_int32, QCdbus_type_uint32;
+Lisp_Object QCdbus_type_int64, QCdbus_type_uint64;
+Lisp_Object QCdbus_type_double, QCdbus_type_string;
+Lisp_Object QCdbus_type_object_path, QCdbus_type_signature;
+Lisp_Object QCdbus_type_array, QCdbus_type_variant;
+Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry;
+
/* Hash table which keeps function definitions. */
Lisp_Object Vdbus_registered_functions_table;
@@ -52,7 +63,7 @@ Lisp_Object Vdbus_debug;
/* We use "xd_" and "XD_" as prefix for all internal symbols, because
we don't want to poison other namespaces with "dbus_". */
-/* Raise a Lisp error from a D-Bus error. */
+/* Raise a Lisp error from a D-Bus ERROR. */
#define XD_ERROR(error) \
{ \
char s[1024]; \
@@ -92,58 +103,364 @@ Lisp_Object Vdbus_debug;
#define XD_DEBUG_VALID_LISP_OBJECT_P(object)
#endif
-/* Determine the DBusType of a given Lisp object. It is used to
+/* Check whether TYPE is a basic DBusType. */
+#define XD_BASIC_DBUS_TYPE(type) \
+ ((type == DBUS_TYPE_BYTE) \
+ || (type == DBUS_TYPE_BOOLEAN) \
+ || (type == DBUS_TYPE_INT16) \
+ || (type == DBUS_TYPE_UINT16) \
+ || (type == DBUS_TYPE_INT32) \
+ || (type == DBUS_TYPE_UINT32) \
+ || (type == DBUS_TYPE_INT64) \
+ || (type == DBUS_TYPE_UINT64) \
+ || (type == DBUS_TYPE_DOUBLE) \
+ || (type == DBUS_TYPE_STRING) \
+ || (type == DBUS_TYPE_OBJECT_PATH) \
+ || (type == DBUS_TYPE_SIGNATURE))
+
+/* Determine the DBusType of a given Lisp symbol. OBJECT must be one
+ of the predefined D-Bus type symbols. */
+#define XD_SYMBOL_TO_DBUS_TYPE(object) \
+ ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE \
+ : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN \
+ : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 \
+ : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 \
+ : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 \
+ : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 \
+ : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 \
+ : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 \
+ : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE \
+ : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING \
+ : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH \
+ : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE \
+ : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY \
+ : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT \
+ : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT \
+ : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY \
+ : DBUS_TYPE_INVALID)
+
+/* Check whether a Lisp symbol is a predefined D-Bus type symbol. */
+#define XD_DBUS_TYPE_P(object) \
+ (SYMBOLP (object) && ((XD_SYMBOL_TO_DBUS_TYPE (object) != DBUS_TYPE_INVALID)))
+
+/* Determine the DBusType of a given Lisp OBJECT. It is used to
convert Lisp objects, being arguments of `dbus-call-method' or
`dbus-send-signal', into corresponding C values appended as
arguments to a D-Bus message. */
-#define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \
- (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN : \
- (NATNUMP (object)) ? DBUS_TYPE_UINT32 : \
- (INTEGERP (object)) ? DBUS_TYPE_INT32 : \
- (FLOATP (object)) ? DBUS_TYPE_DOUBLE : \
- (STRINGP (object)) ? DBUS_TYPE_STRING : \
- DBUS_TYPE_INVALID
-
-/* Extract C value from Lisp OBJECT. DTYPE must be a valid DBusType,
- as detected by XD_LISP_OBJECT_TO_DBUS_TYPE. Compound types are not
- supported (yet). It is used to convert Lisp objects, being
- arguments of `dbus-call-method' or `dbus-send-signal', into
- corresponding C values appended as arguments to a D-Bus
- message. */
-char *
-xd_retrieve_value (dtype, object)
- unsigned int dtype;
+#define XD_OBJECT_TO_DBUS_TYPE(object) \
+ ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \
+ : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \
+ : (INTEGERP (object)) ? DBUS_TYPE_INT32 \
+ : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \
+ : (STRINGP (object)) ? DBUS_TYPE_STRING \
+ : (XD_DBUS_TYPE_P (object)) ? XD_SYMBOL_TO_DBUS_TYPE (object) \
+ : (CONSP (object)) ? ((XD_DBUS_TYPE_P (XCAR (object))) \
+ ? XD_SYMBOL_TO_DBUS_TYPE (XCAR (object)) \
+ : DBUS_TYPE_ARRAY) \
+ : DBUS_TYPE_INVALID)
+
+/* Return a list pointer which does not have a Lisp symbol as car. */
+#define XD_NEXT_VALUE(object) \
+ ((XD_DBUS_TYPE_P (XCAR (object))) ? XCDR (object) : object)
+
+/* Compute SIGNATURE of OBJECT. It must have a form that it can be
+ used in dbus_message_iter_open_container. DTYPE is the DBusType
+ the object is related to. It is passed as argument, because it
+ cannot be detected in basic type objects, when they are preceded by
+ a type symbol. PARENT_TYPE is the DBusType of a container this
+ signature is embedded, or DBUS_TYPE_INVALID. It is needed for the
+ check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */
+void
+xd_signature(signature, dtype, parent_type, object)
+ char *signature;
+ unsigned int dtype, parent_type;
Lisp_Object object;
{
+ unsigned int subtype;
+ Lisp_Object elt;
+ char x[DBUS_MAXIMUM_SIGNATURE_LENGTH];
+
+ elt = object;
- XD_DEBUG_VALID_LISP_OBJECT_P (object);
switch (dtype)
{
- case DBUS_TYPE_BOOLEAN:
- XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true");
- return (NILP (object)) ? (char *) FALSE : (char *) TRUE;
+ case DBUS_TYPE_BYTE:
+ case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- XD_DEBUG_MESSAGE ("%d %d", dtype, XUINT (object));
- return (char *) XUINT (object);
+ case DBUS_TYPE_UINT64:
+ CHECK_NATNUM (object);
+ sprintf (signature, "%c", dtype);
+ break;
+
+ case DBUS_TYPE_BOOLEAN:
+ if (!EQ (object, Qt) && !EQ (object, Qnil))
+ wrong_type_argument (intern ("booleanp"), object);
+ sprintf (signature, "%c", dtype);
+ break;
+
+ case DBUS_TYPE_INT16:
case DBUS_TYPE_INT32:
- XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object));
- return (char *) XINT (object);
+ case DBUS_TYPE_INT64:
+ CHECK_NUMBER (object);
+ sprintf (signature, "%c", dtype);
+ break;
+
case DBUS_TYPE_DOUBLE:
- XD_DEBUG_MESSAGE ("%d %d", dtype, XFLOAT (object));
- return (char *) XFLOAT (object);
+ CHECK_FLOAT (object);
+ sprintf (signature, "%c", dtype);
+ break;
+
case DBUS_TYPE_STRING:
- XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object));
- return SDATA (object);
+ case DBUS_TYPE_OBJECT_PATH:
+ case DBUS_TYPE_SIGNATURE:
+ CHECK_STRING (object);
+ sprintf (signature, "%c", dtype);
+ break;
+
+ case DBUS_TYPE_ARRAY:
+ /* Check that all list elements have the same D-Bus type. For
+ complex element types, we just check the container type, not
+ the whole element's signature. */
+ CHECK_CONS (object);
+
+ if (EQ (QCdbus_type_array, XCAR (elt))) /* Type symbol is optional. */
+ elt = XD_NEXT_VALUE (elt);
+ subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
+ xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
+
+ while (!NILP (elt))
+ {
+ if (subtype != XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)))
+ wrong_type_argument (intern ("D-Bus"), XCAR (elt));
+ elt = XCDR (XD_NEXT_VALUE (elt));
+ }
+
+ sprintf (signature, "%c%s", dtype, x);
+ break;
+
+ case DBUS_TYPE_VARIANT:
+ /* Check that there is exactly one list element. */
+ CHECK_CONS (object);
+
+ elt = XD_NEXT_VALUE (elt);
+ subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
+ xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
+
+ if (!NILP (XCDR (XD_NEXT_VALUE (elt))))
+ wrong_type_argument (intern ("D-Bus"),
+ XCAR (XCDR (XD_NEXT_VALUE (elt))));
+
+ sprintf (signature, "%c%s", dtype, x);
+ break;
+
+ case DBUS_TYPE_STRUCT:
+ /* A struct list might contain any number of elements with
+ different types. No further check needed. */
+ CHECK_CONS (object);
+
+ elt = XD_NEXT_VALUE (elt);
+
+ /* Compose the signature from the elements. It is enclosed by
+ parentheses. */
+ sprintf (signature, "%c", DBUS_STRUCT_BEGIN_CHAR );
+ while (!NILP (elt))
+ {
+ subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
+ xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
+ strcat (signature, x);
+ elt = XCDR (XD_NEXT_VALUE (elt));
+ }
+ sprintf (signature, "%s%c", signature, DBUS_STRUCT_END_CHAR);
+ break;
+
+ case DBUS_TYPE_DICT_ENTRY:
+ /* Check that there are exactly two list elements, and the first
+ one is of basic type. The dictionary entry itself must be an
+ element of an array. */
+ CHECK_CONS (object);
+
+ /* Check the parent object type. */
+ if (parent_type != DBUS_TYPE_ARRAY)
+ wrong_type_argument (intern ("D-Bus"), object);
+
+ /* Compose the signature from the elements. It is enclosed by
+ curly braces. */
+ sprintf (signature, "%c", DBUS_DICT_ENTRY_BEGIN_CHAR);
+
+ /* First element. */
+ elt = XD_NEXT_VALUE (elt);
+ subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
+ xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
+ strcat (signature, x);
+
+ if (!XD_BASIC_DBUS_TYPE (subtype))
+ wrong_type_argument (intern ("D-Bus"), XCAR (XD_NEXT_VALUE (elt)));
+
+ /* Second element. */
+ elt = XCDR (XD_NEXT_VALUE (elt));
+ subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
+ xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
+ strcat (signature, x);
+
+ if (!NILP (XCDR (XD_NEXT_VALUE (elt))))
+ wrong_type_argument (intern ("D-Bus"),
+ XCAR (XCDR (XD_NEXT_VALUE (elt))));
+
+ /* Closing signature. */
+ sprintf (signature, "%s%c", signature, DBUS_DICT_ENTRY_END_CHAR);
+ break;
+
default:
- XD_DEBUG_MESSAGE ("DBus-Type %d not supported", dtype);
- return NULL;
+ wrong_type_argument (intern ("D-Bus"), object);
+ }
+
+ XD_DEBUG_MESSAGE ("%s", signature);
+}
+
+/* Append C value, extracted from Lisp OBJECT, to iteration ITER.
+ DTYPE must be a valid DBusType. It is used to convert Lisp
+ objects, being arguments of `dbus-call-method' or
+ `dbus-send-signal', into corresponding C values appended as
+ arguments to a D-Bus message. */
+void
+xd_append_arg (dtype, object, iter)
+ unsigned int dtype;
+ Lisp_Object object;
+ DBusMessageIter *iter;
+{
+ Lisp_Object elt;
+ char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
+ DBusMessageIter subiter;
+ char *value;
+
+ XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", object, Qnil)));
+
+ if (XD_BASIC_DBUS_TYPE (dtype))
+ {
+ switch (dtype)
+ {
+ case DBUS_TYPE_BYTE:
+ XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
+ value = (unsigned char *) XUINT (object);
+ break;
+
+ case DBUS_TYPE_BOOLEAN:
+ XD_DEBUG_MESSAGE ("%c %s", dtype, (NILP (object)) ? "false" : "true");
+ value = (NILP (object))
+ ? (unsigned char *) FALSE : (unsigned char *) TRUE;
+ break;
+
+ case DBUS_TYPE_INT16:
+ XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object));
+ value = (char *) (dbus_int16_t *) XINT (object);
+ break;
+
+ case DBUS_TYPE_UINT16:
+ XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
+ value = (char *) (dbus_uint16_t *) XUINT (object);
+ break;
+
+ case DBUS_TYPE_INT32:
+ XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object));
+ value = (char *) (dbus_int32_t *) XINT (object);
+ break;
+
+ case DBUS_TYPE_UINT32:
+ XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
+ value = (char *) (dbus_uint32_t *) XUINT (object);
+ break;
+
+ case DBUS_TYPE_INT64:
+ XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object));
+ value = (char *) (dbus_int64_t *) XINT (object);
+ break;
+
+ case DBUS_TYPE_UINT64:
+ XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
+ value = (char *) (dbus_int64_t *) XUINT (object);
+ break;
+
+ case DBUS_TYPE_DOUBLE:
+ XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object));
+ value = (char *) (float *) XFLOAT (object);
+ break;
+
+ case DBUS_TYPE_STRING:
+ case DBUS_TYPE_OBJECT_PATH:
+ case DBUS_TYPE_SIGNATURE:
+ XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (object));
+ value = SDATA (object);
+ break;
+ }
+
+ if (!dbus_message_iter_append_basic (iter, dtype, &value))
+ xsignal2 (Qdbus_error,
+ build_string ("Unable to append argument"), object);
+ }
+
+ else /* Compound types. */
+ {
+
+ /* All compound types except array have a type symbol. For
+ array, it is optional. Skip it. */
+ if (!XD_BASIC_DBUS_TYPE (XD_OBJECT_TO_DBUS_TYPE (XCAR (object))))
+ object = XD_NEXT_VALUE (object);
+
+ /* Open new subiteration. */
+ switch (dtype)
+ {
+ case DBUS_TYPE_ARRAY:
+ case DBUS_TYPE_VARIANT:
+ /* A variant has just one element. An array has elements of
+ the same type. Both have been checked already for
+ correct types, it is sufficient to retrieve just the
+ signature of the first element. */
+ xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)),
+ dtype, XCAR (XD_NEXT_VALUE (object)));
+ XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
+ SDATA (format2 ("%s", object, Qnil)));
+ if (!dbus_message_iter_open_container (iter, dtype,
+ signature, &subiter))
+ xsignal3 (Qdbus_error,
+ build_string ("Cannot open container"),
+ make_number (dtype), build_string (signature));
+ break;
+
+ case DBUS_TYPE_STRUCT:
+ case DBUS_TYPE_DICT_ENTRY:
+ /* These containers do not require a signature. */
+ XD_DEBUG_MESSAGE ("%c %s", dtype,
+ SDATA (format2 ("%s", object, Qnil)));
+ if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter))
+ xsignal2 (Qdbus_error,
+ build_string ("Cannot open container"),
+ make_number (dtype));
+ break;
+ }
+
+ /* Loop over list elements. */
+ while (!NILP (object))
+ {
+ dtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (object));
+ object = XD_NEXT_VALUE (object);
+
+ xd_append_arg (dtype, XCAR (object), &subiter);
+
+ object = XCDR (object);
+ }
+
+ /* Close the subiteration. */
+ if (!dbus_message_iter_close_container (iter, &subiter))
+ xsignal2 (Qdbus_error,
+ build_string ("Cannot close container"),
+ make_number (dtype));
}
}
/* Retrieve C value from a DBusMessageIter structure ITER, and return
a converted Lisp object. The type DTYPE of the argument of the
- D-Bus message must be a valid DBusType. Compound D-Bus types are
- partly supported; they result always in a Lisp list. */
+ D-Bus message must be a valid DBusType. Compound D-Bus types
+ result always in a Lisp list. */
Lisp_Object
xd_retrieve_arg (dtype, iter)
unsigned int dtype;
@@ -152,29 +469,66 @@ xd_retrieve_arg (dtype, iter)
switch (dtype)
{
+ case DBUS_TYPE_BYTE:
+ case DBUS_TYPE_INT16:
+ case DBUS_TYPE_UINT16:
+ {
+ dbus_uint16_t val;
+ dbus_message_iter_get_basic (iter, &val);
+ XD_DEBUG_MESSAGE ("%c %d", dtype, val);
+ return make_number (val);
+ }
+
case DBUS_TYPE_BOOLEAN:
{
dbus_bool_t val;
dbus_message_iter_get_basic (iter, &val);
- XD_DEBUG_MESSAGE ("%d %s", dtype, (val == FALSE) ? "false" : "true");
+ XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true");
return (val == FALSE) ? Qnil : Qt;
}
+
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
{
dbus_uint32_t val;
dbus_message_iter_get_basic (iter, &val);
- XD_DEBUG_MESSAGE ("%d %d", dtype, val);
- return make_number (val);
+ if (FIXNUM_OVERFLOW_P (val))
+ XD_DEBUG_MESSAGE ("%c %f", dtype, val)
+ else
+ XD_DEBUG_MESSAGE ("%c %d", dtype, val);
+ return make_fixnum_or_float (val);
+ }
+
+ case DBUS_TYPE_INT64:
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_uint64_t val;
+ dbus_message_iter_get_basic (iter, &val);
+ if (FIXNUM_OVERFLOW_P (val))
+ XD_DEBUG_MESSAGE ("%c %f", dtype, val)
+ else
+ XD_DEBUG_MESSAGE ("%c %d", dtype, val);
+ return make_fixnum_or_float (val);
+ }
+
+ case DBUS_TYPE_DOUBLE:
+ {
+ double val;
+ dbus_message_iter_get_basic (iter, &val);
+ XD_DEBUG_MESSAGE ("%c %f", dtype, val);
+ return make_float (val);
}
+
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
+ case DBUS_TYPE_SIGNATURE:
{
char *val;
dbus_message_iter_get_basic (iter, &val);
- XD_DEBUG_MESSAGE ("%d %s", dtype, val);
+ XD_DEBUG_MESSAGE ("%c %s", dtype, val);
return build_string (val);
}
+
case DBUS_TYPE_ARRAY:
case DBUS_TYPE_VARIANT:
case DBUS_TYPE_STRUCT:
@@ -195,8 +549,9 @@ xd_retrieve_arg (dtype, iter)
}
RETURN_UNGCPRO (Fnreverse (result));
}
+
default:
- XD_DEBUG_MESSAGE ("DBusType %d not supported", dtype);
+ XD_DEBUG_MESSAGE ("DBusType '%c' not supported", dtype);
return Qnil;
}
}
@@ -275,16 +630,33 @@ converted into D-Bus types via the following rules:
integer => DBUS_TYPE_INT32
float => DBUS_TYPE_DOUBLE
string => DBUS_TYPE_STRING
+ list => DBUS_TYPE_ARRAY
-Other Lisp objects are not supported as input arguments of METHOD.
+All arguments can be preceded by a type symbol. For details about
+type symbols, see Info node `(dbus)Type Conversion'.
`dbus-call-method' returns the resulting values of METHOD as a list of
Lisp objects. The type conversion happens the other direction as for
-input arguments. Additionally to the types supported for input
-arguments, the D-Bus compound types DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT,
-DBUS_TYPE_STRUCT and DBUS_TYPE_DICT_ENTRY are accepted. All of them
-are converted into a list of Lisp objects which correspond to the
-elements of the D-Bus container. Example:
+input arguments. It follows the mapping rules:
+
+ DBUS_TYPE_BOOLEAN => t or nil
+ DBUS_TYPE_BYTE => number
+ DBUS_TYPE_UINT16 => number
+ DBUS_TYPE_INT16 => integer
+ DBUS_TYPE_UINT32 => number or float
+ DBUS_TYPE_INT32 => integer or float
+ DBUS_TYPE_UINT64 => number or float
+ DBUS_TYPE_INT64 => integer or float
+ DBUS_TYPE_DOUBLE => float
+ DBUS_TYPE_STRING => string
+ DBUS_TYPE_OBJECT_PATH => string
+ DBUS_TYPE_SIGNATURE => string
+ DBUS_TYPE_ARRAY => list
+ DBUS_TYPE_VARIANT => list
+ DBUS_TYPE_STRUCT => list
+ DBUS_TYPE_DICT_ENTRY => list
+
+Example:
\(dbus-call-method
:session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
@@ -318,7 +690,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
DBusError derror;
unsigned int dtype;
int i;
- char *value;
+ char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
/* Check parameters. */
bus = args[0];
@@ -344,10 +716,10 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
connection = xd_initialize (bus);
/* Create the message. */
- dmessage = dbus_message_new_method_call (SDATA (service),
- SDATA (path),
- SDATA (interface),
- SDATA (method));
+ dmessage = dbus_message_new_method_call ((char *) SDATA (service),
+ (char *) SDATA (path),
+ (char *) SDATA (interface),
+ (char *) SDATA (method));
if (dmessage == NULL)
{
UNGCPRO;
@@ -356,27 +728,26 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
UNGCPRO;
+ /* Initialize parameter list of message. */
+ dbus_message_iter_init_append (dmessage, &iter);
+
/* Append parameters to the message. */
for (i = 5; i < nargs; ++i)
{
XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
XD_DEBUG_MESSAGE ("Parameter%d %s",
- i-4,
- SDATA (format2 ("%s", args[i], Qnil)));
+ i-4, SDATA (format2 ("%s", args[i], Qnil)));
- dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]);
- if (dtype == DBUS_TYPE_INVALID)
- xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]);
+ dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
+ if (XD_DBUS_TYPE_P (args[i]))
+ ++i;
- value = (char *) xd_retrieve_value (dtype, args[i]);
+ /* Check for valid signature. We use DBUS_TYPE_INVALID is
+ indication that there is no parent type. */
+ xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
- if (!dbus_message_append_args (dmessage,
- dtype,
- &value,
- DBUS_TYPE_INVALID))
- xsignal2 (Qdbus_error,
- build_string ("Unable to append argument"), args[i]);
+ xd_append_arg (dtype, args[i], &iter);
}
/* Send the message. */
@@ -441,8 +812,10 @@ converted into D-Bus types via the following rules:
integer => DBUS_TYPE_INT32
float => DBUS_TYPE_DOUBLE
string => DBUS_TYPE_STRING
+ list => DBUS_TYPE_ARRAY
-Other Lisp objects are not supported as arguments of SIGNAL.
+All arguments can be preceded by a type symbol. For details about
+type symbols, see Info node `(dbus)Type Conversion'.
Example:
@@ -459,9 +832,10 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
DBusConnection *connection;
DBusMessage *dmessage;
+ DBusMessageIter iter;
unsigned int dtype;
int i;
- char *value;
+ char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
/* Check parameters. */
bus = args[0];
@@ -487,9 +861,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
connection = xd_initialize (bus);
/* Create the message. */
- dmessage = dbus_message_new_signal (SDATA (path),
- SDATA (interface),
- SDATA (signal));
+ dmessage = dbus_message_new_signal ((char *) SDATA (path),
+ (char *) SDATA (interface),
+ (char *) SDATA (signal));
if (dmessage == NULL)
{
UNGCPRO;
@@ -498,26 +872,25 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
UNGCPRO;
+ /* Initialize parameter list of message. */
+ dbus_message_iter_init_append (dmessage, &iter);
+
/* Append parameters to the message. */
for (i = 5; i < nargs; ++i)
{
XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
XD_DEBUG_MESSAGE ("Parameter%d %s",
- i-4,
- SDATA (format2 ("%s", args[i], Qnil)));
+ i-4, SDATA (format2 ("%s", args[i], Qnil)));
- dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]);
- if (dtype == DBUS_TYPE_INVALID)
- xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]);
+ dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
+ if (XD_DBUS_TYPE_P (args[i]))
+ ++i;
- value = (char *) xd_retrieve_value (dtype, args[i]);
+ /* Check for valid signature. We use DBUS_TYPE_INVALID is
+ indication that there is no parent type. */
+ xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
- if (!dbus_message_append_args (dmessage,
- dtype,
- &value,
- DBUS_TYPE_INVALID))
- xsignal2 (Qdbus_error,
- build_string ("Unable to append argument"), args[i]);
+ xd_append_arg (dtype, args[i], &iter);
}
/* Send the message. The message is just added to the outgoing
@@ -604,10 +977,10 @@ xd_read_message (bus)
while (!NILP (value))
{
key = XCAR (value);
- /* key has the structure (SERVICE UNAME PATH HANDLER). */
+ /* key has the structure (UNAME SERVICE PATH HANDLER). */
if (((uname == NULL)
- || (NILP (XCAR (XCDR (key))))
- || (strcmp (uname, SDATA (XCAR (XCDR (key)))) == 0))
+ || (NILP (XCAR (key)))
+ || (strcmp (uname, SDATA (XCAR (key))) == 0))
&& ((path == NULL)
|| (NILP (XCAR (XCDR (XCDR (key)))))
|| (strcmp (path, SDATA (XCAR (XCDR (XCDR (key))))) == 0))
@@ -648,10 +1021,10 @@ void
xd_read_queued_messages ()
{
- /* Vdbus_registered_functions_table will be made as hash table in
- dbus.el. When it isn't loaded yet, it doesn't make sense to
- handle D-Bus messages. Furthermore, we ignore all Lisp errors
- during the call. */
+ /* Vdbus_registered_functions_table will be initialized as hash
+ table in dbus.el. When this package isn't loaded yet, it doesn't
+ make sense to handle D-Bus messages. Furthermore, we ignore all
+ Lisp errors during the call. */
if (HASH_TABLE_P (Vdbus_registered_functions_table))
{
internal_condition_case_1 (xd_read_message, QCdbus_system_bus,
@@ -687,15 +1060,15 @@ SIGNAL and HANDLER must not be nil. Example:
:system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
"org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler)
- => (:system ":1.3" "/org/freedesktop/Hal/Manager"
- "org.freedesktop.Hal.Manager" "DeviceAdded")
+ => ((:system "org.freedesktop.Hal.Manager" "DeviceAdded")
+ ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler))
`dbus-register-signal' returns an object, which can be used in
`dbus-unregister-signal' for removing the registration. */)
(bus, service, path, interface, signal, handler)
Lisp_Object bus, service, path, interface, signal, handler;
{
- Lisp_Object unique_name, key, value;
+ Lisp_Object uname, key, value;
DBusConnection *connection;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
DBusError derror;
@@ -706,7 +1079,7 @@ SIGNAL and HANDLER must not be nil. Example:
if (!NILP (path)) CHECK_STRING (path);
CHECK_STRING (interface);
CHECK_STRING (signal);
- CHECK_SYMBOL (handler);
+ FUNCTIONP (handler);
/* Retrieve unique name of service. If service is a known name, we
will register for the corresponding unique name, if any. Signals
@@ -716,51 +1089,58 @@ SIGNAL and HANDLER must not be nil. Example:
&& (strlen (SDATA (service)) > 0)
&& (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0)
&& (strncmp (SDATA (service), ":", 1) != 0))
- unique_name = call2 (intern ("dbus-get-name-owner"), bus, service);
+ {
+ uname = call2 (intern ("dbus-get-name-owner"), bus, service);
+ /* When there is no unique name, we mark it with an empty
+ string. */
+ if (NILP (uname))
+ uname = build_string ("");
+ }
else
- unique_name = service;
+ uname = service;
- /* Open a connection to the bus. */
- connection = xd_initialize (bus);
+ /* Create a matching rule if the unique name exists (when no
+ wildcard). */
+ if (NILP (uname) || (strlen (SDATA (uname)) > 0))
+ {
+ /* Open a connection to the bus. */
+ connection = xd_initialize (bus);
- /* Create a rule to receive related signals. */
- sprintf (rule,
- "type='signal',interface='%s',member=%s%",
- SDATA (interface),
- SDATA (signal));
+ /* Create a rule to receive related signals. */
+ sprintf (rule,
+ "type='signal',interface='%s',member='%s'",
+ SDATA (interface),
+ SDATA (signal));
- /* Add unique name and path to the rule if they are non-nil. */
- if (!NILP (unique_name))
- sprintf (rule, "%s,sender='%s'%", rule, SDATA (unique_name));
+ /* Add unique name and path to the rule if they are non-nil. */
+ if (!NILP (uname))
+ sprintf (rule, "%s,sender='%s'", rule, SDATA (uname));
- if (!NILP (path))
- sprintf (rule, "%s,path='%s'", rule, SDATA (path));
+ if (!NILP (path))
+ sprintf (rule, "%s,path='%s'", rule, SDATA (path));
- /* Add the rule to the bus. */
- dbus_error_init (&derror);
- dbus_bus_add_match (connection, rule, &derror);
- if (dbus_error_is_set (&derror))
- XD_ERROR (derror);
+ /* Add the rule to the bus. */
+ dbus_error_init (&derror);
+ dbus_bus_add_match (connection, rule, &derror);
+ if (dbus_error_is_set (&derror))
+ XD_ERROR (derror);
- XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule);
+ XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule);
+ }
/* Create a hash table entry. */
key = list3 (bus, interface, signal);
value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
- if (NILP (Fmember (list4 (service, unique_name, path, handler), value)))
+ if (NILP (Fmember (list4 (uname, service, path, handler), value)))
Fputhash (key,
- Fcons (list4 (service, unique_name, path, handler), value),
+ Fcons (list4 (uname, service, path, handler), value),
Vdbus_registered_functions_table);
- /* Return key. */
- return key;
+ /* Return object. */
+ return list2 (key, list3 (service, path, handler));
}
-/* The current implementation removes ALL registered functions for a
- given signal. Shouldn't be a problem in general, but there might
- be cases it is not desired. Maybe we can refine the
- implementation. */
DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal,
1, 1, 0,
doc: /* Unregister OBJECT from the D-Bus.
@@ -768,9 +1148,37 @@ OBJECT must be the result of a preceding `dbus-register-signal' call. */)
(object)
Lisp_Object object;
{
+ Lisp_Object value;
+ struct gcpro gcpro1;
+
+ /* Check parameter. */
+ CONSP (object) && (!NILP (XCAR (object))) && CONSP (XCDR (object));
- /* Unintern the signal symbol. */
- Fremhash (object, Vdbus_registered_functions_table);
+ /* Find the corresponding entry in the hash table. */
+ value = Fgethash (XCAR (object), Vdbus_registered_functions_table, Qnil);
+
+ /* Loop over the registered functions. */
+ while (!NILP (value))
+ {
+ GCPRO1 (value);
+
+ /* (car value) has the structure (UNAME SERVICE PATH HANDLER).
+ (cdr object) has the structure ((SERVICE PATH HANDLER) ...). */
+ if (!NILP (Fequal (XCDR (XCAR (value)), XCAR (XCDR (object)))))
+ {
+ /* Compute new hash value. */
+ value = Fdelete (XCAR (value),
+ Fgethash (XCAR (object),
+ Vdbus_registered_functions_table, Qnil));
+ if (NILP (value))
+ Fremhash (XCAR (object), Vdbus_registered_functions_table);
+ else
+ Fputhash (XCAR (object), value, Vdbus_registered_functions_table);
+ RETURN_UNGCPRO (Qt);
+ }
+ UNGCPRO;
+ value = XCDR (value);
+ }
/* Return. */
return Qnil;
@@ -814,20 +1222,68 @@ syms_of_dbusbind ()
QCdbus_session_bus = intern (":session");
staticpro (&QCdbus_session_bus);
+ QCdbus_type_byte = intern (":byte");
+ staticpro (&QCdbus_type_byte);
+
+ QCdbus_type_boolean = intern (":boolean");
+ staticpro (&QCdbus_type_boolean);
+
+ QCdbus_type_int16 = intern (":int16");
+ staticpro (&QCdbus_type_int16);
+
+ QCdbus_type_uint16 = intern (":uint16");
+ staticpro (&QCdbus_type_uint16);
+
+ QCdbus_type_int32 = intern (":int32");
+ staticpro (&QCdbus_type_int32);
+
+ QCdbus_type_uint32 = intern (":uint32");
+ staticpro (&QCdbus_type_uint32);
+
+ QCdbus_type_int64 = intern (":int64");
+ staticpro (&QCdbus_type_int64);
+
+ QCdbus_type_uint64 = intern (":uint64");
+ staticpro (&QCdbus_type_uint64);
+
+ QCdbus_type_double = intern (":double");
+ staticpro (&QCdbus_type_double);
+
+ QCdbus_type_string = intern (":string");
+ staticpro (&QCdbus_type_string);
+
+ QCdbus_type_object_path = intern (":object-path");
+ staticpro (&QCdbus_type_object_path);
+
+ QCdbus_type_signature = intern (":signature");
+ staticpro (&QCdbus_type_signature);
+
+ QCdbus_type_array = intern (":array");
+ staticpro (&QCdbus_type_array);
+
+ QCdbus_type_variant = intern (":variant");
+ staticpro (&QCdbus_type_variant);
+
+ QCdbus_type_struct = intern (":struct");
+ staticpro (&QCdbus_type_struct);
+
+ QCdbus_type_dict_entry = intern (":dict-entry");
+ staticpro (&QCdbus_type_dict_entry);
+
DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table,
doc: /* Hash table of registered functions for D-Bus.
-The key in the hash table is the list (BUS MEMBER INTERFACE). BUS is
+The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is
either the symbol `:system' or the symbol `:session'. INTERFACE is a
string which denotes a D-Bus interface, and MEMBER, also a string, is
either a method or a signal INTERFACE is offering. All arguments but
BUS must not be nil.
-The value in the hash table is a list of triple lists
-\((SERVICE UNAME PATH HANDLER) (SERVICE UNAME PATH HANDLER) ...).
+The value in the hash table is a list of quadruple lists
+\((UNAME SERVICE PATH HANDLER) (UNAME SERVICE PATH HANDLER) ...).
SERVICE is the service name as registered, UNAME is the corresponding
unique name. PATH is the object path of the sending object. All of
-them be nil, which means a wildcard then. HANDLER is the function to
-be called when a D-Bus message, which matches the key criteria,
+them can be nil, which means a wildcard then. HANDLER is the function
+to be called when a D-Bus message, which matches the key criteria,
arrives. */);
/* We initialize Vdbus_registered_functions_table in dbus.el,
because we need to define a hash table function first. */
diff --git a/src/fileio.c b/src/fileio.c
index 51a40e66db9..4dfb0d24796 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -21,6 +21,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
#include <config.h>
+#include <limits.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
@@ -3882,7 +3883,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
overflow. The calculations below double the file size
twice, so check that it can be multiplied by 4 safely. */
if (XINT (end) != st.st_size
- || ((int) st.st_size * 4) / 4 != st.st_size)
+ || st.st_size > INT_MAX / 4)
error ("Maximum buffer size exceeded");
/* The file size returned from stat may be zero, but data
diff --git a/src/macmenu.c b/src/macmenu.c
index aa0be0bdc2e..616d136465a 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -3272,7 +3272,8 @@ fill_menubar (wv, deep_p)
}
#endif /* !TARGET_API_MAC_CARBON */
}
- else
+
+ if (!menu)
{
#if TARGET_API_MAC_CARBON
err = CreateNewMenu (id, 0, &menu);
diff --git a/src/process.c b/src/process.c
index c2f0c82a6a8..542bf4fdda5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -631,7 +631,7 @@ make_process (name)
p->tick = 0;
p->update_tick = 0;
p->pid = 0;
- p->pty_flag = 0;
+ p->pty_flag = Qnil;
p->raw_status_new = 0;
p->status = Qrun;
p->mark = Fmake_marker ();
diff --git a/src/w32fns.c b/src/w32fns.c
index 8ddf8d0f74d..8b2b865c6d3 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -3144,7 +3144,8 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
{
/* Forward asciified character sequence. */
post_character_message
- (hwnd, WM_CHAR, key.uChar.AsciiChar, lParam,
+ (hwnd, WM_CHAR,
+ (unsigned char) key.uChar.AsciiChar, lParam,
w32_get_key_modifiers (wParam, lParam));
w32_kbd_patch_key (&key);
}
diff --git a/src/xdisp.c b/src/xdisp.c
index 5f0ff5e08f9..8e24fbacb4e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23837,6 +23837,24 @@ phys_cursor_in_rect_p (w, r)
{
XRectangle cr, result;
struct glyph *cursor_glyph;
+ struct glyph_row *row;
+
+ if (w->phys_cursor.vpos >= 0
+ && w->phys_cursor.vpos < w->current_matrix->nrows
+ && (row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos),
+ row->enabled_p)
+ && row->cursor_in_fringe_p)
+ {
+ /* Cursor is in the fringe. */
+ cr.x = window_box_right_offset (w,
+ (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+ ? RIGHT_MARGIN_AREA
+ : TEXT_AREA));
+ cr.y = row->y;
+ cr.width = WINDOW_RIGHT_FRINGE_WIDTH (w);
+ cr.height = row->height;
+ return x_intersect_rectangles (&cr, r, &result);
+ }
cursor_glyph = get_phys_cursor_glyph (w);
if (cursor_glyph)