#include <stdio.h>
#include <string.h>
#include <ctype.h>
Go to the source code of this file.
◆ LINE_LEN
◆ NUM_PROC
◆ RECOMMENDED_LEN
#define RECOMMENDED_LEN 100 |
◆ get_next()
Definition at line 27 of file checklibs.c.
35 int non_ascii_found=0;
49 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 261 of file checklibs.c.
272 if (argc!=2) { printf(
"usage: %s lib-file\n",argv[0]);
return 1;}
274 printf(
"\n CHECKING LIBRARY %s\n\n",argv[1]);
276 f=fopen(argv[1],
"r");
277 if(
f==
NULL) { printf(
"cannot read %s\n",argv[1]);
return 2; }
280 if (strncmp(
buf,
"//",2)!=0) { printf(
"error: lib must start with //\n"); }
285 if ((
p=strstr(
buf,
"version="))!=
NULL)
287 unsigned char *
pp=
buf;
290 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
297 while((*
pp)==
' ')
pp++;
304 if ((
p=strstr(
buf,
"category="))!=
NULL)
306 unsigned char *
pp=
buf;
309 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
312 if (
p=
pp) have_category++;
316 unsigned char *
pp=
buf;
319 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
326 printf(
"error: use a space between LIB and \"\n");
328 { printf(
"end of header ? LIB should be in col. 1:>>%s<<\n",
buf); }
334 { printf(
"end of header ? LIB should be in col. 1:>>%s<<\n",
buf); }
339 if ((
p!=
buf)&&(strncmp(
buf,
"static proc ",12)!=0))
340 { printf(
"end of header ? proc should be in col. 1:>>%s<<\n",
buf); }
346 printf(
"header parsed: %d lines of %s\n\n",
header,argv[1]);
350 if ((strstr(
buf,
"static")==(
char*)
buf) && (strstr(
buf,
"proc")==
NULL))
352 printf(
"error: 'static' without 'proc' found\n");
356 &&(strncmp(
buf,
"static proc ",12)!=0))
358 unsigned char *
pp=
buf;
360 while(*
pp==
' ')
pp++;
363 printf(
"warning: proc should be in col. 1: line %d:%s",
lines,
buf);
372 while(isalnum(*
p)||(*
p==
'_'))
p++;
376 if(strcmp(
proc[
i],
pp)==0)
break;
380 printf(
"hint: global proc %s not found in header\n",
pp);
393 if(strncmp(
buf,
"proc ",5)==0)
break;
394 if(strncmp(
buf,
"static proc ",12)==0)
break;
395 if(strncmp(
buf,
"example",7)==0)
413 if(
have_doc[
i]==0) printf(
"proc %s has no documentation\n",
proc[
i]);
414 if(
have_example[
i]==0) printf(
"proc %s has no example (or it does not start in col. 1)\n",
proc[
i]);
419 printf(
"\nproc part parsed: %d lines of %s\n",
footer,argv[1]);
420 if (have_version!=1) printf(
"version missing/duplicate (%d)\n",have_version);
421 if (have_category!=1) printf(
"category missing/duplicate (%d)\n",have_category);
422 if (have_info!=1) printf(
"info missing/duplicate (%d)\n",have_info);
424 printf(
"\nGENERAL SUMMARY:\n");
425 if(
tabs!=0) printf(
"warning: lib should not contain tabs, >=%d found\n",
tabs);
429 printf(
"error: lib should not contain non-ascii characters, %d found, last in line %d\n",
non_ascii,
non_ascii_line);
432 printf(
"warning: DOS format (%d)\n",
crlf);
436 printf(
"error: some lines are in DOS format, some not (%d/%d)\n",
crlf,
lines);
438 printf(
"%d lines parsed\n",
lines);
439 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 132 of file checklibs.c.
136 int have_PROCEDURES=0;
147 if (strstr(
buf,
"LIBRARY: ")!=
NULL)
151 if (have_other+have_AUTHORS+have_PROCEDURES+have_KEYWORDS+have_SEEALSO!=0)
152 printf(
"error: LIBRARY: must be the first section in info\n");
154 else if (strstr(
buf,
"NOTE:")!=
NULL)
156 if (have_PROCEDURES!=0)
157 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
160 else if (strstr(
buf,
"OVERVIEW:")!=
NULL)
163 if (have_PROCEDURES!=0)
164 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
166 else if (strstr(
buf,
"KEYWORDS: ")!=
NULL)
170 else if (strstr(
buf,
"SEE ALSO: ")!=
NULL)
174 else if ((strstr(
buf,
"AUTHORS: ")!=
NULL)
175 ||(strstr(
buf,
"AUTHOR: ")!=
NULL))
178 if (have_PROCEDURES!=0)
179 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
181 else if ((
p=strstr(
buf,
"PROCEDURES"))!=
NULL)
183 unsigned char *
pp=
buf;
186 if ((*
pp!=
' ')&&(*
pp!=
'\t'))
break;
197 printf(
"error: unknown section in library header: %s",
buf);
204 unsigned char *
pp=
buf;
205 while((*
pp==
' ')||(*
pp==
'\t'))
pp++;
206 ch=strspn(
pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
207 if ((ch>1)||(
pp+ch==
p))
210 if ((ch!=10)||(strncmp(
pp,
"REFERENCES",10)!=0))
212 printf(
"error: unknown section in library header: %s",
buf);
215 if (have_PROCEDURES!=0)
216 printf(
"error: only KEYWORDS/SEE ALSO may follow PROCEDURES\n");
219 else if (strncmp(
buf,
"\";",2)==0)
goto e_o_info;
224 { texinfo++; printf(
"%s",
buf); }
229 printf(
"\nSUMMARY OF THE HEADER:\n");
231 printf(
"error: missing/duplicate LIBRARY (%d lines found, should be 1)\n",have_LIBRARY);
233 printf(
"error: missing/duplicate AUTHOR/AUTHORS (%d lines found, should be 1)\n",have_AUTHORS);
234 if (have_PROCEDURES!=1)
235 printf(
"error: missing/duplicate PROCEDURES (%d lines found, should be 1)\n",have_PROCEDURES);
237 printf(
"error: duplicate SEE ALSO (%d lines found)\n",have_SEEALSO);
239 printf(
"error: duplicate KEYWORDS (%d lines found)\n",have_KEYWORDS);
241 printf(
"hint: avoid NOTE: if not used for a library requirement\n");
242 else if (have_NOTE>1)
243 printf(
"error: duplicate NOTE (%d lines found)\n",have_NOTE);
244 if ((have_OVERVIEW==1)&&(
proc_cnt<3))
245 printf(
"hint: avoid OVERVIEW: for small libraries\n");
246 else if (have_OVERVIEW>1)
247 printf(
"error: duplicate OVERVIEW (%d lines found)\n",have_OVERVIEW);
250 printf(
"error: other header entries found (illegal ?) :%d lines found, should be 0\n",have_other);
253 printf(
"warning: %d forced line breaks in %d header lines: @* should be used very rarely!\n",
star_nl,
header);
257 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 101 of file checklibs.c.
111 if (isalpha(*
p)) {
get_next(); (*l)++;
return; }
113 else if (strstr(
buf,
"LIB ")!=
NULL)
break;
114 else if (strstr(
buf,
"LIB\"")!=
NULL)
break;
115 else if (strstr(
buf,
"proc ")!=
NULL)
break;
116 else if (strncmp(
buf,
"\";",2)==0)
break;
121 unsigned char *
pp=
buf;
122 while((*
pp==
' ')||(*
pp==
'\t'))
pp++;
123 ch=strspn(
pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
124 if ((ch>1)||(
pp+ch==
p))
130 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 57 of file checklibs.c.
63 if (((
p=strchr(
buf,
'('))!=
NULL)&&(isalnum(*(--
p))||(*
p==
'_')))
68 if ((((
int)(
long)(
s-
buf))>10)||(strchr(
s,
' ')!=
NULL))
70 printf(
"warning: probably not a proc ? (%s)\n",
s);
75 printf(
"error: minimal length of a procedure name is 4: %s\n",
s);
79 else if (strstr(
buf,
"LIB ")!=
NULL)
break;
80 else if (strstr(
buf,
"LIB\"")!=
NULL)
break;
81 else if (strstr(
buf,
"proc ")!=
NULL)
break;
82 else if (strncmp(
buf,
"\";",2)==0)
break;
87 unsigned char *
pp=
buf;
88 while((*
pp==
' ')||(*
pp==
'\t'))
pp++;
89 ch=strspn(
pp,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
90 if ((ch>1)||(
pp+ch==
p))
97 printf(
"warning: no proc found in the section PROCEDURES ?\n");
98 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