Loading ...
Sorry, an error occurred while loading the content.

Re: g?vim.bat quietly lose arguments

Expand Messages
  • Walter Briscoe
    In article of Wed, 31 Jan 2001 15:34:23 in !vim-dev, J. David Boyd writes ... I have
    Message 1 of 5 , Feb 1, 2001
    • 0 Attachment
      In article <001b01c08bc5$32e10600$3800a8c0@...> of Wed, 31
      Jan 2001 15:34:23 in !vim-dev, J. David Boyd <dave@...> writes
      >
      >----- Original Message ----- >
      >> But it should work on MS-DOS too. That's why a batch script is used.
      >>
      >
      >MS-DOS only supports 9 batch variables directly. Then you have to start
      >using the SHIFT command, like in the script.
      >
      >Dave
      >

      I have tested the file from which the enclosed diff was made
      *** dosinst.!c Sat Jan 06 17:41:52 2001
      --- dosinst.c Thu Feb 01 16:39:58 2001
      ***************
      *** 559,564 ****
      --- 559,624 ----
      }

      /*
      + * On input **destination is the path of an executable.
      + * If that executable is in the current directory, look for another one.
      + * *destination is set to NULL or the location of that file.
      + */
      +
      + static void
      + findoldfile(char **destination)
      + {
      + char *exename;
      + char *bp = *destination;
      + size_t indir_l = strlen(installdir);
      + char *cp = bp + indir_l;
      + char *tmpname;
      + char *farname;
      +
      + /*
      + * No action needed if exe not found or not in this directory.
      + */
      + if (bp == NULL
      + || strnicmp(bp, installdir, indir_l) != 0
      + || strchr("/\\", *cp++) == NULL
      + || strchr(cp, '\\') != NULL
      + || strchr(cp, '/') != NULL)
      + return;
      +
      + exename = alloc(strlen(cp)+1);
      + strcpy(exename, cp);
      + tmpname = alloc(strlen(cp)+sizeof(".tmp"));
      + strcpy(tmpname, cp), strcat(tmpname, ".tmp");
      +
      + if (access(tmpname, 0) == 0)
      + {
      + printf("\nERROR: %s and %s clash. remove/move so only %s exists\n",
      + tmpname, exename, exename);
      + exit(1);
      + }
      +
      + if (rename(exename, tmpname) != 0)
      + {
      + printf("\nERROR: failed to rename %s to %s: %s\n",
      + exename, tmpname, strerror(errno));
      + exit(1);
      + }
      +
      + farname = searchpath_save(exename);
      +
      + if (rename(tmpname, exename) != 0)
      + {
      + printf("\nERROR: failed to rename %s back to %s: %s\n",
      + tmpname, exename, strerror(errno));
      + exit(1);
      + }
      +
      + free(*destination);
      + free(exename);
      + free(tmpname);
      + *destination = farname;
      + }
      +
      + /*
      * Find out information about the system.
      */
      static void
      ***************
      *** 605,610 ****
      --- 665,679 ----
      oldvimexe = searchpath_save("vim.exe");
      oldgvimexe = searchpath_save("gvim.exe");
      mch_chdir(installdir);
      +
      + /*
      + * The technique used above to set oldvimexe and oldgvimexe
      + * gives a spurious result for Windows 2000 Professional.
      + * w.briscoe@... 2001-01-20
      + */
      + findoldfile(&oldvimexe);
      + findoldfile(&oldgvimexe);
      +
      if (oldvimexe != NULL || oldgvimexe != NULL)
      {
      printf("Warning: Found a Vim executable in your $PATH:\n");
      ***************
      *** 796,808 ****
      * contains a space. The quotes would be included in the value
      * for MSDOS. */
      fprintf(fd, "set VIM=%s\n", buf);
      !
      ! strcpy(buf, installdir);
      ! add_pathsep(buf);
      ! strcat(buf, exename);
      ! /* Can only handle 9 arguments now. Use "shift" to use more? */
      ! fprintf(fd, "%s %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9\n", buf);
      !
      fclose(fd);
      printf("%s has been %s\n", batname,
      oldname == NULL ? "created" : "overwritten");
      --- 865,879 ----
      * contains a space. The quotes would be included in the value
      * for MSDOS. */
      fprintf(fd, "set VIM=%s\n", buf);
      ! fprintf(fd, "set VIMARGS=\n");
      ! fprintf(fd, ":arg\n");
      ! fprintf(fd, "if .%%1==. goto start\n");
      ! fprintf(fd, "set VIMARGS=%%VIMARGS%% %%1\n");
      ! fprintf(fd, "shift\n");
      ! fprintf(fd, "goto arg\n");
      ! fprintf(fd, ":start\n");
      ! fprintf(fd, "%%VIM%%VIM60T\\%s %%VIMARGS%%\n", exename);
      ! fprintf(fd, "set VIMARGS=\n");
      fclose(fd);
      printf("%s has been %s\n", batname,
      oldname == NULL ? "created" : "overwritten");


      --
      Walter Briscoe
    Your message has been successfully submitted and would be delivered to recipients shortly.