packages: clean up the package folder
[openwrt/openwrt.git] / package / utils / util-linux / patches / 001-no-printf-alloc.patch
1 for systems that don't support latest POSIX standard: %as
2
3 https://bugs.gentoo.org/406303
4
5 --- a/configure.ac
6 +++ b/configure.ac
7 @@ -688,7 +688,6 @@ AC_ARG_ENABLE([libmount],
8 UL_BUILD_INIT([libmount])
9 UL_REQUIRES_LINUX([libmount])
10 UL_REQUIRES_BUILD([libmount], [libblkid])
11 -UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
12 AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_libmount" = xyes)
13
14 AC_SUBST([LIBMOUNT_VERSION])
15 --- a/libmount/src/tab_parse.c
16 +++ b/libmount/src/tab_parse.c
17 @@ -22,6 +22,10 @@
18 #include "pathnames.h"
19 #include "strutils.h"
20
21 +#ifndef HAVE_SCANF_MS_MODIFIER
22 +# define UL_SCNsA "%s"
23 +#endif
24 +
25 static inline char *skip_spaces(char *s)
26 {
27 assert(s);
28 @@ -61,16 +65,31 @@ static int mnt_parse_table_line(struct l
29 int rc, n = 0, xrc;
30 char *src = NULL, *fstype = NULL, *optstr = NULL;
31
32 +#ifndef HAVE_SCANF_MS_MODIFIER
33 + size_t len = strlen(s) + 1;
34 + src = malloc(len);
35 + fstype = malloc(len);
36 + fs->target = malloc(len);
37 + optstr = malloc(len);
38 +#endif
39 +
40 rc = sscanf(s, UL_SCNsA" " /* (1) source */
41 UL_SCNsA" " /* (2) target */
42 UL_SCNsA" " /* (3) FS type */
43 UL_SCNsA" " /* (4) options */
44 "%n", /* byte count */
45
46 +#ifdef HAVE_SCANF_MS_MODIFIER
47 &src,
48 &fs->target,
49 &fstype,
50 &optstr,
51 +#else
52 + src,
53 + fs->target,
54 + fstype,
55 + optstr,
56 +#endif
57 &n);
58 xrc = rc;
59
60 @@ -136,6 +155,16 @@ static int mnt_parse_mountinfo_line(stru
61 unsigned int maj, min;
62 char *fstype = NULL, *src = NULL, *p;
63
64 +#ifndef HAVE_SCANF_MS_MODIFIER
65 + size_t len = strlen(s) + 1;
66 + fs->root = malloc(len);
67 + fs->target = malloc(len);
68 + fs->vfs_optstr = malloc(len);
69 + fs->fs_optstr = malloc(len);
70 + fstype = malloc(len);
71 + src = malloc(len);
72 +#endif
73 +
74 rc = sscanf(s, "%u " /* (1) id */
75 "%u " /* (2) parent */
76 "%u:%u " /* (3) maj:min */
77 @@ -147,9 +176,15 @@ static int mnt_parse_mountinfo_line(stru
78 &fs->id,
79 &fs->parent,
80 &maj, &min,
81 +#ifdef HAVE_SCANF_MS_MODIFIER
82 &fs->root,
83 &fs->target,
84 &fs->vfs_optstr,
85 +#else
86 + fs->root,
87 + fs->target,
88 + fs->vfs_optstr,
89 +#endif
90 &end);
91
92 if (rc >= 7 && end > 0)
93 @@ -167,9 +202,15 @@ static int mnt_parse_mountinfo_line(stru
94 UL_SCNsA" " /* (9) source */
95 UL_SCNsA, /* (10) fs options (fs specific) */
96
97 +#ifdef HAVE_SCANF_MS_MODIFIER
98 &fstype,
99 &src,
100 &fs->fs_optstr);
101 +#else
102 + fstype,
103 + src,
104 + fs->fs_optstr);
105 +#endif
106
107 if (rc >= 10) {
108 fs->flags |= MNT_FS_KERNEL;