[PATCH] xwin: Clean up os wrappers for System, Popen and Pclose on Windows

Jon TURNEY jon.turney at dronecode.org.uk
Mon Jul 16 05:47:02 PDT 2012


On 13/07/2012 22:36, Keith Packard wrote:
> Popen and Pclose are never used on Windows, so don't bother to even
> try to define them.
> 
> System(s) was defined as system(s), but the two users of that
> function are in xkb, which carefully redefines that as
> Win32System. Move Win32System and Win32TempDir to os/utils.c, renaming
> Win32System to be just System, which simplifies the xkb code
> 
> Signed-off-by: Keith Packard <keithp at keithp.com>
> Cc: Jon TURNEY <jon.turney at dronecode.org.uk>

Thanks for tidying this up.  This seems to be correct, so:

Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

> ---
>  include/os.h  |   10 +++++---
>  os/utils.c    |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  xkb/ddxList.c |    6 -----
>  xkb/ddxLoad.c |   75 ---------------------------------------------------------
>  4 files changed, 80 insertions(+), 84 deletions(-)

> +
> +const char *
> +Win32TempDir()
> +{
> +    static char buffer[PATH_MAX];
> +
> +    if (GetTempPath(sizeof(buffer), buffer)) {
> +        int len;
> +
> +        buffer[sizeof(buffer) - 1] = 0;
> +        len = strlen(buffer);
> +        if (len > 0)
> +            if (buffer[len - 1] == '\\')
> +                buffer[len - 1] = 0;
> +        return buffer;
> +    }
> +    if (getenv("TEMP") != NULL)
> +        return getenv("TEMP");
> +    else if (getenv("TMP") != NULL)
> +        return getenv("TEMP");
> +    else
> +        return "/tmp";
> +}

I just notice in passing that this has been wrong since forever, the second
getenv should be getenv("TMP").  I shall do a separate patch to fix that...


More information about the xorg-devel mailing list