<commit_before>import re
import uuid
import os.path

def fix_newlines(source):
    return re.sub(r'\r\n|\r|\n', '\n', source)


def merge_newlines(source):
    return source.replace('\\\n', '')


def remove_comments(source):
    no_mutiline = re.sub(r'/\*.*?\*/', ' ', source, flags=re.DOTALL)
    no_single_line = re.sub(r'//.*$', ' ', no_mutiline)
    return no_single_line


def extract_includes(source):
    return re.findall(r'^#\s*include\s*[<"](.+)[">]\s*$', source, flags=re.MULTILINE)


def check_include_legal(include):
    prefix = '/%s/' % uuid.uuid4()
    path = os.path.normpath(os.path.join(prefix, include))
    if not path.startswith(prefix):
        raise Exception("Illegal include '%s' -> '%s'" % (include, path))
    return True


def process_file(source):
    processed_text = remove_comments(merge_newlines(fix_newlines(source)))
    includes = extract_includes(processed_text)

    for include in includes:
        check_include_legal(include)<commit_msg>Source files often contain multiple lines.<commit_after>import re
import uuid
import os.path

def fix_newlines(source):
    return re.sub(r'\r\n|\r|\n', '\n', source)


def merge_newlines(source):
    return source.replace('\\\n', '')


def remove_comments(source):
    no_mutiline = re.sub(r'/\*.*?\*/', ' ', source, flags=re.DOTALL|re.MULTILINE)
    no_single_line = re.sub(r'//.*$', ' ', no_mutiline, flags=re.MULTILINE)
    return no_single_line


def extract_includes(source):
    return re.findall(r'^#\s*include\s*[<"](.+)[">]\s*$', source, flags=re.MULTILINE)


def check_include_legal(include):
    prefix = '/%s/' % uuid.uuid4()
    path = os.path.normpath(os.path.join(prefix, include))
    if not path.startswith(prefix):
        raise Exception("Illegal include '%s' -> '%s'" % (include, path))
    return True


def process_file(source):
    processed_text = remove_comments(merge_newlines(fix_newlines(source)))
    includes = extract_includes(processed_text)

    for include in includes:
        check_include_legal(include)
{'fraction_non_alphanumeric': 0.1702970297029703, 'fraction_numerical': 0.0009900990099009901, 'mean_word_length': 4.077889447236181, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3488898', 'n_tokens_mistral': 718, 'n_tokens_neox': 698, 'n_words': 133}