<commit_before>/*
 * File:  PPSpaceSequence.cpp
 * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
 */

#include <vector>

#include "sedna.h"

#include "PPSLStub.h"
#include "PPSpaceSequence.h"

using namespace std;
tuple_cell PPSpaceSequence::space_tup = tuple_cell::atomic_deep(xs_string, " ");
PPSpaceSequence::PPSpaceSequence(variable_context *_cxt_,
                       const arr_of_PPOpIn &_ch_arr_) : PPSequence(_cxt_,_ch_arr_)
{
	space=false;
	int_tup=tuple(1);
	int_tup.set_eos();
}
PPSpaceSequence::~PPSpaceSequence()
{
    for (it = 0; it < ch_arr.size(); it++) 
    {
        delete (ch_arr[it].op);
        ch_arr[it].op = NULL;
    }
}
PPIterator* PPSpaceSequence::copy(variable_context *_cxt_)
{
    PPSpaceSequence *res = new PPSpaceSequence(_cxt_, ch_arr);

    for (it = 0; it < ch_arr.size(); it++)
        res->ch_arr[it].op = ch_arr[it].op->copy(_cxt_);

    return res;
}
void PPSpaceSequence::next(tuple &t)
{
	if (!int_tup.is_eos())
	{
		t.copy(int_tup);
		int_tup.set_eos();
		space=true;
		return;
	}
	while (it < ch_arr.size())
    {
        ch_arr[it].op->next(int_tup);

        if (int_tup.is_eos()) it++;
        else 
		{
			if (space)
			{
				t.copy(space_tup);
				space=false;
			}
			else
			{
				t.copy(int_tup);
				int_tup.set_eos();
				space=true;
			}
			return;
		}
    }

    t.set_eos();
    it = 0;
	space=false;
}<commit_msg>spacesequence-fix<commit_after>/*
 * File:  PPSpaceSequence.cpp
 * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
 */

#include <vector>

#include "sedna.h"

#include "PPSLStub.h"
#include "PPSpaceSequence.h"

using namespace std;
tuple_cell PPSpaceSequence::space_tup = tuple_cell::atomic_deep(xs_string, " ");
PPSpaceSequence::PPSpaceSequence(variable_context *_cxt_,
                       const arr_of_PPOpIn &_ch_arr_) : PPSequence(_cxt_,_ch_arr_)
{
	space=false;
	int_tup=tuple(1);
	int_tup.set_eos();
}
PPSpaceSequence::~PPSpaceSequence()
{
    for (it = 0; it < ch_arr.size(); it++) 
    {
        delete (ch_arr[it].op);
        ch_arr[it].op = NULL;
    }
}
PPIterator* PPSpaceSequence::copy(variable_context *_cxt_)
{
    PPSpaceSequence *res = new PPSpaceSequence(_cxt_, ch_arr);

    for (it = 0; it < ch_arr.size(); it++)
        res->ch_arr[it].op = ch_arr[it].op->copy(_cxt_);

    return res;
}
void PPSpaceSequence::next(tuple &t)
{
	if (!int_tup.is_eos())
	{
		t.copy(int_tup);
		space=int_tup.cells[0].is_atomic();
		int_tup.set_eos();
		
		return;
	}
	while (it < ch_arr.size())
    {
        ch_arr[it].op->next(int_tup);

        if (int_tup.is_eos()) it++;
        else 
		{
			if (space && int_tup.cells[0].is_atomic())
			{
				t.copy(space_tup);
				space=false;
			}
			else
			{
				t.copy(int_tup);
				space=int_tup.cells[0].is_atomic();
				int_tup.set_eos();
				
			}
			return;
		}
    }

    t.set_eos();
    it = 0;
	space=false;
}
{'fraction_non_alphanumeric': 0.15548780487804878, 'fraction_numerical': 0.006436314363143632, 'mean_word_length': 3.1358543417366946, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3303602', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1195, 'n_words': 203}