Hunter的大杂烩 技术学习笔记

2007-12-14

google template build under g++ 2.95

Filed under: C++,Linux — hunter @ 2:49 pm

几个小patch,用来解决在2.95下编译ctemplate的问题 

1. template_dictionary.cc

 line 306

  // modify by hunter: slk8 dosn’t have va_copy function
#if 0
  va_list backup_ap;
  va_copy(backup_ap, ap);
  int result = vsnprintf(space, sizeof(space), format, backup_ap);
  va_end(backup_ap);
#else
  int result = vsnprintf(space, sizeof(space), format, ap);
#endif
 line 332

  // modify by hunter: slk8 dosn’t have va_copy function
#if 0
    // Restore the va_list before we use it again
    va_copy(backup_ap, ap);
    result = vsnprintf(buf, length, format, backup_ap);
    va_end(backup_ap);
#else
    result = vsnprintf(buf, length, format, ap);
#endif
2. template_modifiers.cc

line 271

  for (const char* next_amp = (const char*)(memchr(in, ‘&’, inlen));
       next_amp; next_amp = (const char*)(memchr(pos, ‘&’, end-pos))) {
line 359

    char tmp = (char)arg[1];
    switch (tmp) {
      case ‘s’:{
        return snippet_escape.Modify(in, inlen, per_expand_data, out, “”);
      }
      case ‘p’:{
        return pre_escape.Modify(in, inlen, per_expand_data, out, “”);
      }
      case ‘a’:{
        return cleanse_attribute.Modify(in, inlen, per_expand_data, out, “”);
      }
      case ‘u’:{
        return validate_url_and_html_escape.Modify(in, inlen,
                                                   per_expand_data, out, “”);
     }
line 388

      case ‘j’:{
        return validate_url_and_javascript_escape.Modify(in, inlen,
                                                         per_expand_data,
                                                         out, “”);
     }
      case ‘h’:{
        return validate_url_and_html_escape.Modify(in, inlen,
                                                   per_expand_data,
                                                   out, “”);
     }  
3. template_dictionary.h.in

 line 243

  // begin: change by hunter: move this function from private to public
  // The dictionary types
  inline static int TemplateStringCmp(const TemplateString& a,
                                      const TemplateString& b) {
    if (a.length_ == b.length_)
      return memcmp(a.ptr_, b.ptr_, a.length_);
    else if (a.length_ < b.length_)   // when a is shorter, 0 means <       return memcmp(a.ptr_, b.ptr_, a.length_) <= 0 ? -1 : 1;     else                              // when a is longer, 0 means >
      return memcmp(a.ptr_, b.ptr_, b.length_) < 0 ? -1 : 1;   }   // change by hunter: move this function from private to public   // Normally we'd put this code directly in TemplateStringHash, below, but   // TemplateString friendship rules require the code to be at this level.   inline static size_t HashTemplateString(const TemplateString& s) {     // This is a terrible hash-function     unsigned long r = 0;     for (size_t i = 0; i < s.length_; i++)       r = 5 * r + s.ptr_[i];     return static_cast(r);   }   // end change; 注释掉private:中相应的这两个函数  

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress