summaryrefslogtreecommitdiff
path: root/Build/source/utils/xindy/xindy-2.4-PATCHES/patch-03-win32
blob: 4345e75cb8774bee22f25882e1a7127beecb9628 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff -ur -N -x Makefile.in -x autom4te.cache xindy-2.4.orig/tex2xindy/tex2xindy.l xindy-2.4/tex2xindy/tex2xindy.l
--- xindy-2.4.orig/tex2xindy/tex2xindy.l	2012-06-21 12:13:02.000000000 +0200
+++ xindy-2.4/tex2xindy/tex2xindy.l	2013-11-22 09:25:00.000000000 +0100
@@ -89,11 +89,24 @@
 =cut
 
 */
+%}
 
+%top{
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
+#ifdef WIN32
+# include <fcntl.h>
+# ifndef __MINGW32__  /* this should be W32TeX */
+#  include <kpathsea/getopt.h>
+#  define YY_NO_UNISTD_H 1
+#  define __STDC_VERSION__ 199901L
+# endif
+#else
+# include <unistd.h>
+#endif
+}
 
+%{
 #define QUOTE_ECHO qs(yytext)
 
 FILE* attrfd = NULL;
@@ -375,8 +388,13 @@
 main(int argc, char* argv[])
 {
     int option;
+
+#ifdef WIN32
+    setmode (fileno(stdout), _O_BINARY);
+#else
     extern char *optarg;
     extern int optind, optopt;
+#endif
 
     while ( (option=getopt(argc, argv, ":o")) != -1 ) {
 	switch (option) {
@@ -398,7 +416,7 @@
     if ( optind == argc - 1 ) {
 	fprintf(stderr, "Writing attribute names to file \"%s\".\n",
 		argv[optind]);
-	if ( (attrfd = fopen(argv[optind], "w")) == NULL ) {
+	if ( (attrfd = fopen(argv[optind], "wb")) == NULL ) {
 	    perror (argv[optind]);
 	    exit (1);
 	}