First, this removes the FileSet sort stuff.  It's superfluous now.

Second (and more important), it fixes a minor UI bug with queue -d.
I'm not sure how I managed to test this and have it work.  d:: is
having -d take an optional argument, but that forces getopt to not
take a space between the option and argument, ie -d2, -d"foo".  This
fixes this.  (I suppose I may have had exactly this code in, wondered
why I didn't just use optarg, and changed it--it's commented now.)

-- 
Glenn Maynard
Index: CmdExec.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/CmdExec.cc,v
retrieving revision 1.79
diff -u -r1.79 CmdExec.cc
--- CmdExec.cc  2001/07/26 09:57:17     1.79
+++ CmdExec.cc  2001/08/26 15:12:13
@@ -464,7 +464,6 @@
         }
         else if(glob->Done())
         {
-           glob->SortByName();
            FileSet &list=*glob->GetResult();
            for(int i=0; list[i]; i++)
               args_glob->Append(list[i]->name);
Index: FileAccess.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileAccess.h,v
retrieving revision 1.59
diff -u -r1.59 FileAccess.h
--- FileAccess.h        2001/07/03 13:35:34     1.59
+++ FileAccess.h        2001/08/26 15:12:13
@@ -372,7 +372,6 @@
    void FilesOnly() { files_only=true; }
    void NoMatchPeriod() { match_period=false; }
    void NoInhibitTilde() { inhibit_tilde=false; }
-   void SortByName() { list.SortByName(); }
 
    static bool HasWildcards(const char *);
    static void UnquoteWildcards(char *);
@@ -399,7 +398,6 @@
    bool Error() { return glob->Error(); }
    const char *ErrorText() { return glob->ErrorText(); }
    const char *Status() { return glob->Status(); }
-   void SortByName() { glob->SortByName(); }
 };
 
 #include "FileSet.h"
Index: FileSet.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileSet.cc,v
retrieving revision 1.15
diff -u -r1.15 FileSet.cc
--- FileSet.cc  2001/08/16 14:27:35     1.15
+++ FileSet.cc  2001/08/26 15:12:14
@@ -432,18 +432,6 @@
    return 0;
 }
 
-static int name_compare(const void *a,const void *b)
-{
-   FileInfo *pa=*(FileInfo*const*)a;
-   FileInfo *pb=*(FileInfo*const*)b;
-   return strcmp(pa->name,pb->name);
-}
-
-void FileSet::SortByName()
-{
-   qsort(files,fnum,sizeof(*files),name_compare);
-}
-
 void FileInfo::Init()
 {
    name=NULL;
Index: FileSet.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileSet.h,v
retrieving revision 1.12
diff -u -r1.12 FileSet.h
--- FileSet.h   2001/07/09 13:21:58     1.12
+++ FileSet.h   2001/08/26 15:12:14
@@ -164,8 +164,6 @@
         f->SetDate(date);
    }
 
-   void SortByName();
-
    FileInfo * operator[](int i) const { return i<fnum?files[i]:0; }
 };
 
Index: commands.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/commands.cc,v
retrieving revision 1.134
diff -u -r1.134 commands.cc
--- commands.cc 2001/07/30 14:37:58     1.134
+++ commands.cc 2001/08/26 15:12:16
@@ -888,7 +888,7 @@
 
    exit_code=1; // more failure exits than success exits, so set success explicitely
 
-   while((opt=args->getopt_long("+d::m:n:w",queue_options,0))!=EOF)
+   while((opt=args->getopt_long("+dm:n:w",queue_options,0))!=EOF)
    {
       switch(opt)
       {
@@ -909,7 +909,6 @@
 
       case 'd':
         mode = del;
-        arg = optarg;
         break;
 
       case '?':
@@ -945,7 +944,12 @@
          /* Accept:
          * queue -d (delete the last job)
          * queue -d 1  (delete entry 1)
-         * queue -d "get" (delete all *get*) */
+         * queue -d "get" (delete all *get*)
+         *
+         * We want an optional argument, but don't use getopt ::, since
+         * that'll disallow the space between arguments, which we want. */
+         arg = args->getarg(args->getindex());
+        
         CmdExec *queue=GetQueue(false);
         if(!queue) {
            eprintf(_("%s: No queue is active.\n"), args->a0());

Reply via email to