示例#1
0
main()
{
  int i,j,k;
  char *s;
  unsigned char anf;

  srandom(getpid());
  for(i=ITEM_WEAR_FINGER,j=0;i<=ITEM_WEAR_EARS;i<<=1,j++){
    printf("#%d\n",BASE+j);
    s=item_list[j].name;
    k=(random()%NDESCR);
    anf=(!item_list[j].pair)&&(VOWEL(*descr[k]));
    printf("%s~\n",s);
    printf("%s%s%s %s~\n",
      anf ? "An" : "A",
      item_list[j].pair ? " pair of " : " ",
      descr[k],
      s);
    printf("%s%s%s %s is in the dirt.~\n",
      anf ? "An" : "A",
      item_list[j].pair ? " pair of " : " ",
      descr[k],
      s);
    printf("~\n%d %d %d\n",item_list[j].type,rndflags(),i+1);
    printf("%d 0 0 0\n",RNDARMOR);
    printf("%d %d %d\n",10,1000,100);
  }
}
int main()
{
	bool flag(true),isVowel(false);
	char c, tar;

	while ((c = getchar())!=EOF)
	{
		
			if (!isalpha(c))
			{
				if (flag)
				{
					putchar(c);
					continue;
				}

				if (!isVowel)
					putchar(tar);

				putchar('a');
				putchar('y');
				putchar(c);
				flag = true;
				continue;
			}


			if (flag)
			{
				tar = c;
				flag = false;

				if (VOWEL(tar))
				{
					putchar(tar);
					isVowel = true;
				}
				else isVowel = false;
			}
			else putchar(c);
		
	}


	return 0;
}
示例#3
0
文件: im.c 项目: anandtrex/imli-s60
EXPORT_C syl_t imli_syl_compose (imli_context_t ctx,
			byte_t input, imli_char_type_t type,
			imli_script_t script_prev_syl,
			syl_t prev_syl,
			imli_compose_flag_t flag,
			int *delete_prev_syl)
{
    byte_t c, cons1, cons2, cons3, cons4, v;
    syl_t syl, temp;
    *delete_prev_syl = 0;
    syl = SYL_INVALID;
    
    switch ( type )
    {
    case TYPE_INVALID:
	break;
    case TYPE_SPECIAL:
	//printf("Type = SPECIAL, input = %d\n", input);
	syl = (SPECIAL_START | input);
	break;
    case TYPE_VOWEL:
	//printf("Type = VOWEL, input = %d\n", input);
	syl = (input & VOWEL_MASK);

	/* Check if the previous character was a consonant with "ah" as vowel */
	if (prev_syl == SYL_INVALID) 
	    return syl;

	/* Don't combine across scripts */
	if (imli_get_active_script(ctx) != script_prev_syl)
	    return syl;

	/* Don't combine with special and ascii syllables */
	if (IS_SYL_ASCII(prev_syl) || ( IS_SYL_SPECIAL(prev_syl)))
	    return syl;

	c = CONSONANT(prev_syl);
	v = VOWEL(prev_syl);

	/* useful for implementing vowel rule */
	if (flag == FLAG_STANDALONE_VOWEL)
	{
	    /* delete orphaned halants */
	    if (v == HALANT && c == 0)
		*delete_prev_syl = 1;
	    return syl;
	}

	/* non-joiner */
	if (v == HALANT && input == HALANT && c != 0)
	    return syl;

	if (c && ( v == 0))
	{
	    syl = prev_syl | input;
	    *delete_prev_syl = 1;
	}
	return syl;

    case TYPE_CONSONANT:
	//printf("Type = CONSONANT, input = %d\n", input);
	syl = SYLLABLE(input, 0, 0); /* By default */

	/* Don't combine across scripts */
	if (imli_get_active_script(ctx) != script_prev_syl)
	    return syl;

	/* Nothing much to do if there was no prev syl_t or if the prev syl_t
	 * was a special, vowel or english
	 */
	if ((prev_syl == SYL_INVALID) ||
	    (IS_SYL_ASCII(prev_syl))  ||   /* English    */
	    (IS_SYL_SPECIAL(prev_syl)))    /* Special    */
	{
	    return syl;
	}
	
	v = VOWEL(prev_syl);
	c = CONSONANT(prev_syl);

	/* FIXME: handle nukhta using only 2 keys 
	 *  Old code follows:
	 */
/* 	if (key == ']' && v == 0) */
/* 	    v = HALANT; */

        if (flag == FLAG_INSERT_HALANT && v == 0)
            v = HALANT;

	if (input == NUKHTA && v == 0)
	    v = HALANT;

	/* Combine only if there is a halant */
	if (v != HALANT) return syl;

	/* remove standalone halant */
	if (c == 0 )
	{
	    *delete_prev_syl = 1;
	    return syl;
	}
	
	if (imli_is_syl_full(ctx, prev_syl, &cons1, &cons2, &cons3, &cons4))
	    return syl;

	if (cons2 == 0)
	{
	    /* create a new conjunct */
	    *delete_prev_syl = 1;

	    // hardcoded syllables for ksha and jnya (promoted consonants)
	    if (c == KA && input == SHA ) // ksha
		return SYLLABLE(KSHA, 0, 0);
	    else if (c == JA && input == NJA ) // jnya
		return SYLLABLE(JNYA, 0, 0);
            else if (c == NA)
	    {
		 /* if na fails, check in nex */
		temp = imli_get_conjunct_code (ctx, c, input, 0, 0);
		if (temp != 0xFFFF) 
		    return temp; 
		else 
		    c = NEX;

		temp = imli_get_conjunct_code (ctx, c, input, 0, 0);
		if (temp != 0xFFFF) 
		    return temp; 
		else 
		    *delete_prev_syl = 0;
                return syl;
	    }
	    else if (c == RA)
	    {
		 /* if ra fails, check in rex */
		temp = imli_get_conjunct_code (ctx, c, input, 0, 0);
		if (temp != 0xFFFF) 
                {
		    return temp; 
                }
                c = REX;
                temp = imli_get_conjunct_code (ctx, c, input, 0, 0);
                if (temp != 0xFFFF)
                    return temp;
                
                c = RXL;
                temp = imli_get_conjunct_code(ctx, c, input, 0, 0);
                if (temp != 0xFFFF)
                    return temp;
                    
                c = RXXL;
	    }
	    temp = imli_get_conjunct_code(ctx, c, input, 0, 0);
	    if (temp != 0xFFFF ) 
		return temp;
	    else
		*delete_prev_syl = 0;
	    return syl;
	}

	if (cons3 == 0)
	{
	    temp = imli_get_conjunct_code(ctx, c, cons2, input, 0);
	    if (temp != 0xFFFF )
	    {
		*delete_prev_syl = 1;
		return temp;
	    }
            else 
            {
                *delete_prev_syl = 0;
                return syl;
            }
	}

	if (cons4 == 0)
	{
	    temp = imli_get_conjunct_code(ctx, c, cons2, cons3, input);
	    if (temp != 0xFFFF )
	    {
		*delete_prev_syl = 1;
		return temp;
	    }
        }
        
	*delete_prev_syl = 0;
	return syl;
    default:
        break;
    }
    return syl;
}