2012-02-20 Keith Marshall <keithmarshall@users.sourceforge.net>
+ Fix ill-advised optimisation in $APPROOT environment lookup.
+
+ * src/rites.c (approot_path): Don't save result of getenv() lookup
+ across calls; the environment may have been moved in the interim,
+ making the original result invalid on any subsequent call. Also,
+ prefer MS-Windows style (with backslashes) for default.
+ (pkgLastRites): Report full path name for lastrites.exe, on execl()
+ failure, rather than only the path relative to $APPROOT.
+
+2012-02-20 Keith Marshall <keithmarshall@users.sourceforge.net>
+
Propagate sysroot path settings to scripts via the environment.
* src/pkgbase.h (PKG_PUTENV_FLAGS_MASK): New constant; it maps...
/* Inline helper to identify the root directory path for the running
* application, (which "mingw-get" passes through the APPROOT variable
* in the process environment)...
+ *
+ * Caution: although this is called more than once, DO NOT attempt to
+ * optimise getenv() lookup by saving the returned pointer across calls;
+ * the environment block may have been moved between calls, which makes
+ * the pointer returned from a previous call potentially invalid!
*/
- static const char *approot = NULL;
- return ((approot == NULL) && ((approot = getenv( "APPROOT" )) == NULL))
+ char *approot;
+ return ((approot = getenv( "APPROOT" )) == NULL)
- ? "c:/mingw/" /* default, for failed environment look-up */
+ ? "c:\\mingw\\" /* default, for failed environment look-up */
: approot; /* normal return value */
}
/* We should never get to here; if we do...
* Diagnose a problem, and bail out.
*/
- fprintf( stderr, "%s: execl: ", progname ); perror( lastrites );
+ fprintf( stderr, "%s: execl: ", progname ); perror( rites );
return EXIT_FATAL;
}