MCPcopy Create free account
hub / github.com/coreutils/coreutils / scan_varname

Function scan_varname

src/env.c:211–225  ·  view source on GitHub ↗

Return a pointer to the end of a valid ${VARNAME} string, or NULL. 'str' should point to the '$' character. First letter in VARNAME must be alpha or underscore, rest of letters are alnum or underscore. Any other character is an error. */

Source from the content-addressed store, hash-verified

209 rest of letters are alnum or underscore.
210 Any other character is an error. */
211ATTRIBUTE_PURE
212static char const *
213scan_varname (char const *str)
214{
215 if (str[1] == '{' && (c_isalpha (str[2]) || str[2] == '_'))
216 {
217 char const *end = str + 3;
218 while (c_isalnum (*end) || *end == '_')
219 ++end;
220 if (*end == '}')
221 return end;
222 }
223
224 return NULL;
225}
226
227/* Return a pointer to a static buffer containing the VARNAME as
228 extracted from a '${VARNAME}' string.

Callers 1

extract_varnameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected