summaryrefslogtreecommitdiff
path: root/Build/source/utils/xindy/xindy-2.4-PATCHES/patch-04-win32
blob: 198053967e6563c55efb57b5e4ae050ab74dafed (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
diff -ur -N -x Makefile.in -x autom4te.cache xindy-2.4.orig/tex2xindy/tex2xindy.c xindy-2.4/tex2xindy/tex2xindy.c
--- xindy-2.4.orig/tex2xindy/tex2xindy.c	2012-06-21 12:14:36.000000000 +0200
+++ xindy-2.4/tex2xindy/tex2xindy.c	2012-09-27 14:37:38.000000000 +0200
@@ -1,5 +1,20 @@
+#line 95 "tex2xindy.l"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef WIN32
+# include <kpathsea/getopt.h>
+# include <fcntl.h>
+# define YY_NO_UNISTD_H 1
+# ifdef W32TeX
+#  define __STDC_VERSION__ 199901L
+# endif
+#else
+# include <unistd.h>
+#endif
+
 
-#line 3 "tex2xindy.c"
+
+#line 18 "tex2xindy.c"
 
 #define  YY_INT_ALIGNED short int
 
@@ -8,7 +23,7 @@
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
+#define YY_FLEX_SUBMINOR_VERSION 37
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -53,7 +68,6 @@
 typedef unsigned char flex_uint8_t; 
 typedef unsigned short int flex_uint16_t;
 typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -84,6 +98,8 @@
 #define UINT32_MAX             (4294967295U)
 #endif
 
+#endif /* ! C99 */
+
 #endif /* ! FLEXINT_H */
 
 #ifdef __cplusplus
@@ -152,7 +168,12 @@
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 #endif
 
-extern int yyleng;
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+extern yy_size_t yyleng;
 
 extern FILE *yyin, *yyout;
 
@@ -178,11 +199,6 @@
 
 #define unput(c) yyunput( c, (yytext_ptr)  )
 
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
 #ifndef YY_STRUCT_YY_BUFFER_STATE
 #define YY_STRUCT_YY_BUFFER_STATE
 struct yy_buffer_state
@@ -200,7 +216,7 @@
 	/* Number of characters read into yy_ch_buf, not including EOB
 	 * characters.
 	 */
-	int yy_n_chars;
+	yy_size_t yy_n_chars;
 
 	/* Whether we "own" the buffer - i.e., we know we created it,
 	 * and can realloc() it to grow it, and should free() it to
@@ -270,8 +286,8 @@
 
 /* yy_hold_char holds the character lost when yytext is formed. */
 static char yy_hold_char;
-static int yy_n_chars;		/* number of characters read into yy_ch_buf */
-int yyleng;
+static yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
+yy_size_t yyleng;
 
 /* Points to current character in buffer. */
 static char *yy_c_buf_p = (char *) 0;
@@ -299,7 +315,7 @@
 
 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len  );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len  );
 
 void *yyalloc (yy_size_t  );
 void *yyrealloc (void *,yy_size_t  );
@@ -639,10 +655,7 @@
 
 */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
+#line 110 "tex2xindy.l"
 #define QUOTE_ECHO qs(yytext)
 
 FILE* attrfd = NULL;
@@ -735,7 +748,7 @@
 }
 
 
-#line 739 "tex2xindy.c"
+#line 752 "tex2xindy.c"
 
 #define INITIAL 0
 #define key 1
@@ -782,7 +795,7 @@
 
 void yyset_out  (FILE * out_str  );
 
-int yyget_leng (void );
+yy_size_t yyget_leng (void );
 
 char *yyget_text (void );
 
@@ -832,7 +845,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -843,7 +856,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		int n; \
+		size_t n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -925,10 +938,10 @@
 	register char *yy_cp, *yy_bp;
 	register int yy_act;
     
-#line 209 "tex2xindy.l"
+#line 222 "tex2xindy.l"
 
 
-#line 932 "tex2xindy.c"
+#line 945 "tex2xindy.c"
 
 	if ( !(yy_init) )
 		{
@@ -1009,7 +1022,7 @@
 
 case 1:
 YY_RULE_SETUP
-#line 211 "tex2xindy.l"
+#line 224 "tex2xindy.l"
 {
 			  printf("(indexentry :tkey ((\"");
 			  xref_mode = 0;
@@ -1019,7 +1032,7 @@
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 218 "tex2xindy.l"
+#line 231 "tex2xindy.l"
 {
 			  printf("(indexentry :tkey ((\"");
 			  xref_mode = 0;
@@ -1029,23 +1042,23 @@
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 225 "tex2xindy.l"
+#line 238 "tex2xindy.l"
 { QUOTE_ECHO; }
 	YY_BREAK
 case 4:
 /* rule 4 can match eol */
 YY_RULE_SETUP
-#line 226 "tex2xindy.l"
+#line 239 "tex2xindy.l"
 { qc(yytext[1]); lineno++; }
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 227 "tex2xindy.l"
+#line 240 "tex2xindy.l"
 { qc(yytext[1]); }
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 228 "tex2xindy.l"
+#line 241 "tex2xindy.l"
 {
 			 printf("\")) :attr \"");
                          range = NO_RANGE;
@@ -1054,7 +1067,7 @@
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 233 "tex2xindy.l"
+#line 246 "tex2xindy.l"
 {
 			 if ( glos_mode ) {
                              printf("\")) :attr \"is\" :xref (\"");
@@ -1068,22 +1081,22 @@
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 243 "tex2xindy.l"
+#line 256 "tex2xindy.l"
 { printf("\") (\""); }
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 244 "tex2xindy.l"
+#line 257 "tex2xindy.l"
 { printf("\") (\""); BEGIN(key); }
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 245 "tex2xindy.l"
+#line 258 "tex2xindy.l"
 { ECHO; braces++; }
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 246 "tex2xindy.l"
+#line 259 "tex2xindy.l"
 {
 			 if ( braces > 0 ) {
 			     ECHO;
@@ -1096,32 +1109,32 @@
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 256 "tex2xindy.l"
+#line 269 "tex2xindy.l"
 { printf("\" \""); BEGIN(print); }
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 257 "tex2xindy.l"
+#line 270 "tex2xindy.l"
 { multiple_err; }
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 259 "tex2xindy.l"
+#line 272 "tex2xindy.l"
 { multiple_err; }
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 260 "tex2xindy.l"
+#line 273 "tex2xindy.l"
 { range = OPEN_RANGE; }
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 261 "tex2xindy.l"
+#line 274 "tex2xindy.l"
 { range = CLOSE_RANGE; }
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 262 "tex2xindy.l"
+#line 275 "tex2xindy.l"
 { /* close :attr "... */
                          printf("\" :xref (\"");
 			 if (attrfd) fprintf(attrfd, "\txref\n");
@@ -1131,7 +1144,7 @@
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 268 "tex2xindy.l"
+#line 281 "tex2xindy.l"
 {
 			 if ( braces > 0 ) {
 			     ECHO;
@@ -1154,7 +1167,7 @@
 case 19:
 /* rule 19 can match eol */
 YY_RULE_SETUP
-#line 286 "tex2xindy.l"
+#line 299 "tex2xindy.l"
 {
 			 QUOTE_ECHO;
                          if (attrfd)  fwrite(yytext, sizeof(char), 1, attrfd);
@@ -1163,17 +1176,17 @@
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 294 "tex2xindy.l"
+#line 307 "tex2xindy.l"
 { printf("\" \""); }
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 295 "tex2xindy.l"
+#line 308 "tex2xindy.l"
 { ECHO; braces++; }
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 296 "tex2xindy.l"
+#line 309 "tex2xindy.l"
 {
 			 if ( braces > 1 ) {
 			     ECHO;
@@ -1189,7 +1202,7 @@
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 308 "tex2xindy.l"
+#line 321 "tex2xindy.l"
 {
 			 if ( braces > 0 ) {
 			     ECHO;
@@ -1203,7 +1216,7 @@
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 319 "tex2xindy.l"
+#line 332 "tex2xindy.l"
 {
                          if (xref_mode) {
 			     BEGIN(skiplocation);
@@ -1215,22 +1228,22 @@
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 327 "tex2xindy.l"
+#line 340 "tex2xindy.l"
 { printf("\")\n"); BEGIN(0); }
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 329 "tex2xindy.l"
+#line 342 "tex2xindy.l"
 { printf(")\n"); BEGIN(0); }
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 330 "tex2xindy.l"
+#line 343 "tex2xindy.l"
 { ; }
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 332 "tex2xindy.l"
+#line 345 "tex2xindy.l"
 {
 			if ( omega_mode ) {
 			    omega_output_utf8(2);
@@ -1241,7 +1254,7 @@
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 339 "tex2xindy.l"
+#line 352 "tex2xindy.l"
 {
 			if ( omega_mode ) {
 			    omega_output_utf8(4);
@@ -1252,7 +1265,7 @@
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 346 "tex2xindy.l"
+#line 359 "tex2xindy.l"
 {
 			if ( omega_mode ) {
 			    omega_output_utf8(8);
@@ -1264,28 +1277,28 @@
 case 31:
 /* rule 31 can match eol */
 YY_RULE_SETUP
-#line 354 "tex2xindy.l"
+#line 367 "tex2xindy.l"
 { ECHO; lineno++; }
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 355 "tex2xindy.l"
+#line 368 "tex2xindy.l"
 { QUOTE_ECHO; }
 	YY_BREAK
 case 33:
 /* rule 33 can match eol */
 YY_RULE_SETUP
-#line 357 "tex2xindy.l"
+#line 370 "tex2xindy.l"
 { lineno++; }
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 358 "tex2xindy.l"
+#line 371 "tex2xindy.l"
 { ; }
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 359 "tex2xindy.l"
+#line 372 "tex2xindy.l"
 {
 			fprintf(stderr,
 				"Encountered unexpected char '%c' on line %d\n",
@@ -1294,10 +1307,10 @@
 	YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 365 "tex2xindy.l"
+#line 378 "tex2xindy.l"
 ECHO;
 	YY_BREAK
-#line 1301 "tex2xindy.c"
+#line 1314 "tex2xindy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(key):
 case YY_STATE_EOF(print):
@@ -1492,21 +1505,21 @@
 
 	else
 		{
-			int num_to_read =
+			yy_size_t num_to_read =
 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 
 		while ( num_to_read <= 0 )
 			{ /* Not enough room in the buffer - grow it. */
 
 			/* just a shorter name for the current buffer */
-			YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
 
 			int yy_c_buf_p_offset =
 				(int) ((yy_c_buf_p) - b->yy_ch_buf);
 
 			if ( b->yy_is_our_buffer )
 				{
-				int new_size = b->yy_buf_size * 2;
+				yy_size_t new_size = b->yy_buf_size * 2;
 
 				if ( new_size <= 0 )
 					b->yy_buf_size += b->yy_buf_size / 8;
@@ -1537,7 +1550,7 @@
 
 		/* Read in more data. */
 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
-			(yy_n_chars), (size_t) num_to_read );
+			(yy_n_chars), num_to_read );
 
 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
 		}
@@ -1632,7 +1645,7 @@
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 	yy_is_jam = (yy_current_state == 115);
 
-	return yy_is_jam ? 0 : yy_current_state;
+		return yy_is_jam ? 0 : yy_current_state;
 }
 
     static void yyunput (int c, register char * yy_bp )
@@ -1647,7 +1660,7 @@
 	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
 		{ /* need to shift things up to make room */
 		/* +2 for EOB chars. */
-		register int number_to_move = (yy_n_chars) + 2;
+		register yy_size_t number_to_move = (yy_n_chars) + 2;
 		register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
 					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
 		register char *source =
@@ -1696,7 +1709,7 @@
 
 		else
 			{ /* need more input */
-			int offset = (yy_c_buf_p) - (yytext_ptr);
+			yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
 			++(yy_c_buf_p);
 
 			switch ( yy_get_next_buffer(  ) )
@@ -1968,7 +1981,7 @@
  */
 static void yyensure_buffer_stack (void)
 {
-	int num_to_alloc;
+	yy_size_t num_to_alloc;
     
 	if (!(yy_buffer_stack)) {
 
@@ -2060,12 +2073,12 @@
 
 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
  * 
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
+YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
 {
 	YY_BUFFER_STATE b;
 	char *buf;
@@ -2152,7 +2165,7 @@
 /** Get the length of the current token.
  * 
  */
-int yyget_leng  (void)
+yy_size_t yyget_leng  (void)
 {
         return yyleng;
 }
@@ -2300,7 +2313,7 @@
 
 #define YYTABLES_NAME "yytables"
 
-#line 365 "tex2xindy.l"
+#line 378 "tex2xindy.l"
 
 
 
@@ -2315,8 +2328,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) {
@@ -2338,7 +2356,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);
 	}