Mercurial > vim
comparison src/if_xcmdsrv.c @ 18798:f0f9692d4487 v8.1.2387
patch 8.1.2387: using old C style comments
Commit: https://github.com/vim/vim/commit/2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 4 21:24:53 2019 +0100
patch 8.1.2387: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Dec 2019 21:30:04 +0100 |
parents | bbea1f108187 |
children | a2e6da79274d |
comparison
equal
deleted
inserted
replaced
18797:76af6d0ea316 | 18798:f0f9692d4487 |
---|---|
62 * It's unlikely, but possible. | 62 * It's unlikely, but possible. |
63 */ | 63 */ |
64 | 64 |
65 typedef struct PendingCommand | 65 typedef struct PendingCommand |
66 { | 66 { |
67 int serial; /* Serial number expected in result. */ | 67 int serial; // Serial number expected in result. |
68 int code; /* Result Code. 0 is OK */ | 68 int code; // Result Code. 0 is OK |
69 char_u *result; /* String result for command (malloc'ed). | 69 char_u *result; // String result for command (malloc'ed). |
70 * NULL means command still pending. */ | 70 // NULL means command still pending. |
71 struct PendingCommand *nextPtr; | 71 struct PendingCommand *nextPtr; |
72 /* Next in list of all outstanding commands. | 72 // Next in list of all outstanding commands. |
73 * NULL means end of list. */ | 73 // NULL means end of list. |
74 } PendingCommand; | 74 } PendingCommand; |
75 | 75 |
76 static PendingCommand *pendingCommands = NULL; | 76 static PendingCommand *pendingCommands = NULL; |
77 /* List of all commands currently | 77 // List of all commands currently |
78 * being waited for. */ | 78 // being waited for. |
79 | 79 |
80 /* | 80 /* |
81 * The information below is used for communication between processes | 81 * The information below is used for communication between processes |
82 * during "send" commands. Each process keeps a private window, never | 82 * during "send" commands. Each process keeps a private window, never |
83 * even mapped, with one property, "Comm". When a command is sent to | 83 * even mapped, with one property, "Comm". When a command is sent to |
177 struct x_cmdqueue *prev; | 177 struct x_cmdqueue *prev; |
178 }; | 178 }; |
179 | 179 |
180 typedef struct x_cmdqueue x_queue_T; | 180 typedef struct x_cmdqueue x_queue_T; |
181 | 181 |
182 /* dummy node, header for circular queue */ | 182 // dummy node, header for circular queue |
183 static x_queue_T head = {NULL, 0, NULL, NULL}; | 183 static x_queue_T head = {NULL, 0, NULL, NULL}; |
184 | 184 |
185 /* | 185 /* |
186 * Forward declarations for procedures defined later in this file: | 186 * Forward declarations for procedures defined later in this file: |
187 */ | 187 */ |
198 static int x_error_check(Display *dpy, XErrorEvent *error_event); | 198 static int x_error_check(Display *dpy, XErrorEvent *error_event); |
199 static int IsSerialName(char_u *name); | 199 static int IsSerialName(char_u *name); |
200 static void save_in_queue(char_u *buf, long_u len); | 200 static void save_in_queue(char_u *buf, long_u len); |
201 static void server_parse_message(Display *dpy, char_u *propInfo, long_u numItems); | 201 static void server_parse_message(Display *dpy, char_u *propInfo, long_u numItems); |
202 | 202 |
203 /* Private variables for the "server" functionality */ | 203 // Private variables for the "server" functionality |
204 static Atom registryProperty = None; | 204 static Atom registryProperty = None; |
205 static Atom vimProperty = None; | 205 static Atom vimProperty = None; |
206 static int got_x_error = FALSE; | 206 static int got_x_error = FALSE; |
207 | 207 |
208 static char_u *empty_prop = (char_u *)""; /* empty GetRegProp() result */ | 208 static char_u *empty_prop = (char_u *)""; // empty GetRegProp() result |
209 | 209 |
210 /* | 210 /* |
211 * Associate an ASCII name with Vim. Try real hard to get a unique one. | 211 * Associate an ASCII name with Vim. Try real hard to get a unique one. |
212 * Returns FAIL or OK. | 212 * Returns FAIL or OK. |
213 */ | 213 */ |
214 int | 214 int |
215 serverRegisterName( | 215 serverRegisterName( |
216 Display *dpy, /* display to register with */ | 216 Display *dpy, // display to register with |
217 char_u *name) /* the name that will be used as a base */ | 217 char_u *name) // the name that will be used as a base |
218 { | 218 { |
219 int i; | 219 int i; |
220 int res; | 220 int res; |
221 char_u *p = NULL; | 221 char_u *p = NULL; |
222 | 222 |
327 * Clean out new ID from registry and set it as comm win. | 327 * Clean out new ID from registry and set it as comm win. |
328 * Change any registered window ID. | 328 * Change any registered window ID. |
329 */ | 329 */ |
330 void | 330 void |
331 serverChangeRegisteredWindow( | 331 serverChangeRegisteredWindow( |
332 Display *dpy, /* Display to register with */ | 332 Display *dpy, // Display to register with |
333 Window newwin) /* Re-register to this ID */ | 333 Window newwin) // Re-register to this ID |
334 { | 334 { |
335 char_u propInfo[MAX_NAME_LENGTH + 20]; | 335 char_u propInfo[MAX_NAME_LENGTH + 20]; |
336 | 336 |
337 commWindow = newwin; | 337 commWindow = newwin; |
338 | 338 |
339 /* Always call SendInit() here, to make sure commWindow is marked as a Vim | 339 // Always call SendInit() here, to make sure commWindow is marked as a Vim |
340 * window. */ | 340 // window. |
341 if (SendInit(dpy) < 0) | 341 if (SendInit(dpy) < 0) |
342 return; | 342 return; |
343 | 343 |
344 /* WARNING: Do not step through this while debugging, it will hangup the X | 344 // WARNING: Do not step through this while debugging, it will hangup the X |
345 * server! */ | 345 // server! |
346 XGrabServer(dpy); | 346 XGrabServer(dpy); |
347 DeleteAnyLingerer(dpy, newwin); | 347 DeleteAnyLingerer(dpy, newwin); |
348 if (serverName != NULL) | 348 if (serverName != NULL) |
349 { | 349 { |
350 /* Reinsert name if we was already registered */ | 350 // Reinsert name if we was already registered |
351 (void)LookupName(dpy, serverName, /*delete=*/TRUE, NULL); | 351 (void)LookupName(dpy, serverName, /*delete=*/TRUE, NULL); |
352 sprintf((char *)propInfo, "%x %.*s", | 352 sprintf((char *)propInfo, "%x %.*s", |
353 (int_u)newwin, MAX_NAME_LENGTH, serverName); | 353 (int_u)newwin, MAX_NAME_LENGTH, serverName); |
354 XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING, 8, | 354 XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING, 8, |
355 PropModeAppend, (char_u *)propInfo, | 355 PropModeAppend, (char_u *)propInfo, |
363 * Send to an instance of Vim via the X display. | 363 * Send to an instance of Vim via the X display. |
364 * Returns 0 for OK, negative for an error. | 364 * Returns 0 for OK, negative for an error. |
365 */ | 365 */ |
366 int | 366 int |
367 serverSendToVim( | 367 serverSendToVim( |
368 Display *dpy, /* Where to send. */ | 368 Display *dpy, // Where to send. |
369 char_u *name, /* Where to send. */ | 369 char_u *name, // Where to send. |
370 char_u *cmd, /* What to send. */ | 370 char_u *cmd, // What to send. |
371 char_u **result, /* Result of eval'ed expression */ | 371 char_u **result, // Result of eval'ed expression |
372 Window *server, /* Actual ID of receiving app */ | 372 Window *server, // Actual ID of receiving app |
373 Bool asExpr, /* Interpret as keystrokes or expr ? */ | 373 Bool asExpr, // Interpret as keystrokes or expr ? |
374 int timeout, /* seconds to wait or zero */ | 374 int timeout, // seconds to wait or zero |
375 Bool localLoop, /* Throw away everything but result */ | 375 Bool localLoop, // Throw away everything but result |
376 int silent) /* don't complain about no server */ | 376 int silent) // don't complain about no server |
377 { | 377 { |
378 Window w; | 378 Window w; |
379 char_u *property; | 379 char_u *property; |
380 int length; | 380 int length; |
381 int res; | 381 int res; |
382 static int serial = 0; /* Running count of sent commands. | 382 static int serial = 0; // Running count of sent commands. |
383 * Used to give each command a | 383 // Used to give each command a |
384 * different serial number. */ | 384 // different serial number. |
385 PendingCommand pending; | 385 PendingCommand pending; |
386 char_u *loosename = NULL; | 386 char_u *loosename = NULL; |
387 | 387 |
388 if (result != NULL) | 388 if (result != NULL) |
389 *result = NULL; | 389 *result = NULL; |
390 if (name == NULL || *name == NUL) | 390 if (name == NULL || *name == NUL) |
391 name = (char_u *)"GVIM"; /* use a default name */ | 391 name = (char_u *)"GVIM"; // use a default name |
392 | 392 |
393 if (commProperty == None && dpy != NULL) | 393 if (commProperty == None && dpy != NULL) |
394 { | 394 { |
395 if (SendInit(dpy) < 0) | 395 if (SendInit(dpy) < 0) |
396 return -1; | 396 return -1; |
397 } | 397 } |
398 | 398 |
399 /* Execute locally if no display or target is ourselves */ | 399 // Execute locally if no display or target is ourselves |
400 if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0)) | 400 if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0)) |
401 return sendToLocalVim(cmd, asExpr, result); | 401 return sendToLocalVim(cmd, asExpr, result); |
402 | 402 |
403 /* | 403 /* |
404 * Bind the server name to a communication window. | 404 * Bind the server name to a communication window. |
409 * Delete any lingering names from dead editors. | 409 * Delete any lingering names from dead editors. |
410 */ | 410 */ |
411 while (TRUE) | 411 while (TRUE) |
412 { | 412 { |
413 w = LookupName(dpy, name, FALSE, &loosename); | 413 w = LookupName(dpy, name, FALSE, &loosename); |
414 /* Check that the window is hot */ | 414 // Check that the window is hot |
415 if (w != None) | 415 if (w != None) |
416 { | 416 { |
417 if (!WindowValid(dpy, w)) | 417 if (!WindowValid(dpy, w)) |
418 { | 418 { |
419 LookupName(dpy, loosename ? loosename : name, | 419 LookupName(dpy, loosename ? loosename : name, |
445 | 445 |
446 sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s", | 446 sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s", |
447 0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd); | 447 0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd); |
448 if (name == loosename) | 448 if (name == loosename) |
449 vim_free(loosename); | 449 vim_free(loosename); |
450 /* Add a back reference to our comm window */ | 450 // Add a back reference to our comm window |
451 serial++; | 451 serial++; |
452 sprintf((char *)property + length, "%c-r %x %d", | 452 sprintf((char *)property + length, "%c-r %x %d", |
453 0, (int_u)commWindow, serial); | 453 0, (int_u)commWindow, serial); |
454 /* Add length of what "-r %x %d" resulted in, skipping the NUL. */ | 454 // Add length of what "-r %x %d" resulted in, skipping the NUL. |
455 length += STRLEN(property + length + 1) + 1; | 455 length += STRLEN(property + length + 1) + 1; |
456 | 456 |
457 res = AppendPropCarefully(dpy, w, commProperty, property, length + 1); | 457 res = AppendPropCarefully(dpy, w, commProperty, property, length + 1); |
458 vim_free(property); | 458 vim_free(property); |
459 if (res < 0) | 459 if (res < 0) |
460 { | 460 { |
461 emsg(_("E248: Failed to send command to the destination program")); | 461 emsg(_("E248: Failed to send command to the destination program")); |
462 return -1; | 462 return -1; |
463 } | 463 } |
464 | 464 |
465 if (!asExpr) /* There is no answer for this - Keys are sent async */ | 465 if (!asExpr) // There is no answer for this - Keys are sent async |
466 return 0; | 466 return 0; |
467 | 467 |
468 /* | 468 /* |
469 * Register the fact that we're waiting for a command to | 469 * Register the fact that we're waiting for a command to |
470 * complete (this is needed by SendEventProc and by | 470 * complete (this is needed by SendEventProc and by |
590 | 590 |
591 #ifdef FEAT_TIMERS | 591 #ifdef FEAT_TIMERS |
592 check_due_timer(); | 592 check_due_timer(); |
593 #endif | 593 #endif |
594 | 594 |
595 /* Just look out for the answer without calling back into Vim */ | 595 // Just look out for the answer without calling back into Vim |
596 if (localLoop) | 596 if (localLoop) |
597 { | 597 { |
598 #ifndef HAVE_SELECT | 598 #ifndef HAVE_SELECT |
599 if (poll(&fds, 1, SEND_MSEC_POLL) < 0) | 599 if (poll(&fds, 1, SEND_MSEC_POLL) < 0) |
600 break; | 600 break; |
668 XFree(regProp); | 668 XFree(regProp); |
669 ga_append(&ga, NUL); | 669 ga_append(&ga, NUL); |
670 return ga.ga_data; | 670 return ga.ga_data; |
671 } | 671 } |
672 | 672 |
673 /* ---------------------------------------------------------- | 673 ///////////////////////////////////////////////////////////// |
674 * Reply stuff | 674 // Reply stuff |
675 */ | |
676 | 675 |
677 static struct ServerReply * | 676 static struct ServerReply * |
678 ServerReplyFind(Window w, enum ServerReplyOp op) | 677 ServerReplyFind(Window w, enum ServerReplyOp op) |
679 { | 678 { |
680 struct ServerReply *p; | 679 struct ServerReply *p; |
752 length = STRLEN(p_enc) + STRLEN(str) + 14; | 751 length = STRLEN(p_enc) + STRLEN(str) + 14; |
753 if ((property = alloc(length + 30)) != NULL) | 752 if ((property = alloc(length + 30)) != NULL) |
754 { | 753 { |
755 sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", | 754 sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", |
756 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); | 755 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); |
757 /* Add length of what "%x" resulted in. */ | 756 // Add length of what "%x" resulted in. |
758 length += STRLEN(property + length); | 757 length += STRLEN(property + length); |
759 res = AppendPropCarefully(dpy, win, commProperty, property, length + 1); | 758 res = AppendPropCarefully(dpy, win, commProperty, property, length + 1); |
760 vim_free(property); | 759 vim_free(property); |
761 return res; | 760 return res; |
762 } | 761 } |
802 mch_memmove(s, s + len, p->strings.ga_len - len); | 801 mch_memmove(s, s + len, p->strings.ga_len - len); |
803 p->strings.ga_len -= len; | 802 p->strings.ga_len -= len; |
804 } | 803 } |
805 else | 804 else |
806 { | 805 { |
807 /* Last string read. Remove from list */ | 806 // Last string read. Remove from list |
808 ga_clear(&p->strings); | 807 ga_clear(&p->strings); |
809 ServerReplyFind(win, SROP_Delete); | 808 ServerReplyFind(win, SROP_Delete); |
810 } | 809 } |
811 return 0; | 810 return 0; |
812 } | 811 } |
862 commWindow = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy), | 861 commWindow = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy), |
863 getpid(), 0, 10, 10, 0, | 862 getpid(), 0, 10, 10, 0, |
864 WhitePixel(dpy, DefaultScreen(dpy)), | 863 WhitePixel(dpy, DefaultScreen(dpy)), |
865 WhitePixel(dpy, DefaultScreen(dpy))); | 864 WhitePixel(dpy, DefaultScreen(dpy))); |
866 XSelectInput(dpy, commWindow, PropertyChangeMask); | 865 XSelectInput(dpy, commWindow, PropertyChangeMask); |
867 /* WARNING: Do not step through this while debugging, it will hangup | 866 // WARNING: Do not step through this while debugging, it will hangup |
868 * the X server! */ | 867 // the X server! |
869 XGrabServer(dpy); | 868 XGrabServer(dpy); |
870 DeleteAnyLingerer(dpy, commWindow); | 869 DeleteAnyLingerer(dpy, commWindow); |
871 XUngrabServer(dpy); | 870 XUngrabServer(dpy); |
872 } | 871 } |
873 | 872 |
874 /* Make window recognizable as a vim window */ | 873 // Make window recognizable as a vim window |
875 XChangeProperty(dpy, commWindow, vimProperty, XA_STRING, | 874 XChangeProperty(dpy, commWindow, vimProperty, XA_STRING, |
876 8, PropModeReplace, (char_u *)VIM_VERSION_SHORT, | 875 8, PropModeReplace, (char_u *)VIM_VERSION_SHORT, |
877 (int)STRLEN(VIM_VERSION_SHORT) + 1); | 876 (int)STRLEN(VIM_VERSION_SHORT) + 1); |
878 | 877 |
879 XSync(dpy, False); | 878 XSync(dpy, False); |
894 * If "delete" is non-zero, then if the named server is found it is | 893 * If "delete" is non-zero, then if the named server is found it is |
895 * removed from the registry property. | 894 * removed from the registry property. |
896 */ | 895 */ |
897 static Window | 896 static Window |
898 LookupName( | 897 LookupName( |
899 Display *dpy, /* Display whose registry to check. */ | 898 Display *dpy, // Display whose registry to check. |
900 char_u *name, /* Name of a server. */ | 899 char_u *name, // Name of a server. |
901 int delete, /* If non-zero, delete info about name. */ | 900 int delete, // If non-zero, delete info about name. |
902 char_u **loose) /* Do another search matching -999 if not found | 901 char_u **loose) // Do another search matching -999 if not found |
903 Return result here if a match is found */ | 902 // Return result here if a match is found |
904 { | 903 { |
905 char_u *regProp, *entry; | 904 char_u *regProp, *entry; |
906 char_u *p; | 905 char_u *p; |
907 long_u numItems; | 906 long_u numItems; |
908 int_u returnValue; | 907 int_u returnValue; |
915 | 914 |
916 /* | 915 /* |
917 * Scan the property for the desired name. | 916 * Scan the property for the desired name. |
918 */ | 917 */ |
919 returnValue = (int_u)None; | 918 returnValue = (int_u)None; |
920 entry = NULL; /* Not needed, but eliminates compiler warning. */ | 919 entry = NULL; // Not needed, but eliminates compiler warning. |
921 for (p = regProp; (long_u)(p - regProp) < numItems; ) | 920 for (p = regProp; (long_u)(p - regProp) < numItems; ) |
922 { | 921 { |
923 entry = p; | 922 entry = p; |
924 while (*p != 0 && !isspace(*p)) | 923 while (*p != 0 && !isspace(*p)) |
925 p++; | 924 p++; |
988 * 2. We get that id for our commWindow but only want to send, not register. | 987 * 2. We get that id for our commWindow but only want to send, not register. |
989 * 3. The window will mistakenly be regarded valid because of own commWindow | 988 * 3. The window will mistakenly be regarded valid because of own commWindow |
990 */ | 989 */ |
991 static void | 990 static void |
992 DeleteAnyLingerer( | 991 DeleteAnyLingerer( |
993 Display *dpy, /* Display whose registry to check. */ | 992 Display *dpy, // Display whose registry to check. |
994 Window win) /* Window to remove */ | 993 Window win) // Window to remove |
995 { | 994 { |
996 char_u *regProp, *entry = NULL; | 995 char_u *regProp, *entry = NULL; |
997 char_u *p; | 996 char_u *p; |
998 long_u numItems; | 997 long_u numItems; |
999 int_u wwin; | 998 int_u wwin; |
1002 * Read the registry property. | 1001 * Read the registry property. |
1003 */ | 1002 */ |
1004 if (GetRegProp(dpy, ®Prop, &numItems, FALSE) == FAIL) | 1003 if (GetRegProp(dpy, ®Prop, &numItems, FALSE) == FAIL) |
1005 return; | 1004 return; |
1006 | 1005 |
1007 /* Scan the property for the window id. */ | 1006 // Scan the property for the window id. |
1008 for (p = regProp; (long_u)(p - regProp) < numItems; ) | 1007 for (p = regProp; (long_u)(p - regProp) < numItems; ) |
1009 { | 1008 { |
1010 if (*p != 0) | 1009 if (*p != 0) |
1011 { | 1010 { |
1012 sscanf((char *)p, "%x", &wwin); | 1011 sscanf((char *)p, "%x", &wwin); |
1013 if ((Window)wwin == win) | 1012 if ((Window)wwin == win) |
1014 { | 1013 { |
1015 int lastHalf; | 1014 int lastHalf; |
1016 | 1015 |
1017 /* Copy down the remainder to delete entry */ | 1016 // Copy down the remainder to delete entry |
1018 entry = p; | 1017 entry = p; |
1019 while (*p != 0) | 1018 while (*p != 0) |
1020 p++; | 1019 p++; |
1021 p++; | 1020 p++; |
1022 lastHalf = numItems - (p - regProp); | 1021 lastHalf = numItems - (p - regProp); |
1053 static int | 1052 static int |
1054 GetRegProp( | 1053 GetRegProp( |
1055 Display *dpy, | 1054 Display *dpy, |
1056 char_u **regPropp, | 1055 char_u **regPropp, |
1057 long_u *numItemsp, | 1056 long_u *numItemsp, |
1058 int domsg) /* When TRUE give error message. */ | 1057 int domsg) // When TRUE give error message. |
1059 { | 1058 { |
1060 int result, actualFormat; | 1059 int result, actualFormat; |
1061 long_u bytesAfter; | 1060 long_u bytesAfter; |
1062 Atom actualType; | 1061 Atom actualType; |
1063 XErrorHandler old_handler; | 1062 XErrorHandler old_handler; |
1077 if (got_x_error) | 1076 if (got_x_error) |
1078 return FAIL; | 1077 return FAIL; |
1079 | 1078 |
1080 if (actualType == None) | 1079 if (actualType == None) |
1081 { | 1080 { |
1082 /* No prop yet. Logically equal to the empty list */ | 1081 // No prop yet. Logically equal to the empty list |
1083 *numItemsp = 0; | 1082 *numItemsp = 0; |
1084 *regPropp = empty_prop; | 1083 *regPropp = empty_prop; |
1085 return OK; | 1084 return OK; |
1086 } | 1085 } |
1087 | 1086 |
1088 /* If the property is improperly formed, then delete it. */ | 1087 // If the property is improperly formed, then delete it. |
1089 if (result != Success || actualFormat != 8 || actualType != XA_STRING) | 1088 if (result != Success || actualFormat != 8 || actualType != XA_STRING) |
1090 { | 1089 { |
1091 if (*regPropp != NULL) | 1090 if (*regPropp != NULL) |
1092 XFree(*regPropp); | 1091 XFree(*regPropp); |
1093 XDeleteProperty(dpy, RootWindow(dpy, 0), registryProperty); | 1092 XDeleteProperty(dpy, RootWindow(dpy, 0), registryProperty); |
1108 * response. | 1107 * response. |
1109 */ | 1108 */ |
1110 void | 1109 void |
1111 serverEventProc( | 1110 serverEventProc( |
1112 Display *dpy, | 1111 Display *dpy, |
1113 XEvent *eventPtr, /* Information about event. */ | 1112 XEvent *eventPtr, // Information about event. |
1114 int immediate) /* Run event immediately. Should mostly be 0. */ | 1113 int immediate) // Run event immediately. Should mostly be 0. |
1115 { | 1114 { |
1116 char_u *propInfo; | 1115 char_u *propInfo; |
1117 int result, actualFormat; | 1116 int result, actualFormat; |
1118 long_u numItems, bytesAfter; | 1117 long_u numItems, bytesAfter; |
1119 Atom actualType; | 1118 Atom actualType; |
1133 (long)MAX_PROP_WORDS, True, | 1132 (long)MAX_PROP_WORDS, True, |
1134 XA_STRING, &actualType, | 1133 XA_STRING, &actualType, |
1135 &actualFormat, &numItems, &bytesAfter, | 1134 &actualFormat, &numItems, &bytesAfter, |
1136 &propInfo); | 1135 &propInfo); |
1137 | 1136 |
1138 /* If the property doesn't exist or is improperly formed then ignore it. */ | 1137 // If the property doesn't exist or is improperly formed then ignore it. |
1139 if (result != Success || actualType != XA_STRING || actualFormat != 8) | 1138 if (result != Success || actualType != XA_STRING || actualFormat != 8) |
1140 { | 1139 { |
1141 if (propInfo != NULL) | 1140 if (propInfo != NULL) |
1142 XFree(propInfo); | 1141 XFree(propInfo); |
1143 return; | 1142 return; |
1157 { | 1156 { |
1158 x_queue_T *node; | 1157 x_queue_T *node; |
1159 | 1158 |
1160 node = ALLOC_ONE(x_queue_T); | 1159 node = ALLOC_ONE(x_queue_T); |
1161 if (node == NULL) | 1160 if (node == NULL) |
1162 return; /* out of memory */ | 1161 return; // out of memory |
1163 node->propInfo = propInfo; | 1162 node->propInfo = propInfo; |
1164 node->len = len; | 1163 node->len = len; |
1165 | 1164 |
1166 if (head.next == NULL) /* initialize circular queue */ | 1165 if (head.next == NULL) // initialize circular queue |
1167 { | 1166 { |
1168 head.next = &head; | 1167 head.next = &head; |
1169 head.prev = &head; | 1168 head.prev = &head; |
1170 } | 1169 } |
1171 | 1170 |
1172 /* insert node at tail of queue */ | 1171 // insert node at tail of queue |
1173 node->next = &head; | 1172 node->next = &head; |
1174 node->prev = head.prev; | 1173 node->prev = head.prev; |
1175 head.prev->next = node; | 1174 head.prev->next = node; |
1176 head.prev = node; | 1175 head.prev = node; |
1177 } | 1176 } |
1183 server_parse_messages(void) | 1182 server_parse_messages(void) |
1184 { | 1183 { |
1185 x_queue_T *node; | 1184 x_queue_T *node; |
1186 | 1185 |
1187 if (!X_DISPLAY) | 1186 if (!X_DISPLAY) |
1188 return; /* cannot happen? */ | 1187 return; // cannot happen? |
1189 while (head.next != NULL && head.next != &head) | 1188 while (head.next != NULL && head.next != &head) |
1190 { | 1189 { |
1191 node = head.next; | 1190 node = head.next; |
1192 head.next = node->next; | 1191 head.next = node->next; |
1193 node->next->prev = node->prev; | 1192 node->next->prev = node->prev; |
1212 * "propInfo" will be freed. | 1211 * "propInfo" will be freed. |
1213 */ | 1212 */ |
1214 static void | 1213 static void |
1215 server_parse_message( | 1214 server_parse_message( |
1216 Display *dpy, | 1215 Display *dpy, |
1217 char_u *propInfo, /* A string containing 0 or more X commands */ | 1216 char_u *propInfo, // A string containing 0 or more X commands |
1218 long_u numItems) /* The size of propInfo in bytes. */ | 1217 long_u numItems) // The size of propInfo in bytes. |
1219 { | 1218 { |
1220 char_u *p; | 1219 char_u *p; |
1221 int code; | 1220 int code; |
1222 char_u *tofree; | 1221 char_u *tofree; |
1223 | 1222 |
1274 if (end == p + 2 || *end != ' ') | 1273 if (end == p + 2 || *end != ' ') |
1275 resWindow = None; | 1274 resWindow = None; |
1276 else | 1275 else |
1277 { | 1276 { |
1278 p = serial = end + 1; | 1277 p = serial = end + 1; |
1279 clientWindow = resWindow; /* Remember in global */ | 1278 clientWindow = resWindow; // Remember in global |
1280 } | 1279 } |
1281 break; | 1280 break; |
1282 case 'n': | 1281 case 'n': |
1283 if (p[2] == ' ') | 1282 if (p[2] == ' ') |
1284 name = p + 3; | 1283 name = p + 3; |
1312 res = eval_client_expr_to_string(script); | 1311 res = eval_client_expr_to_string(script); |
1313 if (resWindow != None) | 1312 if (resWindow != None) |
1314 { | 1313 { |
1315 garray_T reply; | 1314 garray_T reply; |
1316 | 1315 |
1317 /* Initialize the result property. */ | 1316 // Initialize the result property. |
1318 ga_init2(&reply, 1, 100); | 1317 ga_init2(&reply, 1, 100); |
1319 (void)ga_grow(&reply, 50 + STRLEN(p_enc)); | 1318 (void)ga_grow(&reply, 50 + STRLEN(p_enc)); |
1320 sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ", | 1319 sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ", |
1321 0, 0, p_enc, 0, serial, 0); | 1320 0, 0, p_enc, 0, serial, 0); |
1322 reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial); | 1321 reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial); |
1323 | 1322 |
1324 /* Evaluate the expression and return the result. */ | 1323 // Evaluate the expression and return the result. |
1325 if (res != NULL) | 1324 if (res != NULL) |
1326 ga_concat(&reply, res); | 1325 ga_concat(&reply, res); |
1327 else | 1326 else |
1328 { | 1327 { |
1329 ga_concat(&reply, (char_u *)_(e_invexprmsg)); | 1328 ga_concat(&reply, (char_u *)_(e_invexprmsg)); |
1483 * than having Xlib panic. | 1482 * than having Xlib panic. |
1484 * Return: 0 for OK, -1 for error | 1483 * Return: 0 for OK, -1 for error |
1485 */ | 1484 */ |
1486 static int | 1485 static int |
1487 AppendPropCarefully( | 1486 AppendPropCarefully( |
1488 Display *dpy, /* Display on which to operate. */ | 1487 Display *dpy, // Display on which to operate. |
1489 Window window, /* Window whose property is to be modified. */ | 1488 Window window, // Window whose property is to be modified. |
1490 Atom property, /* Name of property. */ | 1489 Atom property, // Name of property. |
1491 char_u *value, /* Characters to append to property. */ | 1490 char_u *value, // Characters to append to property. |
1492 int length) /* How much to append */ | 1491 int length) // How much to append |
1493 { | 1492 { |
1494 XErrorHandler old_handler; | 1493 XErrorHandler old_handler; |
1495 | 1494 |
1496 old_handler = XSetErrorHandler(x_error_check); | 1495 old_handler = XSetErrorHandler(x_error_check); |
1497 got_x_error = FALSE; | 1496 got_x_error = FALSE; |
1522 { | 1521 { |
1523 int len = STRLEN(str); | 1522 int len = STRLEN(str); |
1524 | 1523 |
1525 return (len > 1 && vim_isdigit(str[len - 1])); | 1524 return (len > 1 && vim_isdigit(str[len - 1])); |
1526 } | 1525 } |
1527 #endif /* FEAT_CLIENTSERVER */ | 1526 #endif // FEAT_CLIENTSERVER |