aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fref.lex26
1 files changed, 14 insertions, 12 deletions
diff --git a/fref.lex b/fref.lex
index 750711c..5a35bd4 100644
--- a/fref.lex
+++ b/fref.lex
@@ -37,7 +37,7 @@
/* END */
void entry(void);
- void field(char *);
+ void field();
struct trans *gettrans(char *);
int pf(char *, ...);
@@ -74,8 +74,8 @@
%%
\n lines++; ECHO;
-^%.*\n line = ++lines; field(yytext); BEGIN(ENTRY);
-<ENTRY>^%.*\n lines++; field(yytext);
+^%.*\n line = ++lines; field(); BEGIN(ENTRY);
+<ENTRY>^%.*\n lines++; field();
<ENTRY>^[^%] entry(); ECHO; BEGIN(0);
<ENTRY><<EOF>> entry(); yyterminate();
%%
@@ -115,17 +115,19 @@ main(int argc, char *argv[])
/* Save entry field. */
void
-field(char *s)
+field()
{
- s++;
- s[strcspn(s, "\n")] = 0;
+ yytext++;
+ yytext[strcspn(yytext, "\n")] = 0;
/* Fill corresponding field. */
- #define AS(a,b) \
- if(strncmp(s, a, 2) == 0 && (s += 3)){ strcpy(b, s); return; }
+ #define FI(s,m) if(strncmp(yytext,s,2) == 0 && (yytext += 3)){ \
+ strcpy(m, yytext); \
+ return; \
+ }
- AS("au",e.au[e.a++]);
- #define DO(s,n,m) AS(s,m)
+ FI("au",e.au[e.a++]);
+ #define DO(s,n,m) FI(s,m)
FOR_FIELDS
#undef DO
@@ -134,7 +136,7 @@ field(char *s)
* with a positive value.
*/
fprintf(stderr, "%s: unrecognized field %%%.2s at line %d\n",
- name, s, lines);
+ name, yytext, lines);
exit(1);
}
@@ -142,8 +144,8 @@ field(char *s)
void
entry()
{
- struct trans *t;
int i;
+ struct trans *t;
/* Get translation strings. */
t = gettrans(*e.lc ? e.lc : lang);