[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master c762d33 1/2: Use common report_file_notify_error fu
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master c762d33 1/2: Use common report_file_notify_error function |
Date: |
Wed, 16 Sep 2015 13:51:25 +0000 |
branch: master
commit c762d3305cbd429606ef9f51f62b9bb3f36d00f2
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Use common report_file_notify_error function
* src/fileio.c (report_file_notify_error): New function.
* src/inotify.c (report_inotify_error): Remove function.
(inotify_callback, symbol_to_inotifymask, Finotify_add_watch)
(Finotify_rm_watch): Use report_file_notify_error.
* src/lisp.h (report_file_notify_error): Declare external function.
* src/w32notify.c (report_w32notify_error): Remove function.
(Fw32notify_add_watch, Fw32notify_rm_watch):
Use report_file_notify_error.
---
src/fileio.c | 16 ++++++++++++++++
src/inotify.c | 30 +++++++-----------------------
src/lisp.h | 1 +
src/w32notify.c | 29 +++++++----------------------
4 files changed, 31 insertions(+), 45 deletions(-)
diff --git a/src/fileio.c b/src/fileio.c
index d4341f8..69933cc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -210,6 +210,22 @@ report_file_error (char const *string, Lisp_Object name)
report_file_errno (string, name, errno);
}
+/* Like report_file_error, but reports a file-notify-error instead. */
+
+void
+report_file_notify_error (const char *string, Lisp_Object name)
+{
+ Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
+ synchronize_system_messages_locale ();
+ char *str = strerror (errno);
+ Lisp_Object errstring
+ = code_convert_string_norecord (build_unibyte_string (str),
+ Vlocale_coding_system, 0);
+ Lisp_Object errdata = Fcons (errstring, data);
+
+ xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
+}
+
void
close_file_unwind (int fd)
{
diff --git a/src/inotify.c b/src/inotify.c
index 3eda877..be8c1dd 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -116,21 +116,6 @@ inotifyevent_to_event (Lisp_Object watch_object, struct
inotify_event const *ev)
XCDR (watch_object));
}
-/* Like report_file_error, but reports a file-notify-error instead. */
-static _Noreturn void
-report_inotify_error (const char *string, Lisp_Object name)
-{
- Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
- synchronize_system_messages_locale ();
- char *str = strerror (errno);
- Lisp_Object errstring
- = code_convert_string_norecord (build_unibyte_string (str),
- Vlocale_coding_system, 0);
- Lisp_Object errdata = Fcons (errstring, data);
-
- xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
-}
-
/* This callback is called when the FD is available for read. The inotify
events are read from FD and converted into input_events. */
static void
@@ -145,15 +130,14 @@ inotify_callback (int fd, void *_)
to_read = 0;
if (ioctl (fd, FIONREAD, &to_read) == -1)
- report_inotify_error ("Error while trying to retrieve file system events",
- Qnil);
+ report_file_notify_error ("Error while retrieving file system events",
+ Qnil);
buffer = xmalloc (to_read);
n = read (fd, buffer, to_read);
if (n < 0)
{
xfree (buffer);
- report_inotify_error ("Error while trying to read file system events",
- Qnil);
+ report_file_notify_error ("Error while reading file system events",
Qnil);
}
EVENT_INIT (event);
@@ -231,7 +215,7 @@ symbol_to_inotifymask (Lisp_Object symb)
else
{
errno = EINVAL;
- report_inotify_error ("Unknown aspect", symb);
+ report_file_notify_error ("Unknown aspect", symb);
}
}
@@ -324,7 +308,7 @@ is managed internally and there is no corresponding
inotify_init. Use
{
inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC);
if (inotifyfd < 0)
- report_inotify_error ("File watching (inotify) is not available", Qnil);
+ report_file_notify_error ("File watching is not available", Qnil);
watch_list = Qnil;
add_read_fd (inotifyfd, &inotify_callback, NULL);
}
@@ -333,7 +317,7 @@ is managed internally and there is no corresponding
inotify_init. Use
encoded_file_name = ENCODE_FILE (file_name);
watchdesc = inotify_add_watch (inotifyfd, SSDATA (encoded_file_name), mask);
if (watchdesc == -1)
- report_inotify_error ("Could not add watch for file", file_name);
+ report_file_notify_error ("Could not add watch for file", file_name);
watch_descriptor = make_watch_descriptor (watchdesc);
@@ -362,7 +346,7 @@ See inotify_rm_watch(2) for more information.
int wd = XINT (watch_descriptor);
if (inotify_rm_watch (inotifyfd, wd) == -1)
- report_inotify_error ("Could not rm watch", watch_descriptor);
+ report_file_notify_error ("Could not rm watch", watch_descriptor);
/* Remove watch descriptor from watch list. */
watch_object = Fassoc (watch_descriptor, watch_list);
diff --git a/src/lisp.h b/src/lisp.h
index 71630ed..acbd679 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3840,6 +3840,7 @@ extern void fclose_unwind (void *);
extern void restore_point_unwind (Lisp_Object);
extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
extern _Noreturn void report_file_error (const char *, Lisp_Object);
+extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
extern bool internal_delete_file (Lisp_Object);
extern Lisp_Object emacs_readlinkat (int, const char *);
extern bool file_directory_p (const char *);
diff --git a/src/w32notify.c b/src/w32notify.c
index a6b5c19..e822d95 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -464,21 +464,6 @@ filter_list_to_flags (Lisp_Object filter_list)
return flags;
}
-/* Like report_file_error, but reports a file-notify-error instead. */
-static void
-report_w32notify_error (const char *string, Lisp_Object name)
-{
- Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
- synchronize_system_messages_locale ();
- char *str = strerror (errno);
- Lisp_Object errstring
- = code_convert_string_norecord (build_unibyte_string (str),
- Vlocale_coding_system, 0);
- Lisp_Object errdata = Fcons (errstring, data);
-
- xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
-}
-
DEFUN ("w32notify-add-watch", Fw32notify_add_watch,
Sw32notify_add_watch, 3, 3, 0,
doc: /* Add a watch for filesystem events pertaining to FILE.
@@ -543,8 +528,8 @@ generate notifications correctly, though. */)
|| (w32_major_version == 5 && w32_major_version < 1))
{
errno = ENOSYS;
- report_w32notify_error ("Watching filesystem events is not supported",
- Qnil);
+ report_file_notify_error ("Watching filesystem events is not supported",
+ Qnil);
}
/* filenotify.el always passes us a directory, either the parent
@@ -588,11 +573,11 @@ generate notifications correctly, though. */)
Vlocale_coding_system, 0);
else
lisp_errstr = build_string (errstr);
- report_w32notify_error ("Cannot watch file",
- Fcons (lisp_errstr, Fcons (file, Qnil)));
+ report_file_notify_error ("Cannot watch file",
+ Fcons (lisp_errstr, Fcons (file, Qnil)));
}
else
- report_w32notify_error ("Cannot watch file", Fcons (file, Qnil));
+ report_file_notify_error ("Cannot watch file", Fcons (file, Qnil));
}
/* Store watch object in watch list. */
watch_descriptor = make_pointer_integer (dirwatch);
@@ -626,8 +611,8 @@ WATCH-DESCRIPTOR should be an object returned by
`w32notify-add-watch'. */)
}
if (status == -1)
- report_w32notify_error ("Invalid watch descriptor", Fcons
(watch_descriptor,
- Qnil));
+ report_file_notify_error ("Invalid watch descriptor",
+ Fcons (watch_descriptor, Qnil));
return Qnil;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master c762d33 1/2: Use common report_file_notify_error function,
Michael Albinus <=