aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fref.lex25
1 files changed, 4 insertions, 21 deletions
diff --git a/fref.lex b/fref.lex
index d984f8e..19b0c2a 100644
--- a/fref.lex
+++ b/fref.lex
@@ -14,7 +14,7 @@
#include <err.h>
#include <stdarg.h>
- #define MAXFIELD 255 /* Max field length. */
+ #define MAXFIELD 255
#define FOR_FIELDS \
DO("ad",ad,e.ad) /* Access date. */ \
@@ -41,7 +41,6 @@
struct trans *gettrans(char *);
int pf(char *, ...);
- /* Translation strings. */
struct trans {
char *and;
char *avail;
@@ -87,18 +86,15 @@ main(int argc, char *argv[])
{
int c;
- /* Initialize global variables. */
line = lines = punct = 0;
lang = NULL;
tglob = NULL;
memset(&e, 0, sizeof(e));
- /* Save program name. */
name = strrchr(argv[0], '/');
if(name) name++;
else name = argv[0];
- /* Parse command-line options. */
while((c = getopt(argc, argv, "l:")) != -1)
switch(c){
case 'l':
@@ -111,7 +107,6 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- /* Get global language strings. */
tglob = gettrans(lang ? lang : "en");
yylex();
@@ -196,8 +191,7 @@ field()
yytext++;
yytext[strcspn(yytext, "\n")] = 0;
- /* Fill corresponding field. */
- #define FI(s,m) if(strncmp(yytext,s,2) == 0){ \
+ #define CMP(s,m) if(strncmp(yytext,s,2) == 0){ \
/* Don't copy empty field. */ \
if(strlen(yytext) < 3) \
return; \
@@ -206,15 +200,11 @@ field()
return; \
}
- FI("au",e.au[e.a++]);
- #define DO(s,n,m) FI(s,m)
+ CMP("au",e.au[e.a++]);
+ #define DO(s,n,m) CMP(s,m)
FOR_FIELDS
#undef DO
- /*
- * As no field matched, an error is printed and the program exits
- * with a positive value.
- */
fprintf(stderr, "%s: unrecognized field %%%.2s at line %d\n",
name, yytext, lines);
exit(1);
@@ -229,7 +219,6 @@ entry()
#define C(a,b) (punct ? b : a)
- /* Get translation strings. */
t = *e.lc ? gettrans(e.lc) : tglob;
*e.lc = 0;
@@ -311,7 +300,6 @@ pf(char *fmt, ...)
int i, n, sz;
va_list ap;
- /* Count interpolated strings. */
for(n = 0, p = fmt; *p; p++)
if(*p == '%' || *p == '*')
n++;
@@ -319,10 +307,6 @@ pf(char *fmt, ...)
if(!(fs = malloc(sizeof(char *)*n)))
err(1, "malloc");
- /*
- * The strings to be interpolated are saved in fs.
- * If any string is empty, the function returns false.
- */
va_start(ap, fmt);
for(i = 0; i < n; i++){
p = va_arg(ap, char *);
@@ -332,7 +316,6 @@ pf(char *fmt, ...)
}
va_end(ap);
- /* Print formatted string. */
for(i = 0; *fmt; fmt++)
switch(*fmt){
case '%':