diff options
-rw-r--r-- | archival/gzip.c | 14 | ||||
-rw-r--r-- | coreutils/dd.c | 20 | ||||
-rw-r--r-- | coreutils/dos2unix.c | 2 | ||||
-rw-r--r-- | coreutils/ls.c | 9 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 7 | ||||
-rw-r--r-- | coreutils/test.c | 23 | ||||
-rw-r--r-- | debianutils/which.c | 34 | ||||
-rw-r--r-- | editors/patch.c | 8 | ||||
-rw-r--r-- | findutils/grep.c | 8 | ||||
-rw-r--r-- | include/mingw.h | 4 | ||||
-rw-r--r-- | libbb/execable.c | 18 | ||||
-rw-r--r-- | scripts/defconfig.mingw32 | 2 | ||||
-rw-r--r-- | shell/builtin_ulimit.c | 9 | ||||
-rw-r--r-- | win32/process.c | 4 |
14 files changed, 139 insertions, 23 deletions
diff --git a/archival/gzip.c b/archival/gzip.c index a327d5435..958336303 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -1577,7 +1577,7 @@ static void compress_block(ct_data * ltree, ct_data * dtree) | |||
1577 | * trees or store, and output the encoded block to the zip file. This function | 1577 | * trees or store, and output the encoded block to the zip file. This function |
1578 | * returns the total compressed length for the file so far. | 1578 | * returns the total compressed length for the file so far. |
1579 | */ | 1579 | */ |
1580 | static ulg flush_block(char *buf, ulg stored_len, int eof) | 1580 | static ulg flush_block(char *buf, ulg stored_len, int eof_) |
1581 | { | 1581 | { |
1582 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ | 1582 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ |
1583 | int max_blindex; /* index of last bit length code of non zero freq */ | 1583 | int max_blindex; /* index of last bit length code of non zero freq */ |
@@ -1615,7 +1615,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1615 | * and if the zip file can be seeked (to rewrite the local header), | 1615 | * and if the zip file can be seeked (to rewrite the local header), |
1616 | * the whole file is transformed into a stored file: | 1616 | * the whole file is transformed into a stored file: |
1617 | */ | 1617 | */ |
1618 | if (stored_len <= opt_lenb && eof && G2.compressed_len == 0L && seekable()) { | 1618 | if (stored_len <= opt_lenb && eof_ && G2.compressed_len == 0L && seekable()) { |
1619 | /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ | 1619 | /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ |
1620 | if (buf == NULL) | 1620 | if (buf == NULL) |
1621 | bb_error_msg("block vanished"); | 1621 | bb_error_msg("block vanished"); |
@@ -1631,18 +1631,18 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1631 | * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to | 1631 | * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to |
1632 | * transform a block into a stored block. | 1632 | * transform a block into a stored block. |
1633 | */ | 1633 | */ |
1634 | send_bits((STORED_BLOCK << 1) + eof, 3); /* send block type */ | 1634 | send_bits((STORED_BLOCK << 1) + eof_, 3); /* send block type */ |
1635 | G2.compressed_len = (G2.compressed_len + 3 + 7) & ~7L; | 1635 | G2.compressed_len = (G2.compressed_len + 3 + 7) & ~7L; |
1636 | G2.compressed_len += (stored_len + 4) << 3; | 1636 | G2.compressed_len += (stored_len + 4) << 3; |
1637 | 1637 | ||
1638 | copy_block(buf, (unsigned) stored_len, 1); /* with header */ | 1638 | copy_block(buf, (unsigned) stored_len, 1); /* with header */ |
1639 | 1639 | ||
1640 | } else if (static_lenb == opt_lenb) { | 1640 | } else if (static_lenb == opt_lenb) { |
1641 | send_bits((STATIC_TREES << 1) + eof, 3); | 1641 | send_bits((STATIC_TREES << 1) + eof_, 3); |
1642 | compress_block((ct_data *) G2.static_ltree, (ct_data *) G2.static_dtree); | 1642 | compress_block((ct_data *) G2.static_ltree, (ct_data *) G2.static_dtree); |
1643 | G2.compressed_len += 3 + G2.static_len; | 1643 | G2.compressed_len += 3 + G2.static_len; |
1644 | } else { | 1644 | } else { |
1645 | send_bits((DYN_TREES << 1) + eof, 3); | 1645 | send_bits((DYN_TREES << 1) + eof_, 3); |
1646 | send_all_trees(G2.l_desc.max_code + 1, G2.d_desc.max_code + 1, | 1646 | send_all_trees(G2.l_desc.max_code + 1, G2.d_desc.max_code + 1, |
1647 | max_blindex + 1); | 1647 | max_blindex + 1); |
1648 | compress_block((ct_data *) G2.dyn_ltree, (ct_data *) G2.dyn_dtree); | 1648 | compress_block((ct_data *) G2.dyn_ltree, (ct_data *) G2.dyn_dtree); |
@@ -1651,12 +1651,12 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1651 | Assert(G2.compressed_len == G1.bits_sent, "bad compressed size"); | 1651 | Assert(G2.compressed_len == G1.bits_sent, "bad compressed size"); |
1652 | init_block(); | 1652 | init_block(); |
1653 | 1653 | ||
1654 | if (eof) { | 1654 | if (eof_) { |
1655 | bi_windup(); | 1655 | bi_windup(); |
1656 | G2.compressed_len += 7; /* align on byte boundary */ | 1656 | G2.compressed_len += 7; /* align on byte boundary */ |
1657 | } | 1657 | } |
1658 | Tracev((stderr, "\ncomprlen %lu(%lu) ", G2.compressed_len >> 3, | 1658 | Tracev((stderr, "\ncomprlen %lu(%lu) ", G2.compressed_len >> 3, |
1659 | G2.compressed_len - 7 * eof)); | 1659 | G2.compressed_len - 7 * eof_)); |
1660 | 1660 | ||
1661 | return G2.compressed_len >> 3; | 1661 | return G2.compressed_len >> 3; |
1662 | } | 1662 | } |
diff --git a/coreutils/dd.c b/coreutils/dd.c index 7c1a0c0df..eb9f8885f 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -168,6 +168,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
168 | #endif | 168 | #endif |
169 | }; | 169 | }; |
170 | int exitcode = EXIT_FAILURE; | 170 | int exitcode = EXIT_FAILURE; |
171 | int devzero = 0; | ||
171 | size_t ibs = 512, obs = 512; | 172 | size_t ibs = 512, obs = 512; |
172 | ssize_t n, w; | 173 | ssize_t n, w; |
173 | char *ibuf, *obuf; | 174 | char *ibuf, *obuf; |
@@ -285,7 +286,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
285 | #endif | 286 | #endif |
286 | 287 | ||
287 | if (infile != NULL) | 288 | if (infile != NULL) |
288 | xmove_fd(xopen(infile, O_RDONLY), ifd); | 289 | if (ENABLE_PLATFORM_MINGW32 && !strcmp(infile, "/dev/zero")) { |
290 | flags |= FLAG_NOERROR; | ||
291 | devzero = 1; | ||
292 | } | ||
293 | else | ||
294 | xmove_fd(xopen(infile, O_RDONLY), ifd); | ||
289 | else { | 295 | else { |
290 | infile = bb_msg_standard_input; | 296 | infile = bb_msg_standard_input; |
291 | } | 297 | } |
@@ -312,7 +318,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
312 | } else { | 318 | } else { |
313 | outfile = bb_msg_standard_output; | 319 | outfile = bb_msg_standard_output; |
314 | } | 320 | } |
315 | if (skip) { | 321 | if (skip && !devzero) { |
316 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { | 322 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { |
317 | while (skip-- > 0) { | 323 | while (skip-- > 0) { |
318 | n = safe_read(ifd, ibuf, ibs); | 324 | n = safe_read(ifd, ibuf, ibs); |
@@ -329,7 +335,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
329 | } | 335 | } |
330 | 336 | ||
331 | while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { | 337 | while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { |
332 | n = safe_read(ifd, ibuf, ibs); | 338 | if (devzero) { |
339 | memset(ibuf, 0, ibs); | ||
340 | n = ibs; | ||
341 | } | ||
342 | else | ||
343 | n = safe_read(ifd, ibuf, ibs); | ||
333 | if (n == 0) | 344 | if (n == 0) |
334 | break; | 345 | break; |
335 | if (n < 0) { | 346 | if (n < 0) { |
@@ -383,7 +394,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
383 | if (w < 0) goto out_status; | 394 | if (w < 0) goto out_status; |
384 | if (w > 0) G.out_part++; | 395 | if (w > 0) G.out_part++; |
385 | } | 396 | } |
386 | if (close(ifd) < 0) { | 397 | |
398 | if (!devzero && close(ifd) < 0) { | ||
387 | die_infile: | 399 | die_infile: |
388 | bb_simple_perror_msg_and_die(infile); | 400 | bb_simple_perror_msg_and_die(infile); |
389 | } | 401 | } |
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 1911f5319..1c8b4af1b 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -41,7 +41,9 @@ static void convert(char *fn, int conv_type) | |||
41 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); | 41 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); |
42 | i = mkstemp(temp_fn); | 42 | i = mkstemp(temp_fn); |
43 | if (i == -1 | 43 | if (i == -1 |
44 | #if !ENABLE_PLATFORM_MINGW32 | ||
44 | || fchmod(i, st.st_mode) == -1 | 45 | || fchmod(i, st.st_mode) == -1 |
46 | #endif | ||
45 | ) { | 47 | ) { |
46 | bb_simple_perror_msg_and_die(temp_fn); | 48 | bb_simple_perror_msg_and_die(temp_fn); |
47 | } | 49 | } |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 1197f7d71..717b3f493 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -612,7 +612,12 @@ static NOINLINE unsigned list_single(const struct dnode *dn) | |||
612 | if (all_fmt & LIST_INO) | 612 | if (all_fmt & LIST_INO) |
613 | column += printf("%7llu ", (long long) dn->dstat.st_ino); | 613 | column += printf("%7llu ", (long long) dn->dstat.st_ino); |
614 | if (all_fmt & LIST_BLOCKS) | 614 | if (all_fmt & LIST_BLOCKS) |
615 | #if ENABLE_PLATFORM_MINGW32 | ||
616 | /* MinGW does not have st_blocks */ | ||
617 | column += printf("%4"OFF_FMT"u ", (off_t)0); | ||
618 | #else | ||
615 | column += printf("%4"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); | 619 | column += printf("%4"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); |
620 | #endif | ||
616 | if (all_fmt & LIST_MODEBITS) | 621 | if (all_fmt & LIST_MODEBITS) |
617 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); | 622 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); |
618 | if (all_fmt & LIST_NLINKS) | 623 | if (all_fmt & LIST_NLINKS) |
@@ -790,6 +795,7 @@ static void showfiles(struct dnode **dn, unsigned nfiles) | |||
790 | } | 795 | } |
791 | 796 | ||
792 | 797 | ||
798 | #if !ENABLE_PLATFORM_MINGW32 | ||
793 | #if ENABLE_DESKTOP | 799 | #if ENABLE_DESKTOP |
794 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html | 800 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html |
795 | * If any of the -l, -n, -s options is specified, each list | 801 | * If any of the -l, -n, -s options is specified, each list |
@@ -818,6 +824,7 @@ static off_t calculate_blocks(struct dnode **dn) | |||
818 | return blocks >> 1; | 824 | return blocks >> 1; |
819 | } | 825 | } |
820 | #endif | 826 | #endif |
827 | #endif | ||
821 | 828 | ||
822 | 829 | ||
823 | static struct dnode **list_dir(const char *, unsigned *); | 830 | static struct dnode **list_dir(const char *, unsigned *); |
@@ -843,10 +850,12 @@ static void showdirs(struct dnode **dn, int first) | |||
843 | printf("%s:\n", (*dn)->fullname); | 850 | printf("%s:\n", (*dn)->fullname); |
844 | } | 851 | } |
845 | subdnp = list_dir((*dn)->fullname, &nfiles); | 852 | subdnp = list_dir((*dn)->fullname, &nfiles); |
853 | #if !ENABLE_PLATFORM_MINGW32 | ||
846 | #if ENABLE_DESKTOP | 854 | #if ENABLE_DESKTOP |
847 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) | 855 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) |
848 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); | 856 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); |
849 | #endif | 857 | #endif |
858 | #endif | ||
850 | if (nfiles > 0) { | 859 | if (nfiles > 0) { |
851 | /* list all files at this level */ | 860 | /* list all files at this level */ |
852 | dnsort(subdnp, nfiles); | 861 | dnsort(subdnp, nfiles); |
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index 6a532fa9d..7b1ab8981 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -84,6 +84,13 @@ typedef long long llong; | |||
84 | # define LDBL_DIG DBL_DIG | 84 | # define LDBL_DIG DBL_DIG |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | #ifdef __MINGW32__ | ||
88 | /* symbol conflict */ | ||
89 | #define CHAR SIZE_CHAR | ||
90 | #define SHORT SIZE_SHORT | ||
91 | #define LONG SIZE_LONG | ||
92 | #define INT SIZE_INT | ||
93 | #endif | ||
87 | enum size_spec { | 94 | enum size_spec { |
88 | NO_SIZE, | 95 | NO_SIZE, |
89 | CHAR, | 96 | CHAR, |
diff --git a/coreutils/test.c b/coreutils/test.c index 5864c7f32..3115ce6e7 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -599,6 +599,29 @@ static int filstat(char *nm, enum token mode) | |||
599 | return 0; | 599 | return 0; |
600 | } | 600 | } |
601 | 601 | ||
602 | #if ENABLE_PLATFORM_MINGW32 | ||
603 | if (mode == FILEX) { | ||
604 | int len = strlen(nm), ret; | ||
605 | if (len >= 4 && | ||
606 | (!strcmp(nm+len-4,".exe") || | ||
607 | !strcmp(nm+len-4,".com"))) | ||
608 | ret = stat(nm, &s); | ||
609 | else { | ||
610 | char *exepath; | ||
611 | exepath = malloc(len+5); | ||
612 | memcpy(exepath, nm, len); | ||
613 | memcpy(exepath+len, ".exe", 5); | ||
614 | ret = stat(exepath, &s); | ||
615 | if (ret < 0) { | ||
616 | memcpy(exepath+len, ".exe", 5); | ||
617 | ret = stat(exepath, &s); | ||
618 | } | ||
619 | free(exepath); | ||
620 | } | ||
621 | return ret >= 0; | ||
622 | } | ||
623 | #endif | ||
624 | |||
602 | if (stat(nm, &s) != 0) | 625 | if (stat(nm, &s) != 0) |
603 | return 0; | 626 | return 0; |
604 | if (mode == FILEXIST) | 627 | if (mode == FILEXIST) |
diff --git a/debianutils/which.c b/debianutils/which.c index 1558e5c6d..59dedf58d 100644 --- a/debianutils/which.c +++ b/debianutils/which.c | |||
@@ -36,11 +36,26 @@ int which_main(int argc UNUSED_PARAM, char **argv) | |||
36 | do { | 36 | do { |
37 | #if ENABLE_DESKTOP | 37 | #if ENABLE_DESKTOP |
38 | /* Much bloat just to support -a */ | 38 | /* Much bloat just to support -a */ |
39 | if (strchr(*argv, '/')) { | 39 | if (strchr(*argv, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(*argv, '\\'))) { |
40 | if (execable_file(*argv)) { | 40 | if (execable_file(*argv)) { |
41 | puts(*argv); | 41 | puts(*argv); |
42 | continue; | 42 | continue; |
43 | } | 43 | } |
44 | else if (ENABLE_PLATFORM_MINGW32) { | ||
45 | char path[PATH_MAX]; | ||
46 | int len = strlen(*argv); | ||
47 | memcpy(path, *argv, len); | ||
48 | memcpy(path+len, ".exe", 5); | ||
49 | if (execable_file(path)) { | ||
50 | puts(path); | ||
51 | continue; | ||
52 | } | ||
53 | memcpy(path+len, ".com", 5); | ||
54 | if (execable_file(path)) { | ||
55 | puts(path); | ||
56 | continue; | ||
57 | } | ||
58 | } | ||
44 | status = EXIT_FAILURE; | 59 | status = EXIT_FAILURE; |
45 | } else { | 60 | } else { |
46 | char *path2 = xstrdup(path); | 61 | char *path2 = xstrdup(path); |
@@ -66,11 +81,26 @@ int which_main(int argc UNUSED_PARAM, char **argv) | |||
66 | } | 81 | } |
67 | #else | 82 | #else |
68 | /* Just ignoring -a */ | 83 | /* Just ignoring -a */ |
69 | if (strchr(*argv, '/')) { | 84 | if (strchr(*argv, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(*argv, '\\'))) { |
70 | if (execable_file(*argv)) { | 85 | if (execable_file(*argv)) { |
71 | puts(*argv); | 86 | puts(*argv); |
72 | continue; | 87 | continue; |
73 | } | 88 | } |
89 | else if (ENABLE_PLATFORM_MINGW32) { | ||
90 | char path[PATH_MAX]; | ||
91 | int len = strlen(*argv); | ||
92 | memcpy(path, *argv, len); | ||
93 | memcpy(path+len, ".exe", 5); | ||
94 | if (execable_file(path)) { | ||
95 | puts(path); | ||
96 | continue; | ||
97 | } | ||
98 | memcpy(path+len, ".com", 5); | ||
99 | if (execable_file(path)) { | ||
100 | puts(path); | ||
101 | continue; | ||
102 | } | ||
103 | } | ||
74 | } else { | 104 | } else { |
75 | char *path2 = xstrdup(path); | 105 | char *path2 = xstrdup(path); |
76 | char *tmp = path2; | 106 | char *tmp = path2; |
diff --git a/editors/patch.c b/editors/patch.c index 62477af16..507112377 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -25,7 +25,7 @@ static unsigned copy_lines(FILE *src_stream, FILE *dst_stream, unsigned lines_co | |||
25 | { | 25 | { |
26 | while (src_stream && lines_count) { | 26 | while (src_stream && lines_count) { |
27 | char *line; | 27 | char *line; |
28 | line = xmalloc_fgets(src_stream); | 28 | line = xmalloc_fgetline(src_stream); |
29 | if (line == NULL) { | 29 | if (line == NULL) { |
30 | break; | 30 | break; |
31 | } | 31 | } |
@@ -180,7 +180,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
180 | printf("patching file %s\n", new_filename); | 180 | printf("patching file %s\n", new_filename); |
181 | 181 | ||
182 | /* Handle all hunks for this file */ | 182 | /* Handle all hunks for this file */ |
183 | patch_line = xmalloc_fgets(patch_file); | 183 | patch_line = xmalloc_fgetline(patch_file); |
184 | while (patch_line) { | 184 | while (patch_line) { |
185 | unsigned count; | 185 | unsigned count; |
186 | unsigned src_beg_line; | 186 | unsigned src_beg_line; |
@@ -221,7 +221,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
221 | 221 | ||
222 | while (1) { | 222 | while (1) { |
223 | free(patch_line); | 223 | free(patch_line); |
224 | patch_line = xmalloc_fgets(patch_file); | 224 | patch_line = xmalloc_fgetline(patch_file); |
225 | if (patch_line == NULL) | 225 | if (patch_line == NULL) |
226 | break; /* EOF */ | 226 | break; /* EOF */ |
227 | if (!*patch_line) { | 227 | if (!*patch_line) { |
@@ -239,7 +239,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
239 | if (src_cur_line == src_last_line) | 239 | if (src_cur_line == src_last_line) |
240 | break; | 240 | break; |
241 | if (src_stream) { | 241 | if (src_stream) { |
242 | src_line = xmalloc_fgets(src_stream); | 242 | src_line = xmalloc_fgetline(src_stream); |
243 | if (src_line) { | 243 | if (src_line) { |
244 | int diff = strcmp(src_line, patch_line + 1); | 244 | int diff = strcmp(src_line, patch_line + 1); |
245 | src_cur_line++; | 245 | src_cur_line++; |
diff --git a/findutils/grep.c b/findutils/grep.c index a321cc31b..318fb4b2f 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -90,6 +90,14 @@ enum { | |||
90 | #define PRINT_FILES_WITHOUT_MATCHES (option_mask32 & OPT_L) | 90 | #define PRINT_FILES_WITHOUT_MATCHES (option_mask32 & OPT_L) |
91 | #define NUL_DELIMITED (option_mask32 & OPT_z) | 91 | #define NUL_DELIMITED (option_mask32 & OPT_z) |
92 | 92 | ||
93 | #if ENABLE_PLATFORM_MINGW32 | ||
94 | # define RE_TRANSLATE_TYPE unsigned char* | ||
95 | # undef ENABLE_EXTRA_COMPAT | ||
96 | # define ENABLE_EXTRA_COMPAT 0 | ||
97 | # undef IF_EXTRA_COMPAT | ||
98 | # define IF_EXTRA_COMPAT(x) | ||
99 | #endif | ||
100 | |||
93 | struct globals { | 101 | struct globals { |
94 | int max_matches; | 102 | int max_matches; |
95 | #if !ENABLE_EXTRA_COMPAT | 103 | #if !ENABLE_EXTRA_COMPAT |
diff --git a/include/mingw.h b/include/mingw.h index 0fbc8f528..53a0a0d67 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -112,6 +112,8 @@ struct sigaction { | |||
112 | int sigaction(int sig, struct sigaction *in, struct sigaction *out); | 112 | int sigaction(int sig, struct sigaction *in, struct sigaction *out); |
113 | sighandler_t mingw_signal(int sig, sighandler_t handler); | 113 | sighandler_t mingw_signal(int sig, sighandler_t handler); |
114 | NOIMPL(sigfillset,int *mask UNUSED_PARAM); | 114 | NOIMPL(sigfillset,int *mask UNUSED_PARAM); |
115 | NOIMPL(FAST_FUNC sigprocmask_allsigs, int how UNUSED_PARAM); | ||
116 | NOIMPL(FAST_FUNC sigaction_set,int signo UNUSED_PARAM, const struct sigaction *sa UNUSED_PARAM); | ||
115 | 117 | ||
116 | #define signal mingw_signal | 118 | #define signal mingw_signal |
117 | /* | 119 | /* |
@@ -143,6 +145,7 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format | |||
143 | #define WEXITSTATUS(x) ((x) & 0xff) | 145 | #define WEXITSTATUS(x) ((x) & 0xff) |
144 | #define WIFSIGNALED(x) ((unsigned)(x) > 259) | 146 | #define WIFSIGNALED(x) ((unsigned)(x) > 259) |
145 | #define WTERMSIG(x) ((x) & 0x7f) | 147 | #define WTERMSIG(x) ((x) & 0x7f) |
148 | #define WCOREDUMP(x) 0 | ||
146 | 149 | ||
147 | int clearenv(void); | 150 | int clearenv(void); |
148 | char *mingw_getenv(const char *name); | 151 | char *mingw_getenv(const char *name); |
@@ -243,6 +246,7 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out); | |||
243 | * sys/wait.h | 246 | * sys/wait.h |
244 | */ | 247 | */ |
245 | #define WNOHANG 1 | 248 | #define WNOHANG 1 |
249 | #define WUNTRACED 2 | ||
246 | int waitpid(pid_t pid, int *status, unsigned options); | 250 | int waitpid(pid_t pid, int *status, unsigned options); |
247 | 251 | ||
248 | /* | 252 | /* |
diff --git a/libbb/execable.c b/libbb/execable.c index 96ce9bfb8..06b1c534b 100644 --- a/libbb/execable.c +++ b/libbb/execable.c | |||
@@ -18,8 +18,11 @@ int FAST_FUNC execable_file(const char *name) | |||
18 | struct stat s; | 18 | struct stat s; |
19 | if (ENABLE_PLATFORM_MINGW32) { | 19 | if (ENABLE_PLATFORM_MINGW32) { |
20 | int len = strlen(name); | 20 | int len = strlen(name); |
21 | return len > 4 && !strcasecmp(name+len-4, ".exe") && | 21 | return len > 4 && |
22 | !stat(name, &s) && S_ISREG(s.st_mode); | 22 | (!strcasecmp(name+len-4, ".exe") || |
23 | !strcasecmp(name+len-4, ".com")) && | ||
24 | !stat(name, &s) && | ||
25 | S_ISREG(s.st_mode); | ||
23 | } | 26 | } |
24 | return (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)); | 27 | return (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)); |
25 | } | 28 | } |
@@ -43,7 +46,7 @@ char* FAST_FUNC find_execable(const char *filename, char **PATHp) | |||
43 | 46 | ||
44 | p = *PATHp; | 47 | p = *PATHp; |
45 | while (p) { | 48 | while (p) { |
46 | n = next_path_sep(p); | 49 | n = (char*)next_path_sep(p); |
47 | if (n) | 50 | if (n) |
48 | *n++ = '\0'; | 51 | *n++ = '\0'; |
49 | if (*p != '\0') { /* it's not a PATH="foo::bar" situation */ | 52 | if (*p != '\0') { /* it's not a PATH="foo::bar" situation */ |
@@ -54,7 +57,9 @@ char* FAST_FUNC find_execable(const char *filename, char **PATHp) | |||
54 | } | 57 | } |
55 | if (ENABLE_PLATFORM_MINGW32) { | 58 | if (ENABLE_PLATFORM_MINGW32) { |
56 | int len = strlen(p); | 59 | int len = strlen(p); |
57 | if (len > 4 && !strcasecmp(p+len-4, ".exe")) | 60 | if (len > 4 && |
61 | (!strcasecmp(p+len-4, ".exe") || | ||
62 | !strcasecmp(p+len-4, ".com"))) | ||
58 | ; /* nothing, already tested by find_execable() */ | 63 | ; /* nothing, already tested by find_execable() */ |
59 | else { | 64 | else { |
60 | char *np = xmalloc(len+4+1); | 65 | char *np = xmalloc(len+4+1); |
@@ -64,6 +69,11 @@ char* FAST_FUNC find_execable(const char *filename, char **PATHp) | |||
64 | *PATHp = n; | 69 | *PATHp = n; |
65 | return np; | 70 | return np; |
66 | } | 71 | } |
72 | memcpy(np+len, ".com", 5); | ||
73 | if (execable_file(np)) { | ||
74 | *PATHp = n; | ||
75 | return np; | ||
76 | } | ||
67 | } | 77 | } |
68 | } | 78 | } |
69 | free(p); | 79 | free(p); |
diff --git a/scripts/defconfig.mingw32 b/scripts/defconfig.mingw32 index 319d72add..356a08226 100644 --- a/scripts/defconfig.mingw32 +++ b/scripts/defconfig.mingw32 | |||
@@ -327,7 +327,7 @@ CONFIG_DEFAULT_SETFONT_DIR="" | |||
327 | # | 327 | # |
328 | # Editors | 328 | # Editors |
329 | # | 329 | # |
330 | # CONFIG_AWK is not set | 330 | CONFIG_AWK=y |
331 | # CONFIG_FEATURE_AWK_LIBM is not set | 331 | # CONFIG_FEATURE_AWK_LIBM is not set |
332 | CONFIG_CMP=y | 332 | CONFIG_CMP=y |
333 | CONFIG_DIFF=y | 333 | CONFIG_DIFF=y |
diff --git a/shell/builtin_ulimit.c b/shell/builtin_ulimit.c index 9f9205eb6..7ef17b1b0 100644 --- a/shell/builtin_ulimit.c +++ b/shell/builtin_ulimit.c | |||
@@ -16,6 +16,14 @@ | |||
16 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | 16 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
17 | */ | 17 | */ |
18 | #include "libbb.h" | 18 | #include "libbb.h" |
19 | |||
20 | #if ENABLE_PLATFORM_MINGW32 | ||
21 | int FAST_FUNC shell_builtin_ulimit(char **argv) | ||
22 | { | ||
23 | return 1; | ||
24 | } | ||
25 | #else | ||
26 | |||
19 | #include "builtin_ulimit.h" | 27 | #include "builtin_ulimit.h" |
20 | 28 | ||
21 | 29 | ||
@@ -226,3 +234,4 @@ int FAST_FUNC shell_builtin_ulimit(char **argv) | |||
226 | 234 | ||
227 | return 0; | 235 | return 0; |
228 | } | 236 | } |
237 | #endif | ||
diff --git a/win32/process.c b/win32/process.c index 0936e1c42..13bf81797 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -38,7 +38,9 @@ parse_interpreter(const char *cmd) | |||
38 | 38 | ||
39 | /* don't even try a .exe */ | 39 | /* don't even try a .exe */ |
40 | n = strlen(cmd); | 40 | n = strlen(cmd); |
41 | if (n >= 4 && !strcasecmp(cmd+n-4, ".exe")) | 41 | if (n >= 4 && |
42 | (!strcasecmp(cmd+n-4, ".exe") || | ||
43 | !strcasecmp(cmd+n-4, ".com"))) | ||
42 | return NULL; | 44 | return NULL; |
43 | 45 | ||
44 | fd = open(cmd, O_RDONLY); | 46 | fd = open(cmd, O_RDONLY); |