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.0.163 < prev    next >
Encoding:
Internet Message Format  |  2002-02-02  |  13.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.163
  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.0.163
  11. Problem:    When using a GUI dialog, a file name is sometimes used like it was
  12.         a directory.
  13. Solution:   Separate path and file name properly.
  14.         For GTK, Motif and Athena concatenate directory and file name for
  15.         the default selection.
  16. Files:        src/diff.c, src/ex_cmds.c, src/ex_cmds2.c, src/ex_docmd.c,
  17.         src/gui_athena.c, src/gui_gtk.c, src/gui_motif.c, src/message.c
  18.  
  19.  
  20. *** ../vim60.162/src/diff.c    Wed Sep 19 18:36:35 2001
  21. --- src/diff.c    Sun Feb  3 13:43:37 2002
  22. ***************
  23. *** 744,751 ****
  24.   #ifdef FEAT_BROWSE
  25.       if (cmdmod.browse)
  26.       {
  27. !     browseFile = do_browse(TRUE, (char_u *)_("Patch file"),
  28. !         NULL, NULL, eap->arg, BROWSE_FILTER_ALL_FILES, curbuf);
  29.       if (browseFile == NULL)
  30.           return;        /* operation cancelled */
  31.       eap->arg = browseFile;
  32. --- 744,751 ----
  33.   #ifdef FEAT_BROWSE
  34.       if (cmdmod.browse)
  35.       {
  36. !     browseFile = do_browse(FALSE, (char_u *)_("Patch file"),
  37. !              eap->arg, NULL, NULL, BROWSE_FILTER_ALL_FILES, NULL);
  38.       if (browseFile == NULL)
  39.           return;        /* operation cancelled */
  40.       eap->arg = browseFile;
  41. *** ../vim60.162/src/ex_cmds.c    Sun Feb  3 12:33:39 2002
  42. --- src/ex_cmds.c    Sun Feb  3 13:29:29 2002
  43. ***************
  44. *** 2050,2057 ****
  45.   #ifdef FEAT_BROWSE
  46.       if (cmdmod.browse)
  47.       {
  48. !     browse_file = do_browse(TRUE, (char_u *)_("Save As"), NULL,
  49. !                           NULL, ffname, NULL, curbuf);
  50.       if (browse_file == NULL)
  51.           goto theend;
  52.       ffname = browse_file;
  53. --- 2050,2057 ----
  54.   #ifdef FEAT_BROWSE
  55.       if (cmdmod.browse)
  56.       {
  57. !     browse_file = do_browse(TRUE, (char_u *)_("Save As"), ffname,
  58. !                             NULL, NULL, NULL, curbuf);
  59.       if (browse_file == NULL)
  60.           goto theend;
  61.       ffname = browse_file;
  62. ***************
  63. *** 2308,2314 ****
  64.           /* ":browse wall": ask for file name if there isn't one */
  65.           if (buf->b_ffname == NULL && cmdmod.browse)
  66.           buf->b_ffname = do_browse(TRUE, (char_u *)_("Save As"), NULL,
  67. !                            NULL, (char_u *)"", NULL, buf);
  68.   #endif
  69.           if (buf->b_ffname == NULL)
  70.           {
  71. --- 2308,2314 ----
  72.           /* ":browse wall": ask for file name if there isn't one */
  73.           if (buf->b_ffname == NULL && cmdmod.browse)
  74.           buf->b_ffname = do_browse(TRUE, (char_u *)_("Save As"), NULL,
  75. !                                NULL, NULL, NULL, buf);
  76.   #endif
  77.           if (buf->b_ffname == NULL)
  78.           {
  79. ***************
  80. *** 2535,2542 ****
  81.   #ifdef FEAT_BROWSE
  82.       if (cmdmod.browse)
  83.       {
  84. !         browse_file = do_browse(FALSE, (char_u *)_("Edit File"), NULL,
  85. !                           NULL, ffname, NULL, curbuf);
  86.           if (browse_file == NULL)
  87.           goto theend;
  88.           ffname = browse_file;
  89. --- 2535,2542 ----
  90.   #ifdef FEAT_BROWSE
  91.       if (cmdmod.browse)
  92.       {
  93. !         browse_file = do_browse(FALSE, (char_u *)_("Edit File"), ffname,
  94. !                             NULL, NULL, NULL, curbuf);
  95.           if (browse_file == NULL)
  96.           goto theend;
  97.           ffname = browse_file;
  98. *** ../vim60.162/src/ex_cmds2.c    Wed Oct 31 10:12:03 2001
  99. --- src/ex_cmds2.c    Sun Feb  3 13:44:58 2002
  100. ***************
  101. *** 1711,1718 ****
  102.       {
  103.       char_u *fname = NULL;
  104.   
  105. !     fname = do_browse(FALSE, (char_u *)_("Run Macro"),
  106. !         NULL, NULL, eap->arg, BROWSE_FILTER_MACROS, curbuf);
  107.       if (fname != NULL)
  108.       {
  109.           cmd_source(fname, eap);
  110. --- 1711,1718 ----
  111.       {
  112.       char_u *fname = NULL;
  113.   
  114. !     fname = do_browse(FALSE, (char_u *)_("Run Macro"), eap->arg,
  115. !                       NULL, NULL, BROWSE_FILTER_MACROS, NULL);
  116.       if (fname != NULL)
  117.       {
  118.           cmd_source(fname, eap);
  119. *** ../vim60.162/src/ex_docmd.c    Wed Jan 30 16:52:44 2002
  120. --- src/ex_docmd.c    Sun Feb  3 13:47:11 2002
  121. ***************
  122. *** 5554,5560 ****
  123.           && eap->cmdidx != CMD_new)
  124.       {
  125.       fname = do_browse(FALSE, (char_u *)_("Edit File in new window"),
  126. !                       NULL, NULL, eap->arg, NULL, curbuf);
  127.       if (fname == NULL)
  128.           goto theend;
  129.       eap->arg = fname;
  130. --- 5554,5560 ----
  131.           && eap->cmdidx != CMD_new)
  132.       {
  133.       fname = do_browse(FALSE, (char_u *)_("Edit File in new window"),
  134. !                       eap->arg, NULL, NULL, NULL, curbuf);
  135.       if (fname == NULL)
  136.           goto theend;
  137.       eap->arg = fname;
  138. ***************
  139. *** 5923,5930 ****
  140.       {
  141.           char_u *browseFile;
  142.   
  143. !         browseFile = do_browse(FALSE, (char_u *)_("Append File"), NULL,
  144. !                         NULL, eap->arg, NULL, curbuf);
  145.           if (browseFile != NULL)
  146.           {
  147.           i = readfile(browseFile, NULL,
  148. --- 5923,5930 ----
  149.       {
  150.           char_u *browseFile;
  151.   
  152. !         browseFile = do_browse(FALSE, (char_u *)_("Append File"), eap->arg,
  153. !                             NULL, NULL, NULL, curbuf);
  154.           if (browseFile != NULL)
  155.           {
  156.           i = readfile(browseFile, NULL,
  157. ***************
  158. *** 6449,6455 ****
  159.           if (cmdmod.browse)
  160.           {
  161.           browseFile = do_browse(TRUE, (char_u *)_("Save Redirection"),
  162. !                NULL, NULL, eap->arg, BROWSE_FILTER_ALL_FILES, curbuf);
  163.           if (browseFile == NULL)
  164.               return;        /* operation cancelled */
  165.           eap->arg = browseFile;
  166. --- 6449,6455 ----
  167.           if (cmdmod.browse)
  168.           {
  169.           browseFile = do_browse(TRUE, (char_u *)_("Save Redirection"),
  170. !                eap->arg, NULL, NULL, BROWSE_FILTER_ALL_FILES, curbuf);
  171.           if (browseFile == NULL)
  172.               return;        /* operation cancelled */
  173.           eap->arg = browseFile;
  174. ***************
  175. *** 6601,6607 ****
  176.           eap->cmdidx == CMD_mksession ? (char_u *)_("Save Session") :
  177.   # endif
  178.           (char_u *)_("Save Setup"),
  179. !         NULL, (char_u *)"vim", fname, BROWSE_FILTER_MACROS, curbuf);
  180.       if (browseFile == NULL)
  181.           goto theend;
  182.       fname = browseFile;
  183. --- 6601,6607 ----
  184.           eap->cmdidx == CMD_mksession ? (char_u *)_("Save Session") :
  185.   # endif
  186.           (char_u *)_("Save Setup"),
  187. !         fname, (char_u *)"vim", NULL, BROWSE_FILTER_MACROS, NULL);
  188.       if (browseFile == NULL)
  189.           goto theend;
  190.       fname = browseFile;
  191. *** ../vim60.162/src/gui_athena.c    Wed Dec 12 20:36:34 2001
  192. --- src/gui_athena.c    Sun Feb  3 15:24:05 2002
  193. ***************
  194. *** 1836,1841 ****
  195. --- 1836,1856 ----
  196.       char_u    *filter;    /* not used (file name filter) */
  197.   {
  198.       Position x, y;
  199. +     char_u    dirbuf[MAXPATHL];
  200. +     /* Concatenate "initdir" and "dflt". */
  201. +     if (initdir == NULL || *initdir == NUL)
  202. +     mch_dirname(dirbuf, MAXPATHL);
  203. +     else if (STRLEN(initdir) + 2 < MAXPATHL)
  204. +     STRCPY(dirbuf, initdir);
  205. +     else
  206. +     dirbuf[0] = NUL;
  207. +     if (dflt != NULL && *dflt != NUL
  208. +                   && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
  209. +     {
  210. +     add_pathsep(dirbuf);
  211. +     STRCAT(dirbuf, dflt);
  212. +     }
  213.   
  214.       /* Position the file selector just below the menubar */
  215.       XtTranslateCoords(vimShell, (Position)0, (Position)
  216. ***************
  217. *** 1845,1851 ****
  218.           0
  219.   #endif
  220.           , &x, &y);
  221. !     return (char_u *)vim_SelFile(vimShell, (char *)title, (char *)initdir,
  222.             NULL, (int)x, (int)y, gui.menu_fg_pixel, gui.menu_bg_pixel);
  223.   }
  224.   #endif
  225. --- 1860,1866 ----
  226.           0
  227.   #endif
  228.           , &x, &y);
  229. !     return (char_u *)vim_SelFile(vimShell, (char *)title, (char *)dirbuf,
  230.             NULL, (int)x, (int)y, gui.menu_fg_pixel, gui.menu_bg_pixel);
  231.   }
  232.   #endif
  233. *** ../vim60.162/src/gui_gtk.c    Fri Dec 14 20:19:45 2001
  234. --- src/gui_gtk.c    Sun Feb  3 15:25:14 2002
  235. ***************
  236. *** 875,890 ****
  237.       /* if our pointer is currently hidden, then we should show it. */
  238.       gui_mch_mousehide(FALSE);
  239.   
  240. !     if (dflt == NULL)
  241. !     dflt = (char_u *)"";
  242.       if (initdir == NULL || *initdir == NUL)
  243. -     {
  244.       mch_dirname(dirbuf, MAXPATHL);
  245. !     strcat((char *)dirbuf, "/");    /* make sure this is a directory */
  246. !     initdir = dirbuf;
  247. !     }
  248.       gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg),
  249. !                               (const gchar *)initdir);
  250.   
  251.       gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin),
  252.                          GTK_WIDGET(gui.filedlg), VW_POS_MOUSE);
  253. --- 875,895 ----
  254.       /* if our pointer is currently hidden, then we should show it. */
  255.       gui_mch_mousehide(FALSE);
  256.   
  257. !     /* Concatenate "initdir" and "dflt". */
  258.       if (initdir == NULL || *initdir == NUL)
  259.       mch_dirname(dirbuf, MAXPATHL);
  260. !     else if (STRLEN(initdir) + 2 < MAXPATHL)
  261. !     STRCPY(dirbuf, initdir);
  262. !     else
  263. !     dirbuf[0] = NUL;
  264. !     /* Always need a trailing slash for a directory. */
  265. !     add_pathsep(dirbuf);
  266. !     if (dflt != NULL && *dflt != NUL
  267. !                   && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
  268. !     STRCAT(dirbuf, dflt);
  269.       gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg),
  270. !                               (const gchar *)dirbuf);
  271.   
  272.       gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin),
  273.                          GTK_WIDGET(gui.filedlg), VW_POS_MOUSE);
  274. ***************
  275. *** 900,906 ****
  276.   
  277.   #endif    /* FEAT_BROWSE */
  278.   
  279. ! #ifdef FEAT_GUI_DIALOG
  280.   
  281.   static char_u *dialog_textfield = NULL;
  282.   static GtkWidget *dialog_textentry;
  283. --- 905,911 ----
  284.   
  285.   #endif    /* FEAT_BROWSE */
  286.   
  287. ! #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
  288.   
  289.   static char_u *dialog_textfield = NULL;
  290.   static GtkWidget *dialog_textentry;
  291. *** ../vim60.162/src/gui_motif.c    Wed Sep 26 16:47:48 2001
  292. --- src/gui_motif.c    Sun Feb  3 14:23:53 2002
  293. ***************
  294. *** 1531,1537 ****
  295.   
  296.       str = XmStringCreate(new_label, STRING_TAG);
  297.   
  298. !     if (str) {
  299.       XtVaSetValues(w, XmNlabelString, str, NULL);
  300.       XmStringFree(str);
  301.       }
  302. --- 1531,1538 ----
  303.   
  304.       str = XmStringCreate(new_label, STRING_TAG);
  305.   
  306. !     if (str)
  307. !     {
  308.       XtVaSetValues(w, XmNlabelString, str, NULL);
  309.       XmStringFree(str);
  310.       }
  311. ***************
  312. *** 1552,1568 ****
  313.       char_u    *filter;    /* file name filter */
  314.   {
  315.       char_u    dirbuf[MAXPATHL];
  316.       char_u    *pattern;
  317.       char_u    *tofree = NULL;
  318.   
  319.       dialog_wgt = XmCreateFileSelectionDialog(vimShell, (char *)title, NULL, 0);
  320.   
  321. -     if (dflt == NULL)
  322. -     dflt = (char_u *)"";
  323.       if (initdir == NULL || *initdir == NUL)
  324.       {
  325.       mch_dirname(dirbuf, MAXPATHL);
  326.       initdir = dirbuf;
  327.       }
  328.   
  329.       /* Can only use one pattern for a file name.  Get the first pattern out of
  330. --- 1553,1580 ----
  331.       char_u    *filter;    /* file name filter */
  332.   {
  333.       char_u    dirbuf[MAXPATHL];
  334. +     char_u    dfltbuf[MAXPATHL];
  335.       char_u    *pattern;
  336.       char_u    *tofree = NULL;
  337.   
  338.       dialog_wgt = XmCreateFileSelectionDialog(vimShell, (char *)title, NULL, 0);
  339.   
  340.       if (initdir == NULL || *initdir == NUL)
  341.       {
  342.       mch_dirname(dirbuf, MAXPATHL);
  343.       initdir = dirbuf;
  344. +     }
  345. +     if (dflt == NULL)
  346. +     dflt = (char_u *)"";
  347. +     else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL)
  348. +     {
  349. +     /* The default selection should be the full path, "dflt" is only the
  350. +      * file name. */
  351. +     STRCPY(dfltbuf, initdir);
  352. +     add_pathsep(dfltbuf);
  353. +     STRCAT(dfltbuf, dflt);
  354. +     dflt = dfltbuf;
  355.       }
  356.   
  357.       /* Can only use one pattern for a file name.  Get the first pattern out of
  358. *** ../vim60.162/src/message.c    Fri Sep 28 22:19:57 2001
  359. --- src/message.c    Sun Feb  3 13:42:00 2002
  360. ***************
  361. *** 2475,2483 ****
  362.   do_browse(saving, title, dflt, ext, initdir, filter, buf)
  363.       int        saving;        /* write action */
  364.       char_u    *title;        /* title for the window */
  365. !     char_u    *dflt;        /* default file name */
  366.       char_u    *ext;        /* extension added */
  367. !     char_u    *initdir;    /* initial directory, NULL for current dir */
  368.       char_u    *filter;    /* file name filter */
  369.       buf_T    *buf;        /* buffer to read/write for */
  370.   {
  371. --- 2475,2484 ----
  372.   do_browse(saving, title, dflt, ext, initdir, filter, buf)
  373.       int        saving;        /* write action */
  374.       char_u    *title;        /* title for the window */
  375. !     char_u    *dflt;        /* default file name (may include directory) */
  376.       char_u    *ext;        /* extension added */
  377. !     char_u    *initdir;    /* initial directory, NULL for current dir or
  378. !                    when using path from "dflt" */
  379.       char_u    *filter;    /* file name filter */
  380.       buf_T    *buf;        /* buffer to read/write for */
  381.   {
  382. ***************
  383. *** 2498,2505 ****
  384.           title = (char_u *)_("Open File dialog");
  385.       }
  386.   
  387. !     /* When no directory specified, use default dir, buffer dir, last dir
  388. !      * or current dir */
  389.       if (initdir == NULL || *initdir == NUL)
  390.       {
  391.       /* When 'browsedir' is a directory, use it */
  392. --- 2499,2525 ----
  393.           title = (char_u *)_("Open File dialog");
  394.       }
  395.   
  396. !     /* When no directory specified, use default file name, default dir, buffer
  397. !      * dir, last dir or current dir */
  398. !     if ((initdir == NULL || *initdir == NUL) && dflt != NULL && *dflt != NUL)
  399. !     {
  400. !     if (mch_isdir(dflt))        /* default file name is a directory */
  401. !     {
  402. !         initdir = dflt;
  403. !         dflt = NULL;
  404. !     }
  405. !     else if (gettail(dflt) != dflt)    /* default file name includes a path */
  406. !     {
  407. !         tofree = vim_strsave(dflt);
  408. !         if (tofree != NULL)
  409. !         {
  410. !         initdir = tofree;
  411. !         *gettail(initdir) = NUL;
  412. !         dflt = gettail(dflt);
  413. !         }
  414. !     }
  415. !     }
  416.       if (initdir == NULL || *initdir == NUL)
  417.       {
  418.       /* When 'browsedir' is a directory, use it */
  419. ***************
  420. *** 2509,2515 ****
  421.       else if ((saving || *p_bsdir == 'b')
  422.           && buf != NULL && buf->b_ffname != NULL)
  423.       {
  424. !         dflt = gettail(curbuf->b_ffname);
  425.           tofree = vim_strsave(curbuf->b_ffname);
  426.           if (tofree != NULL)
  427.           {
  428. --- 2529,2536 ----
  429.       else if ((saving || *p_bsdir == 'b')
  430.           && buf != NULL && buf->b_ffname != NULL)
  431.       {
  432. !         if (dflt == NULL || *dflt == NUL)
  433. !         dflt = gettail(curbuf->b_ffname);
  434.           tofree = vim_strsave(curbuf->b_ffname);
  435.           if (tofree != NULL)
  436.           {
  437. ***************
  438. *** 2560,2566 ****
  439.           *gettail(last_dir) = NUL;
  440.           if (*last_dir == NUL)
  441.           {
  442. !         /* filename only returned, must be in current dir*/
  443.           vim_free(last_dir);
  444.           last_dir = alloc(MAXPATHL);
  445.           if (last_dir != NULL)
  446. --- 2581,2587 ----
  447.           *gettail(last_dir) = NUL;
  448.           if (*last_dir == NUL)
  449.           {
  450. !         /* filename only returned, must be in current dir */
  451.           vim_free(last_dir);
  452.           last_dir = alloc(MAXPATHL);
  453.           if (last_dir != NULL)
  454. *** ../vim60.162/src/version.c    Sun Feb  3 12:42:13 2002
  455. --- src/version.c    Sun Feb  3 15:16:22 2002
  456. ***************
  457. *** 608,609 ****
  458. --- 608,611 ----
  459.   {   /* Add new patch number below this line */
  460. + /**/
  461. +     163,
  462.   /**/
  463.  
  464. -- 
  465. hundred-and-one symptoms of being an internet addict:
  466. 168. You have your own domain name.
  467.  
  468.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  469. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  470.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  471.