Changeset 1155


Ignore:
Timestamp:
Aug 9, 2010, 5:41:59 AM (9 years ago)
Author:
Peter Johansson
Message:

new config option: tab_size. fixes #229

Location:
trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Configuration.cc

    r1154 r1155  
    3131#include <algorithm>
    3232#include <cassert>
     33#include <cstdlib>
    3334#include <fstream>
    3435#include <map>
     
    216217          else {
    217218            throw Config_error(line, "");
     219          }
     220        }
     221        else if (lhs=="tab_size") {
     222          tab_size_ = strtoul(rhs.c_str(), NULL, 10);
     223          if (tab_size_==0) {
     224            throw Config_error(line,
     225                          "invalid value: tab_size must be a positive integer");
     226          }
     227          else if (tab_size_ == ULONG_MAX) {
     228            throw Config_error(line, "invalid value: out of range");
    218229          }
    219230        }
     
    482493    missing_copyright_warning_=false;
    483494    trac_root_ = "";
     495    tab_size_ = 2;
    484496
    485497    add_codon("*.ac", "#", "\n");
     
    561573
    562574
     575  size_t Configuration::tab_size(void) const
     576  {
     577    return tab_size_;
     578  }
     579
     580
    563581  std::string Configuration::trac_root(void) const
    564582  {
     
    602620    else
    603621      os << "no\n";
     622    os << "# svndigest uses this value to replace tabs "
     623       << "with spaces in blame output\n"
     624       << "tab_size = " << conf.tab_size() << "\n";
     625
    604626
    605627    os << "\n### Section for setting behaviour of copyright update\n"
  • trunk/lib/Configuration.h

    r1154 r1155  
    128128    const std::map<std::string, std::string>&
    129129    svn_properties(const std::string& filename) const;
     130
     131    /**
     132       \return size of a tab, i.e., how many spaces are ued to display
     133       a space (in blame output)
     134     */
     135    size_t tab_size(void) const;
    130136
    131137    ///
     
    209215    bool output_file_;
    210216    std::string trac_root_;
     217    size_t tab_size_;
    211218
    212219    typedef std::map<std::string, std::string> str_map;
  • trunk/lib/HtmlBuf.cc

    r992 r1155  
    2323#include "HtmlBuf.h"
    2424
     25#include "Configuration.h"
     26
    2527#include <cstdio>
    2628#include <iostream>
     
    4042    map_['&']=std::string("&amp;");
    4143    map_[' ']=std::string("&nbsp;");
    42     // This should be configurable, but for now indentation is two spaces.
    43     map_['\t']=std::string("&nbsp;&nbsp;");
     44    std::string str;
     45    for (size_t i=0; i<Configuration::instance().tab_size(); ++i)
     46      str += "&nbsp;";
     47    map_['\t']=str;
    4448  }
    4549
Note: See TracChangeset for help on using the changeset viewer.