<commit_before>//////////////////////////////////////////////////////////////////////////
//
// SneezyMUD - All rights reserved, SneezyMUD Coding Team
//
//////////////////////////////////////////////////////////////////////////


#include <cstdarg>

extern "C" {
#include <unistd.h>
}

#include "stdsneezy.h"
#include "combat.h"
#include "disease.h"
#include "range.h"
#include "connect.h"
#include "shop.h"
#include "obj_spellbag.h"
#include "obj_bag.h"
#include "obj_table.h"
#include "obj_tool.h"
#include "obj_base_weapon.h"
#include "obj_base_clothing.h"


// fname will look for the first non-alpha character
// I added - and ' as valid fname chars since this allows us to do better things
// with items and mobs in the name field.  - Bat 6-30-97
const sstring fname(const char *namelist)
{
  char holder[60];
  register char *point;

  for (point = holder; isalpha(*namelist) || (*namelist == '-') || (*namelist == '\''); namelist++, point++)
    *point = *namelist;

  *point = '\0';

  return (holder);
}

// split up "str", using delimiters "sep" and place resulting sstrings in "argv"
int split_sstring(const sstring &str, const sstring &sep, vector<sstring> &argv)
{
  unsigned int pos=0, last=0;

  while((pos=str.find_first_of(sep,last)) != sstring::npos){
    argv.push_back(str.substr(last,pos-last));
    last=pos+1;
  }

  argv.push_back(str.substr(last,str.length()-last));

  return argv.size();
}

bool isname(const sstring &str, const sstring &namelist)
{
  vector <sstring> argv, xargv;
  unsigned int i, j;

  if (namelist.empty())
    return false;

  split_sstring(str, "- \t\n\r,", argv);
  split_sstring(namelist, "- \t\n\r,", xargv);

  for(i=0;i < argv.size();i++) {
    for(j=0;j < xargv.size();j++) {
      if (!xargv[j].empty() && is_abbrev(argv[i], xargv[j])) {
        xargv[j] = "";
        break;
      }
    }
    if (j >= xargv.size())
      return FALSE;
  }
  return TRUE;
}

bool is_exact_spellname(const sstring &str, const sstring &namelist)
{
  vector <sstring> argv, xargv;
  unsigned int i, j;

  split_sstring(str, "- \t\n\r,", argv);
  split_sstring(namelist, "- \t\n\r,", xargv);

  if(!is_abbrev(argv[0], xargv[0]))
    return FALSE;

  for (i = 0; i < argv.size(); i++) {
    for (j = 0; j < xargv.size(); j++) {
      if(!xargv[j].empty() && lower(argv[i]) == lower(xargv[j])){
        xargv[j] = "";
        break;
      }
    }
    if (j >= xargv.size())
      return FALSE;
  }
  return TRUE;
}

bool is_exact_name(const sstring &str, const sstring &namelist)
{
  vector <sstring> argv, xargv;
  unsigned int i, j;

  split_sstring(str, "- \t\n\r,", argv);
  split_sstring(namelist, "- \t\n\r,", xargv);

  for (i = 0; i < argv.size(); i++) {
    for (j = 0; j < xargv.size(); j++) {
      if(!xargv[j].empty() && lower(argv[i]) == lower(xargv[j])){
        xargv[j] = "";
        break;
      }
    }
    if (j >= xargv.size())
      return FALSE;
  }
  return TRUE;
}

void TBeing::affectChange(unsigned long original, silentTypeT silent)
{
  unsigned long current = specials.affectedBy;
  int rc;

  if (silent)
    return;

  if (!IS_SET(current, AFF_BLIND) && IS_SET(original, AFF_BLIND)) {
    sendTo("Phew, you can see again, thankfully.\n\r");
  }
  if (IS_SET(current, AFF_BLIND) && !IS_SET(original, AFF_BLIND)) {
    sendTo("Ack, you can't see a damn thing!  Who turned out the lights?\n\r");
  }<commit_msg>fixed an obscure bug in is_exact_name<commit_after>//////////////////////////////////////////////////////////////////////////
//
// SneezyMUD - All rights reserved, SneezyMUD Coding Team
//
//////////////////////////////////////////////////////////////////////////


#include <cstdarg>

extern "C" {
#include <unistd.h>
}

#include "stdsneezy.h"
#include "combat.h"
#include "disease.h"
#include "range.h"
#include "connect.h"
#include "shop.h"
#include "obj_spellbag.h"
#include "obj_bag.h"
#include "obj_table.h"
#include "obj_tool.h"
#include "obj_base_weapon.h"
#include "obj_base_clothing.h"


// fname will look for the first non-alpha character
// I added - and ' as valid fname chars since this allows us to do better things
// with items and mobs in the name field.  - Bat 6-30-97
const sstring fname(const char *namelist)
{
  char holder[60];
  register char *point;

  for (point = holder; isalpha(*namelist) || (*namelist == '-') || (*namelist == '\''); namelist++, point++)
    *point = *namelist;

  *point = '\0';

  return (holder);
}

// split up "str", using delimiters "sep" and place resulting sstrings in "argv"
int split_sstring(const sstring &str, const sstring &sep, vector<sstring> &argv)
{
  unsigned int pos=0, last=0;

  while((pos=str.find_first_of(sep,last)) != sstring::npos){
    argv.push_back(str.substr(last,pos-last));
    last=pos+1;
  }

  argv.push_back(str.substr(last,str.length()-last));

  return argv.size();
}

bool isname(const sstring &str, const sstring &namelist)
{
  vector <sstring> argv, xargv;
  unsigned int i, j;

  if (namelist.empty())
    return false;

  split_sstring(str, "- \t\n\r,", argv);
  split_sstring(namelist, "- \t\n\r,", xargv);

  for(i=0;i < argv.size();i++) {
    for(j=0;j < xargv.size();j++) {
      if (!xargv[j].empty() && is_abbrev(argv[i], xargv[j])) {
        xargv[j] = "";
        break;
      }
    }
    if (j >= xargv.size())
      return FALSE;
  }
  return TRUE;
}

bool is_exact_spellname(const sstring &str, const sstring &namelist)
{
  vector <sstring> argv, xargv;
  unsigned int i, j;

  split_sstring(str, "- \t\n\r,", argv);
  split_sstring(namelist, "- \t\n\r,", xargv);

  if(!is_abbrev(argv[0], xargv[0]))
    return FALSE;

  for (i = 0; i < argv.size(); i++) {
    for (j = 0; j < xargv.size(); j++) {
      if(!xargv[j].empty() && lower(argv[i]) == lower(xargv[j])){
        xargv[j] = "";
        break;
      }
    }
    if (j >= xargv.size())
      return FALSE;
  }
  return TRUE;
}

bool is_exact_name(const sstring &str, const sstring &namelist)
{
  vector <sstring> argv, xargv;
  unsigned int i, j;

  split_sstring(str, "- \t\n\r,", argv);
  split_sstring(namelist, "- \t\n\r,", xargv);

  for (i = 0; i < argv.size(); i++) {
    for (j = 0; j < xargv.size(); j++) {
      if(lower(argv[i]) == lower(xargv[j])){
        xargv[j] = "";
        break;
      }
    }
    if (j >= xargv.size())
      return FALSE;
  }
  return TRUE;
}

void TBeing::affectChange(unsigned long original, silentTypeT silent)
{
  unsigned long current = specials.affectedBy;
  int rc;

  if (silent)
    return;

  if (!IS_SET(current, AFF_BLIND) && IS_SET(original, AFF_BLIND)) {
    sendTo("Phew, you can see again, thankfully.\n\r");
  }
  if (IS_SET(current, AFF_BLIND) && !IS_SET(original, AFF_BLIND)) {
    sendTo("Ack, you can't see a damn thing!  Who turned out the lights?\n\r");
  }
{'fraction_non_alphanumeric': 0.2155440414507772, 'fraction_numerical': 0.005625462620281273, 'mean_word_length': 2.7059791552386177, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, '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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6461502', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2508, 'n_words': 616}