diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-23 23:46:32 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-23 23:46:32 +0200 |
commit | e2204cffaacc7fe5715d7cc557ff850e86106f6f (patch) | |
tree | 92cd5f0e8d6798d13162e576d0508f18d1aa9e85 | |
parent | 3cc57925da8dd928b0fd7f19f10ba56811980e6e (diff) | |
download | fref-e2204cffaacc7fe5715d7cc557ff850e86106f6f.tar.gz |
Remove unnecessary comments
-rw-r--r-- | fref.lex | 25 |
1 files changed, 4 insertions, 21 deletions
@@ -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 '%': |