aboutsummaryrefslogtreecommitdiff
path: root/libcpp/errors.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-11-19 08:27:12 +0000
committerJakub Jelinek <jakub@redhat.com>2015-11-19 08:27:12 +0000
commitf6f94390aa0e04d3724a1f7b341bc3ca6973c669 (patch)
tree5835d3decb0a09480820c64a42a01462dccceb96 /libcpp/errors.c
parent00a8002cbb6d4849111c86ce4912580b0044340b (diff)
PR preprocessor/60736
* include/cpplib.h (cpp_errno_filename): New prototype. * errors.c (cpp_errno): Don't handle msgid "" specially, use _(msgid) instead of msgid as argument to cpp_error. (cpp_errno_filename): New function. * files.c (read_file_guts): Use cpp_errno_filename instead of cpp_errno. (open_file_failed): Likewise. Use file->name if file->path is NULL in diagnostics. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@230591 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/errors.c')
-rw-r--r--libcpp/errors.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libcpp/errors.c b/libcpp/errors.c
index 8790e10f5c8..c27a417e886 100644
--- a/libcpp/errors.c
+++ b/libcpp/errors.c
@@ -230,8 +230,18 @@ cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason,
bool
cpp_errno (cpp_reader *pfile, int level, const char *msgid)
{
- if (msgid[0] == '\0')
- msgid = _("stdout");
+ return cpp_error (pfile, level, "%s: %s", _(msgid), xstrerror (errno));
+}
+
+/* Print a warning or error, depending on the value of LEVEL. Include
+ information from errno. Unlike cpp_errno, the argument is a filename
+ that is not localized, but "" is replaced with localized "stdout". */
+
+bool
+cpp_errno_filename (cpp_reader *pfile, int level, const char *filename)
+{
+ if (filename[0] == '\0')
+ filename = _("stdout");
- return cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno));
+ return cpp_error (pfile, level, "%s: %s", filename, xstrerror (errno));
}