mark | 1 Jul 2005 10:02

update to swigmain.cxx

William S Fulton wrote :

> I see you have to use -Lua instead of -lua. You can work around this in 
> swigmain.cxx when checking the -l option if you want. I'd prefer to see 
> all the language modules following the same lowercase conventions.

I looked at this and found something interesting.
Dave wrote some code in getopt.c to mark which args have been used and which have not. If you look in main.cxx
inside SWIG_getoptions(), you will see Swig_mark_arg() which marks the args as being used.
However, the Swig_check_marked() function which looks for whether these are actually used was never
called (I ran a search across the source & couldn't find it being called).

After this I made a patch to the code (given below), which uses that. Its now possible to have a -lua argument ok.

I have a concern is if there was a reason why this Swig_check_marked() function was never used. Any ideas?

Regards,
Mark

$ diff swig/Source/Modules/main.cxx swig-1.3.25/Source/Modules/main.cxx 
=================================
160c160
< // ----------------------------------------------------------------------------- 
---
> // -----------------------------------------------------------------------------
196c196
< // Sets the output directory for language specific (proxy) files if not set and 
---
> // Sets the output directory for language specific (proxy) files if not set and
198c198
< // ----------------------------------------------------------------------------- 
---
> // -----------------------------------------------------------------------------
239c239
< void SWIG_getfeatures(const char *c) 
---
> void SWIG_getfeatures(const char *c)
267c267
<     }    
---
>     }
307c307
<   
---
> 
329c329
<   
---
> 
334c334
< void SWIG_getoptions(int argc, char *argv[]) 
---
> void SWIG_getoptions(int argc, char *argv[])
341c341
<       if (argv[i]) {
---
>       if (argv[i] && !Swig_check_marked(i)) {
510c510
< 	      ModuleName = NewString(argv[i+1]);	    
---
> 	      ModuleName = NewString(argv[i+1]);
526c526
< 	      dependencies_file = NewString(argv[i+1]);	    
---
> 	      dependencies_file = NewString(argv[i+1]);
540c540
< 	      outdir = NewString(argv[i+1]);	    
---
> 	      outdir = NewString(argv[i+1]);
570c570
< 	      xmlout = NewString(argv[i+1]);	    
---
> 	      xmlout = NewString(argv[i+1]);
620c620
<   
---
> 
690c690
< #endif                                        
---
> #endif
696c696
<   
---
> 
710c710
<   
---
> 
845c845
< 	} 
---
> 	}
899c899
<       }	       
---
>       }


Gmane