Lines 1-157
Link Here
|
1 |
based on https://bugs.busybox.net/show_bug.cgi?id=3D3529 |
|
|
2 |
|
3 |
--- include/local.h.orig |
4 |
+++ include/local.h |
5 |
@@ -285,4 +285,125 @@ int snd_config_search_alias_hooks(snd_co |
6 |
const char *base, const char *key, |
7 |
snd_config_t **result); |
8 |
=20 |
9 |
+#ifdef NEED_VERSIONSORT |
10 |
+ |
11 |
+/* Compare strings while treating digits characters numerically. |
12 |
+ Copyright (C) 1997, 2002 Free Software Foundation, Inc. |
13 |
+ This file is part of the GNU C Library. |
14 |
+ Contributed by Jean-Fran=C3=A7ois Bignolles <bignolle@ecoledoc.ibp.fr>= |
15 |
+ |
16 |
+ The GNU C Library is free software; you can redistribute it and/or |
17 |
+ modify it under the terms of the GNU Lesser General Public |
18 |
+ License as published by the Free Software Foundation; either |
19 |
+ version 2.1 of the License, or (at your option) any later version. |
20 |
+ |
21 |
+ The GNU C Library is distributed in the hope that it will be useful, |
22 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
24 |
+ Lesser General Public License for more details. |
25 |
+ |
26 |
+ You should have received a copy of the GNU Lesser General Public |
27 |
+ License along with the GNU C Library; if not, write to the Free |
28 |
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
29 |
+ 02111-1307 USA. */ |
30 |
+ |
31 |
+#include <string.h> |
32 |
+#include <ctype.h> |
33 |
+ |
34 |
+ |
35 |
+/* states: S_N: normal, S_I: comparing integral part, S_F: comparing |
36 |
+ fractionnal parts, S_Z: idem but with leading Zeroes only */ |
37 |
+#define S_N 0x0 |
38 |
+#define S_I 0x4 |
39 |
+#define S_F 0x8 |
40 |
+#define S_Z 0xC |
41 |
+ |
42 |
+/* result_type: CMP: return diff; LEN: compare using len_diff/diff */ |
43 |
+#define CMP 2 |
44 |
+#define LEN 3 |
45 |
+ |
46 |
+/* Compare S1 and S2 as strings holding indices/version numbers, |
47 |
+ returning less than, equal to or greater than zero if S1 is less than, |
48 |
+ equal to or greater than S2 (for more info, see the texinfo doc). |
49 |
+*/ |
50 |
+static inline |
51 |
+int strverscmp (s1, s2) |
52 |
+ const char *s1; |
53 |
+ const char *s2; |
54 |
+{ |
55 |
+ const unsigned char *p1 =3D (const unsigned char *) s1; |
56 |
+ const unsigned char *p2 =3D (const unsigned char *) s2; |
57 |
+ unsigned char c1, c2; |
58 |
+ int state; |
59 |
+ int diff; |
60 |
+ |
61 |
+ /* Symbol(s) 0 [1-9] others (padding) |
62 |
+ Transition (10) 0 (01) d (00) x (11) - */ |
63 |
+ static const unsigned int next_state[] =3D |
64 |
+ { |
65 |
+ /* state x d 0 - */ |
66 |
+ /* S_N */ S_N, S_I, S_Z, S_N, |
67 |
+ /* S_I */ S_N, S_I, S_I, S_I, |
68 |
+ /* S_F */ S_N, S_F, S_F, S_F, |
69 |
+ /* S_Z */ S_N, S_F, S_Z, S_Z |
70 |
+ }; |
71 |
+ |
72 |
+ static const int result_type[] =3D |
73 |
+ { |
74 |
+ /* state x/x x/d x/0 x/- d/x d/d d/0 d/- |
75 |
+ 0/x 0/d 0/0 0/- -/x -/d -/0 -/- */ |
76 |
+ |
77 |
+ /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, |
78 |
+ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, |
79 |
+ /* S_I */ CMP, -1, -1, CMP, +1, LEN, LEN, CMP, |
80 |
+ +1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, |
81 |
+ /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, |
82 |
+ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, |
83 |
+ /* S_Z */ CMP, +1, +1, CMP, -1, CMP, CMP, CMP, |
84 |
+ -1, CMP, CMP, CMP |
85 |
+ }; |
86 |
+ |
87 |
+ if (p1 =3D=3D p2) |
88 |
+ return 0; |
89 |
+ |
90 |
+ c1 =3D *p1++; |
91 |
+ c2 =3D *p2++; |
92 |
+ /* Hint: '0' is a digit too. */ |
93 |
+ state =3D S_N | ((c1 =3D=3D '0') + (isdigit (c1) !=3D 0)); |
94 |
+ |
95 |
+ while ((diff =3D c1 - c2) =3D=3D 0 && c1 !=3D '\0') |
96 |
+ { |
97 |
+ state =3D next_state[state]; |
98 |
+ c1 =3D *p1++; |
99 |
+ c2 =3D *p2++; |
100 |
+ state |=3D (c1 =3D=3D '0') + (isdigit (c1) !=3D 0); |
101 |
+ } |
102 |
+ |
103 |
+ state =3D result_type[state << 2 | (((c2 =3D=3D '0') + (isdigit (c2) != |
104 |
+ |
105 |
+ switch (state) |
106 |
+ { |
107 |
+ case CMP: |
108 |
+ return diff; |
109 |
+ |
110 |
+ case LEN: |
111 |
+ while (isdigit (*p1++)) |
112 |
+ if (!isdigit (*p2++)) |
113 |
+ return 1; |
114 |
+ |
115 |
+ return isdigit (*p2) ? -1 : diff; |
116 |
+ |
117 |
+ default: |
118 |
+ return state; |
119 |
+ } |
120 |
+} |
121 |
+ |
122 |
+static inline |
123 |
+int versionsort(const void * a, const void * b) |
124 |
+{ |
125 |
+ return strverscmp ((*(const struct dirent **) a)->d_name, |
126 |
+ (*(const struct dirent **) b)->d_name); |
127 |
+} |
128 |
+ |
129 |
+#endif |
130 |
#endif |
131 |
--- src/conf.c.orig |
132 |
+++ src/conf.c |
133 |
@@ -419,6 +419,9 @@ beginning:</P> |
134 |
#include <sys/stat.h> |
135 |
#include <dirent.h> |
136 |
#include <locale.h> |
137 |
+#if defined(__FreeBSD__) || __UCLIBC_MAJOR__ =3D=3D 0 && __UCLIBC_MINOR__= |
138 |
=3D=3D 9 && __UCLIBC_SUBLEVEL__ <=3D 30 |
0 |
=3D=3D 9 && __UCLIBC_SUBLEVEL__ <=3D 30 |
139 |
+#define NEED_VERSIONSORT |
|
|
140 |
+#endif |
141 |
#include "local.h" |
142 |
#ifdef HAVE_LIBPTHREAD |
143 |
#include <pthread.h> |
144 |
--- src/ucm/parser.c.orig |
145 |
+++ src/ucm/parser.c |
146 |
@@ -30,8 +30,11 @@ |
147 |
* Jaroslav Kysela <perex@perex.cz> |
148 |
*/ |
149 |
=20 |
150 |
-#include "ucm_local.h" |
151 |
#include <dirent.h> |
152 |
+#if defined(__FreeBSD__) || __UCLIBC_MAJOR__ =3D=3D 0 && __UCLIBC_MINOR__= |
153 |
=3D=3D 9 && __UCLIBC_SUBLEVEL__ <=3D 30 |
1 |
=3D=3D 9 && __UCLIBC_SUBLEVEL__ <=3D 30 |
154 |
+#define NEED_VERSIONSORT |
|
|
155 |
+#endif |
156 |
+#include "ucm_local.h" |
157 |
=20 |
158 |
/** The name of the environment variable containing the UCM directory */ |
159 |
#define ALSA_CONFIG_UCM_VAR "ALSA_CONFIG_UCM" |