Merge remote branch 'alanc/master'

This commit is contained in:
Keith Packard 2010-12-07 13:39:58 -08:00
commit 519d243f0c
66 changed files with 440 additions and 242 deletions

View File

@ -15,11 +15,11 @@ Copyright © 2006 Nokia Corporation
Copyright © 2006-2008 Peter Hutterer
Copyright © 2006 Adam Jackson
Copyright © 2009-2010 NVIDIA Corporation
Copyright © 1987, 2003-2006, 2008-2010 Oracle and/or its affiliates.
Copyright © 1999 Keith Packard
Copyright © 2007-2009 Red Hat, Inc.
Copyright © 2005-2008 Daniel Stone
Copyright © 2006-2009 Simon Thum
Copyright © 1987, 2003-2006, 2008-2009 Sun Microsystems, Inc.
Copyright © 2006 Luc Verhaegen
Permission is hereby granted, free of charge, to any person obtaining a

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -63,10 +63,8 @@ device_removed(LibHalContext *ctx, const char *udi)
{
char *value;
value = malloc(strlen(udi) + 5); /* "hal:" + NULL */
if (!value)
if (asprintf (&value, "hal:%s", udi) == -1)
return;
sprintf(value, "hal:%s", udi);
remove_devices("hal", value);
@ -200,7 +198,9 @@ device_added(LibHalContext *hal_ctx, const char *udi)
"config/hal: getting usb.product_id on %s "
"returned %04x\n", parent, usb_product);
if (usb_vendor && usb_product)
attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_product);
if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_product)
== -1)
attrs.usb_id = NULL;
free(parent);
}
@ -226,12 +226,11 @@ device_added(LibHalContext *hal_ctx, const char *udi)
add_option(&options, "driver", driver);
add_option(&options, "name", name);
config_info = malloc(strlen(udi) + 5); /* "hal:" and NULL */
if (!config_info) {
if (asprintf (&config_info, "hal:%s", udi) == -1) {
config_info = NULL;
LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
goto unwind;
}
sprintf(config_info, "hal:%s", udi);
/* Check for duplicate devices */
if (device_is_duplicate(config_info))

View File

@ -108,8 +108,10 @@ device_added(struct udev_device *udev_device)
/* construct USB ID in lowercase hex - "0000:ffff" */
if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_model);
if (attrs.usb_id)
if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_model)
== -1)
attrs.usb_id = NULL;
else
LOG_PROPERTY(path, "PRODUCT", product);
}
}
@ -127,9 +129,10 @@ device_added(struct udev_device *udev_device)
LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
attrs.tags = xstrtokenize(tags_prop, ",");
config_info = Xprintf("udev:%s", syspath);
if (!config_info)
if (asprintf(&config_info, "udev:%s", syspath) == -1) {
config_info = NULL;
goto unwind;
}
if (device_is_duplicate(config_info)) {
LogMessage(X_WARNING, "config/udev: device %s already added. "
@ -217,8 +220,7 @@ device_removed(struct udev_device *device)
char *value;
const char *syspath = udev_device_get_syspath(device);
value = Xprintf("udev:%s", syspath);
if (!value)
if (asprintf(&value, "udev:%s", syspath) == -1)
return;
remove_devices("udev", value);

View File

@ -203,7 +203,7 @@ dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
strtol getopt getopt_long vsnprintf walkcontext backtrace \
getisax getzoneid shmctl64 strcasestr ffs])
getisax getzoneid shmctl64 strcasestr ffs vasprintf])
AC_FUNC_ALLOCA
dnl Old HAS_* names used in os/*.c.
AC_CHECK_FUNC([getdtablesize],

View File

@ -1,4 +1,4 @@
/* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,4 +1,4 @@
/* Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -2524,9 +2524,11 @@ AllocDevicePair (ClientPtr client, char* name,
if (!pointer)
return BadAlloc;
pointer->name = calloc(strlen(name) + strlen(" pointer") + 1, sizeof(char));
strcpy(pointer->name, name);
strcat(pointer->name, " pointer");
if (asprintf(&pointer->name, "%s pointer", name) == -1) {
pointer->name = NULL;
RemoveDevice(pointer, FALSE);
return BadAlloc;
}
pointer->public.processInputProc = ProcessOtherEvent;
pointer->public.realInputProc = ProcessOtherEvent;
@ -2547,9 +2549,12 @@ AllocDevicePair (ClientPtr client, char* name,
return BadAlloc;
}
keyboard->name = calloc(strlen(name) + strlen(" keyboard") + 1, sizeof(char));
strcpy(keyboard->name, name);
strcat(keyboard->name, " keyboard");
if (asprintf(&keyboard->name, "%s keyboard", name) == -1) {
keyboard->name = NULL;
RemoveDevice(keyboard, FALSE);
RemoveDevice(pointer, FALSE);
return BadAlloc;
}
keyboard->public.processInputProc = ProcessOtherEvent;
keyboard->public.realInputProc = ProcessOtherEvent;

View File

@ -75,7 +75,7 @@ Equipment Corporation.
******************************************************************/
/* XSERVER_DTRACE additions:
* Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1817,7 +1817,9 @@ SetDefaultFontPath(char *path)
start = end;
}
if (!start) {
temp_path = Xprintf("%s%sbuilt-ins", path, *path ? "," : "");
if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "")
== -1)
temp_path = NULL;
} else {
temp_path = strdup(path);
}

View File

@ -75,7 +75,7 @@ Equipment Corporation.
******************************************************************/
/*
* Copyright © 2003-2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2003-2005, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -73,7 +73,7 @@ Equipment Corporation.
******************************************************************/
/* XSERVER_DTRACE additions:
* Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 1987 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -297,8 +297,8 @@ copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver)
}
memcpy(cptr, odev, sizeof(GDevRec));
cptr->identifier = Xprintf("Autoconfigured Video Device %s", driver);
if (!cptr->identifier) {
if (asprintf(&cptr->identifier, "Autoconfigured Video Device %s", driver)
== -1) {
free(cptr);
free(nscreen);
return FALSE;

View File

@ -208,9 +208,7 @@ xf86ValidateFontPath(char *path)
continue;
}
else {
p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
strcpy(p1, dir_elem);
strcat(p1, DIR_FILE);
XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
flag = stat(p1, &stat_buf);
if (flag == 0)
if (!S_ISREG(stat_buf.st_mode))
@ -585,12 +583,11 @@ configFiles(XF86ConfFilesPtr fileconf)
else if (fileconf && fileconf->file_fontpath) {
pathFrom = X_CONFIG;
if (xf86Info.useDefaultFontPath) {
defaultFontPath = Xprintf("%s%s%s",
fileconf->file_fontpath,
*temp_path ? "," : "", temp_path);
if (defaultFontPath != NULL) {
if (asprintf(&defaultFontPath, "%s%s%s", fileconf->file_fontpath,
*temp_path ? "," : "", temp_path) == -1)
defaultFontPath = NULL;
else
must_copy = FALSE;
}
}
else
defaultFontPath = fileconf->file_fontpath;

View File

@ -205,12 +205,9 @@ configureScreenSection (int screennum)
int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
ptr->scrn_identifier = malloc(18);
sprintf(ptr->scrn_identifier, "Screen%d", screennum);
ptr->scrn_monitor_str = malloc(19);
sprintf(ptr->scrn_monitor_str, "Monitor%d", screennum);
ptr->scrn_device_str = malloc(16);
sprintf(ptr->scrn_device_str, "Card%d", screennum);
XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
{
@ -256,14 +253,13 @@ optionTypeToString(OptionValueType type)
static XF86ConfDevicePtr
configureDeviceSection (int screennum)
{
char identifier[16];
OptionInfoPtr p;
int i = 0;
parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
/* Move device info to parser structure */
sprintf(identifier, "Card%d", screennum);
ptr->dev_identifier = strdup(identifier);
if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
ptr->dev_identifier = NULL;
ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
ptr->dev_busid = DevToConfig[screennum].GDev.busID;
ptr->dev_driver = DevToConfig[screennum].GDev.driver;
@ -306,10 +302,8 @@ configureDeviceSection (int screennum)
int len = strlen(ptr->dev_comment) + strlen(prefix) +
strlen(middle) + strlen(suffix) + 1;
optname = malloc(strlen(p->name) + 2 + 1);
if (!optname)
if (asprintf(&optname, "\"%s\"", p->name) == -1)
break;
sprintf(optname, "\"%s\"", p->name);
len += max(20, strlen(optname));
len += strlen(opttype);
@ -370,16 +364,14 @@ configureLayoutSection (void)
aptr->adj_x = 0;
aptr->adj_y = 0;
aptr->adj_scrnum = scrnum;
aptr->adj_screen_str = xnfalloc(18);
sprintf(aptr->adj_screen_str, "Screen%d", scrnum);
XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
if (scrnum == 0) {
aptr->adj_where = CONF_ADJ_ABSOLUTE;
aptr->adj_refscreen = NULL;
}
else {
aptr->adj_where = CONF_ADJ_RIGHTOF;
aptr->adj_refscreen = xnfalloc(18);
sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1);
XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
}
ptr->lay_adjacency_lst =
(XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
@ -443,8 +435,7 @@ configureMonitorSection (int screennum)
{
parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
ptr->mon_identifier = malloc(19);
sprintf(ptr->mon_identifier, "Monitor%d", screennum);
XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
ptr->mon_vendor = strdup("Monitor Vendor");
ptr->mon_modelname = strdup("Monitor Model");
@ -491,11 +482,9 @@ configureDDCMonitorSection (int screennum)
parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
ptr->mon_identifier = malloc(19);
sprintf(ptr->mon_identifier, "Monitor%d", screennum);
XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
ptr->mon_modelname = malloc(12);
sprintf(ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
/* features in centimetres, we want millimetres */
mon_width = 10 * ConfiguredMonitor->features.hsize ;

View File

@ -1193,9 +1193,13 @@ xf86VIDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *forma
{
char *msg;
msg = Xprintf("%s: %s: %s", dev->drv->driverName, dev->name, format);
LogVMessageVerb(type, verb, msg, args);
free(msg);
if (asprintf(&msg, "%s: %s: %s", dev->drv->driverName, dev->name, format)
== -1) {
LogVMessageVerb(type, verb, "%s", args);
} else {
LogVMessageVerb(type, verb, msg, args);
free(msg);
}
}
/* Print input driver message, with verbose level specified directly */
@ -1280,11 +1284,8 @@ xf86LogInit(void)
/* Get the log file name */
if (xf86LogFileFrom == X_DEFAULT) {
/* Append the display number and ".log" */
lf = malloc(strlen(xf86LogFile) + strlen("%s") +
strlen(LOGSUFFIX) + 1);
if (!lf)
if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
FatalError("Cannot allocate space for the log file name\n");
sprintf(lf, "%s%%s" LOGSUFFIX, xf86LogFile);
xf86LogFile = lf;
}

View File

@ -536,8 +536,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->name == NULL) {
xf86Screens[i]->name = xnfalloc(strlen("screen") + 10 + 1);
sprintf(xf86Screens[i]->name, "screen%d", i);
XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
xf86MsgVerb(X_WARNING, 0,
"Screen driver %d has no name set, using `%s'.\n",
i, xf86Screens[i]->name);

View File

@ -638,13 +638,10 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
newn = n + 2;
} else {
free(n);
n = malloc(strlen(p->name) + 2 + 1);
if (!n) {
if (asprintf(&n, "No%s", p->name) == -1) {
p->found = FALSE;
return FALSE;
}
strcpy(n, "No");
strcat(n, p->name);
newn = n;
}
if ((s = xf86findOptionValue(options, newn)) != NULL) {

View File

@ -97,11 +97,8 @@ void DoShowOptions (void) {
);
continue;
}
pSymbol = malloc(
strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1
);
strcpy (pSymbol, xf86DriverList[i]->driverName);
strcat (pSymbol, "ModuleData");
XNFasprintf(&pSymbol, "%sModuleData",
xf86DriverList[i]->driverName);
initData = LoaderSymbol (pSymbol);
if (initData) {
XF86ModuleVersionInfo *vers = initData->vers;
@ -111,6 +108,9 @@ void DoShowOptions (void) {
);
for (p = pOption; p->name != NULL; p++) {
const char *opttype = optionTypeToSting(p->type);
/* XXX: Why overallocate by 2 bytes?
* Otherwise, this would be strdup()
*/
char *optname = malloc(strlen(p->name) + 2 + 1);
if (!optname) {
continue;

View File

@ -1347,9 +1347,9 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
pVideo = (struct pci_device *) busData;
GDev->busID = xnfalloc(16);
xf86FormatPciBusNumber(pVideo->bus, busnum);
sprintf(GDev->busID, "PCI:%s:%d:%d", busnum, pVideo->dev, pVideo->func);
XNFasprintf(&GDev->busID, "PCI:%s:%d:%d",
busnum, pVideo->dev, pVideo->func);
GDev->chipID = pVideo->device_id;
GDev->chipRev = pVideo->revision;

View File

@ -706,11 +706,9 @@ xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
sparcPromClose();
}
if (promPath) {
GDev->busID = xnfalloc(strlen(promPath) + 6);
sprintf(GDev->busID, "SBUS:%s", promPath);
XNFasprintf(&GDev->busID, "SBUS:%s", promPath);
free(promPath);
} else {
GDev->busID = xnfalloc(12);
sprintf(GDev->busID, "SBUS:fb%d", sBus->fbNum);
XNFsprintf(&GDev->busID, "SBUS:fb%d", sBus->fbNum);
}
}

View File

@ -146,11 +146,8 @@ extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
for (i = 0; extensionModules[i].name != NULL; i++) {
if (opts) {
char *s;
s = (char *)malloc(strlen(extensionModules[i].name) + 5);
if (s) {
if (Xasprinf(&s, "omit%s", extensionModules[i].name) != -1) {
pointer o;
strcpy(s, "omit");
strcat(s, extensionModules[i].name);
o = xf86FindOption(opts, s);
free(s);
if (o) {

View File

@ -2426,13 +2426,10 @@ DRICreatePCIBusID(const struct pci_device * dev)
{
char *busID;
busID = malloc(20);
if (busID == NULL)
if (asprintf(&busID, "pci:%04x:%02x:%02x.%d",
dev->domain, dev->bus, dev->dev, dev->func) == -1)
return NULL;
snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus,
dev->dev, dev->func);
return busID;
}

View File

@ -406,22 +406,22 @@ FindModuleInSubdir(const char *dirpath, const char *module)
snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
sprintf(ret, "%s%s", dirpath, tmpBuf);
if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
ret = NULL;
break;
}
snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
sprintf(ret, "%s%s", dirpath, tmpBuf);
if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
ret = NULL;
break;
}
snprintf(tmpBuf, PATH_MAX, "%s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
sprintf(ret, "%s%s", dirpath, tmpBuf);
if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
ret = NULL;
break;
}
}
@ -933,16 +933,14 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
* now check if the special data object <modulename>ModuleData is
* present.
*/
p = malloc(strlen(name) + strlen("ModuleData") + 1);
if (!p) {
if (asprintf(&p, "%sModuleData", name) == -1) {
p = NULL;
if (errmaj)
*errmaj = LDR_NOMEM;
if (errmin)
*errmin = 0;
goto LoadModule_fail;
}
strcpy(p, name);
strcat(p, "ModuleData");
initdata = LoaderSymbol(p);
if (initdata) {
ModuleSetupProc setup;

View File

@ -253,6 +253,7 @@ cat > sdksyms.c << EOF
/* include/Makefile.am */
#include "XIstubs.h"
#include "Xprintf.h"
#include "closestr.h"
#include "closure.h"
#include "colormap.h"

View File

@ -510,7 +510,6 @@ static void
xf86OutputSetMonitor (xf86OutputPtr output)
{
char *option_name;
static const char monitor_prefix[] = "monitor-";
char *monitor;
if (!output->name)
@ -520,11 +519,8 @@ xf86OutputSetMonitor (xf86OutputPtr output)
output->options = xnfalloc (sizeof (xf86OutputOptions));
memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions));
option_name = xnfalloc (strlen (monitor_prefix) +
strlen (output->name) + 1);
strcpy (option_name, monitor_prefix);
strcat (option_name, output->name);
XNFasprintf(&option_name, "monitor-%s", output->name);
monitor = xf86findOptionValue (output->scrn->options, option_name);
if (!monitor)
monitor = output->name;

View File

@ -132,8 +132,8 @@ xf86SetModeDefaultName(DisplayModePtr mode)
free(mode->name);
mode->name = XNFprintf("%dx%d%s", mode->HDisplay, mode->VDisplay,
interlaced ? "i" : "");
XNFasprintf(&mode->name, "%dx%d%s", mode->HDisplay, mode->VDisplay,
interlaced ? "i" : "");
}
/*

View File

@ -279,15 +279,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
if (Interlaced)
Mode->VTotal *= 2;
{
char Name[256];
Name[0] = 0;
snprintf(Name, 256, "%dx%d", HDisplay, VDisplay);
Mode->name = xnfalloc(strlen(Name) + 1);
memcpy(Mode->name, Name, strlen(Name) + 1);
}
XNFasprintf(&Mode->name, "%dx%d", HDisplay, VDisplay);
if (Reduced)
Mode->Flags |= V_PHSYNC | V_NVSYNC;

View File

@ -1,4 +1,4 @@
/ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
/ Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
/
/ Permission is hereby granted, free of charge, to any person obtaining a
/ copy of this software and associated documentation files (the "Software"),

View File

@ -1,4 +1,4 @@
/ Copyright 2004 Sun Microsystems, Inc. All rights reserved.
/ Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
/
/ Permission is hereby granted, free of charge, to any person obtaining a
/ copy of this software and associated documentation files (the "Software"),

View File

@ -1,4 +1,4 @@
/* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -6,7 +6,7 @@
* Copyright © 2000 VA Linux Systems, Inc.
* Copyright © 2001 The XFree86 Project, Inc.
*/
/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -27,7 +27,7 @@
* XFree86 Project.
*/
/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,4 +1,4 @@
/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2004-2005, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -22,7 +22,7 @@
* OF THIS SOFTWARE.
*
*/
/* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
/* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -61,8 +61,8 @@
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "Configint.h"
#include <math.h>
#include <X11/Xfuncproto.h>
#include "Xprintf.h"
extern LexRec val;
@ -143,9 +143,8 @@ xf86parseFlagsSection (void)
} else {
if (tokentype != NUMBER)
Error (NUMBER_MSG, tmp);
valstr = malloc(16);
if (valstr)
sprintf(valstr, "%d", val.num);
if (asprintf(&valstr, "%d", val.num) == -1)
valstr = NULL;
}
}
ptr->flg_option_lst = xf86addNewOption
@ -426,13 +425,9 @@ char *
xf86uLongToString(unsigned long i)
{
char *s;
int l;
l = ceil(log10((double)i) + 2.5);
s = malloc(l);
if (!s)
if (asprintf(&s, "%lu", i) == -1)
return NULL;
sprintf(s, "%lu", i);
return s;
}

View File

@ -31,6 +31,7 @@ libxf86config_internal_la_SOURCES = \
$(INTERNAL_SOURCES)
libxf86config_a_SOURCES = \
$(TOP_SRCDIR)/os/xprintf.c \
$(INTERNAL_SOURCES)
libxf86config_a_CFLAGS = $(AM_CFLAGS)

View File

@ -62,6 +62,7 @@
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "Configint.h"
#include "Xprintf.h"
extern LexRec val;
@ -99,8 +100,8 @@ static xf86ConfigSymTabRec ZMapTab[] =
XF86ConfInputPtr
xf86parsePointerSection (void)
{
char *s, *s1, *s2;
int l;
char *s;
unsigned long val1;
int token;
parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
@ -184,17 +185,12 @@ xf86parsePointerSection (void)
case NUMBER:
if (val.num < 0)
Error (ZAXISMAPPING_MSG, NULL);
s1 = xf86uLongToString(val.num);
val1 = val.num;
if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) {
free(s1);
Error (ZAXISMAPPING_MSG, NULL);
}
s2 = xf86uLongToString(val.num);
l = strlen(s1) + 1 + strlen(s2) + 1;
s = malloc(l);
sprintf(s, "%s %s", s1, s2);
free(s1);
free(s2);
if (asprintf(&s, "%ul %ul", val1, val.num) == -1)
s = NULL;
break;
case XAXIS:
s = strdup("x");

View File

@ -1,4 +1,4 @@
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@ -27,7 +27,10 @@ INCLUDES = $(XORG_INCS) \
-I$(top_srcdir)/hw/xfree86/parser
# gah
cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/modes/xf86cvt.c
cvt_SOURCES = cvt.c \
$(top_srcdir)/hw/xfree86/modes/xf86cvt.c \
$(top_srcdir)/os/xprintf.c
cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
man1_MANS = cvt.man

View File

@ -25,6 +25,24 @@
#include "xf86.h"
/* Error implementation used by the server code we built in */
void
Error(const char *str)
{
perror(str);
}
/* FatalError implementation used by the server code we built in */
void
FatalError(const char *f, ...)
{
va_list args;
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
exit(1);
}
/* xnfalloc implementation used by the server code we built in */
pointer
XNFalloc(unsigned long n)

View File

@ -1,4 +1,4 @@
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),

View File

@ -356,8 +356,8 @@ VBESetModeNames(DisplayModePtr pMode)
pMode->VDisplay > 10000 || pMode->VDisplay < 0) {
pMode->name = strdup("BADMODE");
} else {
pMode->name = xnfalloc(4 + 1 + 4 + 1);
sprintf(pMode->name, "%dx%d", pMode->HDisplay, pMode->VDisplay);
XNFasprintf(&pMode->name, "%dx%d",
pMode->HDisplay, pMode->VDisplay);
}
}
pMode = pMode->next;

View File

@ -221,9 +221,10 @@ if (fDebugProcMsg) \
{ \
char *pszTemp; \
int iLength; \
pszTemp = Xprintf (str, ##__VA_ARGS__); \
MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
free(pszTemp); \
if (asprintf (&pszTemp, str, ##__VA_ARGS__) != -1) { \
MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
free (pszTemp); \
} \
}
#else
#define DEBUG_MSG(str,...)

View File

@ -341,11 +341,10 @@ winExitDlgProc (HWND hDialog, UINT message,
winInitDialog (hDialog);
/* Format the connected clients string */
pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
if (asprintf (&pszConnectedClients, CONNECTED_CLIENTS_FORMAT,
(s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
s_pScreenPriv->iConnectedClients,
(s_pScreenPriv->iConnectedClients == 1) ? "" : "s");
if (!pszConnectedClients)
(s_pScreenPriv->iConnectedClients == 1) ? "" : "s") == -1)
return TRUE;

View File

@ -101,12 +101,15 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
char * pszErrorF = NULL;
char * pszMsgBox = NULL;
va_list args;
int size;
va_start(args, uType);
pszErrorF = Xvprintf(pszError, args);
size = vasprintf (&pszErrorF, pszError, args);
va_end(args);
if (!pszErrorF)
if (size == -1) {
pszErrorF = NULL;
goto winMessageBoxF_Cleanup;
}
#define MESSAGEBOXF \
"%s\n" \
@ -117,15 +120,18 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
"XWin was started with the following command-line:\n\n" \
"%s\n"
pszMsgBox = Xprintf (MESSAGEBOXF,
pszErrorF, XVENDORNAME,
XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT,
BUILDERADDR,
BUILDERSTRING,
g_pszCommandLine);
size = asprintf (&pszMsgBox, MESSAGEBOXF,
pszErrorF, XVENDORNAME,
XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH,
XORG_VERSION_SNAP, XORG_VERSION_CURRENT,
BUILDERADDR,
BUILDERSTRING,
g_pszCommandLine);
if (!pszMsgBox)
if (size == -1) {
pszMsgBox = NULL;
goto winMessageBoxF_Cleanup;
}
/* Display the message box string */
MessageBox (NULL,

View File

@ -1,6 +1,7 @@
if XORG
sdk_HEADERS = \
XIstubs.h \
Xprintf.h \
callback.h \
closestr.h \
closure.h \

69
include/Xprintf.h Normal file
View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef XPRINTF_H
#define XPRINTF_H
#include <stdio.h>
#include <stdarg.h>
#include <X11/Xfuncproto.h>
#ifndef _X_RESTRICT_KYWD
# if defined(restrict) /* assume autoconf set it correctly */ || \
(defined(__STDC__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */
# define _X_RESTRICT_KYWD restrict
# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
# define _X_RESTRICT_KYWD __restrict__
# else
# define _X_RESTRICT_KYWD
# endif
#endif
/*
* These functions provide a portable implementation of the common (but not
* yet universal) asprintf & vasprintf routines to allocate a buffer big
* enough to sprintf the arguments to. The XNF variants terminate the server
* if the allocation fails.
* The buffer allocated is returned in the pointer provided in the first
* argument. The return value is the size of the allocated buffer, or -1
* on failure.
*/
extern _X_EXPORT int Xasprintf (char **ret,
const char * _X_RESTRICT_KYWD fmt,
...) _X_ATTRIBUTE_PRINTF(2,3);
extern _X_EXPORT int Xvasprintf (char **ret,
const char * _X_RESTRICT_KYWD fmt,
va_list va) _X_ATTRIBUTE_PRINTF(2,0);
extern _X_EXPORT int XNFasprintf (char **ret,
const char * _X_RESTRICT_KYWD fmt,
...) _X_ATTRIBUTE_PRINTF(2,3);
extern _X_EXPORT int XNFvasprintf (char **ret,
const char * _X_RESTRICT_KYWD fmt,
va_list va) _X_ATTRIBUTE_PRINTF(2,0);
#if !defined(HAVE_ASPRINTF) && !defined(HAVE_VASPRINTF)
# define asprintf Xasprintf
# define vasprintf Xvasprintf
#endif
#endif /* XPRINTF_H */

View File

@ -243,6 +243,9 @@
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF
/* Define to 1 if you have the `vasprintf' function. */
#undef HAVE_VASPRINTF
/* Support IPv6 for TCP connections */
#undef IPv6

View File

@ -264,10 +264,14 @@ extern _X_EXPORT char *Xstrdup(const char *s);
*/
extern _X_EXPORT char *XNFstrdup(const char *s);
extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
/* Include new X*asprintf API */
#include "Xprintf.h"
/* Older api deprecated in favor of the asprintf versions */
extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_DEPRECATED;
extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va)_X_ATTRIBUTE_PRINTF(1,0) _X_DEPRECATED;
extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_DEPRECATED;
extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va)_X_ATTRIBUTE_PRINTF(1,0) _X_DEPRECATED;
typedef void (*OsSigHandlerPtr)(int /* sig */);
typedef int (*OsSigWrapperPtr)(int /* sig */);

View File

@ -1,5 +1,5 @@
/*
* Copyright © 1987 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -54,7 +54,7 @@ SOFTWARE.
******************************************************************/
/*
* Copyright © 2004 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -177,10 +177,8 @@ LogInit(const char *fname, const char *backup)
char *logFileName = NULL;
if (fname && *fname) {
logFileName = malloc(strlen(fname) + strlen(display) + 1);
if (!logFileName)
if (asprintf(&logFileName, fname, display) == -1)
FatalError("Cannot allocate space for the log file name\n");
sprintf(logFileName, fname, display);
if (backup && *backup) {
struct stat buf;
@ -189,13 +187,9 @@ LogInit(const char *fname, const char *backup)
char *suffix;
char *oldLog;
oldLog = malloc(strlen(logFileName) + strlen(backup) +
strlen(display) + 1);
suffix = malloc(strlen(backup) + strlen(display) + 1);
if (!oldLog || !suffix)
if ((asprintf(&suffix, backup, display) == -1) ||
(asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
FatalError("Cannot allocate space for the log file name\n");
sprintf(suffix, backup, display);
sprintf(oldLog, "%s%s", logFileName, suffix);
free(suffix);
if (rename(logFileName, oldLog) == -1) {
FatalError("Cannot move old log file \"%s\" to \"%s\"\n",

View File

@ -1,6 +1,13 @@
/*
* printf routines which xalloc their buffer
*/
/**
* @file
*
* @section DESCRIPTION
*
* These functions provide a portable implementation of the common (but not
* yet universal) asprintf & vasprintf routines to allocate a buffer big
* enough to sprintf the arguments to. The XNF variants terminate the server
* if the allocation fails.
*/
/*
* Copyright (c) 2004 Alexander Gottwald
*
@ -26,6 +33,29 @@
* holders shall not be used in advertising or otherwise to promote the sale,
* use or other dealings in this Software without prior written authorization.
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@ -35,6 +65,13 @@
#include <stdarg.h>
#include <stdio.h>
#ifdef asprintf
# undef asprintf
#endif
#ifdef vasprintf
# undef vasprintf
#endif
#ifndef va_copy
# ifdef __va_copy
# define va_copy __va_copy
@ -42,11 +79,23 @@
# error "no working va_copy was found"
# endif
#endif
char *
Xvprintf(const char *format, va_list va)
/**
* Varargs sprintf that allocates a string buffer the right size for
* the pattern & data provided and prints the requested data to it.
*
* @param ret Pointer to which the newly allocated buffer is written
* (contents undefined on error)
* @param format printf style format string
* @param va variable argument list
* @return size of allocated buffer, or -1 on error.
*/
int
Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
{
char *ret;
#ifdef HAVE_VASPRINTF
return vasprintf(ret, format, va);
#else
int size;
va_list va2;
@ -54,12 +103,94 @@ Xvprintf(const char *format, va_list va)
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
ret = (char *)malloc(size + 1);
if (ret == NULL)
return NULL;
*ret = malloc(size + 1);
if (*ret == NULL)
return -1;
vsnprintf(ret, size + 1, format, va);
vsnprintf(*ret, size + 1, format, va);
ret[size] = 0;
return size;
#endif
}
#ifndef HAVE_VASPRINTF
# define vasprintf Xvasprintf
#endif
/**
* sprintf that allocates a string buffer the right size for
* the pattern & data provided and prints the requested data to it.
*
* @param ret Pointer to which the newly allocated buffer is written
* (contents undefined on error)
* @param format printf style format string
* @param ... arguments for specified format
* @return size of allocated buffer, or -1 on error.
*/
int
Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
{
int size;
va_list va;
va_start(va, format);
size = vasprintf(ret, format, va);
va_end(va);
return size;
}
/**
* Varargs sprintf that allocates a string buffer the right size for
* the pattern & data provided and prints the requested data to it.
* On failure, issues a FatalError message and aborts the server.
*
* @param ret Pointer to which the newly allocated buffer is written
* (contents undefined on error)
* @param format printf style format string
* @param va variable argument list
* @return size of allocated buffer
*/
int
XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
{
int size = vasprintf(ret, format, va);
if ((size == -1) || (*ret == NULL)) {
Error("XNFvasprintf");
FatalError("XNFvasprintf failed");
}
return size;
}
/**
* sprintf that allocates a string buffer the right size for
* the pattern & data provided and prints the requested data to it.
* On failure, issues a FatalError message and aborts the server.
*
* @param ret Pointer to which the newly allocated buffer is written
* (contents undefined on error)
* @param format printf style format string
* @param ... arguments for specified format
* @return size of allocated buffer
*/
int
XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
{
int size;
va_list va;
va_start(va, format);
size = XNFvasprintf(ret, format, va);
va_end(va);
return size;
}
/* Old api, now deprecated, may be removed in the future */
char *
Xvprintf(const char *format, va_list va)
{
char *ret;
if (vasprintf(&ret, format, va) == -1)
ret = NULL;
return ret;
}
@ -68,7 +199,8 @@ char *Xprintf(const char *format, ...)
char *ret;
va_list va;
va_start(va, format);
ret = Xvprintf(format, va);
if (vasprintf(&ret, format, va) == -1)
ret = NULL;
va_end(va);
return ret;
}
@ -77,19 +209,9 @@ char *
XNFvprintf(const char *format, va_list va)
{
char *ret;
int size;
va_list va2;
va_copy(va2, va);
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
XNFvasprintf(&ret, format, va);
ret = (char *)xnfalloc(size + 1);
if (ret == NULL)
return NULL;
vsnprintf(ret, size + 1, format, va);
ret[size] = 0;
return ret;
}
@ -98,7 +220,7 @@ char *XNFprintf(const char *format, ...)
char *ret;
va_list va;
va_start(va, format);
ret = XNFvprintf(format, va);
XNFvasprintf(&ret, format, va);
va_end(va);
return ret;
}

View File

@ -47,6 +47,11 @@
#include "xace.h"
#include "protocol-versions.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#elif !defined(UINT32_MAX)
@ -2651,9 +2656,6 @@ SProcRenderDispatch (ClientPtr client)
}
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode) {\
int rc = dixLookupResourceByType((pointer *)&(pPicture), pid,\
XRT_PICTURE, client, mode);\

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),

View File

@ -156,34 +156,45 @@ char tmpname[PATH_MAX];
#endif
if (XkbBaseDirectory!=NULL) {
if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
buf = Xprintf("%s/%s.dir",XkbBaseDirectory,componentDirs[what]);
in= fopen(buf,"r");
if (asprintf(&buf, "%s/%s.dir", XkbBaseDirectory,
componentDirs[what]) == -1)
buf = NULL;
else
in = fopen(buf,"r");
}
if (!in) {
haveDir= FALSE;
free(buf);
buf = Xprintf(
"'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long)
((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)),
file W32_tmpfile
);
if (asprintf
(&buf,
"'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
XkbBinDirectory, XkbBaseDirectory, componentDirs[what],
(long) ((xkbDebugFlags < 2) ? 1 :
((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
file W32_tmpfile
) == -1)
buf = NULL;
}
}
else {
if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
buf = Xprintf("%s.dir",componentDirs[what]);
in= fopen(buf,"r");
if (asprintf(&buf, "%s.dir", componentDirs[what]) == -1)
buf = NULL;
else
in = fopen(buf,"r");
}
if (!in) {
haveDir= FALSE;
free(buf);
buf = Xprintf(
"xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
componentDirs[what],(long)
((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)),
file W32_tmpfile
);
if (asprintf
(&buf,
"xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
componentDirs[what],
(long) ((xkbDebugFlags < 2) ? 1 :
((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
file W32_tmpfile
) == -1)
buf = NULL;
}
}
status= Success;

View File

@ -210,7 +210,8 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
#endif
if (XkbBaseDirectory != NULL) {
xkbbasedirflag = Xprintf("\"-R%s\"", XkbBaseDirectory);
if (asprintf(&xkbbasedirflag, "\"-R%s\"", XkbBaseDirectory) == -1)
xkbbasedirflag = NULL;
}
if (XkbBinDirectory != NULL) {
@ -225,14 +226,16 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
}
}
buf = Xprintf("\"%s%sxkbcomp\" -w %d %s -xkm \"%s\" "
if (asprintf(&buf,
"\"%s%sxkbcomp\" -w %d %s -xkm \"%s\" "
"-em1 %s -emp %s -eml %s \"%s%s.xkm\"",
xkbbindir, xkbbindirsep,
( (xkbDebugFlags < 2) ? 1 :
((xkbDebugFlags > 10) ? 10 : (int)xkbDebugFlags) ),
xkbbasedirflag ? xkbbasedirflag : "", xkmfile,
PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
xkm_output_dir, keymap);
xkbbindir, xkbbindirsep,
((xkbDebugFlags < 2) ? 1 :
((xkbDebugFlags > 10) ? 10 : (int) xkbDebugFlags)),
xkbbasedirflag ? xkbbasedirflag : "", xkmfile,
PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
xkm_output_dir, keymap) == -1)
buf = NULL;
free(xkbbasedirflag);