Skip to content

Commit

Permalink
Server: Use strcasestr() instead of stristr()
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Jun 29, 2024
1 parent 6844383 commit 39f3974
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
12 changes: 6 additions & 6 deletions unix/Xvnc/programs/Xserver/hw/vnc/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Modified for XFree86 4.x by Alan Hourihane <[email protected]>
*/

/* Copyright (C) 2009-2023 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2009-2024 D. R. Commander. All Rights Reserved.
* Copyright (C) 2021 Steffen Kieß
* Copyright (C) 2016-2017 Pierre Ossman for Cendio AB. All Rights Reserved.
* Copyright (C) 2010 University Corporation for Atmospheric Research.
Expand Down Expand Up @@ -1231,15 +1231,15 @@ Bool AddExtInputDevice(rfbDevInfo *dev)
dev->pDev->xinput_type = MakeAtom("PAD", strlen("PAD"), 1);
break;
default:
if (stristr(dev->name, "cursor"))
if (strcasestr(dev->name, "cursor"))
dev->pDev->xinput_type = XA_CURSOR;
else if (stristr(dev->name, "stylus"))
else if (strcasestr(dev->name, "stylus"))
dev->pDev->xinput_type = MakeAtom("STYLUS", strlen("STYLUS"), 1);
else if (stristr(dev->name, "eraser"))
else if (strcasestr(dev->name, "eraser"))
dev->pDev->xinput_type = MakeAtom("ERASER", strlen("ERASER"), 1);
else if (stristr(dev->name, "touch"))
else if (strcasestr(dev->name, "touch"))
dev->pDev->xinput_type = MakeAtom("TOUCH", strlen("TOUCH"), 1);
else if (stristr(dev->name, "pad"))
else if (strcasestr(dev->name, "pad"))
dev->pDev->xinput_type = MakeAtom("PAD", strlen("PAD"), 1);
break;
}
Expand Down
29 changes: 4 additions & 25 deletions unix/Xvnc/programs/Xserver/hw/vnc/kbdptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,27 +548,6 @@ void PtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
}


Bool stristr(const char *s1, const char *s2)
{
char *str1, *str2, *ret;
int i;

if (!s1 || !s2 || strlen(s1) < 1 || strlen(s2) < 1)
return FALSE;

str1 = strdup(s1);
for (i = 0; i < strlen(str1); i++)
str1[i] = tolower(str1[i]);
str2 = strdup(s2);
for (i = 0; i < strlen(str2); i++)
str2[i] = tolower(str2[i]);

ret = strstr(str1, str2);
free(str1); free(str2);
return ret != NULL;
}


void ExtInputAddEvent(rfbDevInfoPtr dev, int type, int buttons)
{
ValuatorMask mask;
Expand All @@ -594,13 +573,13 @@ void ExtInputAddEvent(rfbDevInfoPtr dev, int type, int buttons)
vtDev = &virtualTabletPad;
break;
default:
if (stristr(dev->name, "stylus"))
if (strcasestr(dev->name, "stylus"))
vtDev = &virtualTabletStylus;
else if (stristr(dev->name, "eraser"))
else if (strcasestr(dev->name, "eraser"))
vtDev = &virtualTabletEraser;
else if (stristr(dev->name, "touch"))
else if (strcasestr(dev->name, "touch"))
vtDev = &virtualTabletTouch;
else if (stristr(dev->name, "pad"))
else if (strcasestr(dev->name, "pad"))
vtDev = &virtualTabletPad;
else
return;
Expand Down
2 changes: 0 additions & 2 deletions unix/Xvnc/programs/Xserver/hw/vnc/rfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,6 @@ extern void KeyEvent(KeySym keySym, Bool down);
extern void KbdReleaseAllKeys(void);
extern void QEMUExtKeyboardEventInit(void);

extern Bool stristr(const char *s1, const char *s2);


/* nvctrlext.c */

Expand Down

0 comments on commit 39f3974

Please sign in to comment.