OLD | NEW |
1 /* Copyright (C) 1993,1994,1995,1997,2000,2004,2005 | 1 /* Copyright (C) 1993,1994,1995,1997,2000,2004,2005 |
2 Free Software Foundation, Inc. | 2 Free Software Foundation, Inc. |
3 This file is part of the GNU C Library. | 3 This file is part of the GNU C Library. |
4 | 4 |
5 The GNU C Library is free software; you can redistribute it and/or | 5 The GNU C Library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Lesser General Public | 6 modify it under the terms of the GNU Lesser General Public |
7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
8 version 2.1 of the License, or (at your option) any later version. | 8 version 2.1 of the License, or (at your option) any later version. |
9 | 9 |
10 The GNU C Library is distributed in the hope that it will be useful, | 10 The GNU C Library is distributed in the hope that it will be useful, |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include <sysdep.h> | 28 #include <sysdep.h> |
29 #include <unistd.h> | 29 #include <unistd.h> |
30 #include <sys/syslog.h> | 30 #include <sys/syslog.h> |
31 #include <sys/uio.h> | 31 #include <sys/uio.h> |
32 #include <not-cancel.h> | 32 #include <not-cancel.h> |
33 | 33 |
34 #ifdef FATAL_PREPARE_INCLUDE | 34 #ifdef FATAL_PREPARE_INCLUDE |
35 #include FATAL_PREPARE_INCLUDE | 35 #include FATAL_PREPARE_INCLUDE |
36 #endif | 36 #endif |
37 | 37 |
38 struct str_list | 38 struct __str_list |
39 { | 39 { |
40 const char *str; | 40 const char *str; |
41 size_t len; | 41 size_t len; |
42 struct str_list *next; | 42 struct __str_list *next; |
43 }; | 43 }; |
44 | 44 |
45 | 45 |
46 /* Abort with an error message. */ | 46 /* Abort with an error message. */ |
47 void | 47 void |
48 __libc_message (int do_abort, const char *fmt, ...) | 48 __libc_message (int do_abort, const char *fmt, ...) |
49 { | 49 { |
50 va_list ap; | 50 va_list ap; |
51 va_list ap_copy; | 51 va_list ap_copy; |
52 int fd = -1; | 52 int fd = -1; |
53 | 53 |
54 va_start (ap, fmt); | 54 va_start (ap, fmt); |
55 va_copy (ap_copy, ap); | 55 va_copy (ap_copy, ap); |
56 | 56 |
57 #ifdef FATAL_PREPARE | 57 #ifdef FATAL_PREPARE |
58 FATAL_PREPARE; | 58 FATAL_PREPARE; |
59 #endif | 59 #endif |
60 | 60 |
61 /* Open a descriptor for /dev/tty unless the user explicitly | 61 /* Open a descriptor for /dev/tty unless the user explicitly |
62 requests errors on standard error. */ | 62 requests errors on standard error. */ |
63 const char *on_2 = __secure_getenv ("LIBC_FATAL_STDERR_"); | 63 const char *on_2 = __secure_getenv ("LIBC_FATAL_STDERR_"); |
64 if (on_2 == NULL || *on_2 == '\0') | 64 if (on_2 == NULL || *on_2 == '\0') |
65 fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY); | 65 fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY); |
66 | 66 |
67 if (fd == -1) | 67 if (fd == -1) |
68 fd = STDERR_FILENO; | 68 fd = STDERR_FILENO; |
69 | 69 |
70 struct str_list *list = NULL; | 70 struct __str_list *list = NULL; |
71 int nlist = 0; | 71 int nlist = 0; |
72 | 72 |
73 const char *cp = fmt; | 73 const char *cp = fmt; |
74 while (*cp != '\0') | 74 while (*cp != '\0') |
75 { | 75 { |
76 /* Find the next "%s" or the end of the string. */ | 76 /* Find the next "%s" or the end of the string. */ |
77 const char *next = cp; | 77 const char *next = cp; |
78 while (next[0] != '%' || next[1] != 's') | 78 while (next[0] != '%' || next[1] != 's') |
79 { | 79 { |
80 next = __strchrnul (next + 1, '%'); | 80 next = __strchrnul (next + 1, '%'); |
(...skipping 11 matching lines...) Expand all Loading... |
92 len = strlen (str); | 92 len = strlen (str); |
93 cp += 2; | 93 cp += 2; |
94 } | 94 } |
95 else | 95 else |
96 { | 96 { |
97 str = cp; | 97 str = cp; |
98 len = next - cp; | 98 len = next - cp; |
99 cp = next; | 99 cp = next; |
100 } | 100 } |
101 | 101 |
102 struct str_list *newp = alloca (sizeof (struct str_list)); | 102 struct __str_list *newp = alloca (sizeof (struct __str_list)); |
103 newp->str = str; | 103 newp->str = str; |
104 newp->len = len; | 104 newp->len = len; |
105 newp->next = list; | 105 newp->next = list; |
106 list = newp; | 106 list = newp; |
107 ++nlist; | 107 ++nlist; |
108 } | 108 } |
109 | 109 |
110 bool written = false; | 110 bool written = false; |
111 if (nlist > 0) | 111 if (nlist > 0) |
112 { | 112 { |
(...skipping 28 matching lines...) Expand all Loading... |
141 | 141 |
142 void | 142 void |
143 __libc_fatal (message) | 143 __libc_fatal (message) |
144 const char *message; | 144 const char *message; |
145 { | 145 { |
146 /* The loop is added only to keep gcc happy. */ | 146 /* The loop is added only to keep gcc happy. */ |
147 while (1) | 147 while (1) |
148 __libc_message (1, "%s", message); | 148 __libc_message (1, "%s", message); |
149 } | 149 } |
150 libc_hidden_def (__libc_fatal) | 150 libc_hidden_def (__libc_fatal) |
OLD | NEW |