Ignore:
Timestamp:
Jun 13, 2010, 7:28:19 PM (13 years ago)
Author:
Peter Johansson
Message:

merge trunk to src-highlight

Location:
branches/src-highlight
Files:
11 deleted
115 edited
41 copied

Legend:

Unmodified
Added
Removed
  • branches/src-highlight

  • branches/src-highlight/.svndigest/config

    r758 r1100  
    1414jari = Jari Häkkinen
    1515peter = Peter Johansson
     16
     17### Section for images
     18[image]
     19format = png
     20anchor_format = png
     21
     22### Section for author color in plots and blame output.
     23[author-color]
     24# jdoe = 000000
     25jari = 0000aa
     26peter = aa0000
    1627
    1728### Section for setting trac environment
     
    4354*.ac = "#":"\n"  ;  "dnl":"\n"
    4455*.am = "#":"\n"
    45 *.m4 = "#":"\n"  ;  "dnl":"\n"
     56*.as = "#":"\n"  ;  "dnl":"\n"
     57*.bat = "\nREM":"\n"  ;  "\nrem":"\n"
    4658*.c = "//":"\n"  ;  "/*":"*/"
    4759*.cc = "//":"\n"  ;  "/*":"*/"
    4860*.cpp = "//":"\n"  ;  "/*":"*/"
     61*.css = "<!--":"-->"
    4962*.cxx = "//":"\n"  ;  "/*":"*/"
    5063*.h = "//":"\n"  ;  "/*":"*/"
    5164*.hh = "//":"\n"  ;  "/*":"*/"
    5265*.hpp = "//":"\n"  ;  "/*":"*/"
     66*.html = "<%--":"--%>"
    5367*.java = "//":"\n"  ;  "/*":"*/"
     68*.jsp = "<!--":"-->"
     69*.m = "%":"\n"
     70*.m4 = "#":"\n"  ;  "dnl":"\n"
    5471*.pl = "#":"\n"
    5572*.pm = "#":"\n"
     73*.R = "#":"\n"
     74*.rss = "<!--":"-->"
     75*.sgml = "<!--":"-->"
    5676*.sh = "#":"\n"
     77*.shtml = "<!--":"-->"
     78*.tex = "%":"\n"
     79*.xhtml = "<!--":"-->"
     80*.xml = "<!--":"-->"
     81*.xsd = "<!--":"-->"
     82*.xsl = "<!--":"-->"
    5783*config = "#":"\n"
    5884bootstrap = "#":"\n"
    5985Makefile = "#":"\n"
    60 *.tex = "%":"\n"
    61 *.m = "%":"\n"
    62 *.jsp = "<!--":"-->"
    63 *.html = "<%--":"--%>"
    64 *.xml = "<!--":"-->"  ;  "<!--":"-->"
    65 *.xsl = "<!--":"-->"
    66 *.xsd = "<!--":"-->"
    67 *.xhtml = "<!--":"-->"
    68 *.shtml = "<!--":"-->"
    69 *.css = "<!--":"-->"
    70 *.rss = "<!--":"-->"
    71 *.sgml = "<!--":"-->"
    72 *.bat = "\nREM":"\n"  ;  "\nrem":"\n"
  • branches/src-highlight/AUTHORS

    r768 r1100  
    11$Id$
    22
    3 Copyright (C) 2005, 2006, 2008 Jari Häkkinen
    4 Copyright (C) 2007, 2008 Peter Johansson
     3Copyright (C) 2005, 2006 Jari Häkkinen
     4Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5Copyright (C) 2009 Peter Johansson
    56
    67Files are copyright by their respective authors. The contributions to
  • branches/src-highlight/ChangeLog

    r811 r1100  
    2626{{{
    2727Copyright (C) 2005, 2006 Jari Häkkinen
    28 Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    29 Copyright (C) 2008, 2009 Peter Johansson
     28Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     29Copyright (C) 2009 Peter Johansson
    3030
    3131This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/Makefile.am

    r821 r1100  
    44
    55# Copyright (C) 2005, 2006 Jari Häkkinen
    6 # Copyright (C) 2007, 2008 Peter Johansson
     6# Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     7# Copyright (C) 2009, 2010 Peter Johansson
    78#
    89# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2627SUBDIRS = lib bin man test
    2728
    28 EXTRA_dist = build_support/move-if-change
     29EXTRA_DIST = build_support/move-if-change .release_year
     30MOVE_IF_CHANGE = $(SHELL) $(top_srcdir)/build_support/move-if-change
     31
     32lazycheck recheck: all
     33  cd test && $(MAKE) $(AM_MAKEFLAGS) $@
    2934
    3035clean-local:
    3136  rm -rf svndigest *~
    3237
    33 if ENABLE_SVN_SUPPORT
    34 include build_support/svn_support.am
    35 else
    36 release:
    37   @echo "ERROR: target 'release' not activated."
    38   @echo "       You need to run configure with '--enable-svn-support'."
    39   @exit 1
     38.PHONY: .release_year.tmp recheck
     39if HAVE_SVN_WC
     40# update copyright year automatically (if we build from svn wc)
     41$(srcdir)/.release_year: $(builddir)/.release_year.tmp
     42  @$(MOVE_IF_CHANGE) $(builddir)/.release_year.tmp $@
     43
     44$(builddir)/.release_year.tmp:
     45  @if ($(SVNVERSION) $(top_srcdir) | $(GREP) M > /dev/null); then \
     46     date -u "+%Y" > $@; \
     47  else \
     48     cp $(srcdir)/.release_year $@; \
     49  fi
    4050endif
    4151
    4252
    43 # This is a workaround to avoid a broken make when .m4 files are
    44 # renamed or deleted. Something similar will be provided by Automake 1.11
    45 $(am__aclocal_m4_deps):
     53##############################################################
     54##
     55## Some rules useful for maintainer
     56##
     57
     58include $(srcdir)/maintainer.am
     59
     60# called within maintainer-check
     61## We do wanna run all tests here since test repository is not
     62## included in tarball, and thus some tests are skiped in distcheck.
     63MAINTAINER_CHECK_LOCAL = check
     64# extra check in release rule
     65RELEASE_LOCAL = check-svn_revision
     66
     67.PHONY: check-svn_revision
     68
     69check-svn_revision:
     70  @$(SVNVERSION) | $(EGREP) '^[0-9]+$$' || \
     71  { echo incorrect svn revision - expected single unmodified revision 1>&2; \
     72    exit 1; }
  • branches/src-highlight/NEWS

    r768 r1100  
    33See the end of this file for copyrights and conditions.
    44
    5 Version 0.7 (released DATE)
     5Version 0.8 (released NOT YET)
     6  - Gnuplot replaced with plplot (ticket:97)
     7  - option --copyright deprecated; use new program snvcopyright (ticket #307)
     8  - new option --format (ticket:438)
     9  - new option --anchor-format (ticket:279)
     10  - new section, `[image]`, in config file (ticket:279 and ticket:405)
     11  - new configure option --with-plplot
     12  - new default codon for `*.as` in config file
     13  - new default codon for `*.R` in config file (ticket:432)
     14  - image format is configurable, refer to Manual (ticket:405)
     15
     16  A complete list of closed tickets can be found here [[br]]
     17  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=0.8
     18
     19svndigest 0.7.x series from
     20    http://dev.thep.lu.se/svndigest/svn/branches/0.7-stable
     21
     22Version 0.7.4 (released 8 June 2010)
     23  - fixed memory bug in StatsCollection (r1075)
     24
     25  A complete list of closed tickets can be found here [[br]]
     26  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=0.7.4
     27
     28Version 0.7.3 (released 15 February 2010)
     29  - Fixed bug that authors were excluded in BlameStats plot (bug #441)
     30
     31  A complete list of closed tickets can be found here [[br]]
     32  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=0.7.3
     33
     34Version 0.7.2 (released 2 January 2010)
     35  - Author included in plot unless count is 0 for all revisions (bug #434)
     36  - Default codons in config file is now corrected. Old cache files
     37    are obsolete and are ignored by svndigest 0.7.2 (bug #431)
     38
     39  A complete list of closed tickets can be found here [[br]]
     40  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=0.7.2
     41
     42Version 0.7.1 (released 3 December 2009)
     43  - File name in parsing rules are matched against the file name and
     44    not the entire path. This has no influence on most files because
     45    the name starts with a wild card (*) but for files not doing so
     46    (default bootstrap and Makefile) the correct parsing rule will be
     47    used. It is recommended to remove the cache of such files before
     48    running svndigest (ticket:417).
     49  - copyright update works on mixed revision wc (ticket:415)
     50
     51  A complete list of closed tickets can be found here [[br]]
     52  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=0.7.1
     53
     54Version 0.7 (released 22 November 2009)
    655  - Upgraded to GLPv3 (ticket:339)
    756  - configure option --enable-staticbin is removed (ticket:340)
    857  - configure option --enable-wctests is removed (ticket:295)
     58  - configure option --enable-svn-support is removed
    959  - parsing rules can be set in config file (ticket:283)
     60  - Statistics is now cached (ticket:5)
     61  - More statistics: StatsType Blame (ticket:24) and StatsType Add (ticket:82)
    1062
    1163  A complete list of closed tickets can be found here [[br]]
    1264  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=0.7
    1365
     66version 0.6.8 (released 12 November 2009)
     67  - configure now handles --disable correctly (issue #383)
     68
     69  A complete list of closed tickets can be found here [[br]]
     70  http://dev.thep.lu.se/svndigest/query?status=closed&milestone=svndigest+0.6.8
     71
    1472version 0.6.7 (released 1 February 2009)
    1573  - Improved TracLinks (issue #353)
    16   - Daylight saving time is now handled correctly (issue #353)
     74  - Daylight saving time is now handled correctly (issue #356)
    1775
    1876  A complete list of closed tickets can be found here [[br]]
     
    101159{{{
    102160Copyright (C) 2005, 2006 Jari Häkkinen
    103 Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    104 Copyright (C) 2008, 2009 Peter Johansson
     161Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     162Copyright (C) 2010 Peter Johansson
    105163
    106164This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/README

    r806 r1100  
    4343   consequence, the dependency is inherited by svndigest.
    4444
    45  * Gnuplot.
     45 * PLplot, http://plplot.sourceforge.net, is used to generate graphics
     46   in the output. You can build svndigest without PLplot if you run
     47   configure with `--without-plplot`.
     48
     49 * pkg-config utility, http://pkg-config.freedesktop.org, is used to
     50   query information about PLplot headers and libs. It is possible to
     51   configure and build without pkg-config, but we recommend that you
     52   have pkg-config available because it makes detection of PLplot much
     53   more automatic and convenient.
    4654
    4755 * A standard C++ compliant compiler with one extension: svndigest
     
    5462   flag to suppress 'long long' diagnostics, -Wno-long-long.
    5563
     64=== Optional ===
     65
     66 * src-highlite available from http://www.gnu.org/software/src-highlite
    5667
    5768== Installing svndigest ==
     
    7182
    7283The `./configure` script accepts a few options of interest for
    73 svndigest. You can provide `./configure` with APR and subversion API
    74 location information with `--with-apr=DIR` and `--with-svn=DIR`,
    75 respectively.
     84svndigest. You can provide `./configure` with APR, subversion, and
     85PLplot API location information with `--with-apr=DIR`,
     86`--with-svn=DIR`, and `--with-plplot=DIR, respectively.
    7687
    7788If you grabbed the source from the subversion repository you need to
     
    114125{{{
    115126Copyright (C) 2005, 2006 Jari Häkkinen
    116 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    117 Copyright (C) 2009 Peter Johansson
     127Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
    118128
    119129This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/README.developer

    r839 r1100  
    2424
    2525To build from a subversion checkout, you will need Autotools. More
    26 specifically Automake 1.10 (or later) and Autoconf 2.61 (or later). To
     26specifically Automake 1.10 (or later) and Autoconf 2.63 (or later). To
    2727build man page you will need help2man.
    2828
     
    5454Test programs should be created and added to the `make check`
    5555execution. Always check that the test runs before committing code to
    56 the repository, i.e., run `make check`.
     56the repository, i.e., run `make check`. For more details on how to run
     57and write tests, please refer to file `test/README`.
    5758
    5859There is a test repository in source:trunk/test/repo that is a part of
     
    116117shared between authors.
    117118
     119== Design and Motivation ==
     120
     121Please refer to source:trunk/doc/HACKING for a list of design
     122decisions we try to follow.
    118123
    119124== Releasing ==
     
    125130{{{
    126131Copyright (C) 2005, 2006 Jari Häkkinen
    127 Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    128 Copyright (C) 2008 Peter Johansson
     132Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     133Copyright (C) 2009 Peter Johansson
    129134
    130135This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/THANKS

    r799 r1100  
    11$Id$
    2 
    3 svndigest uses a C++ interface to Gnuplot inspired by Rajarshi Guha.
    4 
    5 Rajarshi Guha's "A C++ Interface to Gnuplot" can be found through
    6 http://jijo.cjb.net/ . The C++ interface is based on "gnuplot
    7 interfaces in ANSI C" written by Nicolas Devillard. The C
    8 implementation is available through http://ndevilla.free.fr/ .
    92
    103svndigest build system uses an M4 macro (m4/find_apr.m4) created
     
    2619
    2720svndigest build system uses a shell script
    28 (build_support/move-if-changed) that was copied from GCC. The script
     21(build_support/move-if-change) that was copied from GCC. The script
    2922is licensed under GNU GPL <http://www.gnu.org/licenses/>.
    3023
     
    3225{{{
    3326Copyright (C) 2005, 2006 Jari Häkkinen
    34 Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    35 Copyright (C) 2008 Peter Johansson
     27Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     28Copyright (C) 2009, 2010 Peter Johansson
    3629
    3730This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/bin/Makefile.am

    r795 r1100  
    44
    55# Copyright (C) 2005 Jari Häkkinen
    6 # Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    7 # Copyright (C) 2007, 2008 Peter Johansson
    8 # Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     6# Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     7# Copyright (C) 2010 Peter Johansson
    98#
    109# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2322# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2423
    25 bin_PROGRAMS = svndigest
     24bin_PROGRAMS = svndigest svncopyright
    2625
    27 svndigest_SOURCES = Parameter.cc svndigest.cc
     26svndigest_SOURCES = Parameter.cc svndigestParameter.cc svndigest.cc
     27svncopyright_SOURCES = Parameter.cc svncopyrightParameter.cc svncopyright.cc
    2828
    29 noinst_HEADERS = Parameter.h
     29noinst_HEADERS = Parameter.h svncopyrightParameter.h svndigestParameter.h
     30
     31bin_SCRIPTS = svndigest-copy-cache
     32EXTRA_DIST = svndigest-copy-cache.as
    3033
    3134LDADD = $(top_builddir)/lib/libsvndigest.a \
    32   $(top_builddir)/lib/yat/libyat.a $(SVNDIGEST_LIBS)
    33 AM_LDFLAGS = $(SVNDIGEST_LDFLAGS)
     35  $(top_builddir)/lib/yat/libyat.a $(SVN_LIBS) $(APR_LIBS) $(PLPLOT_LIBS)
     36AM_LDFLAGS = $(APR_LDFLAGS) $(SVN_LDFLAGS) $(PLPLOT_LDFLAGS)
    3437
    35 AM_CPPFLAGS = -I$(top_srcdir)/lib $(SVNDIGEST_CPPFLAGS)
    36 AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     38AM_CPPFLAGS  = -I$(top_srcdir)/lib $(DEFAULT_CPPFLAGS) \
     39  $(APR_CPPFLAGS) $(SVN_CPPFLAGS) $(PLPLOT_CPPFLAGS)
     40AM_CXXFLAGS = $(DEFAULT_CXXFLAGS)
    3741
     42##svndigest_LDADD = $(LDADD) $(PLPLOT_LIBS)
     43##svndigest_LDFLAGS = $(AM_LDFLAGS) $(PLPLOT_LDFLAGS)
     44##svndigest_CPPFLAGS  = $(AM_CPPFLAGS) $(PLPLOT_CPPFLAGS)
     45
     46.as.in:
     47  $(AUTOM4TE) -l M4sh -o $@ $(M4SH_OPTIONS) $<
     48
     49MAINTAINERCLEANFILES = svndigest-copy-cache.in
    3850
    3951clean-local:
  • branches/src-highlight/bin/Parameter.cc

    r830 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    1920  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2021*/
     22
     23#include <config.h> // this header file is created by configure
    2124
    2225#include "Parameter.h"
     
    3033#include "yat/OptionHelp.h"
    3134#include "yat/OptionSwitch.h"
    32 
    33 #include <config.h> // this header file is created by configure
    3435
    3536#include <cassert>
     
    4445#include <sys/stat.h>
    4546
    46 // FIXME: remove this when we require autoconf 2.64
    47 // autoconf 2.64 defines PACKAGE_URL in config.h (from AC_INIT)
    48 #ifndef PACKAGE_URL
    49 #define PACKAGE_URL "http://dev.thep.lu.se/svndigest"
    50 #endif
    51 
    5247namespace theplu {
    5348namespace svndigest {
    5449
    55   Parameter::Parameter( int argc, char *argv[])
     50  Parameter::Parameter(void)
    5651    : cmd_( std::string("Mandatory arguments to long options ") +
    5752            std::string("are mandatory for short options too.")),
    5853      config_file_(cmd_, "config-file",
    5954                   "configuration file [<ROOT>/.svndigest/config]"),
    60       copyright_(cmd_, "copyright", "update copyright statement"),
    61       force_(cmd_, "f,force",
    62              std::string("if sub-directory named <ROOT> exists in target dire")+
    63              std::string("ctory, remove sub-directory before writing results")),
    6455      generate_config_(cmd_, "g,generate-config",
    6556                       "write configuration to standard output"),
     
    6859                    std::string("ignore cache files and analyze ") +
    6960                    std::string("everything from repository")),
    70       report_(cmd_, "report", "create no HTML report", true),
    71       revisions_(cmd_, "revisions",
    72                  "use revision number as time scale instead of dates [dates]"),
    7361      root_(cmd_, "r,root",
    7462            "svn controlled directory to perform statistics on [.]"),
    75       target_(cmd_, "t,target", "output directory [.]"),
    7663      verbose_(cmd_, "v,verbose", "explain what is being done"),
    7764      version_(cmd_, "version", "print version information and exit", &verbose_)
     65  {
     66  }
     67
     68  void Parameter::parse(int argc, char* argv[])
    7869  {
    7970    init();
     
    8677    }
    8778
    88     // set default values
    89     if (!root_.present())
    90       root_.value(".");
    91 
    92     if (!target_.present())
    93       target_.value(".");
    94 
    95     if (!config_file_.present())
    96       config_file_.value(concatenate_path(root_.value(),".svndigest/config"));
     79    set_default();
    9780
    9881    // analyse arguments
     
    11497      check_existence(root_.value());
    11598      check_readable(root_.value());
    116       if (chdir(root_.value().c_str())) {
    117         std::stringstream ss;
    118         ss << "svndigest: cannot read `" << root_.value() << "': "
    119            << strerror(errno);
    120         throw yat::utility::cmd_error(ss.str());
    121       }
     99      chdir(root_.value());
    122100      root_.value(pwd());
    123       chdir(save_wd.c_str());
    124 
    125       // check target (only if we write report)
    126       if (report()) {
    127         check_existence(target_.value());
    128         check_readable(target_.value());
    129         std::string base_root = file_name(root_.value());
    130         std::string path = concatenate_path(target_.value(),base_root);
    131         if (access_rights(target_.value().c_str(), "w")) {
    132           std::stringstream ss;
    133           ss << "svndigest: cannot create directory `" << path
    134              << "': " << strerror(errno);
    135           throw yat::utility::cmd_error(ss.str());
    136         }
    137         if (node_exist(path) && !force()) {
    138           std::stringstream ss;
    139           ss << "svndigest: cannot create directory `" << path << "' "
    140              << strerror(EEXIST);
    141           throw yat::utility::cmd_error(ss.str());
    142         }
    143         if (chdir(target_.value().c_str())) {
    144           std::stringstream ss;
    145           ss << "svndigest: cannot read `" << target_.value() << "': "
    146              << strerror(errno);
    147           throw yat::utility::cmd_error(ss.str());
    148         }
    149         target_.value(pwd());
    150         chdir(save_wd.c_str());
    151       }
     101      chdir(save_wd);
    152102    }
    153103
     
    164114      check_readable(config_file_.value());
    165115      stat(config_file_.value().c_str(), &nodestat);
    166       if (!S_ISREG(nodestat.st_mode)) {
     116      if (S_ISDIR(nodestat.st_mode)) {
    167117        std::stringstream ss;
    168         ss << "svndigest: `" << config_file_.value()
    169            << "' is not a regular file";
     118        ss << cmd_.program_name() << ": `" << config_file_.value()
     119           << "' is a directory";
    170120        throw yat::utility::cmd_error(ss.str());
    171121      }
    172122    }
     123    analyse2();
    173124  }
    174125
     
    179130      return;
    180131    std::stringstream ss;
    181     ss << "svndigest: cannot stat `" << path << "': " << strerror(errno);
     132    ss << cmd_.program_name() << ": cannot stat `" << path << "': "
     133       << strerror(errno);
    182134    throw yat::utility::cmd_error(ss.str());
    183135  }
     
    189141      return;
    190142    std::stringstream ss;
    191     ss << "svndigest: cannot open `" << path << "': " << strerror(errno);
     143    ss << cmd_.program_name() << ": cannot open `" << path << "': "
     144       << strerror(errno);
    192145    throw yat::utility::cmd_error(ss.str());
    193146  }
     
    200153
    201154
    202   bool Parameter::copyright(void) const
    203   {
    204     return copyright_.present();
    205   }
    206 
    207 
    208   bool Parameter::force(void) const
    209   {
    210     return force_.present();
    211   }
    212 
    213 
    214155  bool Parameter::generate_config(void) const
    215156  {
     
    226167  void Parameter::init(void)
    227168  {
    228     // don't use argv[0] because user may rename the binary
    229     cmd_.program_name() = PACKAGE_NAME;
     169    // we like the options sorted alphabetically
     170    cmd_.sort();
    230171    config_file_.print_arg("=FILE");
    231172    root_.print_arg("=ROOT");
    232     target_.print_arg("=TARGET");
    233173    std::stringstream ss;
    234174    ss << "Report bugs to " << PACKAGE_BUGREPORT << ".\n"
    235175       << PACKAGE << " home page: <" << PACKAGE_URL << ">.\n";
    236176    help_.post_arguments() = ss.str();
    237     help_.synopsis() =
    238       "Generate statistical report for a subversion repository\n";
    239   }
    240 
    241 
    242   bool Parameter::report(void) const
    243   {
    244     return report_.value();
    245   }
    246 
    247 
    248   bool Parameter::revisions(void) const
    249   {
    250     return revisions_.present();
     177    init2();
    251178  }
    252179
     
    257184  }
    258185
    259  
    260   std::string Parameter::targetdir(void) const
    261   {
    262     return target_.value();
    263   }
    264 
    265  
     186  void Parameter::set_default(void)
     187  {
     188    if (!root_.present())
     189      root_.value(".");
     190
     191    if (!config_file_.present())
     192      config_file_.value(concatenate_path(root_.value(),".svndigest/config"));
     193
     194    set_default2();
     195  }
     196
     197
    266198  bool Parameter::verbose(void) const
    267199  {
  • branches/src-highlight/bin/Parameter.h

    r820 r1100  
    55
    66/*
    7   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4747  class Parameter {
    4848  public:
    49     Parameter( int argc, char *argv[]);
     49    Parameter(void);
    5050    virtual ~Parameter(void);
     51    void parse( int argc, char *argv[]);
     52
    5153    std::string config_file(void) const;
    5254   
    53     bool copyright(void) const;
    54     bool force(void) const;
    5555    bool generate_config(void) const ;
    5656    bool ignore_cache(void) const;
    57     bool report(void) const;
    58     bool revisions(void) const;
    5957    /// @return absolute path to root directory
    6058    std::string root(void) const;
    61     /// @return absolute path to target directory
    62     std::string targetdir(void) const;
    6359    bool verbose(void) const;
    6460
    65   private:
    66     void analyse(void);
     61  protected:
     62    yat::utility::CommandLine cmd_;
     63    yat::utility::OptionHelp help_;
     64
    6765    // throw cmd_error if path doesn't exist
    6866    void check_existence(std::string path) const;
     
    7270    void check_readable(std::string path) const;
    7371
     72  private:
     73    void analyse(void);
     74    virtual void analyse2(void)=0;
    7475    void init(void);
     76    // called at end of init(void)
     77    virtual void init2(void) = 0;
     78    void set_default(void);
     79    virtual void set_default2(void)=0;
    7580
    76     yat::utility::CommandLine cmd_;
    7781    yat::utility::OptionArg<std::string> config_file_;
    78     yat::utility::OptionSwitch copyright_;
    79     yat::utility::OptionSwitch force_;
    8082    yat::utility::OptionSwitch generate_config_;
    81     yat::utility::OptionHelp help_;
    8283    yat::utility::OptionSwitch ignore_cache_;
    83     yat::utility::OptionSwitch report_;
    84     yat::utility::OptionSwitch revisions_;
    8584    yat::utility::OptionArg<std::string> root_;
    86     yat::utility::OptionArg<std::string> target_;
    8785    yat::utility::OptionSwitch verbose_;
     86  protected:
    8887    OptionVersion version_;
    8988
  • branches/src-highlight/bin/svndigest.cc

    r808 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2010 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2121*/
    2222
    23 #include "Parameter.h"
     23#include "svndigestParameter.h"
    2424
    2525#include "Configuration.h"
     
    2727#include "Directory.h"
    2828#include "first_page.h"
    29 #include "GnuplotFE.h"
     29#include "Graph.h"
    3030#include "html_utility.h"
     31#include "main_utility.h"
    3132#include "rmdirhier.h"
    3233#include "Stats.h"
     
    3839
    3940#include "yat/Exception.h"
     41#include "yat/OptionArg.h"
    4042
    4143#include <cassert>
     44#include <cstdlib>
    4245#include <iostream>
    4346#include <fstream>
     
    4750#include <unistd.h>
    4851
     52using namespace theplu;
     53using namespace svndigest;
     54void copy_option2config(const svndigestParameter&, Configuration&);
     55
    4956void create_file_struct(std::string stats_type,
    5057                        const theplu::svndigest::Stats& stats);
    5158
     59void write_report(const svndigestParameter& option, const std::string& repo,
     60                  const Node& tree, const StatsCollection& stats);
     61
    5262int main( int argc, char* argv[])
    5363{
    54   using namespace theplu;
    55   using namespace svndigest;
    5664
    5765  // Reading commandline options
    58   Parameter* option=NULL;
    59   try {
    60     option = new Parameter(argc,argv);
    61     if (option->verbose())
     66  svndigestParameter option;
     67  try {
     68    option.parse(argc,argv);
     69    if (option.verbose())
    6270      std::cout << "Done parsing parameters" << std::endl;
    6371  }
    6472  catch (yat::utility::cmd_error& e) {
    6573    std::cerr << e.what() << std::endl;
    66     exit(-1);
    67   }
    68   assert(option);
    69 
    70   // Reading configuration file
    71   Configuration& config = Configuration::instance();
    72   if (node_exist(option->config_file())) {
    73     std::ifstream is(option->config_file().c_str());
    74     if (!is.good()){
    75       is.close();
    76       std::cerr << "\nsvndigest: Cannot open config file "
    77                 << option->config_file() << std::endl;
    78       exit(-1);
     74    exit(EXIT_FAILURE);
     75  }
     76  catch (std::runtime_error& e) {
     77    std::cerr << "svndigest: " << e.what() << std::endl;
     78    return EXIT_FAILURE;
     79  }
     80
     81  try {
     82    load_config(option.config_file());
     83    copy_option2config(option, Configuration::instance());
     84    if (option.generate_config()) {
     85      std::cout << Configuration::instance();
     86      return EXIT_SUCCESS;
    7987    }
    80     try {
    81       config.load(is);
     88
     89    if (option.verbose())
     90      std::cout << "Initializing SVN singleton." << std::endl;
     91    SVN::instance(option.root());
     92
     93    // Extract repository location
     94    std::string repo=SVNinfo(option.root()).repos_root_url();
     95
     96    // build directory tree already here ... if WC is not upto date with
     97    // repo an exception is thrown. This avoids several costly
     98    // statements below and will not remove a digest tree below if a
     99    // tree already exists.
     100    if (option.verbose())
     101      std::cout << "Building directory tree" << std::endl;
     102    Directory tree(0,option.root(),"");
     103
     104    if (option.verbose())
     105      std::cout << "Parsing directory tree" << std::endl;
     106    const StatsCollection& stats(tree.parse(option.verbose(),
     107                                            option.ignore_cache()));
     108
     109    if (option.report())
     110      write_report(option, repo, tree, stats);
     111
     112    if (option.copyright()){
     113      update_copyright(tree, option.verbose());
    82114    }
    83     catch (std::runtime_error e) {
    84       std::cerr << "svndigest: invalid config file\n"
    85                 << e.what() << std::endl;
    86       exit(-1);
    87     }
    88     is.close();
     115  }
     116  catch (std::runtime_error& e) {
     117    std::cerr << "svndigest: " << e.what() << "\n";
     118    return EXIT_FAILURE;
     119  }
     120
     121  if (option.verbose())
     122    std::cout << "Done!" << std::endl;
     123  return EXIT_SUCCESS;        // normal exit
     124}
     125
     126
     127void copy_option2config(const svndigestParameter& option, Configuration& config)
     128{
     129  try {
     130    if (option.format().present())
     131      Configuration::instance().image_format(option.format().value());
     132  }
     133  catch (std::runtime_error& e) {
     134    std::stringstream ss;
     135    ss << "invalid argument `"
     136       << option.format().value() << "' for `--"
     137       << option.format().long_name() << "'\n"
     138       << e.what() << "\n"
     139       << "Try `svndigest --help' for more information.\n";
     140    throw std::runtime_error(ss.str());
     141  }
     142  try {
     143    if (option.anchor_format().present())
     144      config.image_anchor_format(option.anchor_format().value());
     145  }
     146  catch (std::runtime_error& e) {
     147    std::stringstream ss;
     148    ss << "invalid argument `"
     149       << option.anchor_format().value() << "' for `--"
     150       << option.anchor_format().long_name() << "'\n"
     151       << e.what() << "\n"
     152       << "Try `svndigest --help' for more information.\n";
     153    throw std::runtime_error(ss.str());
     154  }
     155}
     156
     157
     158void create_file_struct(std::string stats_type,
     159                        const theplu::svndigest::Stats& stats)
     160{
     161  using namespace theplu::svndigest;
     162  mkdir(stats_type);
     163  touch(stats_type+std::string("index.html"));
     164  mkdir(stats_type+std::string("all"));
     165  mkdir(stats_type+std::string("images"));
     166  touch(stats_type+std::string("all/index.html"));
     167  touch(stats_type+std::string("images/index.html"));
     168  for (std::set<std::string>::const_iterator i = stats.authors().begin();
     169       i!=stats.authors().end(); ++i) {
     170    mkdir(stats_type+*i);
     171    touch(stats_type+*i+std::string("/index.html"));
     172  }
     173}
     174
     175void remove_target(const std::string& target_path, bool verbose)
     176{
     177  if (verbose)
     178    std::cout << "Removing old target tree: " << target_path << "\n";
     179  rmdirhier(target_path);
     180  // exit if remove failed
     181  if (node_exist(target_path))
     182    throw std::runtime_error("remove failed");
     183}
     184
     185
     186void set_dates(const std::string& repo, bool verbose)
     187{
     188  if (verbose)
     189    std::cout << "retrieving dates" << std::endl;
     190  SVNlog log(repo);
     191  std::vector<std::string> dates;
     192  dates.reserve(log.commits().size());
     193  for (SVNlog::container::const_iterator iter=log.commits().begin();
     194       iter!=log.commits().end(); ++iter) {
     195    assert(static_cast<svn_revnum_t>(dates.size())==iter->revision());
     196    dates.push_back(iter->date());
     197  }
     198  // all plots uses the same dates
     199  Graph::set_dates(dates);
     200}
     201
     202void write_report(const svndigestParameter& option, const std::string& repo,
     203                  const Node& tree, const StatsCollection& stats)
     204{
     205  std::string target_path = concatenate_path(option.targetdir(),
     206                                             file_name(option.root()));
     207  // remove target if needed
     208  if (node_exist(target_path)) {
     209    assert(option.force());
     210    remove_target(target_path, option.verbose());
    89211  }
    90212 
    91   // write configuration
    92   if (option->generate_config()) {
    93     std::cout << config;
    94     exit(0);
    95   }
    96 
    97   SVN* svn=NULL;
    98   try {
    99     if (option->verbose())
    100       std::cout << "Initializing SVN singleton." << std::endl;
    101     svn=SVN::instance(option->root());
    102   }
    103   catch (SVNException e) {
    104     std::cerr << "svndigest: " << e.what() << "\n";
    105     exit(-1);
    106   }
    107 
    108   // check if target already exists and behave appropriately
    109   bool need_to_erase_target=false;
    110   std::string target_path=option->targetdir() + '/' + file_name(option->root());
    111   if (option->report()) {
    112     if (option->verbose())
    113       std::cout << "Checking target directory" << std::endl;
    114     need_to_erase_target = node_exist(target_path);
    115     if (need_to_erase_target && !option->force()) {
    116       std::cerr << "svndigest: directory `"
    117                 << target_path << "' already exists\n";
    118       exit(-1);
    119     }
    120   }
    121 
    122   // Extract repository location
    123   std::string repo;
    124   try {
    125     if (option->verbose())
    126       std::cout << "Acquiring repository information" << std::endl;
    127     repo=SVNinfo(option->root()).repos_root_url();
    128   }
    129   catch (SVNException e) {
    130     std::cerr << "\nsvndigest: " << e.what()
    131               << "\nsvndigest: Failed to determine repository for "
    132               << option->root() << '\n' << std::endl;
    133     exit(-1);
    134   }
    135 
    136   // build directory tree already here ... if WC is not upto date with
    137   // repo an exception is thrown. This avoids several costly
    138   // statements below and will not remove a digest tree below if a
    139   // tree already exists.
    140   if (option->verbose())
    141     std::cout << "Building directory tree" << std::endl;
    142   Directory* tree=NULL;
    143   try {
    144     tree = new Directory(0,option->root(),"");
    145   }
    146   catch (NodeException e) {
    147     std::cerr << "svndigest: " << e.what() << std::endl;
    148     exit(-1);
    149   }
    150   assert(tree);
    151 
    152   if (option->verbose())
    153     std::cout << "Parsing directory tree" << std::endl;
    154   StatsCollection stats(tree->parse(option->verbose(), option->ignore_cache()));
    155 
    156   if (option->report()) {
    157     // remove target if needed
    158     if (need_to_erase_target) {
    159       if (option->verbose())
    160         std::cout << "Removing old target tree: " << target_path << "\n";
    161       rmdirhier(target_path);
    162       // exit if remove failed
    163       if (node_exist(target_path)) {
    164         std::cerr << "svndigest: remove failed\n";
    165         exit(-1);
    166       }
    167     }
    168 
    169 
    170     if (option->verbose())
    171       std::cout << "Generating output" << std::endl;
    172     if (!option->revisions()) {
    173       SVNlog log(repo);
    174       std::vector<std::string> dates;
    175       dates.reserve(log.commits().size());
    176       for (SVNlog::container::const_iterator iter=log.commits().begin();
    177            iter!=log.commits().end(); ++iter) {
    178         assert(static_cast<svn_revnum_t>(dates.size())==iter->revision());
    179         dates.push_back(iter->date());
    180       }
    181       GnuplotFE::instance()->set_dates(dates);
    182     }
    183     if (chdir(option->targetdir().c_str()) ) {
    184       std::cerr << "svndigest: chdir " << option->targetdir() << " failed\n";
    185       exit(-1);
    186     }
    187     mkdir(tree->name());
    188     if (chdir(tree->name().c_str()) ) {
    189       std::cerr << "svndigest: chdir " << tree->name() << " failed\n";
    190       exit(-1);
    191     }
    192     GnuplotFE::instance()->command(std::string("cd '")+option->targetdir()+"/"
    193                                    +tree->name()+"'");
    194     print_css("svndigest.css");
    195     print_main_page(tree->name(), tree->log(), stats, tree->url());
    196     // create structure StatsType/Author/LineType
    197     for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin());
    198          i!=stats.stats().end(); ++i)
    199       create_file_struct(i->first+std::string("/"), *i->second);
    200     try {
    201       tree->print(option->verbose());
    202     }
    203     catch (const std::runtime_error& x) {
    204       std::cerr << "svndigest: " << x.what() << std::endl;
    205       exit(-1);
    206     }
    207   }
    208 
    209   if (option->copyright()){
    210     try {
    211       if (option->verbose())
    212         std::cout << "Updating copyright statements" << std::endl;
    213       std::map<std::string, Alias> alias(config.copyright_alias());
    214       tree->print_copyright(alias, option->verbose());
    215     }
    216     catch (const std::runtime_error& x) {
    217       std::cerr << "svndigest: " << x.what() << std::endl;
    218       exit(-1);
    219     }
    220   }
    221 
    222   if (option->verbose())
    223     std::cout << "Finalizing" << std::endl;
    224 
    225   delete tree;
    226   if (option->verbose())
    227     std::cout << "Done!" << std::endl;
    228   delete option;
    229   exit(0);        // normal exit
    230 }
    231 
    232   void create_file_struct(std::string stats_type,
    233                           const theplu::svndigest::Stats& stats)
    234   {
    235     using namespace theplu::svndigest;
    236     mkdir(stats_type);
    237     touch(stats_type+std::string("index.html"));
    238     mkdir(stats_type+std::string("all"));
    239     mkdir(stats_type+std::string("images"));
    240     touch(stats_type+std::string("all/index.html"));
    241     touch(stats_type+std::string("images/index.html"));
    242     for (std::set<std::string>::const_iterator i = stats.authors().begin();
    243          i!=stats.authors().end(); ++i) {
    244       mkdir(stats_type+*i);
    245       touch(stats_type+*i+std::string("/index.html"));
    246     }
    247   }
     213  if (!option.revisions())
     214    set_dates(repo, option.verbose());
     215
     216  chdir(option.targetdir());
     217
     218  if (option.verbose())
     219    std::cout << "Generating output" << std::endl;
     220  mkdir(tree.name());
     221  chdir(tree.name().c_str());
     222  print_css("svndigest.css");
     223  print_main_page(tree.name(), tree.log(), stats, tree.url());
     224  // create structure StatsType/Author/LineType
     225  for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin());
     226       i!=stats.stats().end(); ++i)
     227    create_file_struct(i->first+std::string("/"), *i->second);
     228  tree.print(option.verbose());
     229}
  • branches/src-highlight/bootstrap

    r768 r1100  
    88
    99# Copyright (C) 2005, 2006 Jari Häkkinen
    10 # Copyright (C) 2007, 2008 Peter Johansson
     10# Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    1111#
    1212# This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/configure.ac

    r835 r1100  
    1212# Copyright (C) 2005 Jari Häkkinen, Peter Johansson
    1313# Copyright (C) 2006 Jari Häkkinen
    14 # Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    15 # Copyright (C) 2009 Peter Johansson
     14# Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     15# Copyright (C) 2010 Peter Johansson
    1616#
    1717# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    3030# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    3131
    32 AC_PREREQ(2.61)
     32AC_PREREQ([2.63])
    3333
    3434m4_include([m4/version.m4])
    35 AC_INIT([svndigest],[SVNDIGEST_VERSION],[jari@thep.lu.se],,
     35AC_INIT([svndigest], m4_defn([SVNDIGEST_VERSION]),[jari@thep.lu.se],,
    3636        [http://dev.thep.lu.se/svndigest])
    3737AC_CONFIG_SRCDIR([lib/File.h])
     
    4040AC_CONFIG_MACRO_DIR([m4])
    4141AC_PREFIX_DEFAULT([/usr/local])
     42
     43dnl FIXME remove when we assume autoconf 2.64
     44m4_ifndef([AC_PACKAGE_URL],
     45          [AC_DEFINE([PACKAGE_URL], ["http://dev.thep.lu.se/svndigest"],
     46                     [Define to home page for this package])
     47           AC_SUBST([PACKAGE_URL], ["http://dev.thep.lu.se/svndigest"])])
     48
     49# propagate RELEASE_YEAR from file .release_year
     50RELEASE_YEAR=`cat $srcdir/.release_year`
     51AC_SUBST([RELEASE_YEAR])
     52AC_DEFINE_UNQUOTED([RELEASE_YEAR], ["$RELEASE_YEAR"],
     53                   [Define year package was last modified])
     54AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/.release_year'])
    4255
    4356AC_SUBST([SVNDIGEST_MAJOR_VERSION], [MAJOR_VERSION])
     
    5467                    [Define to the svndigest patch version])
    5568
    56 AC_CONFIG_HEADER([config.h])
    57 AM_INIT_AUTOMAKE([1.10 std-options check-news])
     69AC_CONFIG_HEADERS([config.h])
     70AM_INIT_AUTOMAKE([1.11 color-tests std-options parallel-tests])
     71
     72dnl create bin/svndigest-copy-cache.in at autoconf time and let
     73dnl config.status create bin/svndigest-copy-cache from
     74dnl bin/svndigest-copy-cache.in
     75m4_pushdef([FILE], [svndigest-copy-cache])
     76m4_pushdef([my_m4sh_options], [-m 0644])
     77dnl me cd down in bin to have same output as when created from Makefile
     78m4_syscmd([cd bin && autom4te -l M4sh -o ]FILE[.in ]my_m4sh_options FILE[.as])
     79AC_CONFIG_FILES([bin/]FILE[], [chmod +x bin/]FILE[ && chmod a-w bin/]FILE[])
     80dnl export options so we can use the same in Makefile
     81AC_SUBST([M4SH_OPTIONS], ['my_m4sh_options'])
     82m4_popdef([my_m4sh_options])
     83m4_popdef([FILE])
     84AM_MISSING_PROG([AUTOM4TE], [autom4te])
    5885
    5986# Set default programming language
    60 AC_LANG(C++)
     87AC_LANG([C++])
    6188
    6289# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
     
    78105AC_PROG_CXXCPP
    79106AC_PROG_CXX
    80 AC_PROG_INSTALL
    81107AC_PROG_RANLIB
    82108AC_PROG_SED
    83109AC_PATH_PROG([HELP2MAN], [help2man], [no])
    84 AM_CONDITIONAL([HAVE_HELP2MAN], [test x$HELP2MAN != xno])
    85 AC_PATH_PROG([GNUPLOT],[gnuplot],[no])
    86 AC_DEFINE_UNQUOTED([GNUPLOT_PATH], ["$GNUPLOT"],
    87                    [defined to gnuplot path (or no if gnuplot was not found)])
     110# look for pkg-config
     111PKG_PROG_PKG_CONFIG([0.23])
    88112
    89113# Save FLAGS
    90 SAVE_CPPFLAGS="$CPPFLAGS"
    91 SAVE_CXXFLAGS="$CXXFLAGS"
    92 SAVE_LDFLAGS="$LDFLAGS"
    93 SAVE_LIBS="$LIBS"
     114APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
     115APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
    94116
    95117# -Wno-long-long is needed to suppress compiler diagnostics regarding
    96118# using extension beyond the C++ standard (usage of non C++ standard
    97119# 'long long' types).
    98 YAT_CXX_ADD_FLAG([SD_CXXFLAGS],[-pedantic -Wno-long-long])
     120YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -Wno-long-long])
    99121AC_TYPE_LONG_LONG_INT
    100122AS_IF([test x$ac_cv_type_long_long_int = xno],
     
    103125
    104126AC_ARG_ENABLE([debug],
    105   [AS_HELP_STRING([--enable-debug],[turn on debug options and code])],
    106   [YAT_CXX_ADD_FLAG([SD_CXXFLAGS],[-g -O])],
    107   [YAT_CPP_ADD_FLAG([SD_CPPFLAGS],[-DNDEBUG])
    108    YAT_CXX_ADD_FLAG([SD_CXXFLAGS],[-O3])])
    109 
    110 # enable svn-support
    111 AC_ARG_ENABLE([svn-support],
    112               [AS_HELP_STRING([--enable-svn-support],
    113                               [enable svn support - used by maintainer])])
    114 
    115 AS_IF([test "x$enable_svn_support" = xyes],
    116       [AS_IF([test -d $srcdir/.svn], [],
    117              [AC_MSG_ERROR([svn support cannot be enabled: `$srcdir' is not an svn wc.])])])
    118 AM_CONDITIONAL([ENABLE_SVN_SUPPORT], [test "x$enable_svn_support" = "xyes"])
     127  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
     128
     129AS_IF([test x$enable_debug = xyes],
     130  [YAT_CXX_ADD_FLAG([CXXFLAGS],[-g -O])],
     131  [YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])
     132   YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])])
    119133
    120134# Apache Portable Runtime (APR) API checks
    121 APR_FIND_APR(,,1,[1 0])
     135APR_FIND_APR(,,[1],[1 0])
    122136AS_IF([test "${with_apr+set}" = set],
    123137    [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-apr=$with_apr"]
    124138)
    125139if test "$apr_found" = "yes" ; then
    126     SD_LIBS="`$apr_config --libs` $SD_LIBS"
    127     apr_link_ld=`$apr_config --link-ld`
     140    APR_LIBS="`$apr_config --libs`"
     141    apr_link_ld="`$apr_config --link-ld`"
    128142    for i in $apr_link_ld; do
    129       AS_IF([test ${i:0:2} = "-l"],[SD_LIBS="$i $SD_LIBS"],
    130             [YAT_LD_ADD_FLAG([SD_LDFLAGS], [$i])])
     143      AS_IF([test ${i:0:2} = "-l"],[APR_LIBS="$i $APR_LIBS"],
     144            [YAT_LD_ADD_FLAG([APR_LDFLAGS], [$i])])
    131145    done
    132     YAT_CPP_ADD_FLAG([SD_CPPFLAGS],[`$apr_config --includes --cppflags`])
    133 fi
     146    YAT_CPP_ADD_FLAG([APR_CPPFLAGS],[`$apr_config --includes --cppflags`])
     147    save_CPPFLAGS=$CPPFLAGS
     148    CPPFLAGS="$APR_CPPFLAGS $CPPFLAGS"
     149    AC_CHECK_HEADER([apr_allocator.h],,[apr_found="no"])
     150    CPPFLAGS=$save_CPPFLAGS
     151fi
     152AC_SUBST([APR_CPPFLAGS])
     153AC_SUBST([APR_LDFLAGS])
     154AC_SUBST([APR_LIBS])
    134155
    135156# Subversion API checks
    136157svn_found="yes"
    137 AC_ARG_WITH(svn,
     158AC_ARG_WITH([svn],
    138159  [AS_HELP_STRING([--with-svn=DIR],[prefix for svn developer files [[PREFIX]]])],
    139   [ DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-svn=$withval"
    140     YAT_LD_ADD_FLAG([SD_LDFLAGS], [-L$withval/lib])
    141     YAT_CPP_ADD_FLAG([SD_CPPFLAGS], [-I$withval/include])
    142   ])
    143 
    144 
    145 
    146 # Use SD_*FLAGS in tests
    147 CPPFLAGS="$SD_CPPFLAGS $CPPFLAGS"
    148 CXXFLAGS="$SD_CXXFLAGS $CXXFLAGS"
    149 LDFLAGS="$SD_LDFLAGS $LDFLAGS"
    150 LIBS="$SD_LIBS $LIBS"
    151 
    152 AC_CHECK_HEADER([apr_allocator.h],,apr_found="no")
    153 AC_CHECK_HEADER([subversion-1/svn_types.h],,svn_found="no")
     160  [ AS_CASE([$withval], [yes|no],
     161            [AC_MSG_ERROR([--with-svn requires a directory to be provided])])
     162    AS_IF([test -d $with_svn], [],
     163          [AC_MSG_ERROR([$with_svn: no such directory])])
     164    # transform argument to absolute path
     165    with_svn=`cd $with_svn && pwd`
     166    DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-svn=$with_svn"
     167    YAT_LD_ADD_FLAG([SVN_LDFLAGS], [-L$with_svn/lib])
     168    YAT_CPP_ADD_FLAG([SVN_CPPFLAGS], [-I$with_svn/include])
     169  ])
     170# svn needs needs apr headers
     171save_CPPFLAGS=$CPPFLAGS
     172CPPFLAGS="$APR_CPPFLAGS $SVN_CPPFLAGS $CPPFLAGS"
     173AC_CHECK_HEADER([subversion-1/svn_types.h],,[svn_found="no"])
     174CPPFLAGS=$save_CPPFLAGS
     175
     176save_LDFLAGS=$LDFLAGS
     177save_LIBS=$LIBS
     178tmp_LIBS="$APR_LIBS $save_LIBS"
     179LIBS=""
     180LDFLAGS="$SVN_LDFLAGS $APR_LDFLAGS"
    154181AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
    155                [SD_LIBS="-lsvn_subr-1 $SD_LIBS"],svn_found="no")
    156 AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1],
    157                [SD_LIBS="-lsvn_ra-1 $SD_LIBS"],svn_found="no")
    158 AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1],
    159                [SD_LIBS="-lsvn_wc-1 $SD_LIBS"],svn_found="no")
    160 AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],
    161                [SD_LIBS="-lsvn_diff-1 $SD_LIBS"],svn_found="no")
    162 AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],
    163                [SD_LIBS="-lsvn_client-1 $SD_LIBS"],svn_found="no")
    164 
    165 # Export flags
    166 AC_SUBST([SVNDIGEST_CPPFLAGS], $SD_CPPFLAGS)
    167 AC_SUBST([SVNDIGEST_CXXFLAGS], $SD_CXXFLAGS)
    168 AC_SUBST([SVNDIGEST_LDFLAGS], $SD_LDFLAGS)
    169 AC_SUBST([SVNDIGEST_LIBS], $SD_LIBS)
    170 
    171 # Reset FLAGS
    172 CPPFLAGS="$SAVE_CPPFLAGS"
    173 CXXFLAGS="$SAVE_CXXFLAGS"
    174 LDFLAGS="$SAVE_LDFLAGS"
    175 LIBS="$SAVE_LIBS"
     182               [], [svn_found="no"], [$tmp_LIBS])
     183AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1], [], [svn_found="no"],[$tmp_LIBS])
     184AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1], [], [svn_found="no"], [$tmp_LIBS])
     185AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],[],
     186               [svn_found="no"], [$tmp_LIBS])
     187AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],,[svn_found="no"], [$tmp_LIBS])
     188SVN_LIBS=$LIBS
     189LIBS=$save_LIBS
     190LDFLAGS=$save_LDFLAGS
     191AC_SUBST([SVN_CPPFLAGS])
     192AC_SUBST([SVN_LDFLAGS])
     193AC_SUBST([SVN_LIBS])
     194
    176195
    177196# check if svnversion is installed
    178197AC_PATH_PROG([SVNVERSION], [svnversion], [no])
     198
     199# PLplot API checks
     200# plplot_found can get values: skip, noheader, old, or nolib if an
     201# error is detected.
     202plplot_found="yes"
     203plplot_version=5.9
     204save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
     205AC_ARG_WITH([plplot],
     206  [AS_HELP_STRING([--with-plplot=DIR],[prefix for plplot developer files])],
     207  [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-plplot=$withval"
     208   AS_IF([test "x$withval" = "xno"], [ dnl
     209     plplot_found=skip;
     210   ], [ dnl
     211     AS_IF([test -d $with_plplot], [],
     212           [AC_MSG_ERROR([$with_plplot: no such directory])])
     213     with_plplot=`cd $with_plplot && pwd`
     214     # help pkg-config find .pc file
     215     PKG_CONFIG_PATH=$with_plplot/lib/pkgconfig$PATH_SEPARATOR$PKG_CONFIG_PATH
     216     export PKG_CONFIG_PATH
     217   ])
     218  ])
     219
     220use_plplot_pc="no"
     221AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
     222  AC_MSG_CHECKING([for plplotd-c++.pc])
     223  AS_IF([$PKG_CONFIG --exists plplotd-c++], [
     224    AC_MSG_RESULT([yes])
     225    use_plplot_pc="yes"
     226  ],[
     227    AC_MSG_RESULT([no])
     228    AC_MSG_WARN([cannot find plplotd-c++;
     229      please use --with-plplot with appropriate argument to get more accurate
     230      configuration.])
     231  ])
     232])
     233
     234AS_IF([test "x$plplot_found" = "xyes"], [
     235  # copy flags if we have found pc file
     236  AS_IF([test "$use_plplot_pc" = "yes"], [
     237    YAT_LD_ADD_FLAG([PLPLOT_LDFLAGS], [`$PKG_CONFIG plplotd-c++ --libs-only-L`])
     238    PLPLOT_LIBS="`$PKG_CONFIG plplotd-c++ --libs-only-l --libs-only-other`"
     239  ],[
     240    # otherwise guess
     241    PLPLOT_LIBS="-lplplotcxxd -lplplotd";
     242    AS_IF([test -n "$with_plplot" && test "x$with_plplot" != "xyes"], [
     243      YAT_LD_ADD_FLAG([PLPLOT_LDFLAGS], [-L$with_plplot/libs])
     244    ])
     245  ])
     246  # don't use `pkg-config --cflags' because it returns
     247  # `PREFIX/include/plplot' rather than `PREFIX/include'
     248  AS_IF([test -n "$with_plplot" && test "x$with_plplot" != "xyes"], [
     249    YAT_CPP_ADD_FLAG([PLPLOT_CPPFLAGS], [-I$with_plplot/include])
     250  ])
     251])
     252                 
     253AS_IF([test "x$plplot_found" = "xyes"], [
     254  save_CPPFLAGS=$CPPFLAGS
     255  CPPFLAGS="$PLPLOT_CPPFLAGS $CPPFLAGS"
     256  AC_CHECK_HEADER([plplot/plstream.h], [], [plplot_found="noheader"])
     257  CPPFLAGS=$save_CPPFLAGS
     258])
     259
     260
     261AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
     262  AC_MSG_CHECKING([plplot version >= $plplot_version])
     263  AS_IF([$PKG_CONFIG --atleast-version=$plplot_version plplotd-c++], [
     264    AC_MSG_RESULT([yes])
     265  ],[
     266    AC_MSG_RESULT([`$PKG_CONFIG --modversion= plplotd-c++`])
     267    plplot_found="old"
     268  ])
     269])
     270
     271AS_IF([test "x$plplot_found" = "xyes"], [
     272  save_CPPFLAGS=$CPPFLAGS
     273  CPPFLAGS="$PLPLOT_CPPFLAGS $CPPFLAGS"
     274  save_LDFLAGS=$LDFLAGS
     275  LDFLAGS="$PLPLOT_LDFLAGS $LDFLAGS"
     276  save_LIBS=$LIBS
     277  LIBS="$PLPLOT_LIBS $LIBS"
     278  AC_MSG_CHECKING([for library containing plstream])
     279  AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <plplot/plstream.h>],
     280                                  [plstream pls(1,1,"svg", "conftest.svg");
     281                                   pls.scolbga(255, 255, 255, 0);
     282                                  ])],
     283                 [AC_MSG_RESULT([yes]);
     284                  AC_DEFINE([HAVE_PLPLOT], [1],
     285                            [Define to 1 if you have plplot])],
     286                 [AC_MSG_RESULT([no])
     287                  plplot_found=nolib;])
     288  CPPFLAGS=$save_CPPFLAGS
     289  LDFLAGS=$save_LDFLAGS
     290  LIBS=$save_LIBS
     291])
     292# restore variable
     293export PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
     294AC_SUBST(PLPLOT_CPPFLAGS)
     295AC_SUBST(PLPLOT_LDFLAGS)
     296AC_SUBST(PLPLOT_LIBS)
    179297
    180298# checking if we build in a subversion WC
     
    194312       AC_SUBST(abs_test_repo)]
    195313     )
    196 AC_CONFIG_FILES([test/test_repo.sh], [chmod +x test/test_repo.sh])
     314AC_CONFIG_FILES([test/init.sh])
    197315AC_CONFIG_FILES([test/svn_update.sh], [chmod +x test/svn_update.sh])
    198 AC_CONFIG_FILES([test/check_repo_status.sh],
    199                 [chmod +x test/check_repo_status.sh])   
    200 
     316
     317dnl maintainer make rukes from yat project
     318YAT_SVN_RELEASE
     319
     320# Restore FLAGS
     321APR_RESTORE_THE_ENVIRONMENT([CPPFLAGS], [DEFAULT_])
     322APR_RESTORE_THE_ENVIRONMENT([CXXFLAGS], [DEFAULT_])
    201323
    202324AC_CONFIG_FILES([Makefile
     
    267389fi
    268390
     391# Non-existing PLplot API is fatal -- sub-sequent compilation will fail.
     392AS_CASE([$plplot_found],
     393  [noheader],
     394    [AC_MSG_WARN([
     395    PLplot developer files cannot be found. Make sure PLplot is installed.])
     396    all_reqs_ok="false"],
     397  [old],
     398    [AC_MSG_WARN([
     399    PLplot developer files found but not required API version.
     400    Version at least $plplot_version is required. Please upgrade PLplot.])
     401    all_reqs_ok="false"],
     402  [nolib],
     403    [AC_MSG_WARN([
     404    PLplot developer files found but linking against plplot library failed.])
     405    all_reqs_ok="false"])
     406
    269407if test $ac_cv_type_long_long_int != yes ; then
    270408  AC_MSG_WARN([Compiler $CXX does not support `long long'.
     
    284422
    285423# Some more messages.
    286 AC_MSG_NOTICE([])
    287 AC_MSG_NOTICE([   Ready to compile the executables of svndigest $VERSION])
    288 AC_MSG_NOTICE([   The following flags and libs will be used:])
    289 AC_MSG_NOTICE([   +++++++++++++++++++++++++++++++++++++++++++++++])
    290 AC_MSG_NOTICE([    Compiler:           $CXX])
    291 AC_MSG_NOTICE([    Preprocessor flags: $SD_CPPFLAGS $CPPFLAGS])
    292 AC_MSG_NOTICE([    C++ flags:          $SD_CXXFLAGS $CXXFLAGS])
    293 AC_MSG_NOTICE([    Linker flags:       $SD_LDFLAGS $LDFLAGS])
    294 AC_MSG_NOTICE([    LIBS:               $SD_LIBS $LIBS])
    295 AC_MSG_NOTICE([   +++++++++++++++++++++++++++++++++++++++++++++++])
    296 AC_MSG_NOTICE([])
    297 
    298 # Failure to locate gnuplot is not considered fatal
    299 if (test "x$GNUPLOT" = "xno") ; then
    300   AC_MSG_WARN([Gnuplot was not found. svndigest will compile
    301   without gnuplot but will throw an exception at run-time. Please
    302   install gnuplot (available for a wide range of operating systems
    303   at http://www.gnuplot.info).])
    304   AC_MSG_NOTICE([])
    305 fi
    306 
    307 AC_MSG_NOTICE([Now type 'make && make check'.])
     424AC_MSG_NOTICE([
     425Ready to compile the executables of svndigest $VERSION
     426The following flags and libs will be used:
     427+++++++++++++++++++++++++++++++++++++++++++++++
     428  Compiler:           $CXX
     429  Preprocessor flags: $SD_CPPFLAGS $CPPFLAGS
     430    CPPFLAGS:         $CPPFLAGS
     431    DEFAULT_CPPFLAGS: $DEFAULT_CPPFLAGS
     432    APR_CPPFLAGS:     $APR_CPPFLAGS
     433    SVN_CPPFLAGS:     $SVN_CPPFLAGS
     434    PLPLOT_CPPFLAGS:  $PLPLOT_CPPFLAGS
     435  C++ flags:
     436    CXXFLAGS:         $CXXFLAGS
     437    DEFAULT_CXXFLAGS: $DEFAULT_CXXFLAGS
     438  Linker flags:
     439    LDFLAGS:          $LDFLAGS
     440    APR_LDFLAGS:      $APR_LDFLAGS
     441    SVN_LDFLAGS:      $SVN_LDFLAGS
     442    PLPLOT_LDFLAGS:   $PLPLOT_LDFLAGS
     443  Libraries:         
     444    LIBS              $LIBS
     445    APR_LIBS          $APR_LIBS
     446    SVN_LIBS          $SVN_LIBS
     447    PLPLOT_LIBS       $PLPLOT_LIBS
     448+++++++++++++++++++++++++++++++++++++++++++++++]dnl
     449)
     450
     451AC_MSG_NOTICE([Now type 'make all check'.])
  • branches/src-highlight/doc/readme.txt

    r833 r1100  
    22{{{
    33Copyright (C) 2005 Jari Häkkinen
    4 Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    5 Copyright (C) 2007, 2008, 2009 Peter Johansson
     4Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     5Copyright (C) 2009, 2010 Peter Johansson
    66
    77This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    7777second block describes that comments also could come as `/* ... */`.
    7878
    79 For a more detailed illustration, please have a look at `config` that
    80 can be found in directory `.svndigest`, and the svndigest screenshots
    81 that can be reached through http://dev.thep.lu.se/svndigest/.
    82 
    8379Sometimes it might be useful if a file could be parsed as though it
    8480was going under a different name. It could, for example, be useful if
     
    9793
    9894To avoid retrieving the same data repeatedly from the repository,
    99 statistics is cahed in files located in `.svndigest`. Subsequent
     95statistics is cached in files located in `.svndigest`. Subsequent
    10096svndigest runs read the cache files and retrieve information from the
    10197repository only for the revisions that have been committed since the
     
    143139inherited to the new config file. To preserve such a comment you must
    144140merge the new config file with the old config file manually.
     141
     142The color used for each author in plots and blame output can be
     143configured in section [author-color] in config file. The format of the
     144color string is a 6-digit hexadecimal number in which each color (red,
     145green and blue) is decribed by 2 digits, i.e. each color is described
     146by a value between 0 and 255 in hexadecimal format. It is also allowed
     147to set the color with a 3-digit hexadecimal number in which case, for
     148example, 'a5b' would be equivalent to 'aa55bb'.
     149
     150The format of images in the report can be configured in section
     151[image]. Allowed formats are `png`, `svg`, and `none` where the latter
     152implies that images are not created.
    145153
    146154== Copyright update ==
     
    198206  * Create the plots and HTML presentation.
    199207
     208= Copy Cache =
     209
     210As explained above, statistics are cached during a run and svndigest
     211only communicates with the server to retrieve statistics of the
     212activity since last run. Subsequent runs are much faster why it is
     213prefereble to run svndigest in a wc with recent cache available.
     214
     215Sometimes it is useful to copy the cache from one wc to another, and
     216an easy way to do this is to use the tool `svndigest-copy-cache`,
     217which is shipped with svndigest. A common use case is when creating,
     218say, a release branch from the trunk, in which case you likely will
     219have two working copies to follow the two branches. If you want to run
     220svndigest on both of them and you want to avoid the first expensive
     221run (without cache) you can copy the cache from the trunk wc to the
     222release-branch wc.
     223
     224As explained in the caching section, it is important that the cache
     225reflects a revision that belong to the history of the wc. So, for
     226example, when creating a branch it is crucial to copy the cache from
     227the trunk wc to the new branch wc before running svndigest on trunk
     228wc. Otherwise the cache will contain information about changesets that
     229were committed after the new branch were forked out. This will not
     230only be untrue as these changesets are not in the line of history of
     231the branch, but it will also cause problems for svndigest when
     232calculating the statistics of the most recent revisons and result is
     233undefined due to inconsistency between the cache and the log. For an
     234example of how `svndigest-copy-cache` may be used please refer to the
     235ReleaseProcedure of svndigest.
     236
     237`svndigest-copy-cache` copies the cache file from `ROOT` tree to the
     238corresponding directory in `TARGET` tree. The tree structure of the
     239two working copies must be identical because `svndigest-copy-cache`
     240will not create any directories in `TARGET` tree except that
     241`.svndigest` directories are created when necessary.
     242
     243Also, `svndigest-copy-cache` is ignorant about svn wc and will parse
     244through `ROOT` directory and all its sub-directories ,looking for
     245svndigest cache files, regardless whether they belong to the same svn
     246working copy or not. Therefore, having other svn wc in subdirectories
     247of `ROOT` might give an unexpected result.
  • branches/src-highlight/lib/AddStats.cc

    r803 r1100  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2005 Peter Johansson
     5  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    57
    68  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    7577
    7678
     79  unsigned int AddStats::max_element(const std::vector<unsigned int>& v) const
     80  {
     81    assert(v.size());
     82    return v.back();
     83  }
     84
     85
    7786}} // end of namespace svndigest and namespace theplu
  • branches/src-highlight/lib/AddStats.h

    r693 r1100  
    55
    66/*
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2005 Peter Johansson
     8  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     9  Copyright (C) 2010 Peter Johansson
    810
    911  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4345  private:
    4446    void do_parse(const std::string&, svn_revnum_t);
     47    unsigned int max_element(const std::vector<unsigned int>&) const;
    4548
    4649  };
  • branches/src-highlight/lib/Alias.cc

    r768 r1100  
    22
    33/*
    4   Copyright (C) 2007, 2008 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Alias.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    99  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/BlameStats.cc

    r818 r1100  
    33/*
    44  Copyright (C) 2005 Peter Johansson
    5   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009 Peter Johansson
     5  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/BlameStats.h

    r693 r1100  
    66/*
    77  Copyright (C) 2005 Peter Johansson
    8   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2007 Peter Johansson
     8  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     9  Copyright (C) 2010 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/ClassicStats.cc

    r803 r1100  
    33/*
    44  Copyright (C) 2005 Peter Johansson
    5   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    67
    78  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    7374
    7475
     76  unsigned int
     77  ClassicStats::max_element(const std::vector<unsigned int>& v) const
     78  {
     79    assert(v.size());
     80    return v.back();
     81  }
     82
    7583}} // end of namespace svndigest and namespace theplu
  • branches/src-highlight/lib/ClassicStats.h

    r693 r1100  
    66/*
    77  Copyright (C) 2005 Peter Johansson
    8   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2007 Peter Johansson
     8  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     9  Copyright (C) 2010 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4545  private:
    4646    void do_parse(const std::string&, svn_revnum_t);
     47    unsigned int max_element(const std::vector<unsigned int>&) const;
    4748
    4849  };
  • branches/src-highlight/lib/Commitment.cc

    r768 r1100  
    22
    33/*
    4   Copyright (C) 2007, 2008 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Commitment.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Configuration.cc

    r818 r1100  
    22
    33/*
    4   Copyright (C) 2007, 2008 Peter Johansson
    5   Copyright (C) 2008 Jari Häkkinen
     4  Copyright (C) 2007, 2008, 2009, 2010 Jari Häkkinen, Peter Johansson
    65
    76  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2120*/
    2221
     22#include <config.h>
     23
    2324#include "Configuration.h"
    2425
     26#include "Colors.h"
    2527#include "Functor.h"
    2628
     
    6163
    6264
     65  const std::map<std::string, std::string>&
     66  Configuration::author_colors(void) const
     67  {
     68    return author_color_;
     69  }
     70
    6371  std::string Configuration::author_str_color(const std::string& author) const
    6472  {
     
    7886    for (String2Codons::const_iterator i(string2codons_.begin());
    7987         i!=string2codons_.end(); ++i) {
    80       if (svndigest::equal(file_name.begin(), file_name.end(),
    81                            i->first.begin(), i->first.end()) ) {
     88      if (fnmatch(i->first.c_str(), file_name.c_str()))
    8289        return &i->second;
    83       }
    8490    }
    8591    return NULL;
     
    97103  {
    98104    for (size_t i=0; i<dictionary_.size(); ++i)
    99       if (svndigest::equal(lhs.begin(), lhs.end(),
    100                            dictionary_[i].first.begin(),
    101                            dictionary_[i].first.end()))
     105      if (fnmatch(lhs.c_str(), dictionary_[i].first.c_str()))
    102106        return &dictionary_[i];
    103107    return NULL;
     
    119123
    120124
     125  const std::string& Configuration::image_anchor_format(void) const
     126  {
     127    return image_anchor_format_;
     128  }
     129
     130
     131  const std::string& Configuration::image_format(void) const
     132  {
     133    return image_format_;
     134  }
     135
     136
    121137  void Configuration::load(void)
    122138  {
     
    129145  {
    130146    assert(is.good());
    131     set_default();
    132147
    133148    bool parsing_found=false;
     
    188203      }
    189204      else if (section == "author-color") {
     205        unsigned char r,g,b;
     206        try {
     207          str2rgb(rhs, r,g,b);
     208        }
     209        catch (std::runtime_error& e) {
     210          throw Config_error(line, e.what());
     211        }
    190212        author_color_[lhs] = rhs;
    191213      }     
     
    203225          for (String2Codons::const_iterator i(string2codons_.begin());
    204226               i!=string2codons_.end(); ++i) {
    205             if (svndigest::equal(lhs.begin(), lhs.end(),
    206                                  i->first.begin(), i->first.end()) ) {
     227            if (fnmatch(lhs.c_str(), i->first.c_str())) {
    207228              mess << "`" << i->first << "'";
    208229              break;
     
    269290        }
    270291      }
     292      else if (section == "image") {
     293        if (lhs == "format") {
     294          try {
     295            image_format(rhs);
     296          }
     297          catch (std::runtime_error e) {
     298            throw Config_error(line,
     299                               "unknown format: " + rhs + "\n" + e.what());
     300          }
     301        }
     302        else if (lhs == "image_format") {
     303          try {
     304            image_anchor_format(rhs);
     305          }
     306          catch (std::runtime_error e) {
     307            throw Config_error(line,
     308                               "unknown format: " + rhs + "\n" + e.what());
     309          }
     310        }
     311      }
    271312    }
    272313    validate_dictionary();
     314  }
     315
     316
     317  void Configuration::image_anchor_format(const std::string& format)
     318  {
     319    if (format!="none" && format!="pdf" && format!="png" && format!="svg") {
     320      std::ostringstream oss;
     321      oss << "Valid arguments are:\n"
     322          << "  - `none'\n"
     323          << "  - `pdf'\n"
     324          << "  - `png'\n"
     325          << "  - `svg'";
     326      throw std::runtime_error(oss.str());
     327    }
     328    image_anchor_format_ = format;
     329  }
     330
     331
     332  void Configuration::image_format(const std::string& format)
     333  {
     334    if (format!="none" && format!="png" && format!="svg") {
     335      std::ostringstream oss;
     336      oss << "Valid arguments are:\n"
     337          << "  - `none'\n"
     338          << "  - `png'\n"
     339          << "  - `svg'";
     340      throw std::runtime_error(oss.str());
     341    }
     342    image_format_ = format;
    273343  }
    274344
     
    294364                           const std::pair<std::string, std::string>& dic) const
    295365  {
    296     assert(svndigest::equal(str.begin(), str.end(),
    297                             dic.first.begin(), dic.first.end()));
    298366    std::string res;
    299367    std::vector<std::string> vec;
    300     regexp(str.begin(), str.end(), dic.first.begin(), dic.first.end(), vec);
     368    if (!regexp(dic.first, str, vec)) {
     369      std::stringstream mess;
     370      mess << "invalid config file: "
     371           << "expression " << dic.first << " is invalid";
     372      throw std::runtime_error(mess.str());       
     373    }
    301374    for (std::string::const_iterator i(dic.second.begin());
    302375         i!=dic.second.end(); ++i) {
     
    307380        if (n>vec.size() || n==0){
    308381          std::stringstream mess;
    309           mess << "svndigest: invalid config file: "
     382          mess << "invalid config file: "
    310383               << "expression " << dic.second << " is invalid";
    311384          if (n)
    312385            mess << "because " << n << " is a too large.";
    313           throw std::runtime_error("");       
     386          throw std::runtime_error(mess.str());       
    314387        }
    315388        res += vec[n-1];
     
    366439    add_codon("*.ac", "dnl", "\n");
    367440    add_codon("*.am", "#", "\n");
    368     add_codon("*.m4", "#", "\n");
    369     add_codon("*.m4", "dnl", "\n");
     441    add_codon("*.as", "#", "\n");
     442    add_codon("*.as", "dnl", "\n");
     443    add_codon("*.bat", "\nREM", "\n");
     444    add_codon("*.bat", "\nrem", "\n");
    370445    add_codon("*.c", "//", "\n");
    371446    add_codon("*.c", "/*", "*/");
     
    374449    add_codon("*.cpp", "//", "\n");
    375450    add_codon("*.cpp", "/*", "*/");
     451    add_codon("*.css", "<!--", "-->");
    376452    add_codon("*.cxx", "//", "\n");
    377453    add_codon("*.cxx", "/*", "*/");
     
    382458    add_codon("*.hpp", "//", "\n");
    383459    add_codon("*.hpp", "/*", "*/");
     460    add_codon("*.html", "<%--", "--%>");
    384461    add_codon("*.java", "//", "\n");
    385462    add_codon("*.java", "/*", "*/");
     463    add_codon("*.jsp", "<!--", "-->");
     464    add_codon("*.m", "%", "\n");
     465    add_codon("*.m4", "#", "\n");
     466    add_codon("*.m4", "dnl", "\n");
    386467    add_codon("*.pl", "#", "\n");
    387468    add_codon("*.pm", "#", "\n");
     469    add_codon("*.R", "#", "\n");
     470    add_codon("*.rss", "<!--", "-->");
     471    add_codon("*.sgml", "<!--", "-->");
    388472    add_codon("*.sh", "#", "\n");
     473    add_codon("*.shtml", "<!--", "-->");
     474    add_codon("*.tex", "%", "\n");
     475    add_codon("*.xhtml", "<!--", "-->");
     476    add_codon("*.xml", "<!--", "-->");
     477    add_codon("*.xsd", "<!--", "-->");
     478    add_codon("*.xsl", "<!--", "-->");
    389479    add_codon("*config", "#", "\n");
    390480    add_codon("bootstrap", "#", "\n");
    391481    add_codon("Makefile", "#", "\n");
    392     add_codon("*.tex", "%", "\n");
    393     add_codon("*.m", "%", "\n");
    394     add_codon("*.jsp", "<!--", "-->");
    395     add_codon("*.html", "<%--", "--%>");
    396     add_codon("*.xml", "<!--", "-->");
    397     add_codon("*.xsl", "<!--", "-->");
    398     add_codon("*.xsd", "<!--", "-->");
    399     add_codon("*.xhtml", "<!--", "-->");
    400     add_codon("*.shtml", "<!--", "-->");
    401     add_codon("*.xml", "<!--", "-->");
    402     add_codon("*.css", "<!--", "-->");
    403     add_codon("*.rss", "<!--", "-->");
    404     add_codon("*.sgml", "<!--", "-->");
    405     add_codon("*.bat", "\nREM", "\n");
    406     add_codon("*.bat", "\nrem", "\n");
    407482
    408483    dictionary_ = VectorPair(1, std::make_pair("*.in", "$1"));
     484    image_format_ = "png";
     485    image_anchor_format_ = "png";
    409486  }
    410487
     
    463540
    464541    for (vector::const_iterator i(vec.begin()); i!=vec.end(); ++i) {
    465       os << i->first << " = " << i->second.name() << " \n";
     542      os << i->first << " = " << i->second.name() << "\n";
    466543    }
    467544
    468545    os << "\n"
    469        << "### Section for author color in blame output\n"
     546       << "### Section for images\n"
     547       << "[image]\n"
     548       << "format = " << conf.image_format() << "\n";
     549    os << "anchor_format = " << conf.image_anchor_format() << "\n";
     550
     551
     552    os << "\n"
     553       << "### Section for author color in plots and blame output.\n"
    470554       << "[author-color]\n"
    471555       << "# jdoe = 000000\n";
     
    473557    for (str_map::const_iterator i(conf.author_color_.begin());
    474558         i!=conf.author_color_.end(); ++i) {
    475       os << i->first << " = " << i->second << " \n";
     559      os << i->first << " = " << i->second << "\n";
    476560    }
    477561
  • branches/src-highlight/lib/Configuration.h

    r815 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4546
    4647    /**
    47        \return hexadecimal color code (e.g. 5aee4a) that is used in
    48        blame output. If no color is configured for \a author, an empty
    49        string is returned.
     48       \return Hexadecimal color code (e.g. 5aee4a) that is used in
     49       blame output and as line colors in plots. If no color is
     50       configured for \a author, an empty string is returned.
    5051     */
    5152    std::string author_str_color(const std::string& author) const;
     53
     54    /**
     55       The map to lookup the author-color mapping set in the
     56       configuration file. The color code is a six digit hexadecimal
     57       number rrggbb.
     58
     59       \return The author-color map
     60    */
     61    const std::map<std::string, std::string>& author_colors(void) const;
    5262
    5363    /**
     
    6171    ///
    6272    const std::map<std::string, Alias>& copyright_alias(void) const;
     73
     74    /**
     75       \return pdf, png, none, or svg
     76     */
     77    const std::string& image_anchor_format(void) const;
     78
     79    /**
     80       \brief set image_anchor_format
     81     */
     82    void image_anchor_format(const std::string&);
     83
     84    /**
     85       \return png, none, svg, or svgz
     86     */
     87    const std::string& image_format(void) const;
     88
     89    /**
     90       \brief set image_format
     91     */
     92    void image_format(const std::string&);
    6393
    6494    ///
     
    111141       Translate string \a str using dictionary \a dict
    112142
    113        \note \a str must be equal to d.first (see function equal),
     143       \note \a str must be equal to d.first (see regexp(5)),
    114144       or behavior is unspecified.
    115145
     
    134164
    135165    VectorPair dictionary_;
    136 
     166    std::string image_anchor_format_;
     167    std::string image_format_;
    137168    std::string trac_root_;
    138169  };
  • branches/src-highlight/lib/Date.cc

    r768 r1100  
    22
    33/*
    4   Copyright (C) 2007 Peter Johansson
    5   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    65  Copyright (C) 2009 Peter Johansson
    76
  • branches/src-highlight/lib/Date.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    99  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Directory.cc

    r834 r1100  
    22
    33/*
    4   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2009 Peter Johansson
     4  Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Jari Häkkinen, Peter Johansson
    65
    76  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2423
    2524#include "Alias.h"
     25#include "Configuration.h"
    2626#include "File.h"
    2727#include "html_utility.h"
     
    3939#include <list>
    4040#include <map>
     41#include <sstream>
    4142
    4243#include <cerrno> // Needed to check error state below.
     
    148149  void Directory::print_core(const bool verbose) const
    149150  {
    150     mkdir("blame_output/" + local_path_);
     151    mkdir("blame_output/" + local_path());
    151152    // print daughter nodes
    152153    for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
     
    162163
    163164    const Stats& stats = stats_[stats_type];
    164     std::string outdir = stats_type+"/"+user+"/"+line_type+"/"+local_path_;
    165     if (local_path_=="")
    166       outdir = stats_type+"/"+user+"/"+line_type;
    167 
     165    std::string imagedir = stats_type+"/"+"images/"+line_type;
     166    std::string outdir   = stats_type+"/"+user+"/" +line_type;
     167    if (local_path()!="") {
     168      imagedir += "/"+local_path();
     169      outdir   += "/"+local_path();
     170    }
    168171    mkdir(outdir);
    169     std::string imagedir = stats_type+"/"+"images/"+line_type+"/"+local_path_;
    170172    if (user=="all")
    171173      mkdir(imagedir);
     
    180182                   local_path()+"/index.html", stats_type);
    181183    path_anchor(os);
    182     os << "<p class=\"plot\">\n<img src='";
     184
     185    std::stringstream ss;
    183186    for (size_t i=0; i<level_; ++i)
    184       os << "../";
    185     os << "../../../";
     187      ss << "../";
     188    ss << "../../../";
    186189    if (user=="all")
    187       os << stats.plot(imagedir+"/index.png", line_type);
     190      ss << stats.plot(imagedir+"/index", line_type);
    188191    else
    189       os << imagedir << "/index.png";
    190     os << "' alt='[plot]' /></p>\n";
     192      ss << imagedir << "/index";
     193    os << "<p class=\"plot\">\n";
     194    os << image(ss.str());
     195    os << "</p>\n";
     196
    191197    os << "<h3>File Summary";
    192198    if (user!="all")
  • branches/src-highlight/lib/Directory.h

    r834 r1100  
    55
    66/*
    7   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
     7  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    88  Copyright (C) 2009 Peter Johansson
    99
  • branches/src-highlight/lib/File.cc

    r834 r1100  
    22
    33/*
    4   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2009 Peter Johansson
     4  Copyright (C) 2005, 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2010 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2424
    2525#include "Alias.h"
     26#include "Colors.h"
    2627#include "Configuration.h"
    2728#include "Date.h"
    28 #include "GnuplotFE.h"
     29#include "Graph.h"
    2930#include "html_utility.h"
    3031#include "HtmlStream.h"
     
    4243#include <stdexcept>
    4344#include <string>
     45#include <sstream>
    4446#include <sys/stat.h>
    4547
     
    8284        ++rev_iter;
    8385      }
     86      // do not go beyond BASE rev of file
     87      last_rev_this_year = std::min(last_rev_this_year, last_changed_rev());
     88      last_rev_last_year = std::min(last_rev_last_year, last_changed_rev());
    8489      // loop over authors
    8590      for (std::set<std::string>::const_iterator a_iter=stats.authors().begin();
     
    103108            Alias a(*a_iter,alias.size());
    104109            year_authors[rev_iter->first].insert(a);
    105             std::cerr << "svndigest: warning: no copyright alias found for `"
     110            std::cerr << "svncopyright: warning: no copyright alias found for `"
    106111                      << *a_iter << "'\n";
    107112            // insert alias to avoid multiple warnings.
     
    258263    int first=0;
    259264    bool using_dates=true;
    260     if (GnuplotFE::instance()->dates().empty()){
     265    if (!Graph::date_xticks()) {
    261266      using_dates=false;
    262267      last = stats_["classic"].revision();
    263268    }
    264269    else {
    265       last = Date(GnuplotFE::instance()->dates().back()).seconds();
     270      last = Date(Graph::xticks().back()).seconds();
    266271      // earliest date corresponds either to revision 0 or revision 1
    267       first = std::min(Date(GnuplotFE::instance()->dates()[0]).seconds(),
    268                        Date(GnuplotFE::instance()->dates()[1]).seconds());
     272      first = std::min(Date(Graph::xticks()[0]).seconds(),
     273                       Date(Graph::xticks()[1]).seconds());
    269274    }
    270275    // color is calculated linearly on time, c = kt + m
     
    287292      hs << Date(blame.date())("%d %b %y");
    288293      os << "</font></td>\n<td class=\"author\">";
    289       std::string author_color =
    290         Configuration::instance().author_str_color(blame.author());
    291       if (!author_color.empty())
    292         os << "<font color=\"#" << author_color << "\">";
     294      const std::string& author_color =
     295        Colors::instance().color_str(blame.author());
     296      assert(!author_color.empty());
     297      os << "<font color=\"#" << author_color << "\">";
    293298      hs << blame.author();
    294299      os << "</td>\n<td class=\"";
     
    330335    if (!detect_copyright(old_block, start_line, end_line, prefix)){
    331336      if (Configuration::instance().missing_copyright_warning())
    332         std::cerr << "svndigest: warning: no copyright statement found in `"
     337        std::cerr << "svncopyright: warning: no copyright statement found in `"
    333338                  << path_ << "'\n";
    334339      return;
     
    363368      lpath = "index";
    364369    std::string outpath = stats_type+"/"+user+"/"+line_type+"/"+lpath;
    365     std::string imagefile = stats_type+"/"+"images/"+line_type+"/"+
    366       lpath+".png";
     370    std::string imagefile = stats_type+"/"+"images/"+line_type+"/"+lpath;
    367371    std::string html_name(outpath + ".html");
    368372    std::ofstream os(html_name.c_str());
     
    370374                 stats_type);
    371375    path_anchor(os);
    372     os << "<p class=\"plot\">\n<img src='";
     376
     377    std::stringstream ss;
    373378    for (size_t i=0; i<level_; ++i)
    374       os << "../";
    375     os << "../../../";
     379      ss << "../";
     380    ss << "../../../";
    376381    if (user=="all")
    377       os << stats_[stats_type].plot(imagefile,line_type);
     382      ss << stats_[stats_type].plot(imagefile,line_type);
    378383    else
    379       os << imagefile;
    380     os << "' alt='[plot]' />\n</p>";
     384      ss << imagefile;
     385    os << "<p class=\"plot\">\n";
     386    os << image(ss.str());
     387    os << "</p>\n";
    381388
    382389    print_author_summary(os, stats_[stats_type], line_type, log);
     
    443450    catch (std::runtime_error e) {
    444451      // catch exception, cleanup, and rethrow
    445       std::cerr << "svndigest: File::print_copyright: Exception caught, "
     452      std::cerr << "svncopyright: File::print_copyright: Exception caught, "
    446453                << "removing temporary file " << tmpname << std::endl;
    447454      if (unlink(tmpname))
  • branches/src-highlight/lib/File.h

    r834 r1100  
    55
    66/*
    7   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
     7  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    88  Copyright (C) 2009 Peter Johansson
    99
  • branches/src-highlight/lib/Functor.cc

    r693 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Functor.h

    r727 r1100  
    55
    66/*
    7   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2008 Jari Häkkinen
     7  Copyright (C) 2005 Peter Johansson
     8  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/HtmlBuf.cc

    r693 r1100  
    22
    33/*
    4   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    3333    : std::streambuf(), buf_(buf)
    3434  {
    35     map_['"']=std::string("\"");
     35    map_['"']=std::string("&quot;");
    3636    map_['\'']=std::string("\'");
    3737    map_['\n']=std::string("<br />");
     
    4242    // This should be configurable, but for now indentation is two spaces.
    4343    map_['\t']=std::string("&nbsp;&nbsp;");
    44     map_['å']=std::string("&aring;");
    45     map_['ä']=std::string("&auml;");
    46     map_['ö']=std::string("&ouml;");
    47     map_['Å']=std::string("&Aring;");
    48     map_['Ä']=std::string("&Auml;");
    49     map_['Ö']=std::string("&Ouml;");
    50     map_['é']=std::string("&eacute;");
    51     map_['É']=std::string("&Eacute;");
    52     map_['á']=std::string("&aacute;");
    53     map_['Á']=std::string("&Aacute;");
    5444  }
    5545
  • branches/src-highlight/lib/HtmlBuf.h

    r693 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    99  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/HtmlStream.cc

    r768 r1100  
    22
    33/*
    4   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    65
    76  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/HtmlStream.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    99  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/LineTypeParser.cc

    r693 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4041    : mode_(0), post_copyright_(false), copyright_found_(false)
    4142  {
    42     codon_ = Configuration::instance().codon(path);
     43    codon_ = Configuration::instance().codon(file_name(path));
    4344  }
    4445
  • branches/src-highlight/lib/LineTypeParser.h

    r802 r1100  
    55
    66/*
    7   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2007, 2009 Peter Johansson
     7  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Makefile.am

    r838 r1100  
    44
    55# Copyright (C) 2005 Jari Häkkinen
    6 # Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    7 # Copyright (C) 2007, 2008 Peter Johansson
    8 # Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    9 # Copyright (C) 2009 Peter Johansson
     6# Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     7# Copyright (C) 2010 Peter Johansson
    108#
    119# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2927SUBDIRS = yat .
    3028
    31 AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS)
    32 AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     29AM_CPPFLAGS = $(DEFAULT_CPPFLAGS) $(APR_CPPFLAGS) $(SVN_CPPFLAGS) \
     30  $(PLPLOT_CPPFLAGS)
     31AM_CXXFLAGS = $(DEFAULT_CXXFLAGS)
    3332
    3433noinst_LIBRARIES = libsvndigest.a
    3534
    3635noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h \
    37   Commitment.h Configuration.h copyright_year.h css.h\
     36  Colors.h Commitment.h Configuration.h css.h \
    3837  Date.h Directory.h File.h first_page.h Functor.h \
    39   Gnuplot.h GnuplotFE.h \
     38  Graph.h \
    4039  HtmlBuf.h HtmlStream.h html_utility.h LineTypeParser.h \
    41   Node.h
     40  main_utility.h Node.h \
    4241  OptionVersion.h rmdirhier.h \
    4342  Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h  \
     
    4544
    4645libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \
    47   ClassicStats.cc \
    48   Commitment.cc Configuration.cc copyright_year.cc \
     46  ClassicStats.cc Colors.cc \
     47  Commitment.cc Configuration.cc \
    4948  css.cc Date.cc Directory.cc File.cc first_page.cc\
    50   Functor.cc Gnuplot.cc GnuplotFE.cc  HtmlBuf.cc HtmlStream.cc \
    51   html_utility.cc LineTypeParser.cc Node.cc \
     49  Functor.cc Graph.cc HtmlBuf.cc HtmlStream.cc \
     50  html_utility.cc LineTypeParser.cc main_utility.cc Node.cc \
    5251  OptionVersion.cc \
    5352  rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \
     
    7271  $(srcdir)/subversion_info.cc.in >> $@ ;
    7372
    74 # update copyright year automatically (if we build from svn wc)
    75 $(srcdir)/copyright_year.cc: copyright_year.cc.tmp
    76   @$(MOVE_IF_CHANGE) copyright_year.cc.tmp $@
    77 
    78 copyright_year.cc.tmp: FORCE
    79   @if (echo $(SVN_REVISION) | $(GREP) M); then \
    80     $(SED) -e 's/"20[0-9][0-9]"/'\"`date -u "+%Y"`\"'/g' \
    81       $(srcdir)/copyright_year.cc > $@ ; \
    82   else \
    83     cp $(srcdir)/copyright_year.cc $@; \
    84   fi
    85 
    8673else
    8774# this is needed in 'svn export' build
  • branches/src-highlight/lib/Node.cc

    r834 r1100  
    22
    33/*
    4   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008 Jari Häkkinen
     4  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    65  Copyright (C) 2009 Peter Johansson
    76
  • branches/src-highlight/lib/Node.h

    r834 r1100  
    55
    66/*
    7   Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
     7  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    88  Copyright (C) 2009 Peter Johansson
     9  Copyright (C) 2010 Jari Häkkinen
    910
    1011  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    208209
    209210    unsigned int level_;
    210     std::string local_path_; // path from root
    211211    std::string output_dir_;
    212212    std::string path_; // absolute path
     
    235235    bool binary_;
    236236    bool link_;
     237    std::string local_path_; // path from root
    237238    mutable SVNlog* log_;
    238239    bool svndigest_ignore_;
  • branches/src-highlight/lib/OptionVersion.cc

    r795 r1100  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2008, 2009, 2010 Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2222#include <config.h>
    2323
    24 #include "copyright_year.h"
    2524#include "OptionVersion.h"
    2625#include "subversion_info.h"
     
    3433#include <apr_version.h>
    3534
     35#include <cstdlib>
     36#include <iostream>
    3637#include <sstream>
    3738#include <string>
     
    5253    yat::utility::ColumnStream cs(std::cout, 1);
    5354    cs.width(0)=79;
    54     cs << PACKAGE_NAME << " " << PACKAGE_VERSION;
     55    cs << prog_name_ << " " << PACKAGE_VERSION;
    5556    bool no_verbose = verbose_ && verbose_->present() && !verbose_->value();
    5657    if (!no_verbose) {
     
    6162         << ")";
    6263    }
    63     cs << "\n\nCopyright (C) " << svn_year()
     64    cs << "\n\nCopyright (C) " << RELEASE_YEAR
    6465       << " Jari H\u00E4kkinen and Peter Johansson.\n"
    6566       << "This is free software. You may redistribute copies of it under "
     
    7879      cs << apr_version_string();
    7980      cs << "\n";
     81      cs << extra_;
    8082    }
    81     exit(0);
     83    exit(EXIT_SUCCESS);
     84  }
     85
     86
     87  void OptionVersion::extra(const std::string& str)
     88  {
     89    extra_ = str;
     90  }
     91
     92
     93  void OptionVersion::program_name(const std::string& str)
     94  {
     95    prog_name_ = str;
    8296  }
    8397
  • branches/src-highlight/lib/OptionVersion.h

    r795 r1100  
    55
    66/*
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2008, 2009, 2010 Peter Johansson
    88
    9   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    1010
    1111  svndigest is free software; you can redistribute it and/or modify it
     
    5757                  OptionSwitch* const verbose=NULL);
    5858
     59    /**
     60       add extra string appended to output
     61     */
     62    void extra(const std::string&);
     63
     64    /**
     65       set program name
     66     */
     67    void program_name(const std::string&);
     68
     69    /**
     70       \brief set version string
     71    */
     72    void version(const std::string&);
     73
    5974  private:
    6075    OptionSwitch* const verbose_;
    61 
     76    std::string extra_;
     77    std::string prog_name_;
    6278
    6379    /**
  • branches/src-highlight/lib/SVN.cc

    r693 r1100  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2008 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    76
    87  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVN.h

    r800 r1100  
    66/*
    77  Copyright (C) 2006 Jari Häkkinen
    8   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2008 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     9  Copyright (C) 2009 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVNblame.cc

    r768 r1100  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2008 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    76
    87  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVNblame.h

    r768 r1100  
    66/*
    77  Copyright (C) 2006 Jari Häkkinen
    8   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2008 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    109
    1110  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVNinfo.cc

    r768 r1100  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2008 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    76
    87  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVNinfo.h

    r768 r1100  
    66/*
    77  Copyright (C) 2006 Jari Häkkinen
    8   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2008 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    109
    1110  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    109108    /// @see Subversion API documentation
    110109    ///
    111     // The return type should be svn_log_message_receiver_t but I
    112     // cannot get it to compile (see comment for log_message_receiver
    113     // in SVNlog.h)
    114110    static svn_error_t * info_receiver(void *baton, const char *path,
    115111                                       const svn_info_t *info, apr_pool_t *pool);
  • branches/src-highlight/lib/SVNlog.cc

    r768 r1100  
    33/*
    44  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVNlog.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    126126       \see Subversion API documentation
    127127    */
    128     // The return type should be svn_log_message_receiver_t but I
    129     // cannot get it to compile. The svn API has a typedef like
    130     // typedef svn_error_t*(* svn_log_message_receiver_t)(void *baton,
    131     // apr_hash_t *changed_paths, svn_revnum_t revision, const char
    132     // *author, const char *date,const char *message, apr_pool_t
    133     // *pool) for svn_log_message_receiver_t.
    134128    static svn_error_t*
    135129    log_message_receiver(void *baton, apr_hash_t *changed_paths,
  • branches/src-highlight/lib/SVNproperty.cc

    r768 r1100  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen
    5   Copyright (C) 2007, 2008 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/SVNproperty.h

    r768 r1100  
    66/*
    77  Copyright (C) 2006 Jari Häkkinen
    8   Copyright (C) 2007, 2008 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Stats.cc

    r803 r1100  
    33/*
    44  Copyright (C) 2005 Peter Johansson
    5   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2008, 2009 Peter Johansson
     5  Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2010 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2424#include "Stats.h"
    2525
     26#include "Colors.h"
     27#include "Configuration.h"
    2628#include "Functor.h"
    27 #include "GnuplotFE.h"
     29#include "Graph.h"
    2830#include "SVNblame.h"
    2931#include "SVNinfo.h"
     
    278280    std::string str;
    279281    getline(is, str);
    280     if (str!=cache_check_str())
     282    if (str!=cache_check_str()) {
     283      if (str == prev_cache_check_str())
     284        std::cout << "cache file is obsolete; "
     285                  << "retrieving statistics from repository.\n";
    281286      return 0;
     287    }
    282288    svn_revnum_t rev;
    283289    is >> rev;
     
    331337
    332338
     339  unsigned int Stats::max_element(const std::vector<unsigned int>& vec) const
     340  {
     341    return *std::max_element(vec.begin(), vec.end());
     342  }
     343
     344
    333345  void Stats::parse(const std::string& path, svn_revnum_t rev)
    334346  {
     
    349361  }
    350362
     363
    351364  std::string Stats::plot(const std::string& filename,
    352365                          const std::string& linetype) const
    353366  {
     367    const std::string& format = Configuration::instance().image_format();
     368    if (format=="none")
     369      return filename;
     370    plot(filename, linetype, format);
     371    const std::string& anchor_format =
     372      Configuration::instance().image_anchor_format();
     373
     374    if (format!=anchor_format)
     375      plot(filename, linetype, anchor_format);
     376    return filename;
     377  }
     378
     379
     380  void Stats::plot(const std::string& filename,
     381                   const std::string& linetype,
     382                   const std::string& format) const
     383  {
    354384    assert(total_stats().size());
    355     plot_init(filename);
    356     GnuplotFE* gp=GnuplotFE::instance();
     385    Graph gp(filename+"."+format, format);
    357386    const Author2Vector* stat=NULL;
    358387    if (linetype=="total")
     
    368397    assert(stat->find("all")!=stat->end());
    369398    std::vector<unsigned int> total=get_vector(*stat, "all");   
    370     double yrange_max=1.03*total.back()+1;
    371     gp->yrange(yrange_max);
     399    double yrange_max=1.03 * max_element(total) +1.0;
     400    gp.ymax(yrange_max);
    372401
    373402    typedef std::vector<std::pair<std::string, std::vector<unsigned int> > > vec_type;
     
    376405    for (std::set<std::string>::const_iterator i=authors_.begin();
    377406         i != authors_.end(); ++i) {
    378       if (lines(*i)) {
    379         assert(stat->find(*i)!=stat->end());
    380         author_cont.push_back(std::make_pair(*i,get_vector(*stat,*i)));
     407      assert(stat->find(*i)!=stat->end());
     408      const std::vector<unsigned int>& vec = get_vector(*stat,*i);
     409      if (max_element(vec)) {
     410        author_cont.push_back(std::make_pair(*i,vec));
    381411      }
    382412    }
     
    387417    std::sort(author_cont.begin(), author_cont.end(), compare);
    388418
    389     size_t plotno=author_cont.size();
    390     std::stringstream ss;
    391419    vec_type::iterator end(author_cont.end());
    392     for (vec_type::iterator i(author_cont.begin()); i!=end; ++i) {
    393       ss.str("");
    394       ss << "set key height " << 2*plotno;
    395       gp->command(ss.str());
    396       ss.str("");
    397       ss << get_back(*stat, i->first) << " " << i->first;
    398       gp->yrange(yrange_max);
    399       gp->linetitle(ss.str());
    400       ss.str("");
    401       ss << "steps " << --plotno+2;
    402       gp->linestyle(ss.str());
    403       gp->plot(i->second);
    404     }
    405     ss.str("");
    406     ss << get_back(*stat, "all") << " total";
    407     gp->command("set key height 0");
    408     gp->linetitle(ss.str());
    409     gp->linestyle("steps 1");
    410     gp->plot(total);
    411 
    412     gp->command("unset multiplot");
    413     gp->yrange();
    414 
    415     return filename;
    416   }
    417 
    418 
    419   void Stats::plot_init(const std::string& filename) const
    420   {
    421     GnuplotFE* gp=GnuplotFE::instance();
    422     gp->command("set term png");
    423     gp->command("set output '"+filename+"'");
    424     gp->command("set xtics nomirror");
    425     gp->command("set ytics nomirror");
    426     gp->command("set key default");
    427     gp->command("set key left Left reverse");
    428     gp->command("set multiplot");
     420    vec_type::iterator i(author_cont.begin());
     421    const vec_type::size_type maxauthors=8;
     422    int authskip=author_cont.size()-maxauthors;
     423    if (authskip>1) {
     424      // only use others if there is more than 1 author to be skipped,
     425      // there is no reason to add only 1 author to others.
     426      vec_type::iterator j(i);
     427      i+=authskip;
     428      std::vector<unsigned int> init(revision()+1);
     429      std::vector<unsigned int> others =
     430        std::accumulate(j, i, init, PairValuePlus<std::string,unsigned int>());
     431      unsigned char r, g, b;
     432      std::string label("others");
     433      Colors::instance().get_color(label, r,g,b);
     434      gp.current_color(r,g,b);
     435      gp.plot(others, label, others.back());
     436    }
     437    for ( ; i!=end; ++i) {
     438      unsigned char r, g, b;
     439      Colors::instance().get_color(i->first,r,g,b);
     440      gp.current_color(r,g,b);
     441      gp.plot(i->second, i->first, get_back(*stat, i->first));
     442    }
     443    gp.current_color(255,0,0);
     444    gp.plot(total, "total", get_back(*stat, "all"));
    429445  }
    430446
     
    432448  void Stats::plot_summary(const std::string& filename) const
    433449  {
    434     plot_init(filename);
    435     GnuplotFE* gp=GnuplotFE::instance();
     450    const std::string& format = Configuration::instance().image_format();
     451    if (format=="none")
     452      return;
     453    plot_summary(filename, format);
     454    const std::string& anchor_format =
     455      Configuration::instance().image_anchor_format();
     456
     457    if (format!=anchor_format)
     458      plot_summary(filename, anchor_format);
     459  }
     460
     461
     462  void Stats::plot_summary(const std::string& filename,
     463                           const std::string& format) const
     464  {
     465    Graph gp(filename+"."+format, format);
    436466    std::vector<unsigned int> total = get_vector(total_stats(), "all");
    437467    double yrange_max=1.03*total.back()+1;
    438     gp->yrange(yrange_max);
    439     std::stringstream ss;
     468    gp.ymax(yrange_max);
    440469   
    441     ss.str("");
    442470    std::vector<unsigned int> x(get_vector(code_stats(), "all"));
    443     ss << x.back() << " code";
    444     gp->command("set key height 2");
    445     gp->linetitle(ss.str());
    446     gp->linestyle("steps 2");
    447     gp->plot(x);
    448 
    449     ss.str("");
     471    gp.current_color(255,255,0);
     472    gp.plot(x, "code", x.back());
     473
    450474    x = get_vector(comment_or_copy_stats(), "all");
    451     ss << x.back() << " comment";
    452     gp->command("set key height 4");
    453     gp->linetitle(ss.str());
    454     gp->linestyle("steps 3");
    455     gp->plot(x);
    456 
    457     ss.str("");
     475    gp.current_color(0,0,255);
     476    gp.plot(x, "comment", x.back());
     477
    458478    x = get_vector(other_stats(), "all");
    459     ss << x.back() << " other";
    460     gp->command("set key height 6");
    461     gp->linetitle(ss.str());
    462     gp->linestyle("steps 4");
    463     gp->plot(x);
    464 
    465     ss.str("");
    466     ss << total.back() << " total";
    467     gp->command("set key height 0");
    468     gp->linetitle(ss.str());
    469     gp->linestyle("steps 1");
    470     gp->plot(total);
    471 
    472     gp->command("unset multiplot");
    473     gp->yrange();
     479    gp.current_color(0,255,0);
     480    gp.plot(x, "other", x.back());
     481
     482    gp.current_color(255,0,0);
     483    gp.plot(total, "total", total.back());
    474484  }
    475485
  • branches/src-highlight/lib/Stats.h

    r768 r1100  
    66/*
    77  Copyright (C) 2005 Peter Johansson
    8   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2007, 2008 Peter Johansson
     8  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     9  Copyright (C) 2010 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    192192                 Author2Vector& map);
    193193
    194     ///
    195     /// Init statistics graph.
    196     ///
    197     void plot_init(const std::string& output) const;
    198 
    199194    std::set<std::string> authors_;
    200195
     
    221216    virtual void do_parse(const std::string&, svn_revnum_t first_rev)=0;
    222217   
     218    /**
     219       called from plot(2)
     220     */
     221    void plot(const std::string& basename, const std::string& linetype,
     222              const std::string& format) const;
     223
     224    /**
     225       called from plot_summary(1)
     226     */
     227    void plot_summary(const std::string& basename,
     228                      const std::string& format) const;
     229
    223230    // Change this string if cache format is changed in such a way
    224231    // that all old cache files are obsolete.
    225232    inline std::string cache_check_str(void) const
     233    {return "CACHE FILE VERSION 7";}
     234
     235    inline std::string prev_cache_check_str(void) const
    226236    {return "CACHE FILE VERSION 6";}
    227237
     
    231241    unsigned int get_back(const Author2Vector&, std::string user) const;
    232242    void load(std::istream& is, Author2Vector& m);
     243    /**
     244       Finds the largets element by iterating through the entire
     245       vector. Inherited classes should implement their own version
     246       when it is possible to get the largest element in faster than
     247       in linear time.
     248
     249       \return the largest largest element in \a v.
     250    */
     251    virtual unsigned int max_element(const std::vector<unsigned int>& v) const;
     252
    233253    void print(std::ostream& os, const Author2Vector& m) const;
    234254
  • branches/src-highlight/lib/StatsCollection.cc

    r803 r1100  
    33/*
    44  Copyright (C) 2007 Peter Johansson
     5  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    57
    68  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4951  StatsCollection::~StatsCollection(void)
    5052  {
    51     for (map::const_iterator i(stats_.begin()); i!=stats_.end(); ++i) {
     53    for (map::iterator i(stats_.begin()); i!=stats_.end(); ++i) {
    5254      assert(i->second);
    5355      delete i->second;
     56      i->second = NULL;
    5457    }
    55 
    5658  }
    5759
  • branches/src-highlight/lib/StatsCollection.h

    r801 r1100  
    55
    66/*
    7   Copyright (C) 2005 Peter Johansson
    8   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    97  Copyright (C) 2007 Peter Johansson
     8  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     9  Copyright (C) 2010 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    8787
    8888  private:
     89    // copy not allowed
     90    StatsCollection(const StatsCollection&);
     91    StatsCollection& operator=(const StatsCollection&);
     92
    8993    const std::string path_;
    9094    typedef std::map<std::string, Stats*> map;
  • branches/src-highlight/lib/Trac.cc

    r768 r1100  
    22
    33/*
    4   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/Trac.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008, 2009 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/css.cc

    r832 r1100  
    33/*
    44  Copyright (C) 2006 Peter Johansson
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    3737
    3838      << "Copyright (C) 2006 Peter Johansson\n"
    39       << "Copyright (C) 2007 Jari Häkkinen, Peter Johansson\n"
     39      << "Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson\n"
    4040      << "Copyright (C) 2009 Peter Johansson\n"
    4141      << "\nThis file is part of svndigest, "
     
    146146    s << " padding: 0 1em .1em 0;\n";
    147147    s << "}\n\n";
    148 
     148    s << "div.main img { border: 0; }\n";
    149149
    150150    s << "p.plot { text-align: center; }\n";
  • branches/src-highlight/lib/css.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2006, 2007, 2008 Peter Johansson
     7  Copyright (C) 2006 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/first_page.cc

    r759 r1100  
    33/*
    44  Copyright (C) 2006 Peter Johansson
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009 Peter Johansson
     5  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2010 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    9393       << "</th></tr></thead>\n"
    9494       << "<tbody>\n"
    95        << "<tr><td>URL:</td><td>"
    96        << url << "</td></tr>\n"
     95       << "<tr><td>URL:</td><td>";
     96    if (url.size()>=4 && url.substr(0,4)=="http")
     97      os << anchor(url, url);
     98    else
     99      os << url;
     100    os << "</td></tr>\n"
    97101       << "<tr><td>First Revision Date:</td><td>"
    98102       << begin(timefmt) << "</td></tr>\n"
     
    149153         << 100*stats.comments(i->author())/(stats.comments()?stats.comments():1)
    150154         << "%)</td><td>";
    151       hs << Date(i->date())(timefmt);
     155      std::string date = Date(i->date())(timefmt);
     156      const Configuration& conf = Configuration::instance();
     157      if (conf.trac_root().empty())
     158        hs << date;
     159      else {
     160        std::stringstream url;
     161        url << conf.trac_root() << "changeset/" << i->revision();
     162        os << anchor(url.str(), date);
     163      }
    152164      os << "</td>" <<"</tr>";
    153165    }
     
    226238  void print_summary_plot(std::ostream& os, const Stats& stats)
    227239  {
    228     std::string name("summary_plot.png");
     240    std::string name("summary_plot");
    229241    stats.plot_summary(name);
    230242    os << "<div class=\"main\">\n";
    231     os << "<img src='" << name << "' alt='[plot]'/>";
     243    os << image(name);
    232244    os << "</div>";
     245
     246
    233247  }
    234248
  • branches/src-highlight/lib/first_page.h

    r768 r1100  
    55
    66/*
    7   Copyright (C) 2006, 2007, 2008 Peter Johansson
     7  Copyright (C) 2006 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/html_utility.cc

    r751 r1100  
    33/*
    44  Copyright (C) 2006 Peter Johansson
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2009, 2010 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    3131#include "subversion_info.h"
    3232
     33#include <cassert>
    3334#include <sstream>
    3435#include <string>
     
    6162
    6263 
     64  std::string image(const std::string& name)
     65  {
     66    std::ostringstream os;
     67    const std::string& format = Configuration::instance().image_format();
     68    const std::string& anchor_format =
     69      Configuration::instance().image_anchor_format();
     70    if (format=="svg") {
     71      os << "<object data='" << name << ".svg' type='image/svg+xml'"
     72         << " width='600'>\n"
     73         << "<embed src='" << name << ".svg' type='image/svg+xml'"
     74         << " width='600' />\n"
     75         << "</object>\n";
     76      if (anchor_format != "svg")
     77        std::cerr << "svndigest: anchor_format: " << anchor_format
     78                  << " not supported with format " << format << "\n";
     79    }
     80    else if (format=="png") {
     81      if (anchor_format=="none")
     82        os << "<img src='" << name << ".png' alt='[plot]'/>";
     83      else
     84        os << "<a href=\"" << name << "." << anchor_format << "\">"
     85           << "<img src='" << name << ".png' alt='[plot]'/>"
     86           << "</a>";
     87    }
     88    else if (format=="none")
     89      os << "<!-- no images -->";
     90    else {
     91      assert(false);
     92      throw std::runtime_error("unknown image format: " + format);
     93    }
     94    return os.str();
     95  }
     96
     97
    6398  void print_footer(std::ostream& os)
    6499  {
     
    67102    os << "<p class=\"footer\">\nGenerated on ";
    68103    hs << date("%a %b %e %H:%M:%S %Y") << " (UTC) by ";
    69     os << anchor("http://dev.thep.lu.se/svndigest/",
    70                  PACKAGE_STRING, 0, "");
     104    os << anchor(PACKAGE_URL, PACKAGE_STRING, 0, "");
    71105    if (DEV_BUILD)
    72106      os << " (dev build " << svn_revision() << ")";
     
    179213       << "<head>\n"
    180214       << "<title> " << title << " - svndigest</title>\n"
     215       << "<meta http-equiv=\"Content-type\" content=\"text/html; "
     216       << "charset=UTF-8\" />\n"
    181217       << "<link rel=\"stylesheet\" "
    182218       << "href=\"";
  • branches/src-highlight/lib/html_utility.h

    r768 r1100  
    77  Copyright (C) 2006 Peter Johansson
    88  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2008 Peter Johansson
     9  Copyright (C) 2009, 2010 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4747                     const std::string& title="",
    4848                     const std::string& color="");
     49
     50  /**
     51   */
     52  std::string image(const std::string& name);
    4953
    5054  ///
  • branches/src-highlight/lib/rmdirhier.cc

    r823 r1100  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen
    5   Copyright (C) 2007, 2008 Peter Johansson
     5  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     6  Copyright (C) 2010 Peter Johansson
    67
    78  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    7879      return;
    7980    }
    80     if (chdir(dir.c_str()))
     81    if (::chdir(dir.c_str()))
    8182      throw BadDirectory(concatenate_path(pwd(),dir));
    8283
  • branches/src-highlight/lib/rmdirhier.h

    r768 r1100  
    66/*
    77  Copyright (C) 2006 Jari Häkkinen
    8   Copyright (C) 2007, 2008 Peter Johansson
     8  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/subversion_info.cc.in

    r726 r1100  
    22
    33/*
    4   Copyright (C) 2008 Peter Johansson
     4  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/subversion_info.h

    r726 r1100  
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2007 Peter Johansson
     8  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/utility.cc

    r797 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007, 2009 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2010 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2525#include "subversion_info.h"
    2626#include "config.h"
     27
     28#include "yat/Exception.h"
    2729
    2830#include <cassert>
     
    3133#include <cstdlib>
    3234#include <cstring>
     35#include <fnmatch.h>
    3336#include <fstream>
    3437#include <sstream>
     
    6770
    6871
     72  void chdir(const std::string& dir)
     73  {
     74    if (::chdir(dir.c_str()) )
     75      throw yat::utility::errno_error("chdir: " + dir + ":");
     76  }
     77
     78
    6979  std::string concatenate_path(std::string dir, std::string base)
    7080  {
     
    107117
    108118
    109   bool equal(std::string::const_iterator first1,
    110              std::string::const_iterator end1,
    111              std::string::const_iterator first2,
    112              std::string::const_iterator end2)
    113   {
    114     if (first1==end1 && first2==end2)
    115       return true;
    116     if (first1!=end1 && first2!=end2 &&
    117         (*first1==*first2 || *first1=='*' || *first2=='*' ||
    118          *first1=='?' || *first2=='?') &&
    119         equal(first1+1, end1, first2+1, end2) )
    120       return true;
    121     if ( (first1!=end1 && first2!=end2 && (*first1=='*'|| *first2=='*') ) &&
    122          (equal(first1+1, end1, first2, end2) ||
    123           equal(first1, end1, first2+1, end2))
    124          )
    125       return true;
    126     return false;
    127   }
    128 
    129 
    130119  std::string file_name(const std::string& full_path)
    131120  {
     
    167156
    168157
     158  bool fnmatch(const std::string& pattern, const std::string& str)
     159  {
     160    int res = ::fnmatch(pattern.c_str(), str.c_str(), 0);
     161    if (res==0)
     162      return true;
     163    if (res!=FNM_NOMATCH) {
     164      std::stringstream ss;
     165      ss << "fnmatch with args: " << pattern << ", " << str;
     166      throw std::runtime_error(ss.str());
     167    }                     
     168    return false;
     169  }
     170
     171
    169172  std::string ltrim(std::string str)
    170173  {
     
    220223
    221224
    222   bool regexp(std::string::const_iterator first1,
    223               std::string::const_iterator last1,
    224               std::string::const_iterator first2,
    225               std::string::const_iterator last2,
     225  bool regexp(const std::string& pattern, const std::string& str,
    226226              std::vector<std::string>& vec)
    227227  {
    228     if (vec.empty())
    229       vec.push_back("");
    230 
    231     // first two cases when ranges are empty
    232     if (first1==last1 && first2==last2){
    233       vec.pop_back();
    234       return true;
    235     }
     228    bool regexp__(std::string::const_iterator first1,
     229                  std::string::const_iterator last1,
     230                  std::string::const_iterator first2,
     231                  std::string::const_iterator last2,
     232                  std::vector<std::string>::iterator item);
     233   
     234    // find number of special chars
     235    size_t count=0;
     236    for (std::string::const_iterator i=pattern.begin(); i!=pattern.end(); ++i)
     237      if (*i=='*' || *i=='?' || *i=='[')
     238        ++count;
     239    vec.resize(count);
     240    return regexp__(pattern.begin(), pattern.end(), str.begin(), str.end(),
     241                    vec.begin());
     242  }
     243
     244  bool regexp__(std::string::const_iterator first1,
     245                std::string::const_iterator last1,
     246                std::string::const_iterator first2,
     247                std::string::const_iterator last2,
     248                std::vector<std::string>::iterator item)
     249  {
     250    if (first1==last1) {
     251      return first2==last2;
     252    }
     253    if (*first1 == '*') {
     254      if (first2<last2) {
     255        item->push_back(*first2);
     256        if (regexp__(first1, last1, first2+1, last2, item))
     257          return true;
     258        item->resize(item->size()-1);
     259      }
     260      return regexp__(first1+1, last1, first2, last2, item+1);
     261    }
     262    if (*first1 == '?') {
     263      if (first2==last2)
     264        return false;
     265      *item = *first2;
     266      return regexp__(first1+1, last1, first2+1, last2, item+1);
     267    }
     268    if (*first1 == '[') {
     269      if (first2==last2)
     270        return false;
     271      bool found = false;
     272      while (*first1 != ']') {
     273        if (*first1 == *first2) {
     274          found = true;
     275          *item = *first2;
     276        }
     277        ++first1;
     278        assert(first1!=last1);
     279      }
     280      return regexp__(first1+1, last1, first2+1, last2, item+1);
     281      /*
     282      while (*first2 != ']') {
     283        if (*first2==*first1) {
     284          found = true;
     285          vec.back() = *first1;
     286          vec.push_back("");
     287        }
     288        ++first2;
     289        assert(first2!=last2);
     290      }
     291      if (!found)
     292        return false;
     293      return regexp(first1+1, last1, first2+1, last2, vec);
     294      */
     295    }
     296
     297    if (first2==last2)
     298      return false;
     299    if (*first1 != *first2)
     300      return false;
     301    return regexp__(first1+1, last1, first2+1, last2, item);
     302
     303    /*
     304
     305
     306
     307    if (first1==last1)
     308      return false;
     309    if (*first1 != *first2)
     310      return false;
     311    return regexp(first1+1, last1, first2+1, last2, vec);
     312   
     313    /// hm
    236314    if (first1==last1 || first2==last2)
    237315      return false;
     
    271349      return false;
    272350    return regexp(++first1, last1, ++first2, last2, vec);
     351    */
    273352  }
    274353
  • branches/src-highlight/lib/utility.h

    r796 r1100  
    77  Copyright (C) 2005 Peter Johansson
    88  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2009 Peter Johansson
     9  Copyright (C) 2009, 2010 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    5757
    5858  /**
     59     wrapper around GNU C Library function chdir
     60
     61     \throw if underlying chdir call does not return 0
     62   */
     63  void chdir(const std::string& dir);
     64
     65  /**
    5966     \return dir+base if dir ends with '/', else dir+'/'+base
    6067   */
     
    7885  std::string directory_name(std::string path);
    7986
    80   /**
    81      Function to compare strings. Strings may contain '*'.
    82 
    83      \return true if \a a and \a b are identical.
    84    */
    85   bool equal(std::string::const_iterator first1,
    86              std::string::const_iterator end1,
    87              std::string::const_iterator first2,
    88              std::string::const_iterator end2);
    89 
    9087  ///
    9188  /// @return everything after last '/'
    9289  ///
    9390  std::string file_name(const std::string&);
     91
     92  /**
     93     \return true if \a str matches \a pattern
     94
     95     \see fnmatch(3)
     96   */
     97  bool fnmatch(const std::string& pattern, const std::string& str);
    9498
    9599  ///
     
    161165
    162166  /**
    163      \return true if first range match second range
    164 
    165      Second range may contain wildcards (such as '*' and '?'), in
    166      which case vector \a vec is filled with the corresponding strings
    167      in first range. The algorithm is greedy, i.e., wildcard * is will
     167     \return true if \a str matches \a pattern
     168
     169     \a pattern may contain wildcards '*', '?' and \a vec will contain
     170     the matching string in \a str. If it's not a match, \a vec is
     171     undefined. The algorithm is greedy, i.e., wildcards '*' will
    168172     consume as many charcters as possible.
    169173
    170174     \note \a vec is supposed to be empty
    171175   */
    172   bool regexp(std::string::const_iterator first1,
    173               std::string::const_iterator end1,
    174               std::string::const_iterator first2,
    175               std::string::const_iterator end2,
     176  bool regexp(const std::string& pattern, const std::string& str,
    176177              std::vector<std::string>& vec);
    177178
  • branches/src-highlight/lib/yat/ColumnStream.cc

    r795 r1100  
    1 // $Id: ColumnStream.cc 1797 2009-02-12 18:07:10Z peter $
     1// $Id: ColumnStream.cc 2119 2009-12-12 23:11:43Z peter $
    22
    33/*
  • branches/src-highlight/lib/yat/ColumnStream.h

    r795 r1100  
    22#define _theplu_yat__utility_column_stream_
    33
    4 // $Id: ColumnStream.h 1887 2009-03-31 17:38:16Z peter $
     4// $Id: ColumnStream.h 2119 2009-12-12 23:11:43Z peter $
    55
    66/*
     
    2424*/
    2525#include <fstream>
    26 #include <iostream>
     26#include <iosfwd>
    2727#include <sstream>
    2828#include <vector>
  • branches/src-highlight/lib/yat/CommandLine.cc

    r824 r1100  
    1 // $Id: CommandLine.cc 2046 2009-09-02 21:42:32Z peter $
     1// $Id: CommandLine.cc 2265 2010-06-05 23:12:10Z peter $
    22
    33/*
     
    55  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    66  Copyright (C) 2009 Peter Johansson
     7  Copyright (C) 2010 Jari Häkkinen, Peter Johansson
    78
    89  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3132
    3233#include <algorithm>
     34#include <cassert>
    3335#include <functional>
    3436#include <fstream>
     
    6062        ss << "yat::utility::Commandline: two options with long_name: "
    6163           << option.long_name();
    62         throw std::runtime_error(ss.str());
     64        throw runtime_error(ss.str());
    6365      }
    6466      long_options_[option.long_name()] = &option;
     
    6971        ss << "yat::utility::Commandline: two options with short_name: "
    7072           << option.short_name();
    71         throw std::runtime_error(ss.str());
     73        throw runtime_error(ss.str());
    7274      }
    7375      short_options_[option.short_name()] = &option;
     
    196198
    197199
     200  void CommandLine::sort(void)
     201  {
     202    sort(OptionCompare());
     203  }
     204
     205
    198206  std::vector<std::string> CommandLine::split(std::string str, char del) const
    199207  {
     
    236244
    237245
     246  bool CommandLine::OptionCompare::operator()(const Option* lhs,
     247                                              const Option* rhs) const
     248  {
     249    assert(lhs);
     250    assert(rhs);
     251    std::string lhs_str = lhs->long_name();
     252    if (lhs_str.empty())
     253      lhs_str = lhs->short_name();
     254    std::string rhs_str = rhs->long_name();
     255    if (rhs_str.empty())
     256      rhs_str = rhs->short_name();
     257    return lhs_str < rhs_str;
     258  }
     259
     260
    238261}}} // of namespace utility, yat, and theplu
  • branches/src-highlight/lib/yat/CommandLine.h

    r824 r1100  
    22#define _theplu_yat_utility_commandline_
    33
    4 //$Id: CommandLine.h 2054 2009-09-06 18:25:06Z peter $
     4//$Id: CommandLine.h 2265 2010-06-05 23:12:10Z peter $
    55
    66/*
    7   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     7  Copyright (C) 2007, 2008, 2009, 2010 Jari Häkkinen, Peter Johansson
    98
    109  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2423*/
    2524
     25#include <algorithm>
    2626#include <cctype>
    2727#include <map>
     
    158158
    159159    /**
     160       \brief Sort Options how they will appear in (help) output.
     161
     162       This function will sort the Options in alphabetical order. If
     163       the Option has a long_name, it is used for the sorting;
     164       otherwise, the short_name is used.
     165
     166       \since New in yat 0.7
     167     */
     168    void sort(void);
     169
     170    /**
     171       Like sort(void) but using \a compare to sort Options.
     172
     173       The functor Compare must be a <a
     174       href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary
     175       Function</a> with both argument types \c const \c Option* and
     176       return type \c bool.
     177
     178       \since New in yat 0.7
     179     */
     180    template<class Compare>
     181    void sort(Compare compare);
     182
     183    /**
    160184       \return something like "Try `<program_name()> --help` for
    161185       more information."
     
    165189  private:
    166190    friend std::ostream& operator<<(std::ostream& os, const CommandLine& cl);
    167     void add_private(std::string, Option&);
    168191    bool is_long_option(std::string str) const;
    169192    bool is_short_option(std::string str) const;
     
    178201    bool parsed_;
    179202    std::string program_name_;
     203
     204    struct OptionCompare
     205    {
     206      bool operator()(const Option*, const Option*) const;
     207    };
     208
    180209  };
    181210
     
    200229  std::ostream& operator<<(std::ostream&, const CommandLine&);
    201230
     231  template<class Compare>
     232  void CommandLine::sort(Compare compare)
     233  {
     234    std::sort(options_.begin(), options_.end(), compare);
     235  }
     236
    202237}}} // end of namespace utility, yat, and theplu
    203238
  • branches/src-highlight/lib/yat/Exception.h

    r795 r1100  
    22#define _theplu_yat_utility_exception_
    33
    4 // $Id: Exception.h 1797 2009-02-12 18:07:10Z peter $
     4// $Id: Exception.h 2210 2010-03-05 22:59:01Z peter $
    55
    66/*
    77  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2010 Peter Johansson
    89
    910  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3031namespace utility {
    3132
     33 
     34
     35  /**
     36     \brief Class used for all runtime error detected within yat library.
     37   */
     38  class runtime_error : public std::runtime_error
     39  {
     40  public:
     41    /**
     42       \brief Constructor
     43
     44       \param message message to be displayed using function what().
     45     */
     46    runtime_error(std::string message);
     47  };
     48
     49
    3250  /**
    3351     \brief Class used for error reported from Commandline or Option.
     
    4159       \param message message to be displayed using function what().
    4260     */
    43     inline cmd_error(std::string message)
    44       : std::runtime_error(message) {}
     61    cmd_error(std::string message);
     62  };
     63
     64
     65  /**
     66     \brief Class that contains information reported bia global
     67     variable errno.
     68   */
     69  class errno_error : public std::runtime_error
     70  {
     71  public:
     72    /**
     73       The error message, return from what(), is set to
     74       \a message + strerror(errno)
     75     */
     76    errno_error(std::string message);
     77  };
     78
     79  /**
     80     \brief Class for errors reported from underlying GSL calls.
     81
     82     GSL_error is used in the same way as C++ standard library
     83     exceptions.
     84  */
     85  class GSL_error : public std::runtime_error
     86  {
     87  public:
     88    /**
     89       \brief Constructor to create an exception with a message.
     90    */
     91    GSL_error(std::string message);
     92
     93    /**
     94       \brief Constructor to create an exception with a message
     95       containg the GSL error description.
     96    */
     97    GSL_error(std::string message, int gsl_status);
    4598  };
    4699
     
    58111       \brief Constructor to create an exception with a message.
    59112    */
    60     inline IO_error(std::string message) throw()
    61       : std::runtime_error("IO_error: " + message) {}
     113    IO_error(std::string message);
    62114  };
    63115
  • branches/src-highlight/lib/yat/Makefile.am

    r795 r1100  
    33## $Id$
    44
    5 # Copyright (C) 2009 Peter Johansson
     5# Copyright (C) 2009, 2010 Peter Johansson
    66#
    77# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2222MOVE_IF_CHANGE = $(SHELL) $(abs_top_srcdir)/build_support/move-if-change
    2323
    24 AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS)
    25 AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     24AM_CPPFLAGS = $(DEFAULT_CPPFLAGS)
     25AM_CXXFLAGS = $(DEFAULT_CXXFLAGS)
    2626
    2727noinst_LIBRARIES = libyat.a
     
    4242libyat_a_SOURCES += ColumnStream.cc
    4343libyat_a_SOURCES += CommandLine.cc
     44libyat_a_SOURCES += Exception.cc
    4445libyat_a_SOURCES += Option.cc
    4546libyat_a_SOURCES += OptionHelp.cc
     
    5758  test -d Fetchdir || $(SVN) co $(yat_url) Fetchdir
    5859  (cd Fetchdir && $(SVN) revert -Rq . && $(SVN) update)
    59   cp $(srcdir)/Exception.h.diff Fetchdir
    60   (cd Fetchdir && patch -i Exception.h.diff || exit 1)
     60  cp $(srcdir)/Exception.cc.patch Fetchdir
     61  (cd Fetchdir && patch -i Exception.cc.patch || exit 1)
    6162  @for f in $(FETCH_FILES); do \
    6263    $(MOVE_IF_CHANGE) -v Fetchdir/$$f $(srcdir)/$$f; \
  • branches/src-highlight/lib/yat/Option.cc

    r795 r1100  
    1 // $Id: Option.cc 1797 2009-02-12 18:07:10Z peter $
     1// $Id: Option.cc 2210 2010-03-05 22:59:01Z peter $
    22
    33/*
     
    2323#include "Option.h"
    2424#include "CommandLine.h"
     25#include "Exception.h"
    2526
    2627#include <iostream>
    2728#include <sstream>
    28 #include <stdexcept>
    2929#include <string>
    3030
     
    3838  {
    3939    if (flag.empty())
    40       throw std::runtime_error("yat: Option: given flag is empty");
     40      throw runtime_error("yat: Option: given flag is empty");
    4141    if (flag.size()==1 || (flag.size()==2 && flag[1]==','))
    4242      short_name_ = flag[0];
     
    8989  {
    9090    if (!cmd().parsed()) {
    91       std::string s("Option::present called before Commandline was parsed");
     91      std::string s("theplu::yat::utility::Option::present");
     92      s += " called before Commandline was parsed";
    9293      throw std::logic_error(s);
    9394    }
  • branches/src-highlight/lib/yat/Option.h

    r824 r1100  
    22#define _theplu_yat_utility_option_
    33
    4 // $Id: Option.h 2046 2009-09-02 21:42:32Z peter $
     4// $Id: Option.h 2119 2009-12-12 23:11:43Z peter $
    55
    66/*
  • branches/src-highlight/lib/yat/OptionArg.h

    r824 r1100  
    22#define _theplu_yat_utility_option_arg_
    33
    4 // $Id: OptionArg.h 2046 2009-09-02 21:42:32Z peter $
     4// $Id: OptionArg.h 2210 2010-03-05 22:59:01Z peter $
    55
    66/*
     
    134134    }
    135135
    136     void assign(std::string& lhs, std::string rhs )
     136    void assign(std::string& lhs, const std::string& rhs )
    137137    {
    138138      lhs = rhs;
     
    140140   
    141141    template<class T1>
    142     void assign(T1& lhs, std::string rhs )
     142    void assign(T1& lhs, const std::string& rhs )
    143143    {
    144144      try {
    145145        lhs = convert<T1>(rhs);
    146146      }
    147       catch (std::runtime_error& e) {
     147      catch (runtime_error& e) {
    148148        std::stringstream sstr(rhs);
    149149        sstr << ": invalid argument";
  • branches/src-highlight/lib/yat/OptionHelp.cc

    r824 r1100  
    1 // $Id: OptionHelp.cc 2055 2009-09-08 18:23:43Z peter $
     1// $Id: OptionHelp.cc 2246 2010-04-22 00:53:23Z peter $
    22
    33/*
    44  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    4950    std::cout << cmd() << "\n";
    5051    std::cout << post_cmd_;
    51     exit(0);
     52    exit(EXIT_SUCCESS);
    5253  }
    5354
  • branches/src-highlight/lib/yat/OptionHelp.h

    r795 r1100  
    22#define _theplu_yat_utility_option_help_
    33
    4 // $Id: OptionHelp.h 1797 2009-02-12 18:07:10Z peter $
     4// $Id: OptionHelp.h 2119 2009-12-12 23:11:43Z peter $
    55
    66/*
  • branches/src-highlight/lib/yat/OptionSwitch.cc

    r795 r1100  
    1 // $Id: OptionSwitch.cc 1797 2009-02-12 18:07:10Z peter $
     1// $Id: OptionSwitch.cc 2119 2009-12-12 23:11:43Z peter $
    22
    33/*
  • branches/src-highlight/lib/yat/OptionSwitch.h

    r795 r1100  
    22#define _theplu_yat_utility_option_switch_
    33
    4 // $Id: OptionSwitch.h 1797 2009-02-12 18:07:10Z peter $
     4// $Id: OptionSwitch.h 2119 2009-12-12 23:11:43Z peter $
    55
    66/*
  • branches/src-highlight/lib/yat/README

    r826 r1100  
    88fetch'. Be careful doing this and particularly in sensitive branches
    99such as a stable-branch. All files are left pristine except
    10 `Exception.h' that is modified to avoid a dependency to GSL.
     10`Exception.cc' that is modified to avoid a dependency to GSL.
    1111
    1212How to add a new file from yat? Add the file to 'noinst_HEADERS' or
     
    1919
    2020
    21 Copyright (C) 2009 Peter Johansson
     21Copyright (C) 2009, 2010 Peter Johansson
    2222
    2323This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/lib/yat/config_public.h.in

    r798 r1100  
    22#define _theplu_yat_utility_config_public_
    33
    4 // $Id: config_public.h.in 1797 2009-02-12 18:07:10Z peter $
     4// $Id: config_public.h.in 2140 2009-12-31 22:43:29Z peter $
    55
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    9   This file is part of the yat library, http://trac.thep.lu.se/yat
     10  This file is part of the yat library, http://dev.thep.lu.se/yat
    1011
    1112  The yat library is free software; you can redistribute it and/or
  • branches/src-highlight/lib/yat/deprecate.h

    r824 r1100  
    22#define _theplu_yat_utility_deprecate_
    33
    4 // $Id: deprecate.h 2062 2009-09-14 20:19:17Z peter $
     4// $Id: deprecate.h 2124 2009-12-19 22:43:03Z peter $
    55
    66/*
    77  Copyright (C) 2008, 2009 Peter Johansson
    88
    9   This file is part of the yat library, http://trac.thep.lu.se/yat
     9  This file is part of the yat library, http://dev.thep.lu.se/yat
    1010
    1111  The yat library is free software; you can redistribute it and/or
  • branches/src-highlight/lib/yat/utility.h

    r824 r1100  
    22#define _theplu_yat_utility_utility_
    33
    4 // $Id: utility.h 2055 2009-09-08 18:23:43Z peter $
     4// $Id: utility.h 2248 2010-04-22 00:57:13Z peter $
    55
    66/*
     
    8888
    8989  /**
    90      @return true if string \a s fulfills regular expression \verbatim
    91      ^\w* \endverbatim \a other \verbatim \w*$ \endverbatim (case
    92      insensitive)
     90     This function takes the first word (separated by whitespace) in
     91     \a s, replaces all upper case with lower case, and compares it
     92     with \a other.
     93
     94     \return true if processed \a s is equal to \a other. It returns
     95     false otherwise or if \a s contains more than one word.
    9396  */
    9497  bool is_equal(std::string s, std::string other);
     
    146149
    147150     \note Requirement on T: utility::convert<T> must be supported
     151     (from yat 0.7 T=string is also supported)
    148152
    149153     \since New in yat 0.6
     
    170174     
    171175     \note Requirement on T: utility::convert<T> must be supported
     176     (from yat 0.7 T=string is also supported)
    172177
    173178     \since New in yat 0.6
     
    176181  void load(std::istream& is, std::vector<T>& vec, char sep='\0');
    177182 
     183// private namespace
     184namespace detail {
     185  /**
     186     Functor used in load function
     187   */
     188  template<typename T>
     189  struct VectorPusher
     190  {
     191    /**
     192       convert element to T and push on vec's back
     193
     194       \internal
     195     */
     196    void operator()(const std::string& element, std::vector<T>& vec)
     197    {
     198      if (!element.size())
     199        vec.push_back(std::numeric_limits<T>::quiet_NaN());
     200      else {
     201        vec.push_back(theplu::yat::utility::convert<T>(element));
     202      }
     203    }
     204  };
     205
     206  /**
     207     specialization for string
     208
     209     \internal
     210   */
     211  template<>
     212  struct VectorPusher<std::string>
     213  {
     214    /**
     215       push element on vec's back
     216     */
     217    void operator()(const std::string& element, std::vector<std::string>& vec)
     218    {
     219      vec.push_back(element);
     220    }
     221  };
     222
     223} // end of namespace detail
     224
     225
    178226  // template implementations
    179227
     
    209257        return -std::numeric_limits<T>::infinity();
    210258      else
    211         throw std::runtime_error(std::string("yat::utility::convert(\"")+s+
    212                                  std::string("\"): type is unsigned") );
     259        throw runtime_error(std::string("yat::utility::convert(\"")+s+
     260                            std::string("\"): type is unsigned") );
    213261    }
    214262    std::stringstream ss(s);
     
    222270    ss >> b;
    223271    if (!b.empty() || !ok)
    224       throw std::runtime_error(std::string("yat::utility::convert(\"")+s+
    225                                std::string("\")"));
     272      throw runtime_error(std::string("yat::utility::convert(\"")+s+
     273                          std::string("\")"));
    226274    return a;
    227275  }
     
    284332  void load(std::istream& is, std::vector<T>& vec, char sep='\0')
    285333  {
     334    detail::VectorPusher<T> pusher;
    286335    std::string element;
    287336    bool ok=true;
    288     while(ok) {
     337    while(true) {
    289338      if(sep=='\0')
    290339        ok=(is>>element);
     
    294343        break;
    295344     
    296       if (!element.size())
    297         vec.push_back(std::numeric_limits<T>::quiet_NaN());
    298       else {
    299         vec.push_back(convert<T>(element));
    300       }
     345      pusher(element, vec);
    301346    }
    302347  }           
  • branches/src-highlight/m4/apache_LICENSE-2.0.txt

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/src-highlight/m4/ax_cxx_check_flag.m4

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/src-highlight/m4/ax_cxxcpp_check_flag.m4

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/src-highlight/m4/ax_ld_check_flag.m4

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/src-highlight/m4/find_apr.m4

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/src-highlight/m4/version.m4

    r775 r1100  
    22#
    33# Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     4# Copyright (C) 2009, 2010 Peter Johansson
    45#
    5 # This file is part of svndigest, http://trac.thep.lu.se/svndigest
     6# This file is part of svndigest, http://dev.thep.lu.se/svndigest
    67#
    78# svndigest is free software; you can redistribute it and/or modify it
     
    2526m4_define([MAJOR_VERSION], [0])
    2627# MINOR - Modify when new functionality is added
    27 m4_define([MINOR_VERSION], [7])
     28m4_define([MINOR_VERSION], [8])
    2829# PATCH - Modify for every released patch
    2930m4_define([PATCH_VERSION], [0])
  • branches/src-highlight/m4/yat_add_flag.m4

    r777 r1100  
    1 ## $Id: yat_add_flag.m4 1780 2009-02-06 18:13:22Z peter $
     1## $Id: yat_add_flag.m4 2107 2009-11-07 15:53:27Z peter $
    22
    33# SYNOPSIS
     
    1717# LAST MODIFICATION
    1818#
    19 #   $Date: 2009-02-06 13:13:22 -0500 (Fri, 06 Feb 2009) $
     19#   $Date: 2009-11-07 10:53:27 -0500 (Sat, 07 Nov 2009) $
    2020#
    2121# COPYLEFT
     
    4040
    4141#
    42 # serial 2 
     42# serial 5 
    4343#
    4444# see http://www.gnu.org/software/automake/manual/automake.html#Serials
     
    4646AC_DEFUN([YAT_CPP_ADD_FLAG],
    4747[
    48   for i in $2; do
    49     YAT_FIND_STR([$1], [$i], , [AX_CXXCPP_CHECK_FLAG([$i], ,, [$1="$$1 $i"])])
     48  AC_PREREQ([2.63]) dnl we use AS_VAR_IF
     49  AC_REQUIRE([AC_PROG_SED])
     50  for yat_flag in $2; do
     51    # ignore flag if
     52    # 1) it is -I/usr/include
     53    # 2) it is -I/usr/local/include and CXX is g++
     54    # 3) it is -D* and * is already defined in $1, $CPPFLAGS, or AC_DEFINE
     55    ignore=no
     56    AS_CASE([$yat_flag],
     57            [-I/usr/include], [ignore=yes],
     58            [-I/usr/local/include],[AS_IF([test "x$CXX" = "xg++"],[ignore=yes])],
     59            [-D*], [yat_def=`AS_ECHO([$yat_flag]) | $SED 's,^-D,,;s,=.*,,'`;
     60                    yat_save_CPPFLAGS="$CPPFLAGS"
     61                    m4_if([$1], [CPPFLAGS], [], [CPPFLAGS="$$1 $CPPFLAGS"])
     62                    AC_CHECK_DECL([$yat_def],[ignore=yes])
     63                    CPPFLAGS="$yat_save_CPPFLAGS"])
     64
     65    AS_VAR_IF([ignore], [no],
     66          [YAT_FIND_STR([$1], [$yat_flag], ,
     67                        [AX_CXXCPP_CHECK_FLAG([$yat_flag], ,,
     68                                              [$1="$$1 $yat_flag"])])])
    5069  done
    5170]) # YAT_CPP_ADD_FLAG
     
    5473AC_DEFUN([YAT_CXX_ADD_FLAG],
    5574[
    56   for i in $2; do
    57     YAT_FIND_STR([$1], [$i], , [AX_CXX_CHECK_FLAG([$i], ,, [$1="$$1 $i"])])
     75  AC_PREREQ([2.61]) dnl we use AX_CXX_CHECK_FLAG
     76  for yat_flag in $2; do
     77    YAT_FIND_STR([$1], [$yat_flag], ,
     78                 [AX_CXX_CHECK_FLAG([$yat_flag], ,, [$1="$$1 $yat_flag"])])
    5879  done
    5980]) # YAT_CXX_ADD_FLAG
     
    6182AC_DEFUN([YAT_LD_ADD_FLAG],
    6283[
    63   for i in $2; do
    64     YAT_FIND_STR([$1], [$i], , [AX_LD_CHECK_FLAG([$i], ,, [$1="$$1 $i"])])
     84  AC_PREREQ([2.61]) dnl we use AX_LD_CHECK_FLAG
     85  for yat_flag in $2; do
     86    # ignore flag if
     87    # 1) it is -L/usr/lib
     88    # 2) it is -L/usr/local/lib and CXX is g++
     89    AS_IF([test "x$yat_flag" = "x-L/usr/lib"],,
     90          [test "x$CXX" = "xg++" && test "x$yat_flag" = "x-L/usr/local/lib"],,
     91          [YAT_FIND_STR([$1], [$yat_flag], ,
     92                        [AX_LD_CHECK_FLAG([$yat_flag], ,,
     93                                          [$1="$$1 $yat_flag"])])])
    6594  done
    6695]) # YAT_LD_ADD_FLAG
  • branches/src-highlight/man/Makefile.am

    r805 r1100  
    33## $Id$
    44
    5 # Copyright (C) 2008 Peter Johansson
     5# Copyright (C) 2008, 2009, 2010 Peter Johansson
    66#
    7 # This file is part of svndigest, http://trac.thep.lu.se/trac/svndigest
     7# This file is part of svndigest, http://dev.thep.lu.se/trac/svndigest
    88#
    99# svndigest is free software; you can redistribute it and/or modify it
     
    2020# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2121
    22 dist_man1_MANS = $(srcdir)/svndigest.1
     22dist_man1_MANS =
     23dist_man1_MANS += $(srcdir)/svncopyright.1
     24dist_man1_MANS += $(srcdir)/svndigest.1
     25dist_man1_MANS += $(srcdir)/svndigest-copy-cache.1
    2326
    2427EXTRA_DIST = svndigest.x
     
    2629MAINTAINERCLEANFILES = $(dist_man1_MANS)
    2730
    28 if HAVE_HELP2MAN
    2931# we would like to depend on svndigest binary, but since svndigest.1
    3032# is distributed it is recommended to depend on only distributed files
    3133# (see automake manual 27.5).
    3234$(srcdir)/svndigest.1: $(top_srcdir)/configure $(srcdir)/Makefile.in \
    33   $(srcdir)/svndigest.x
     35  $(srcdir)/svndigest.x $(top_srcdir)/bin/svndigestParameter.cc
    3436  @$(HELP2MAN) --no-info -o $@ \
    3537  --include $(srcdir)/svndigest.x \
    3638  --version-option="--no-verbose --version" \
    3739  $(top_builddir)/bin/svndigest$(EXEEXT)
    38 else
    39 $(srcdir)/svndigest.1:
    40   echo "WARNING: bogus svndigest.1 is created" >&2; \
    41   echo 'ab help2man is required to generate this page' > $@
    4240
    43 # Checking that we don't ship a bogus man page, which might be created
    44 # if help2man is not available. (The check can be removed in a future
    45 # where we require Automake 1.11)
    46 dist-hook:
    47         echo "ERROR: svndigest.1 is bogus" >&2; \
    48         echo "       you need help2man to generate a valid man page" >&2;\
    49         echo "       install help2man, re-run `configure'," >&2;\
    50         echo "       remove svndigest.1 and run 'make'" >&2;\
    51         exit 1;
    52 endif
     41$(srcdir)/svncopyright.1: $(top_srcdir)/configure $(srcdir)/Makefile.in \
     42  $(srcdir)/svndigest.x $(top_srcdir)/bin/svncopyrightParameter.cc
     43  @$(HELP2MAN) --no-info -o $@ \
     44  --include $(srcdir)/svndigest.x \
     45  --version-option="--no-verbose --version" \
     46  $(top_builddir)/bin/svncopyright$(EXEEXT)
     47
     48$(srcdir)/svndigest-copy-cache.1: $(top_srcdir)/configure $(srcdir)/Makefile.in \
     49  $(srcdir)/svndigest.x $(top_srcdir)/bin/svndigest-copy-cache.in
     50  @$(HELP2MAN) --no-info -o $@ \
     51  --include $(srcdir)/svndigest.x \
     52  $(top_builddir)/bin/svndigest-copy-cache
     53
  • branches/src-highlight/test/Makefile.am

    r801 r1100  
    33## $Id$
    44
    5 # Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    6 # Copyright (C) 2008, 2009 Peter Johansson
     5# Copyright (C) 2005, 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     6# Copyright (C) 2010 Peter Johansson
    77#
    88# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2121# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2222
    23 check_SCRIPTS = svn_update.sh
     23check_SCRIPTS = svn_update.sh init.sh
    2424
    25 check_PROGRAMS = cache_partial_test \
    26   config_test copyright_test date_test gnuplot_pipe_test \
     25## we use suffix .cc for all source
     26AM_DEFAULT_SOURCE_EXT = .cc
     27
     28EXTRA_PROGRAMS = cache_partial_test color_test \
     29  config_test copyright_test date_test \
     30  htmlstream_test \
    2731  parser_test stats_test trac_test utility_test
    2832
    29 TESTS = $(check_PROGRAMS) test_repo.sh check_repo_status.sh
     33CLEANFILES = $(EXTRA_PROGRAMS)
     34
     35distributed_TESTS =
     36distributed_TESTS += cmd_format_test.sh
     37distributed_TESTS += config2_test.sh
     38distributed_TESTS += config3_test.sh
     39distributed_TESTS += copyright2_test.sh
     40distributed_TESTS += repo_status_test.sh
     41distributed_TESTS += repo_test.sh
     42distributed_TESTS += svncopyright_test.sh
     43distributed_TESTS += svndigest_copy_cache_test.sh
     44
     45TESTS = $(EXTRA_PROGRAMS) $(distributed_TESTS)
     46
     47TEST_EXTENSIONS = .sh
     48
     49EXTRA_DIST = $(distributed_TESTS)
    3050
    3151# tests not yet passing are listed here
     
    4060  $(top_builddir)/lib/libsvndigest.a \
    4161  $(top_builddir)/lib/yat/libyat.a \
    42   $(SVNDIGEST_LIBS)
    43 AM_LDFLAGS = $(SVNDIGEST_LDFLAGS)
     62  $(SVN_LIBS) $(APR_LIBS) $(PLPLOT_LIBS)
     63AM_LDFLAGS = $(APR_LDFLAGS) $(SVN_LDFLAGS) $(PLPLOT_LDFLAGS)
    4464
    45 AM_CPPFLAGS = -I$(top_srcdir)/lib $(SVNDIGEST_CPPFLAGS)
    46 AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     65AM_CPPFLAGS = -I$(top_srcdir)/lib $(APR_CPPFLAGS) $(SVN_CPPFLAGS) \
     66  $(DEFAULT_CPPFLAGS) $(PLPLOT_CPPFLAGS)
     67AM_CXXFLAGS = $(DEFAULT_CXXFLAGS)
    4768
    4869libsvndigesttest_a_SOURCES = Suite.cc
    4970
    50 cache_partial_test_SOURCES = cache_partial_test.cc
    51 config_test_SOURCES = config_test.cc
    52 copyright_test_SOURCES = copyright_test.cc
    53 date_test_SOURCES = date_test.cc
    54 gnuplot_pipe_test_SOURCES = gnuplot_pipe_test.cc
    55 parser_test_SOURCES = parser_test.cc
    56 stats_test_SOURCES = stats_test.cc
    57 trac_test_SOURCES = trac_test.cc
    58 utility_test_SOURCES = utility_test.cc
    59 
    6071clean-local:
    61   rm -rf generated_output toy_project
     72  rm -rf generated_output toy_project testSubDir
    6273
    6374mostlyclean-local:
    64   rm -f *.png *.tmp *~
     75  rm -f *.png *.tmp *~ .toy_project2
     76
     77.PHONY: lazycheck
     78
     79lazycheck:; $(MAKE) $(AM_MAKEFLAGS) check RECHECK_LOGS=
     80
     81# dependencies for lazycheck
     82cmd_format_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT)
     83config2_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT)
     84config3_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT)
     85copyright2_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT)
     86repo_status_test.log:init.sh
     87repo_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT)
     88svncopyright_test.log:init.sh $(top_builddir)/bin/svncopyright$(EXEEXT)
     89svndigest_copy_cache_test.log:init.sh $(top_builddir)/bin/svndigest-copy-cache
     90
     91
  • branches/src-highlight/test/Suite.cc

    r803 r1100  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    56
    67  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    4142
    4243  Suite::Suite(int argc, char* argv[], bool need_test_repo)
    43     : dev_null_(NULL), ok_(true), verbose_(false)
    44   {
    45     char* buffer=std::getenv("VERBOSE");
    46     if ( (argc>1 && (argv[1]==std::string("-v")
    47                      || argv[1]==std::string("--verbose"))
    48           || (buffer && buffer == std::string("1"))) ) {
    49       verbose_=true;
    50     }
    51     else
    52       dev_null_ = new std::ofstream("/dev/null");
    53 
     44    : ok_(true)
     45  {
     46    chdir(abs_builddir());
     47    std::string test_dir = concatenate_path("testSubDir", file_name(argv[0]));
     48    mkdir_p(test_dir);
     49    chdir(test_dir);
    5450    if (need_test_repo) {
    5551      bool have_test_repo=false;
     
    6965  Suite::~Suite(void)
    7066  {
    71     delete dev_null_;
    7267  }
    7368
     
    8883  std::ostream& Suite::out(void) const
    8984  {
    90     if (verbose())
    91       return std::cout;
    92     return *dev_null_;
     85    return std::cout;
    9386  }
    9487
     
    274267  bool Suite::verbose(void) const
    275268  {
    276     return verbose_;
     269    // we are always verbose nowadays
     270    return true;
    277271  }
    278272
  • branches/src-highlight/test/Suite.h

    r803 r1100  
    55
    66/*
    7   Copyright (C) 2008, 2009 Peter Johansson
     7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    89
    910  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    6061
    6162  private:
    62     std::ofstream* dev_null_;
    6363    bool ok_;
    64     bool verbose_;
    6564
    6665    void checkout_test_wc(void) const;
  • branches/src-highlight/test/cache_partial_test.cc

    r803 r1100  
    22
    33/*
    4   Copyright (C) 2009 Peter Johansson
     4  Copyright (C) 2009, 2010 Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    3838  test::Suite suite(argc, argv, true);
    3939
    40   mkdir_p(test::filename("toy_project/.svndigest"));
    41   std::string root=test::filename("toy_project");
     40  mkdir_p("toy_project/.svndigest");
     41  std::string root="toy_project";
    4242  std::string filename = root + "/AUTHORS";
    4343  suite.out() << "Create SVN instance" << std::endl;
  • branches/src-highlight/test/config_test.cc

    r817 r1100  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2021*/
    2122
     23#include "Suite.h"
     24
    2225#include "Configuration.h"
    2326
    2427namespace theplu{
    2528namespace svndigest{
    26   bool test_codon(void);
     29  void test_codon(test::Suite&);
     30  void test_read_write(test::Suite&);
    2731}} // end of namespace svndigest and theplu
    2832
     
    3135{
    3236  using namespace theplu::svndigest;
    33   bool ok=true;
     37  test::Suite suite(argc, argv, false);
    3438
    35   ok &= test_codon();
     39  test_codon(suite);
     40  test_read_write(suite);
    3641                                                                               
    37   if (ok)
     42  if (suite.ok()) {
     43    suite.out() << "Test is Ok!" << std::endl;
    3844    return 0;
    39   return 1;
     45  }
     46  suite.out() << "Test failed." << std::endl;
     47  return 1;
    4048}
    4149
     
    4452namespace svndigest{
    4553
    46   bool test_codon(void)
     54  void test_codon(test::Suite& suite)
    4755  {
    4856    const Configuration& c(Configuration::instance());
    49     bool ok =true;
    5057    if (!c.codon("foo.h")){
    51       std::cerr << "No codon for foo.h\n";
    52       ok = false;
     58      suite.out() << "No codon for foo.h\n";
     59      suite.add(false);
    5360    }
    54     if (!c.codon("../dir/test.cc")){
    55       std::cerr << "No codon for test.cc\n";
    56       ok = false;
     61    if (!c.codon("/dir/test.cc")){
     62      suite.out() << "No codon for test.cc\n";
     63      suite.add(false);
    5764    }
    58 
    59     return ok;
     65    if (!c.codon("bootstrap")){
     66      suite.out() << "No codon for bootstrap\n";
     67      suite.add(false);
     68    }
    6069  }
    6170 
     71  void test_read_write(test::Suite& suite)
     72  {
     73    Configuration& config = Configuration::instance();
     74    std::stringstream ss;
     75    ss << config;
     76    config.load(ss);
     77    std::stringstream ss2;
     78    ss2 << config;
     79    if (ss2.str() != ss.str()) {
     80      suite.out() << "error: configuration output not equal\n";
     81      suite.out() << "defalt output:\n" << ss.str() << "\n";
     82      suite.out() << "second output:\n" << ss2.str() << "\n";
     83      suite.add(false);
     84    }
     85  }
     86
    6287}} // end of namespace svndigest and theplu
  • branches/src-highlight/test/copyright_test.cc

    r744 r1100  
    22
    33/*
    4   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4142  test::Suite suite(argc, argv, true);
    4243
    43   std::string root=test::filename("toy_project");
     44  std::string root="toy_project";
    4445  std::string filename = root + "/README";
    4546
  • branches/src-highlight/test/data/AUTHORS.svndigest-cache-r61

    r792 r1100  
    1 CACHE FILE VERSION 6
     1CACHE FILE VERSION 7
    2248 1
    33jari
    4 CACHE FILE VERSION 6
     4CACHE FILE VERSION 7
    55all
    66
    77jari
    88
    9 CACHE FILE VERSION 6
     9CACHE FILE VERSION 7
    1010all
    11112 6
    1212jari
    13132 6
    14 CACHE FILE VERSION 6
     14CACHE FILE VERSION 7
    1515all
    16162 8
    1717jari
    18182 8
    19 CACHE FILE VERSION 6
     19CACHE FILE VERSION 7
    2020all
    2121
    2222jari
    2323
    24 CACHE FILE VERSION 6
     24CACHE FILE VERSION 7
    2525all
    26262 8
    2727jari
    28282 8
    29 CACHE FILE VERSION 6
     29CACHE FILE VERSION 7
    3030all
    31312 14
    3232jari
    33332 14
    34 CACHE FILE VERSION 6
    35 CACHE FILE VERSION 6
     34CACHE FILE VERSION 7
     35CACHE FILE VERSION 7
    363648 1
    3737jari
    38 CACHE FILE VERSION 6
     38CACHE FILE VERSION 7
    3939all
    4040
    4141jari
    4242
    43 CACHE FILE VERSION 6
     43CACHE FILE VERSION 7
    4444all
    45452 6 48 4294967292
    4646jari
    47472 6 48 4294967292
    48 CACHE FILE VERSION 6
     48CACHE FILE VERSION 7
    4949all
    50502 8 48 4294967293
    5151jari
    52522 8 48 4294967293
    53 CACHE FILE VERSION 6
     53CACHE FILE VERSION 7
    5454all
    5555
    5656jari
    5757
    58 CACHE FILE VERSION 6
     58CACHE FILE VERSION 7
    5959all
    60602 8 48 4294967293
    6161jari
    62622 8 48 4294967293
    63 CACHE FILE VERSION 6
     63CACHE FILE VERSION 7
    6464all
    65652 14 48 4294967289
    6666jari
    67672 14 48 4294967289
    68 CACHE FILE VERSION 6
    69 CACHE FILE VERSION 6
     68CACHE FILE VERSION 7
     69CACHE FILE VERSION 7
    707048 1
    7171jari
    72 CACHE FILE VERSION 6
     72CACHE FILE VERSION 7
    7373all
    7474
    7575jari
    7676
    77 CACHE FILE VERSION 6
     77CACHE FILE VERSION 7
    7878all
    79792 2
    8080jari
    81812 2
    82 CACHE FILE VERSION 6
     82CACHE FILE VERSION 7
    8383all
    84842 5
    8585jari
    86862 5
    87 CACHE FILE VERSION 6
     87CACHE FILE VERSION 7
    8888all
    8989
    9090jari
    9191
    92 CACHE FILE VERSION 6
     92CACHE FILE VERSION 7
    9393all
    94942 5
    9595jari
    96962 5
    97 CACHE FILE VERSION 6
     97CACHE FILE VERSION 7
    9898all
    99992 7
    100100jari
    1011012 7
    102 CACHE FILE VERSION 6
     102CACHE FILE VERSION 7
  • branches/src-highlight/test/date_test.cc

    r693 r1100  
    22
    33/*
    4   Copyright (C) 2007 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/test/environment.h.in

    r737 r1100  
    66
    77/*
    8   Copyright (C) 2008 Peter Johansson
     8  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/test/parser_test.cc

    r693 r1100  
    33/*
    44  Copyright (C) 2006 Peter Johansson
    5   Copyright (C) 2007 Peter Johansson
     5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/test/repo/db/current

    r818 r1100  
    1 64 1y 4
     168 2s 4
  • branches/src-highlight/test/stats_test.cc

    r744 r1100  
    33/*
    44  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2009 Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4040#include <vector>
    4141
     42using namespace theplu::svndigest;
     43
    4244namespace theplu{
    4345namespace svndigest{
     
    4648             int linetype, const std::string& descr, const std::string& author);
    4749  std::string path(void);
    48   bool test_add(void);
    49   bool test_blame(void);
    50   bool test_classic(void);
     50  bool test_add(test::Suite&);
     51  bool test_blame(test::Suite&);
     52  bool test_classic(test::Suite&);
    5153  bool test_base_class(const Stats&);
    5254  bool test_cache(const Stats&);
     
    5759int main( int argc, char* argv[])
    5860{
    59   using namespace theplu::svndigest;
    6061  test::Suite suite(argc, argv, true);
    6162
     
    6364  bool ok=true;
    6465
    65   SVN* svn=SVN::instance(test::filename("toy_project"));
     66  SVN* svn=SVN::instance("toy_project");
    6667  if (!svn){
    6768    std::cerr << "error: cannot create SVN instance\n";
     
    6970  }
    7071
    71   ok &= test_add();
    72   ok &= test_blame();
    73   ok &= test_classic();
     72  ok &= test_add(suite);
     73  ok &= test_blame(suite);
     74  ok &= test_classic(suite);
    7475                                                                               
    7576  if (verbose) {
     
    9091  std::string path(void)
    9192  {
    92     return test::filename("toy_project/bin/svnstat.cc");
    93   }
    94 
    95   bool test_add(void)
    96   {
     93    return "toy_project/bin/svnstat.cc";
     94  }
     95
     96  bool test_add(test::Suite& suite)
     97  {
     98    suite.out() << "testing add\n";
    9799    bool ok =true;
    98100    AddStats cs(path());
     
    140142 
    141143 
    142   bool test_blame(void)
    143   {
     144  bool test_blame(test::Suite& suite)
     145  {
     146    suite.out() << "testing blame\n";
    144147    bool ok =true;
    145148    BlameStats cs(path());
     
    207210
    208211
    209   bool test_classic(void)
    210   {
     212  bool test_classic(test::Suite& suite)
     213  {
     214    suite.out() << "testing classic\n";
    211215    bool ok =true;
    212216    ClassicStats cs(path());
     
    216220    // testing copyright lines for peter
    217221    std::vector<int> correct(48,0);
    218     correct[47]=2;
     222    correct[47]=1;
    219223    ok &= check(cs, correct, LineTypeParser::copyright, "copyright", "peter");
    220224
     
    253257    correct[28]=31;
    254258    correct[30]=63;
    255     correct[47]=2;
     259    correct[47]=1;
    256260    ok &= check(cs, correct, LineTypeParser::total, "total", "all");
    257261
  • branches/src-highlight/test/svn_update.sh.in

    r772 r1100  
    44# $Id$
    55
    6 # Copyright (C) 2009 Peter Johansson
     6# Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     7# Copyright (C) 2009, 2010 Peter Johansson
    78#
    89# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2122# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2223
    23 rootdir=@abs_builddir@/toy_project
     24test -z "$SVN" && SVN=svn
     25rootdir=toy_project
    2426
    2527if test ! -e $rootdir; then
    2628    repo="@abs_test_repo@";
    27     svn co file://$repo/trunk $rootdir > /dev/null;
     29    $SVN checkout file://$repo/trunk $rootdir;
    2830fi
    2931
    30 svn update $rootdir > /dev/null;
     32$SVN update $rootdir
  • branches/src-highlight/test/trac_test.cc

    r768 r1100  
    22
    33/*
    4   Copyright (C) 2007, 2008, 2009 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
  • branches/src-highlight/test/utility_test.cc

    r795 r1100  
    22
    33/*
    4   Copyright (C) 2007 Peter Johansson
    5   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2929
    3030bool test_hex(int, unsigned int, std::string);
    31 bool test_equal(bool, std::string, std::string);
     31bool test_fnmatch(bool, std::string, std::string);
    3232bool test_regexp(bool, std::string, std::string,
    3333                 const std::vector<std::string>&);
     
    4141  ok &= test_hex(16,2, "10");
    4242
    43   ok &= test_equal(true,"peter", "peter");
    44   ok &= test_equal(false,"peter", "peterj");
    45   ok &= test_equal(true,"p*", "peterj");
    46   ok &= test_equal(true,"peter", "p*");
    47   ok &= test_equal(false,"peter", "p*j");
    48   ok &= test_equal(true,"peter", "*peter");
     43  ok &= test_fnmatch(true,"peter", "peter");
     44  ok &= test_fnmatch(false,"peter", "peterj");
     45
     46  ok &= test_fnmatch(true,"*", "peterj");
     47  ok &= test_fnmatch(true,"p*", "peterj");
     48  ok &= test_fnmatch(true, "p*", "peter");
     49  ok &= test_fnmatch(false, "p*j", "peter");
     50  ok &= test_fnmatch(true, "p*j", "peterj");
     51  ok &= test_fnmatch(true, "*peter", "peter");
     52
     53  ok &= test_fnmatch(true, "p?ter", "peter");
     54  ok &= test_fnmatch(false, "p?er", "peter");
     55  ok &= test_fnmatch(false, "p?eter", "peter");
     56
     57  ok &= test_fnmatch(true, "filename", "filename");
     58  ok &= test_fnmatch(true, "*name", "filename");
     59  ok &= test_fnmatch(true, "[fa]il?name", "filename");
     60  ok &= test_fnmatch(true, "[fa]*il?name", "ffilename");
     61
     62  ok &= test_fnmatch(true, "[fa]*il?name", "fafafailename");
     63  ok &= test_fnmatch(false, "[fa]?il?name", "ilename");
     64  ok &= test_fnmatch(false, "?[fa]il?name", "ilename");
     65  ok &= test_fnmatch(true, "[fa]il?name", "filename");
     66  ok &= test_fnmatch(false, "[fa]?il?name", "fafafailename");
     67
     68  ok &= test_fnmatch(true, "*name", "/path/to/filename");
     69  ok &= test_fnmatch(true, "*name", "file.name");
     70  // posix dictates that leading period can not be matched by
     71  // wildcard, but here we allow match
     72  ok &= test_fnmatch(true, "*.txt", ".file.txt");
     73
    4974
    5075  std::vector<std::string> vec;
    5176  ok &= test_regexp(true,"abcde", "abcde", vec);
     77  vec.push_back("c");
     78  ok &= test_regexp(true,"ab?de", "abcde", vec);
     79  vec[0] = "bcd";
     80  ok &= test_regexp(true,"a*e", "abcde", vec);
    5281  vec.push_back("");
    53   ok &= test_regexp(true,"abcde", "abcd?e", vec);
    54   vec[0]="c";
    55   ok &= test_regexp(true,"abcde", "ab?de", vec);
    56   vec[0] = "bcd";
    57   ok &= test_regexp(true,"abcde", "a*e", vec);
    58   vec.push_back("");
    59   ok &= test_regexp(true,"abcddf", "a*d*f", vec);
     82  ok &= test_regexp(true,"a*d*f", "abcddf", vec);
    6083  vec[0] = "bc";
    6184  vec[1] = "ef";
    62   ok &= test_regexp(true,"abcdefg", "a*d*g", vec);
     85  ok &= test_regexp(true,"a*d*g", "abcdefg", vec);
    6386  vec.push_back("");
    64   ok &= test_regexp(true,"abcdefg", "a*d*?g", vec);
     87  vec[1]="e";
     88  vec[2]="f";
     89  ok &= test_regexp(true,"a*d*?g", "abcdefg", vec);
     90  ok &= test_regexp(true,"a*d??g", "abcdefg", vec);
     91  vec.resize(2);
     92  vec[0]="f";
     93  vec[1]="e";
     94  ok &= test_regexp(true, "[fa]il?name", "filename", vec);
    6595
    6696  if (ok)
     
    6999}
    70100
    71 bool test_equal(bool answ, std::string a, std::string b)
     101bool test_fnmatch(bool answ, std::string a, std::string b)
    72102{
    73   if (theplu::svndigest::equal(a.begin(), a.end(), b.begin(), b.end())==answ)
     103  using namespace theplu::svndigest;
     104  bool res = fnmatch(a.c_str(), b.c_str());
     105  // check that fnmatch and regexp agree
     106  std::vector<std::string> v;
     107  bool res2 = regexp(a, b, v);
     108  if (res == answ && res2==answ)
    74109    return true;
    75   std::cerr << "equal(" << a << ", " << b << ") results "
    76             << theplu::svndigest::equal(a.begin(), a.end(),b.begin(), b.end())
    77             << ". Expects " << answ << std::endl;
     110  if (res!=answ)
     111    std::cerr << "fnmatch(" << a << ", " << b << ") results "
     112              << res
     113              << ". Expects " << answ << std::endl;
     114  if (res2!=answ)
     115    std::cerr << "regexp(" << b << ", " << a << ") results "
     116              << res2
     117              << ". Expects " << answ << std::endl;
    78118  return false;
    79119}
     
    94134  using namespace theplu::svndigest;
    95135  std::vector<std::string> v;
    96   bool res = regexp(a.begin(), a.end(), b.begin(), b.end(), v);
     136  bool res = regexp(a, b, v);
    97137  if (res!=ans || v!=vec) {
    98138    std::cerr << "regexp(" << a << ", " << b << ") results "
     
    107147  }
    108148  return true;
    109 
    110149}
Note: See TracChangeset for help on using the changeset viewer.