--- src/.svn/text-base/fortranscanner.l.svn-base	2011-06-30 22:02:54.372800000 +0200
+++ src/fortranscanner.l	2011-07-17 15:10:34.941983200 +0200
@@ -111,6 +111,10 @@
 {
    "", "intent(in)", "intent(out)", "intent(inout)"
 };
+static const char *directionParam[] = 
+{
+   "", "[in]", "[out]", "[in,out]"
+};
 
 // }}}
 
@@ -127,6 +131,8 @@
 static unsigned int     inputPositionPrepass;
 static int              lineCountPrepass = 0;
 
+static QList<Entry>  subrCurrent;
+
 struct CommentInPrepass {
   int column;
   QCString str;
@@ -185,6 +191,7 @@
 static int yyread(char *buf,int max_size);
 static void startCommentBlock(bool);
 static void handleCommentBlock(const QCString &doc,bool brief);
+static void subrHandleCommentBlock(const QCString &doc,bool brief);
 static void addCurrentEntry();
 static void addModule(const char *name, bool isModule=FALSE);
 static void addSubprogram(const char *text);
@@ -646,6 +654,7 @@
 
 					   if (!endScope(current_root))
 					     yyterminate();
+                                           subrCurrent.remove(0u);
 					   yy_pop_state() ;
 				        }
 <Start,ModuleBody,TypedefBody,SubprogBody>{
@@ -756,8 +765,7 @@
 					      if (!argType.isNull()) parameter->type=argType.stripWhiteSpace();
 					      if (!docBlock.isNull()) 
 					      {
-						parameter->docs += "\n";
-						parameter->docs += docBlock;
+  					        subrHandleCommentBlock(docBlock,TRUE);
 					      }					    
 					    }
 					    // save, it may be function return type
@@ -1000,11 +1018,12 @@
                                           }
 					  else if (v_type == V_PARAMETER) 
 					  {
-					    parameter->docs+=docBlock;
+  					    subrHandleCommentBlock(docBlock,TRUE);
                                           }
-                                          yy_pop_state();
- 					 }
-   
+                                          yy_pop_state();                                          
+                                          docBlock.resize(0);
+                                          }
+
 <Start,SubprogBody,ModuleBody,TypedefBody,InterfaceBody,ModuleBodyContains,SubprogBodyContains,TypedefBodyContains>"!>"  {
                                           yy_push_state(YY_START);
 					  current->docLine  = yyLineNr;
@@ -1868,6 +1911,7 @@
 static void addSubprogram(const char *text)
 {
   //fprintf(stderr,"1=========> got subprog, type: %s\n",text); 
+  subrCurrent.prepend(current);
   current->section = Entry::FUNCTION_SEC ;
   QCString subtype = text; subtype=subtype.lower().stripWhiteSpace();
   current->type += " " + subtype;
@@ -1995,6 +2039,25 @@
 
   if (needsEntry) addCurrentEntry();
 }
+static void subrHandleCommentBlock(const QCString &doc,bool brief)
+{
+  Entry *tmp_entry = current; 
+  current = subrCurrent.first(); // temporarily switch to the entry of the subroutine / function
+  if (docBlock.stripWhiteSpace().find("\\param") == 0)
+  {
+    handleCommentBlock(docBlock,TRUE);
+  }
+  else if (docBlock.stripWhiteSpace().find("@param") == 0)
+  {
+    handleCommentBlock(docBlock,TRUE);
+  }
+  else 
+  {
+    int dir1 = modifiers[current_root][argName.lower()].direction;
+    handleCommentBlock(QCString("@param ") + directionParam[dir1] + " " + argName + " " + docBlock,TRUE);
+  }
+  current=tmp_entry;
+}
 
 //----------------------------------------------------------------------------
 static int level=0;
