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)
{
static char buf[256];
char buf[256];
char c = peek_next_nonws(in);
READ_INTO(in, buf, 256, c,
READ_INTO(in, buf, 255, c,
std::isdigit(c) || c == '-' || c == '.' || c == ',');
value = buf;
}
void parse_commodity(std::istream& in, std::string& symbol)
{
static char buf[256];
char buf[256];
char c = peek_next_nonws(in);
if (c == '"') {
in.get(c);
READ_INTO(in, buf, 256, c, c != '"');
READ_INTO(in, buf, 255, c, c != '"');
if (c == '"')
in.get(c);
else
throw amount_error("Quoted commodity symbol lacks closing quote");
} 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 != '.');
}
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_TIME(cls, x) { \
char buf[256]; \
std::strftime(buf, 255, "%Y/%m/%d", std::localtime(&x)); \
char buf[16]; \
std::strftime(buf, 15, "%Y/%m/%d", std::localtime(&x)); \
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;
static char buf[1024];
char buf[1024];
char * q = buf;
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())
return (*i).second;
static char buf[256];
char buf[256];
std::string::size_type sep = name.find(':');
assert(sep < 256);
const char * first, * rest;
if (sep == std::string::npos) {
first = name.c_str();

View file

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

View file

@ -59,7 +59,6 @@ void quotes_by_script::operator()(commodity_t& commodity,
cache_dirty = true;
if (price && ! price_db.empty()) {
char buf[128];
strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&now));
ofstream database(price_db.c_str(), ios_base::out | ios_base::app);
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)
{
static char buf[256];
std::auto_ptr<value_expr_t> node;
char buf[256];
char c = peek_next_nonws(in);
if (std::isdigit(c)) {
READ_INTO(in, buf, 255, c, std::isdigit(c));