ic bug ...

Per Bergqvist per@REDACTED
Wed Jan 16 18:06:00 CET 2002


Hi,                                                                   
                                                                      
there is a bit of "not so very forward compatible" code in ic.        
If gcc is used as preprocessor command (as mnesia session do) by ic,  
icpreproc.erl will check if the output begins with the string "# 1" as
then treats this as an                                                
indication of succesful preprocessing.                                
However, gcc 3.0  (and probably earlier versions as well) will        
generate "# <line-number-of-first-non-comment-line>"                  
in this case.                                                         
                                                                      
My quick fix is to replace the line :                                 
               [$#, $ , $1 | Rest] ->                  % Ok output    
with:                                                                 
               [$#, $ , C | Rest] when integer(C),C>$0,C=<$9 ->       
              % Ok output                                             
                                                                      
A better and more future proof solution would be to actually check the
return status from the command ;-).                                   
                                                                      
(I know you can't get it from os:cmd but the needed underlying        
mechanisms are present so we just need a                              
"os:ext_cmd" that gives you return status as well.)                   
                                                                      
The only user of this alternative preprocessor is mnesia_session.     
                                                                      
I am a bit puzzled that nobody detected this bug earlier. Are there   
any users of mnesia_session out there ?                               
                                                                      
=========================================================             
Per Bergqvist                                                         
Synapse Systems AB                                                    
Phone: +46 709 686 685                                                
Email: per@REDACTED                                                   



More information about the erlang-questions mailing list