rem: home[0], what);
add: home, what);
context: expandPath (char *dest, size_t len, const char *src, int what){	char *destend;	char *destptr;#define CHECKLEN(n) \		if (destptr + (n) >= destend) \		{ \			errno = ENAMETOOLONG; \			return -1; \		} \		else \			(void) 0	destptr = dest;	destend = dest + len;	if (what & EP_HOME)	{		if (src[0] == '~')		{			const char *home;			size_t homelen;						if (src[1] != '/')			{				errno = EINVAL;				return -1;			}			home = getHomeDir ();			if (home == NULL)			{				errno = ENOENT;				return -1;			}			homelen = strlen (home);					if (what & EP_ABSOLUTE) {				dest = expandPathAbsolute (dest, destend - dest,						home[0], what);				if (dest == NULL)				{					// errno is set					return -1;				}				what &= ~EP_ABSOLUTE;						// The part after the '~' should not be seen						// as absolute.			}			CHECKLEN (homelen);			memcpy (destptr, home, homelen);			destptr += homelen;			src++;  /* skip the ~ */		}	}		if (what & EP_ABSOLUTE)	{		destptr = expandPathAbsolute (destptr, destend - destptr, src[0],				what);		if (destptr == NULL)		{			// errno is set			return -1;		}	}		if (what & EP_ENVVARS)	{		while (*src != '\0')		{			switch (*src)			{#ifdef WIN32				case '%':				{					/* Environment variable substitution in Windows */					const char *end;     // end of env var name in src					const char *envVar;					char *envName;					size_t envNameLen, envVarLen;										src++;					end = strchr (src, '%');					if (end == NULL)					{						errno = EINVAL;						return -1;					}										envNameLen = end - src;					envName = HMalloc (envNameLen + 1);					memcpy (envName, src, envNameLen + 1);					envName[envNameLen] = '\0';					envVar = getenv (envName);					HFree (envName);					if (envVar == NULL)					{#ifdef APPDATA_FALLBACK						if (strncmp (src, "APPDATA", envNameLen) != 0)						{							// Substitute an empty string							src = end + 1;							break;						}						// fallback for when the APPDATA env var is not set						// Using SHGetFolderPath or SHGetSpecialFolderPath						// is problematic (not everywhere available).						fprintf(stderr, "Warning: %%APPDATA%% is not set. "								"Falling back to \"%%USERPROFILE%%\\Application "								"Data\"\n");						envVar = getenv ("USERPROFILE");						if (envVar != NULL)						{#define APPDATA_STRING "\\Application Data"							envVarLen = strlen (envVar);							CHECKLEN (envVarLen + sizeof (APPDATA_STRING) - 1);							strcpy (destptr, envVar);							destptr += envVarLen;							strcpy (destptr, APPDATA_STRING);							destptr += sizeof (APPDATA_STRING) - 1;							src = end + 1;							break;						}												// fallback to "../userdata"						fprintf(stderr, "Warning: %%USERPROFILE%% is not set. "								"Falling back to \"..\\userdata\" for %%APPDATA%%"								"\n");#define APPDATA_FALLBACK_STRING "..\\userdata"						CHECKLEN (sizeof (APPDATA_FALLBACK_STRING) - 1);						strcpy (destptr, APPDATA_FALLBACK_STRING);						destptr += sizeof (APPDATA_FALLBACK_STRING) - 1;						src = end + 1;						break;#else  /* !defined (APPDATA_FALLBACK) */						// Substitute an empty string						src = end + 1;						break;#endif  /* APPDATA_FALLBACK */					}					envVarLen = strlen (envVar);					CHECKLEN (envVarLen);					strcpy (destptr, envVar);					destptr += envVarLen;					src = end + 1;					break;				}#endif#if 0				case '$':					/* Environment variable substitution for Unix */					// not implemented					// Should accept both $BLA_123 and ${BLA}					break;#endif				default:					CHECKLEN(1);					*(destptr++) = *(src++);					break;			}  // switch		}  // while		*destptr = '\0';	}  // if (what & EP_ENVVARS)	else	{		strcpy (destptr, src);	}		if (what & EP_SLASHES)	{		/* Replacing backslashes in path by slashes. */		destptr = dest;		while (*destptr != '\0')		{			if (*destptr == '\\')				*destptr = '/';			destptr++;		}	}	return 0;}