- include strings.h for str{,n}casecmp
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Fri, 19 May 2006 12:30:46 +0000 (12:30 -0000)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Fri, 19 May 2006 12:30:46 +0000 (12:30 -0000)
  Thanks to Rich Felker for pointing this out.

editors/awk.c
editors/vi.c
libbb/u_signal_names.c
networking/wget.c

index cce3b562a187aae9a816afa5c1c97bc2190e8560..82a399228847096af9c34cedc734d83947276e74 100644 (file)
@@ -12,6 +12,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+#include <strings.h>
 #include <time.h>
 #include <math.h>
 #include <ctype.h>
index 2852b384a32b743e20b708940af0bc4cf9ab196c..0ef894b8898b36bfce5e5b2351cabaa0a77c8b06 100644 (file)
@@ -3,9 +3,24 @@
  * tiny vi.c: A small 'vi' clone
  * Copyright (C) 2000, 2001 Sterling Huxley <sterling@europa.com>
  *
- * 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <termios.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
@@ -70,9 +86,6 @@
 #include <stdarg.h>
 #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)
index be444a97bb9916031647cff157d31ae5c1e3c047..3ab60354014ed466cbff3bce77f08c727b6dd1d1 100644 (file)
@@ -24,6 +24,7 @@
 #include <signal.h>
 #include <ctype.h>
 #include <string.h>
+#include <strings.h>
 #include <stdlib.h>
 #include <stdio.h>
 
index 90ab48f9b5016d6025be195de99e96bdfcf064b8..6efa3bf217d5c33d9a0ac484b18a141506cb0db9 100644 (file)
@@ -12,6 +12,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <signal.h>
 #include <sys/ioctl.h>