diff options
-rw-r--r-- | fref.lex | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -65,12 +65,13 @@ extern int optind; char *name; /* Program name. */ - char *lang = NULL; /* Main language (-l). */ + char *lang; /* Main language (-l). */ int line; /* Line at which entry begins. */ - int lines = 0; /* Total number of lines. */ - struct trans *len = NULL; /* English strings. */ - struct trans *lru = NULL; /* Russian strings. */ - struct trans *lsv = NULL; /* Swedish strings. */ + int lines; /* Total number of lines. */ + struct trans *len; /* English strings. */ + struct trans *lru; /* Russian strings. */ + struct trans *lsv; /* Swedish strings. */ + struct trans *tglob; /* Global (default) strings. */ %% \n lines++; ECHO; @@ -85,6 +86,12 @@ main(int argc, char *argv[]) { int c; + /* Initialize global variables. */ + lines = 0; + lang = NULL; + len = lru = lsv = tglob = NULL; + memset(&e, 0, sizeof(e)); + /* Save program name. */ name = strrchr(argv[0], '/'); if(name) name++; @@ -103,12 +110,8 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if(!lang) - lang = strdup("en"); - gettrans(lang); - - /* Clear entry struct. */ - memset(&e, 0, sizeof(e)); + /* Get global language strings. */ + tglob = gettrans(lang ? lang : "en"); yylex(); } @@ -148,7 +151,7 @@ entry() struct trans *t; /* Get translation strings. */ - t = gettrans(*e.lc ? e.lc : lang); + t = *e.lc ? gettrans(e.lc) : tglob; *e.lc = 0; /* Print label. */ @@ -240,7 +243,7 @@ gettrans(char *lg) if(!(lru = malloc(sizeof(struct trans)))) err(1, "malloc"); lru->and = strdup("и"); - lru->avail = strdup("Доступный: "); + lru->avail = strdup("Доступная: "); lru->ed = strdup("ред. "); lru->p = strdup("c. "); lru->pp = strdup("с. "); |