From 13219be215a6bdfa65a0fc0e1ad15148d73eae35 Mon Sep 17 00:00:00 2001 From: "olafvdspek@gmail.com" Date: Tue, 13 Mar 2012 14:18:31 +0000 Subject: [PATCH] Refactor TemplateDictionary --- src/config.h.in | 3 +++ src/ctemplate/template_string.h.in | 2 +- src/template_dictionary.cc | 15 ++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/config.h.in b/src/config.h.in index c7ccabd..bc5c885 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -157,6 +157,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/src/ctemplate/template_string.h.in b/src/ctemplate/template_string.h.in index bd850f2..6fa999d 100644 --- a/src/ctemplate/template_string.h.in +++ b/src/ctemplate/template_string.h.in @@ -226,7 +226,7 @@ class @ac_windows_dllexport@ TemplateString { // This returns true if s is in the .text segment of the binary. // (Note this only checks .text of the main executable, not of -// shared libraries. So it may not be all that useful.) + // shared libraries. So it may not be all that useful.) // This requires the gnu linker (and probably elf), to define // _start and data_start. static bool InTextSegment(const char* s) { diff --git a/src/template_dictionary.cc b/src/template_dictionary.cc index f4d1402..93096a6 100644 --- a/src/template_dictionary.cc +++ b/src/template_dictionary.cc @@ -59,8 +59,6 @@ using std::map; using std::pair; using std::make_pair; -typedef long int64; // used with SetIntValue - _START_GOOGLE_NAMESPACE_ // Guards the initialization of the global dictionary. @@ -438,7 +436,7 @@ void TemplateDictionary::SetValueWithoutCopy(const TemplateString variable, } void TemplateDictionary::SetIntValue(const TemplateString variable, - int64 value) { + long value) { char buffer[64]; // big enough for any int int valuelen = snprintf(buffer, sizeof(buffer), "%ld", value); LazilyCreateDict(&variable_dict_); @@ -447,9 +445,9 @@ void TemplateDictionary::SetIntValue(const TemplateString variable, void TemplateDictionary::SetFormattedValue(const TemplateString variable, const char* format, ...) { - char *scratch, *buffer; + char* buffer; - scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes + char* scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes va_list ap; va_start(ap, format); const int buflen = StringAppendV(scratch, &buffer, format, ap); @@ -471,16 +469,15 @@ void TemplateDictionary::SetFormattedValue(const TemplateString variable, void TemplateDictionary::SetEscapedValue(TemplateString variable, TemplateString value, const TemplateModifier& escfn) { - string escaped_string(escfn(value.ptr_, value.length_)); - SetValue(variable, escaped_string); + SetValue(variable, string(escfn(value.data(), value.size()))); } void TemplateDictionary::SetEscapedFormattedValue(TemplateString variable, const TemplateModifier& escfn, const char* format, ...) { - char *scratch, *buffer; + char* buffer; - scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes + char* scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes va_list ap; va_start(ap, format); const int buflen = StringAppendV(scratch, &buffer, format, ap);