From 0c4c053c9df30528784f4da7e91b6e5b90121f56 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 19 May 2006 12:30:46 +0000 Subject: [PATCH] - include strings.h for str{,n}casecmp Thanks to Rich Felker for pointing this out. --- editors/awk.c | 1 + editors/vi.c | 53 ++++++++++++++++++++++++------------------ libbb/u_signal_names.c | 1 + networking/wget.c | 1 + 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/editors/awk.c b/editors/awk.c index cce3b562a..82a399228 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/editors/vi.c b/editors/vi.c index 2852b384a..0ef894b88 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -3,9 +3,24 @@ * tiny vi.c: A small 'vi' clone * Copyright (C) 2000, 2001 Sterling Huxley * - * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +static const char vi_Version[] = + "$Id: vi.c,v 1.38 2004/08/19 19:15:06 andersen Exp $"; + /* * To compile for standalone use: * gcc -Wall -Os -s -DSTANDALONE -o vi vi.c @@ -53,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -70,9 +86,6 @@ #include #ifndef STANDALONE #include "busybox.h" -#define vi_Version BB_VER " " BB_BT -#else -#define vi_Version "standalone" #endif /* STANDALONE */ #ifdef CONFIG_LOCALE_SUPPORT @@ -1072,10 +1085,9 @@ static void colon(Byte * buf) #endif /* CONFIG_FEATURE_VI_SEARCH */ } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version psb("%s", vi_Version); - } else if (strncasecmp((char *) cmd, "write", i) == 0 // write text to file - || strncasecmp((char *) cmd, "wq", i) == 0 - || strncasecmp((char *) cmd, "wn", i) == 0 - || strncasecmp((char *) cmd, "x", i) == 0) { + } else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file + (strncasecmp((char *) cmd, "wq", i) == 0) || + (strncasecmp((char *) cmd, "x", i) == 0)) { // is there a file name to write to? if (strlen((char *) args) > 0) { fn = args; @@ -1112,9 +1124,7 @@ static void colon(Byte * buf) file_modified = 0; last_file_modified = -1; } - if ((cmd[0] == 'x' || cmd[1] == 'q' || cmd[1] == 'n' || - cmd[0] == 'X' || cmd[1] == 'Q' || cmd[1] == 'N') - && l == ch) { + if ((cmd[0] == 'x' || cmd[1] == 'q') && l == ch) { editing = 0; } } @@ -3423,10 +3433,9 @@ key_cmd_mode: } else { editing = 0; } - } else if (strncasecmp((char *) p, "write", cnt) == 0 - || strncasecmp((char *) p, "wq", cnt) == 0 - || strncasecmp((char *) p, "wn", cnt) == 0 - || strncasecmp((char *) p, "x", cnt) == 0) { + } else if (strncasecmp((char *) p, "write", cnt) == 0 || + strncasecmp((char *) p, "wq", cnt) == 0 || + strncasecmp((char *) p, "x", cnt) == 0) { cnt = file_write(cfn, text, end - 1); if (cnt < 0) { if (cnt == -1) @@ -3435,8 +3444,7 @@ key_cmd_mode: file_modified = 0; last_file_modified = -1; psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt); - if (p[0] == 'x' || p[1] == 'q' || p[1] == 'n' || - p[0] == 'X' || p[1] == 'Q' || p[1] == 'N') { + if (p[0] == 'x' || p[1] == 'q') { editing = 0; } } @@ -3617,13 +3625,12 @@ key_cmd_mode: indicate_error(c); break; } - if (file_modified) { + if (file_modified #ifdef CONFIG_FEATURE_VI_READONLY - if (vi_readonly || readonly) { - psbs("\"%s\" File is read only", cfn); - break; - } -#endif /* CONFIG_FEATURE_VI_READONLY */ + && ! vi_readonly + && ! readonly +#endif /* CONFIG_FEATURE_VI_READONLY */ + ) { cnt = file_write(cfn, text, end - 1); if (cnt < 0) { if (cnt == -1) diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c index be444a97b..3ab603540 100644 --- a/libbb/u_signal_names.c +++ b/libbb/u_signal_names.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/networking/wget.c b/networking/wget.c index 90ab48f9b..6efa3bf21 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include -- 2.25.1