/* file seporth2.c */

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

#if !defined(LEX_COMPILE_ENVIRONMENT)
#include <plex/stdcenvf.h> /* phonlex compile environment for functions */
#endif

 void separate_orth(char *snor, char *caps, char *diacritics, char *orth)
                                       
/**************************************************************************/
/* Splits standard orthography *orth into snor, caps, and diacritics.     */
/**************************************************************************/
 {char *proc = "separate_orth";
  char *ps,*pc,*pd,*pk;
  char diacritic_from_previous_char;
 db_enter_msg(proc,2); /* debug only */
  *snor = '\0'; *caps = '\0'; *diacritics = '\0'; /* null output strings */
  ps = snor;  pc = caps; pd = diacritics; /* loop sorting input into output */
/* lift diacritics */
  diacritic_from_previous_char = ' ';
  for (pk = orth; *pk != '\0'; pk++)
    {if (*pk == '\\') /* diacritic flag */
       {diacritic_from_previous_char = *(++pk);
       }
     else
       {*ps = *pk;
        *pd = diacritic_from_previous_char; *++pd = '\0';
        diacritic_from_previous_char = ' ';
/* handle capitalization */
        if (isupper((int)*ps)) {*pc = '+'; *ps = tolower(*ps);}
        else                   {*pc = ' ';}
        *++pc = '\0';
        *++ps = '\0';
    }  }

 db_leave_msg(proc,2); /* debug only */
  return;
 }
