summaryrefslogtreecommitdiffstats
path: root/patches/06_fix-use-of-undefined-asort-awk-function.patch
blob: fd53a6dca16f087a79db2ace4df9f84501a0ea6d (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From: "P. J. McDermott" <pjm@nac.net>
Description: Don't use asort() and asorti() awk functions
 BusyBox awk doesn't define them and they aren't necessary for simple array
 iteration.
 .
 Also, fix some newlines in errlist-compat.awk.  POSIX.1-2008 states, "a
 <newline> shall not occur within a string constant."  GNU Awk allows newlines
 in strings and allows them to be escaped.  BusyBox awk also allows newlines in
 strings, but it ignores any preceeding backslash.
 .
 As a result, in BusyBox awk, erroneous newlines are added to errlist-compat.c,
 including in the string in the link_warning macro.  This causes the following
 warnings and errors:
 .
     gcc ../sysdeps/gnu/errlist.c -c [...]
     In file included from ../sysdeps/gnu/errlist.c:1482:0:
     /usr/src/eglibc_2.17~r22751+sip1-1/tmp/libcbuild/stdio-common/errlist-compat.c:87:28: warning: missing terminating " character [enabled by default]
     /usr/src/eglibc_2.17~r22751+sip1-1/tmp/libcbuild/stdio-common/errlist-compat.c:88:59: warning: missing terminating ' character [enabled by default]
     /usr/src/eglibc_2.17~r22751+sip1-1/tmp/libcbuild/stdio-common/errlist-compat.c:90:25: warning: missing terminating " character [enabled by default]
     /usr/src/eglibc_2.17~r22751+sip1-1/tmp/libcbuild/stdio-common/errlist-compat.c:91:56: warning: missing terminating ' character [enabled by default]
     /usr/src/eglibc_2.17~r22751+sip1-1/tmp/libcbuild/stdio-common/errlist-compat.c:91:0: error: unterminated argument list invoking macro "link_warning"
     ../sysdeps/gnu/errlist.c:1483:0: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input

diff -Naur src.orig/libc/scripts/option-groups.awk src/libc/scripts/option-groups.awk
--- src.orig/libc/scripts/option-groups.awk	2007-12-13 13:16:57.000000000 -0500
+++ src/libc/scripts/option-groups.awk	2013-06-21 11:14:39.304717753 -0400
@@ -32,10 +32,9 @@
     print ""
 
     # Produce a sorted list of variable names.
-    i=0
+    n=0
     for (var in vars)
-        names[i++] = var
-    n = asort (names)
+        names[n++] = var
 
     for (i = 1; i <= n; i++)
     {
diff -Naur src.orig/libc/sysdeps/gnu/errlist-compat.awk src/libc/sysdeps/gnu/errlist-compat.awk
--- src.orig/libc/sysdeps/gnu/errlist-compat.awk	2012-04-21 13:19:39.000000000 -0400
+++ src/libc/sysdeps/gnu/errlist-compat.awk	2013-06-21 13:17:44.606655144 -0400
@@ -84,10 +84,8 @@
     printf "#define ERR_MAX %d\n\n", highest - 1;
   }
 
-  # same regardless of awk's ordering of the associative array.
-  num_compat_elems = asorti(compat, compat_indices)
-  for (i = 1; i <= num_compat_elems; i++) {
-    old = compat_indices[i]
+  for (compat_index in compat) {
+    old = compat_index;
     new = compat[old];
     n = vcount[old];
     printf "#if SHLIB_COMPAT (libc, %s, %s)\n", old, new;
@@ -113,21 +111,23 @@
     printf "#endif\n\n";
   }
 
-  printf "\
-extern const char *const __sys_errlist_internal[NERR];\n\
-extern const int __sys_nerr_internal;\n\
-strong_alias (_sys_errlist_internal, __sys_errlist_internal)\n\
-strong_alias (_sys_nerr_internal, __sys_nerr_internal)\n\
-extern const char *const sys_errlist[NERR];\n\
-versioned_symbol (libc, _sys_errlist_internal, sys_errlist, %s);\n\
-versioned_symbol (libc, __sys_errlist_internal, _sys_errlist, %s);\n\
-versioned_symbol (libc, _sys_nerr_internal, sys_nerr, %s);\n\
-versioned_symbol (libc, __sys_nerr_internal, _sys_nerr, %s);\n", \
-    lastv, lastv, lastv, lastv;
+  printf "extern const char *const __sys_errlist_internal[NERR];\n"
+  printf "extern const int __sys_nerr_internal;\n"
+  printf "strong_alias (_sys_errlist_internal, __sys_errlist_internal)\n"
+  printf "strong_alias (_sys_nerr_internal, __sys_nerr_internal)\n"
+  printf "extern const char *const sys_errlist[NERR];\n"
+  printf "versioned_symbol (libc, _%s_internal, %s, %s);\n", \
+    "sys_errlist", "sys_errlist", lastv;
+  printf "versioned_symbol (libc, _%s_internal, %s, %s);\n", \
+    "_sys_errlist", "_sys_errlist", lastv;
+  printf "versioned_symbol (libc, _%s_internal, %s, %s);\n", \
+    "sys_nerr", "sys_nerr", lastv;
+  printf "versioned_symbol (libc, _%s_internal, %s, %s);\n", \
+    "_sys_nerr", "_sys_nerr", lastv;
 
-  print "\n\
-link_warning (sys_errlist, \"\
-`sys_errlist' is deprecated; use `strerror' or `strerror_r' instead\")\n\
-link_warning (sys_nerr, \"\
-`sys_nerr' is deprecated; use `strerror' or `strerror_r' instead\")";
+  printf "\n"
+  printf "link_warning (sys_errlist, \"`sys_errlist' "
+  printf "is deprecated; use `strerror' or `strerror_r' instead\")\n"
+  printf "link_warning (sys_nerr, \"`sys_nerr' "
+  printf "is deprecated; use `strerror' or `strerror_r' instead\")";
 }