comparison src/if_xcmdsrv.c @ 39:c16898406ff2

synchorinize version 7.3.081
author one@zeus.cr.ie.u-ryukyu.ac.jp
date Fri, 17 Dec 2010 17:43:06 +0900
parents e170173ecb68
children 67300faee616
comparison
equal deleted inserted replaced
38:e06a1cd7230d 39:c16898406ff2
17 #if defined(FEAT_CLIENTSERVER) || defined(PROTO) 17 #if defined(FEAT_CLIENTSERVER) || defined(PROTO)
18 18
19 # ifdef FEAT_X11 19 # ifdef FEAT_X11
20 # include <X11/Intrinsic.h> 20 # include <X11/Intrinsic.h>
21 # include <X11/Xatom.h> 21 # include <X11/Xatom.h>
22 # endif
23
24 # if defined(HAVE_SYS_SELECT_H) && \
25 (!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
26 # include <sys/select.h>
27 # endif
28
29 # ifndef HAVE_SELECT
30 # ifdef HAVE_SYS_POLL_H
31 # include <sys/poll.h>
32 # else
33 # ifdef HAVE_POLL_H
34 # include <poll.h>
35 # endif
36 # endif
37 # endif 22 # endif
38 23
39 /* 24 /*
40 * This file provides procedures that implement the command server 25 * This file provides procedures that implement the command server
41 * functionality of Vim when in contact with an X11 server. 26 * functionality of Vim when in contact with an X11 server.
680 665
681 /* 666 /*
682 * Scan all of the names out of the property. 667 * Scan all of the names out of the property.
683 */ 668 */
684 ga_init2(&ga, 1, 100); 669 ga_init2(&ga, 1, 100);
685 for (p = regProp; (p - regProp) < numItems; p++) 670 for (p = regProp; (long_u)(p - regProp) < numItems; p++)
686 { 671 {
687 entry = p; 672 entry = p;
688 while (*p != 0 && !isspace(*p)) 673 while (*p != 0 && !isspace(*p))
689 p++; 674 p++;
690 if (*p != 0) 675 if (*p != 0)
734 { 719 {
735 p = ((struct ServerReply *) serverReply.ga_data) 720 p = ((struct ServerReply *) serverReply.ga_data)
736 + serverReply.ga_len; 721 + serverReply.ga_len;
737 e.id = w; 722 e.id = w;
738 ga_init2(&e.strings, 1, 100); 723 ga_init2(&e.strings, 1, 100);
739 memcpy(p, &e, sizeof(e)); 724 mch_memmove(p, &e, sizeof(e));
740 serverReply.ga_len++; 725 serverReply.ga_len++;
741 } 726 }
742 } 727 }
743 else if (p != NULL && op == SROP_Delete) 728 else if (p != NULL && op == SROP_Delete)
744 { 729 {
967 /* 952 /*
968 * Scan the property for the desired name. 953 * Scan the property for the desired name.
969 */ 954 */
970 returnValue = (int_u)None; 955 returnValue = (int_u)None;
971 entry = NULL; /* Not needed, but eliminates compiler warning. */ 956 entry = NULL; /* Not needed, but eliminates compiler warning. */
972 for (p = regProp; (p - regProp) < numItems; ) 957 for (p = regProp; (long_u)(p - regProp) < numItems; )
973 { 958 {
974 entry = p; 959 entry = p;
975 while (*p != 0 && !isspace(*p)) 960 while (*p != 0 && !isspace(*p))
976 p++; 961 p++;
977 if (*p != 0 && STRICMP(name, p + 1) == 0) 962 if (*p != 0 && STRICMP(name, p + 1) == 0)
984 p++; 969 p++;
985 } 970 }
986 971
987 if (loose != NULL && returnValue == (int_u)None && !IsSerialName(name)) 972 if (loose != NULL && returnValue == (int_u)None && !IsSerialName(name))
988 { 973 {
989 for (p = regProp; (p - regProp) < numItems; ) 974 for (p = regProp; (long_u)(p - regProp) < numItems; )
990 { 975 {
991 entry = p; 976 entry = p;
992 while (*p != 0 && !isspace(*p)) 977 while (*p != 0 && !isspace(*p))
993 p++; 978 p++;
994 if (*p != 0 && IsSerialName(p + 1) 979 if (*p != 0 && IsSerialName(p + 1)
1016 while (*p != 0) 1001 while (*p != 0)
1017 p++; 1002 p++;
1018 p++; 1003 p++;
1019 count = numItems - (p - regProp); 1004 count = numItems - (p - regProp);
1020 if (count > 0) 1005 if (count > 0)
1021 memcpy(entry, p, count); 1006 mch_memmove(entry, p, count);
1022 XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING, 1007 XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING,
1023 8, PropModeReplace, regProp, 1008 8, PropModeReplace, regProp,
1024 (int)(numItems - (p - entry))); 1009 (int)(numItems - (p - entry)));
1025 XSync(dpy, False); 1010 XSync(dpy, False);
1026 } 1011 }
1054 */ 1039 */
1055 if (GetRegProp(dpy, &regProp, &numItems, FALSE) == FAIL) 1040 if (GetRegProp(dpy, &regProp, &numItems, FALSE) == FAIL)
1056 return; 1041 return;
1057 1042
1058 /* Scan the property for the window id. */ 1043 /* Scan the property for the window id. */
1059 for (p = regProp; (p - regProp) < numItems; ) 1044 for (p = regProp; (long_u)(p - regProp) < numItems; )
1060 { 1045 {
1061 if (*p != 0) 1046 if (*p != 0)
1062 { 1047 {
1063 sscanf((char *)p, "%x", &wwin); 1048 sscanf((char *)p, "%x", &wwin);
1064 if ((Window)wwin == win) 1049 if ((Window)wwin == win)
1070 while (*p != 0) 1055 while (*p != 0)
1071 p++; 1056 p++;
1072 p++; 1057 p++;
1073 lastHalf = numItems - (p - regProp); 1058 lastHalf = numItems - (p - regProp);
1074 if (lastHalf > 0) 1059 if (lastHalf > 0)
1075 memcpy(entry, p, lastHalf); 1060 mch_memmove(entry, p, lastHalf);
1076 numItems = (entry - regProp) + lastHalf; 1061 numItems = (entry - regProp) + lastHalf;
1077 p = entry; 1062 p = entry;
1078 continue; 1063 continue;
1079 } 1064 }
1080 } 1065 }
1194 /* 1179 /*
1195 * Several commands and results could arrive in the property at 1180 * Several commands and results could arrive in the property at
1196 * one time; each iteration through the outer loop handles a 1181 * one time; each iteration through the outer loop handles a
1197 * single command or result. 1182 * single command or result.
1198 */ 1183 */
1199 for (p = propInfo; (p - propInfo) < numItems; ) 1184 for (p = propInfo; (long_u)(p - propInfo) < numItems; )
1200 { 1185 {
1201 /* 1186 /*
1202 * Ignore leading NULs; each command or result starts with a 1187 * Ignore leading NULs; each command or result starts with a
1203 * NUL so that no matter how badly formed a preceding command 1188 * NUL so that no matter how badly formed a preceding command
1204 * is, we'll be able to tell that a new command/result is 1189 * is, we'll be able to tell that a new command/result is
1228 name = NULL; 1213 name = NULL;
1229 resWindow = None; 1214 resWindow = None;
1230 serial = (char_u *)""; 1215 serial = (char_u *)"";
1231 script = NULL; 1216 script = NULL;
1232 enc = NULL; 1217 enc = NULL;
1233 while (p - propInfo < numItems && *p == '-') 1218 while ((long_u)(p - propInfo) < numItems && *p == '-')
1234 { 1219 {
1235 switch (p[1]) 1220 switch (p[1])
1236 { 1221 {
1237 case 'r': 1222 case 'r':
1238 end = skipwhite(p + 2); 1223 end = skipwhite(p + 2);
1331 p += 2; 1316 p += 2;
1332 gotSerial = 0; 1317 gotSerial = 0;
1333 res = (char_u *)""; 1318 res = (char_u *)"";
1334 code = 0; 1319 code = 0;
1335 enc = NULL; 1320 enc = NULL;
1336 while ((p-propInfo) < numItems && *p == '-') 1321 while ((long_u)(p - propInfo) < numItems && *p == '-')
1337 { 1322 {
1338 switch (p[1]) 1323 switch (p[1])
1339 { 1324 {
1340 case 'r': 1325 case 'r':
1341 if (p[2] == ' ') 1326 if (p[2] == ' ')
1399 */ 1384 */
1400 p += 2; 1385 p += 2;
1401 gotWindow = 0; 1386 gotWindow = 0;
1402 str = (char_u *)""; 1387 str = (char_u *)"";
1403 enc = NULL; 1388 enc = NULL;
1404 while ((p-propInfo) < numItems && *p == '-') 1389 while ((long_u)(p - propInfo) < numItems && *p == '-')
1405 { 1390 {
1406 switch (p[1]) 1391 switch (p[1])
1407 { 1392 {
1408 case 'n': 1393 case 'n':
1409 if (p[2] == ' ') 1394 if (p[2] == ' ')
1487 1472
1488 1473
1489 /* 1474 /*
1490 * Another X Error handler, just used to check for errors. 1475 * Another X Error handler, just used to check for errors.
1491 */ 1476 */
1492 /* ARGSUSED */
1493 static int 1477 static int
1494 x_error_check(dpy, error_event) 1478 x_error_check(dpy, error_event)
1495 Display *dpy; 1479 Display *dpy UNUSED;
1496 XErrorEvent *error_event; 1480 XErrorEvent *error_event UNUSED;
1497 { 1481 {
1498 got_x_error = TRUE; 1482 got_x_error = TRUE;
1499 return 0; 1483 return 0;
1500 } 1484 }
1501 1485