aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-05-23 11:32:44 +0100
committerRon Yorston <rmy@pobox.com>2023-05-23 11:32:44 +0100
commit5adeafb91fe5d0fbfd2e4f773e64da9aa13d2f09 (patch)
tree5e739c2dd648786eeff06cc6a65fdff3d5ed8283 /coreutils
parentc2eb45989fcd59617884dc853743b5cc94b15935 (diff)
parent3e83699ce23400d75c7ddaa7ebfdec015177caa7 (diff)
downloadbusybox-w32-5adeafb91fe5d0fbfd2e4f773e64da9aa13d2f09.tar.gz
busybox-w32-5adeafb91fe5d0fbfd2e4f773e64da9aa13d2f09.tar.bz2
busybox-w32-5adeafb91fe5d0fbfd2e4f773e64da9aa13d2f09.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/factor.c71
-rw-r--r--coreutils/readlink.c9
2 files changed, 39 insertions, 41 deletions
diff --git a/coreutils/factor.c b/coreutils/factor.c
index a7a5a5030..f909a0d96 100644
--- a/coreutils/factor.c
+++ b/coreutils/factor.c
@@ -48,38 +48,40 @@ typedef unsigned long half_t;
48 * Larger wheels improve sieving only slightly, but quickly grow in size 48 * Larger wheels improve sieving only slightly, but quickly grow in size
49 * (adding just one prime, 13, results in 5766 element sieve). 49 * (adding just one prime, 13, results in 5766 element sieve).
50 */ 50 */
51#define R(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \ 51#define R(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J,x) \
52 (((uint64_t)(a<<0) | (b<<3) | (c<<6) | (d<<9) | (e<<12) | (f<<15) | (g<<18) | (h<<21) | (i<<24) | (j<<27)) << 1) | \ 52 (((uint64_t)(a<<0) | (b<<3) | (c<<6) | (d<<9) | (e<<12) | (f<<15) | (g<<18) | (h<<21) | (i<<24) | (j<<27)) << 1) | \
53 (((uint64_t)(A<<0) | (B<<3) | (C<<6) | (D<<9) | (E<<12) | (F<<15) | (G<<18) | (H<<21) | (I<<24) | (J<<27)) << 31) 53 (((uint64_t)(A<<0) | (B<<3) | (C<<6) | (D<<9) | (E<<12) | (F<<15) | (G<<18) | (H<<21) | (I<<24) | (J<<27)) << 31) | \
54#define P(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \ 54 ((uint64_t)x << 61)
55#define P(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J,x) \
55 R( (a/2),(b/2),(c/2),(d/2),(e/2),(f/2),(g/2),(h/2),(i/2),(j/2), \ 56 R( (a/2),(b/2),(c/2),(d/2),(e/2),(f/2),(g/2),(h/2),(i/2),(j/2), \
56 (A/2),(B/2),(C/2),(D/2),(E/2),(F/2),(G/2),(H/2),(I/2),(J/2) ) 57 (A/2),(B/2),(C/2),(D/2),(E/2),(F/2),(G/2),(H/2),(I/2),(J/2), \
58 (x/2) \
59 )
57static const uint64_t packed_wheel[] = { 60static const uint64_t packed_wheel[] = {
58 /*1, 2, 2, 4, 2,*/ 61 /* 1, 2, */
59 P( 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4), //01 62 P( 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6),
60 P( 2, 4, 2, 4,14, 4, 6, 2,10, 2, 6, 6, 4, 2, 4, 6, 2,10, 2, 4), //02 63 P( 8, 4, 2, 4, 2, 4,14, 4, 6, 2,10, 2, 6, 6, 4, 2, 4, 6, 2,10, 2),
61 P( 2,12,10, 2, 4, 2, 4, 6, 2, 6, 4, 6, 6, 6, 2, 6, 4, 2, 6, 4), //03 64 P( 4, 2,12,10, 2, 4, 2, 4, 6, 2, 6, 4, 6, 6, 6, 2, 6, 4, 2, 6, 4),
62 P( 6, 8, 4, 2, 4, 6, 8, 6,10, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2), //04 65 P( 6, 8, 4, 2,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 4, 2, 4, 2,10, 2,10, 6, 2, 4, 6, 2, 6, 4), //20 81 P( 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2,10, 6, 8, 6, 4, 2, 4, 8, 6),
79 P( 2, 4, 6, 6, 2, 6, 4, 2,10, 6, 8, 6, 4, 2, 4, 8, 6, 4, 6, 2), //21 82 P( 4, 6, 2, 4, 6, 2, 6, 6, 6, 4, 6, 2, 6, 4, 2, 4, 2,10,12, 2, 4),
80 P( 4, 6, 2, 6, 6, 6, 4, 6, 2, 6, 4, 2, 4, 2,10,12, 2, 4, 2,10), //22 83 P( 2,10, 2, 6, 4, 2, 4, 6, 6, 2,10, 2, 6, 4,14, 4, 2, 4, 2, 4, 8),
81 P( 2, 6, 4, 2, 4, 6, 6, 2,10, 2, 6, 4,14, 4, 2, 4, 2, 4, 8, 6), //23 84 P( 6, 4, 6, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4,12, 2,12),
82 P( 4, 6, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4,12, 2,12), //24
83}; 85};
84#undef P 86#undef P
85#undef R 87#undef R
@@ -93,8 +95,8 @@ static const uint64_t packed_wheel[] = {
93 * function old new delta 95 * function old new delta
94 * wheel_tab - 485 +485 96 * wheel_tab - 485 +485
95 * 3-bit-packed insanity: 97 * 3-bit-packed insanity:
96 * packed_wheel - 192 +192 98 * packed_wheel - 184 +184
97 * factor_main 108 171 +63 99 * factor_main 108 163 +55
98 */ 100 */
99static void unpack_wheel(void) 101static void unpack_wheel(void)
100{ 102{
@@ -104,10 +106,7 @@ static void unpack_wheel(void)
104 setup_common_bufsiz(); 106 setup_common_bufsiz();
105 wheel_tab[0] = 1; 107 wheel_tab[0] = 1;
106 wheel_tab[1] = 2; 108 wheel_tab[1] = 2;
107 wheel_tab[2] = 2; 109 p = &wheel_tab[2];
108 wheel_tab[3] = 4;
109 wheel_tab[4] = 2;
110 p = &wheel_tab[5];
111 for (i = 0; i < ARRAY_SIZE(packed_wheel); i++) { 110 for (i = 0; i < ARRAY_SIZE(packed_wheel); i++) {
112 uint64_t v = packed_wheel[i]; 111 uint64_t v = packed_wheel[i];
113 while ((v & 0xe) != 0) { 112 while ((v & 0xe) != 0) {
diff --git a/coreutils/readlink.c b/coreutils/readlink.c
index 0a9aa957e..e17fc3b1e 100644
--- a/coreutils/readlink.c
+++ b/coreutils/readlink.c
@@ -68,12 +68,11 @@ int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
68int readlink_main(int argc UNUSED_PARAM, char **argv) 68int readlink_main(int argc UNUSED_PARAM, char **argv)
69{ 69{
70 char *buf; 70 char *buf;
71 char *fname;
72 unsigned opt; 71 unsigned opt;
73 72
73 /* -n must use bit 0 (see printf below) */
74 opt = getopt32(argv, "^" "n" IF_FEATURE_READLINK_FOLLOW("fvsq") 74 opt = getopt32(argv, "^" "n" IF_FEATURE_READLINK_FOLLOW("fvsq")
75 "\0" "=1"); 75 "\0" "=1");
76 fname = argv[optind];
77 76
78 /* compat: coreutils readlink reports errors silently via exit code */ 77 /* compat: coreutils readlink reports errors silently via exit code */
79 if (!(opt & 4)) /* not -v */ 78 if (!(opt & 4)) /* not -v */
@@ -81,14 +80,14 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
81 80
82 /* NOFORK: only one alloc is allowed; must free */ 81 /* NOFORK: only one alloc is allowed; must free */
83 if (opt & 2) { /* -f */ 82 if (opt & 2) { /* -f */
84 buf = xmalloc_realpath_coreutils(fname); 83 buf = xmalloc_realpath_coreutils(argv[optind]);
85 } else { 84 } else {
86 buf = xmalloc_readlink_or_warn(fname); 85 buf = xmalloc_readlink_or_warn(argv[optind]);
87 } 86 }
88 87
89 if (!buf) 88 if (!buf)
90 return EXIT_FAILURE; 89 return EXIT_FAILURE;
91 printf((opt & 1) ? "%s" : "%s\n", buf); 90 printf("%s%s", buf, &"\n"[opt & 1]);
92 free(buf); 91 free(buf);
93 92
94 fflush_stdout_and_exit_SUCCESS(); 93 fflush_stdout_and_exit_SUCCESS();