From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23040 invoked by alias); 28 Dec 2013 15:07:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23014 invoked by uid 48); 28 Dec 2013 15:07:14 -0000 From: "Denis.V.Kolesnik@safe-mail.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59598] very simple code using file open for read Date: Sat, 28 Dec 2013 15:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.6.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: blocker X-Bugzilla-Who: Denis.V.Kolesnik@safe-mail.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg02301.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D59598 Denis Kolesnik changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #14 from Denis Kolesnik --- In the following code:> // a small text file filter.c // #include main(int argc, char* argv[]) { char c, previous_c;=20=20=20=20=20=20=20 int word_begin_position[3000]; int spec_symbol[7]=3D{0xAE,0xBB,0xAB,0xA9,0x22,0x2F,0x27}; int eof_symbol[2]=3D{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=3D0;=20=20=20=20 stream =3D fopen (argv[1],"r"); while ((c =3D fgetc(stream)) !=3D EOF)=20 {=20=20=20=20 characters_count++; } fclose(stream); //printf("total characters are %i\n", characters_count);=20 character_number=3D1; words_count=3D0; previous_c=3D0; stream =3D fopen (argv[1],"r"); while ((c =3D fgetc(stream)) !=3D EOF)=20 { if(((c!=3D0x20) && (character_number=3D=3D1)) || ((previous_c=3D=3D= 0x20) && (c!=3D0x20) && (c!=3D0x0A)) || ((previous_c!=3D0x20) && (c=3D=3D0x0D)) || (= (c!=3D0x20) && (c!=3D0x0D) && (c!=3D0x0A) && (previous_c=3D=3D0x0A)) || ((previous_c!=3D0x= 20) && (previous_c!=3D0x0A) && (character_number=3D=3Dcharacters_count) && (c=3D= =3D0x20))) // 1. ((c!=3D0x20) && (character_number=3D=3D1)) // 2. ((previous_c=3D=3D0x20) && (c!=3D0x20) && (c!=3D0x0A)) // 3. ((previous_c!=3D0x20) && (c=3D=3D0x0D)) // !((previous_c!=3D0x0D) && (c=3D=3D0x0A)) // 4. ((c!=3D0x20) && (c!=3D0x0D) && (c!=3D0x0A) && (previous_c=3D= =3D0x0A)) // 5. ((previous_c!=3D0x20) && (previous_c!=3D0x0A) && (character_number=3D=3Dcharacters_count) && (c=3D=3D0x20)) this_is_the_same_word=3D0; else this_is_the_same_word=3D1; if(this_is_the_same_word=3D=3D0) { words_count++;=20=20=20=20=20=20=20=20=20=20=20=20 word_begin_position[words_count]=3Dcharacter_number; //printf(" the begin char is ..... %i",word_begin_position[words_count]); } //if(character_number=3D=3Dcharacters_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=3D=3D0x0D) printf(" the current character is ..... 0x0D\n"); if(c=3D=3D0x0A) printf(" the current character is ..... 0x0A\n"); */ previous_c=3Dc; character_number++; } fclose(stream); word_number=3D1;=20=20=20=20 character_number=3D1; A_count=3D1; E_count=3D1; stream =3D fopen (argv[1],"r"); //stream2 =3D fopen (argv[2],"w"); while ((c =3D fgetc(stream)) !=3D EOF)=20 {=20=20=20=20 other_character_printed=3D0; if((character_number >=3D word_begin_position[word_number]) && (character_number <=3D word_begin_position[word_number+1]) ) { if(((c=3D=3D'a') || (c=3D=3D'=D0=B0') || (c=3D=3D'A') || (c=3D= =3D'=D0=90')) ) { if(A_count=3D=3D1) { printf("A1"); A_count=3D2; other_character_printed=3D1; } else { printf("A2"); A_count=3D1; other_character_printed=3D1; } } else if((other_character_printed=3D=3D0) && ((c!=3D'=D0=B5') && (c!= =3D'e') && (c!=3D'=D0=95') && (c!=3D'E'))) { printf("%c", c); other_character_printed=3D1; } if((c=3D=3D'e') || (c=3D=3D'=D0=B5') || (c=3D=3D'=D0=95') || (c= =3D=3D'E')) { if(E_count=3D=3D1) { printf("E1"); E_count=3D2; other_character_printed=3D1; } else { printf("E2"); E_count=3D1; other_character_printed=3D1; } } else if((other_character_printed=3D=3D0) && (((c=3D=3D'a') & (c=3D= =3D'=D0=B0') && (c=3D=3D'A') && (c=3D=3D'=D0=90')))) { printf("%c", c); other_character_printed=3D1; } } else { A_count=3D1; E_count=3D1; word_number++; } character_number++; } fclose(stream); //printf(" the number of words is %i", words_count); return 0; } why other characters representing number are displayed to the screen except "0"? when the input text file is of the cintent: ARSeNALE 2012 ARSENALE It is a bug and nothing else! Nowhere in my code is stated to ignore "0" -- >>From gcc-bugs-return-438647-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Dec 28 15:09:59 2013 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 24051 invoked by alias); 28 Dec 2013 15:09:59 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 24033 invoked by uid 48); 28 Dec 2013 15:09:55 -0000 From: "Denis.V.Kolesnik@safe-mail.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59598] very simple code using file open for read Date: Sat, 28 Dec 2013 15:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.6.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: blocker X-Bugzilla-Who: Denis.V.Kolesnik@safe-mail.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg02302.txt.bz2 Content-length: 199 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59598 --- Comment #15 from Denis Kolesnik --- the output line is:> A1RSE1NA2LE2 212 A1 should be:> A1RSE1NA2LE2 2012 A1