// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader test_split_v_str_v_sep_v_max_ura (output vector res=0, 
           output vector calres = 0)
{
    string var_str = format("%f",v);
    string var_sep = format("%d", int(u)); //Varying sep
    int var_maxsplit = 4+int(u);//varying maxsplit
    
    string uniform_str = "spam";    
    //Initialize result output array
    string results[4] = {uniform_str,uniform_str,uniform_str,uniform_str}; 
    string results1[4] = {uniform_str,uniform_str,uniform_str,uniform_str};
    
    //Setup uniform string
    int accum1 = 0;
    int sc1 = 0;
    sc1 = split(format("%f,%d,%f,%f", 2.0*u, int(u), 2.0*v, 3.0*u ),results, var_sep, var_maxsplit); //varying string amd varying separator
    
    for (int i = 0 ; i<sc1; ++i) {
        accum1 += stoi(results[i]);
    }
    res = vector (accum1/40.0, u, (float) sc1*u);
    
    int accum2 = 0;
    int sc2 = 0;
    
    if(int(P[0]*64)%2){
        split(format("%f,%d,%f,%f", 2.0*(u+v), int(u), 4.0*(v-u),2.0*v),results1, var_sep, var_maxsplit);//varying string and varying sep
    }
    
    for (int i = 0 ; i<sc2; ++i){
        accum2 += stoi(results1[i]);
    }
    
    calres = vector(((float)accum2)+1.2/(4.0 + u*4.0), (u+v), ((float)accum1)+1.5/(3.5 + v*3.5)); 
}
