218 |
|
int lvl; |
219 |
|
{ |
220 |
|
static char nambuf[MAXWORD]; |
221 |
< |
register char *cp = nambuf, *cpp = context; |
222 |
< |
/* check for explicit global */ |
221 |
> |
register char *cp = nambuf, *cpp; |
222 |
> |
/* check for explicit local */ |
223 |
|
if (*nam == CNTXMARK) |
224 |
< |
return(lvl > 0 ? NULL : nam+1); |
225 |
< |
/* check for repeat call */ |
226 |
< |
if (nam == nambuf) |
227 |
< |
return(lvl > 0 ? NULL : nambuf); |
224 |
> |
if (lvl > 0) /* only action is to refuse search */ |
225 |
> |
return(NULL); |
226 |
> |
else |
227 |
> |
nam++; |
228 |
> |
else if (nam == nambuf) /* check for repeat call */ |
229 |
> |
return(lvl > 0 ? NULL : nam); |
230 |
|
/* copy name to static buffer */ |
231 |
|
while (*nam) { |
232 |
|
if (cp >= nambuf+MAXWORD-1) |
233 |
|
goto toolong; |
234 |
< |
if ((*cp++ = *nam++) == CNTXMARK) |
233 |
< |
cpp = NULL; /* flag a qualified name */ |
234 |
> |
*cp++ = *nam++; |
235 |
|
} |
236 |
< |
if (cpp == NULL) { |
236 |
> |
/* check for explicit global */ |
237 |
> |
if (cp > nambuf && cp[-1] == CNTXMARK) { |
238 |
|
if (lvl > 0) |
239 |
< |
return(NULL); /* no higher level */ |
240 |
< |
if (cp[-1] == CNTXMARK) { |
241 |
< |
cp--; cpp = context; /* current context explicitly */ |
242 |
< |
} else |
243 |
< |
cpp = ""; /* else fully qualified */ |
244 |
< |
} else /* else skip the requested levels */ |
245 |
< |
while (lvl-- > 0) { |
246 |
< |
if (!*cpp) |
247 |
< |
return(NULL); /* return NULL if past global level */ |
248 |
< |
while (*++cpp && *cpp != CNTXMARK) |
249 |
< |
; |
248 |
< |
} |
239 |
> |
return(NULL); |
240 |
> |
*--cp = '\0'; |
241 |
> |
return(nambuf); /* already qualified */ |
242 |
> |
} |
243 |
> |
cpp = context; /* else skip the requested levels */ |
244 |
> |
while (lvl-- > 0) { |
245 |
> |
if (!*cpp) |
246 |
> |
return(NULL); /* return NULL if past global level */ |
247 |
> |
while (*++cpp && *cpp != CNTXMARK) |
248 |
> |
; |
249 |
> |
} |
250 |
|
while (*cpp) { /* copy context to static buffer */ |
251 |
|
if (cp >= nambuf+MAXWORD-1) |
252 |
|
goto toolong; |