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

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

[Dotgnu-pnet-commits] pnet/ildd ildd.1,1.3,1.4 ildd.c,1.4,1.5


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnet/ildd ildd.1,1.3,1.4 ildd.c,1.4,1.5
Date: Wed, 26 Nov 2003 04:01:48 +0000

Update of /cvsroot/dotgnu-pnet/pnet/ildd
In directory subversions:/tmp/cvs-serv11522/ildd

Modified Files:
        ildd.1 ildd.c 
Log Message:


Add the "-r" option to "ildd", to recursively print dependencies.


Index: ildd.1
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildd/ildd.1,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ildd.1      24 Nov 2003 11:36:34 -0000      1.3
--- ildd.1      26 Nov 2003 04:01:46 -0000      1.4
***************
*** 36,39 ****
--- 36,42 ----
  Print detailed information about PInvoke declarations.
  .TP
+ .B \-r, \-\-recursive
+ Recursively print transitive dependencies.
+ .TP
  .B \-\-help
  Print a usage message for the \fBildd\fR program.

Index: ildd.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildd/ildd.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ildd.c      26 Nov 2003 03:44:46 -0000      1.4
--- ildd.c      26 Nov 2003 04:01:46 -0000      1.5
***************
*** 20,23 ****
--- 20,24 ----
  
  #include <stdio.h>
+ #include <stdlib.h>
  #include "il_system.h"
  #include "il_image.h"
***************
*** 41,44 ****
--- 42,49 ----
                "--pinvoke    or -p",
                "Print detailed information on PInvoke declarations."},
+       {"-r", 'r', 0, 0, 0},
+       {"--recursive", 'r', 0,
+               "--recursive  or -r",
+               "Recursively print transitive dependencies."},
        {"-v", 'v', 0, 0, 0},
        {"--version", 'v', 0,
***************
*** 51,58 ****
  };
  
  static void usage(const char *progname);
  static void version(void);
  static int printDependencies(const char *filename, ILContext *context,
!                                                        int multiple, int 
pinvoke);
  
  int main(int argc, char *argv[])
--- 56,74 ----
  };
  
+ /*
+  * Forward declarations.
+  */
  static void usage(const char *progname);
  static void version(void);
+ static void addModule(const char *filename);
  static int printDependencies(const char *filename, ILContext *context,
!                                                        int multiple, int 
pinvoke, int recursive);
! 
! /*
!  * List of all modules to be scanned.
!  */
! static char **modules = 0;
! static int numModules = 0;
! static int maxModules = 0;
  
  int main(int argc, char *argv[])
***************
*** 61,64 ****
--- 77,81 ----
        int filenames = 0;
        int pinvoke = 0;
+       int recursive = 0;
        int sawStdin;
        int state, opt;
***************
*** 66,69 ****
--- 83,87 ----
        int errors;
        int multiple;
+       int posn;
        ILContext *context;
  
***************
*** 87,90 ****
--- 105,114 ----
                        break;
  
+                       case 'r':
+                       {
+                               recursive = 1;
+                       }
+                       break;
+ 
                        case 'v':
                        {
***************
*** 118,145 ****
        }
  
!       /* Load and print information about the input files */
        sawStdin = 0;
-       errors = 0;
        multiple = ((argc > 2) || filenames);
        while(argc > 1)
        {
!               if(!strcmp(argv[1], "-"))
!               {
!                       /* Dump the contents of stdin, but only once */
!                       if(!sawStdin)
!                       {
!                               errors |= printDependencies("-", context, 
multiple, pinvoke);
!                               sawStdin = 1;
!                       }
!               }
!               else
!               {
!                       /* Dump the contents of a regular file */
!                       errors |= printDependencies(argv[1], context, multiple, 
pinvoke);
!               }
                ++argv;
                --argc;
        }
  
        /* Destroy the context */
        ILContextDestroy(context);
--- 142,165 ----
        }
  
!       /* Add the primary modules to be scanned to the list */
        sawStdin = 0;
        multiple = ((argc > 2) || filenames);
        while(argc > 1)
        {
!               addModule(argv[1]);
                ++argv;
                --argc;
        }
  
+       /* Print the dependencies for all modules */
+       errors = 0;
+       posn = 0;
+       while(posn < numModules)
+       {
+               errors |= printDependencies
+                       (modules[posn], context, multiple, pinvoke, recursive);
+               ++posn;
+       }
+ 
        /* Destroy the context */
        ILContextDestroy(context);
***************
*** 173,180 ****
  
  /*
   * Load an IL image from an input stream and print its dependency information.
   */
  static int printDependencies(const char *filename, ILContext *context,
!                                                        int multiple, int 
pinvoke)
  {
        ILImage *image;
--- 193,234 ----
  
  /*
+  * Add a module to the global list to be scanned, as long as there
+  * isn't already a module with the specified name on the list.
+  */
+ static void addModule(const char *filename)
+ {
+       char **newModules;
+       int posn;
+       for(posn = 0; posn < numModules; ++posn)
+       {
+               if(!strcmp(modules[posn], filename))
+               {
+                       return;
+               }
+       }
+       if(numModules >= maxModules)
+       {
+               newModules = (char **)ILRealloc
+                       (modules, sizeof(char *) * (numModules + 32));
+               if(!newModules)
+               {
+                       exit(1);
+               }
+               modules = newModules;
+               maxModules += 32;
+       }
+       modules[numModules] = ILDupString(filename);
+       if(!(modules[numModules]))
+       {
+               exit(1);
+       }
+       ++numModules;
+ }
+ 
+ /*
   * Load an IL image from an input stream and print its dependency information.
   */
  static int printDependencies(const char *filename, ILContext *context,
!                                                        int multiple, int 
pinvoke, int recursive)
  {
        ILImage *image;
***************
*** 210,214 ****
  
        /* Print the file header if we have multiple files */
!       if(multiple)
        {
                if(!strcmp(filename, "-"))
--- 264,268 ----
  
        /* Print the file header if we have multiple files */
!       if(multiple || recursive)
        {
                if(!strcmp(filename, "-"))
***************
*** 244,247 ****
--- 298,305 ----
                {
                        fputs(path, stdout);
+                       if(recursive)
+                       {
+                               addModule(path);
+                       }
                        ILFree(path);
                }
***************
*** 274,277 ****
--- 332,339 ----
                        {
                                fputs(path, stdout);
+                               if(recursive)
+                               {
+                                       addModule(path);
+                               }
                                ILFree(path);
                        }





reply via email to

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