Skip to content

Commit 24db729

Browse files
committed
patch 7.4.1040
Problem: The tee command is not available on MS-Windows. Solution: Adjust tee.c for MSVC and add a makefile. (Yasuhiro Matsumoto)
1 parent d798af8 commit 24db729

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

src/Make_mvc.mak

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,8 +946,13 @@ LINKARGS1 = $(LINKARGS1) /LTCG:STATUS
946946
!endif
947947
!endif
948948

949-
all: $(VIM).exe vimrun.exe install.exe uninstal.exe xxd/xxd.exe \
950-
GvimExt/gvimext.dll
949+
all: $(VIM).exe \
950+
vimrun.exe \
951+
install.exe \
952+
uninstal.exe \
953+
xxd/xxd.exe \
954+
tee/tee.exe \
955+
GvimExt/gvimext.dll
951956

952957
$(VIM).exe: $(OUTDIR) $(OBJ) $(GUI_OBJ) $(OLE_OBJ) $(OLE_IDL) $(MZSCHEME_OBJ) \
953958
$(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
@@ -982,6 +987,11 @@ xxd/xxd.exe: xxd/xxd.c
982987
$(MAKE) /NOLOGO -f Make_mvc.mak
983988
cd ..
984989

990+
tee/tee.exe: tee/tee.c
991+
cd tee
992+
$(MAKE) /NOLOGO -f Make_mvc.mak
993+
cd ..
994+
985995
GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
986996
cd GvimExt
987997
$(MAKE) /NOLOGO -f Makefile $(MAKEFLAGS_GVIMEXT)

src/tee/Make_mvc.mak

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# A very (if not the most) simplistic Makefile for MSVC
2+
3+
CC=cl
4+
CFLAGS=/O2
5+
6+
tee.exe: tee.obj
7+
$(CC) $(CFLAGS) /Fo$@ $**
8+
9+
tee.obj: tee.c
10+
$(CC) $(CFLAGS) /c $**
11+
12+
clean:
13+
- del tee.obj
14+
- del tee.exe

src/tee/tee.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* Author: Paul Slootman
66
7+
* Modifications for MSVC: Yasuhiro Matsumoto
78
*
89
* This source code is released into the public domain. It is provided on an
910
* as-is basis and no responsibility is accepted for its failure to perform
@@ -26,9 +27,16 @@
2627
* precompiled for OS/2. That one probably works better.
2728
*/
2829

29-
#include <unistd.h>
30+
#ifndef _MSC_VER
31+
# include <unistd.h>
32+
#endif
3033
#include <malloc.h>
3134
#include <stdio.h>
35+
#include <fcntl.h>
36+
37+
#ifdef _WIN32
38+
# define sysconf(x) -1
39+
#endif
3240

3341
void usage(void)
3442
{
@@ -79,17 +87,17 @@ main(int argc, char *argv[])
7987
int i;
8088
char buf[BUFSIZ];
8189
int n;
82-
extern int optind;
90+
int optind = 1;
8391

84-
while ((opt = getopt(argc, argv, "a")) != EOF)
92+
for (i = 1; i < argc; i++)
8593
{
86-
switch (opt)
87-
{
88-
case 'a': append++;
89-
break;
90-
default: usage();
91-
exit(2);
92-
}
94+
if (argv[i][0] != '-')
95+
break;
96+
if (!strcmp(argv[i], "-a"))
97+
append++;
98+
else
99+
usage();
100+
optind++;
93101
}
94102

95103
numfiles = argc - optind;
@@ -124,9 +132,9 @@ main(int argc, char *argv[])
124132
exit(1);
125133
}
126134
}
127-
_fsetmode(stdin, "b");
135+
setmode(fileno(stdin), O_BINARY);
128136
fflush(stdout); /* needed for _fsetmode(stdout) */
129-
_fsetmode(stdout, "b");
137+
setmode(fileno(stdout), O_BINARY);
130138

131139
while ((n = myfread(buf, sizeof(char), sizeof(buf), stdin)) > 0)
132140
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1040,
744746
/**/
745747
1039,
746748
/**/

0 commit comments

Comments
 (0)