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

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

[Dotgnu-pnet-commits] CVS: treecc ChangeLog,1.76,1.77 main.c,1.4,1.5


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: treecc ChangeLog,1.76,1.77 main.c,1.4,1.5
Date: Tue, 28 Jan 2003 19:46:56 -0500

Update of /cvsroot/dotgnu-pnet/treecc
In directory subversions:/tmp/cvs-serv31032

Modified Files:
        ChangeLog main.c 
Log Message:


Add the "-O" option to the treecc command-line, which allows "%option"
commands to be issued directly from the command-line.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/ChangeLog,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -r1.76 -r1.77
*** ChangeLog   29 Jan 2003 00:16:16 -0000      1.76
--- ChangeLog   29 Jan 2003 00:46:53 -0000      1.77
***************
*** 8,11 ****
--- 8,15 ----
        third party node allocators.
  
+       * main.c, doc/treecc.1, doc/treecc.texi: add the "-O" option to
+       the treecc command-line, which allows "%option" commands to
+       be issued directly from the command-line.
+ 
  2003-01-27  James Michael DuPont  <address@hidden>
  

Index: main.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** main.c      15 Dec 2002 13:17:07 -0000      1.4
--- main.c      29 Jan 2003 00:46:54 -0000      1.5
***************
*** 22,25 ****
--- 22,26 ----
  #include "errors.h"
  #include "gen.h"
+ #include "options.h"
  
  #ifdef        __cplusplus
***************
*** 29,32 ****
--- 30,34 ----
  static void Usage(char *progname);
  static void Version(void);
+ static int ExtraOptions(TreeCCContext *context, char **options, int num);
  static char *GetDefault(const char *filename, const char *extension);
  
***************
*** 46,49 ****
--- 48,60 ----
        FILE *file;
        int len, result;
+       char **options = (char **)malloc(sizeof(char *) * argc);
+       int num_options = 0;
+ 
+       /* Allocate the array for external "%option" values */
+       options = (char **)malloc(sizeof(char *) * argc);
+       if(!options)
+       {
+               TreeCCOutOfMemory(0);
+       }
  
        /* Parse the command-line options */
***************
*** 121,124 ****
--- 132,146 ----
                                extension = argv[1];
                        }
+                       else if(!strcmp(argv[1], "--option"))
+                       {
+                               --argc;
+                               ++argv;
+                               if(argc <= 1)
+                               {
+                                       Usage(progname);
+                                       return 1;
+                               }
+                               options[num_options++] = argv[1];
+                       }
                        else if(!strcmp(argv[1], "--force-create"))
                        {
***************
*** 258,261 ****
--- 280,304 ----
                                        break;
  
+                                       case 'O':
+                                       {
+                                               if(*opt != '\0')
+                                               {
+                                                       options[num_options++] 
= opt;
+                                                       opt = "";
+                                               }
+                                               else if(argc <= 2)
+                                               {
+                                                       Usage(progname);
+                                                       return 1;
+                                               }
+                                               else
+                                               {
+                                                       --argc;
+                                                       ++argv;
+                                                       options[num_options++] 
= argv[1];
+                                               }
+                                       }
+                                       break;
+ 
                                        case 'f':
                                        {
***************
*** 345,348 ****
--- 388,398 ----
        context->outputDirectory = outputDir;
  
+       /* Process additional options from the command-line */
+       if(!ExtraOptions(context, options, num_options))
+       {
+               return 1;
+       }
+       free(options);
+ 
        /* Create the default source and header streams */
        context->sourceStream = TreeCCStreamCreate(context, outputFile,
***************
*** 436,439 ****
--- 486,491 ----
        fprintf(stderr, "    -f,      --force-create\n");
        fprintf(stderr, "        Force the creation of unchanged output 
files.\n");
+       fprintf(stderr, "    -O opt,  --option opt\n");
+       fprintf(stderr, "        Set a treecc source option value.\n");
        fprintf(stderr, "    --help\n");
        fprintf(stderr, "        Print this help message.\n");
***************
*** 452,455 ****
--- 504,539 ----
        printf("\n");
        printf("Use the `--help' option to get help on the command-line 
options.\n");
+ }
+ 
+ /*
+  * Process extra treecc "%option" values from the command-line.
+  */
+ static int ExtraOptions(TreeCCContext *context, char **options, int num)
+ {
+       char *name;
+       char *value;
+       while(num-- > 0)
+       {
+               name = *options++;
+               value = name;
+               while(*value != '\0' && *value != '=')
+               {
+                       ++value;
+               }
+               if(*value == '\0')
+               {
+                       value = 0;
+               }
+               else
+               {
+                       *value++ = '\0';
+               }
+               if(TreeCCOptionProcess(context, name, value) != TREECC_OPT_OK)
+               {
+                       fprintf(stderr, "%s: unknown option or invalid 
value\n", name);
+                       return 0;
+               }
+       }
+       return 1;
  }
  





reply via email to

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