/* file ttp_prep1_prot.c */

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

/*********************************************/
/* Pre-process input text:                   */
/* change <X>+s to <X>'s                     */
/* lower-case everything                     */
/* replace '-' with space                    */
/* remove punctuation except & and ' and \   */
/* make sure string begins & ends with space */
/*********************************************/
PROTECTED_CHR_STR *ttp_prep1_prot(PROTECTED_CHR_STR *ps_out, char *s_in)
{char *p;
 if (*s_in != ' ') strcat_prot_i(ps_out,' '); /* make sure output starts with space */
 for (p = s_in; *p != '\0'; p++)
   {if (p > s_in)
      {if ((*p == '+') && isalpha(*(p-1)) && isalpha(*(p+1)))
         {strcat_prot_i(ps_out,'\'');  /* "kiska+s" --> kiska's */
          continue;
      }  }
    if (*p == '-') /* replace "-" with space */
      {strcat_prot_i(ps_out,' ');
       continue;
      }
    if ( (!ispunct(*p)) ||
          (*p == '\'')  ||
          (*p == '\\')  ||
          (*p == '&'))
      {strcat_prot_i(ps_out,tolower(*p));
       continue;
      }
   }
 strcat_prot_i(ps_out,' '); /* make sure output ends with space */
 return ps_out;
}
