contrib/gdb-7/gdb/cp-namespace.c
static struct symbol *
lookup_namespace_scope (const char *name,
			const struct block *block,
			const domain_enum domain,
			const char *scope,
			int scope_len)
{
  char *namespace;

  if (scope[scope_len] != '\0')
    {
      /* Recursively search for names in child namespaces first.  */

      struct symbol *sym;
      int new_scope_len = scope_len;

      /* If the current scope is followed by "::", skip past that.  */
      if (new_scope_len != 0)
	{
	  gdb_assert (scope[new_scope_len] == ':');
	  new_scope_len += 2;
	}
      new_scope_len += cp_find_first_component (scope + new_scope_len);
      sym = lookup_namespace_scope (name, block, domain,
				    scope, new_scope_len);
      if (sym != NULL)
	return sym;
    }

  /* Okay, we didn't find a match in our children, so look for the
     name in the current namespace.  */

  namespace = alloca (scope_len + 1);
  strncpy (namespace, scope, scope_len);
  namespace[scope_len] = '\0';
  return cp_lookup_symbol_in_namespace (namespace, name,
					block, domain);
}
/* Lookup NAME at namespace scope (or, in C terms, in static and
   global variables).  SCOPE is the namespace that the current
   function is defined within; only consider namespaces whose length
   is at least SCOPE_LEN.  Other arguments are as in
   cp_lookup_symbol_nonlocal.

   For example, if we're within a function A::B::f and looking for a
   symbol x, this will get called with NAME = "x", SCOPE = "A::B", and
   SCOPE_LEN = 0.  It then calls itself with NAME and SCOPE the same,
   but with SCOPE_LEN = 1.  And then it calls itself with NAME and
   SCOPE the same, but with SCOPE_LEN = 4.  This third call looks for
   "A::B::x"; if it doesn't find it, then the second call looks for
   "A::x", and if that call fails, then the first call looks for
   "x".  */
Lookup NAME at namespace scope (or, in C terms, in static and
global variables).  SCOPE is the namespace that the current
function is defined within; only consider namespaces whose length
is at least SCOPE_LEN.  Other arguments are as in
cp_lookup_symbol_nonlocal.


Lookup NAME at namespace scope ( or in C terms in static and global variables ) . SCOPE is the namespace that the current function is defined within ; only consider namespaces whose length is at least SCOPE_LEN . Other arguments are as in cp_lookup_symbol_nonlocal .
static struct symbol *
lookup_namespace_scope (const char *name,
			const struct block *block,
			const domain_enum domain,
			const char *scope,
			int scope_len)
{
  char *namespace;
  if (scope[scope_len] != '\0')
    {
      struct symbol *sym;
      int new_scope_len = scope_len;
      if (new_scope_len != 0)
	{
	  gdb_assert (scope[new_scope_len] == ':');
	  new_scope_len += 2;
	}
      new_scope_len += cp_find_first_component (scope + new_scope_len);
      sym = lookup_namespace_scope (name, block, domain,
				    scope, new_scope_len);
      if (sym != NULL)
	return sym;
    }
  namespace = alloca (scope_len + 1);
  strncpy (namespace, scope, scope_len);
  namespace[scope_len] = '\0';
  return cp_lookup_symbol_in_namespace (namespace, name,
					block, domain);
}
static struct symbol * lookup_namespace_scope ( const char * name , const struct block * block , const domain_enum domain , const char * scope , int scope_len ) { char * namespace ; if ( scope [ scope_len ] != ' \0 ' ) { struct symbol * sym ; int new_scope_len = scope_len ; if ( new_scope_len != 0 ) { gdb_assert ( scope [ new_scope_len ] == ' ' ) ; new_scope_len += 2 ; } new_scope_len += cp_find_first_component ( scope + new_scope_len ) ; sym = lookup_namespace_scope ( name , block , domain , scope , new_scope_len ) ; if ( sym != NULL ) return sym ; } namespace = alloca ( scope_len + 1 ) ; strncpy ( namespace , scope , scope_len ) ; namespace [ scope_len ] = ' \0 ' ; return cp_lookup_symbol_in_namespace ( namespace , name , block , domain ) ; }
Lookup NAME at namespace scope (or, in C terms, in static and
global variables).
Lookup NAME at namespace scope ( or in C terms in static and global variables ) .
/* Recursively search for names in child namespaces first.  */ /* If the current scope is followed by "::", skip past that.  */ /* Okay, we didn't find a match in our children, so look for the
     name in the current namespace.  */