/* Check whether the string between a pair of % is a valid environment variable name. */
BOOLEAN IsValidEnvironmentVariableName(IN CONST CHAR16 *BeginPercent, IN CONST CHAR16 *EndPercent)
/* Check whether the string between a pair of % is a valid environment variable name. */
BOOLEAN IsValidEnvironmentVariableName(IN CONST CHAR16 *BeginPercent, IN CONST CHAR16 *EndPercent)
{
  CONST CHAR16  *Walker;
  Walker = NULL;
  ASSERT (BeginPercent != NULL);
  ASSERT (EndPercent != NULL);
  ASSERT (BeginPercent < EndPercent);
  if ((BeginPercent + 1) == EndPercent) {
    return FALSE;
  }
  for (Walker = BeginPercent + 1; Walker < EndPercent; Walker++) {
    if (
        ((*Walker >= L'0') && (*Walker <= L'9')) ||
        ((*Walker >= L'A') && (*Walker <= L'Z')) ||
        ((*Walker >= L'a') && (*Walker <= L'z')) ||
        (*Walker == L'_')
        )
    {
      if ((Walker == BeginPercent + 1) && ((*Walker >= L'0') && (*Walker <= L'9'))) {
        return FALSE;
      } else {
        continue;
      }
    } else {
      return FALSE;
    }
  }
  return TRUE;
}