home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.145 < prev    next >
Encoding:
Internet Message Format  |  2002-08-02  |  6.7 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.145
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.145
  11. Problem:    GTK: Drag&drop with more than 3 files may cause a crash. (Mickael
  12.         Marchand)
  13. Solution:   Rewrite the code that parses the received list of files to be more
  14.         robust.
  15. Files:        src/charset.c, src/gui_gtk_x11.c
  16.  
  17.  
  18. *** ../vim61.144/src/charset.c    Sat Aug  3 14:05:15 2002
  19. --- src/charset.c    Tue Jul 30 19:28:32 2002
  20. ***************
  21. *** 1558,1564 ****
  22.       return c - '0';
  23.   }
  24.   
  25. ! #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
  26.   /*
  27.    * Convert two hex characters to a byte.
  28.    * Return -1 if one of the characters is not hex.
  29. --- 1558,1565 ----
  30.       return c - '0';
  31.   }
  32.   
  33. ! #if defined(FEAT_TERMRESPONSE) \
  34. !     || (defined(FEAT_GUI_GTK) && defined(FEAT_WINDOWS)) || defined(PROTO)
  35.   /*
  36.    * Convert two hex characters to a byte.
  37.    * Return -1 if one of the characters is not hex.
  38. *** ../vim61.144/src/gui_gtk_x11.c    Sat May  4 22:23:07 2002
  39. --- src/gui_gtk_x11.c    Thu Jul 18 21:20:54 2002
  40. ***************
  41. *** 1400,1408 ****
  42.       int        redo_dirs = FALSE;
  43.       int        i;
  44.       int        n;
  45. !     char    *start;
  46. !     char    *stop;
  47. !     char    *copy;
  48.       int        nfiles;
  49.       int        url = FALSE;
  50.       GdkModifierType current_modifiers;
  51. --- 1400,1408 ----
  52.       int        redo_dirs = FALSE;
  53.       int        i;
  54.       int        n;
  55. !     char_u    *start;
  56. !     char_u    *copy;
  57. !     char_u    *names = data->data;
  58.       int        nfiles;
  59.       int        url = FALSE;
  60.       GdkModifierType current_modifiers;
  61. ***************
  62. *** 1415,1495 ****
  63.       /* guard against trash */
  64.       if (data->length <= 0
  65.           || data->format != 8
  66. !         || ((char *)data->data)[data->length] != '\0')
  67.       {
  68.       gtk_drag_finish(context, FALSE, FALSE, time);
  69.       return;
  70.       }
  71.   
  72. !     /* Count how many items there may be and normalize delimiters. */
  73. !     n = 1;
  74. !     copy = strdup((char *)data->data);
  75.       for (i = 0; i < data->length; ++i)
  76.       {
  77. !     if (copy[i] == '\n')
  78. !         ++n;
  79. !     else if (copy[i] == '\r')
  80.       {
  81. !         copy[i] = '\n';
  82. !         ++n;
  83.       }
  84.       }
  85.   
  86. !     fnames = (char_u **)alloc((n + 1) * sizeof(char_u *));
  87.   
  88.       start = copy;
  89. !     stop = copy;
  90. !     nfiles = 0;
  91. !     for (i = 0; i < n; ++i)
  92.       {
  93. !     stop = strchr(start, '\n');
  94. !     if (stop != NULL)
  95. !         *stop = '\0';
  96. !     if (strlen(start) == 0)
  97. !         continue;
  98. !     if (strncmp(start, "http://", 7) == 0
  99. !         || strncmp(start, "ftp://", 6) == 0)
  100. !     {
  101. !         url = TRUE;
  102. !     }
  103. !     else if (strncmp(start, "file:", 5) != 0)
  104. !     {
  105. !         int j;
  106. !         free(copy);
  107. !         for (j = 0; j < nfiles; ++j)
  108. !         free(fnames[j]);
  109. !         gtk_drag_finish(context, FALSE, FALSE, time);
  110. !         return;
  111. !     }
  112. !     if (strncmp(start, "file://localhost", 16) == 0)
  113. !     {
  114. !         fnames[nfiles] = (char_u *)strdup(start + 16);
  115. !         ++nfiles;
  116. !     }
  117.       else
  118.       {
  119. !         if (url == FALSE)
  120.           {
  121.           start += 5;
  122.           while (start[0] == '/' && start[1] == '/')
  123.               ++start;
  124.           }
  125. -         fnames[nfiles] = (char_u *)strdup(start);
  126. -         ++nfiles;
  127.       }
  128. !     start = stop + 2;
  129.       }
  130. -     free(copy);
  131.   
  132.       /* accept */
  133.       gtk_drag_finish(context, TRUE, FALSE, time);
  134.   
  135. !     /* Real files (i.e. not http and not ftp) */
  136.       if (url == FALSE)
  137.       {
  138.       if (nfiles == 1)
  139. --- 1415,1485 ----
  140.       /* guard against trash */
  141.       if (data->length <= 0
  142.           || data->format != 8
  143. !         || names[data->length] != '\0')
  144.       {
  145.       gtk_drag_finish(context, FALSE, FALSE, time);
  146.       return;
  147.       }
  148.   
  149. !     /* Count how many items there may be and separate them with a NUL.
  150. !      * Apparently the items are separated with \r\n.  This is not documented,
  151. !      * thus be careful not to go past the end.  Also allow separation with NUL
  152. !      * characters. */
  153. !     nfiles = 0;
  154. !     copy = alloc((unsigned)(data->length + 1));
  155. !     start = copy;
  156.       for (i = 0; i < data->length; ++i)
  157.       {
  158. !     if (names[i] == NUL || names[i] == '\n' || names[i] == '\r')
  159. !     {
  160. !         if (start > copy && start[-1] != NUL)
  161. !         {
  162. !         ++nfiles;
  163. !         *start++ = NUL;
  164. !         }
  165. !     }
  166. !     else if (names[i] == '%' && i + 2 < data->length
  167. !                           && hexhex2nr(names + i + 1) > 0)
  168.       {
  169. !         *start++ = hexhex2nr(names + i + 1);
  170. !         i += 2;
  171.       }
  172. +     else
  173. +         *start++ = names[i];
  174. +     }
  175. +     if (start > copy && start[-1] != NUL)
  176. +     {
  177. +     *start = NUL;   /* last item didn't have \r or \n */
  178. +     ++nfiles;
  179.       }
  180.   
  181. !     fnames = (char_u **)alloc((unsigned)(nfiles * sizeof(char_u *)));
  182.   
  183. +     url = FALSE;    /* Set when a non-file URL was found. */
  184.       start = copy;
  185. !     for (n = 0; n < nfiles; ++n)
  186.       {
  187. !     if (STRNCMP(start, "file://localhost", 16) == 0)
  188. !         start += 16;
  189.       else
  190.       {
  191. !         if (STRNCMP(start, "file:", 5) != 0)
  192. !         url = TRUE;
  193. !         else
  194.           {
  195.           start += 5;
  196.           while (start[0] == '/' && start[1] == '/')
  197.               ++start;
  198.           }
  199.       }
  200. !     fnames[n] = vim_strsave(start);
  201. !     start += STRLEN(start) + 1;
  202.       }
  203.   
  204.       /* accept */
  205.       gtk_drag_finish(context, TRUE, FALSE, time);
  206.   
  207. !     /* Special handling when all items are real files. */
  208.       if (url == FALSE)
  209.       {
  210.       if (nfiles == 1)
  211. ***************
  212. *** 1499,1505 ****
  213.           /* Handle dropping a directory on Vim. */
  214.           if (mch_chdir((char *)fnames[0]) == 0)
  215.           {
  216. !             free(fnames[0]);
  217.               fnames[0] = NULL;
  218.               redo_dirs = TRUE;
  219.           }
  220. --- 1489,1495 ----
  221.           /* Handle dropping a directory on Vim. */
  222.           if (mch_chdir((char *)fnames[0]) == 0)
  223.           {
  224. !             vim_free(fnames[0]);
  225.               fnames[0] = NULL;
  226.               redo_dirs = TRUE;
  227.           }
  228. ***************
  229. *** 1543,1548 ****
  230. --- 1533,1539 ----
  231.               }
  232.       }
  233.       }
  234. +     vim_free(copy);
  235.   
  236.       /* Handle the drop, :edit or :split to get to the file */
  237.       handle_drop(nfiles, fnames, current_modifiers & GDK_CONTROL_MASK);
  238. ***************
  239. *** 1552,1560 ****
  240.   
  241.       /* Update the screen display */
  242.       update_screen(NOT_VALID);
  243. ! #ifdef FEAT_MENU
  244.       gui_update_menus(0);
  245. ! #endif
  246.       setcursor();
  247.       out_flush();
  248.       gui_update_cursor(FALSE, FALSE);
  249. --- 1543,1551 ----
  250.   
  251.       /* Update the screen display */
  252.       update_screen(NOT_VALID);
  253. ! # ifdef FEAT_MENU
  254.       gui_update_menus(0);
  255. ! # endif
  256.       setcursor();
  257.       out_flush();
  258.       gui_update_cursor(FALSE, FALSE);
  259. *** ../vim61.144/src/version.c    Sat Aug  3 14:05:15 2002
  260. --- src/version.c    Sat Aug  3 14:09:44 2002
  261. ***************
  262. *** 608,609 ****
  263. --- 608,611 ----
  264.   {   /* Add new patch number below this line */
  265. + /**/
  266. +     145,
  267.   /**/
  268.  
  269. -- 
  270. From "know your smileys":
  271.  :'-D    Laughing so much that they're crying
  272.  
  273.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  274. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  275. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  276.  \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
  277.