summaryrefslogtreecommitdiff
path: root/src/util/ParseFile.c
diff options
context:
space:
mode:
authortradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2002-01-02 12:24:42 +0000
committertradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2002-01-02 12:24:42 +0000
commita2a57e189b6f7af4b38f724733f095e753fedcde (patch)
tree077488fae9fbb66e7420dcf9f59e444308a4cc14 /src/util/ParseFile.c
parent41af9e8cc55c4be04e72d4ea033115ecef047ea1 (diff)
The callback routine, CCTKi_SetParameter(), passed to the ParseFile() routine
now takes the current line number in the parameter file as a third argument. CCTKi_SetParameter() is now able to tell you what line in the parameter file was erroneous. This closes PR Cactus-838. git-svn-id: http://svn.cactuscode.org/flesh/trunk@2555 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util/ParseFile.c')
-rw-r--r--src/util/ParseFile.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/util/ParseFile.c b/src/util/ParseFile.c
index f09aa2d1..b1771453 100644
--- a/src/util/ParseFile.c
+++ b/src/util/ParseFile.c
@@ -3,11 +3,11 @@
@date Tue Jan 12 15:58:31 1999
@author Tom Goodale
@desc
- Routines to read in a parameter file and pass the resulting data
- to a user-supplied subroutine.
- Currently taken from the old cactus ones and slightly modifed.
+ Routines to read in a parameter file and pass the resulting data
+ to a user-supplied subroutine.
+ Currently taken from the old cactus ones and slightly modifed.
@enddesc
- @version $Header$
+ @version $Id$
@@*/
/*#define DEBUG*/
@@ -44,7 +44,7 @@ static void removeSpaces(char *stripMe);
********************************************************************/
int ParseFile(FILE *ifp,
- int (*set_function)(const char *, const char *),
+ int (*set_function)(const char *, const char *, int),
tFleshConfig *ConfigData);
/********************************************************************
@@ -120,7 +120,7 @@ static int lineno = 1;
@endreturndesc
@@*/
int ParseFile(FILE *ifp,
- int (*set_function)(const char *, const char *),
+ int (*set_function)(const char *, const char *, int),
tFleshConfig *ConfigData)
{
/* Buffers for parsing from the file */
@@ -164,6 +164,10 @@ int ParseFile(FILE *ifp,
printf("%c",c);
#endif
}
+ if (c == '\n')
+ {
+ lineno++;
+ }
c = fgetc(ifp);
#ifdef DEBUG
printf("%c",c);
@@ -279,7 +283,7 @@ int ParseFile(FILE *ifp,
printf ("\nString %s -> %s\n",
tokens,value);
#endif
- set_function(tokens,value);
+ set_function(tokens,value, lineno);
}
else if (c == '$')
{
@@ -307,7 +311,7 @@ int ParseFile(FILE *ifp,
free(dir);
free(file);
value[strlen(value)-1] = '\0';
- set_function(tokens,value);
+ set_function(tokens,value,lineno);
}
else
{
@@ -331,21 +335,20 @@ int ParseFile(FILE *ifp,
#ifdef DEBUG
printf("%c",c);
#endif
- if (c=='\n')
- {
-#ifdef DEBUG
- printf ("LINE %d\n",lineno);
-#endif
- lineno++;
- }
}
value[p] = '\0';
#ifdef DEBUG
printf ("Parsed %d characters\n", p);
printf("\nFloat/Int: %s -> %s\n", tokens,value);
#endif
- set_function(tokens,value);
-
+ set_function(tokens,value,lineno);
+ if (c=='\n')
+ {
+#ifdef DEBUG
+ printf ("LINE %d\n",lineno);
+#endif
+ lineno++;
+ }
}
else
{
@@ -437,7 +440,7 @@ int ParseFile(FILE *ifp,
}
subvalue[pp] = '\0';
- set_function(subtoken,subvalue);
+ set_function(subtoken,subvalue,lineno);
#ifdef DEBUG
printf("Setting sub-token %s -> %s\n",
subtoken, subvalue);
@@ -465,7 +468,7 @@ int ParseFile(FILE *ifp,
}
subvalue[pp] = '\0';
- set_function(subtoken,subvalue);
+ set_function(subtoken,subvalue,lineno);
}
}
}