From 808caf0e3038020441cdb1d964efd26ebc6ba474 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 2 May 2011 12:29:48 +0000 Subject: texk/mendex: Change most 'unsigned char' into plain 'char' to avoid lots of 'differ in signedness' warnings from gcc-4.4 git-svn-id: svn://tug.org/texlive/trunk@22277 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/mendexk/ChangeLog.TL | 28 +++++++++++++++++++++++++ Build/source/texk/mendexk/Makefile.am | 6 ++---- Build/source/texk/mendexk/Makefile.in | 3 +-- Build/source/texk/mendexk/configure | 28 +------------------------ Build/source/texk/mendexk/configure.ac | 5 +---- Build/source/texk/mendexk/convert.c | 37 ++++++++++++++-------------------- Build/source/texk/mendexk/exkana.h | 22 ++++++++++---------- Build/source/texk/mendexk/exvar.h | 4 ++-- Build/source/texk/mendexk/fread.c | 32 ++++++++++++++--------------- Build/source/texk/mendexk/fwrite.c | 8 ++++---- Build/source/texk/mendexk/kana.h | 22 ++++++++++---------- Build/source/texk/mendexk/ktable.h | 10 ++++----- Build/source/texk/mendexk/main.c | 2 +- Build/source/texk/mendexk/mendex.h | 16 +++++++-------- Build/source/texk/mendexk/sort.c | 30 +++++++++++++-------------- Build/source/texk/mendexk/var.h | 4 ++-- 16 files changed, 123 insertions(+), 134 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/mendexk/ChangeLog.TL b/Build/source/texk/mendexk/ChangeLog.TL index 104cb0757c8..b2a58d6d428 100644 --- a/Build/source/texk/mendexk/ChangeLog.TL +++ b/Build/source/texk/mendexk/ChangeLog.TL @@ -1,6 +1,34 @@ ChangeLog.TL: TeX Live (TL) changes for mendexk =============================================== +2011-04-23 Peter Breitenlohner + + * Makefile.am (EXTRA_DIST): No need to mention ChangeLog, README. + * configure.ac: Drop useless check for . + + * convert.c, fread.c, main.c, sort.c: Do not typecast the + result of malloc(). + +2011-04-22 Peter Breitenlohner + + Avoid 'differ in signedness' warnings. + The string functions strlen(), strcmp(), strncmp(), strcpy(), + and strncpy() all expect 'char *' arguments and gcc-4.x will + create warnings for 'signed char *' and 'unsigned char *' args. + Moreover strcmp() and strncmp() will always compare string bytes + interpreted as 'unsigned char'. Finally initializing plain char + array elements with, e.g., '0x80' always does the right thing. + + * convert.c, exkana.h, exvar.h, fread.c, fwrite.c, kana.h, + ktable.h, mendex.h, sort.c, var.h: Change type of all global and + local vars, function params, and struct members from 'unsigned + char' or 'unsigned char *' to plain 'char' or 'char *', but + always cast string bytes to 'unsigned char' when tested for '<', + '<=', '>', or '>='. + + * convert.c, fread.c, main.c, sort.c: Do not typecast the + result of malloc(). + 2010-04-17 Peter Breitenlohner * convert.c (dicread, dicvalread), fread.c (idxread), diff --git a/Build/source/texk/mendexk/Makefile.am b/Build/source/texk/mendexk/Makefile.am index bf5fe2dda07..7cb1c85e804 100644 --- a/Build/source/texk/mendexk/Makefile.am +++ b/Build/source/texk/mendexk/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am for the TeX Live subdirectory texk/mendexk/ ## -## Copyright (C) 2010 Peter Breitenlohner +## Copyright (C) 2010, 2011 Peter Breitenlohner ## You may freely use, modify and/or distribute this file. ## ACLOCAL_AMFLAGS = -I ../../m4 @@ -42,9 +42,7 @@ dist_man1_MANS = mendex.1 EXTRA_DIST = \ COPYRIGHT \ COPYRIGHT.jis \ - ChangeLog \ - ChangeLog.TL \ - README + ChangeLog.TL ## Eventually delete these files ## diff --git a/Build/source/texk/mendexk/Makefile.in b/Build/source/texk/mendexk/Makefile.in index c85474acd0b..4cafb83d593 100644 --- a/Build/source/texk/mendexk/Makefile.in +++ b/Build/source/texk/mendexk/Makefile.in @@ -274,8 +274,7 @@ mendex_SOURCES = \ LDADD = $(PTEXENC_LIBS) $(KPATHSEA_LIBS) dist_man1_MANS = mendex.1 -EXTRA_DIST = COPYRIGHT COPYRIGHT.jis ChangeLog ChangeLog.TL README \ - indexsty mendex.doc +EXTRA_DIST = COPYRIGHT COPYRIGHT.jis ChangeLog.TL indexsty mendex.doc all: c-auto.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/Build/source/texk/mendexk/configure b/Build/source/texk/mendexk/configure index 7df6c35c9f6..084bf0413dc 100755 --- a/Build/source/texk/mendexk/configure +++ b/Build/source/texk/mendexk/configure @@ -762,8 +762,7 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP -CPPFLAGS' +CPP' # Initialize some variables set by options. @@ -12503,31 +12502,6 @@ WARNING_CFLAGS=$kpse_cv_warning_cflags ac_config_headers="$ac_config_headers c-auto.h:c-auto.in" -for ac_header in strings.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default" -if test "x$ac_cv_header_strings_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRINGS_H 1 -_ACEOF - -fi - -done - -for ac_func -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - kpse_save_CPPFLAGS=$CPPFLAGS kpse_save_LIBS=$LIBS diff --git a/Build/source/texk/mendexk/configure.ac b/Build/source/texk/mendexk/configure.ac index ecd187ba60b..074cd8f189e 100644 --- a/Build/source/texk/mendexk/configure.ac +++ b/Build/source/texk/mendexk/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl Copyright (C) 2010 Peter Breitenlohner +dnl Copyright (C) 2010, 2011 Peter Breitenlohner dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, @@ -17,9 +17,6 @@ KPSE_COMMON([mendexk], [no-define]) AC_CONFIG_HEADERS([c-auto.h:c-auto.in]) -AC_CHECK_HEADERS([strings.h]) -AC_CHECK_FUNCS([]) - KPSE_KPATHSEA_FLAGS KPSE_PTEXENC_FLAGS diff --git a/Build/source/texk/mendexk/convert.c b/Build/source/texk/mendexk/convert.c index 886d07bfafb..3d7d4241d22 100644 --- a/Build/source/texk/mendexk/convert.c +++ b/Build/source/texk/mendexk/convert.c @@ -17,11 +17,11 @@ #endif struct dictionary{ -unsigned char dic[2][50]; +char dic[2][50]; }; -struct dictionary *dictable,*envdic; -int dlines=0,elines=0; +static struct dictionary *dictable,*envdic; +static int dlines=0,elines=0; static int dicvalread(const char *filename, struct dictionary *dicval, int line); @@ -32,15 +32,15 @@ void initkanatable(void) for (i=0xa4a1;i<=0xa4f3;i++) { cc=i-0xa4a1; - hiragana[cc*2]=(unsigned char)((i>>8)&0xff); - hiragana[cc*2+1]=(unsigned char)(i&0xff); + hiragana[cc*2]=((i>>8)&0xff); + hiragana[cc*2+1]=(i&0xff); } hiragana[(i-0xa4a1)*2]=0; for (i=0xa5a1;i<=0xa5f6;i++) { cc=i-0xa5a1; - katakana[cc*2]=(unsigned char)((i>>8)&0xff); - katakana[cc*2+1]=(unsigned char)(i&0xff); + katakana[cc*2]=((i>>8)&0xff); + katakana[cc*2+1]=(i&0xff); } katakana[(i-0xa5a1)*2]=0; @@ -87,7 +87,7 @@ int dicread(const char *filename) } nkf_close(fp); - dictable=(struct dictionary *)malloc(sizeof(struct dictionary)*i); + dictable=malloc(sizeof(struct dictionary)*i); dlines=dicvalread(filename,dictable,i); @@ -124,7 +124,7 @@ ENV: } nkf_close(fp); - envdic=(struct dictionary *)malloc(sizeof(struct dictionary)*i); + envdic=malloc(sizeof(struct dictionary)*i); elines=dicvalread(envfile,envdic,i); @@ -140,7 +140,7 @@ static int dcomp(const void *bf1, const void *bf2); static int dicvalread(const char *filename, struct dictionary *dicval, int line) { int i,j,k; - unsigned char buff[256]; + char buff[256]; FILE *fp; if(kpse_in_name_ok(filename)) @@ -195,14 +195,14 @@ static int dcomp(const void *bf1, const void *bf2) if (((*buff1).dic[0][i]=='\0')&&((*buff2).dic[0][i]=='\0')) return 0; else if (((*buff1).dic[0][i]=='\0')&&((*buff2).dic[0][i]!='\0')) return 1; else if (((*buff1).dic[0][i]!='\0')&&((*buff2).dic[0][i]=='\0')) return -1; - else if ((*buff1).dic[0][i]<(*buff2).dic[0][i]) return 1; - else if ((*buff1).dic[0][i]>(*buff2).dic[0][i]) return -1; + else if ((unsigned char)(*buff1).dic[0][i]<(unsigned char)(*buff2).dic[0][i]) return 1; + else if ((unsigned char)(*buff1).dic[0][i]>(unsigned char)(*buff2).dic[0][i]) return -1; } return 0; } /* convert to capital-hiragana character */ -int convert(unsigned char *buff1, unsigned char *buff2) +int convert(char *buff1, char *buff2) { int i=0,j=0,k,l; char errbuff[4096]; @@ -223,7 +223,7 @@ int convert(unsigned char *buff1, unsigned char *buff2) i++; } - else if (buff1[i]<0x80) { + else if ((unsigned char)buff1[i]<0x80) { buff2[j]=buff1[i]; i++; j++; @@ -284,7 +284,7 @@ MATCH3: j+=2; } - else if (buff1[i]>=0x80) { + else if ((unsigned char)buff1[i]>=0x80) { if ((strncmp(&buff1[i],SPACE,2)>=0)&&(strncmp(&buff1[i],ALPHAEND,2)<=0)) { /* alpha-numeric,symbols */ for (k=0;k=0x80) { + if ((unsigned char)buff[j]>=0x80) { wbuff[k+1]=buff[j+1]; j++; k++; @@ -240,7 +240,7 @@ LOOP: n++; goto LOOP; } - ind[i].dic[k]=(unsigned char *)malloc(strlen(table)+1); + 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); @@ -257,7 +257,7 @@ LOOP: n++; goto LOOP; } - ind[i].dic[k]=(unsigned char *)malloc(strlen(table)+1); + 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); @@ -271,7 +271,7 @@ LOOP: if (i==0) { ind[0].num=0; - ind[0].p=(struct page *)malloc(sizeof(struct page)*16); + ind[0].p=malloc(sizeof(struct page)*16); for (;buff[j]!=arg_open && buff[j]!='\n' && buff[j]!='\0';j++); if (buff[j]=='\n' || buff[j]=='\0') { verb_printf(efp,"\nWarning: Missing second argument in %s, line %d.",filename,ind[i].lnum); @@ -306,7 +306,7 @@ LOOP: } else nest--; } - else if (buff[j]>=0x80) { + else if ((unsigned char)buff[j]>=0x80) { table[k]=buff[j]; j++; k++; @@ -378,7 +378,7 @@ LOOP: if (nest==0) break; else nest--; } - else if (buff[j]>=0x80) { + else if ((unsigned char)buff[j]>=0x80) { table[k]=buff[j]; j++; k++; @@ -408,7 +408,7 @@ LOOP: } else { ind[i].num=0; - ind[i].p=(struct page *)malloc(sizeof(struct page)*16); + ind[i].p=malloc(sizeof(struct page)*16); for (;buff[j]!=arg_open && buff[j]!='\n' && buff[j]!='\0';j++); if (buff[j]=='\n' || buff[j]=='\0') { verb_printf(efp,"\nWarning: Missing second argument in %s, line %d.",filename,ind[i].lnum); @@ -439,7 +439,7 @@ LOOP: } else nest--; } - else if (buff[j]>=0x80) { + else if ((unsigned char)buff[j]>=0x80) { table[k]=buff[j]; j++; k++; @@ -460,14 +460,14 @@ LOOP: } /* pic up encap string */ -static int getestr(unsigned char *buff, unsigned char *estr) +static int getestr(char *buff, char *estr) { int i,nest=0; for (i=0;i0) { - if (buff[i-1]<0x80) { + if ((unsigned char)buff[i-1]<0x80) { estr[i]=buff[i]; i++; } @@ -484,7 +484,7 @@ static int getestr(unsigned char *buff, unsigned char *estr) if (buff[i]==arg_open) nest++; else if (buff[i]==arg_close) nest--; estr[i]=buff[i]; - if (buff[i]>0x80) { + if ((unsigned char)buff[i]>0x80) { i++; estr[i]=buff[i]; } diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c index 2f2b35283e2..07b332fa647 100644 --- a/Build/source/texk/mendexk/fwrite.c +++ b/Build/source/texk/mendexk/fwrite.c @@ -74,7 +74,7 @@ int verb_printf(FILE *fp, const char *format, ...) void indwrite(char *filename, struct index *ind, int pagenum) { int i,j,hpoint=0; - unsigned char datama[256],lbuff[4096]; + char datama[256],lbuff[4096]; FILE *fp; if (filename[0]!='\0' && kpse_out_name_ok(filename)) fp=fopen(filename,"w"); @@ -116,7 +116,7 @@ void indwrite(char *filename, struct index *ind, int pagenum) if (lethead_flag) { fputs(lethead_prefix,fp); for (j=hpoint;j<(strlen(datama)/2);j++) { - if (ind[i].dic[0][1](*index2).dic[j][i]) return 1; + if ((unsigned char)(*index1).dic[j][i]<(unsigned char)(*index2).dic[j][i]) return -1; + else if ((unsigned char)(*index1).dic[j][i]>(unsigned char)(*index2).dic[j][i]) return 1; /* 2byte character */ - if (((*index1).dic[j][i]>=0x80)&&((*index2).dic[j][i]>=0x80)) { + if (((unsigned char)(*index1).dic[j][i]>=0x80)&&((unsigned char)(*index2).dic[j][i]>=0x80)) { prechar=1; i++; - if ((*index1).dic[j][i]<(*index2).dic[j][i]) return -1; - else if ((*index1).dic[j][i]>(*index2).dic[j][i]) return 1; + if ((unsigned char)(*index1).dic[j][i]<(unsigned char)(*index2).dic[j][i]) return -1; + else if ((unsigned char)(*index1).dic[j][i]>(unsigned char)(*index2).dic[j][i]) return 1; } else prechar=0; } @@ -139,8 +139,8 @@ static int wcomp(const void *p, const void *q) if (((*index1).idx[j][i]=='\0')&&((*index2).idx[j][i]=='\0')) break; else if ((*index1).idx[j][i]=='\0') return -1; else if ((*index2).idx[j][i]=='\0') return 1; - else if ((*index1).idx[j][i]<(*index2).idx[j][i]) return -1; - else if ((*index1).idx[j][i]>(*index2).idx[j][i]) return 1; + else if ((unsigned char)(*index1).idx[j][i]<(unsigned char)(*index2).idx[j][i]) return -1; + else if ((unsigned char)(*index1).idx[j][i]>(unsigned char)(*index2).idx[j][i]) return 1; } } return 0; @@ -155,7 +155,7 @@ void pagesort(struct index *ind, int num) for (i=0;i='A')&&(c<='Z'))||((c>='a')&&(c<='z'))||((c>='0')&&(c<='9'))) return 1; else return 0; } -int alphabet(unsigned char c) +int alphabet(char c) { if (((c>='A')&&(c<='Z'))||((c>='a')&&(c<='z'))) return 1; else return 0; } -int numeric(unsigned char c) +int numeric(char c) { if ((c>='0')&&(c<='9')) return 1; else return 0; } -int japanese(unsigned char *buff) +int japanese(char *buff) { if (strncmp(buff,HIRATOP,2)>=0) return 1; else return 0; diff --git a/Build/source/texk/mendexk/var.h b/Build/source/texk/mendexk/var.h index 5b7fe8a7ddb..9565dd791d0 100644 --- a/Build/source/texk/mendexk/var.h +++ b/Build/source/texk/mendexk/var.h @@ -32,6 +32,6 @@ char symhead_positive[2048]={"Symbols"},symhead_negative[2048]={"symbols"}; char numhead_positive[2048]={"Numbers"},numhead_negative[2048]={"numbers"}; int symbol_flag=1; int letter_head=1; -unsigned char atama[2048]; -unsigned char page_compositor[2048]={"-"},page_precedence[2048]={"rnaRA"}; +char atama[2048]; +char page_compositor[2048]={"-"},page_precedence[2048]={"rnaRA"}; char character_order[2048]={"SNEJ"}; -- cgit v1.2.3