summaryrefslogtreecommitdiff
path: root/lib/meta.c
diff options
context:
space:
mode:
authorPixel <>2001-04-01 12:36:50 +0000
committerPixel <>2001-04-01 12:36:50 +0000
commit8212d25ba09a7fdf1938a1992022a0143d29e05b (patch)
treebedd5f49afe9d2a74cdb7436ac1bce1151fe6d0e /lib/meta.c
parent4837528241a8f05ce2ca1fcdf35ea60b27728fb3 (diff)
Exceptions
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) {