replace _S since it is used in msys ctype.h

This commit is contained in:
Kelvin Sherlock 2020-11-18 12:37:38 -05:00
parent 32495371de
commit 9430f99270
2 changed files with 47 additions and 47 deletions

View File

@ -30,9 +30,9 @@
struct { struct {
bool _S = false; bool S = false;
bool _g = false; bool g = false;
bool _n = false; bool n = false;
} flags; } flags;
@ -287,7 +287,7 @@ bool dump_obj(const char *name, int fd)
std::string name; std::string name;
if (flags._n) { if (flags.n) {
name = d.section_name(section) + "+" + d.to_x(offset, 4, '$'); name = d.section_name(section) + "+" + d.to_x(offset, 4, '$');
} else { } else {
name = d.location_name(section, offset); name = d.location_name(section, offset);
@ -549,7 +549,7 @@ bool dump_obj(const char *name, int fd)
unsigned f = 0; unsigned f = 0;
if (flags._S) f |= 0x01; if (flags.S) f |= 0x01;
d.back_matter(f); d.back_matter(f);
if (iter != data.end() || op != REC_END) errx(EX_DATAERR, "%s records ended early", name); if (iter != data.end() || op != REC_END) errx(EX_DATAERR, "%s records ended early", name);
@ -661,9 +661,9 @@ int main(int argc, char **argv) {
int c; int c;
while ((c = getopt(argc, argv, "Sgn")) != -1) { while ((c = getopt(argc, argv, "Sgn")) != -1) {
switch(c) { switch(c) {
case 'S': flags._S = true; break; case 'S': flags.S = true; break;
case 'g': flags._g = true; break; case 'g': flags.g = true; break;
case 'n': flags._n = true; break; case 'n': flags.n = true; break;
default: exit(EX_USAGE); break; default: exit(EX_USAGE); break;
} }
} }

View File

@ -40,18 +40,18 @@
struct { struct {
bool _v = false; bool v = false;
bool _C = false; bool C = false;
bool _X = false; bool X = false;
bool _S = false; bool S = false;
std::string _o; std::string o;
std::vector<std::string> _l; std::vector<std::string> l;
std::vector<std::string> _L; std::vector<std::string> L;
unsigned _errors = 0; unsigned errors = 0;
uint16_t _file_type; uint16_t file_type;
uint32_t _aux_type; uint32_t aux_type;
} flags; } flags;
@ -360,7 +360,7 @@ inline void expr_error(bool fatal, const expression &e, const char *msg) {
fatal = true; fatal = true;
} }
if (fatal) flags._errors++; if (fatal) flags.errors++;
} }
@ -532,7 +532,7 @@ void one_module(const std::vector<uint8_t> &data,
// convert local symbols to global. // convert local symbols to global.
for (auto &s : local_symbols) { for (auto &s : local_symbols) {
if (flags._v) { if (flags.v) {
const char *status = ""; const char *status = "";
if (s.type == S_UND) status = "extern"; if (s.type == S_UND) status = "extern";
else if (s.flags & SF_GBL) status = "public"; else if (s.flags & SF_GBL) status = "public";
@ -599,7 +599,7 @@ void one_module(const std::vector<uint8_t> &data,
// ok if symbols are identical.. // ok if symbols are identical..
if (ss.type != s.type || ss.flags != s.flags || ss.section != s.section || ss.offset != s.offset) { if (ss.type != s.type || ss.flags != s.flags || ss.section != s.section || ss.offset != s.offset) {
warnx("Duplicate label %s", s.name.c_str()); warnx("Duplicate label %s", s.name.c_str());
flags._errors++; flags.errors++;
} }
} }
} }
@ -1197,7 +1197,7 @@ void build_omf_segments() {
// add a stack segment at the end // add a stack segment at the end
if (flags._S) { if (flags.S) {
auto &s = sections[SECT_PAGE0]; auto &s = sections[SECT_PAGE0];
// create stack/dp segment. // create stack/dp segment.
@ -1319,7 +1319,7 @@ bool one_module(const std::string &name, int fd, std::set<std::string> *local_un
return false; return false;
} }
if (flags._v) { if (flags.v) {
printf("Processing %s:%s\n", name.c_str(), module_name.c_str()); printf("Processing %s:%s\n", name.c_str(), module_name.c_str());
} }
@ -1334,7 +1334,7 @@ bool one_module(const std::string &name, int fd, std::set<std::string> *local_un
bool one_file(const std::string &name) { bool one_file(const std::string &name) {
if (flags._v) printf("Processing %s\n", name.c_str()); if (flags.v) printf("Processing %s\n", name.c_str());
int fd = open(name.c_str(), O_RDONLY | O_BINARY); int fd = open(name.c_str(), O_RDONLY | O_BINARY);
if (fd < 0) { if (fd < 0) {
@ -1449,7 +1449,7 @@ bool one_lib(const std::string &path) {
if (errno == ENOENT) return false; if (errno == ENOENT) return false;
} }
if (flags._v) printf("Processing library %s\n", path.c_str()); if (flags.v) printf("Processing library %s\n", path.c_str());
if (fd < 0) { if (fd < 0) {
warn("Unable to open %s", path.c_str()); warn("Unable to open %s", path.c_str());
@ -1567,8 +1567,8 @@ void libraries() {
if (undefined_symbols.empty()) return; if (undefined_symbols.empty()) return;
for (auto &l : flags._l) { for (auto &l : flags.l) {
for (auto &L : flags._L) { for (auto &L : flags.L) {
//std::string path = L + "lib" + l; //std::string path = L + "lib" + l;
std::string path = L + l + ".lib"; std::string path = L + l + ".lib";
@ -1610,8 +1610,8 @@ bool parse_ft(const std::string &s) {
} }
if (at && ft) { if (at && ft) {
flags._file_type = *ft; flags.file_type = *ft;
flags._aux_type = *at; flags.aux_type = *at;
return true; return true;
} }
return false; return false;
@ -1637,11 +1637,11 @@ bool parse_ft(const std::string &s) {
return lhs + (rhs | 0x20) - 'a' + 10; return lhs + (rhs | 0x20) - 'a' + 10;
}; };
flags._file_type = std::accumulate(s.begin(), s.begin() + 2, 0, lambda); flags.file_type = std::accumulate(s.begin(), s.begin() + 2, 0, lambda);
flags._aux_type = 0; flags.aux_type = 0;
if (s.length() == 7) if (s.length() == 7)
flags._aux_type = std::accumulate(s.begin() + 3, s.end(), 0, lambda); flags.aux_type = std::accumulate(s.begin() + 3, s.end(), 0, lambda);
return true; return true;
} }
@ -1661,19 +1661,19 @@ int main(int argc, char **argv) {
int c; int c;
while ((c = getopt(argc, argv, "vCXL:l:o:t:")) != -1) { while ((c = getopt(argc, argv, "vCXL:l:o:t:")) != -1) {
switch(c) { switch(c) {
case 'v': flags._v = true; break; case 'v': flags.v = true; break;
case 'X': flags._X = true; break; case 'X': flags.X = true; break;
case 'C': flags._C = true; break; case 'C': flags.C = true; break;
case 'o': flags._o = optarg; break; case 'o': flags.o = optarg; break;
case 'l': { case 'l': {
if (*optarg) flags._l.emplace_back(optarg); if (*optarg) flags.l.emplace_back(optarg);
break; break;
} }
case 'L': { case 'L': {
std::string tmp(optarg); std::string tmp(optarg);
if (tmp.empty()) tmp = "."; if (tmp.empty()) tmp = ".";
if (tmp.back() != '/') tmp.push_back('/'); if (tmp.back() != '/') tmp.push_back('/');
flags._L.emplace_back(std::move(tmp)); flags.L.emplace_back(std::move(tmp));
break; break;
} }
case 'h': help(); break; case 'h': help(); break;
@ -1700,11 +1700,11 @@ int main(int argc, char **argv) {
init(); init();
for (int i = 0 ; i < argc; ++i) { for (int i = 0 ; i < argc; ++i) {
if (!one_file(argv[i])) flags._errors++; if (!one_file(argv[i])) flags.errors++;
} }
if (flags._v && !undefined_symbols.empty()) { if (flags.v && !undefined_symbols.empty()) {
printf("Undefined Symbols:\n"); printf("Undefined Symbols:\n");
for (const auto & s : undefined_symbols) { for (const auto & s : undefined_symbols) {
printf("%s\n", s.c_str()); printf("%s\n", s.c_str());
@ -1727,7 +1727,7 @@ int main(int argc, char **argv) {
simplify(); simplify();
if (flags._v) { if (flags.v) {
for (const auto &s : sections) { for (const auto &s : sections) {
//if (s.flags & SEC_REF_ONLY) continue; //if (s.flags & SEC_REF_ONLY) continue;
printf("section %3d %-20s $%04x $%04x\n", printf("section %3d %-20s $%04x $%04x\n",
@ -1738,7 +1738,7 @@ int main(int argc, char **argv) {
build_omf_segments(); build_omf_segments();
if (flags._v) { if (flags.v) {
for (const auto &s : omf_segments) { for (const auto &s : omf_segments) {
printf("segment %3d %-20s $%04x\n", printf("segment %3d %-20s $%04x\n",
s.segnum, s.segname.c_str(), (uint32_t)s.data.size()); s.segnum, s.segname.c_str(), (uint32_t)s.data.size());
@ -1754,15 +1754,15 @@ int main(int argc, char **argv) {
} }
} }
if (flags._o.empty()) flags._o = "out.omf"; if (flags.o.empty()) flags.o = "out.omf";
if (!flags._file_type) { if (!flags.file_type) {
flags._file_type = 0xb3; flags.file_type = 0xb3;
} }
void save_omf(const std::string &path, std::vector<omf::segment> &segments, bool compress, bool expressload); void save_omf(const std::string &path, std::vector<omf::segment> &segments, bool compress, bool expressload);
int set_file_type(const std::string &path, uint16_t file_type, uint32_t aux_type); int set_file_type(const std::string &path, uint16_t file_type, uint32_t aux_type);
save_omf(flags._o, omf_segments, !flags._C, !flags._X); save_omf(flags.o, omf_segments, !flags.C, !flags.X);
set_file_type(flags._o, flags._file_type, flags._aux_type); set_file_type(flags.o, flags.file_type, flags.aux_type);
} }