diff options
author | 2015-08-13 19:06:28 +0200 | |
---|---|---|
committer | 2015-08-13 21:35:32 +0200 | |
commit | 98b1106ee99be2aba9c6b540e7b25bc056bebed8 (patch) | |
tree | 1d0e17bae097c87ed30119e1acfcce30ed161cf4 | |
parent | 6e3fef765dc4849d8d63cf4cf9d1ba004d9461dd (diff) |
Make more use of pformat. (nw)
-rw-r--r-- | src/emu/netlist/nl_parser.c | 6 | ||||
-rw-r--r-- | src/emu/netlist/nl_parser.h | 2 | ||||
-rw-r--r-- | src/emu/netlist/plib/pparser.c | 29 | ||||
-rw-r--r-- | src/emu/netlist/plib/pparser.h | 4 | ||||
-rw-r--r-- | src/emu/netlist/plib/pstring.h | 8 | ||||
-rw-r--r-- | src/emu/netlist/tools/nl_convert.c | 2 | ||||
-rw-r--r-- | src/emu/netlist/tools/nl_convert.h | 2 |
7 files changed, 24 insertions, 29 deletions
diff --git a/src/emu/netlist/nl_parser.c b/src/emu/netlist/nl_parser.c index 2872648aa52..f77b97a2741 100644 --- a/src/emu/netlist/nl_parser.c +++ b/src/emu/netlist/nl_parser.c @@ -25,7 +25,7 @@ namespace netlist // A netlist parser // ---------------------------------------------------------------------------------------- -ATTR_COLD void parser_t::verror(pstring msg, int line_num, pstring line) +ATTR_COLD void parser_t::verror(const pstring &msg, int line_num, const pstring &line) { m_setup.netlist().error("line %d: error: %s\n\t\t%s\n", line_num, msg.cstr(), line.cstr()); @@ -297,7 +297,7 @@ void parser_t::net_c() if (n.is(m_tok_param_right)) break; if (!n.is(m_tok_comma)) - error("expected a comma, found <%s>", n.str().cstr()); + error(pformat("expected a comma, found <%1>")(n.str()) ); } } @@ -317,7 +317,7 @@ void parser_t::dippins() if (n.is(m_tok_param_right)) break; if (!n.is(m_tok_comma)) - error("expected a comma, found <%s>", n.str().cstr()); + error(pformat("expected a comma, found <%1>")(n.str()) ); } if ((pins.size() % 2) == 1) error("You must pass an equal number of pins to DIPPINS"); diff --git a/src/emu/netlist/nl_parser.h b/src/emu/netlist/nl_parser.h index 2a2086a0d72..73c6cf66837 100644 --- a/src/emu/netlist/nl_parser.h +++ b/src/emu/netlist/nl_parser.h @@ -42,7 +42,7 @@ namespace netlist /* for debugging messages */ netlist_t &netlist() { return m_setup.netlist(); } - virtual void verror(pstring msg, int line_num, pstring line); + virtual void verror(const pstring &msg, int line_num, const pstring &line); private: nl_double eval_param(const token_t tok); diff --git a/src/emu/netlist/plib/pparser.c b/src/emu/netlist/plib/pparser.c index 6355894bd56..7e05c8a29e0 100644 --- a/src/emu/netlist/plib/pparser.c +++ b/src/emu/netlist/plib/pparser.c @@ -75,7 +75,7 @@ void ptokenizer::require_token(const token_t tok, const token_id_t &token_num) { if (!tok.is(token_num)) { - error("Error: expected token <%s> got <%s>\n", m_tokens[token_num.id()].cstr(), tok.str().cstr()); + error(pformat("Expected token <%1> got <%2>")(m_tokens[token_num.id()])(tok.str()) ); } } @@ -84,7 +84,7 @@ pstring ptokenizer::get_string() token_t tok = get_token(); if (!tok.is_type(STRING)) { - error("Error: expected a string, got <%s>\n", tok.str().cstr()); + error(pformat("Expected a string, got <%1>")(tok.str()) ); } return tok.str(); } @@ -94,7 +94,7 @@ pstring ptokenizer::get_identifier() token_t tok = get_token(); if (!tok.is_type(IDENTIFIER)) { - error("Error: expected an identifier, got <%s>\n", tok.str().cstr()); + error(pformat("Expected an identifier, got <%1>")(tok.str()) ); } return tok.str(); } @@ -104,7 +104,7 @@ pstring ptokenizer::get_identifier_or_number() token_t tok = get_token(); if (!(tok.is_type(IDENTIFIER) || tok.is_type(NUMBER))) { - error("Error: expected an identifier, got <%s>\n", tok.str().cstr()); + error(pformat("Expected an identifier, got <%1>")(tok.str()) ); } return tok.str(); } @@ -114,12 +114,12 @@ double ptokenizer::get_number_double() token_t tok = get_token(); if (!tok.is_type(NUMBER)) { - error("Error: expected a number, got <%s>\n", tok.str().cstr()); + error(pformat("Expected a number, got <%1>")(tok.str()) ); } bool err = false; double ret = tok.str().as_double(&err); if (err) - error("Error: expected a number, got <%s>\n", tok.str().cstr()); + error(pformat("Expected a number, got <%1>")(tok.str()) ); return ret; } @@ -128,12 +128,12 @@ long ptokenizer::get_number_long() token_t tok = get_token(); if (!tok.is_type(NUMBER)) { - error("Error: expected a long int, got <%s>\n", tok.str().cstr()); + error(pformat("Expected a long int, got <%1>")(tok.str()) ); } bool err = false; long ret = tok.str().as_long(&err); if (err) - error("Error: expected a long int, got <%s>\n", tok.str().cstr()); + error(pformat("Expected a long int, got <%1>")(tok.str()) ); return ret; } @@ -252,16 +252,9 @@ ptokenizer::token_t ptokenizer::get_token_internal() } -ATTR_COLD void ptokenizer::error(const char *format, ...) +ATTR_COLD void ptokenizer::error(const pstring &errs) { - va_list ap; - va_start(ap, format); - - pstring errmsg1 = pstring(format).vprintf(ap); - va_end(ap); - - verror(errmsg1, currentline_no(), currentline_str()); - + verror("Error: " + errs, currentline_no(), currentline_str()); //throw error; } @@ -460,7 +453,7 @@ pstring ppreprocessor::process_line(const pstring &line) } } else - error(pformat("unknown directive on line %1: %2\n")(m_lineno)(line)); + error(pformat("unknown directive on line %1: %2")(m_lineno)(line)); } else { diff --git a/src/emu/netlist/plib/pparser.h b/src/emu/netlist/plib/pparser.h index 95356dae224..e425af17569 100644 --- a/src/emu/netlist/plib/pparser.h +++ b/src/emu/netlist/plib/pparser.h @@ -112,10 +112,10 @@ public: } token_t get_token_internal(); - void error(const char *format, ...) ATTR_PRINTF(2,3); + void error(const pstring &errs); protected: - virtual void verror(pstring msg, int line_num, pstring line) = 0; + virtual void verror(const pstring &msg, int line_num, const pstring &line) = 0; private: void skipeol(); diff --git a/src/emu/netlist/plib/pstring.h b/src/emu/netlist/plib/pstring.h index 074201deee3..3bebcb4cb3f 100644 --- a/src/emu/netlist/plib/pstring.h +++ b/src/emu/netlist/plib/pstring.h @@ -395,6 +395,10 @@ public: pformat &x (const INT64 x, const char *f = "") { return update(f, I64FMT "x", x); } pformat &x (const UINT64 x, const char *f = "") { return update(f, I64FMT "x", x); } + pformat &operator ()(const long x, const char *f = "") { return update(f, "ld", x); } + pformat &operator ()(const unsigned long x, const char *f = "") { return update(f, "lu", x); } + + pformat &operator ()(const INT32 x, const char *f = "") { return update(f, "d", x); } pformat &operator ()(const UINT32 x, const char *f = "") { return update(f, "u", x); } @@ -405,7 +409,7 @@ public: pformat &operator ()(const UINT16 x, const char *f = "") { return update(f, "hu", x); } #if !defined(__MINGW32__) && !defined(__MINGW64__) && !defined(EMSCRIPTEN) - pformat &operator ()(const std::size_t x, const char *f = "") { return update(f, SIZETFMT, x); } + //pformat &operator ()(const std::size_t x, const char *f = "") { return update(f, SIZETFMT, x); } #endif pformat &operator ()(const double x, const char *f = "") { return update(f, "g", x); } pformat & e(const double x, const char *f = "") { return update(f, "e", x); } @@ -422,8 +426,6 @@ private: char m_str[2048]; unsigned m_arg; }; -//const type_t vprintf(va_list args) const; -//static const type_t sprintf(const char *format, ...) ATTR_PRINTF(1,2); #endif /* _PSTRING_H_ */ diff --git a/src/emu/netlist/tools/nl_convert.c b/src/emu/netlist/tools/nl_convert.c index 191cc1a7c99..85490bab5b6 100644 --- a/src/emu/netlist/tools/nl_convert.c +++ b/src/emu/netlist/tools/nl_convert.c @@ -439,7 +439,7 @@ void nl_convert_eagle_t::convert(const pstring &contents) break; } default: - tok.error("// IGNORED %s\n", name.cstr()); + tok.error("// IGNORED " + name); } } diff --git a/src/emu/netlist/tools/nl_convert.h b/src/emu/netlist/tools/nl_convert.h index 650d23dcff6..5772f334d44 100644 --- a/src/emu/netlist/tools/nl_convert.h +++ b/src/emu/netlist/tools/nl_convert.h @@ -196,7 +196,7 @@ public: protected: - void verror(pstring msg, int line_num, pstring line) + void verror(const pstring &msg, int line_num, const pstring &line) { m_convert.out("%s (line %d): %s\n", msg.cstr(), line_num, line.cstr()); } |