aboutsummaryrefslogtreecommitdiff
path: root/fref.lex
diff options
context:
space:
mode:
Diffstat (limited to 'fref.lex')
-rw-r--r--fref.lex29
1 files changed, 16 insertions, 13 deletions
diff --git a/fref.lex b/fref.lex
index fb6fb47..e57eb01 100644
--- a/fref.lex
+++ b/fref.lex
@@ -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("с. ");