made several of the buffers used non-static

This commit is contained in:
John Wiegley 2004-09-26 23:48:31 -04:00
parent f32f698d7f
commit f8a62c444f
7 changed files with 21 additions and 20 deletions

View file

@ -671,27 +671,26 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt)
void parse_quantity(std::istream& in, std::string& value) void parse_quantity(std::istream& in, std::string& value)
{ {
static char buf[256]; char buf[256];
char c = peek_next_nonws(in); char c = peek_next_nonws(in);
READ_INTO(in, buf, 256, c, READ_INTO(in, buf, 255, c,
std::isdigit(c) || c == '-' || c == '.' || c == ','); std::isdigit(c) || c == '-' || c == '.' || c == ',');
value = buf; value = buf;
} }
void parse_commodity(std::istream& in, std::string& symbol) void parse_commodity(std::istream& in, std::string& symbol)
{ {
static char buf[256]; char buf[256];
char c = peek_next_nonws(in); char c = peek_next_nonws(in);
if (c == '"') { if (c == '"') {
in.get(c); in.get(c);
READ_INTO(in, buf, 256, c, c != '"'); READ_INTO(in, buf, 255, c, c != '"');
if (c == '"') if (c == '"')
in.get(c); in.get(c);
else else
throw amount_error("Quoted commodity symbol lacks closing quote"); throw amount_error("Quoted commodity symbol lacks closing quote");
} else { } else {
READ_INTO(in, buf, 256, c, ! std::isspace(c) && ! std::isdigit(c) && READ_INTO(in, buf, 255, c, ! std::isspace(c) && ! std::isdigit(c) &&
c != '-' && c != '.'); c != '-' && c != '.');
} }
symbol = buf; symbol = buf;

View file

@ -62,8 +62,8 @@ bool _debug_active(const char * const cls);
#define DEBUG_PRINT_(x) DEBUG_PRINT(_debug_cls, x) #define DEBUG_PRINT_(x) DEBUG_PRINT(_debug_cls, x)
#define DEBUG_PRINT_TIME(cls, x) { \ #define DEBUG_PRINT_TIME(cls, x) { \
char buf[256]; \ char buf[16]; \
std::strftime(buf, 255, "%Y/%m/%d", std::localtime(&x)); \ std::strftime(buf, 15, "%Y/%m/%d", std::localtime(&x)); \
DEBUG_PRINT(cls, #x << " is " << buf); \ DEBUG_PRINT(cls, #x << " is " << buf); \
} }

View file

@ -56,7 +56,7 @@ element_t * format_t::parse_elements(const std::string& fmt)
element_t * current = NULL; element_t * current = NULL;
static char buf[1024]; char buf[1024];
char * q = buf; char * q = buf;
for (const char * p = fmt.c_str(); *p; p++) { for (const char * p = fmt.c_str(); *p; p++) {

View file

@ -242,9 +242,11 @@ account_t * account_t::find_account(const std::string& name,
if (i != accounts.end()) if (i != accounts.end())
return (*i).second; return (*i).second;
static char buf[256]; char buf[256];
std::string::size_type sep = name.find(':'); std::string::size_type sep = name.find(':');
assert(sep < 256);
const char * first, * rest; const char * first, * rest;
if (sep == std::string::npos) { if (sep == std::string::npos) {
first = name.c_str(); first = name.c_str();

View file

@ -15,14 +15,15 @@ void add_option_handler(std::list<option_t>& options,
option_t opt; option_t opt;
static char buf[128]; char buf[128];
char * p = buf; char * p = buf;
for (const char * q = label.c_str(); *q; q++) for (const char * q = label.c_str();
*q && p - buf < 128;
q++)
if (*q == '_') if (*q == '_')
*p++ = '-'; *p++ = '-';
else else
*p++ = *q; *p++ = *q;
assert(p < buf + 127);
*p = '\0'; *p = '\0';
opt.long_opt = buf; opt.long_opt = buf;
@ -147,15 +148,16 @@ void process_environment(std::list<option_t>& options,
for (char ** p = envp; *p; p++) for (char ** p = envp; *p; p++)
if (std::strncmp(*p, tag_p, tag_len) == 0) { if (std::strncmp(*p, tag_p, tag_len) == 0) {
char * q; char buf[128];
static char buf[128];
char * r = buf; char * r = buf;
for (q = *p + tag_len; *q && *q != '='; q++) char * q;
for (q = *p + tag_len;
*q && *q != '=' && r - buf < 128;
q++)
if (*q == '_') if (*q == '_')
*r++ += '-'; *r++ += '-';
else else
*r++ += std::tolower(*q); *r++ += std::tolower(*q);
assert(r < buf + 127);
*r = '\0'; *r = '\0';
if (*q == '=') if (*q == '=')

View file

@ -59,7 +59,6 @@ void quotes_by_script::operator()(commodity_t& commodity,
cache_dirty = true; cache_dirty = true;
if (price && ! price_db.empty()) { if (price && ! price_db.empty()) {
char buf[128];
strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&now)); strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&now));
ofstream database(price_db.c_str(), ios_base::out | ios_base::app); ofstream database(price_db.c_str(), ios_base::out | ios_base::app);
database << "P " << buf << " " << commodity.symbol database << "P " << buf << " " << commodity.symbol

View file

@ -430,10 +430,9 @@ inline value_expr_t * parse_value_term(const char * p) {
value_expr_t * parse_value_term(std::istream& in) value_expr_t * parse_value_term(std::istream& in)
{ {
static char buf[256];
std::auto_ptr<value_expr_t> node; std::auto_ptr<value_expr_t> node;
char buf[256];
char c = peek_next_nonws(in); char c = peek_next_nonws(in);
if (std::isdigit(c)) { if (std::isdigit(c)) {
READ_INTO(in, buf, 255, c, std::isdigit(c)); READ_INTO(in, buf, 255, c, std::isdigit(c));