diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-07-27 07:24:40 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-07-27 07:24:40 +0000 |
commit | c5709ea5924966b82883b45f0b92e7d6a0486226 (patch) | |
tree | d5960aa9526e2000ff762c83e3236234e6cb6181 /Build/source | |
parent | eaac90e158a99ebff3c1ca7ee451f1048abe5f63 (diff) |
mendexk: Use binary mode for input and output (from W32TeX)
Use 8-bit exit() codes
git-svn-id: svn://tug.org/texlive/trunk@27191 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/mendexk/ChangeLog | 7 | ||||
-rw-r--r-- | Build/source/texk/mendexk/convert.c | 2 | ||||
-rw-r--r-- | Build/source/texk/mendexk/fread.c | 17 | ||||
-rw-r--r-- | Build/source/texk/mendexk/fwrite.c | 9 | ||||
-rw-r--r-- | Build/source/texk/mendexk/main.c | 9 |
5 files changed, 31 insertions, 13 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog b/Build/source/texk/mendexk/ChangeLog index 146be2bddd5..120556fb31a 100644 --- a/Build/source/texk/mendexk/ChangeLog +++ b/Build/source/texk/mendexk/ChangeLog @@ -1,3 +1,10 @@ +2012-07-26 Peter Breitenlohner <peb@mppmu.mpg.de> + + * fwrite.c, main.c: Use binary mode for input and output + (from W32TeX). + * convert.c, fread.c, main.c: Use 8-bit exit() codes. + * main.c: Terminate main() with return instead of exit(). + 2012-07-15 Peter Breitenlohner <peb@mppmu.mpg.de> * kp.c: Pass program name string to kpse_set_program_name. diff --git a/Build/source/texk/mendexk/convert.c b/Build/source/texk/mendexk/convert.c index 3341cccad05..be0441b4cdb 100644 --- a/Build/source/texk/mendexk/convert.c +++ b/Build/source/texk/mendexk/convert.c @@ -143,7 +143,7 @@ static int dicvalread(const char *filename, struct dictionary *dicval, int line) fp=nkf_open(filename,"rb"); else { fprintf(stderr, "mendex: %s is forbidden to open for reading.\n",filename); - exit(-1); + exit(255); } for (i=0;i<line;i++) { if (mfgets(buff,255,fp)==NULL) break; diff --git a/Build/source/texk/mendexk/fread.c b/Build/source/texk/mendexk/fread.c index b1b8d906826..e6fd3804a60 100644 --- a/Build/source/texk/mendexk/fread.c +++ b/Build/source/texk/mendexk/fread.c @@ -27,6 +27,9 @@ int idxread(char *filename, int start) if (filename==NULL) { fp=stdin; +#ifdef WIN32 + setmode(fileno(fp), _O_BINARY); +#endif verb_printf(efp, "Scanning input file stdin."); } else { @@ -122,7 +125,7 @@ LOOP: ind[i].idx[indent]=malloc(k+1); if (ind[i].idx[indent]==NULL) { fprintf(stderr,"Malloc error.(ind[%d].idx[%d])\n",i,indent); - exit(-1); + exit(255); } strncpy(ind[i].idx[indent],wbuff,k); ind[i].idx[indent][k]='\0'; @@ -145,7 +148,7 @@ LOOP: ind[i].org[indent]=malloc(k+1); if (ind[i].org[indent]==NULL) { fprintf(stderr,"Malloc error.(ind[%d].org[%d])\n",i,indent); - exit(-1); + exit(255); } strncpy(ind[i].org[indent],wbuff,k); ind[i].org[indent][k]='\0'; @@ -173,7 +176,7 @@ LOOP: ind[i].idx[indent]=malloc(k+1); if (ind[i].idx[indent]==NULL) { fprintf(stderr,"Malloc error.(ind[%d].idx[%d])\n",i,indent); - exit(-1); + exit(255); } strncpy(ind[i].idx[indent],wbuff,k); ind[i].idx[indent][k]='\0'; @@ -243,7 +246,7 @@ LOOP: ind[i].dic[k]=malloc(strlen(table)+1); if (ind[i].dic[k]==NULL) { fprintf(stderr,"Malloc error.(ind[%d].dic[%d])\n",i,k); - exit(-1); + exit(255); } strcpy(ind[i].dic[k],table); } @@ -260,7 +263,7 @@ LOOP: ind[i].dic[k]=malloc(strlen(table)+1); if (ind[i].dic[k]==NULL) { fprintf(stderr,"Malloc error.(ind[%d].dic[%d])\n",i,k); - exit(-1); + exit(255); } strcpy(ind[i].dic[k],table); } @@ -299,7 +302,7 @@ LOOP: ind[0].p[0].page=malloc(strlen(table)+1); if (ind[0].p[0].page==NULL) { fprintf(stderr,"Malloc error.(ind[0].p[0].page)\n"); - exit(-1); + exit(255); } strcpy(ind[0].p[0].page,table); break; @@ -316,7 +319,7 @@ LOOP: ind[0].p[0].enc=malloc(strlen(estr)+1); if (ind[0].p[0].enc==NULL) { fprintf(stderr,"Malloc error.(ind[0].p[0].enc)\n"); - exit(-1); + exit(255); } strcpy(ind[0].p[0].enc,estr); chkpageattr(&ind[0].p[0]); diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c index 07b332fa647..10eb46c9b93 100644 --- a/Build/source/texk/mendexk/fwrite.c +++ b/Build/source/texk/mendexk/fwrite.c @@ -77,8 +77,13 @@ void indwrite(char *filename, struct index *ind, int pagenum) char datama[256],lbuff[4096]; FILE *fp; - if (filename[0]!='\0' && kpse_out_name_ok(filename)) fp=fopen(filename,"w"); - else fp=stdout; + if (filename[0]!='\0' && kpse_out_name_ok(filename)) fp=fopen(filename,"wb"); + else { + fp=stdout; +#ifdef WIN32 + setmode(fileno(fp), _O_BINARY); +#endif + } convert(atama,datama); fputs(preamble,fp); diff --git a/Build/source/texk/mendexk/main.c b/Build/source/texk/mendexk/main.c index e226a660b56..e418c709960 100644 --- a/Build/source/texk/mendexk/main.c +++ b/Build/source/texk/mendexk/main.c @@ -35,6 +35,9 @@ int main(int argc, char **argv) const char *envbuff; set_enc_string(NULL, "EUC"); +#ifdef WIN32 + _setmaxstdio(2048); +#endif #ifdef KPATHSEA KP_init(argv[0]); kp_ist.var_name = "INDEXSTYLE"; @@ -241,7 +244,7 @@ int main(int argc, char **argv) if (i==-1) sprintf(logfile,"%s.ilg",idxfile[0]); } if ((logfile[0] != '\0') && kpse_out_name_ok(logfile)) - efp=fopen(logfile,"w"); + efp=fopen(logfile,"wb"); if(efp == NULL) { efp=stderr; strcpy(logfile,"stderr"); @@ -309,7 +312,7 @@ int main(int argc, char **argv) if (lines==0) { verb_printf(efp,"Nothing written in output file.\n"); if (efp!=stderr) fclose(efp); - exit(-1); + exit(255); } /* sort index */ @@ -367,5 +370,5 @@ int main(int argc, char **argv) verb_printf(efp,"Output written in %s.\n",indfile); if (efp!=stderr) fclose(efp); - exit(0); + return 0; } |