- unsigned OrigLen, NewLen;
- char* NewPath;
-
- /* Get the length of the original string */
- OrigLen = Orig? strlen (Orig) : 0;
-
- /* Get the length of the new path */
- NewLen = strlen (New);
-
- /* Check for a trailing path separator and remove it */
- if (NewLen > 0 && (New [NewLen-1] == '\\' || New [NewLen-1] == '/')) {
- --NewLen;
- }
-
- /* Allocate memory for the new string */
- NewPath = xmalloc (OrigLen + NewLen + 2);
-
- /* Copy the strings */
- memcpy (NewPath, Orig, OrigLen);
- memcpy (NewPath+OrigLen, New, NewLen);
- NewPath [OrigLen+NewLen+0] = ';';
- NewPath [OrigLen+NewLen+1] = '\0';
-
- /* Delete the original path */
- xfree (Orig);
-
- /* Return the new path */
- return NewPath;