8#define RECOMMENDED_LEN 100
37 int non_ascii_found=0;
51 if (non_ascii_found) printf(
"non-ascii:>>%s<<\n",
buf);
65 if (((
p=strchr(
buf,
'('))!=
NULL)&&(isalnum(*(--
p))||(*
p==
'_')))
70 if ((((
int)(
long)(
s-
buf))>10)||(strchr(
s,
' ')!=
NULL))
72 printf(
"warning: probably not a proc ? (%s)\n",
s);
77 printf(
"error: minimal length of a procedure name is 4: %s\n",
s);
81 else if (strstr(
buf,
"LIB ")!=
NULL)
break;
82 else if (strstr(
buf,
"LIB\"")!=
NULL)
break;
83 else if (strstr(
buf,
"proc ")!=
NULL)
break;
84 else if (strncmp(
buf,
"\";",2)==0)
break;
89 unsigned char *
pp=
buf;
90 while((*
pp==
' ')||(*
pp==
'\t'))
pp++;
91 ch=strspn(
pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
92 if ((ch>1)||(
pp+ch==
p))
99 printf(
"warning: no proc found in the section PROCEDURES ?\n");
100 printf(
"\n# proc mentioned in the header: %d\n",
proc_cnt);
113 if (isalpha(*
p)) {
get_next(); (*l)++;
return; }
115 else if (strstr(
buf,
"LIB ")!=
NULL)
break;
116 else if (strstr(
buf,
"LIB\"")!=
NULL)
break;
117 else if (strstr(
buf,
"proc ")!=
NULL)
break;
118 else if (strncmp(
buf,
"\";",2)==0)
break;
123 unsigned char *
pp=
buf;
124 while((*
pp==
' ')||(*
pp==
'\t'))
pp++;
125 ch=strspn(
pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
126 if ((ch>1)||(
pp+ch==
p))
132 printf(
"error: seperate keywords by ; but do not have ; after the last keyword\n");
139 if (strstr(
buf,
"\";")!=
NULL)
break;
140 if (
buf[0]==
'{')
break;
146 printf(
"texinfo in proc help(%s): >>%s",
s,
buf);
155 int have_PROCEDURES=0;
166 if (strstr(
buf,
"LIBRARY: ")!=
NULL)
170 if (have_other+have_AUTHORS+have_PROCEDURES+have_KEYWORDS+have_SEEALSO!=0)
171 printf(
"error: LIBRARY: must be the first section in info\n");
173 else if (strstr(
buf,
"NOTE:")!=
NULL)
175 if (have_PROCEDURES!=0)
176 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
179 else if (strstr(
buf,
"OVERVIEW:")!=
NULL)
182 if (have_PROCEDURES!=0)
183 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
185 else if (strstr(
buf,
"KEYWORDS: ")!=
NULL)
189 else if (strstr(
buf,
"SEE ALSO: ")!=
NULL)
193 else if ((strstr(
buf,
"AUTHORS: ")!=
NULL)
194 ||(strstr(
buf,
"AUTHOR: ")!=
NULL))
197 if (have_PROCEDURES!=0)
198 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
200 else if ((
p=strstr(
buf,
"PROCEDURES"))!=
NULL)
202 unsigned char *
pp=
buf;
205 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
216 printf(
"error: unknown section in library header: %s",
buf);
223 unsigned char *
pp=
buf;
224 while((*
pp==
' ')||(*
pp==
'\t'))
pp++;
225 ch=strspn(
pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
226 if ((ch>1)||(
pp+ch==
p))
229 if ((ch!=10)||(strncmp(
pp,
"REFERENCES",10)!=0))
231 printf(
"error: unknown section in library header: %s",
buf);
234 if (have_PROCEDURES!=0)
235 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
238 else if (strncmp(
buf,
"\";",2)==0)
goto e_o_info;
243 { texinfo++; printf(
"%s",
buf); }
248 printf(
"\nSUMMARY OF THE HEADER:\n");
250 printf(
"error: missing/duplicate LIBRARY (%d lines found, should be 1)\n",have_LIBRARY);
252 printf(
"error: missing/duplicate AUTHOR/AUTHORS (%d lines found, should be 1)\n",have_AUTHORS);
253 if (have_PROCEDURES!=1)
254 printf(
"error: missing/duplicate PROCEDURES (%d lines found, should be 1)\n",have_PROCEDURES);
256 printf(
"error: duplicate SEE ALSO (%d lines found)\n",have_SEEALSO);
258 printf(
"error: duplicate KEYWORDS (%d lines found)\n",have_KEYWORDS);
260 printf(
"hint: avoid NOTE: if not used for a library requirement\n");
261 else if (have_NOTE>1)
262 printf(
"error: duplicate NOTE (%d lines found)\n",have_NOTE);
263 if ((have_OVERVIEW==1)&&(
proc_cnt<3))
264 printf(
"hint: avoid OVERVIEW: for small libraries\n");
265 else if (have_OVERVIEW>1)
266 printf(
"error: duplicate OVERVIEW (%d lines found)\n",have_OVERVIEW);
269 printf(
"error: other header entries found (illegal ?) :%d lines found, should be 0\n",have_other);
272 printf(
"warning: %d forced line breaks in %d header lines: @* should be used very rarely!\n",
star_nl,
header);
276 printf(
"warning: %d texinfo commands in %d header lines: should be used very rarely!\n",texinfo,
header);
297 if (argc!=2) { printf(
"usage: %s lib-file\n",argv[0]);
return 1;}
298 printf(
"\n CHECKING LIBRARY %s\n\n",argv[1]);
299 f=fopen(argv[1],
"r");
300 if(
f==
NULL) { printf(
"cannot read %s\n",argv[1]);
return 2; }
305 if (strncmp(
buf,
"//",2)!=0) { printf(
"error: lib must start with //\n"); }
310 if ((
p=strstr(
buf,
"version="))!=
NULL)
312 unsigned char *
pp=
buf;
315 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
322 while((*
pp)==
' ')
pp++;
329 if ((
p=strstr(
buf,
"category="))!=
NULL)
331 unsigned char *
pp=
buf;
334 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
337 if (
p=
pp) have_category++;
341 unsigned char *
pp=
buf;
344 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
351 printf(
"error: use a space between LIB and \"\n");
353 { printf(
"end of header ? LIB should be in col. 1:>>%s<<\n",
buf); }
359 { printf(
"end of header ? LIB should be in col. 1:>>%s<<\n",
buf); }
364 if ((
p!=
buf)&&(strncmp(
buf,
"static proc ",12)!=0))
365 { printf(
"end of header ? proc should be in col. 1:>>%s<<\n",
buf); }
371 printf(
"header parsed: %d lines of %s\n\n",
header,argv[1]);
375 if ((strstr(
buf,
"static")==(
char*)
buf) && (strstr(
buf,
"proc")==
NULL))
377 printf(
"error: 'static' without 'proc' found\n");
381 &&(strncmp(
buf,
"static proc ",12)!=0))
383 unsigned char *
pp=
buf;
385 while(*
pp==
' ')
pp++;
388 printf(
"warning: proc should be in col. 1: line %d:%s",
lines,
buf);
397 while(isalnum(*
p)||(*
p==
'_'))
p++;
401 if(strcmp(
proc[
i],
pp)==0)
break;
405 printf(
"hint: global proc %s not found in header\n",
pp);
420 if(strncmp(
buf,
"proc ",5)==0)
break;
421 if(strncmp(
buf,
"static proc ",12)==0)
break;
422 if(strncmp(
buf,
"example",7)==0)
440 if(
have_doc[
i]==0) printf(
"proc %s has no documentation\n",
proc[
i]);
441 if(
have_example[
i]==0) printf(
"proc %s has no example (or it does not start in col. 1)\n",
proc[
i]);
446 printf(
"\nproc part parsed: %d lines of %s\n",
footer,argv[1]);
447 if (have_version!=1) printf(
"version missing/duplicate (%d)\n",have_version);
448 if (have_category!=1) printf(
"category missing/duplicate (%d)\n",have_category);
449 if (have_info!=1) printf(
"info missing/duplicate (%d)\n",have_info);
451 printf(
"\nGENERAL SUMMARY:\n");
452 if(
tabs!=0) printf(
"warning: lib should not contain tabs, >=%d found\n",
tabs);
456 printf(
"error: lib should not contain non-ascii characters, %d found, last in line %d\n",
non_ascii,
non_ascii_line);
459 printf(
"warning: DOS format (%d)\n",
crlf);
463 printf(
"error: some lines are in DOS format, some not (%d/%d)\n",
crlf,
lines);
465 printf(
"%d lines parsed\n",
lines);
466 printf(
"%d proc found in header\n",
proc_cnt);
468 printf(
"%d lines found in proc help with texinfo commands (should be very small)\n",
proc_help_texinfo);
void scan_proc_help(const char *s)
unsigned char proc_found[NUM_PROC]
void scan_keywords(int *l)
unsigned char have_doc[NUM_PROC]
unsigned char have_example[NUM_PROC]
unsigned char buf[LINE_LEN]
unsigned char * proc[NUM_PROC]
const CanonicalForm int s