diff options
| author | Paul Eggert | 2015-08-18 16:17:30 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-08-18 16:24:56 -0700 |
| commit | 636736861688abe73cc5dd4181fdb66de3fd8cfd (patch) | |
| tree | 94e6780e22be312f57d32ef1b8768b4708c8cc45 /src/lread.c | |
| parent | 345284f5e9eebb07536d12c08c72f1bab02ea55e (diff) | |
| download | emacs-636736861688abe73cc5dd4181fdb66de3fd8cfd.tar.gz emacs-636736861688abe73cc5dd4181fdb66de3fd8cfd.zip | |
Fix file name encodings in diagnostics
Also, close some minor races when opening image files, by opening
them once instead of multiple times.
* src/gtkutil.c (xg_get_image_for_pixmap):
* src/image.c (xpm_load, tiff_load, gif_load, imagemagick_load)
(svg_load):
* src/nsimage.m (allocInitFromFile:):
* src/xfns.c (xg_set_icon):
Encode file name, since x_find_image_file no longer does that.
* src/image.c (x_find_image_fd): New function.
(x_find_image_file): Use it. Do not encode resulting file name,
since callers sometimes need it decoded.
(slurp_file): File arg is now a fd, not a file name.
All callers changed. This saves us having to open the file twice.
(xbm_load, xpm_load, pbm_load, png_load_body, jpeg_load_body)
(svg_load):
Use x_find_image_fd and fdopen to save a file-open.
Report file name that failed.
* src/lread.c (openp): If PREDICATE is t, open the file in binary mode.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lread.c b/src/lread.c index ebd594c1a16..77a62118a39 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1403,7 +1403,8 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */) | |||
| 1403 | SUFFIXES is a list of strings containing possible suffixes. | 1403 | SUFFIXES is a list of strings containing possible suffixes. |
| 1404 | The empty suffix is automatically added if the list is empty. | 1404 | The empty suffix is automatically added if the list is empty. |
| 1405 | 1405 | ||
| 1406 | PREDICATE non-nil means don't open the files, | 1406 | PREDICATE t means the files are binary. |
| 1407 | PREDICATE non-nil and non-t means don't open the files, | ||
| 1407 | just look for one that satisfies the predicate. In this case, | 1408 | just look for one that satisfies the predicate. In this case, |
| 1408 | return 1 on success. The predicate can be a lisp function or | 1409 | return 1 on success. The predicate can be a lisp function or |
| 1409 | an integer to pass to `access' (in which case file-name-handlers | 1410 | an integer to pass to `access' (in which case file-name-handlers |
| @@ -1418,7 +1419,7 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */) | |||
| 1418 | 1419 | ||
| 1419 | If NEWER is true, try all SUFFIXes and return the result for the | 1420 | If NEWER is true, try all SUFFIXes and return the result for the |
| 1420 | newest file that exists. Does not apply to remote files, | 1421 | newest file that exists. Does not apply to remote files, |
| 1421 | or if PREDICATE is specified. */ | 1422 | or if a non-nil and non-t PREDICATE is specified. */ |
| 1422 | 1423 | ||
| 1423 | int | 1424 | int |
| 1424 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | 1425 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, |
| @@ -1520,10 +1521,11 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1520 | else | 1521 | else |
| 1521 | string = make_string (fn, fnlen); | 1522 | string = make_string (fn, fnlen); |
| 1522 | handler = Ffind_file_name_handler (string, Qfile_exists_p); | 1523 | handler = Ffind_file_name_handler (string, Qfile_exists_p); |
| 1523 | if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate)) | 1524 | if ((!NILP (handler) || (!NILP (predicate) && !EQ (predicate, Qt))) |
| 1525 | && !NATNUMP (predicate)) | ||
| 1524 | { | 1526 | { |
| 1525 | bool exists; | 1527 | bool exists; |
| 1526 | if (NILP (predicate)) | 1528 | if (NILP (predicate) || EQ (predicate, Qt)) |
| 1527 | exists = !NILP (Ffile_readable_p (string)); | 1529 | exists = !NILP (Ffile_readable_p (string)); |
| 1528 | else | 1530 | else |
| 1529 | { | 1531 | { |
| @@ -1577,7 +1579,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, | |||
| 1577 | } | 1579 | } |
| 1578 | else | 1580 | else |
| 1579 | { | 1581 | { |
| 1580 | fd = emacs_open (pfn, O_RDONLY, 0); | 1582 | int oflags = O_RDONLY + (NILP (predicate) ? 0 : O_BINARY); |
| 1583 | fd = emacs_open (pfn, oflags, 0); | ||
| 1581 | if (fd < 0) | 1584 | if (fd < 0) |
| 1582 | { | 1585 | { |
| 1583 | if (errno != ENOENT) | 1586 | if (errno != ENOENT) |