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 2013-11-22 09:30:35.299204605 +0100 +++ xindy-2.4/tex2xindy/tex2xindy.c 2013-11-22 09:27:49.000000000 +0100 @@ -1,5 +1,20 @@ +#line 95 "tex2xindy.l" +#include +#include +#ifdef WIN32 +# include +# ifndef __MINGW32__ /* this should be W32TeX */ +# include +# define YY_NO_UNISTD_H 1 +# define __STDC_VERSION__ 199901L +# endif +#else +# include +#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 -#include -#include - +#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); }