Index: src/fortrancode.l
===================================================================
RCS file: /cygdrive/d/cvs_doxygen/doxygen/doxygen/src/fortrancode.l,v
retrieving revision 1.6
diff -u -r1.6 fortrancode.l
--- src/fortrancode.l	12 Aug 2012 12:06:56 -0000	1.6
+++ src/fortrancode.l	21 Oct 2012 12:47:40 -0000
@@ -48,6 +48,20 @@
 #define YY_NEVER_INTERACTIVE 1
 #define YY_NO_TOP_STATE 1
 #define YY_NO_INPUT 1
+
+/*
+ * For fixed formatted code position 6 is of importance (continuation character).
+ * The following variables and macros keep track of the column number
+ * YY_USER_ACTION is always called for each scan action
+ * YY_FTN_REST    is used to handle end of lines and reset the column counter
+ * YY_FTN_REJECT  resets the column counters when a pattern is rejected and thus rescanned.
+ */
+int yy_old_start = 0;
+int yy_my_start  = 0;
+int yy_end       = 1;
+#define YY_USER_ACTION {yy_old_start = yy_my_start; yy_my_start = yy_end; yy_end += yyleng;}
+#define YY_FTN_RESET   {yy_old_start = 0; yy_my_start = 0; yy_end = 1;}
+#define YY_FTN_REJECT  {yy_end = yy_my_start; yy_my_start = yy_old_start; REJECT;}
    
 //--------------------------------------------------------------------------------
 
@@ -724,6 +738,10 @@
 					  endFontClass();
 					}
 <Start>{FLOW}/[,( \t\n].*               {
+                                          if (g_isFixedForm)
+                                          {
+                                            if ((yy_my_start == 1) && ((yytext[0] == 'c') || (yytext[0] == 'C'))) YY_FTN_REJECT;
+                                          }
    					  /* font class is defined e.g. in doxygen.css */
   					  startFontClass("keywordflow");
   					  codifyLines(yytext);
@@ -772,7 +790,7 @@
 					  BEGIN(UseOnly);     
                                         }           
 <UseOnly>{BS},{BS}                      { codifyLines(yytext); }
-<UseOnly>{BS}&{BS}"\n"                  { codifyLines(yytext); }
+<UseOnly>{BS}&{BS}"\n"                  { codifyLines(yytext); YY_FTN_RESET}
 <UseOnly>{ID}                           {
                                           g_insideBody=TRUE;
                                           generateLink(*g_code, yytext);
@@ -781,7 +799,7 @@
                                         }
 <Use,UseOnly>"\n"                       {
                                           unput(*yytext);
-                                          yy_pop_state();
+                                          yy_pop_state();YY_FTN_RESET
                                         }
        
  /*-------- fortran module  -----------------------------------------*/
@@ -805,11 +823,11 @@
  					}
 <ClassName>\n				{ // interface may be without name
                                           yy_pop_state();
-					  REJECT;
+					  YY_FTN_REJECT;
 					}
 <Start>"end"({BS_}"module").*          { // just reset currentModule, rest is done in following rule
                                           currentModule=0;
-					  REJECT;
+					  YY_FTN_REJECT;
                                         }
  /*-------- subprog definition -------------------------------------*/
 <Start>({PREFIX}{BS_})?{TYPE_SPEC}{BS_}({PREFIX}{BS_})?{BS}/{SUBPROG}{BS_}  {   // TYPE_SPEC is for old function style function result
@@ -834,6 +852,7 @@
                                         }
 <Subprog,Subprogend>"\n"                { codifyLines(yytext);
                                           yy_pop_state();
+                                          YY_FTN_RESET
                                         }
 <Start>^{BS}"end"{BS}("block"{BS}"data"|{SUBPROG}|"module"|"program"|"type"|"interface"){BS}     {  // Fortran subroutine or function ends
                                           //cout << "===> end function " << yytext << endl;
@@ -921,11 +940,13 @@
                                           codifyLines(yytext);
 					  bracketCount = 0;
                                           yy_pop_state();
+                                          YY_FTN_RESET
  				 	}
 <Declaration>"\n"                       { // end declaration line
 					  codifyLines(yytext);
 					  bracketCount = 0;
                                           yy_pop_state();
+                                          YY_FTN_RESET
  					}
 
  /*-------- subprog calls  -----------------------------------------*/
@@ -949,6 +970,14 @@
 
  /*-------- comments ---------------------------------------------------*/
 <Start>\n?{BS}"!>"|"!<"                 { // start comment line or comment block
+                                          if (yytext[0] == '\n')
+                                          {
+                                            yy_old_start = 0;
+                                            yy_my_start = 1;
+                                            yy_end = yyleng;
+                                          }
+                                          // Actually we should see if ! on position 6, can be continuation
+                                          // but the chance is very unlikely, so no effort to solve it here
                                           yy_push_state(YY_START);
 					  BEGIN(DocBlock);
                                           docBlock=yytext;
@@ -962,7 +991,12 @@
 <DocBlock>.*    			{ // contents of current comment line
                                           docBlock+=yytext;
   					}
-<DocBlock>"\n"{BS}("!>"|"!<"|"!!")	{ //| comment block (next line is also comment line)
+<DocBlock>"\n"{BS}("!>"|"!<"|"!!")	{ // comment block (next line is also comment line)
+                                          yy_old_start = 0;
+                                          yy_my_start = 1;
+                                          yy_end = yyleng;
+                                          // Actually we should see if ! on position 6, can be continuation
+                                          // but the chance is very unlikely, so no effort to solve it here
 					  docBlock+=yytext; 
    					}
 <DocBlock>"\n"        			{ // comment block ends at the end of this line
@@ -984,17 +1018,19 @@
 					    endFontClass();
 					  }
                                          yy_pop_state();
+                                          YY_FTN_RESET
 					}
 
 <*>"!"[^><\n].*|"!"$ 			{ // normal comment
-					  if(YY_START == String) REJECT; // ignore in strings
+					  if(YY_START == String) YY_FTN_REJECT; // ignore in strings
+                                          if (g_isFixedForm && yy_my_start == 6) YY_FTN_REJECT;
   					  startFontClass("comment");
   					  codifyLines(yytext);
 					  endFontClass();
 					}
 
 <*>^[Cc*].*              		{ // normal comment
-                                          if(! g_isFixedForm) REJECT;
+                                          if(! g_isFixedForm) YY_FTN_REJECT;
 
   					  startFontClass("comment");
   					  codifyLines(yytext);
@@ -1002,9 +1038,12 @@
 					}
 
  /*------ preprocessor  --------------------------------------------*/ 
-<Start>"#".*\n                          { startFontClass("preprocessor");
+<Start>"#".*\n                          {
+                                          if (g_isFixedForm && yy_my_start == 6) YY_FTN_REJECT;
+                                          startFontClass("preprocessor");
   					  codifyLines(yytext);
 					  endFontClass();
+                                          YY_FTN_RESET
                                         }
  /*------ variable references?  -------------------------------------*/ 
 
@@ -1026,9 +1065,10 @@
   					  codifyLines(str);
 					  endFontClass();
                                           str = "";
+                                          YY_FTN_RESET
                                         }           
 <String>\"|\'                           { // string ends with next quote without previous backspace 
-                                          if(yytext[0]!=stringStartSymbol) REJECT; // single vs double quote
+                                          if(yytext[0]!=stringStartSymbol) YY_FTN_REJECT; // single vs double quote
                                           str+=yytext;
   					  startFontClass("stringliteral");
   					  codifyLines(str);
@@ -1038,7 +1078,8 @@
 <String>.                               {str+=yytext;}
 
 <*>\"|\'                                { /* string starts */
-					  /* if(YY_START == StrIgnore) REJECT; // ignore in simple comments */
+					  /* if(YY_START == StrIgnore) YY_FTN_REJECT; // ignore in simple comments */
+                                          if (g_isFixedForm && yy_my_start == 6) YY_FTN_REJECT;
                                           yy_push_state(YY_START);
                                           stringStartSymbol=yytext[0]; // single or double quote
                                           BEGIN(String);
@@ -1048,6 +1089,7 @@
 
 <*>\n					{
   					  codifyLines(yytext); 
+                                          YY_FTN_RESET
   					}
 <*>.					{ 
   					  g_code->codify(yytext);
