summaryrefslogtreecommitdiff
path: root/lib/meta.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/meta.c')
-rw-r--r--lib/meta.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/lib/meta.c b/lib/meta.c
index c40f116..275d60b 100644
--- a/lib/meta.c
+++ b/lib/meta.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <limits.h>
#include <string.h>
+#include <errno.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
@@ -45,25 +46,32 @@ static char *getword(char *line, char *p)
line++;
} while ((*line) && (!strchr(meta_ops, o)) && (!strchr(meta_ops, *line)));
*p = '\0';
+
return line;
}
void meta_parse_line(char *line)
{
char buffer[BUFSIZ], *first = NULL, m = 0, *p1 = NULL, *p2 = NULL, *Fnames[MAXF], *Fimplicits[MAXF],
- *Snames[MAXF], *Sinames[MAXF], gotname = 0, goteoi = 0;
+ *Snames[MAXF], *Sinames[MAXF], gotname = 0, goteoi = 0, errbuff[BUFSIZ];
phon_t *phon = NULL;
field_t *field = NULL;
pattern_t *pattern = NULL;
instruct_t *instruct = NULL;
metaexpr_t *metaexpr = NULL, *tmetaexpr, *tabmetaexpr[MAXM];
int Fsizes[MAXF], Fvalues[MAXF], Itypes[MAXF], Etypes[MAXF], nbfields = 0, valid, i, nbimplicit = 0;
-
+
if (*line == '#') {
return;
}
+
+ sprintf(errbuff, _("Read line '%s'"), line);
+ pushcontext(errbuff);
+
while (*line) {
line = getword(line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
if (!m) {
if (*line != ':') {
exception(1, _("Missing operator ':'"));
@@ -137,7 +145,10 @@ void meta_parse_line(char *line)
tmetaexpr->type = 0;
if (*buffer == '.') {
tmetaexpr->type = 1;
+ popcontext();
line = getword(line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
}
if (!isident(buffer)) {
exception(1, _("Identifier incorrect."));
@@ -147,7 +158,10 @@ void meta_parse_line(char *line)
if (*(++line) != '.') {
exception(1, _("Error: Expecting a . after a ="));
}
+ popcontext();
line = getword(++line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
if (!isident(buffer)) {
exception(1, _("Identifier incorrect."));
}
@@ -217,14 +231,20 @@ void meta_parse_line(char *line)
Etypes[nbfields] = 0;
if (*buffer == '.') {
Etypes[nbfields] = 1;
+ popcontext();
line = getword(line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
}
Fnames[nbfields] = Estrdup(buffer);
if (*line == '=') {
if (*(++line) != '.') {
exception(1, _("Error: character . expected."));
}
+ popcontext();
line = getword(++line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
if (!isident(buffer)) {
exception(1, _("Identifier incorrect."));
}
@@ -246,11 +266,17 @@ void meta_parse_line(char *line)
if (*line != '=') {
exception(1, _("= expected after an implicit name"));
}
+ popcontext();
line = getword(++line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
if (*buffer == '.') {
Itypes[nbimplicit] = 1;
+ popcontext();
line = getword(line, buffer);
+ sprintf(errbuff, _("Analysing word '%s'"), buffer);
+ pushcontext(errbuff);
if (!isident(buffer)) {
exception(1, _("Identifier incorrect"));
}
@@ -304,7 +330,10 @@ void meta_parse_line(char *line)
break;
}
}
+ popcontext();
}
+
+ popcontext();
}
int meta_init(void)
@@ -452,9 +481,16 @@ int meta_load(char * n) {
FILE * f;
char buf[BUFSIZ], *p;
+ pushcontext("Loading meta file");
+ sprintf(buf, "Opening file '%s'", n);
+ pushcontext(buf);
+
if (!(f = fopen(n, "r"))) {
+ pushcontext(strerror(errno));
return 1;
}
+ popcontext();
+ pushcontext("Reading file");
while (fgets(buf, BUFSIZ, f)) {
if ((p = strchr(buf, '\r'))) {
*p = '\0';
@@ -464,6 +500,11 @@ int meta_load(char * n) {
}
meta_parse_line(buf);
}
+ popcontext();
+ popcontext();
+
+
+ fclose(f);
return 0;
}