<commit_before>//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 <NAME> (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: <EMAIL>
//          <EMAIL>
//          http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Line dash generator
//
//----------------------------------------------------------------------------

#include <math.h>
#include "agg_vcgen_dash.h"
#include "agg_shorten_path.h"

namespace agg
{

//------------------------------------------------------------------------
vcgen_dash::vcgen_dash() :
    m_total_dash_len(0.0),
    m_num_dashes(0),
    m_dash_start(0.0),
    m_shorten(0.0),
    m_curr_dash_start(0.0),
    m_curr_dash(0),
    m_src_vertices(),
    m_closed(0),
    m_status(initial),
    m_src_vertex(0)
{
}



//------------------------------------------------------------------------
void vcgen_dash::remove_all_dashes()
{
    m_total_dash_len = 0.0;
    m_num_dashes = 0;
    m_curr_dash_start = 0.0;
    m_curr_dash = 0;
}


//------------------------------------------------------------------------
void vcgen_dash::add_dash(double dash_len, double gap_len)
{
    if(m_num_dashes < max_dashes)
    {
        m_total_dash_len += dash_len + gap_len;
        m_dashes[m_num_dashes++] = dash_len;
        m_dashes[m_num_dashes++] = gap_len;
    }
}


//------------------------------------------------------------------------
void vcgen_dash::dash_start(double ds)
{
    m_dash_start = ds;
    calc_dash_start(std::fabs(ds));
}


//------------------------------------------------------------------------
void vcgen_dash::calc_dash_start(double ds)
{
    m_curr_dash = 0;
    m_curr_dash_start = 0.0;
    while(ds > 0.0)
    {
        if(ds > m_dashes[m_curr_dash])
        {
            ds -= m_dashes[m_curr_dash];
            ++m_curr_dash;
            m_curr_dash_start = 0.0;
            if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;<commit_msg>fix possible out-of-bounds write [coverity]<commit_after>//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 <NAME> (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: <EMAIL>
//          <EMAIL>
//          http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Line dash generator
//
//----------------------------------------------------------------------------

#include <math.h>
#include "agg_vcgen_dash.h"
#include "agg_shorten_path.h"

namespace agg
{

//------------------------------------------------------------------------
vcgen_dash::vcgen_dash() :
    m_total_dash_len(0.0),
    m_num_dashes(0),
    m_dash_start(0.0),
    m_shorten(0.0),
    m_curr_dash_start(0.0),
    m_curr_dash(0),
    m_src_vertices(),
    m_closed(0),
    m_status(initial),
    m_src_vertex(0)
{
}



//------------------------------------------------------------------------
void vcgen_dash::remove_all_dashes()
{
    m_total_dash_len = 0.0;
    m_num_dashes = 0;
    m_curr_dash_start = 0.0;
    m_curr_dash = 0;
}


//------------------------------------------------------------------------
void vcgen_dash::add_dash(double dash_len, double gap_len)
{
    if(m_num_dashes < max_dashes-1)
    {
        m_total_dash_len += dash_len + gap_len;
        m_dashes[m_num_dashes++] = dash_len;
        m_dashes[m_num_dashes++] = gap_len;
    }
}


//------------------------------------------------------------------------
void vcgen_dash::dash_start(double ds)
{
    m_dash_start = ds;
    calc_dash_start(std::fabs(ds));
}


//------------------------------------------------------------------------
void vcgen_dash::calc_dash_start(double ds)
{
    m_curr_dash = 0;
    m_curr_dash_start = 0.0;
    while(ds > 0.0)
    {
        if(ds > m_dashes[m_curr_dash])
        {
            ds -= m_dashes[m_curr_dash];
            ++m_curr_dash;
            m_curr_dash_start = 0.0;
            if(m_curr_dash >= m_num_dashes) m_curr_dash = 0;
{'fraction_non_alphanumeric': 0.37484355444305384, 'fraction_numerical': 0.015227367542761786, 'mean_word_length': 1.1141975308641976, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2623109', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1393, 'n_words': 259}