Changeset 606 for CMT/HEAD


Ignore:
Timestamp:
Mar 26, 2012, 6:15:12 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 481

Location:
CMT/HEAD
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r605 r606  
     12012-03-26    <rybkin@lal.in2p3.fr> 481
     2
     3        * source/cmt_deps_builder.cxx: Re-write function build_deps_text in order
     4        to optimise (make more than 4 times faster), in function
     5        in_line_comment_action, do not check for backslash characters as all
     6        continuation characters are already deleted
     7        * mgr/Unix.make: Add -static to LDFLAGS if STATIC set to 1
     8       
    192012-03-09    <rybkin@lal.in2p3.fr> 480
    210       
  • CMT/HEAD/mgr/Unix.make

    r604 r606  
    88
    99ifeq ($(STATIC),1)
    10     cpplinkflags   += -static
     10    LDFLAGS   += -static
    1111endif
    1212
  • CMT/HEAD/source/cmt_deps_builder.cxx

    r588 r606  
    511511static char* in_line_comment_action (char* ptr, state_def& state)
    512512{
    513   char * pos = strchr (ptr, '\\'); 
     513  //  char * pos = strchr (ptr, '\\'); 
    514514  /* Extend this part to deal with continuation character */ 
    515   if ( (pos == NULL) || ( (ptr + strlen(ptr)-1)!=pos ))
    516     {
    517       state = in_line;
    518     }
    519  
     515//   if ( (pos == NULL) || ( (ptr + strlen(ptr)-1)!=pos ))
     516//     {
     517//       state = in_line;
     518//     }
     519  /* We already deleted all backslash characters that with newline continue line */
     520  state = in_line;
    520521  ptr    += strlen (ptr);
    521522 
     
    535536  Log;
    536537
    537   int pos;
    538   int max_pos;
    539538  int line_number = 1;
    540539
    541   log << "CMT> build_deps_text dir_name="
     540  log << "|build_deps_text> dir_name="
    542541      << dir_name << log_endl;
    543542
    544   // erase of continuation character
    545   pos = 0;
    546   max_pos = strlen (text);
    547543  char* current = text;
    548 
    549   char* last = text + max_pos;
    550   while (current < last)
    551     {
    552    
    553       //  bscrnl -> BackSlash Carriage Return New Line
    554       //  bsnl -> BackSlash New Line
    555       char* bscrnl = strstr (current, "\\\r\n");
    556       char* bsnl   = strstr (current, "\\\n");
    557      
    558       if ( (bscrnl==0) && (bsnl ==0)) break;
    559      
    560       int length = 0;
    561            
    562       char * ptr = 0;
    563       if (bsnl==0)  //bscrnl > 0
    564         {
    565           length = 3;
    566           ptr    = bscrnl;
    567         }     
    568       else if (bscrnl==0) //bsnl > 0
    569         {
    570           length = 2;                       
    571           ptr    = bsnl;
    572         }     
    573       else if (bscrnl < bsnl)
    574         {
    575           length = 3;
    576           ptr    = bscrnl;                 
    577         }
    578       else // (bscrnl > bsnl)
    579         {
    580           length = 2;                       
    581           ptr    = bsnl;         
    582         }
    583       strcpy (ptr, ptr+length);
    584       current = ptr;
    585       last -= length;
    586     }
     544  char* nl;
     545  int length;
     546  char * ptr;
     547  char * begin = current;
    587548 
    588   pos = 0;
    589   max_pos = strlen (text);
    590   current = text;
    591   last = text + max_pos;
    592 
    593549  state_def state = at_start;
    594550 
    595 
    596   while (current < last)
    597     {
    598              
    599       char marker;
    600       char* marker_pos = 0;
    601 
    602       //  crnl -> Carriage Return New Line
    603       //  nl -> New Line
    604       char* crnl = strstr (current, "\r\n");
    605       char* nl = strchr (current, '\n');
    606 
    607       char* first = nl;
    608       int length = 1;
    609 
    610       char* ptr = 0;
    611 
    612       if (crnl != 0)
    613         {
    614           // cr+nl has been found
    615 
    616           if (nl == 0)
    617             {
    618               // cr but no nl ??
    619               first = crnl;
    620               length = 2;
    621             }
    622           else
    623             {
    624               // both cr+nl and nl found
    625               first = (nl < crnl) ? nl : crnl;
    626               length = (nl < crnl) ? 1 : 2;
    627             }
    628         }
     551  // nl -> new line
     552  while (nl = strchr (begin, '\n'))
     553    {
     554      length = 0;
     555
     556      if (begin < nl)
     557        {
     558          if (*(nl - 1) == '\\')
     559            {
     560              // erase backslash + newline (continuation character)
     561              // shift 2
     562              begin = nl - 1;
     563              char *d = begin;
     564              char *s = nl + 1;
     565              while (*d++ = *s++)
     566                ;
     567            }
     568          else if (*(nl - 1) == '\r')
     569            {
     570              if ((begin < (nl - 1)) && (*(nl - 2) == '\\'))
     571                {
     572                  // erase backslash + carriage return + newline (continuation character)
     573                  // shift 3
     574                  begin = nl - 2;
     575                  char *d = begin;
     576                  char *s = nl + 1;
     577                  while (*d++ = *s++)
     578                    ;
     579                }
     580              else
     581                {
     582                  // process line [current, nl - 1)
     583                  length = 2;
     584                }
     585            }
     586          else
     587            {
     588              // process line [current, nl)
     589              length = 1;
     590            }
     591        }
    629592      else
    630593        {
    631           // no cr+nl but nl alone found
    632           first = nl;
     594          // process line [current, nl)
    633595          length = 1;
    634596        }
    635 
     597     
     598      if (0 == length) continue;
     599
     600      if (1 == length)
     601        {
     602          *nl = 0;
     603        }
     604      else
     605        {
     606          *(nl - 1) = 0;
     607        }
     608     
    636609      ptr = current;
    637 
    638       if (first == 0)
    639         {
    640           // neither nl nor cr+nl found => this is the last line
    641           marker_pos = 0;
    642         }
    643       else
    644         {
    645           marker_pos = first;
    646           marker = *marker_pos;
    647           *marker_pos = 0;
    648         }
    649 
    650       log << "CMT> build_deps_text2 line=["
     610      log << "|build_deps_text> line=["
    651611          << current << "]" << log_endl;
    652612     
     
    662622                                     include_paths,
    663623                                     substitutions,
    664                                      header_filters,
     624                                     header_filters,
    665625                                     all_deps,
    666626                                     deps);
     
    688648              break;
    689649            }
    690         }
    691 
     650        } // while (strlen (ptr) > 0)
     651     
    692652      if (state == in_line) state = at_start;
    693653      line_number++;
    694654
    695       if (marker_pos != 0)
    696         {
    697           *marker_pos = marker;
    698           current = marker_pos + length;
     655      if (1 == length)
     656        {
     657          *nl = '\n';
    699658        }
    700659      else
    701660        {
    702           break;
     661          *(nl - 1) = '\r';
    703662        }
    704     }
    705            
     663      current = nl + 1;
     664      begin = current;
     665
     666    } // while (nl = ...)
     667
     668      ptr = current;
     669      log << "|build_deps_text> line=["
     670          << current << "]" << log_endl;
     671     
     672      while (strlen (ptr) > 0)
     673        {
     674          switch (state)
     675            {
     676            case at_start:
     677              ptr = at_start_action (ptr,
     678                                     state,
     679                                     dir_name,
     680                                     current_path_index,
     681                                     include_paths,
     682                                     substitutions,
     683                                     header_filters,
     684                                     all_deps,
     685                                     deps);
     686              break;
     687            case in_line:
     688              ptr = in_line_action (ptr, state);
     689              break;
     690            case in_string:
     691              ptr = in_string_action (ptr, state);
     692              break;
     693            case in_char:
     694              ptr = in_char_action (ptr, state);
     695              break;
     696            case in_comment:
     697              ptr = in_comment_action (ptr, state);
     698              break;
     699            case in_string_comment:
     700              ptr = in_string_comment_action (ptr, state);
     701              break;
     702            case in_char_comment:
     703              ptr = in_char_comment_action (ptr, state);
     704              break;
     705            case in_line_comment:
     706              ptr = in_line_comment_action (ptr, state);
     707              break;
     708            }
     709        }
     710 
    706711}
    707712
Note: See TracChangeset for help on using the changeset viewer.