File: 30-basename-fix.patch

package info (click to toggle)
gramofile 1.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,440 kB
  • sloc: ansic: 11,252; makefile: 60
file content (70 lines) | stat: -rw-r--r-- 2,409 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# <30-basename-fix.dpatch> by Daniel Kobras <kobras@debian.org>
#
# Use the POSIX basename(3), get rid of private prototype that wasn't used
# anyway. Remove the now unneeded REDHAT50 define from the Makefile.
#
# Explanation: Previously, the code used glibc's basename but didn't realise
# it was a GNU extension. Alternatively, one could define _GNU_SOURCE, but
# I opted for the--hopefully--more portable POSIX version. (Unlike the GNU
# version, the POSIX version may potentially modify its argument.)
Index: gramofile/bplaysrc/bplay.c
===================================================================
--- gramofile.orig/bplaysrc/bplay.c	2011-08-14 13:27:15.277217351 +0200
+++ gramofile/bplaysrc/bplay.c	2011-08-14 13:27:15.593217482 +0200
@@ -20,6 +20,10 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 
+#ifdef linux
+#include <libgen.h>
+#endif
+
 #ifndef __FreeBSD__
 #include <sys/soundcard.h>
 #else
@@ -53,16 +57,6 @@
 
 /* Prototypes */
 
-#ifdef linux
-/* This is in libc, but not in the header files. -- but it IS in
-   Red Hat 5.0.... Libc6?
-   well i'd guess its not in the headers because its nonstandard, i.e.
-   (probably) only exists on linux...  -nox */
-#ifndef REDHAT50
-extern char *basename(char *name);
-#endif
-#endif
-
 void Usage(void);
 void ErrDie(char *err);
 void Die(char *err);
@@ -107,11 +101,14 @@
 	sndf_t filetype;		/* The file type */
 	int mods;			/* So user can override */
 	int optc;			/* For getopt */
+	char *tmp = NULL;		/* Do not clobber argv[0] */
 
 	init_curses();
 
 #ifdef linux
-	progname = basename(argv[0]);	/* For errors */
+	tmp = strdup(argv[0]);		/* POSIX basename may modify its arg */
+	progname = basename(tmp);	/* For errors */
+	free(tmp);
 #else
 	progname = strrchr(argv[0], '/');  /* Replacement for e.g. FreeBSD */
 	if (!progname || !*++progname)
Index: gramofile/bplaysrc/Makefile
===================================================================
--- gramofile.orig/bplaysrc/Makefile	2011-08-14 13:21:45.449217435 +0200
+++ gramofile/bplaysrc/Makefile	2011-08-14 13:27:15.593217482 +0200
@@ -12,7 +12,7 @@
 ########## CHOOSE YOUR ARCHITECTURE:    (NOTE: also see ../Makefile!)
 
 # For Linux (and maybe others), use these:
-CFLAGS = -Wall -O2 -DUSEBUFFLOCK -DREDHAT50 -DLP2CD -DVUMETER # -DDEBUG
+CFLAGS = -Wall -O2 -DUSEBUFFLOCK -DLP2CD -DVUMETER # -DDEBUG
 LIBS = -lncurses
 
 # For FreeBSD (and maybe others), use these: