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 / unreleased / patches / old / 5.4o.9 < prev    next >
Encoding:
Internet Message Format  |  1999-07-15  |  4.0 KB

  1. To: vim-dev@vim.org
  2. Subject: patch 5.4o.9
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. This patch only applies to the DOS and Windows versions.  And then only to the
  8. installation program.
  9.  
  10.  
  11. Patch 5.4o.9
  12. Problem:    The DOS install.exe program used the "move" program.  That doesn't
  13.         work on Windows NT, where "move" is internal to cmd.exe.
  14. Solution:   Don't use an external program for moving the executables.  Use C
  15.         functions to copy the file and delete the original.
  16. Files:        src/dosinst.c
  17.  
  18.  
  19. *** ../vim-5.4o/src/dosinst.c    Sun Jul 11 20:10:44 1999
  20. --- src/dosinst.c    Fri Jul 16 16:06:19 1999
  21. ***************
  22. *** 12,23 ****
  23. --- 12,25 ----
  24.    * Compile with Makefile.bcc or Makefile.djg.
  25.    */
  26.   
  27. + #include <io.h>
  28.   #include <stdio.h>
  29.   #include <stdlib.h>
  30.   #include <ctype.h>
  31.   #include <string.h>
  32.   #include <direct.h>
  33.   #include <sys/stat.h>
  34. + #include <fcntl.h>
  35.   #ifdef WIN32
  36.   # include <windows.h>
  37.   #else
  38. ***************
  39. *** 32,38 ****
  40.   #define NUL 0
  41.   
  42.   /*
  43. !  * Return TRUE if the the user types a 'y' or 'Y', FALSE otherwise.
  44.    */
  45.       int
  46.   confirm(void)
  47. --- 34,50 ----
  48.   #define NUL 0
  49.   
  50.   /*
  51. !  * EMX doesn't have a global way of making open() use binary I/O.
  52. !  * Use O_BINARY for all open() calls.
  53. !  */
  54. ! #if defined(__EMX__) || defined(__CYGWIN32__)
  55. ! # define O_EXTRA    O_BINARY
  56. ! #else
  57. ! # define O_EXTRA    0
  58. ! #endif
  59. ! /*
  60. !  * Return TRUE if the user types a 'y' or 'Y', FALSE otherwise.
  61.    */
  62.       int
  63.   confirm(void)
  64. ***************
  65. *** 291,313 ****
  66.   #endif
  67.   
  68.   /*
  69. !  * Move a file to another directory.
  70.    */
  71.       void
  72.   move_file(char *fname, char *dir)
  73.   {
  74.       struct stat    st;
  75. !     char    cmd[1000];
  76.   
  77.       /* if the file doesn't exist, silently skip it */
  78.       if (stat(fname, &st) < 0)
  79.       return;
  80.   
  81. !     sprintf(cmd, "move %s %s", fname, dir);
  82. !     system(cmd);
  83.   
  84. !     if (stat(fname, &st) >= 0)
  85.       printf("ERROR: Moving \"%s\" to \"%s\" failed\n", fname, dir);
  86.   }
  87.   
  88.   /*
  89. --- 303,366 ----
  90.   #endif
  91.   
  92.   /*
  93. !  * Move file "fname" to directory "dir".
  94. !  * We actually copy the file and then delete the original, to avoid depending
  95. !  * on an external program.
  96.    */
  97.       void
  98.   move_file(char *fname, char *dir)
  99.   {
  100.       struct stat    st;
  101. !     char    new_name[256];
  102. ! #define COPYBUFSIZE 4096
  103. !     char    *buf;
  104. !     long    len;
  105. !     int        fdr, fdw;
  106. ! #ifndef __MINGW32__
  107. !     extern int    _fmode;
  108. ! #endif
  109.   
  110.       /* if the file doesn't exist, silently skip it */
  111.       if (stat(fname, &st) < 0)
  112.       return;
  113.   
  114. !     buf = malloc(COPYBUFSIZE);
  115. !     if (buf == NULL)
  116. !     {
  117. !     printf("ERROR: Out of memory!\n");
  118. !     return;
  119. !     }
  120. !     _fmode = O_BINARY;        /* Use binary I/O */
  121. !     /* make the destination file name: "dir\fname" */
  122. !     strcpy(new_name, dir);
  123. !     if (dir[strlen(dir) - 1] != '\\' && dir[strlen(dir) - 1] != '/')
  124. !     strcat(new_name, "\\");
  125. !     strcat(new_name, fname);
  126.   
  127. !     fdr = open(fname, O_RDONLY | O_EXTRA, 0);
  128. !     if (fdr >= 0)
  129. !     {
  130. !     fdw = open(new_name, O_WRONLY|O_CREAT|O_TRUNC|O_EXTRA, 0777);
  131. !     if (fdw >= 0)
  132. !     {
  133. !         /* copy the file. */
  134. !         while ((len = read(fdr, buf, COPYBUFSIZE)) > 0)
  135. !         if (write(fdw, buf, len) != len)
  136. !             break;
  137. !         close(fdw);
  138. !     }
  139. !     close(fdr);
  140. !     }
  141. !     if (fdr < 0 || fdw < 0 || len > 0 || len < 0)
  142.       printf("ERROR: Moving \"%s\" to \"%s\" failed\n", fname, dir);
  143. +     else
  144. +     {
  145. +     printf("%s moved to %s\n", fname, new_name);
  146. +     unlink(fname);
  147. +     }
  148. +     free(buf);
  149.   }
  150.   
  151.   /*
  152. ***************
  153. *** 422,427 ****
  154. --- 475,488 ----
  155.       int        i;
  156.       char    *p;
  157.       int        vimdirend;
  158. + #ifdef DJGPP
  159. +     /*
  160. +      * Use Long File Names by default, if $LFN not set.
  161. +      */
  162. +     if (getenv("LFN") == NULL)
  163. +     putenv("LFN=y");
  164. + #endif
  165.   
  166.       printf("This program sets up the installation of Vim %s\n\n",
  167.           VIM_VERSION_MEDIUM);
  168.  
  169. --
  170. hundred-and-one symptoms of being an internet addict:
  171. 127. You bring your laptop and cellular phone to church.
  172.  
  173. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\--
  174.   \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /
  175.