1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
5 /// \file tuklib_progname.c
6 /// \brief Program name to be displayed in messages
8 // Author: Lasse Collin
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "tuklib_progname.h"
16 #ifndef HAVE_PROGRAM_INVOCATION_NAME
17 char *progname
= NULL
;
22 tuklib_progname_init(char **argv
)
25 // On these systems, argv[0] always has the full path and .exe
26 // suffix even if the user just types the plain program name.
27 // We modify argv[0] to make it nicer to read.
29 // Strip the leading path.
30 char *p
= argv
[0] + strlen(argv
[0]);
31 while (argv
[0] < p
&& p
[-1] != '/' && p
[-1] != '\\')
36 // Strip the .exe suffix.
42 for (p
= argv
[0]; *p
!= '\0'; ++p
)
43 if (*p
>= 'A' && *p
<= 'Z')