Skip to content

Commit 06b0871

Browse files
committed
cshtml --cwe-names: default to /usr/share/csdiff/cwe-names.csv
... only if the file is actually installed on the system
1 parent 7ac5e9d commit 06b0871

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,23 @@ add_library(cs STATIC
4242
)
4343

4444
# link cslib.a and boost libraries
45-
find_library(BOOST_REGEX boost_regex REQUIRED)
45+
find_library(BOOST_FILESYSTEM boost_filesystem REQUIRED)
4646
find_library(BOOST_PROGRAM_OPTIONS boost_program_options REQUIRED)
47+
find_library(BOOST_REGEX boost_regex REQUIRED)
48+
find_library(BOOST_SYSTEM boost_system REQUIRED)
4749
link_libraries(cs
48-
boost_regex
49-
boost_program_options)
50+
boost_program_options
51+
boost_regex)
5052

5153
# the list of executables
5254
add_executable(csdiff csdiff.cc)
5355
add_executable(csgrep csgrep.cc)
5456
add_executable(cshtml cshtml.cc)
5557
add_executable(cslinker cslinker.cc)
5658
add_executable(cssort cssort.cc)
59+
target_link_libraries(cshtml
60+
boost_filesystem
61+
boost_system)
5762

5863
# experimental
5964
add_executable(cstrans-df-run cstrans-df-run.cc)

src/cshtml.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
#include "regex.hh"
2626
#include "version.hh"
2727

28+
#include <boost/filesystem.hpp>
2829
#include <boost/program_options.hpp>
2930

3031
#ifndef DEFAULT_CWE_NAMES_FILE
3132
# define DEFAULT_CWE_NAMES_FILE "/usr/share/csdiff/cwe-names.csv"
3233
#endif
33-
static const char fnCweNamesDefault[] = DEFAULT_CWE_NAMES_FILE;
3434

3535
std::string titleFromFileName(const std::string &fileName)
3636
{
@@ -56,6 +56,11 @@ int main(int argc, char *argv[])
5656
using std::string;
5757
const char *name = argv[0];
5858

59+
std::string fnCweNamesDefault = DEFAULT_CWE_NAMES_FILE;
60+
if (!boost::filesystem::exists(fnCweNamesDefault))
61+
// if the default file is not installed, do not use it as default
62+
fnCweNamesDefault.clear();
63+
5964
namespace po = boost::program_options;
6065
po::variables_map vm;
6166
po::options_description desc(string("Usage: ") + name

0 commit comments

Comments
 (0)