Skip to content

Commit

Permalink
what appears to be a working version, at least when called with -repp…
Browse files Browse the repository at this point in the history
…=common

git-svn-id: https://pet.opendfki.de/repos/pet/branches/repp@789 4200e16c-5112-0410-ac55-d7fb557a720a
  • Loading branch information
oe committed Aug 3, 2011
1 parent 633abdf commit f6934a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
18 changes: 8 additions & 10 deletions cheap/repp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ tReppTokenizer::tReppTokenizer()
file = find_file(name, SET_EXT,
cheap_settings->base() + SET_SUBDIRECTORY + PATH_SEP);

if(file.empty()) {
cerr << "Unable to locate REPP configuration '" << name << "'." << endl;
exit(1);
} // if
if(file.empty())
throw tError("Unable to locate REPP configuration '" + name + "'.");

_path = dir_name(file);
_update = new settings(file, _path, "reading");
_update = new settings(raw_name(file), _path, "reading");
cheap_settings->install(_update);
} // if

Expand All @@ -84,11 +83,10 @@ tReppTokenizer::~tReppTokenizer()
iter != _repps.end(); ++iter)
delete iter->second;

// uninstall hangs, memory should be freed anyway?
// if (cheap_settings != NULL && _update != NULL) {
// cheap_settings->uninstall(_update);
// delete _update;
// }
if (cheap_settings != NULL && _update != NULL) {
cheap_settings->uninstall(_update);
delete _update;
} // if
}

tRepp::tRepp(string name, tReppTokenizer *parent) :_id(name), _parent(parent)
Expand Down
7 changes: 4 additions & 3 deletions common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
using std::string;

settings::settings(string name, string base_dir, const char *message)
: _lloc(0), _li_cache(), _updates() {
: _valid(false), _lloc(0), _li_cache(), _updates() {
_n = 0;
_set = new setting*[SET_TABLE_SIZE];

Expand All @@ -45,13 +45,13 @@ settings::settings(string name, string base_dir, const char *message)
lexer_idchars = "_+-*?$";
parse();
lexer_idchars = sv;

_valid = true;
}
}


settings::settings(const std::string &input)
: _lloc(0), _li_cache(), _updates() {
: _valid(false), _lloc(0), _li_cache(), _updates() {
_n = 0;
_set = new setting*[SET_TABLE_SIZE];

Expand All @@ -60,6 +60,7 @@ settings::settings(const std::string &input)
lexer_idchars = "_+-*?$";
parse();
lexer_idchars = sv;
_valid = true;
}


Expand Down
2 changes: 2 additions & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class settings
settings(const std::string &input);
~settings();

bool valid() { return _valid; }
const std::string &base() { return _base; }
setting *lookup(const char *name);

Expand Down Expand Up @@ -81,6 +82,7 @@ class settings
bool uninstall(settings *);

private:
bool _valid;
int _n;
setting **_set;
std::string _fname, _prefix, _base;
Expand Down

0 comments on commit f6934a9

Please sign in to comment.