winecfg/audio: Simplify removeDriver() function.
This commit is contained in:
parent
d540cf3c80
commit
1482006fb5
|
@ -173,45 +173,26 @@ static void addDriver(const char * driver)
|
||||||
/* remove driver from local copy of driver registry string */
|
/* remove driver from local copy of driver registry string */
|
||||||
static void removeDriver(const char * driver)
|
static void removeDriver(const char * driver)
|
||||||
{
|
{
|
||||||
char before[32], after[32], * start;
|
char pattern[32], *p;
|
||||||
|
int drvlen, listlen;
|
||||||
|
|
||||||
strcpy(before, ",");
|
strcpy(pattern, ",");
|
||||||
strcat(before, driver);
|
strcat(pattern, driver);
|
||||||
strcpy(after, driver);
|
strcat(pattern, ",");
|
||||||
strcat(after, ",");
|
drvlen = strlen(driver);
|
||||||
|
listlen = strlen(curAudioDriver);
|
||||||
|
|
||||||
if ((start = strstr(curAudioDriver, after)))
|
p = strstr(curAudioDriver, pattern);
|
||||||
{
|
if (p) /* somewhere in the middle */
|
||||||
int len = strlen(after);
|
memmove(p, p+drvlen+1, strlen(p+drvlen+1)+1);
|
||||||
char * end = curAudioDriver + strlen(curAudioDriver);
|
else if (!strncmp(curAudioDriver, pattern+1, drvlen+1)) /* the head */
|
||||||
int i, count = end - start + len;
|
memmove(curAudioDriver, curAudioDriver+drvlen+1, listlen-drvlen);
|
||||||
for (i = 0; i < count; i++)
|
else if (!strncmp(curAudioDriver+listlen-drvlen-1, pattern, drvlen+1)) /* the tail */
|
||||||
{
|
curAudioDriver[listlen-drvlen-1] = 0;
|
||||||
if (start + len >= end)
|
else if (!strcmp(curAudioDriver, driver)) /* only one entry (head&tail) */
|
||||||
*start = 0;
|
curAudioDriver[0] = 0;
|
||||||
else
|
else
|
||||||
*start = start[len];
|
WINE_FIXME("driver '%s' is not in the list, please report!\n", driver);
|
||||||
start++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((start = strstr(curAudioDriver, before)))
|
|
||||||
{
|
|
||||||
int len = strlen(before);
|
|
||||||
char * end = curAudioDriver + strlen(curAudioDriver);
|
|
||||||
int i, count = end - start + len;
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
if (start + len >= end)
|
|
||||||
*start = 0;
|
|
||||||
else
|
|
||||||
*start = start[len];
|
|
||||||
start++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strcmp(curAudioDriver, driver) == 0)
|
|
||||||
{
|
|
||||||
strcpy(curAudioDriver, "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initAudioDeviceTree(HWND hDlg)
|
static void initAudioDeviceTree(HWND hDlg)
|
||||||
|
|
Loading…
Reference in New Issue