aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.flags8
-rw-r--r--editors/sed.c15
-rwxr-xr-xscripts/gcc-version.sh12
3 files changed, 28 insertions, 7 deletions
diff --git a/Makefile.flags b/Makefile.flags
index b39dfbb3c..9de52d89a 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -20,16 +20,22 @@ CFLAGS += $(call cc-option,-Wall -Wshadow,)
ifeq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Werror,)
endif
-CFLAGS += $(call cc-option,-Wundef -Wold-style-definition -Wstrict-prototypes,)
+CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon.
+
+# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
+CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
+
+# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
ifneq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
endif
+
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
# -fno-guess-branch-probability: prohibit pseudo-random guessing
# of branch probabilities (hopefully makes bloatcheck more stable):
diff --git a/editors/sed.c b/editors/sed.c
index 70be2e824..bf40877e4 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -422,8 +422,10 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr)
if (sed_cmd->end_line || sed_cmd->end_match)
bb_error_msg_and_die("command only uses one address");
cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string);
- if (sed_cmd->cmd == 'w')
+ if (sed_cmd->cmd == 'w') {
sed_cmd->sw_file = xfopen(sed_cmd->string, "w");
+ sed_cmd->sw_last_char = '\n';
+ }
/* handle branch commands */
} else if (strchr(":btT", sed_cmd->cmd)) {
int length;
@@ -726,7 +728,8 @@ enum {
static char *get_next_line(char *gets_char)
{
char *temp = NULL;
- int len, gc;
+ int len;
+ char gc;
flush_append();
@@ -744,9 +747,11 @@ static char *get_next_line(char *gets_char)
char c = temp[len-1];
if (c == '\n' || c == '\0') {
temp[len-1] = '\0';
- gc = (unsigned char)c;
- break;
+ gc = c;
}
+ /* else we put NO_EOL_CHAR into *gets_char */
+ break;
+
/* NB: I had the idea of peeking next file(s) and returning
* NO_EOL_CHAR only if it is the *last* non-empty
* input file. But there is a case where this won't work:
@@ -754,8 +759,6 @@ static char *get_next_line(char *gets_char)
* file2: "c no\nd no"
* sed -ne 's/woo/bang/p' input1 input2 => "a bang\nb bang"
* (note: *no* newline after "b bang"!) */
-
- break;
}
/* Close this file and advance to next one */
fclose(bbg.input_file_list[bbg.current_input_file++]);
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
new file mode 100755
index 000000000..34510804f
--- /dev/null
+++ b/scripts/gcc-version.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# gcc-version gcc-command
+#
+# Prints the gcc version of `gcc-command' in a canonical 4-digit form
+# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
+#
+
+compiler="$*"
+
+MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
+printf '%02d%02d\n' $MAJ_MIN