dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[Dotgnu-pnet-commits] CVS: pnet/support cmdline.c,1.4,1.5


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/support cmdline.c,1.4,1.5
Date: Fri, 13 Dec 2002 00:04:28 -0500

Update of /cvsroot/dotgnu-pnet/pnet/support
In directory subversions:/tmp/cvs-serv8295/support

Modified Files:
        cmdline.c 
Log Message:


Rearrange the command-line so that '/' options always come first
if the command supports them.


Index: cmdline.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/cmdline.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** cmdline.c   12 Dec 2002 07:32:10 -0000      1.4
--- cmdline.c   13 Dec 2002 05:04:25 -0000      1.5
***************
*** 146,149 ****
--- 146,184 ----
  }
  
+ /*
+  * Rearrange a command-line so that '/' options precede regular arguments.
+  */
+ static void RearrangeSlashOptions(const ILCmdLineOption *options,
+                                                                 int argc, 
char **argv)
+ {
+       int posn = 1;
+       int slashInsert = 1;
+       int temp;
+       char *param, *param2;
+       while(posn < argc)
+       {
+               if(argv[posn][0] == '/' &&
+                  RecognizeSlashOption(options, argv[posn], &param) != 0)
+               {
+                       /* Shift this option to the beginning of the 
command-line */
+                       param = argv[posn];
+                       for(temp = slashInsert; temp <= posn; ++temp)
+                       {
+                               param2 = argv[temp];
+                               argv[temp] = param;
+                               param = param2;
+                       }
+                       ++slashInsert;
+               }
+               else if(!strcmp(argv[posn], "--"))
+               {
+                       /* Stop when we see "--", as any arguments that follow
+                          starting with '/' are probably filenames, not 
options */
+                       break;
+               }
+               ++posn;
+       }
+ }
+ 
  int ILCmdLineNextOption(int *argc, char ***argv, int *state,
                                                const ILCmdLineOption *options, 
char **param)
***************
*** 157,160 ****
--- 192,205 ----
                   so expand response files before we get going */
                ILCmdLineExpand(argc, argv);
+ 
+               /* If this program supports '/' compatibility options,
+                  then rearrange the command-line so that those options
+                  are at the front, before all other arguments */
+               if(HasSlashOptions(options))
+               {
+                       RearrangeSlashOptions(options, *argc, *argv);
+               }
+ 
+               /* Start parsing the first option */
                *state = 1;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]