diff options
-rw-r--r-- | archival/Config.in | 14 | ||||
-rw-r--r-- | archival/gzip.c | 6 | ||||
-rw-r--r-- | include/libbb.h | 3 | ||||
-rw-r--r-- | include/mingw.h | 13 | ||||
-rw-r--r-- | libbb/Kbuild | 13 | ||||
-rw-r--r-- | libbb/git.c | 31 | ||||
-rw-r--r-- | libbb/git.h | 5 | ||||
-rw-r--r-- | libbb/lineedit.c | 2 | ||||
-rw-r--r-- | libbb/mingw.c | 5 | ||||
-rw-r--r-- | libbb/regex.c | 2 | ||||
-rw-r--r-- | libbb/strbuf.c | 11 | ||||
-rw-r--r-- | libbb/strbuf_file.c | 4 | ||||
-rw-r--r-- | libbb/termios.c | 2 | ||||
-rw-r--r-- | libbb/usage.c | 81 | ||||
-rw-r--r-- | networking/wget.c | 1 | ||||
-rw-r--r-- | shell/ash_mingw.c | 4 |
16 files changed, 83 insertions, 114 deletions
diff --git a/archival/Config.in b/archival/Config.in index f21509271..22f985ac0 100644 --- a/archival/Config.in +++ b/archival/Config.in | |||
@@ -154,7 +154,7 @@ config FEATURE_TAR_CREATE | |||
154 | config FEATURE_TAR_BZIP2 | 154 | config FEATURE_TAR_BZIP2 |
155 | bool "Enable -j option to handle .tar.bz2 files" | 155 | bool "Enable -j option to handle .tar.bz2 files" |
156 | default n | 156 | default n |
157 | depends on TAR | 157 | depends on TAR && !MINGW32 # open_transformer.c |
158 | help | 158 | help |
159 | If you enable this option you'll be able to extract | 159 | If you enable this option you'll be able to extract |
160 | archives compressed with bzip2. | 160 | archives compressed with bzip2. |
@@ -162,7 +162,7 @@ config FEATURE_TAR_BZIP2 | |||
162 | config FEATURE_TAR_LZMA | 162 | config FEATURE_TAR_LZMA |
163 | bool "Enable -a option to handle .tar.lzma files" | 163 | bool "Enable -a option to handle .tar.lzma files" |
164 | default n | 164 | default n |
165 | depends on TAR | 165 | depends on TAR && !MINGW32 # open_transformer.c |
166 | help | 166 | help |
167 | If you enable this option you'll be able to extract | 167 | If you enable this option you'll be able to extract |
168 | archives compressed with lzma. | 168 | archives compressed with lzma. |
@@ -178,7 +178,7 @@ config FEATURE_TAR_FROM | |||
178 | config FEATURE_TAR_GZIP | 178 | config FEATURE_TAR_GZIP |
179 | bool "Enable -z option" | 179 | bool "Enable -z option" |
180 | default y | 180 | default y |
181 | depends on TAR | 181 | depends on TAR && !MINGW32 # open_transformer.c |
182 | help | 182 | help |
183 | If you enable this option tar will be able to call gzip, | 183 | If you enable this option tar will be able to call gzip, |
184 | when creating or extracting tar gziped archives. | 184 | when creating or extracting tar gziped archives. |
@@ -186,7 +186,7 @@ config FEATURE_TAR_GZIP | |||
186 | config FEATURE_TAR_COMPRESS | 186 | config FEATURE_TAR_COMPRESS |
187 | bool "Enable -Z option" | 187 | bool "Enable -Z option" |
188 | default n | 188 | default n |
189 | depends on TAR | 189 | depends on TAR && !MINGW32 # open_transformer.c |
190 | help | 190 | help |
191 | If you enable this option tar will be able to call uncompress, | 191 | If you enable this option tar will be able to call uncompress, |
192 | when extracting .tar.Z archives. | 192 | when extracting .tar.Z archives. |
@@ -271,7 +271,7 @@ comment "Common options for dpkg and dpkg_deb" | |||
271 | config FEATURE_DEB_TAR_GZ | 271 | config FEATURE_DEB_TAR_GZ |
272 | bool "gzip debian packages (normal)" | 272 | bool "gzip debian packages (normal)" |
273 | default y if DPKG || DPKG_DEB | 273 | default y if DPKG || DPKG_DEB |
274 | depends on DPKG || DPKG_DEB | 274 | depends on (DPKG || DPKG_DEB) && !MINGW32 # open_transformer.c |
275 | help | 275 | help |
276 | This is the default compression method inside the debian ar file. | 276 | This is the default compression method inside the debian ar file. |
277 | 277 | ||
@@ -280,7 +280,7 @@ config FEATURE_DEB_TAR_GZ | |||
280 | config FEATURE_DEB_TAR_BZ2 | 280 | config FEATURE_DEB_TAR_BZ2 |
281 | bool "bzip2 debian packages" | 281 | bool "bzip2 debian packages" |
282 | default n | 282 | default n |
283 | depends on DPKG || DPKG_DEB | 283 | depends on (DPKG || DPKG_DEB) && !MINGW32 # open_transformer.c |
284 | help | 284 | help |
285 | This allows dpkg and dpkg-deb to extract deb's that are compressed internally | 285 | This allows dpkg and dpkg-deb to extract deb's that are compressed internally |
286 | with bzip2 instead of gzip. | 286 | with bzip2 instead of gzip. |
@@ -291,7 +291,7 @@ config FEATURE_DEB_TAR_BZ2 | |||
291 | config FEATURE_DEB_TAR_LZMA | 291 | config FEATURE_DEB_TAR_LZMA |
292 | bool "lzma debian packages" | 292 | bool "lzma debian packages" |
293 | default n | 293 | default n |
294 | depends on DPKG || DPKG_DEB | 294 | depends on (DPKG || DPKG_DEB) && !MINGW32 # open_transformer.c |
295 | help | 295 | help |
296 | This allows dpkg and dpkg-deb to extract deb's that are compressed | 296 | This allows dpkg and dpkg-deb to extract deb's that are compressed |
297 | internally with lzma instead of gzip. | 297 | internally with lzma instead of gzip. |
diff --git a/archival/gzip.c b/archival/gzip.c index fdf2a794c..14d1ef2b0 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -1589,6 +1589,9 @@ static void compress_block(ct_data * ltree, ct_data * dtree) | |||
1589 | * trees or store, and output the encoded block to the zip file. This function | 1589 | * trees or store, and output the encoded block to the zip file. This function |
1590 | * returns the total compressed length for the file so far. | 1590 | * returns the total compressed length for the file so far. |
1591 | */ | 1591 | */ |
1592 | #ifdef __MINGW32__ | ||
1593 | #define eof eof_ | ||
1594 | #endif | ||
1592 | static ulg flush_block(char *buf, ulg stored_len, int eof) | 1595 | static ulg flush_block(char *buf, ulg stored_len, int eof) |
1593 | { | 1596 | { |
1594 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ | 1597 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ |
@@ -1672,6 +1675,9 @@ static ulg flush_block(char *buf, ulg stored_len, int eof) | |||
1672 | 1675 | ||
1673 | return G2.compressed_len >> 3; | 1676 | return G2.compressed_len >> 3; |
1674 | } | 1677 | } |
1678 | #ifdef __MINGW32__ | ||
1679 | #undef eof | ||
1680 | #endif | ||
1675 | 1681 | ||
1676 | 1682 | ||
1677 | /* =========================================================================== | 1683 | /* =========================================================================== |
diff --git a/include/libbb.h b/include/libbb.h index ea02a9978..ce90a11c7 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -410,6 +410,7 @@ extern void *xzalloc(size_t size); | |||
410 | extern void *xrealloc(void *old, size_t size); | 410 | extern void *xrealloc(void *old, size_t size); |
411 | 411 | ||
412 | extern ssize_t safe_read(int fd, void *buf, size_t count); | 412 | extern ssize_t safe_read(int fd, void *buf, size_t count); |
413 | extern void xread(int fd, void *buf, size_t count); | ||
413 | extern ssize_t full_read(int fd, void *buf, size_t count); | 414 | extern ssize_t full_read(int fd, void *buf, size_t count); |
414 | extern unsigned char xread_char(int fd); | 415 | extern unsigned char xread_char(int fd); |
415 | extern char *reads(int fd, char *buf, size_t count); | 416 | extern char *reads(int fd, char *buf, size_t count); |
@@ -419,6 +420,7 @@ extern void *xmalloc_open_read_close(const char *filename, size_t *sizep); | |||
419 | 420 | ||
420 | #define safe_write(fd, buf, count) bb_safe_write(fd, buf, count) | 421 | #define safe_write(fd, buf, count) bb_safe_write(fd, buf, count) |
421 | extern ssize_t safe_write(int fd, const void *buf, size_t count); | 422 | extern ssize_t safe_write(int fd, const void *buf, size_t count); |
423 | extern void xwrite(int fd, const void *buf, size_t count); | ||
422 | extern ssize_t full_write(int fd, const void *buf, size_t count); | 424 | extern ssize_t full_write(int fd, const void *buf, size_t count); |
423 | 425 | ||
424 | /* Reads and prints to stdout till eof, then closes FILE. Exits on error: */ | 426 | /* Reads and prints to stdout till eof, then closes FILE. Exits on error: */ |
@@ -442,6 +444,7 @@ extern FILE *fopen_or_warn_stdin(const char *filename); | |||
442 | 444 | ||
443 | /* Convert each alpha char in str to lower-case */ | 445 | /* Convert each alpha char in str to lower-case */ |
444 | extern char* str_tolower(char *str); | 446 | extern char* str_tolower(char *str); |
447 | extern char* xstrndup(const char *s, int n); | ||
445 | 448 | ||
446 | char *utoa(unsigned n); | 449 | char *utoa(unsigned n); |
447 | #ifdef __MINGW32__ | 450 | #ifdef __MINGW32__ |
diff --git a/include/mingw.h b/include/mingw.h index 500308947..1c3728ee4 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -83,8 +83,10 @@ static inline int symlink(const char *oldpath, const char *newpath) | |||
83 | { errno = ENOSYS; return -1; } | 83 | { errno = ENOSYS; return -1; } |
84 | static inline int fchmod(int fildes, mode_t mode) | 84 | static inline int fchmod(int fildes, mode_t mode) |
85 | { errno = ENOSYS; return -1; } | 85 | { errno = ENOSYS; return -1; } |
86 | /* | ||
86 | static inline int fork(void) | 87 | static inline int fork(void) |
87 | { errno = ENOSYS; return -1; } | 88 | { errno = ENOSYS; return -1; } |
89 | */ | ||
88 | static inline unsigned int alarm(unsigned int seconds) | 90 | static inline unsigned int alarm(unsigned int seconds) |
89 | { return 0; } | 91 | { return 0; } |
90 | static inline int fsync(int fd) | 92 | static inline int fsync(int fd) |
@@ -93,7 +95,7 @@ static inline int getppid(void) | |||
93 | { return 1; } | 95 | { return 1; } |
94 | static inline void sync(void) | 96 | static inline void sync(void) |
95 | {} | 97 | {} |
96 | static inline int getuid() | 98 | static inline int getuid(void) |
97 | { return 1; } | 99 | { return 1; } |
98 | static inline struct passwd *getpwnam(const char *name) | 100 | static inline struct passwd *getpwnam(const char *name) |
99 | { return NULL; } | 101 | { return NULL; } |
@@ -148,6 +150,13 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out); | |||
148 | int sigaction(int sig, struct sigaction *in, struct sigaction *out); | 150 | int sigaction(int sig, struct sigaction *in, struct sigaction *out); |
149 | int link(const char *oldpath, const char *newpath); | 151 | int link(const char *oldpath, const char *newpath); |
150 | time_t tm_to_time_t(const struct tm *tm); | 152 | time_t tm_to_time_t(const struct tm *tm); |
153 | char *strsep(char **stringp, const char *delim); | ||
154 | char *strptime(const char *s, const char *format, struct tm *tm); | ||
155 | void unsetenv(const char *env); | ||
156 | char *realpath(const char *path, char *resolved_path); | ||
157 | int fdprintf(int fd, const char *format, ...); | ||
158 | int setenv(const char *name, const char *value, int replace); | ||
159 | size_t strlcpy(char *dest, const char *src, size_t size); | ||
151 | 160 | ||
152 | /* | 161 | /* |
153 | * replacements of existing functions | 162 | * replacements of existing functions |
@@ -251,7 +260,7 @@ char **copy_environ(void); | |||
251 | void free_environ(char **env); | 260 | void free_environ(char **env); |
252 | char **env_setenv(char **env, const char *name); | 261 | char **env_setenv(char **env, const char *name); |
253 | 262 | ||
254 | const char *get_busybox_exec_path(); | 263 | const char *get_busybox_exec_path(void); |
255 | /* | 264 | /* |
256 | * A replacement of main() that ensures that argv[0] has a path | 265 | * A replacement of main() that ensures that argv[0] has a path |
257 | */ | 266 | */ |
diff --git a/libbb/Kbuild b/libbb/Kbuild index b3560bd0b..1ef67a8b7 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild | |||
@@ -13,11 +13,17 @@ lib-y += change_identity.o | |||
13 | lib-y += create_icmp6_socket.o | 13 | lib-y += create_icmp6_socket.o |
14 | lib-y += create_icmp_socket.o | 14 | lib-y += create_icmp_socket.o |
15 | lib-y += device_open.o | 15 | lib-y += device_open.o |
16 | lib-y += get_console.o | ||
16 | lib-y += inet_common.o | 17 | lib-y += inet_common.o |
18 | lib-y += inode_hash.o | ||
17 | lib-y += kernel_version.o | 19 | lib-y += kernel_version.o |
18 | lib-y += login.o | 20 | lib-y += login.o |
19 | lib-y += makedev.o | 21 | lib-y += makedev.o |
20 | lib-y += match_fstype.o | 22 | lib-y += match_fstype.o |
23 | lib-y += obscure.o | ||
24 | lib-y += procps.o | ||
25 | lib-y += restricted_shell.o | ||
26 | lib-y += run_shell.o | ||
21 | lib-y += setup_environment.o | 27 | lib-y += setup_environment.o |
22 | lib-y += speed_table.o | 28 | lib-y += speed_table.o |
23 | lib-y += vfork_daemon_rexec.o | 29 | lib-y += vfork_daemon_rexec.o |
@@ -46,7 +52,6 @@ lib-y += fgets_str.o | |||
46 | lib-y += find_pid_by_name.o | 52 | lib-y += find_pid_by_name.o |
47 | lib-y += find_root_device.o | 53 | lib-y += find_root_device.o |
48 | lib-y += full_write.o | 54 | lib-y += full_write.o |
49 | lib-y += get_console.o | ||
50 | lib-y += get_last_path_component.o | 55 | lib-y += get_last_path_component.o |
51 | lib-y += get_line_from_file.o | 56 | lib-y += get_line_from_file.o |
52 | lib-y += getopt32.o | 57 | lib-y += getopt32.o |
@@ -54,7 +59,6 @@ lib-y += herror_msg.o | |||
54 | lib-y += herror_msg_and_die.o | 59 | lib-y += herror_msg_and_die.o |
55 | lib-y += human_readable.o | 60 | lib-y += human_readable.o |
56 | lib-y += info_msg.o | 61 | lib-y += info_msg.o |
57 | lib-y += inode_hash.o | ||
58 | lib-y += isdirectory.o | 62 | lib-y += isdirectory.o |
59 | lib-y += last_char_is.o | 63 | lib-y += last_char_is.o |
60 | lib-y += lineedit.o | 64 | lib-y += lineedit.o |
@@ -64,7 +68,6 @@ lib-y += md5.o | |||
64 | lib-y += messages.o | 68 | lib-y += messages.o |
65 | lib-y += mode_string.o | 69 | lib-y += mode_string.o |
66 | lib-y += mtab_file.o | 70 | lib-y += mtab_file.o |
67 | lib-y += obscure.o | ||
68 | lib-y += parse_mode.o | 71 | lib-y += parse_mode.o |
69 | lib-y += perror_msg.o | 72 | lib-y += perror_msg.o |
70 | lib-y += perror_msg_and_die.o | 73 | lib-y += perror_msg_and_die.o |
@@ -72,12 +75,9 @@ lib-y += perror_nomsg.o | |||
72 | lib-y += perror_nomsg_and_die.o | 75 | lib-y += perror_nomsg_and_die.o |
73 | lib-y += pidfile.o | 76 | lib-y += pidfile.o |
74 | lib-y += process_escape_sequence.o | 77 | lib-y += process_escape_sequence.o |
75 | lib-y += procps.o | ||
76 | lib-y += read.o | 78 | lib-y += read.o |
77 | lib-y += recursive_action.o | 79 | lib-y += recursive_action.o |
78 | lib-y += remove_file.o | 80 | lib-y += remove_file.o |
79 | lib-y += restricted_shell.o | ||
80 | lib-y += run_shell.o | ||
81 | lib-y += safe_strncpy.o | 81 | lib-y += safe_strncpy.o |
82 | lib-y += safe_write.o | 82 | lib-y += safe_write.o |
83 | lib-y += sha1.o | 83 | lib-y += sha1.o |
@@ -140,6 +140,5 @@ lib-$(CONFIG_MINGW32) += strbuf_file.o | |||
140 | lib-$(CONFIG_MINGW32) += strlcpy.o | 140 | lib-$(CONFIG_MINGW32) += strlcpy.o |
141 | lib-$(CONFIG_MINGW32) += termios.o | 141 | lib-$(CONFIG_MINGW32) += termios.o |
142 | lib-$(CONFIG_MINGW32) += trace.o | 142 | lib-$(CONFIG_MINGW32) += trace.o |
143 | lib-$(CONFIG_MINGW32) += usage.o | ||
144 | lib-$(CONFIG_MINGW32) += winansi.o | 143 | lib-$(CONFIG_MINGW32) += winansi.o |
145 | lib-$(CONFIG_MINGW32) += write_or_die.o | 144 | lib-$(CONFIG_MINGW32) += write_or_die.o |
diff --git a/libbb/git.c b/libbb/git.c index 3ca8a9424..668f8c118 100644 --- a/libbb/git.c +++ b/libbb/git.c | |||
@@ -1,13 +1,42 @@ | |||
1 | #include "libbb.h" | 1 | #include "libbb.h" |
2 | #include "git.h" | 2 | #include "git.h" |
3 | 3 | ||
4 | #define die bb_error_msg_and_die | ||
5 | |||
6 | /* | ||
7 | * xwrite() is the same a write(), but it automatically restarts write() | ||
8 | * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT | ||
9 | * GUARANTEE that "len" bytes is written even if the operation is successful. | ||
10 | */ | ||
11 | ssize_t _xwrite(int fd, const void *buf, size_t len) | ||
12 | { | ||
13 | ssize_t nr; | ||
14 | while (1) { | ||
15 | nr = write(fd, buf, len); | ||
16 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | ||
17 | continue; | ||
18 | return nr; | ||
19 | } | ||
20 | } | ||
21 | |||
22 | ssize_t _xread(int fd, void *buf, size_t len) | ||
23 | { | ||
24 | ssize_t nr; | ||
25 | while (1) { | ||
26 | nr = read(fd, buf, len); | ||
27 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | ||
28 | continue; | ||
29 | return nr; | ||
30 | } | ||
31 | } | ||
32 | |||
4 | ssize_t write_in_full(int fd, const void *buf, size_t count) | 33 | ssize_t write_in_full(int fd, const void *buf, size_t count) |
5 | { | 34 | { |
6 | const char *p = buf; | 35 | const char *p = buf; |
7 | ssize_t total = 0; | 36 | ssize_t total = 0; |
8 | 37 | ||
9 | while (count > 0) { | 38 | while (count > 0) { |
10 | ssize_t written = xwrite(fd, p, count); | 39 | ssize_t written = _xwrite(fd, p, count); |
11 | if (written < 0) | 40 | if (written < 0) |
12 | return -1; | 41 | return -1; |
13 | if (!written) { | 42 | if (!written) { |
diff --git a/libbb/git.h b/libbb/git.h index 3274af34d..07ef93bf4 100644 --- a/libbb/git.h +++ b/libbb/git.h | |||
@@ -1,4 +1,7 @@ | |||
1 | ssize_t write_in_full(int fd, const void *buf, size_t count); | 1 | ssize_t write_in_full(int fd, const void *buf, size_t count); |
2 | void *xcalloc(size_t nmemb, size_t size); | ||
3 | ssize_t _xwrite(int fd, const void *buf, size_t len); | ||
4 | ssize_t _xread(int fd, void *buf, size_t len); | ||
2 | 5 | ||
3 | #define alloc_nr(x) (((x)+16)*3/2) | 6 | #define alloc_nr(x) (((x)+16)*3/2) |
4 | 7 | ||
@@ -19,3 +22,5 @@ static inline int is_absolute_path(const char *path) | |||
19 | } | 22 | } |
20 | 23 | ||
21 | #define NORETURN ATTRIBUTE_NORETURN | 24 | #define NORETURN ATTRIBUTE_NORETURN |
25 | #define die bb_error_msg_and_die | ||
26 | #define error(...) fprintf(stderr, __VA_ARGS__) | ||
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index e56dd20b0..a4b0ff045 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -170,7 +170,7 @@ static void input_backward(unsigned num) | |||
170 | if (cmdedit_x >= num) { | 170 | if (cmdedit_x >= num) { |
171 | cmdedit_x -= num; | 171 | cmdedit_x -= num; |
172 | if (num <= 4) { | 172 | if (num <= 4) { |
173 | printf("\b\b\b\b" + (4-num)); | 173 | printf("%s", "\b\b\b\b" + (4-num)); /* "%s" to stop mingw warning */ |
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | printf("\033[%uD", num); | 176 | printf("\033[%uD", num); |
diff --git a/libbb/mingw.c b/libbb/mingw.c index aa1417acf..ab582215b 100644 --- a/libbb/mingw.c +++ b/libbb/mingw.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "win32.h" | 2 | #include "win32.h" |
3 | #include "strbuf.h" | 3 | #include "strbuf.h" |
4 | #include "run-command.h" | 4 | #include "run-command.h" |
5 | #include "git.h" | ||
5 | 6 | ||
6 | unsigned int _CRT_fmode = _O_BINARY; | 7 | unsigned int _CRT_fmode = _O_BINARY; |
7 | 8 | ||
@@ -131,13 +132,15 @@ int mingw_open (const char *filename, int oflags, ...) | |||
131 | { | 132 | { |
132 | va_list args; | 133 | va_list args; |
133 | unsigned mode; | 134 | unsigned mode; |
135 | int fd; | ||
136 | |||
134 | va_start(args, oflags); | 137 | va_start(args, oflags); |
135 | mode = va_arg(args, int); | 138 | mode = va_arg(args, int); |
136 | va_end(args); | 139 | va_end(args); |
137 | 140 | ||
138 | if (!strcmp(filename, "/dev/null")) | 141 | if (!strcmp(filename, "/dev/null")) |
139 | filename = "nul"; | 142 | filename = "nul"; |
140 | int fd = open(filename, oflags, mode); | 143 | fd = open(filename, oflags, mode); |
141 | if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { | 144 | if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { |
142 | DWORD attrs = GetFileAttributes(filename); | 145 | DWORD attrs = GetFileAttributes(filename); |
143 | if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) | 146 | if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) |
diff --git a/libbb/regex.c b/libbb/regex.c index 87b33e466..2cca16934 100644 --- a/libbb/regex.c +++ b/libbb/regex.c | |||
@@ -24,7 +24,9 @@ | |||
24 | #pragma alloca | 24 | #pragma alloca |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #ifndef _GNU_SOURCE | ||
27 | #define _GNU_SOURCE | 28 | #define _GNU_SOURCE |
29 | #endif | ||
28 | 30 | ||
29 | /* We need this for `regex.h', and perhaps for the Emacs include files. */ | 31 | /* We need this for `regex.h', and perhaps for the Emacs include files. */ |
30 | #include <sys/types.h> | 32 | #include <sys/types.h> |
diff --git a/libbb/strbuf.c b/libbb/strbuf.c index d98b0fd41..98659d448 100644 --- a/libbb/strbuf.c +++ b/libbb/strbuf.c | |||
@@ -2,15 +2,6 @@ | |||
2 | #include "strbuf.h" | 2 | #include "strbuf.h" |
3 | #include "git.h" | 3 | #include "git.h" |
4 | 4 | ||
5 | int prefixcmp(const char *str, const char *prefix) | ||
6 | { | ||
7 | for (; ; str++, prefix++) | ||
8 | if (!*prefix) | ||
9 | return 0; | ||
10 | else if (*str != *prefix) | ||
11 | return (unsigned char)*prefix - (unsigned char)*str; | ||
12 | } | ||
13 | |||
14 | /* | 5 | /* |
15 | * Used as the default ->buf value, so that people can always assume | 6 | * Used as the default ->buf value, so that people can always assume |
16 | * buf is non NULL and ->buf is NUL terminated even for a freshly | 7 | * buf is non NULL and ->buf is NUL terminated even for a freshly |
@@ -275,7 +266,7 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint) | |||
275 | for (;;) { | 266 | for (;;) { |
276 | ssize_t cnt; | 267 | ssize_t cnt; |
277 | 268 | ||
278 | cnt = xread(fd, sb->buf + sb->len, sb->alloc - sb->len - 1); | 269 | cnt = _xread(fd, sb->buf + sb->len, sb->alloc - sb->len - 1); |
279 | if (cnt < 0) { | 270 | if (cnt < 0) { |
280 | if (oldalloc == 0) | 271 | if (oldalloc == 0) |
281 | strbuf_release(sb); | 272 | strbuf_release(sb); |
diff --git a/libbb/strbuf_file.c b/libbb/strbuf_file.c index fb2ba7966..cdacf5344 100644 --- a/libbb/strbuf_file.c +++ b/libbb/strbuf_file.c | |||
@@ -31,14 +31,14 @@ int sfprintf(struct strbuf_file *sf, const char *fmt, ...) | |||
31 | len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap); | 31 | len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap); |
32 | va_end(ap); | 32 | va_end(ap); |
33 | if (len < 0) | 33 | if (len < 0) |
34 | die("your vsnprintf is broken"); | 34 | bb_error_msg_and_die("your vsnprintf is broken"); |
35 | if (len > strbuf_avail(&sb)) { | 35 | if (len > strbuf_avail(&sb)) { |
36 | strbuf_grow(&sb, len); | 36 | strbuf_grow(&sb, len); |
37 | va_start(ap, fmt); | 37 | va_start(ap, fmt); |
38 | len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap); | 38 | len = vsnprintf(sb.buf + sb.len, sb.alloc - sb.len, fmt, ap); |
39 | va_end(ap); | 39 | va_end(ap); |
40 | if (len > strbuf_avail(&sb)) { | 40 | if (len > strbuf_avail(&sb)) { |
41 | die("this should not happen, your snprintf is broken"); | 41 | bb_error_msg_and_die("this should not happen, your snprintf is broken"); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | strbuf_setlen(&sb, sb.len + len); | 44 | strbuf_setlen(&sb, sb.len + len); |
diff --git a/libbb/termios.c b/libbb/termios.c index 1291bf785..04eee7ced 100644 --- a/libbb/termios.c +++ b/libbb/termios.c | |||
@@ -260,7 +260,7 @@ int wincon_read(int fd, char *buf, int size) | |||
260 | static int initialized = 0; | 260 | static int initialized = 0; |
261 | 261 | ||
262 | if (fd != 0) | 262 | if (fd != 0) |
263 | die("wincon_read is for stdin only"); | 263 | bb_error_msg_and_die("wincon_read is for stdin only"); |
264 | if (cin == INVALID_HANDLE_VALUE || is_cygwin_tty(fd)) | 264 | if (cin == INVALID_HANDLE_VALUE || is_cygwin_tty(fd)) |
265 | return safe_read(fd, buf, size); | 265 | return safe_read(fd, buf, size); |
266 | if (!initialized) { | 266 | if (!initialized) { |
diff --git a/libbb/usage.c b/libbb/usage.c deleted file mode 100644 index 86bf68e21..000000000 --- a/libbb/usage.c +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | * GIT - The information manager from hell | ||
3 | * | ||
4 | * Copyright (C) Linus Torvalds, 2005 | ||
5 | */ | ||
6 | #include "libbb.h" | ||
7 | #include "git.h" | ||
8 | |||
9 | static void report(const char *prefix, const char *err, va_list params) | ||
10 | { | ||
11 | char msg[1024]; | ||
12 | vsnprintf(msg, sizeof(msg), err, params); | ||
13 | fprintf(stderr, "%s%s\n", prefix, msg); | ||
14 | } | ||
15 | |||
16 | static NORETURN void usage_builtin(const char *err) | ||
17 | { | ||
18 | fprintf(stderr, "usage: %s\n", err); | ||
19 | exit(129); | ||
20 | } | ||
21 | |||
22 | static NORETURN void die_builtin(const char *err, va_list params) | ||
23 | { | ||
24 | report("fatal: ", err, params); | ||
25 | exit(128); | ||
26 | } | ||
27 | |||
28 | static void error_builtin(const char *err, va_list params) | ||
29 | { | ||
30 | report("error: ", err, params); | ||
31 | } | ||
32 | |||
33 | static void warn_builtin(const char *warn, va_list params) | ||
34 | { | ||
35 | report("warning: ", warn, params); | ||
36 | } | ||
37 | |||
38 | /* If we are in a dlopen()ed .so write to a global variable would segfault | ||
39 | * (ugh), so keep things static. */ | ||
40 | static void (*usage_routine)(const char *err) NORETURN = usage_builtin; | ||
41 | static void (*die_routine)(const char *err, va_list params) NORETURN = die_builtin; | ||
42 | static void (*error_routine)(const char *err, va_list params) = error_builtin; | ||
43 | static void (*warn_routine)(const char *err, va_list params) = warn_builtin; | ||
44 | |||
45 | void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN) | ||
46 | { | ||
47 | die_routine = routine; | ||
48 | } | ||
49 | |||
50 | void usage(const char *err) | ||
51 | { | ||
52 | usage_routine(err); | ||
53 | } | ||
54 | |||
55 | void die(const char *err, ...) | ||
56 | { | ||
57 | va_list params; | ||
58 | |||
59 | va_start(params, err); | ||
60 | die_routine(err, params); | ||
61 | va_end(params); | ||
62 | } | ||
63 | |||
64 | int error(const char *err, ...) | ||
65 | { | ||
66 | va_list params; | ||
67 | |||
68 | va_start(params, err); | ||
69 | error_routine(err, params); | ||
70 | va_end(params); | ||
71 | return -1; | ||
72 | } | ||
73 | |||
74 | void warning(const char *warn, ...) | ||
75 | { | ||
76 | va_list params; | ||
77 | |||
78 | va_start(params, warn); | ||
79 | warn_routine(warn, params); | ||
80 | va_end(params); | ||
81 | } | ||
diff --git a/networking/wget.c b/networking/wget.c index 8752a6bd2..d6f76c8af 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -670,6 +670,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *fp, char *buf) | |||
670 | #ifdef __MINGW32__ | 670 | #ifdef __MINGW32__ |
671 | 671 | ||
672 | /* from include/mingw.h */ | 672 | /* from include/mingw.h */ |
673 | #undef fprintf /* winansi.c */ | ||
673 | #define fprintf(...) winansi_fprintf(__VA_ARGS__) | 674 | #define fprintf(...) winansi_fprintf(__VA_ARGS__) |
674 | 675 | ||
675 | /* Source: uclibc */ | 676 | /* Source: uclibc */ |
diff --git a/shell/ash_mingw.c b/shell/ash_mingw.c index a5295532d..a39919439 100644 --- a/shell/ash_mingw.c +++ b/shell/ash_mingw.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include "git.h" | ||
2 | |||
1 | extern void trace_printf(const char *format, ...); | 3 | extern void trace_printf(const char *format, ...); |
2 | extern void trace_argv_printf(const char **argv, const char *format, ...); | 4 | extern void trace_argv_printf(const char **argv, const char *format, ...); |
3 | 5 | ||
@@ -18,7 +20,7 @@ static union node *node_recv(int fd); | |||
18 | static inline void | 20 | static inline void |
19 | ser_read(int fd, void *buf, size_t len) | 21 | ser_read(int fd, void *buf, size_t len) |
20 | { | 22 | { |
21 | if (xread(fd, buf, len) != len) | 23 | if (_xread(fd, buf, len) != len) |
22 | die("Corrupted"); | 24 | die("Corrupted"); |
23 | } | 25 | } |
24 | 26 | ||