summaryrefslogtreecommitdiff
path: root/src/gfilenotify.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gfilenotify.c')
-rw-r--r--src/gfilenotify.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 1e0f4160816..ddb19770c3c 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -18,7 +18,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
-#ifdef HAVE_GFILENOTIFY
#include <stdio.h>
#include <gio/gio.h>
#include "lisp.h"
@@ -77,7 +76,6 @@ dir_monitor_callback (GFileMonitor *monitor,
/* Determine callback function. */
monitor_object = make_pointer_integer (monitor);
- eassert (INTEGERP (monitor_object));
watch_object = assq_no_quit (monitor_object, watch_list);
if (CONSP (watch_object))
@@ -87,11 +85,11 @@ dir_monitor_callback (GFileMonitor *monitor,
/* Check, whether event_type is expected. */
flags = XCAR (XCDR (XCDR (watch_object)));
- if ((!NILP (Fmember (Qchange, flags)) &&
- !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint,
- Qdeleted, Qcreated, Qmoved)))) ||
- (!NILP (Fmember (Qattribute_change, flags)) &&
- ((EQ (symbol, Qattribute_changed)))))
+ if ((!NILP (Fmember (Qchange, flags))
+ && !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint,
+ Qdeleted, Qcreated, Qmoved))))
+ || (!NILP (Fmember (Qattribute_change, flags))
+ && EQ (symbol, Qattribute_changed)))
{
/* Construct an event. */
EVENT_INIT (event);
@@ -109,9 +107,9 @@ dir_monitor_callback (GFileMonitor *monitor,
}
/* Cancel monitor if file or directory is deleted. */
- if (!NILP (Fmember (symbol, list2 (Qdeleted, Qmoved))) &&
- (strcmp (name, SSDATA (XCAR (XCDR (watch_object)))) == 0) &&
- !g_file_monitor_is_cancelled (monitor))
+ if (!NILP (Fmember (symbol, list2 (Qdeleted, Qmoved)))
+ && strcmp (name, SSDATA (XCAR (XCDR (watch_object)))) == 0
+ && !g_file_monitor_is_cancelled (monitor))
g_file_monitor_cancel (monitor);
}
@@ -203,10 +201,10 @@ will be reported only in case of the `moved' event. */)
if (! monitor)
xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
- Lisp_Object watch_descriptor = make_pointer_integer (monitor);
+ Lisp_Object watch_descriptor = make_pointer_integer_unsafe (monitor);
- /* Check the dicey assumption that make_pointer_integer is safe. */
- if (! INTEGERP (watch_descriptor))
+ if (! (FIXNUMP (watch_descriptor)
+ && XFIXNUMPTR (watch_descriptor) == monitor))
{
g_object_unref (monitor);
xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
@@ -239,12 +237,12 @@ WATCH-DESCRIPTOR should be an object returned by `gfile-add-watch'. */)
xsignal2 (Qfile_notify_error, build_string ("Not a watch descriptor"),
watch_descriptor);
- eassert (INTEGERP (watch_descriptor));
- GFileMonitor *monitor = XINTPTR (watch_descriptor);
- if (!g_file_monitor_is_cancelled (monitor) &&
- !g_file_monitor_cancel (monitor))
- xsignal2 (Qfile_notify_error, build_string ("Could not rm watch"),
- watch_descriptor);
+ eassert (FIXNUMP (watch_descriptor));
+ GFileMonitor *monitor = XFIXNUMPTR (watch_descriptor);
+ if (!g_file_monitor_is_cancelled (monitor)
+ && !g_file_monitor_cancel (monitor))
+ xsignal2 (Qfile_notify_error, build_string ("Could not rm watch"),
+ watch_descriptor);
/* Remove watch descriptor from watch list. */
watch_list = Fdelq (watch_object, watch_list);
@@ -271,7 +269,7 @@ invalid. */)
return Qnil;
else
{
- GFileMonitor *monitor = XINTPTR (watch_descriptor);
+ GFileMonitor *monitor = XFIXNUMPTR (watch_descriptor);
return g_file_monitor_is_cancelled (monitor) ? Qnil : Qt;
}
}
@@ -290,7 +288,7 @@ If WATCH-DESCRIPTOR is not valid, nil is returned. */)
return Qnil;
else
{
- GFileMonitor *monitor = XINTPTR (watch_descriptor);
+ GFileMonitor *monitor = XFIXNUMPTR (watch_descriptor);
return intern (G_OBJECT_TYPE_NAME (monitor));
}
}
@@ -334,7 +332,4 @@ syms_of_gfilenotify (void)
staticpro (&watch_list);
Fprovide (intern_c_string ("gfilenotify"), Qnil);
-
}
-
-#endif /* HAVE_GFILENOTIFY */