On Thu, Jan 22, 2015 at 12:25:20PM +0400, Maxim Ostapenko wrote: > gcc/ChangeLog: > > 2015-01-22 Max Ostapenko <m.ostape...@partner.samsung.com> > > PR driver/64690 > * gcc.c (insert_comments): New function. > (try_generate_repro): Call it. > (append_text): Removed. > > diff --git a/gcc/gcc.c b/gcc/gcc.c > index 52d0521..6d3939c 100644 > --- a/gcc/gcc.c > +++ b/gcc/gcc.c > @@ -6487,6 +6487,28 @@ out: > return status; > } > > +/* This routine reads lines from IN file, adds C++ style comments > + at the begining of each line and writes result into OUT. */ > + > +static void > +insert_comments (const char *file_in, const char *file_out) > +{ > + FILE *in = fopen (file_in, "rb"); > + FILE *out = fopen (file_out, "wb"); > + char line[256]; > + fputs ("// ", out); > + while (fgets (line, sizeof (line), in)) > + { > + fputs (line, out); > + if (strchr (line, '\n')) > + { > + fputs ("// ", out); > + }
Please don't put {}s around single line if body. Also, if file_in ends with a newline, won't that mean an extra "// " will be printed? So what about bool add_comment = true; while (fgets (line, sizeof (line, in)) { if (add_comment) fputs ("// ", out); add_comment = strchr (line, '\n') != NULL; } ? Otherwise LGTM. Jakub