Xming: Always remove temporary file used when invoking xkbcomp on Win32

When built for native Win32, pipe() & fork() aren't available, so we
use a tempoary file and system() to invoke xkbcomp

Ensure the temporary file is always removed. It was only being removed
on most errors, not on success :S

Also fix a couple of warnings which occur when built with WIN32 defined

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
This commit is contained in:
Colin Harrison 2011-10-08 14:39:07 +01:00 committed by Jon TURNEY
parent ee19853867
commit f6529a05a2
2 changed files with 9 additions and 2 deletions

View File

@ -44,7 +44,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef WIN32 #ifdef WIN32
/* from ddxLoad.c */ /* from ddxLoad.c */
extern const char* Win32TempDir(); extern const char* Win32TempDir(void);
extern int Win32System(const char *cmdline); extern int Win32System(const char *cmdline);
#undef System #undef System
#define System Win32System #define System Win32System
@ -126,10 +126,11 @@ XkbDDXListComponent( DeviceIntPtr dev,
char *file,*map,*tmp,*buf=NULL; char *file,*map,*tmp,*buf=NULL;
FILE *in; FILE *in;
Status status; Status status;
int rval;
Bool haveDir; Bool haveDir;
#ifdef WIN32 #ifdef WIN32
char tmpname[PATH_MAX]; char tmpname[PATH_MAX];
#else
int rval;
#endif #endif
if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='\0')) if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='\0'))
@ -223,6 +224,9 @@ char tmpname[PATH_MAX];
buf = malloc(PATH_MAX * sizeof(char)); buf = malloc(PATH_MAX * sizeof(char));
if (!buf) { if (!buf) {
fclose(in); fclose(in);
#ifdef WIN32
unlink(tmpname);
#endif
return BadAlloc; return BadAlloc;
} }
while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) { while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {

View File

@ -267,6 +267,9 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
nameRtrn[nameRtrnLen-1]= '\0'; nameRtrn[nameRtrnLen-1]= '\0';
} }
free(buf); free(buf);
#ifdef WIN32
unlink(tmpname);
#endif
return TRUE; return TRUE;
} }
else else