This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR 18785: alternative patch


Zack Weinberg <zack@codesourcery.com> writes:

[...]

|  static void
|  pp_c_char (c_pretty_printer *pp, int c)
|  {
| -  switch (c)

[...]

| -    case '\\':
| -      pp_string (pp, "\\\\");
| -      break;
| -    case '\'':
| -      pp_string (pp, "\\'");
| -      break;
| -    case '\"':
| -      pp_string (pp, "\\\"");
| -      break;
| -    default:
| -      if (ISPRINT (c))
| -	pp_character (pp, c);
| -      else
| -	pp_scalar (pp, "\\%03o", (unsigned) c);
| -      break;
| +      switch (c)
| +	{
| +	case '\\': pp_string (pp, "\\\\"); break;
| +	case '\'': pp_string (pp, "\\\'"); break;
| +	case '\"': pp_string (pp, "\\\""); break;
| +	default:   pp_character (pp, c);
| +	}

A style question:  isn't it the convention to write

     case '\\':
       pp_string (pp, "\\\\");
       break;

as opposed to yours?

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]