Index: CMT/HEAD/ChangeLog
===================================================================
--- CMT/HEAD/ChangeLog	(revision 605)
+++ CMT/HEAD/ChangeLog	(revision 606)
@@ -1,2 +1,10 @@
+2012-03-26    <rybkin@lal.in2p3.fr> 481
+
+	* source/cmt_deps_builder.cxx: Re-write function build_deps_text in order
+	to optimise (make more than 4 times faster), in function
+	in_line_comment_action, do not check for backslash characters as all
+	continuation characters are already deleted
+	* mgr/Unix.make: Add -static to LDFLAGS if STATIC set to 1
+	
 2012-03-09    <rybkin@lal.in2p3.fr> 480
 	
Index: CMT/HEAD/mgr/Unix.make
===================================================================
--- CMT/HEAD/mgr/Unix.make	(revision 605)
+++ CMT/HEAD/mgr/Unix.make	(revision 606)
@@ -8,5 +8,5 @@
 
 ifeq ($(STATIC),1)
-    cpplinkflags   += -static
+    LDFLAGS   += -static
 endif
 
Index: CMT/HEAD/source/cmt_deps_builder.cxx
===================================================================
--- CMT/HEAD/source/cmt_deps_builder.cxx	(revision 605)
+++ CMT/HEAD/source/cmt_deps_builder.cxx	(revision 606)
@@ -511,11 +511,12 @@
 static char* in_line_comment_action (char* ptr, state_def& state)
 {
-  char * pos = strchr (ptr, '\\');  
+  //  char * pos = strchr (ptr, '\\');  
   /* Extend this part to deal with continuation character */  
-  if ( (pos == NULL) || ( (ptr + strlen(ptr)-1)!=pos ))
-    {
-      state = in_line;
-    }
-  
+//   if ( (pos == NULL) || ( (ptr + strlen(ptr)-1)!=pos ))
+//     {
+//       state = in_line;
+//     }
+  /* We already deleted all backslash characters that with newline continue line */
+  state = in_line;
   ptr    += strlen (ptr);
   
@@ -535,118 +536,77 @@
   Log;
 
-  int pos;
-  int max_pos;
   int line_number = 1;
 
-  log << "CMT> build_deps_text dir_name="
+  log << "|build_deps_text> dir_name="
       << dir_name << log_endl;
 
-  // erase of continuation character
-  pos = 0;
-  max_pos = strlen (text);
   char* current = text;
-
-  char* last = text + max_pos;
-  while (current < last)
-    {
-   
-      //  bscrnl -> BackSlash Carriage Return New Line
-      //  bsnl -> BackSlash New Line
-      char* bscrnl = strstr (current, "\\\r\n");
-      char* bsnl   = strstr (current, "\\\n");
-      
-      if ( (bscrnl==0) && (bsnl ==0)) break;
-      
-      int length = 0;
-            
-      char * ptr = 0;
-      if (bsnl==0)  //bscrnl > 0
-	{
-	  length = 3;
-	  ptr    = bscrnl; 
-	}      
-      else if (bscrnl==0) //bsnl > 0
-	{
-	  length = 2;                        
-	  ptr    = bsnl; 
-	}     
-      else if (bscrnl < bsnl)
-	{
-	  length = 3;
-	  ptr    = bscrnl;                 
-	}
-      else // (bscrnl > bsnl)
-	{
-	  length = 2;                        
-	  ptr    = bsnl;         
-	}
-      strcpy (ptr, ptr+length);
-      current = ptr;
-      last -= length;
-    } 
+  char* nl;
+  int length;
+  char * ptr;
+  char * begin = current;
   
-  pos = 0;
-  max_pos = strlen (text);
-  current = text;
-  last = text + max_pos;
-
   state_def state = at_start;
   
-
-  while (current < last)
-    {
-             
-      char marker;
-      char* marker_pos = 0;
-
-      //  crnl -> Carriage Return New Line
-      //  nl -> New Line
-      char* crnl = strstr (current, "\r\n");
-      char* nl = strchr (current, '\n');
-
-      char* first = nl;
-      int length = 1;
-
-      char* ptr = 0;
-
-      if (crnl != 0)
-        {
-	  // cr+nl has been found
-
-          if (nl == 0)
-            {
-	      // cr but no nl ??
-              first = crnl;
-              length = 2;
-            }
-          else
-            {
-	      // both cr+nl and nl found
-              first = (nl < crnl) ? nl : crnl;
-              length = (nl < crnl) ? 1 : 2;
-            }
-        }
+  // nl -> new line
+  while (nl = strchr (begin, '\n'))
+    {
+      length = 0;
+
+      if (begin < nl)
+	{
+	  if (*(nl - 1) == '\\')
+	    {
+	      // erase backslash + newline (continuation character)
+	      // shift 2
+	      begin = nl - 1;
+	      char *d = begin;
+	      char *s = nl + 1;
+	      while (*d++ = *s++)
+		;
+	    }
+	  else if (*(nl - 1) == '\r')
+	    {
+	      if ((begin < (nl - 1)) && (*(nl - 2) == '\\'))
+		{
+		  // erase backslash + carriage return + newline (continuation character)
+		  // shift 3
+		  begin = nl - 2;
+		  char *d = begin;
+		  char *s = nl + 1;
+		  while (*d++ = *s++)
+		    ;
+		}
+	      else
+		{
+		  // process line [current, nl - 1)
+		  length = 2;
+		}
+	    }
+	  else
+	    {
+	      // process line [current, nl)
+	      length = 1;
+	    }
+	}
       else
 	{
-	  // no cr+nl but nl alone found
-	  first = nl;
+	  // process line [current, nl)
 	  length = 1;
 	}
-
+      
+      if (0 == length) continue;
+
+      if (1 == length)
+	{
+	  *nl = 0;
+	}
+      else
+	{
+	  *(nl - 1) = 0;
+	}
+      
       ptr = current;
-
-      if (first == 0)
-        {
-    	  // neither nl nor cr+nl found => this is the last line
-	  marker_pos = 0;
-        }
-      else
-        {
-    	  marker_pos = first;
-	  marker = *marker_pos;
-	  *marker_pos = 0;
-        }
-
-      log << "CMT> build_deps_text2 line=[" 
+      log << "|build_deps_text> line=["
 	  << current << "]" << log_endl;
       
@@ -662,5 +622,5 @@
 				     include_paths,
 				     substitutions,
-                                     header_filters,
+				     header_filters,
 				     all_deps,
 				     deps);
@@ -688,20 +648,65 @@
 	      break;
 	    }
-	}
-
+	} // while (strlen (ptr) > 0)
+      
       if (state == in_line) state = at_start;
       line_number++;
 
-      if (marker_pos != 0)
-	{
-	  *marker_pos = marker;
-	  current = marker_pos + length;
+      if (1 == length)
+	{
+	  *nl = '\n';
 	}
       else
 	{
-	  break;
+	  *(nl - 1) = '\r';
 	}
-    }
-            
+      current = nl + 1;
+      begin = current;
+
+    } // while (nl = ...)
+
+      ptr = current;
+      log << "|build_deps_text> line=["
+	  << current << "]" << log_endl;
+      
+      while (strlen (ptr) > 0)
+	{
+	  switch (state)
+	    {
+	    case at_start:
+	      ptr = at_start_action (ptr,
+				     state,
+				     dir_name,
+				     current_path_index,
+				     include_paths,
+				     substitutions,
+				     header_filters,
+				     all_deps,
+				     deps);
+	      break;
+	    case in_line:
+	      ptr = in_line_action (ptr, state);
+	      break;
+	    case in_string:
+	      ptr = in_string_action (ptr, state);
+	      break;
+	    case in_char:
+	      ptr = in_char_action (ptr, state);
+	      break;
+	    case in_comment:
+	      ptr = in_comment_action (ptr, state);
+	      break;
+	    case in_string_comment:
+	      ptr = in_string_comment_action (ptr, state);
+	      break;
+	    case in_char_comment:
+	      ptr = in_char_comment_action (ptr, state);
+	      break;
+	    case in_line_comment:
+	      ptr = in_line_comment_action (ptr, state);
+	      break;
+	    }
+	}
+  
 }
 
