aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2000-06-15 18:04:40 +0000
committerPavel Roskin <proski@gnu.org>2000-06-15 18:04:40 +0000
commit2e965239ee4f19f86e377ade94574c3c73a32425 (patch)
treed77dd91a7e2d4f2c8edab88b75daace67d828307
parent3f75503fa0b747b6d505ffe8ec047f6894f81050 (diff)
downloadbusybox-w32-2e965239ee4f19f86e377ade94574c3c73a32425.tar.gz
busybox-w32-2e965239ee4f19f86e377ade94574c3c73a32425.tar.bz2
busybox-w32-2e965239ee4f19f86e377ade94574c3c73a32425.zip
ln: fixed command line parser. Added support for "--"
-rw-r--r--Changelog3
-rw-r--r--coreutils/ln.c20
-rw-r--r--ln.c20
3 files changed, 26 insertions, 17 deletions
diff --git a/Changelog b/Changelog
index d5c72684e..e3548257a 100644
--- a/Changelog
+++ b/Changelog
@@ -61,7 +61,8 @@
61 * Simplified freeramdisk and added argument checking -- Pavel Roskin. 61 * Simplified freeramdisk and added argument checking -- Pavel Roskin.
62 * Fixed segfault caused by "touch -c" 62 * Fixed segfault caused by "touch -c"
63 * Fixed segfault caused by "rm -f" 63 * Fixed segfault caused by "rm -f"
64 * Fixed segfault caused by "ln -s -s" and similar abuses. 64 * Fixed segfault caused by "ln -s -s" and similar abuses. Further fixes
65 and "--" support from Pavel Roskin.
65 * Fixed segfault caused by "cp -a -a" and similar abuses. 66 * Fixed segfault caused by "cp -a -a" and similar abuses.
66 * Implemented "rm -- <foo>". Implementation fixed by Pavel Roskin. 67 * Implemented "rm -- <foo>". Implementation fixed by Pavel Roskin.
67 * "which" rewritten to use stat(). Fixes to improve its compatability 68 * "which" rewritten to use stat(). Fixes to improve its compatability
diff --git a/coreutils/ln.c b/coreutils/ln.c
index d4fa47306..634c9905d 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -51,16 +51,14 @@ extern int ln_main(int argc, char **argv)
51{ 51{
52 char *linkName; 52 char *linkName;
53 int linkIntoDirFlag; 53 int linkIntoDirFlag;
54 int stopIt = FALSE;
54 55
55 if (argc < 3) {
56 usage(ln_usage);
57 }
58 argc--; 56 argc--;
59 argv++; 57 argv++;
60 58
61 /* Parse any options */ 59 /* Parse any options */
62 while (--argc >= 0 && *argv && **argv) { 60 while (argc > 0 && stopIt == FALSE) {
63 while (**argv == '-') { 61 if (**argv == '-') {
64 while (*++(*argv)) 62 while (*++(*argv))
65 switch (**argv) { 63 switch (**argv) {
66 case 's': 64 case 's':
@@ -72,15 +70,21 @@ extern int ln_main(int argc, char **argv)
72 case 'n': 70 case 'n':
73 followLinks = FALSE; 71 followLinks = FALSE;
74 break; 72 break;
73 case '-':
74 stopIt = TRUE;
75 break;
75 default: 76 default:
76 usage(ln_usage); 77 usage(ln_usage);
77 } 78 }
79 argc--;
80 argv++;
78 } 81 }
79 argv++; 82 else
83 break;
80 } 84 }
81 85
82 if (argc < 1) { 86 if (argc < 2) {
83 fatalError("ln: missing file argument\n"); 87 usage(ln_usage);
84 } 88 }
85 89
86 linkName = argv[argc - 1]; 90 linkName = argv[argc - 1];
diff --git a/ln.c b/ln.c
index d4fa47306..634c9905d 100644
--- a/ln.c
+++ b/ln.c
@@ -51,16 +51,14 @@ extern int ln_main(int argc, char **argv)
51{ 51{
52 char *linkName; 52 char *linkName;
53 int linkIntoDirFlag; 53 int linkIntoDirFlag;
54 int stopIt = FALSE;
54 55
55 if (argc < 3) {
56 usage(ln_usage);
57 }
58 argc--; 56 argc--;
59 argv++; 57 argv++;
60 58
61 /* Parse any options */ 59 /* Parse any options */
62 while (--argc >= 0 && *argv && **argv) { 60 while (argc > 0 && stopIt == FALSE) {
63 while (**argv == '-') { 61 if (**argv == '-') {
64 while (*++(*argv)) 62 while (*++(*argv))
65 switch (**argv) { 63 switch (**argv) {
66 case 's': 64 case 's':
@@ -72,15 +70,21 @@ extern int ln_main(int argc, char **argv)
72 case 'n': 70 case 'n':
73 followLinks = FALSE; 71 followLinks = FALSE;
74 break; 72 break;
73 case '-':
74 stopIt = TRUE;
75 break;
75 default: 76 default:
76 usage(ln_usage); 77 usage(ln_usage);
77 } 78 }
79 argc--;
80 argv++;
78 } 81 }
79 argv++; 82 else
83 break;
80 } 84 }
81 85
82 if (argc < 1) { 86 if (argc < 2) {
83 fatalError("ln: missing file argument\n"); 87 usage(ln_usage);
84 } 88 }
85 89
86 linkName = argv[argc - 1]; 90 linkName = argv[argc - 1];