[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] progname fixes
From: |
Simon Josefsson |
Subject: |
[Bug-gnulib] progname fixes |
Date: |
Wed, 08 Sep 2004 14:37:31 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
I find that being able to extract the short program name is useful
(e.g., for openlog), hence get_short_program_name below. When adding
this, I noticed that the ENABLE_RELOCATABLE stuff in progname.h didn't
seem to be implemented anywhere, so I removed it.
2004-09-08 Simon Josefsson <address@hidden>
* progname.h: Don't prefix _ on CPP symbols.
(set_program_name_and_installdir)
(get_full_program_name) [ENABLE_RELOCATABLE]: Remove (not
implemented).
(get_short_program_name): Add.
* progname.c (get_short_program_name): Add.
Index: lib/progname.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/progname.h,v
retrieving revision 1.4
diff -u -p -r1.4 progname.h
--- lib/progname.h 6 Aug 2004 20:42:23 -0000 1.4
+++ lib/progname.h 8 Sep 2004 12:35:22 -0000
@@ -16,8 +16,8 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#ifndef _PROGNAME_H
-#define _PROGNAME_H
+#ifndef PROGNAME_H
+#define PROGNAME_H
/* Programs using this file should do the following in main():
set_program_name (argv[0]);
@@ -35,21 +35,11 @@ extern const char *program_name;
/* Set program_name, based on argv[0]. */
extern void set_program_name (const char *argv0);
-#if ENABLE_RELOCATABLE
-
-/* Set program_name, based on argv[0], and original installation prefix and
- directory, for relocatability. */
-extern void set_program_name_and_installdir (const char *argv0,
- const char *orig_installprefix,
- const char *orig_installdir);
-#define set_program_name(ARG0) \
- set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
-
-/* Return the full pathname of the current executable, based on the earlier
- call to set_program_name_and_installdir. Return NULL if unknown. */
-extern char *get_full_program_name (void);
-
-#endif
+/* Return short program name of the current executable, based on the
+ earlier call to set_program_name. Return NULL if unknown. The
+ short program name is computed by removing all directory names and
+ path separators. */
+extern char *get_short_program_name (void);
#ifdef __cplusplus
@@ -57,4 +47,4 @@ extern char *get_full_program_name (void
#endif
-#endif /* _PROGNAME_H */
+#endif /* PROGNAME_H */
Index: lib/progname.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/progname.c,v
retrieving revision 1.2
diff -u -p -r1.2 progname.c
--- lib/progname.c 22 Aug 2003 13:56:46 -0000 1.2
+++ lib/progname.c 8 Sep 2004 12:35:22 -0000
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004 Free Software Foundation, Inc.
Written by Bruno Haible <address@hidden>, 2001.
This program is free software; you can redistribute it and/or modify
@@ -51,3 +51,16 @@ set_program_name (const char *argv0)
argv0 = base + 3;
program_name = argv0;
}
+
+/* Return short program name of the current executable, based on the
+ earlier call to set_program_name. Return NULL if unknown. The
+ short program name is computed by removing all directory names and
+ path separators. */
+char *
+get_short_program_name (void)
+{
+ const char *slash = NULL;
+ if (program_name)
+ slash = strrchr (program_name, '/');
+ return slash != NULL ? slash + 1 : program_name;
+}
- [Bug-gnulib] progname fixes,
Simon Josefsson <=