+void AddSubSearchPathFromEnv (const char* EnvVar, const char* SubDir, unsigned Where)
+/* Add a search path from an environment variable, adding a subdirectory to
+ * the environment variable value.
+ */
+{
+ StrBuf Dir = AUTO_STRBUF_INITIALIZER;
+
+ const char* EnvVal = getenv (EnvVar);
+ if (EnvVal == 0) {
+ /* Not found */
+ return;
+ }
+
+ /* Copy the environment variable to the buffer */
+ SB_CopyStr (&Dir, EnvVal);
+
+ /* Add a path separator if necessary */
+ if (SB_NotEmpty (&Dir)) {
+ if (SB_LookAtLast (&Dir) != '\\' && SB_LookAtLast (&Dir) != '/') {
+ SB_AppendChar (&Dir, '/');
+ }
+ }
+
+ /* Add the subdirectory */
+ SB_AppendStr (&Dir, SubDir);
+
+ /* Terminate the string */
+ SB_Terminate (&Dir);
+
+ /* Add the search path */
+ AddSearchPath (SB_GetConstBuf (&Dir), Where);
+
+ /* Free the temp buffer */
+ SB_Done (&Dir);
+}
+
+
+