projects
/
emacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1178f98
)
Use a better buffer size in emacs_perror
author
Paul Eggert
<eggert@cs.ucla.edu>
Sat, 13 Jul 2019 19:31:41 +0000
(12:31 -0700)
committer
Paul Eggert
<eggert@cs.ucla.edu>
Sat, 13 Jul 2019 23:53:21 +0000
(16:53 -0700)
* src/sysdep.c (emacs_perror): Since the buffer is for avoiding
interleaving, size it via PIPE_BUF not BUFSIZ.
* src/sysstdio.h (PIPE_BUF): Provide a default.
src/sysdep.c
patch
|
blob
|
history
src/sysstdio.h
patch
|
blob
|
history
diff --git
a/src/sysdep.c
b/src/sysdep.c
index 4c3d546962c92f858418058529ce67325ac958be..9301405943b41c44c97b89b2023bcead6c0ab28a 100644
(file)
--- a/
src/sysdep.c
+++ b/
src/sysdep.c
@@
-2711,10
+2711,10
@@
emacs_perror (char const *message)
? initial_argv[0] : "emacs");
/* Write it out all at once, if it's short; this is less likely to
be interleaved with other output. */
- char buf[
BUFSIZ
];
+ char buf[
min (PIPE_BUF, MAX_ALLOCA)
];
int nbytes = snprintf (buf, sizeof buf, "%s: %s: %s\n",
command, message, error_string);
- if (0 <= nbytes && nbytes <
BUFSIZ
)
+ if (0 <= nbytes && nbytes <
sizeof buf
)
emacs_write (STDERR_FILENO, buf, nbytes);
else
{
diff --git
a/src/sysstdio.h
b/src/sysstdio.h
index 5303e8a15b200e6601457329916242027c7c2089..637f5fdfa6d06ab85d572243e4ed01b7fa977e45 100644
(file)
--- a/
src/sysstdio.h
+++ b/
src/sysstdio.h
@@
-21,6
+21,7
@@
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#define EMACS_SYSSTDIO_H
#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
#include "unlocked-io.h"
@@
-38,4
+39,8
@@
extern void close_output_streams (void);
# define FOPEN_TEXT ""
#endif
+#ifndef PIPE_BUF
+ #define PIPE_BUF MAX_ALLOCA
+#endif
+
#endif /* EMACS_SYSSTDIO_H */