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.3,1.4


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/support cmdline.c,1.3,1.4
Date: Thu, 12 Dec 2002 02:32:12 -0500

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

Modified Files:
        cmdline.c 
Log Message:


Add Microsoft command-line syntax compatibility support to "ilasm".


Index: cmdline.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/cmdline.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** cmdline.c   15 Jan 2002 23:49:01 -0000      1.3
--- cmdline.c   12 Dec 2002 07:32:10 -0000      1.4
***************
*** 27,34 ****
--- 27,154 ----
  #endif
  
+ /*
+  * Determine if an option list contains '/' compatibility options.
+  */
+ static int HasSlashOptions(const ILCmdLineOption *options)
+ {
+       while(options->name != 0)
+       {
+               if(options->name[0] == '/')
+               {
+                       return 1;
+               }
+               ++options;
+       }
+       return 0;
+ }
+ 
+ /*
+  * Recognize a '/' compatibility option.  Returns the option value
+  * if valid, zero if not recognized, or -1 if an error occurred.
+  */
+ static int RecognizeSlashOption(const ILCmdLineOption *options,
+                                                               char *arg, char 
**param)
+ {
+       int namelen;
+       const char *optname;
+       int posn, ch1, ch2;
+ 
+       /* Parse the option into name and value */
+       namelen = 1;
+       while(arg[namelen] != '\0' && arg[namelen] != ':' && arg[namelen] != 
'=')
+       {
+               ++namelen;
+       }
+       if(arg[namelen] == '\0')
+       {
+               *param = 0;
+       }
+       else
+       {
+               *param = arg + namelen + 1;
+       }
+ 
+       /* Look through the option table for a match */
+       while(options->name != 0)
+       {
+               /* Skip non-slash options */
+               if(options->name[0] != '/')
+               {
+                       ++options;
+                       continue;
+               }
+ 
+               /* Match the option name, while ignoring case.  If we come
+                  across a '*', then match only the prefix up to that point */
+               posn = 1;
+               optname = options->name;
+               while(optname[posn] != '\0')
+               {
+                       ch1 = optname[posn];
+                       if(ch1 >= 'A' && ch1 <= 'Z')
+                       {
+                               ch1 = ch1 - 'A' + 'a';
+                       }
+                       if(posn < namelen)
+                       {
+                               ch2 = arg[posn];
+                       }
+                       else
+                       {
+                               ch2 = '\0';
+                       }
+                       if(ch2 >= 'A' && ch2 <= 'Z')
+                       {
+                               ch2 = ch2 - 'A' + 'a';
+                       }
+                       if(ch1 == '*')
+                       {
+                               break;
+                       }
+                       else if(ch1 != ch2)
+                       {
+                               break;
+                       }
+                       ++posn;
+               }
+ 
+               /* Did we get an option match? */
+               if((optname[posn] == '\0' && posn == namelen) || optname[posn] 
== '*')
+               {
+                       if(options->hasParam)
+                       {
+                               if(*param)
+                               {
+                                       return options->value;
+                               }
+                               else
+                               {
+                                       return -1;
+                               }
+                       }
+                       else
+                       {
+                               if(*param)
+                               {
+                                       return -1;
+                               }
+                               else
+                               {
+                                       return options->value;
+                               }
+                       }
+               }
+ 
+               /* Proceed to the next option in the table */
+               ++options;
+       }
+       return 0;
+ }
+ 
  int ILCmdLineNextOption(int *argc, char ***argv, int *state,
                                                const ILCmdLineOption *options, 
char **param)
  {
        char opt;
+       int value;
  
        if(*state == 0)
***************
*** 46,49 ****
--- 166,184 ----
                {
                        return 0;
+               }
+               if((*argv)[1][0] == '/' && HasSlashOptions(options))
+               {
+                       /* Recognise compatibility options that start with '/' 
*/
+                       value = RecognizeSlashOption(options, (*argv)[1], 
param);
+                       if(value > 0)
+                       {
+                               --(*argc);
+                               ++(*argv);
+                               return value;
+                       }
+                       else if(value < 0)
+                       {
+                               return value;
+                       }
                }
                if((*argv)[1][0] != '-' || (*argv)[1][1] == '\0')




reply via email to

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