diff options
author | Roland McGrath <roland@gnu.org> | 1994-05-16 22:10:55 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1994-05-16 22:10:55 +0000 |
commit | 139b153f8b8bef4d674ca2d33b6fcfc8d5776a0e (patch) | |
tree | 93c8ca0b0b1528e4f3c47af8a5b92ec0beae6a7d /assert | |
parent | a8cc3d3a3a10d3bfb49fbc1c6902e516cc54024f (diff) |
Formerly assert.c.~4~
Diffstat (limited to 'assert')
-rw-r--r-- | assert/assert.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/assert/assert.c b/assert/assert.c index a2c03767d4..0490fad8e4 100644 --- a/assert/assert.c +++ b/assert/assert.c @@ -20,8 +20,11 @@ Cambridge, MA 02139, USA. */ #include <assert.h> #include <stdio.h> #include <stdlib.h> +#include <sysdep.h> +CONST char *__assert_program_name; + /* This function, when passed a string containing an asserted expression, a filename, and a line number, prints a message on the standard error stream of the form: @@ -33,9 +36,15 @@ DEFUN(__assert_fail, (assertion, file, line, function), CONST char *assertion AND CONST char *file AND unsigned int line AND CONST char *function) { +#ifdef FATAL_PREPARE + FATAL_PREPARE; +#endif + /* Print the message. */ - (void) fprintf (stderr, "%s:%u: %s%sAssertion `%s' failed.\n", + (void) fprintf (stderr, "%s:%u: %s%s%s%sAssertion `%s' failed.\n", file, line, + __assert_program_name ? __assert_program_name : "", + __assert_program_name ? ": " : "", function ? function : "", function ? ": " : "", assertion); (void) fflush (stderr); @@ -46,3 +55,30 @@ DEFUN(__assert_fail, (assertion, file, line, function), but returning something makes the assert macro easier to write. */ return 0; } + +#ifdef HAVE_GNU_LD + +#include <string.h> +#include <gnu-stabs.h> + +static void +DEFUN(set_progname, (argc, argv, envp), + int argc AND char **argv AND char **envp) +{ + char *p; + + if (argv && argv[0]) + { + p = strrchr (argv[0], '/'); + if (p == NULL) + __assert_program_name = argv[0]; + else + __assert_program_name = p + 1; + } + + (void) &set_progname; /* Avoid "defined but not used" warning. */ +} + +text_set_element (__libc_subinit, set_progname); + +#endif |