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 / old / 5.5.062 < prev    next >
Encoding:
Internet Message Format  |  1999-12-06  |  6.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.5.062 (extra)
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.5.062 (extra)
  8. Problem:    Win32 console: Temp files are created in the root of the current
  9.         drive, which may be read-only. (Peterson)
  10. Solution:   Use the same mechanism of the GUI version: Use $TMP, $TEMP or the
  11.         current directory.  Cleaned up vim_tempname() a bit.
  12. Files:        src/fileio.c, src/os_win32.h, runtime/doc/os_dos.txt
  13.  
  14.  
  15. *** ../vim-5.5.61/src/fileio.c    Sat Dec  4 13:53:42 1999
  16. --- src/fileio.c    Tue Dec  7 15:47:47 1999
  17. ***************
  18. *** 20,25 ****
  19. --- 20,29 ----
  20.   
  21.   #include "vim.h"
  22.   
  23. + #ifdef WIN32
  24. + # include <windows.h>    /* For DeleteFile(), GetTempPath(), etc. */
  25. + #endif
  26.   #ifdef HAVE_FCNTL_H
  27.   # include <fcntl.h>
  28.   #endif
  29. ***************
  30. *** 2982,2990 ****
  31.   vim_tempname(extra_char)
  32.       int        extra_char;        /* character to use in the name instead of '?' */
  33.   {
  34. ! #ifdef USE_GUI_WIN32
  35. ! # undef USE_TMPNAM
  36. ! # define TEMPNAMELEN 256
  37.       char    szTempFile[_MAX_PATH+1];
  38.       char    buf4[4];
  39.   #endif
  40. --- 2986,2992 ----
  41.   vim_tempname(extra_char)
  42.       int        extra_char;        /* character to use in the name instead of '?' */
  43.   {
  44. ! #ifdef WIN32
  45.       char    szTempFile[_MAX_PATH+1];
  46.       char    buf4[4];
  47.   #endif
  48. ***************
  49. *** 2993,3000 ****
  50.   #else
  51.       char_u    itmp[TEMPNAMELEN];
  52.   #endif
  53. ! #if defined(TEMPDIRNAMES) || (!defined(USE_GUI_WIN32) && !defined(USE_TMPNAM))
  54. !     char_u        *p;
  55.   #endif
  56.   
  57.   #ifdef TEMPDIRNAMES
  58. --- 2995,3002 ----
  59.   #else
  60.       char_u    itmp[TEMPNAMELEN];
  61.   #endif
  62. ! #if defined(TEMPDIRNAMES) || !defined(USE_TMPNAM)
  63. !     char_u    *p;
  64.   #endif
  65.   
  66.   #ifdef TEMPDIRNAMES
  67. ***************
  68. *** 3017,3023 ****
  69.           if (first_try)
  70.           first_dir = i;        /* start here next time */
  71.           first_try = FALSE;
  72. ! #ifdef __EMX__
  73.           /*
  74.            * if $TMP contains a forward slash (perhaps because we're using
  75.            * bash or tcsh, right Stefan?), don't add a backslash to the
  76. --- 3019,3025 ----
  77.           if (first_try)
  78.           first_dir = i;        /* start here next time */
  79.           first_try = FALSE;
  80. ! # ifdef __EMX__
  81.           /*
  82.            * if $TMP contains a forward slash (perhaps because we're using
  83.            * bash or tcsh, right Stefan?), don't add a backslash to the
  84. ***************
  85. *** 3028,3034 ****
  86.           if (vim_strchr(itmp, '/'))
  87.           STRCAT(itmp, "/");
  88.           else
  89. ! #endif
  90.           add_pathsep(itmp);
  91.           STRCAT(itmp, TEMPNAME);
  92.           if ((p = vim_strchr(itmp, '?')) != NULL)
  93. --- 3030,3036 ----
  94.           if (vim_strchr(itmp, '/'))
  95.           STRCAT(itmp, "/");
  96.           else
  97. ! # endif
  98.           add_pathsep(itmp);
  99.           STRCAT(itmp, TEMPNAME);
  100.           if ((p = vim_strchr(itmp, '?')) != NULL)
  101. ***************
  102. *** 3039,3056 ****
  103.       }
  104.       }
  105.       return NULL;
  106.   #else /* !TEMPDIRNAMES */
  107.   
  108. ! # ifdef USE_GUI_WIN32
  109.       STRCPY(itmp, "");
  110. !     GetTempPath(_MAX_PATH, szTempFile);
  111.       strcpy(buf4, "VIM");
  112.       buf4[2] = extra_char;   /* make it "VIa", "VIb", etc. */
  113.       if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0)
  114.   # else
  115.   #  ifdef USE_TMPNAM
  116.       /* tmpnam() will make its own name */
  117.       if (*tmpnam((char *)itmp) == NUL)
  118.   #  else
  119.   #   ifdef VMS_TEMPNAM
  120.       /* mktemp() is not working on VMS.  It seems to be
  121. --- 3041,3064 ----
  122.       }
  123.       }
  124.       return NULL;
  125.   #else /* !TEMPDIRNAMES */
  126.   
  127. ! # ifdef WIN32
  128.       STRCPY(itmp, "");
  129. !     if (GetTempPath(_MAX_PATH, szTempFile) == 0)
  130. !     szTempFile[0] = NUL;    /* GetTempPath() failed, use current dir */
  131.       strcpy(buf4, "VIM");
  132.       buf4[2] = extra_char;   /* make it "VIa", "VIb", etc. */
  133.       if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0)
  134. +     return NULL;
  135. +     /* GetTempFileName() will create the file, we don't want that */
  136. +     (void)DeleteFile(itmp);
  137.   # else
  138.   #  ifdef USE_TMPNAM
  139.       /* tmpnam() will make its own name */
  140.       if (*tmpnam((char *)itmp) == NUL)
  141. +     return NULL;
  142.   #  else
  143.   #   ifdef VMS_TEMPNAM
  144.       /* mktemp() is not working on VMS.  It seems to be
  145. ***************
  146. *** 3067,3089 ****
  147.       free(p);
  148.       }
  149.       else
  150.   #   else
  151.       STRCPY(itmp, TEMPNAME);
  152.       if ((p = vim_strchr(itmp, '?')) != NULL)
  153.       *p = extra_char;
  154.       if (mktemp((char *)itmp) == NULL)
  155.   #   endif
  156.   #  endif
  157.   # endif
  158. -     return NULL;
  159.   
  160. - # ifdef USE_GUI_WIN32
  161. -     /* GetTempFileName() will create the file, we don't want that */
  162. -     (void)DeleteFile(itmp);
  163. - # endif
  164.   # ifdef WIN32
  165.       {
  166. -     char_u    *p;
  167.       char_u    *retval;
  168.   
  169.       /* Backslashes in a temp file name cause problems when filtering with
  170. --- 3075,3093 ----
  171.       free(p);
  172.       }
  173.       else
  174. +     return NULL;
  175.   #   else
  176.       STRCPY(itmp, TEMPNAME);
  177.       if ((p = vim_strchr(itmp, '?')) != NULL)
  178.       *p = extra_char;
  179.       if (mktemp((char *)itmp) == NULL)
  180. +     return NULL;
  181.   #   endif
  182.   #  endif
  183.   # endif
  184.   
  185.   # ifdef WIN32
  186.       {
  187.       char_u    *retval;
  188.   
  189.       /* Backslashes in a temp file name cause problems when filtering with
  190. *** ../vim-5.5.61/src/os_win32.h    Wed Sep 22 10:06:28 1999
  191. --- src/os_win32.h    Tue Dec  7 15:07:26 1999
  192. ***************
  193. *** 25,31 ****
  194.   #endif
  195.   #define HAVE_STRFTIME        /* guessed */
  196.   #define HAVE_MEMSET
  197. - #define USE_TMPNAM        /* use tmpnam() instead of mktemp() */
  198.   #define HAVE_LOCALE_H
  199.   #define HAVE_FCNTL_H
  200.   #define HAVE_QSORT
  201. --- 25,30 ----
  202. ***************
  203. *** 74,79 ****
  204. --- 73,80 ----
  205.   #define MAXPATHL    1024
  206.   
  207.   #define BASENAMELEN    (_MAX_PATH - 5)    /* length of base of file name */
  208. + #define TEMPNAMELEN    _MAX_PATH    /* length of temp file name path */
  209.   
  210.   #ifndef MAXMEM
  211.   # define MAXMEM        (2*1024)    /* use up to 2 Mbyte for a buffer */
  212. *** ../vim-5.5.61/runtime/doc/os_dos.txt    Wed Sep 22 10:06:42 1999
  213. --- runtime/doc/os_dos.txt    Tue Dec  7 14:43:27 1999
  214. ***************
  215. *** 1,4 ****
  216. ! *os_dos.txt*    For Vim version 5.5.  Last change: 1999 Sep 14
  217.   
  218.   
  219.             VIM REFERENCE MANUAL    by Bram Moolenaar
  220. --- 1,4 ----
  221. ! *os_dos.txt*    For Vim version 5.5.  Last change: 1999 Dec 07
  222.   
  223.   
  224.             VIM REFERENCE MANUAL    by Bram Moolenaar
  225. ***************
  226. *** 238,249 ****
  227. --- 238,258 ----
  228.   ==============================================================================
  229.   8. Temp files                        *dos-temp-files*
  230.   
  231. + Only for the 16 bit and 32 bit DOS version:
  232.   Vim puts temporary files (for filtering) in the first of these directories
  233.   that exists and in which Vim can create a file:
  234.       $TMP
  235.       $TEMP
  236.       C:\TMP
  237.       C:\TEMP
  238. +     current directory
  239. + For the Win32 version (both console and GUI):
  240. + Vim uses standard Windows functions to obtain a temporary file name (for
  241. + filtering).  The first of these directories that exists and in which Vim can
  242. + create a file is used:
  243. +     $TMP
  244. +     $TEMP
  245.       current directory
  246.   
  247.   ==============================================================================
  248. *** ../vim-5.5.61/src/version.c    Tue Dec  7 12:51:33 1999
  249. --- src/version.c    Tue Dec  7 15:11:33 1999
  250. ***************
  251. *** 420,420 ****
  252. --- 420,421 ----
  253.   {   /* Add new patch number below this line */
  254. +     62,
  255.  
  256. -- 
  257. The software said it requires Windows 95 or better, so I installed Linux.
  258.  
  259. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\--
  260.   \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /
  261.