16 #include <ucommon/ucommon.h>
21 using namespace UCOMMON_NAMESPACE;
23 class lint :
public Script::interp
28 static Script::keyword_t keywords[] = {
31 static const char *defs[128];
32 static const char *clist =
" \t,;:";
35 static shell::flagopt helpflag(
'h',
"--help", _TEXT(
"display this list"));
36 static shell::flagopt althelp(
'?', NULL, NULL);
37 static shell::stringopt driver(
'd',
"--driver", _TEXT(
"driver lint definitions to use"),
"name", NULL);
38 static shell::stringopt modules(
'm',
"--modules", _TEXT(
"names of optional modules we added"),
"list", NULL);
39 static shell::flagopt ver(
'v',
"--version", _TEXT(
"version of application"));
41 static void version(
void)
43 printf(
"Bayonne Lint " VERSION
"\n"
44 "Copyright (C) 2009 David Sugar, Tycho Softworks\n"
45 "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
46 "This is free software: you are free to change and redistribute it.\n"
47 "There is NO WARRANTY, to the extent permitted by law.\n");
51 static void usage(
void)
53 printf(
"%s\n", _TEXT(
"usage: baylint [options] scriptfile\n"
56 printf(
"\n%s\n", _TEXT(
"Report bugs to dyfet@gnu.org"));
62 linked_pointer<Script::error> ep;
63 const char *modname = NULL;
71 shell::bind(
"baylint");
72 shell args(argc, argv);
76 const char *lintfiles = Env::env(
"definitions");
78 if(is(helpflag) || is(althelp))
88 fprintf(stderr,
"*** baylint: no filename specified\n");
92 ext = strrchr(fn,
'.');
94 if(!fsys::isfile(fn)) {
95 fprintf(stderr,
"*** baylint: %s: not found\n", fn);
99 if((is(driver) || is(modules)) && !fsys::isdir(lintfiles)) {
100 fprintf(stderr,
"*** baylint: %s: invalid data directory\n", lintfiles);
105 Script::assign(keywords);
111 modname = String::token((
char *)*modules, &tokens, clist);
115 modname = String::token(NULL, &tokens, clist);
120 if(!strchr(dn,
'/') && !strchr(dn,
'.')) {
121 snprintf(buffer,
sizeof(buffer),
"%s/%s.lint", lintfiles, dn);
124 if(!fsys::isfile(dn))
126 lib = Script::merge(dn, lib);
127 ep = lib->getListing();
129 fprintf(stderr,
"%s:%d: warning: %s\n", lib->getFilename(), ep->errline, ep->errmsg);
134 Script *img = Script::compile(fn, lib);
137 fprintf(stderr,
"*** baylint: %s: failed to compile\n", fn);
141 unsigned errors = img->getErrors();
143 if(!String::equal(ext,
".ics") && !String::equal(ext,
".ocs") && !String::equal(ext,
".dcs")) {
144 fprintf(stderr,
"*** %s: not a valid script file name\n", fn);
149 fprintf(stderr,
"*** %d total errors in %s\n", errors, fn);
150 ep = img->getListing();
152 fprintf(stderr,
"%s:%d: error: %s\n", img->getFilename(), ep->errline, ep->errmsg);
#define BAYONNE_NAMESPACE
GNU Bayonne library namespace.