#include <stdio.h>
#include <string.h>
Go to the source code of this file.
§ LINE_LEN
§ NUM_PROC
§ RECOMMENDED_LEN
#define RECOMMENDED_LEN 100 |
§ get_next()
Definition at line 25 of file checklibs.c.
33 int non_ascii_found=0;
47 if (non_ascii_found) printf(
"non-ascii:>>%s<<\n",
buf);
unsigned char buf[LINE_LEN]
§ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 259 of file checklibs.c.
270 if (argc!=2) { printf(
"usage: %s lib-file\n",argv[0]);
return 1;}
272 printf(
"\n CHECKING LIBRARY %s\n\n",argv[1]);
274 f=fopen(argv[1],
"r");
275 if(
f==
NULL) { printf(
"cannot read %s\n",argv[1]);
return 2; }
278 if (strncmp(
buf,
"//",2)!=0) { printf(
"error: lib must start with //\n"); }
283 if ((p=strstr(
buf,
"version="))!=
NULL)
285 unsigned char *
pp=
buf;
288 if ((*pp!=
' ')&&(*pp!=
'\t'))
break;
295 while((*pp)==
' ') pp++;
302 if ((p=strstr(
buf,
"category="))!=
NULL)
304 unsigned char *pp=
buf;
307 if ((*pp!=
' ')&&(*pp!=
'\t'))
break;
310 if (p=pp) have_category++;
312 if ((p=strstr(
buf,
"info="))!=
NULL)
314 unsigned char *pp=
buf;
317 if ((*pp!=
' ')&&(*pp!=
'\t'))
break;
322 if ((p=strstr(
buf,
"LIB\""))!=
NULL)
324 printf(
"error: use a space between LIB and \"\n");
326 { printf(
"end of header ? LIB should be in col. 1:>>%s<<\n",
buf); }
329 if ((p=strstr(
buf,
"LIB \""))!=
NULL)
332 { printf(
"end of header ? LIB should be in col. 1:>>%s<<\n",
buf); }
335 if ((p=strstr(
buf,
"proc "))!=
NULL)
337 if ((p!=
buf)&&(strncmp(
buf,
"static proc ",12)!=0))
338 { printf(
"end of header ? proc should be in col. 1:>>%s<<\n",
buf); }
344 printf(
"header parsed: %d lines of %s\n\n",
header,argv[1]);
348 if ((strstr(
buf,
"static")==(
char*)
buf) && (strstr(
buf,
"proc")==
NULL))
350 printf(
"error: 'static' without 'proc' found\n");
353 if(((p=strstr(
buf,
"proc "))!=
NULL)
354 &&(strncmp(
buf,
"static proc ",12)!=0))
356 unsigned char *pp=
buf;
358 while(*pp==
' ') pp++;
359 if ((pp!=
buf)&&(pp==p))
361 printf(
"warning: proc should be in col. 1: line %d:%s",
lines,
buf);
370 while(isalnum(*p)||(*p==
'_')) p++;
374 if(strcmp(
proc[i],pp)==0)
break;
378 printf(
"hint: global proc %s not found in header\n",pp);
391 if(strncmp(
buf,
"proc ",5)==0)
break;
392 if(strncmp(
buf,
"static proc ",12)==0)
break;
393 if(strncmp(
buf,
"example",7)==0)
411 if(
have_doc[i]==0) printf(
"proc %s has no documentation\n",
proc[i]);
412 if(
have_example[i]==0) printf(
"proc %s has no example (or it does not start in col. 1)\n",
proc[i]);
417 printf(
"\nproc part parsed: %d lines of %s\n",
footer,argv[1]);
418 if (have_version!=1) printf(
"version missing/duplicate (%d)\n",have_version);
419 if (have_category!=1) printf(
"category missing/duplicate (%d)\n",have_category);
420 if (have_info!=1) printf(
"info missing/duplicate (%d)\n",have_info);
422 printf(
"\nGENERAL SUMMARY:\n");
423 if(
tabs!=0) printf(
"warning: lib should not contain tabs, >=%d found\n",
tabs);
427 printf(
"error: lib should not contain non-ascii characters, %d found, last in line %d\n",
non_ascii,
non_ascii_line);
430 printf(
"warning: DOS format (%d)\n",
crlf);
434 printf(
"error: some lines are in DOS format, some not (%d/%d)\n",
crlf,
lines);
436 printf(
"%d lines parsed\n",
lines);
437 printf(
"%d proc found in header\n",
proc_cnt);
unsigned char * proc[NUM_PROC]
unsigned char proc_found[NUM_PROC]
unsigned char have_doc[NUM_PROC]
unsigned char buf[LINE_LEN]
unsigned char have_example[NUM_PROC]
§ scan_info()
void scan_info |
( |
int * |
l | ) |
|
Definition at line 130 of file checklibs.c.
134 int have_PROCEDURES=0;
145 if (strstr(
buf,
"LIBRARY: ")!=
NULL)
149 if (have_other+have_AUTHORS+have_PROCEDURES+have_KEYWORDS+have_SEEALSO!=0)
150 printf(
"error: LIBRARY: must be the first section in info\n");
152 else if (strstr(
buf,
"NOTE:")!=
NULL)
154 if (have_PROCEDURES!=0)
155 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
158 else if (strstr(
buf,
"OVERVIEW:")!=
NULL)
161 if (have_PROCEDURES!=0)
162 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
164 else if (strstr(
buf,
"KEYWORDS: ")!=
NULL)
168 else if (strstr(
buf,
"SEE ALSO: ")!=
NULL)
172 else if ((strstr(
buf,
"AUTHORS: ")!=
NULL)
173 ||(strstr(
buf,
"AUTHOR: ")!=
NULL))
176 if (have_PROCEDURES!=0)
177 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
179 else if ((p=strstr(
buf,
"PROCEDURES:"))!=
NULL)
181 unsigned char *
pp=
buf;
184 if ((*pp!=
' ')&&(*pp!=
'\t'))
break;
195 printf(
"error: unknown section in library header: %s",
buf);
199 else if ((p=strstr(
buf,
":"))!=
NULL)
202 unsigned char *pp=
buf;
203 while((*pp==
' ')||(*pp==
'\t')) pp++;
204 ch=strspn(pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
205 if ((ch>1)||(pp+ch==p))
208 if ((ch!=10)||(strncmp(pp,
"REFERENCES",10)!=0))
210 printf(
"error: unknown section in library header: %s",
buf);
213 if (have_PROCEDURES!=0)
214 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
217 else if (strncmp(
buf,
"\";",2)==0)
goto e_o_info;
222 { texinfo++; printf(
"%s",
buf); }
227 printf(
"\nSUMMARY OF THE HEADER:\n");
229 printf(
"error: missing/duplicate LIBRARY (%d lines found, should be 1)\n",have_LIBRARY);
231 printf(
"error: missing/duplicate AUTHOR/AUTHORS (%d lines found, should be 1)\n",have_AUTHORS);
232 if (have_PROCEDURES!=1)
233 printf(
"error: missing/duplicate PROCEDURES (%d lines found, should be 1)\n",have_PROCEDURES);
235 printf(
"error: duplicate SEE ALSO (%d lines found)\n",have_SEEALSO);
237 printf(
"error: duplicate KEYWORDS (%d lines found)\n",have_KEYWORDS);
239 printf(
"hint: avoid NOTE: if not used for a library requirement\n");
240 else if (have_NOTE>1)
241 printf(
"error: duplicate NOTE (%d lines found)\n",have_NOTE);
242 if ((have_OVERVIEW==1)&&(
proc_cnt<3))
243 printf(
"hint: avoid OVERVIEW: for small libraries\n");
244 else if (have_OVERVIEW>1)
245 printf(
"error: duplicate OVERVIEW (%d lines found)\n",have_OVERVIEW);
248 printf(
"error: other header entries found (illegal ?) :%d lines found, should be 0\n",have_other);
251 printf(
"warning: %d forced line breaks in %d header lines: @* should be used very rarely!\n",
star_nl,
header);
255 printf(
"warning: %d texinfo commands in %d header lines: should be used very rarely!\n",texinfo,
header);
unsigned char buf[LINE_LEN]
§ scan_keywords()
void scan_keywords |
( |
int * |
l | ) |
|
Definition at line 99 of file checklibs.c.
109 if (isalpha(*p)) {
get_next(); (*l)++;
return; }
110 if (*p==
'\0') {
get_next(); (*l)++; }
111 else if (strstr(
buf,
"LIB ")!=
NULL)
break;
112 else if (strstr(
buf,
"LIB\"")!=
NULL)
break;
113 else if (strstr(
buf,
"proc ")!=
NULL)
break;
114 else if (strncmp(
buf,
"\";",2)==0)
break;
115 else if ((p=strstr(
buf,
":"))!=
NULL)
119 unsigned char *
pp=
buf;
120 while((*pp==
' ')||(*pp==
'\t')) pp++;
121 ch=strspn(pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
122 if ((ch>1)||(pp+ch==p))
128 printf(
"error: seperate keywords by ; but do not have ; after the last keyword\n");
unsigned char buf[LINE_LEN]
§ scan_proc()
void scan_proc |
( |
int * |
l | ) |
|
Definition at line 55 of file checklibs.c.
61 if (((p=strchr(
buf,
'('))!=
NULL)&&(isalnum(*(--p))||(*p==
'_')))
66 if ((((
int)(
long)(s-
buf))>10)||(strchr(s,
' ')!=
NULL))
68 printf(
"warning: probably not a proc ? (%s)\n",s);
73 printf(
"error: minimal length of a procedure name is 4: %s\n",s);
77 else if (strstr(
buf,
"LIB ")!=
NULL)
break;
78 else if (strstr(
buf,
"LIB\"")!=
NULL)
break;
79 else if (strstr(
buf,
"proc ")!=
NULL)
break;
80 else if (strncmp(
buf,
"\";",2)==0)
break;
81 else if ((p=strstr(
buf,
":"))!=
NULL)
85 unsigned char *
pp=
buf;
86 while((*pp==
' ')||(*pp==
'\t')) pp++;
87 ch=strspn(pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
88 if ((ch>1)||(pp+ch==p))
95 printf(
"warning: no proc found in the section PROCEDURES ?\n");
96 printf(
"\n# proc mentioned in the header: %d\n",
proc_cnt);
const CanonicalForm int s
unsigned char * proc[NUM_PROC]
unsigned char buf[LINE_LEN]
§ buf
§ crlf
§ footer
§ have_doc
§ have_example
§ header
§ lines
§ non_ascii
§ non_ascii_line
§ proc
§ proc_cnt
§ proc_found
§ star_nl
§ tabs
§ trailing_spaces
§ verylong_lines