/* file sptiers2.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif

void split_tiers2_prot(PROTECTED_INT_STR *seg_int, PROTECTED_INT_STR *str_int,
  PROTECTED_INT_STR *bnd_int, PROTECTED_INT_STR *sint, pcodeset *pcdp, int *perr)
          
/**********************************************************************/
/* Splits the phone int string *sint up into separate segmental,      */
/* stress, and bondary tiers in *seg_int, *str_int, and *bnd_int,     */
/* respectively.  The maximum number of units that it will put into   */
/* any of these integer arrays is *max_segs.  Uses info in *pcdp.     */
/* On return, *perr ==0 iff a.o.k.                                    */
/**********************************************************************/
 {char *proc = "split_tiers2_prot";
  int j, jseg, jstr, jbnd;
  int dbi;
/* coding */
  db_enter_msg(proc,1);

if (db_level > 2)
 {printf("%s sint->str = ",pdb);
  for (dbi=1; dbi <= sint->str[0]; dbi++) printf("%4d",sint->str[dbi]);
  printf("\n");
 }
/* split phones into segments, stresses, and boundaries */
  str_int->str[0] = 0;
  bnd_int->str[0] = 0;
  seg_int->str[0] = 0;
  jstr = 0;
  jbnd = 0;
  for (j=1; j <= sint->str[0]; j++)
    {jseg = sint->str[j];
     if (suprasegmental(jseg,pcdp))
       {if (stress_mark(jseg,pcdp))   jstr = jseg;
        if (boundary_mark(jseg,pcdp)) jbnd = jseg;
       }
     else
       {nstrcat_prot_i(str_int,jstr);
        nstrcat_prot_i(bnd_int,jbnd);
        nstrcat_prot_i(seg_int,jseg);
    }  }

if (db_level > 2)
 {printf("%sstresses & boundaries split out,\n",pdb);
  printf("%sstr_int->str=",pdb);
  for (dbi=1; dbi <= str_int->str[0]; dbi++) printf("%4d",str_int->str[dbi]);
  printf("\n");
  printf("%sbnd_int->str=",pdb);
  for (dbi=1; dbi <= bnd_int->str[0]; dbi++) printf("%4d",bnd_int->str[dbi]);
  printf("\n");
  printf("%sseg_int->str=",pdb);
  for (dbi=1; dbi <= seg_int->str[0]; dbi++) printf("%4d",seg_int->str[dbi]);
  printf("\n");
 }
  db_leave_msg(proc,1);
  return;
 } /* sptiers2_prot() */
