fix shadow warnings

master
Daniel Kolesa 2016-03-04 21:33:25 +00:00
parent 0862578d06
commit 3e539cf4a3
4 changed files with 30 additions and 30 deletions

View File

@ -1,4 +1,4 @@
OB_CXXFLAGS = -g -Wall -Wextra -O2 OB_CXXFLAGS = -g -Wall -Wextra -Wshadow -O2
CUBESCRIPT_PATH = ../libcubescript CUBESCRIPT_PATH = ../libcubescript
OCTASTD_PATH = ../octastd OCTASTD_PATH = ../octastd

View File

@ -149,8 +149,8 @@ static String ob_expand_globs(const Vector<String> &src) {
return ret; return ret;
} }
void cs_register_globs(cscript::CsState &cs) { void cs_register_globs(cscript::CsState &csv) {
cs.add_command("glob", "C", [](cscript::CsState &cs, ConstCharRange lst) { csv.add_command("glob", "C", [](cscript::CsState &cs, ConstCharRange lst) {
auto fnames = cscript::util::list_explode(lst); auto fnames = cscript::util::list_explode(lst);
cs.result->set_str(ob_expand_globs(fnames).disown()); cs.result->set_str(ob_expand_globs(fnames).disown());
}); });

52
main.cc
View File

@ -37,7 +37,7 @@ using cscript::Bytecode;
struct Task { struct Task {
ostd::Function<void()> cb; ostd::Function<void()> cb;
Task *next = nullptr; Task *next = nullptr;
Task(ostd::Function<void()> &&cb): cb(ostd::move(cb)) {} Task(ostd::Function<void()> &&cbf): cb(ostd::move(cbf)) {}
}; };
struct ThreadPool { struct ThreadPool {
@ -454,16 +454,16 @@ struct ObState: CsState {
}; };
int main(int argc, char **argv) { int main(int argc, char **argv) {
ObState os; ObState osv;
ConstCharRange pn = argv[0]; ConstCharRange pn = argv[0];
ConstCharRange lslash = ostd::find_last(pn, '/'); ConstCharRange lslash = ostd::find_last(pn, '/');
os.progname = lslash.empty() ? pn : (lslash + 1); osv.progname = lslash.empty() ? pn : (lslash + 1);
cscript::init_libs(os); cscript::init_libs(osv);
int ncpus = ostd::Thread::hardware_concurrency(); int ncpus = ostd::Thread::hardware_concurrency();
os.add_ident(cscript::ID_VAR, "numcpus", 4096, 1, &ncpus); osv.add_ident(cscript::ID_VAR, "numcpus", 4096, 1, &ncpus);
os.add_ident(cscript::ID_VAR, "numjobs", 4096, 1, &os.jobs); osv.add_ident(cscript::ID_VAR, "numjobs", 4096, 1, &osv.jobs);
ConstCharRange fcont; ConstCharRange fcont;
@ -471,16 +471,16 @@ int main(int argc, char **argv) {
for (int i = 1; i < argc; ++i) if (argv[i][0] == '-') { for (int i = 1; i < argc; ++i) if (argv[i][0] == '-') {
char argn = argv[i][1]; char argn = argv[i][1];
if (argn == 'E') { if (argn == 'E') {
os.ignore_env = true; osv.ignore_env = true;
continue; continue;
} else if ((argn == 'h') || (!argv[i][2] && ((i + 1) >= argc))) { } else if ((argn == 'h') || (!argv[i][2] && ((i + 1) >= argc))) {
return os.print_help(argn != 'h'); return osv.print_help(argn != 'h');
} }
ConstCharRange val = (argv[i][2] == '\0') ? argv[++i] : &argv[i][2]; ConstCharRange val = (argv[i][2] == '\0') ? argv[++i] : &argv[i][2];
switch (argn) { switch (argn) {
case 'C': case 'C':
if (!ostd::directory_change(val)) if (!ostd::directory_change(val))
return os.error(1, "failed changing directory: %s", val); return osv.error(1, "failed changing directory: %s", val);
break; break;
case 'f': case 'f':
deffile = val; deffile = val;
@ -491,22 +491,22 @@ int main(int argc, char **argv) {
case 'j': { case 'j': {
int ival = atoi(val.data()); int ival = atoi(val.data());
if (!ival) ival = ncpus; if (!ival) ival = ncpus;
os.jobs = ostd::max(1, ival); osv.jobs = ostd::max(1, ival);
break; break;
} }
default: default:
return os.print_help(true); return osv.print_help(true);
} }
} else { } else {
posarg = i; posarg = i;
break; break;
} }
tpool.init(os.jobs); tpool.init(osv.jobs);
os.register_rulecmds(); osv.register_rulecmds();
os.add_command("shell", "C", [](ObState &os, ConstCharRange s) { osv.add_command("shell", "C", [](ObState &os, ConstCharRange s) {
auto cnt = os.counters.back(); auto cnt = os.counters.back();
cnt->incr(); cnt->incr();
tpool.push([cnt, ds = String(s)]() { tpool.push([cnt, ds = String(s)]() {
@ -518,7 +518,7 @@ int main(int argc, char **argv) {
os.result->set_int(0); os.result->set_int(0);
}); });
os.add_commandn("getenv", "ss", [](ObState &os, TvalRange args) { osv.add_commandn("getenv", "ss", [](ObState &os, TvalRange args) {
if (os.ignore_env) { if (os.ignore_env) {
os.result->set_cstr(""); os.result->set_cstr("");
return; return;
@ -534,10 +534,10 @@ int main(int argc, char **argv) {
} }
}); });
os.add_command("extreplace", "sss", [](cscript::CsState &cs, osv.add_command("extreplace", "sss", [](cscript::CsState &cs,
const char *lst, const char *lst,
const char *oldext, const char *oldext,
const char *newext) { const char *newext) {
String ret; String ret;
if (oldext[0] == '.') ++oldext; if (oldext[0] == '.') ++oldext;
if (newext[0] == '.') ++newext; if (newext[0] == '.') ++newext;
@ -556,17 +556,17 @@ int main(int argc, char **argv) {
cs.result->set_str_dup(ret); cs.result->set_str_dup(ret);
}); });
os.add_command("invoke", "s", [](ObState &os, const char *name) { osv.add_command("invoke", "s", [](ObState &os, const char *name) {
os.result->set_int(os.exec_main(name)); os.result->set_int(os.exec_main(name));
}); });
cs_register_globs(os); cs_register_globs(osv);
if ((!fcont.empty() && !os.run_bool(fcont)) || !os.run_file(deffile)) if ((!fcont.empty() && !osv.run_bool(fcont)) || !osv.run_file(deffile))
return os.error(1, "failed creating rules"); return osv.error(1, "failed creating rules");
if (os.rules.empty()) if (osv.rules.empty())
return os.error(1, "no targets"); return osv.error(1, "no targets");
return os.exec_main((posarg < argc) ? argv[posarg] : "default"); return osv.exec_main((posarg < argc) ? argv[posarg] : "default");
} }

View File

@ -1,6 +1,6 @@
CXX = (getenv CXX c++) CXX = (getenv CXX c++)
OB_CXXFLAGS = "-g -Wall -Wextra -O2" OB_CXXFLAGS = "-g -Wall -Wextra -Wshadow -O2"
CS_PATH = "../libcubescript" CS_PATH = "../libcubescript"
OS_PATH = "../octastd" OS_PATH = "../octastd"