contrib/gdb-7/gdb/utils.c
int
parse_escape (struct gdbarch *gdbarch, char **string_ptr)
{
  int target_char = -2;	/* Initialize to avoid GCC warnings.  */
  int c = *(*string_ptr)++;

  switch (c)
    {
      case '\n':
	return -2;
      case 0:
	(*string_ptr)--;
	return 0;

      case '0':
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
	{
	  int i = host_hex_value (c);
	  int count = 0;
	  while (++count < 3)
	    {
	      c = (**string_ptr);
	      if (isdigit (c) && c != '8' && c != '9')
		{
		  (*string_ptr)++;
		  i *= 8;
		  i += host_hex_value (c);
		}
	      else
		{
		  break;
		}
	    }
	  return i;
	}

    case 'a':
      c = '\a';
      break;
    case 'b':
      c = '\b';
      break;
    case 'f':
      c = '\f';
      break;
    case 'n':
      c = '\n';
      break;
    case 'r':
      c = '\r';
      break;
    case 't':
      c = '\t';
      break;
    case 'v':
      c = '\v';
      break;

    default:
      break;
    }

  if (!host_char_to_target (gdbarch, c, &target_char))
    error (_("The escape sequence `\\%c' is equivalent to plain `%c',"
	     " which has no equivalent\nin the `%s' character set."),
	   c, c, target_charset (gdbarch));
  return target_char;
}
/* Parse a C escape sequence.  STRING_PTR points to a variable
   containing a pointer to the string to parse.  That pointer
   should point to the character after the \.  That pointer
   is updated past the characters we use.  The value of the
   escape sequence is returned.

   A negative value means the sequence \ newline was seen,
   which is supposed to be equivalent to nothing at all.

   If \ is followed by a null character, we return a negative
   value and leave the string pointer pointing at the null character.

   If \ is followed by 000, we return 0 and leave the string pointer
   after the zeros.  A value of 0 does not mean end of string.  */
Parse a C escape sequence.  STRING_PTR points to a variable
containing a pointer to the string to parse.  That pointer
should point to the character after the \.  That pointer
is updated past the characters we use.  The value of the
escape sequence is returned.

A negative value means the sequence \ newline was seen,
which is supposed to be equivalent to nothing at all.

If \ is followed by a null character, we return a negative
value and leave the string pointer pointing at the null character.

If \ is followed by 000, we return 0 and leave the string pointer
after the zeros.  A value of 0 does not mean end of string.
Parse a C escape sequence . STRING_PTR points to a variable containing a pointer to the string to parse . That pointer should point to the character after the \ . That pointer is updated past the characters we use . The value of the escape sequence is returned . A negative value means the sequence \ newline was seen which is supposed to be equivalent to nothing at all . If \ is followed by a null character we return a negative value and leave the string pointer pointing at the null character . If \ is followed by 000 we return 0 and leave the string pointer after the zeros . A value of 0 does not mean end of string .
int
parse_escape (struct gdbarch *gdbarch, char **string_ptr)
{
  int target_char = -2;	
  int c = *(*string_ptr)++;
  switch (c)
    {
      case '\n':
	return -2;
      case 0:
	(*string_ptr)--;
	return 0;
      case '0':
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
	{
	  int i = host_hex_value (c);
	  int count = 0;
	  while (++count < 3)
	    {
	      c = (**string_ptr);
	      if (isdigit (c) && c != '8' && c != '9')
		{
		  (*string_ptr)++;
		  i *= 8;
		  i += host_hex_value (c);
		}
	      else
		{
		  break;
		}
	    }
	  return i;
	}
    case 'a':
      c = '\a';
      break;
    case 'b':
      c = '\b';
      break;
    case 'f':
      c = '\f';
      break;
    case 'n':
      c = '\n';
      break;
    case 'r':
      c = '\r';
      break;
    case 't':
      c = '\t';
      break;
    case 'v':
      c = '\v';
      break;
    default:
      break;
    }
  if (!host_char_to_target (gdbarch, c, &target_char))
    error (_("The escape sequence `\\%c' is equivalent to plain `%c',"
	     " which has no equivalent\nin the `%s' character set."),
	   c, c, target_charset (gdbarch));
  return target_char;
}
int parse_escape ( struct gdbarch * gdbarch , char * * string_ptr ) { int target_char = -2 ; int c = * ( * string_ptr ) ++ ; switch ( c ) { case ' \n ' : return -2 ; case 0 : ( * string_ptr ) -- ; return 0 ; case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : { int i = host_hex_value ( c ) ; int count = 0 ; while ( ++ count < 3 ) { c = ( * * string_ptr ) ; if ( isdigit ( c ) && c != ' ' && c != ' ' ) { ( * string_ptr ) ++ ; i *= 8 ; i += host_hex_value ( c ) ; } else { break ; } } return i ; } case ' ' : c = ' \a ' ; break ; case ' ' : c = ' \b ' ; break ; case ' ' : c = ' \f ' ; break ; case ' ' : c = ' \n ' ; break ; case ' ' : c = ' \r ' ; break ; case ' ' : c = ' \t ' ; break ; case ' ' : c = ' \v ' ; break ; default : break ; } if ( ! host_char_to_target ( gdbarch , c , & target_char ) ) error ( _ ( " \\ " " \n " ) , c , c , target_charset ( gdbarch ) ) ; return target_char ; }
Parse a C escape sequence.
Parse a C escape sequence .
/* Initialize to avoid GCC warnings.  */