Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/sort Don't recognize "+3" after -- or after the firs...



details:   https://anonhg.NetBSD.org/src/rev/299011206a67
branches:  trunk
changeset: 755193:299011206a67
user:      dholland <dholland%NetBSD.org@localhost>
date:      Thu May 27 05:52:29 2010 +0000

description:
Don't recognize "+3" after -- or after the first non-option argument.
This prevents converting "+3" into "-k4.1" in places where getopt
won't recognize it, which in turn prevents silly error messages and
lossage trying to sort files whose names begin with +. PR 43358.

diffstat:

 usr.bin/sort/init.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r de49b48df070 -r 299011206a67 usr.bin/sort/init.c
--- a/usr.bin/sort/init.c       Thu May 27 05:41:54 2010 +0000
+++ b/usr.bin/sort/init.c       Thu May 27 05:52:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.24 2009/11/06 18:34:22 joerg Exp $  */
+/*     $NetBSD: init.c,v 1.25 2010/05/27 05:52:29 dholland Exp $       */
 
 /*-
  * Copyright (c) 2000-2003 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 
 #include "sort.h"
 
-__RCSID("$NetBSD: init.c,v 1.24 2009/11/06 18:34:22 joerg Exp $");
+__RCSID("$NetBSD: init.c,v 1.25 2010/05/27 05:52:29 dholland Exp $");
 
 #include <ctype.h>
 #include <string.h>
@@ -249,6 +249,16 @@
        size_t sz;
 
        for (i = 1; i < *argc; i++) {
+               /*
+                * Stop where getopt will stop, to avoid turning e.g.
+                * "sort x +3" into "sort x -k4.1" which will croak if
+                * +3 was in fact really a file name.
+                */
+               if (argv[i][0] == '-' && argv[i][1] == '-')
+                       break;
+               if (argv[i][0] != '-' && argv[i][0] != '+')
+                       break;
+
                if (argv[i][0] != '+' && !fplus)
                        continue;
 



Home | Main Index | Thread Index | Old Index