contrib/gdb-7/gdb/linespec.c
static char *
locate_first_half (char **argptr, int *is_quote_enclosed)
{
  char *ii;
  char *p, *p1;
  int has_comma;

  /* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
     and we must isolate the first half.  Outer layers will call again later
     for the second half.

     Don't count commas that appear in argument lists of overloaded
     functions, or in quoted strings.  It's stupid to go to this much
     trouble when the rest of the function is such an obvious roach hotel.  */
  ii = find_toplevel_char (*argptr, ',');
  has_comma = (ii != 0);

  /* Temporarily zap out second half to not confuse the code below.
     This is undone below.  Do not change ii!!  */
  if (has_comma)
    {
      *ii = '\0';
    }

  /* Maybe arg is FILE : LINENUM or FILE : FUNCTION.  May also be
     CLASS::MEMBER, or NAMESPACE::NAME.  Look for ':', but ignore
     inside of <>.  */

  p = *argptr;
  if (p[0] == '"')
    {
      *is_quote_enclosed = 1;
      (*argptr)++;
      p++;
    }
  else
    {
      *is_quote_enclosed = 0;
      if (strchr (get_gdb_completer_quote_characters (), *p))
	{
	  ++(*argptr);
	  ++p;
	}
    }


  /* Check for a drive letter in the filename.  This is done on all hosts
     to capture cross-compilation environments.  On Unixen, directory
     separators are illegal in filenames, so if the user enters "e:/foo.c",
     he is referring to a directory named "e:" and a source file named
     "foo.c", and we still want to keep these two pieces together.  */
  if (isalpha (p[0]) && p[1] == ':' && IS_DIR_SEPARATOR (p[2]))
    p += 3;

  for (; *p; p++)
    {
      if (p[0] == '<')
	{
	  char *temp_end = find_template_name_end (p);

	  if (!temp_end)
	    error (_("malformed template specification in command"));
	  p = temp_end;
	}

      if (p[0] == '(')
	p = find_method_overload_end (p);

      /* Check for a colon and a plus or minus and a [ (which
         indicates an Objective-C method).  */
      if (is_objc_method_format (p))
	{
	  break;
	}
      /* Check for the end of the first half of the linespec.  End of
         line, a tab, a colon or a space.  But if enclosed in double
	 quotes we do not break on enclosed spaces.  */
      if (!*p
	  || p[0] == '\t'
	  || (p[0] == ':')
	  || ((p[0] == ' ') && !*is_quote_enclosed))
	break;
      if (p[0] == '.' && strchr (p, ':') == NULL)
	{
	  /* Java qualified method.  Find the *last* '.', since the
	     others are package qualifiers.  Stop at any open parenthesis
	     which might provide overload information.  */
	  for (p1 = p; *p1 && *p1 != '('; p1++)
	    {
	      if (*p1 == '.')
		p = p1;
	    }
	  break;
	}
    }
  p = skip_spaces (p);

  /* If the closing double quote was left at the end, remove it.  */
  if (*is_quote_enclosed)
    {
      char *closing_quote = strchr (p - 1, '"');

      if (closing_quote && closing_quote[1] == '\0')
	*closing_quote = '\0';
    }

  /* Now that we've safely parsed the first half, put back ',' so
     outer layers can see it.  */
  if (has_comma)
    *ii = ',';

  return p;
}
/* Locate the first half of the linespec, ending in a colon, period,
   or whitespace.  (More or less.)  Also, check to see if *ARGPTR is
   enclosed in double quotes; if so, set is_quote_enclosed, advance
   ARGPTR past that and zero out the trailing double quote.
   If ARGPTR is just a simple name like "main", p will point to ""
   at the end.  */
Locate the first half of the linespec, ending in a colon, period,
or whitespace.  (More or less.)  Also, check to see if *ARGPTR is
enclosed in double quotes; if so, set is_quote_enclosed, advance
ARGPTR past that and zero out the trailing double quote.
If ARGPTR is just a simple name like "main", p will point to ""
at the end.
Locate the first half of the linespec ending in a colon period or whitespace . ( More or less . ) Also check to see if * ARGPTR is enclosed in double quotes ; if so set is_quote_enclosed advance ARGPTR past that and zero out the trailing double quote . If ARGPTR is just a simple name like " main " p will point to " " at the end .
static char *
locate_first_half (char **argptr, int *is_quote_enclosed)
{
  char *ii;
  char *p, *p1;
  int has_comma;
  ii = find_toplevel_char (*argptr, ',');
  has_comma = (ii != 0);
  if (has_comma)
    {
      *ii = '\0';
    }
  p = *argptr;
  if (p[0] == '"')
    {
      *is_quote_enclosed = 1;
      (*argptr)++;
      p++;
    }
  else
    {
      *is_quote_enclosed = 0;
      if (strchr (get_gdb_completer_quote_characters (), *p))
	{
	  ++(*argptr);
	  ++p;
	}
    }
  if (isalpha (p[0]) && p[1] == ':' && IS_DIR_SEPARATOR (p[2]))
    p += 3;
  for (; *p; p++)
    {
      if (p[0] == '<')
	{
	  char *temp_end = find_template_name_end (p);
	  if (!temp_end)
	    error (_("malformed template specification in command"));
	  p = temp_end;
	}
      if (p[0] == '(')
	p = find_method_overload_end (p);
      if (is_objc_method_format (p))
	{
	  break;
	}
      if (!*p
	  || p[0] == '\t'
	  || (p[0] == ':')
	  || ((p[0] == ' ') && !*is_quote_enclosed))
	break;
      if (p[0] == '.' && strchr (p, ':') == NULL)
	{
	  for (p1 = p; *p1 && *p1 != '('; p1++)
	    {
	      if (*p1 == '.')
		p = p1;
	    }
	  break;
	}
    }
  p = skip_spaces (p);
  if (*is_quote_enclosed)
    {
      char *closing_quote = strchr (p - 1, '"');
      if (closing_quote && closing_quote[1] == '\0')
	*closing_quote = '\0';
    }
  if (has_comma)
    *ii = ',';
  return p;
}
static char * locate_first_half ( char * * argptr , int * is_quote_enclosed ) { char * ii ; char * p , * p1 ; int has_comma ; ii = find_toplevel_char ( * argptr , ' ' ) ; has_comma = ( ii != 0 ) ; if ( has_comma ) { * ii = ' \0 ' ; } p = * argptr ; if ( p [ 0 ] == ' ' ) { * is_quote_enclosed = 1 ; ( * argptr ) ++ ; p ++ ; } else { * is_quote_enclosed = 0 ; if ( strchr ( get_gdb_completer_quote_characters ( ) , * p ) ) { ++ ( * argptr ) ; ++ p ; } } if ( isalpha ( p [ 0 ] ) && p [ 1 ] == ' ' && IS_DIR_SEPARATOR ( p [ 2 ] ) ) p += 3 ; for ( ; * p ; p ++ ) { if ( p [ 0 ] == ' ' ) { char * temp_end = find_template_name_end ( p ) ; if ( ! temp_end ) error ( _ ( " " ) ) ; p = temp_end ; } if ( p [ 0 ] == ' ' ) p = find_method_overload_end ( p ) ; if ( is_objc_method_format ( p ) ) { break ; } if ( ! * p || p [ 0 ] == ' \t ' || ( p [ 0 ] == ' ' ) || ( ( p [ 0 ] == ' ' ) && ! * is_quote_enclosed ) ) break ; if ( p [ 0 ] == ' ' && strchr ( p , ' ' ) == NULL ) { for ( p1 = p ; * p1 && * p1 != ' ' ; p1 ++ ) { if ( * p1 == ' ' ) p = p1 ; } break ; } } p = skip_spaces ( p ) ; if ( * is_quote_enclosed ) { char * closing_quote = strchr ( p - 1 , ' ' ) ; if ( closing_quote && closing_quote [ 1 ] == ' \0 ' ) * closing_quote = ' \0 ' ; } if ( has_comma ) * ii = ' ' ; return p ; }
Locate the first half of the linespec, ending in a colon, period,
or whitespace.
Locate the first half of the linespec ending in a colon period or whitespace .
/* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
     and we must isolate the first half.  Outer layers will call again later
     for the second half.

     Don't count commas that appear in argument lists of overloaded
     functions, or in quoted strings.  It's stupid to go to this much
     trouble when the rest of the function is such an obvious roach hotel.  */ /* Temporarily zap out second half to not confuse the code below.
     This is undone below.  Do not change ii!!  */ /* Maybe arg is FILE : LINENUM or FILE : FUNCTION.  May also be
     CLASS::MEMBER, or NAMESPACE::NAME.  Look for ':', but ignore
     inside of <>.  */ /* Check for a drive letter in the filename.  This is done on all hosts
     to capture cross-compilation environments.  On Unixen, directory
     separators are illegal in filenames, so if the user enters "e:/foo.c",
     he is referring to a directory named "e:" and a source file named
     "foo.c", and we still want to keep these two pieces together.  */ /* Check for a colon and a plus or minus and a [ (which
         indicates an Objective-C method).  */ /* Check for the end of the first half of the linespec.  End of
         line, a tab, a colon or a space.  But if enclosed in double
	 quotes we do not break on enclosed spaces.  */ /* Java qualified method.  Find the *last* '.', since the
	     others are package qualifiers.  Stop at any open parenthesis
	     which might provide overload information.  */ /* If the closing double quote was left at the end, remove it.  */ /* Now that we've safely parsed the first half, put back ',' so
     outer layers can see it.  */