To: vim-dev@vim.org Subject: Patch 6.1.439 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.439 Problem: Netbeans: A "create" function doesn't actually create a buffer, following functions may fail. Solution: Create a Vim buffer without a name when "create" is called. (Gordon Prieur) Files: runtime/doc/netbeans.txt, src/netbeans.c *** ../vim61.438/runtime/doc/netbeans.txt Wed Mar 12 19:19:15 2003 --- runtime/doc/netbeans.txt Wed Apr 2 11:17:57 2003 *************** *** 1,4 **** ! *netbeans.txt* For Vim version 6.1. Last change: 2003 Mar 12 VIM REFERENCE MANUAL by Gordon Prieur --- 1,4 ---- ! *netbeans.txt* For Vim version 6.1. Last change: 2003 Apr 02 VIM REFERENCE MANUAL by Gordon Prieur *************** *** 191,197 **** marked with "version 2.1". The messages are currently sent over a socket. Since the messages are in ! plain text this protocol could also be used with any other communication mechanism. 10.1 Kinds of messages |nb-messages| --- 191,197 ---- marked with "version 2.1". The messages are currently sent over a socket. Since the messages are in ! plain UTF-8 text this protocol could also be used with any other communication mechanism. 10.1 Kinds of messages |nb-messages| *************** *** 296,302 **** close Close the buffer. This leaves us without current buffer, very dangerous to use! ! create Not implemented. defineAnnoType typeNum typeName tooltip glyphFile fg bg Define a type of annotation for this buffer. --- 296,312 ---- close Close the buffer. This leaves us without current buffer, very dangerous to use! ! create Creates a buffer without a name. Replaces the current buffer ! (it's hidden when it was changed). ! Netbeans uses this as the first command for a file that is ! being opened. The sequence of commands could be: ! create ! setCaretListener (ignored) ! setModified (no effect) ! setContentType (ignored) ! startDocumentListen ! setTitle ! setFullName defineAnnoType typeNum typeName tooltip glyphFile fg bg Define a type of annotation for this buffer. *************** *** 312,318 **** used (new in version 2.1). When "glyphFile" is empty, no text sign is used (new in version 2.1). ! When "glyphFile" is two characters long, a text sign is defined (new in version 2.1). Note: the annotations will be defined in sequence, and the sequence number is later used with addAnno. --- 322,328 ---- used (new in version 2.1). When "glyphFile" is empty, no text sign is used (new in version 2.1). ! When "glyphFile" is one or two characters long, a text sign is defined (new in version 2.1). Note: the annotations will be defined in sequence, and the sequence number is later used with addAnno. *** ../vim61.438/src/netbeans.c Wed Mar 26 10:20:31 2003 --- src/netbeans.c Wed Apr 2 10:50:42 2003 *************** *** 297,303 **** sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion); nb_send(buf, "externaleditor_version"); ! nbdebug(("netbeans_connect: Connnection succeeded\n")); /* nb_init_graphics(); delay until needed */ --- 297,303 ---- sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion); nb_send(buf, "externaleditor_version"); ! nbdebug(("netbeans_connect: Connection succeeded\n")); /* nb_init_graphics(); delay until needed */ *************** *** 493,500 **** --- 493,502 ---- vim_free(node); } else + { /* more follows, move to the start */ mch_memmove(node->buffer, p, STRLEN(p) + 1); + } } } } *************** *** 630,637 **** char_u *verb; char_u *q; int bufno; ! int iscmd = 0; ! int isfunc = 0; if (STRCMP(cmd, "DISCONNECT") == 0) { --- 632,638 ---- char_u *verb; char_u *q; int bufno; ! int isfunc = -1; if (STRCMP(cmd, "DISCONNECT") == 0) { *************** *** 668,674 **** if (*q == '!') { *q++ = NUL; ! iscmd = 1; break; } else if (*q == '/') --- 669,675 ---- if (*q == '!') { *q++ = NUL; ! isfunc = 0; break; } else if (*q == '/') *************** *** 679,685 **** } } ! if (!iscmd && !isfunc) { warn("missing ! or / in: %s", cmd); return; --- 680,686 ---- } } ! if (isfunc < 0) { warn("missing ! or / in: %s", cmd); return; *************** *** 688,694 **** --- 689,698 ---- cmdno = strtol((char *)q, (char **)&q, 10); if (nb_do_cmd(bufno, verb, isfunc, cmdno, q) == FAIL) + { + nbdebug(("nb_parse_cmd: Command error for \"%s\"\n", cmd)); die("bad return from nb_do_cmd"); + } } struct nbbuf_struct *************** *** 747,753 **** /* * Given a Netbeans buffer number, return the netbeans buffer. ! * Returns NULL for a negative number. */ static nbbuf_T * nb_get_buf(int bufno) --- 751,758 ---- /* * Given a Netbeans buffer number, return the netbeans buffer. ! * Returns NULL for 0 or a negative number. A 0 bufno means a ! * non-buffer related command has been sent. */ static nbbuf_T * nb_get_buf(int bufno) *************** *** 755,761 **** /* find or create a buffer with the given number */ int incr; ! if (bufno < 0) return NULL; if (!buf_list) --- 760,766 ---- /* find or create a buffer with the given number */ int incr; ! if (bufno <= 0) return NULL; if (!buf_list) *************** *** 1075,1080 **** --- 1080,1086 ---- if (buf == NULL || buf->bufp == NULL) { + nbdebug((" null bufp in getLength")); die("null bufp in getLength"); retval = FAIL; } *************** *** 1103,1108 **** --- 1109,1115 ---- if (buf == NULL || buf->bufp == NULL) { + nbdebug((" null bufp in getText")); die("null bufp in getText"); retval = FAIL; } *************** *** 1113,1119 **** --- 1120,1129 ---- text = alloc((unsigned)((len > 0) ? ((len + nlines) * 2) : 4)); if (text == NULL) + { + nbdebug((" nb_do_cmd: getText has null text field\n")); retval = FAIL; + } else { p = text; *************** *** 1161,1166 **** --- 1171,1177 ---- if (buf == NULL || buf->bufp == NULL) { + nbdebug((" null bufp in remove")); die("null bufp in remove"); retval = FAIL; } *************** *** 1264,1269 **** --- 1275,1281 ---- if (buf == NULL || buf->bufp == NULL) { + nbdebug((" null bufp in insert")); die("null bufp in insert"); retval = FAIL; } *************** *** 1366,1377 **** /* =====================================================================*/ if (streq((char *)cmd, "create")) { ! #if 0 /* never used */ ! buf->internalname = (char *)alloc_clear(8); ! sprintf(buf->internalname, "<%d>", bufno); ! buf->netbeansOwns = 1; ! #endif ! /* not really created until setFullName */ /* =====================================================================*/ } else if (streq((char *)cmd, "startDocumentListen")) --- 1378,1399 ---- /* =====================================================================*/ if (streq((char *)cmd, "create")) { ! /* Create a buffer without a name. */ ! if (buf == NULL) ! { ! die("null buf in create"); ! return FAIL; ! } ! vim_free(buf->displayname); ! buf->displayname = NULL; ! nbdebug((" CREATE %d\n", bufno)); ! ! netbeansReadFile = 0; /* don't try to open disk file */ ! do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF); ! netbeansReadFile = 1; ! buf->bufp = curbuf; ! maketitle(); ! gui_update_menus(0); /* =====================================================================*/ } else if (streq((char *)cmd, "startDocumentListen")) *** ../vim61.438/src/version.c Sun Apr 6 14:32:02 2003 --- src/version.c Sun Apr 6 14:38:14 2003 *************** *** 613,614 **** --- 613,616 ---- { /* Add new patch number below this line */ + /**/ + 439, /**/ -- Life is a gift, living is an art. (Bram Moolenaar) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///