/* file orth2key1_prot.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 orth2key1_prot(PROTECTED_CHR_STR *key, char *orth, int *perr)
/************************************************************/
/* Converts orthography (spelling) in *orth to lex key *key.*/
/* On return, *perr > 0 signals an error.                   */
/************************************************************/
 {char *proc = "orth2key1_prot";
  char *p,*q;
/* coding */
 db_enter_msg(proc,0); /* debug only */
  *perr = 0;
  strcpy_prot_s(key,orth);
 /* remove diacritics */
  q = key->str;
  for (p = key->str; *p != '\0'; p++)
    {if (*p == '\\') p++; /* diacritic flag */
     *q++ = *p;
    }
  *q = '\0';
 /* lower case */
  make_lower(key->str);
 /* fill space with '=' in key, to make a token */
  str_encode(key->str," ","=");
 /* delete initial apostrophe in key */
  if (key->str[0] == '\'')
    {for (p = key->str; *p != '\0'; p++) {*p = *p+1;}
    }
 db_leave_msg(proc,0); /* debug only */
return;
 } /* end orth2key1_prot */
