diff options
author | Tim King <taking@cs.nyu.edu> | 2016-03-21 20:51:07 -0700 |
---|---|---|
committer | Tim King <taking@cs.nyu.edu> | 2016-03-21 20:51:07 -0700 |
commit | fa0e13c32b15b628cc812928c0fb6c094f85079d (patch) | |
tree | 5ac79f0393ef395b83cbbff2a26b7fab51610176 /src/options/argument_extender.cpp | |
parent | 22c24eeffd7dc0e44533ccd8c2c6dc91eb77f2f3 (diff) |
New version of the recursive options parsing strategy.
Diffstat (limited to 'src/options/argument_extender.cpp')
-rw-r--r-- | src/options/argument_extender.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/options/argument_extender.cpp b/src/options/argument_extender.cpp deleted file mode 100644 index d55610590..000000000 --- a/src/options/argument_extender.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/********************* */ -/*! \file preempt_get_option.h - ** \verbatim - ** Original author: Tim King - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Utility function for parsing commandline options. - ** - ** Utility function for parsing commandline options. - **/ - -#include "options/argument_extender.h" - -#include <cstdlib> -#include <cstring> -#include <vector> - -#include "base/cvc4_assert.h" -#include "base/output.h" - -namespace CVC4 { -namespace options { - -ArgumentExtender::ArgumentExtender(unsigned additional, size_t length) - : d_additional(additional) - , d_length(length) -{ - AlwaysAssert(d_additional >= 1); - AlwaysAssert(d_length >= 1); -} - -ArgumentExtender::~ArgumentExtender(){} - -unsigned ArgumentExtender::getIncrease() const { return d_additional; } -size_t ArgumentExtender::getLength() const { return d_length; } - -void ArgumentExtender::extend(int& argc, char**& argv, const char* opt, - std::vector<char*>& allocated) -{ - - Debug("preemptGetopt") << "preempting getopt() with " << opt << std::endl; - - AlwaysAssert(opt != NULL && *opt != '\0'); - AlwaysAssert(strlen(opt) <= getLength()); - - ++argc; - unsigned i = 1; - while(argv[i] != NULL && argv[i][0] != '\0') { - ++i; - } - - if(argv[i] == NULL) { - unsigned newSize = i + getIncrease(); - argv = (char**) realloc(argv, newSize * sizeof(char*)); - for(unsigned j = i; j < newSize-1; ++j) { - char* newString = (char*) malloc(sizeof(char) * getLength()); - newString[0] = '\0'; - argv[j] = newString; - allocated.push_back(newString); - } - argv[newSize - 1] = NULL; - } - - strncpy(argv[i], opt, getLength() - 1); - argv[i][getLength() - 1] = '\0'; // ensure NULL-termination even on overflow -} - -}/* CVC4::options namespace */ -}/* CVC4 namespace */ |