Changeset 7922

Show
Ignore:
Timestamp:
04/03/07 23:18:29 (22 months ago)
Author:
jburke
Message:

(merge from 0.4 branch) Refs #2386. Copyright parsing is flawed and takes way too much time. A copyright text is passed in to this method, so there is a way to set a specific copyright.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • util/trunk/buildscripts/jslib/buildUtil.js

    r7909 r7922  
    677677buildUtil.optimizeJs = function(/*String fileName*/fileName, /*String*/fileContents, /*String*/copyright, /*boolean*/doCompression){ 
    678678        //summary: either strips comments from string or compresses it. 
    679  
    680         //Look for copyright. If so, maintain it. 
    681         //If no copyright text passed in, assume want a really stripped 
    682         //version. 
    683679        copyright = copyright || ""; 
    684         var copyrightText = ""; 
    685         if(copyright){ 
    686                 var singleLineMatches = fileContents.match(/\/\/.*copyright.*$/gi); 
    687                  
    688                 //Get rid of cr, lf, since it messes up matching. 
    689                 var copyrightFileContents = fileContents.replace(/\r/g, "__DOJOCARRIAGERETURN__").replace(/\n/g, "__DOJONEWLINE__"); 
    690                 var multiLineMatches = copyrightFileContents.match(/\/\*.*?copyright.*?\*\//gi); 
    691          
    692                 //Finalize copyright notice. 
    693                 if((multiLineMatches && multiLineMatches.length > 0) || (singleLineMatches && singleLineMatches.length > 0)){ 
    694                         if(multiLineMatches && multiLineMatches.length > 0){ 
    695                                 copyrightText += multiLineMatches.join("\r\n").replace(/__DOJOCARRIAGERETURN__/g, "\r").replace(/__DOJONEWLINE__/g, "\n"); 
    696                         }                                        
    697                         if(singleLineMatches && singleLineMatches.length > 0){ 
    698                                 copyrightText += singleLineMatches.join("\r\n"); 
    699                         } 
    700                         copyrightText += fileUtil.getLineSeparator(); 
    701                 }else{ 
    702                         copyrightText = copyright; 
    703                 } 
    704         } 
    705680 
    706681        //Use rhino to help do minifying/compressing. 
     
    731706        } 
    732707 
    733         return copyrightText + fileContents; 
     708        return copyright + fileContents; 
    734709} 
    735710