]> Zhao Yanbai Git Server - minix.git/commitdiff
Fix parameter parsing in cut
authorErik van der Kouwe <erik@minix3.org>
Thu, 21 Jan 2010 10:16:05 +0000 (10:16 +0000)
committerErik van der Kouwe <erik@minix3.org>
Thu, 21 Jan 2010 10:16:05 +0000 (10:16 +0000)
LICENSE
commands/simple/cut.c
include/time.h

diff --git a/LICENSE b/LICENSE
index 9cbf4712c6caa1db2c55838c5c9ba97d23f2903e..a119efa5f44dc93086bc34e7c95f10ed55b6401f 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -50,3 +50,13 @@ observe the conditions of the GPL with respect to this software. As
 clearly stated in Article 2 of the GPL, when GPL and nonGPL software are
 distributed together on the same medium, this aggregation does not cause
 the license of either part to apply to the other part.
+
+
+Acknowledgements
+
+This product includes software developed by the University of
+California, Berkeley and its contributors.
+
+This product includes software developed by Softweyr LLC, the
+University of California, Berkeley, and its contributors.
+
index 79d57f830db9bc7da6dd91885f2213fd934aaf7c..d3641cac1f18ded345750be881762c780ce5e784 100644 (file)
@@ -134,7 +134,10 @@ void get_args()
                                args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
                        if (!args[arg_ptr]) cuterror(POSITION_ERROR);
                        arg_ptr++;
+               } else if (line[i] != '-') {
+                       cuterror(SYNTAX_ERROR);
                }
+
                if (line[i] == '-') {
                        arg_ptr |= 1;
                        i++;
@@ -208,6 +211,7 @@ int main(argc, argv)
 int argc;
 char *argv[];
 {
+  char *linearg;
   int i = 1;
   int numberFilenames = 0;
   name = argv[0];
@@ -220,22 +224,29 @@ char *argv[];
                    case 'd':
                        if (mode == OPTIONC || mode == OPTIONB)
                                warn(DELIMITER_NOT_APPLICABLE, "d");
-                       delim = argv[i++][0];
+                       delim = argv[i - 1][2] ? 
+                               argv[i - 1][2] : argv[i++][0];
                        break;
                    case 'f':
-                       sprintf(line, "%s", argv[i++]);
+                       linearg = argv[i - 1][2] ? 
+                           (argv[i - 1] + 2) : argv[i++];
+                       sprintf(line, "%s", linearg);
                        if (mode == OPTIONC || mode == OPTIONB)
                                warn(OVERRIDING_PREVIOUS_MODE, "f");
                        mode = OPTIONF;
                        break;
                    case 'b':
-                       sprintf(line, "%s", argv[i++]);
+                       linearg = argv[i - 1][2] ? 
+                           (argv[i - 1] + 2) : argv[i++];
+                       sprintf(line, "%s", linearg);
                        if (mode == OPTIONF || mode == OPTIONC)
                                warn(OVERRIDING_PREVIOUS_MODE, "b");
                        mode = OPTIONB;
                        break;
                    case 'c':
-                       sprintf(line, "%s", argv[i++]);
+                       linearg = argv[i - 1][2] ? 
+                           (argv[i - 1] + 2) : argv[i++];
+                       sprintf(line, "%s", linearg);
                        if (mode == OPTIONF || mode == OPTIONB)
                                warn(OVERRIDING_PREVIOUS_MODE, "c");
                        mode = OPTIONC;
@@ -281,7 +292,7 @@ char *argv[];
                            case 'f':
                            case 'c':
                            case 'b':
-                           case 'd':   i += 2; break;
+                           case 'd':   i += argv[i][2] ? 1 : 2; break;
                            case 'n':
                            case 'i':
                            case 's':   i++;    break;
index e17c42f4e25440c938b6f463a6788c8c1e892539..e013dd180d9eb3fbb54a074ee448e909558d3e14 100644 (file)
@@ -59,6 +59,8 @@ _PROTOTYPE( char *asctime, (const struct tm *_timeptr)                        );
 _PROTOTYPE( char *ctime, (const time_t *_timer)                        );
 _PROTOTYPE( struct tm *gmtime, (const time_t *_timer)                  );
 _PROTOTYPE( struct tm *localtime, (const time_t *_timer)               );
+_PROTOTYPE( struct tm *localtime_r, (const time_t *const timep,
+                                       struct tm *tmp)                 );
 _PROTOTYPE( size_t strftime, (char *_s, size_t _max, const char *_fmt,
                                const struct tm *_timep)                );