http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59598

Denis Kolesnik <denis.v.koles...@safe-mail.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #34 from Denis Kolesnik <denis.v.koles...@safe-mail.net> ---
// a small text file filter.c //

#include <stdio.h>





main(int argc, char* argv[])

{


    char c, previous_c;       

    int word_begin_position[3000];


    //int spec_symbol[7]={0xAE,0xBB,0xAB,0xA9,0x22,0x2F,0x27};


    //int eof_symbol[2]={0x0D,0x0A};
    int search_result;

    int this_is_the_same_word;
    int words_count;
    int word_number;

    int search_result_A_count;
    int search_result_space;

    FILE *stream,*stream2;


    int i, j, characters_count, character_number;
    int other_character_printed;


    // double characters
    int A_count, E_count;



    characters_count=0;    

    stream = fopen (argv[1],"r");

    while ((c = fgetc(stream)) != EOF) 

    {    
        characters_count++;

    }
    fclose(stream);
    //printf("total characters are %i\n", characters_count); 


    character_number=1;
    words_count=0;
    previous_c=0;


    stream = fopen (argv[1],"r");

    while ((c = fgetc(stream)) != EOF) 

    {
        if(((c!=0x20) && (character_number==1)) || ((previous_c==0x20) &&
(c!=0x20) && (c!=0x0A)) || ((previous_c!=0x20) && (c==0x0D)) || ((c!=0x20) &&
(c!=0x0D) && (c!=0x0A) && (previous_c==0x0A)) || ((previous_c!=0x20) &&
(previous_c!=0x0A) && (character_number==characters_count) && (c==0x20)))

//        1. ((c!=0x20) && (character_number==1))
//        2. ((previous_c==0x20) && (c!=0x20) && (c!=0x0A))
//        3. ((previous_c!=0x20) && (c==0x0D))
//        !((previous_c!=0x0D) && (c==0x0A))
//        4. ((c!=0x20) && (c!=0x0D) && (c!=0x0A) && (previous_c==0x0A))
//        5. ((previous_c!=0x20) && (previous_c!=0x0A) &&
(character_number==characters_count) && (c==0x20))

            this_is_the_same_word=0;
        else
            this_is_the_same_word=1;

        if(this_is_the_same_word==0)
        {
            words_count++;            
            word_begin_position[words_count]=character_number;

            //printf(" the begin char is .....
%i",word_begin_position[words_count]);
        }

    //if(character_number==characters_count)
    //    printf("the last character");
/*
    printf(" the number of words is %i\n", words_count);
    printf(" the current character is ..... %c\n", c);
    if(c==0x0D)
        printf(" the current character is ..... 0x0D\n");
    if(c==0x0A)
        printf(" the current character is ..... 0x0A\n");
*/
        previous_c=c;
        character_number++;
    }
    fclose(stream);



    word_number=1;    
    character_number=1;

    A_count=1;
    E_count=1;

    stream = fopen (argv[1],"r");

    //stream2 = fopen (argv[2],"w");

    while ((c = fgetc(stream)) != EOF) 

    {    

        other_character_printed=0;
        if(words_count>=2)
        if(word_number<words_count-1)
        if((character_number >= word_begin_position[word_number]) &&
(character_number < word_begin_position[word_number+1]))
        {
            A_count=1;
            E_count=1;

            word_number++;
        }

        //printf("\n the word begin position
%i\n",word_begin_position[word_number]);
        //printf("\n1 char is %i\n", character_number);
        //printf("\nthe words count is %i\n", words_count);

        // A
        if((other_character_printed==0) && ((c=='a') || (c=='а') || (c=='A') ||
(c=='А')) )
        if(A_count==1)
        {
            printf("A1");
            A_count=2;
            other_character_printed=1;
        }
        else
        {
            printf("A2");
            A_count=1;
            other_character_printed=1;
        }
        else
        if((other_character_printed==0) && ((c!='е') && (c!='e') && (c!='Е') &&
(c!='E')))
        {
            printf("%c", c);
            other_character_printed=1;
        }

        // E
        if((other_character_printed==0) && ((c=='e') || (c=='е') || (c=='E') ||
(c=='Е')) )
        if(E_count==1)
        {
            printf("E1");
            E_count=2;
            other_character_printed=1;
        }
        else
        {
            printf("E2");
            E_count=1;
            other_character_printed=1;
        }
        else
        if((other_character_printed==0) && ((c!='a') && (c!='а') && (c!='А') &&
(c!='A')))
        {
            printf("%c", c);
            other_character_printed=1;
        }


        //if(c=='0')
        //{
        //    printf("%c", c);
        //    other_character_printed=1;
        //}


        character_number++;
    }
    fclose(stream);
    //printf(" the number of words is %i", words_count);



    return 0;

}

Reply via email to