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

shader test_split_u_str_u_sep_u_max (output vector res=0, 
		   output vector calres = 0)
{
    string uniform_str = format("%d",raytype("camera"));
    string uniform_sep = ",";
    int uniform_maxsplit = 3;
        
    //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 uval = raytype("camera");
    int sc = split(format("%d,%d,%d,%d", 2*uval, 2*uval, 6*uval, 8*uval ),results, uniform_sep, uniform_maxsplit); 
    res = vector (u+v, v, (float) sc*u);
    
    int accum = 0;
    for (int i = 0 ; i< sc; ++i) {
        accum += stoi(results[i]);
    }
    
    int accum2 = 0;
    
    int sc2 = 0;
    if(int(P[0]*64)%2){
    	 sc2 = split(format("%d,%d,%d,%d", 3*uval,4*uval,9*uval,12*uval),results1, uniform_sep, uniform_maxsplit);
    }
    
    for (int i = 0 ; i< sc2; ++i) {
        accum2 += stoi(results1[i]);
    }
    calres = vector(((float)accum2)/(14.0 + u*14), u+v, ((float)accum)/(9 + v*9)); 
}
