]> code.delx.au - pulseaudio/commitdiff
utils: use pa_path_get_filename() where applicable
authorLennart Poettering <lennart@poettering.net>
Thu, 4 Jun 2009 21:19:48 +0000 (23:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 4 Jun 2009 21:19:48 +0000 (23:19 +0200)
src/daemon/cmdline.c
src/utils/pactl.c
src/utils/pasuspender.c

index d78089e194b7a0cc9b289d077fca186d94b9cd28..ecb384866337842afa24ce281b1ad954a9db5f6c 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <pulse/xmalloc.h>
 #include <pulse/i18n.h>
+#include <pulse/util.h>
 
 #include <pulsecore/core-util.h>
 #include <pulsecore/strbuf.h>
@@ -109,15 +110,8 @@ static const struct option long_options[] = {
 };
 
 void pa_cmdline_help(const char *argv0) {
-    const char *e;
-
     pa_assert(argv0);
 
-    if ((e = strrchr(argv0, '/')))
-        e++;
-    else
-        e = argv0;
-
     printf(_("%s [options]\n\n"
            "COMMANDS:\n"
            "  -h, --help                            Show this help\n"
@@ -172,7 +166,8 @@ void pa_cmdline_help(const char *argv0) {
            "  -C                                    Open a command line on the running TTY\n"
            "                                        after startup\n\n"
 
-           "  -n                                    Don't load default script file\n"), e);
+           "  -n                                    Don't load default script file\n"),
+           pa_path_get_filename(argv0));
 }
 
 int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
index 53c67666340b2e353ef39fb2b12c6d55dcfd32e8..6608c01e93b3e132ef415ee84efd4d4a9a15b425 100644 (file)
@@ -802,7 +802,6 @@ enum {
 
 int main(int argc, char *argv[]) {
     pa_mainloop* m = NULL;
-    char tmp[PATH_MAX];
     int ret = 1, c;
     char *server = NULL, *bn;
 
@@ -882,17 +881,8 @@ int main(int argc, char *argv[]) {
             if (optind+2 < argc)
                 sample_name = pa_xstrdup(argv[optind+2]);
             else {
-                char *f = strrchr(argv[optind+1], '/');
-                size_t n;
-                if (f)
-                    f++;
-                else
-                    f = argv[optind];
-
-                n = strcspn(f, ".");
-                strncpy(tmp, f, n);
-                tmp[n] = 0;
-                sample_name = pa_xstrdup(tmp);
+                char *f = pa_path_get_filename(argv[optind+1]);
+                sample_name = pa_xstrndup(f, strcspn(f, "."));
             }
 
             pa_zero(sfi);
index b4bccd5684f17ab6891442d9ec0216a6468b59fd..c327ee4153457375a568a49990dae72f7e3b7f39 100644 (file)
@@ -235,10 +235,7 @@ int main(int argc, char *argv[]) {
     setlocale(LC_ALL, "");
     bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
 
-    if (!(bn = strrchr(argv[0], '/')))
-        bn = argv[0];
-    else
-        bn++;
+    bn = pa_path_get_filename(argv[0]);
 
     while ((c = getopt_long(argc, argv, "s:h", long_options, NULL)) != -1) {
         switch (c) {