<commit_before>#ifndef CONFIG_H
#define CONFIG_H

#include <algorithm>
#include <sstream>
#include <map>
#include <string>
#include <vector>
#include <ostream>
#include <cerrno>
#include <cstring>
#include <inttypes.h>
#include "kernel.h"
#include "except.h"
#include "programs/mgsim.h"

/// InputConfigRegistry: registry for configuration values provided
/// before the simulation starts.

class InputConfigRegistry
{
public:
    // a sequence of (pattern, value) pairs 
    typedef std::vector<std::pair<std::string,std::string> > ConfigMap;
    
private:
    typedef std::map<std::string,std::pair<std::string,std::string> > ConfigCache;
    
    ConfigMap                m_data;
    const ConfigMap&         m_overrides;
    ConfigCache              m_cache;
    std::vector<std::string> m_argv;

    template<typename T>
    static T convertToNumber(const std::string& name, const std::string& value)
    {
        const char *start = value.c_str();
        char *end;
        T val;

        val = strtoumax(start, &end, 0);
        if (errno == EINVAL)
        {
            val = strtoimax(start, &end, 0);
        }
        if (errno == EINVAL)
        {
            throw Simulator::exceptf<Simulator::SimulationException>("Configuration value for %s is not a number: %s", name.c_str(), start); 
        }<commit_msg>Try to fix a configuration loading bug.<commit_after>#ifndef CONFIG_H
#define CONFIG_H

#include <algorithm>
#include <sstream>
#include <map>
#include <string>
#include <vector>
#include <ostream>
#include <cerrno>
#include <cstring>
#include <inttypes.h>
#include "kernel.h"
#include "except.h"
#include "programs/mgsim.h"

/// InputConfigRegistry: registry for configuration values provided
/// before the simulation starts.

class InputConfigRegistry
{
public:
    // a sequence of (pattern, value) pairs 
    typedef std::vector<std::pair<std::string,std::string> > ConfigMap;
    
private:
    typedef std::map<std::string,std::pair<std::string,std::string> > ConfigCache;
    
    ConfigMap                m_data;
    const ConfigMap&         m_overrides;
    ConfigCache              m_cache;
    std::vector<std::string> m_argv;

    template<typename T>
    static T convertToNumber(const std::string& name, const std::string& value)
    {
        const char *start = value.c_str();
        char *end;
        T val;

        val = strtoumax(start, &end, 0);
        if (val == 0 && errno == EINVAL)
        {
            val = strtoimax(start, &end, 0);
        }
        if (val == 0 && errno == EINVAL)
        {
            throw Simulator::exceptf<Simulator::SimulationException>("Configuration value for %s is not a number: %s", name.c_str(), start); 
        }
{'fraction_non_alphanumeric': 0.1290680473372781, 'fraction_numerical': 0.0022189349112426036, 'mean_word_length': 2.943148688046647, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '7076965', 'n_tokens_mistral': 847, 'n_tokens_neox': 829, 'n_words': 224}