1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
--- src/mouse.c.orig 1997-01-27 20:40:27.000000000 +0900
+++ src/mouse.c 2012-05-10 00:14:28.944551694 +0900
@@ -122,11 +122,11 @@
}
};
-static int mouseBaud;
+static int mouseBaud = B1200;
static int ConfigMouseBaud(const char *config)
{
- int baud;
+ int baud = 0;
sscanf(config, "%d", &baud);
@@ -149,19 +149,23 @@
return SUCCESS;
}
-static char *mouseDev;
+static char *mouseDev = NULL;
static int ConfigMouseDev(const char *config)
{
- char name[MAX_COLS];
- sscanf(config, "%s", name);
+ char *name, *last, *sep = " \t\r\n";
- if (mouseDev) free(mouseDev);
+ name = strtok_r((char *)config, sep, &last);
+ if (name == NULL) {
+ warn("unknown mouse type ignored; assuming no mouse\r\n");
+ return SUCCESS;
+ }
+ SafeFree(mouseDev);
mouseDev = strdup(name);
return SUCCESS;
}
-static int pasteButton;
+static int pasteButton = MOUSE_RGT;
static int Config3Buttons(const char *config)
{
@@ -172,11 +176,15 @@
static int ConfigMouse(const char *config)
{
struct mouseconf *p;
- char name[MAX_COLS];
+ char *name, *last, *sep = " \t\r\n";
mouseType = MOUSE_NONE;
mInfo.has_mouse = FALSE;
- sscanf(config, "%s", name);
+ name = strtok_r((char *)config, sep, &last);
+ if (name == NULL) {
+ warn("unknown mouse type ignored; assuming no mouse\r\n");
+ return SUCCESS;
+ }
for (p = mice; p->name != NULL; p++) {
if (strcasecmp(name, p->name) == 0) {
mouseType = p->type;
@@ -253,7 +261,7 @@
if ((mfd = open(mouseDev, O_RDWR|O_NONBLOCK)) < 0) {
warn("couldn't open mouse device; mouse disabled\n");
Perror(mouseDev);
- free(mouseDev);
+ SafeFree(mouseDev);
mouseDev = NULL;
mInfo.has_mouse = FALSE;
return -1;
|