summaryrefslogtreecommitdiff
path: root/lib/meta.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/meta.c')
-rw-r--r--lib/meta.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/meta.c b/lib/meta.c
index 7aa5add..c40f116 100644
--- a/lib/meta.c
+++ b/lib/meta.c
@@ -10,7 +10,7 @@ void exception(int, char *);
char * Estrdup(char *);
void * Emalloc(size_t);
#endif
-#include "global.h"
+#include "exceptions.h"
#include "numbers.h"
#include "meta.h"
@@ -448,6 +448,25 @@ void meta_flush(void) {
instructs = NULL;
}
+int meta_load(char * n) {
+ FILE * f;
+ char buf[BUFSIZ], *p;
+
+ if (!(f = fopen(n, "r"))) {
+ return 1;
+ }
+ while (fgets(buf, BUFSIZ, f)) {
+ if ((p = strchr(buf, '\r'))) {
+ *p = '\0';
+ }
+ if ((p = strchr(buf, '\n'))) {
+ *p = '\0';
+ }
+ meta_parse_line(buf);
+ }
+ return 0;
+}
+
#ifndef HAVE_CONFIG_H
char * Estrdup(char * o) {
char * r;
@@ -475,8 +494,6 @@ void exception(int level, char *msg)
void main(void)
{
- FILE *f;
- char buf[BUFSIZ], *p;
phon_t *phon;
field_t *field;
pattern_t *pattern;
@@ -486,13 +503,7 @@ void main(void)
if (meta_init())
exception(1, _("Meta parser init failed."));
- f = fopen("instructions.txt", "r");
- while (fgets(buf, BUFSIZ, f)) {
- if ((p = strchr(buf, '\n'))) {
- *p = '\0';
- }
- meta_parse_line(buf);
- }
+ meta_load("instructions.txt");
fprintf(stderr, "\nListe des phonèmes:\n");
for (phon = phons->next; phon; phon = phon->next) {