<commit_before>// ------------------------------------------------------------------------
// com_line.cpp: A wrapper class for parsing command line arguments
// Copyright (C) 1999 <NAME> (<EMAIL>)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
// ------------------------------------------------------------------------

#include <string>
#include <vector>
#include <algorithm>

// #include "debug.h"
#include "com_line.h"

COMMAND_LINE::COMMAND_LINE(int argc, char *argv[]) {
  current_rep = 0;

  for(int t = 0; t < argc; t++) {
    cparams.push_back(argv[t]);
  }
}

COMMAND_LINE::COMMAND_LINE(const vector<string>& params) {  cparams = params; }
void COMMAND_LINE::push_back(const string& argu) { cparams.push_back(argu); }


bool COMMAND_LINE::has(char option) const {
  vector<string>::size_type savepos = current_rep;

  current_rep = 0;
  while (current_rep < cparams.size()) {
    if (cparams[current_rep].size() > 1) {
      if (cparams[current_rep].at(0) == '-' &&
	  cparams[current_rep].at(1) == option) {
	current_rep = savepos;
	return(true);
      }
    }
    ++current_rep;
  }
  current_rep = savepos;
  return(false);
}

bool COMMAND_LINE::has(const string& option) const {
  vector<string>::size_type savepos = current_rep;

  current_rep = 0;
  while (current_rep < cparams.size()) {
    if (cparams[current_rep] == option) {
      current_rep = savepos;
      return(true);
    }
    ++current_rep;
  }
  current_rep = savepos;
  return(false);
}

void COMMAND_LINE::combine(void) { cparams = combine(cparams); }

vector<string> COMMAND_LINE::combine(const vector<string>& source) {
  vector<string> result;
  string first;
  vector<string>::const_iterator p = source.begin();
  while(p != source.end()) {
    if (p->size() == 0) {
      ++p;
      continue;
    }
    if ((*p)[0] == '-') {
      if (find(p->begin(), p->end(), ':') == p->end()) {
	first = *p;
	++p;
	if (p == source.end()) {
	  result.push_back(first);
	  break;
	}
	if ((*p)[0] != '-') {
	  first += ":" + *p;
	  result.push_back(first);
	}
	else {
	  result.push_back(first);
	  result.push_back(*p);
	}
      }
      else 
	result.push_back(*p);
    }
    else 
      result.push_back(*p);
    
    ++p;
  }
  return(result);
}<commit_msg>Cline combine bug fixed.<commit_after>// ------------------------------------------------------------------------
// com_line.cpp: A wrapper class for parsing command line arguments
// Copyright (C) 1999 <NAME> (<EMAIL>)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
// ------------------------------------------------------------------------

#include <string>
#include <vector>
#include <algorithm>

// #include "debug.h"
#include "com_line.h"

COMMAND_LINE::COMMAND_LINE(int argc, char *argv[]) {
  current_rep = 0;

  for(int t = 0; t < argc; t++) {
    cparams.push_back(argv[t]);
  }
}

COMMAND_LINE::COMMAND_LINE(const vector<string>& params) {  cparams = params; }
void COMMAND_LINE::push_back(const string& argu) { cparams.push_back(argu); }


bool COMMAND_LINE::has(char option) const {
  vector<string>::size_type savepos = current_rep;

  current_rep = 0;
  while (current_rep < cparams.size()) {
    if (cparams[current_rep].size() > 1) {
      if (cparams[current_rep].at(0) == '-' &&
	  cparams[current_rep].at(1) == option) {
	current_rep = savepos;
	return(true);
      }
    }
    ++current_rep;
  }
  current_rep = savepos;
  return(false);
}

bool COMMAND_LINE::has(const string& option) const {
  vector<string>::size_type savepos = current_rep;

  current_rep = 0;
  while (current_rep < cparams.size()) {
    if (cparams[current_rep] == option) {
      current_rep = savepos;
      return(true);
    }
    ++current_rep;
  }
  current_rep = savepos;
  return(false);
}

void COMMAND_LINE::combine(void) { cparams = combine(cparams); }

vector<string> COMMAND_LINE::combine(const vector<string>& source) {
  vector<string> result;
  string first;
  vector<string>::const_iterator p = source.begin();
  while(p != source.end()) {
    if (p->size() == 0) {
      ++p;
      continue;
    }
    if ((*p)[0] == '-') {
      if (find(p->begin(), p->end(), ':') == p->end()) {
	first = *p;
	++p;
	if (p == source.end()) {
	  result.push_back(first);
	  break;
	}
	if ((*p)[0] != '-') {
	  first += ":" + *p;
	  result.push_back(first);
	}
	else {
	  --p;
	  result.push_back(first);
	}
      }
      else 
	result.push_back(*p);
    }
    else 
      result.push_back(*p);
    
    ++p;
  }
  return(result);
}
{'fraction_non_alphanumeric': 0.1939655172413793, 'fraction_numerical': 0.01, 'mean_word_length': 2.7138284250960307, 'pattern_counts': {'":': 2, '<': 33, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6470499', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1852, 'n_words': 523}