diff --git a/Parser/FunctionManager.cpp b/Parser/FunctionManager.cpp
index 9c9dc8e713546606eb41d3642476132be982de7d..d31ec25c84d3b3775b4e078822899786b2fddd90 100644
--- a/Parser/FunctionManager.cpp
+++ b/Parser/FunctionManager.cpp
@@ -14,6 +14,7 @@ struct ltstr
 class File_Position 
 {
   public :
+    int lineno;
     fpos_t position;
     FILE *file;
 };
@@ -46,20 +47,22 @@ FunctionManager* FunctionManager::Instance()
   return instance;
 }
 
-bool FunctionManager::enterFunction(char *name, FILE **f) const
+bool FunctionManager::enterFunction(char *name, FILE **f, int &lno) const
 {
   if(functions->m.find(name) == functions->m.end())return false;
   File_Position fpold;
+  fpold.lineno = lno;
   fpold.file = *f;
   fgetpos(fpold.file,&fpold.position);
   calls->s.push(fpold);
   File_Position fp = (functions->m)[name];
   fsetpos(fp.file,&fp.position);
   *f = fp.file;
+  lno = fp.lineno;
   return true;
 }
 
-bool FunctionManager::leaveFunction(FILE **f)
+bool FunctionManager::leaveFunction(FILE **f,int &lno)
 {
   if(!calls->s.size())return false;
   File_Position fp;
@@ -67,13 +70,15 @@ bool FunctionManager::leaveFunction(FILE **f)
   calls->s.pop();
   fsetpos(fp.file,&fp.position);
   *f = fp.file;
+  lno = fp.lineno;
   return true;
 }
 
-bool FunctionManager::createFunction(char *name, FILE *f)
+bool FunctionManager::createFunction(char *name, FILE *f, int lno)
 {
   File_Position fp;
   fp.file = f;
+  fp.lineno = lno;
   fgetpos(fp.file,&fp.position);
   (functions->m)[name] = fp;
   return true;
diff --git a/Parser/FunctionManager.h b/Parser/FunctionManager.h
index 6961f6dd17051dc55728412a901eab3923eba890..e3befed6a58f99f68b5fa15789e9b3d91484131e 100644
--- a/Parser/FunctionManager.h
+++ b/Parser/FunctionManager.h
@@ -17,9 +17,9 @@ class FunctionManager
     static FunctionManager *instance;
   public :
     static FunctionManager* Instance();
-    bool enterFunction (char *name, FILE **f) const;
-    bool createFunction  (char *name, FILE *f);
-    bool leaveFunction (FILE **f);
+    bool enterFunction (char *name, FILE **f, int &) const;
+    bool createFunction  (char *name, FILE *f, int);
+    bool leaveFunction (FILE **f, int &);
 };
 
 #endif
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index 2ca619ea4984d0b82c514e1705af895c002fb0cc..e186dd3b05dd2b028b8fe59344b55ef06f9f7d43 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -164,7 +164,7 @@
 #define	tMINUSMINUS	414
 
 #line 1 "Gmsh.y"
- /* $Id: Gmsh.tab.cpp,v 1.26 2000-12-07 16:03:43 remacle Exp $ */
+ /* $Id: Gmsh.tab.cpp,v 1.27 2000-12-07 16:24:58 remacle Exp $ */
 
 #include <stdarg.h>
 
@@ -4831,7 +4831,7 @@ case 208:
 case 209:
 #line 1743 "Gmsh.y"
 {
-    if(!FunctionManager::Instance()->leaveFunction(&yyin))
+    if(!FunctionManager::Instance()->leaveFunction(&yyin,yylineno))
       {
 	vyyerror("Error while exiting function");
       }
@@ -4840,7 +4840,7 @@ case 209:
 case 210:
 #line 1750 "Gmsh.y"
 {
-    if(!FunctionManager::Instance()->enterFunction(yyvsp[-1].c,&yyin))
+    if(!FunctionManager::Instance()->enterFunction(yyvsp[-1].c,&yyin,yylineno))
       {
 	vyyerror("Unknown Function %s",yyvsp[-1].c);
       }
@@ -4850,7 +4850,7 @@ case 211:
 #line 1757 "Gmsh.y"
 {
     // skip everything until return is found
-    if(!FunctionManager::Instance()->createFunction(yyvsp[0].c,yyin))
+    if(!FunctionManager::Instance()->createFunction(yyvsp[0].c,yyin,yylineno))
       {
 	vyyerror("Redefinition of function %s",yyvsp[0].c);
       }
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index 5ce893dd606f70892d520c33ae1a180b2f1c59ca..cdffecc205b7f46b3bdde0ac959e56dbd78e78c2 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,4 +1,4 @@
-%{ /* $Id: Gmsh.y,v 1.26 2000-12-07 16:03:44 remacle Exp $ */
+%{ /* $Id: Gmsh.y,v 1.27 2000-12-07 16:24:58 remacle Exp $ */
 
 #include <stdarg.h>
 
@@ -1741,14 +1741,14 @@ Loop :
   }
   | tReturn
   {
-    if(!FunctionManager::Instance()->leaveFunction(&yyin))
+    if(!FunctionManager::Instance()->leaveFunction(&yyin,yylineno))
       {
 	vyyerror("Error while exiting function");
       }
   } 
   | tCall tSTRING tEND
   {
-    if(!FunctionManager::Instance()->enterFunction($2,&yyin))
+    if(!FunctionManager::Instance()->enterFunction($2,&yyin,yylineno))
       {
 	vyyerror("Unknown Function %s",$2);
       }
@@ -1756,7 +1756,7 @@ Loop :
   | tFunction tSTRING
   {
     // skip everything until return is found
-    if(!FunctionManager::Instance()->createFunction($2,yyin))
+    if(!FunctionManager::Instance()->createFunction($2,yyin,yylineno))
       {
 	vyyerror("Redefinition of function %s",$2);
       }
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index eac5173ed961535686bd7202c762d24099b8caa5..aa3608feb2270bff815c00784a3a73768caa2538 100644
--- a/Parser/Gmsh.yy.cpp
+++ b/Parser/Gmsh.yy.cpp
@@ -2,7 +2,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.26 2000-12-07 16:03:44 remacle Exp $
+ * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.27 2000-12-07 16:24:58 remacle Exp $
  */
 
 #define FLEX_SCANNER
diff --git a/examples/function.geo b/examples/function.geo
index 000e7e6b64eb65a66d0ede9c7b401e6ef45c58cf..54ce6fe371ebc182eabebc44a88473947e50c5e3 100644
--- a/examples/function.geo
+++ b/examples/function.geo
@@ -55,3 +55,5 @@ Line(10000) = {6,11};
 Attractor Line {10000} = {1,.03,1};
 
 Mesh.Algorithm = 2 ; // This is the new 2D anisotropic algorithm
+
+