summaryrefslogtreecommitdiff
path: root/Build/source/texk/mendexk
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2010-04-15 09:05:21 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2010-04-15 09:05:21 +0000
commitf9a686d424f912154ffe8b7d5eb235032777a16f (patch)
treed0080bb63d613a4a64dc476c5c58e3ffbe8c241c /Build/source/texk/mendexk
parent32912d37dba67d5dc461a98e4444d5ea7723d2e3 (diff)
pTeX: avoid compiler warnings
git-svn-id: svn://tug.org/texlive/trunk@17875 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/mendexk')
-rw-r--r--Build/source/texk/mendexk/ChangeLog.TL23
-rw-r--r--Build/source/texk/mendexk/convert.c21
-rw-r--r--Build/source/texk/mendexk/exvar.h4
-rw-r--r--Build/source/texk/mendexk/fread.c8
-rw-r--r--Build/source/texk/mendexk/kana.h2
-rw-r--r--Build/source/texk/mendexk/kp.c33
-rw-r--r--Build/source/texk/mendexk/kp.h19
-rw-r--r--Build/source/texk/mendexk/main.c2
-rw-r--r--Build/source/texk/mendexk/mendex.h6
-rw-r--r--Build/source/texk/mendexk/pageread.c4
-rw-r--r--Build/source/texk/mendexk/sort.c2
-rw-r--r--Build/source/texk/mendexk/styfile.c30
-rw-r--r--Build/source/texk/mendexk/var.h2
13 files changed, 95 insertions, 61 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog.TL b/Build/source/texk/mendexk/ChangeLog.TL
index 1eb3003dbfb..7117d3223b0 100644
--- a/Build/source/texk/mendexk/ChangeLog.TL
+++ b/Build/source/texk/mendexk/ChangeLog.TL
@@ -1,6 +1,29 @@
ChangeLog.TL: TeX Live (TL) changes for mendexk
===============================================
+2010-04-15 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * pageread.c: #include "mendex.h" for prototype.
+ * kana.h: #include "exkana.h" for type checking.
+ * var.h: #include "exvar.h" for type checking.
+ * sort.c (wcomp): Initialize local variable prechar.
+ * kp.c (KP_init): Use kpse_set_program_name() because
+ kpse_set_progname() is deprecated since ages and no longer
+ exported from kpathsea.
+
+ FIXME: Is this correct?
+ * exvar.h (atama, page_compositor, page_precedence): Change type
+ from 'unsigned char' to 'char' as defined in var.h.
+
+ FIXME: Is this correct?
+ * convert.c (dicread): Add 'return 0' at end.
+
+ Avoid compiler warnings.
+ * ANSI C function prototypes and definitions.
+ * Declare functions as static, skip compilation of unused ones.
+ * Declare various function param or result, struct member, and
+ local or global var strings as const.
+
2010-04-12 Peter Breitenlohner <peb@mppmu.mpg.de>
* Makefile.am (EXTRA_DIST): Add indexsty, mendex.doc.
diff --git a/Build/source/texk/mendexk/convert.c b/Build/source/texk/mendexk/convert.c
index 30455e4d6fb..03959bcf8ff 100644
--- a/Build/source/texk/mendexk/convert.c
+++ b/Build/source/texk/mendexk/convert.c
@@ -23,7 +23,7 @@ unsigned char dic[2][50];
struct dictionary *dictable,*envdic;
int dlines=0,elines=0;
-int dicvalread(char *filename, struct dictionary *dicval, int line);
+static int dicvalread(const char *filename, struct dictionary *dicval, int line);
/* initialize kana table */
void initkanatable(void)
@@ -60,10 +60,11 @@ void initkanatable(void)
}
/* get dictionary */
-int dicread(char *filename)
+int dicread(const char *filename)
{
int i,ecount=0;
- char *envfile,buff[4096];
+ const char *envfile;
+ char buff[4096];
FILE *fp;
if (filename!=NULL) {
@@ -123,17 +124,19 @@ ENV:
verb_printf(efp,"...done.\n");
}
+
+ return 0; /* FIXME: is this right? */
}
+static int dcomp(const void *bf1, const void *bf2);
+
/* read dictionary file */
-int dicvalread(char *filename, struct dictionary *dicval, int line)
+static int dicvalread(const char *filename, struct dictionary *dicval, int line)
{
int i,j,k;
unsigned char buff[256];
FILE *fp;
- int dcomp();
-
fp=nkf_open(filename,"r");
for (i=0;i<line;i++) {
if (mfgets(buff,255,fp)==NULL) break;
@@ -171,8 +174,10 @@ int dicvalread(char *filename, struct dictionary *dicval, int line)
}
/* comp-function of dictionary sorting */
-int dcomp(struct dictionary *buff1, struct dictionary *buff2)
+static int dcomp(const void *bf1, const void *bf2)
{
+ const struct dictionary *buff1 = (const struct dictionary *) bf1;
+ const struct dictionary *buff2 = (const struct dictionary *) bf2;
int i;
for (i=0;i<50;i++) {
@@ -511,7 +516,9 @@ int pnumconv(char *page, int attr)
return cc;
}
+#if 0 /* unused */
int nbyte(unsigned char *str, int n)
{
return (unsigned int)str[n];
}
+#endif /* 0 */
diff --git a/Build/source/texk/mendexk/exvar.h b/Build/source/texk/mendexk/exvar.h
index 7190a233c72..a30a77220b4 100644
--- a/Build/source/texk/mendexk/exvar.h
+++ b/Build/source/texk/mendexk/exvar.h
@@ -29,6 +29,6 @@ extern char symhead_positive[2048],symhead_negative[2048];
extern char numhead_positive[2048],numhead_negative[2048];
extern int symbol_flag;
extern int letter_head;
-extern unsigned char atama[2048];
-extern unsigned char page_compositor[2048],page_precedence[2048];
+extern char atama[2048];
+extern char page_compositor[2048],page_precedence[2048];
extern char character_order[2048];
diff --git a/Build/source/texk/mendexk/fread.c b/Build/source/texk/mendexk/fread.c
index 5737894d379..9cd5d322eeb 100644
--- a/Build/source/texk/mendexk/fread.c
+++ b/Build/source/texk/mendexk/fread.c
@@ -11,8 +11,8 @@
#define BUFSIZE 65535
-int getestr(unsigned char *buff, unsigned char *estr);
-void chkpageattr(struct page *p);
+static int getestr(unsigned char *buff, unsigned char *estr);
+static void chkpageattr(struct page *p);
/* read idx file */
int idxread(char *filename, int start)
@@ -453,7 +453,7 @@ LOOP:
}
/* pic up encap string */
-int getestr(unsigned char *buff, unsigned char *estr)
+static int getestr(unsigned char *buff, unsigned char *estr)
{
int i,nest=0;
@@ -486,7 +486,7 @@ int getestr(unsigned char *buff, unsigned char *estr)
return -1;
}
-void chkpageattr(struct page *p)
+static void chkpageattr(struct page *p)
{
int i,j,cc=0;
diff --git a/Build/source/texk/mendexk/kana.h b/Build/source/texk/mendexk/kana.h
index 3c6822a9212..e83f4a35fe7 100644
--- a/Build/source/texk/mendexk/kana.h
+++ b/Build/source/texk/mendexk/kana.h
@@ -1,3 +1,5 @@
+#include "exkana.h"
+
unsigned char AKASATANA[]={
0xa4,0xa2, /* дв */
0xa4,0xab, /* дл */
diff --git a/Build/source/texk/mendexk/kp.c b/Build/source/texk/mendexk/kp.c
index 8ca6c7c461f..efc3823e37b 100644
--- a/Build/source/texk/mendexk/kp.c
+++ b/Build/source/texk/mendexk/kp.c
@@ -6,10 +6,9 @@
#include "kp.h"
int
-KP_init(prog)
- char *prog;
+KP_init(char *prog)
{
- kpse_set_progname(prog);
+ kpse_set_program_name(prog, "mendexk");
return 0;
}
@@ -19,10 +18,9 @@ KP_init(prog)
char *var: name of variable.
char *def_val: default value.
*/
-char *KP_get_value(var,def_val)
- char *var,*def_val;
+const char *KP_get_value(const char *var, const char *def_val)
{
- char *p = kpse_var_value(var);
+ const char *p = kpse_var_value(var);
return p ? p : def_val;
}
@@ -36,10 +34,9 @@ char *KP_get_value(var,def_val)
char *cnf: name of variable in `texmf.cnf'.
char *def_val: default value.
*/
-char *KP_get_value(env,cnf,def_val)
- char *env,*cnf,*def_val;
+const char *KP_get_value(const char *env, const char *cnf, const char *def_val)
{
- char *val;
+ const char *val;
char *cnf_val,*env_val;
val = def_val ? def_val : "";
@@ -49,36 +46,36 @@ char *KP_get_value(env,cnf,def_val)
if (cnf_val) val = kpse_expand_default(cnf_val,val);
if (env_val) val = kpse_expand_default(env_val,val);
- return val[0] ? val : ((cnf_val || env_val) ? val : (char *)0);
+ return val[0] ? val : ((cnf_val || env_val) ? val : NULL);
}
#endif
+#ifdef KPATHSEA3
/* KP_get_path(char *var, char *def_val)
ARGUMENTS:
char *var: name of variable.
char *def_val: default value.
*/
-char *KP_get_path(var,def_val)
- char *var,*def_val;
+static const char *KP_get_path(const char *var, const char *def_val)
{
char avar[50];
- char *p;
+ const char *p;
strcpy(avar, "${");
strcat(avar, var);
strcat(avar, "}");
p = kpse_path_expand(avar);
return (p && *p) ? p : def_val;
}
+#endif
/*
*/
-int KP_entry_filetype(info)
- KpathseaSupportInfo *info;
+int KP_entry_filetype(KpathseaSupportInfo *info)
{
#ifdef KPATHSEA3
info->path = KP_get_path(info->var_name,info->path);
#else
- char *path;
+ const char *path;
path = KP_get_value(info->var_name,info->var_name,info->path);
info->path = kpse_path_expand(path);
#endif
@@ -90,9 +87,7 @@ int KP_entry_filetype(info)
KpathseaSupportInfo *info: Informations about the type of files.
char *name: Name of file.
*/
-char *KP_find_file(info,name)
- KpathseaSupportInfo *info;
- char *name;
+const char *KP_find_file(KpathseaSupportInfo *info, const char *name)
{
char *ret;
ret = kpse_path_search(info->path,name,1);
diff --git a/Build/source/texk/mendexk/kp.h b/Build/source/texk/mendexk/kp.h
index f304b2c2542..3f4ba5880b2 100644
--- a/Build/source/texk/mendexk/kp.h
+++ b/Build/source/texk/mendexk/kp.h
@@ -3,15 +3,18 @@
#define KSUPPORT_H_INCLUDED
#ifdef KPATHSEA
typedef struct {
- char *var_name;
- char *path;
- char *suffix;
+ const char *var_name;
+ const char *path;
+ const char *suffix;
} KpathseaSupportInfo;
-extern int KP_init();
-extern int KP_entry_filetype();
-extern char *KP_find_file();
-extern char *KP_get_value();
-extern char *KP_get_path();
+extern int KP_init(char *);
+extern int KP_entry_filetype(KpathseaSupportInfo *);
+extern const char *KP_find_file(KpathseaSupportInfo *, const char *);
+#ifdef KPATHSEA3
+extern const char *KP_get_value(const char *, const char *);
+#else
+extern const char *KP_get_value(const char *, const char *, const char *);
+#endif
#endif /* KPATHSEA */
#endif /* ! KSUPPORT_H_INCLUDED */
diff --git a/Build/source/texk/mendexk/main.c b/Build/source/texk/mendexk/main.c
index 9fac729869c..7da7f7c9721 100644
--- a/Build/source/texk/mendexk/main.c
+++ b/Build/source/texk/mendexk/main.c
@@ -31,7 +31,7 @@ KpathseaSupportInfo kp_ist,kp_dict;
int main(int argc, char **argv)
{
int i,j,cc=0,startpagenum=-1,ecount=0;
- char *envbuff;
+ const char *envbuff;
set_enc_string(NULL, "EUC");
#ifdef KPATHSEA
diff --git a/Build/source/texk/mendexk/mendex.h b/Build/source/texk/mendexk/mendex.h
index 4b684880d14..da931e5422b 100644
--- a/Build/source/texk/mendexk/mendex.h
+++ b/Build/source/texk/mendexk/mendex.h
@@ -18,10 +18,10 @@ struct index {
void initkanatable(void);
int convert(unsigned char *buff1, unsigned char *buff2);
int pnumconv(char *page, int attr);
-int dicread(char *filename);
+int dicread(const char *filename);
/* pageread.c */
-int lastpage(char *filename);
+int lastpage(const char *filename);
/* sort.c */
void wsort(struct index *ind, int num);
@@ -33,7 +33,7 @@ int japanese(unsigned char *buff);
int chkcontinue(struct page *p, int num);
/* styfile.c */
-void styread(char *filename);
+void styread(const char *filename);
/* fread.c */
char *mfgets(char *buf, int byte, FILE *fp);
diff --git a/Build/source/texk/mendexk/pageread.c b/Build/source/texk/mendexk/pageread.c
index 9c231690621..41c65de14c1 100644
--- a/Build/source/texk/mendexk/pageread.c
+++ b/Build/source/texk/mendexk/pageread.c
@@ -2,8 +2,10 @@
#include <stdlib.h>
#include <string.h>
+#include "mendex.h"
+
/* checking last page */
-int lastpage(char *filename)
+int lastpage(const char *filename)
{
int i,cc,num= -1;
char logfile[32],numbuff[16];
diff --git a/Build/source/texk/mendexk/sort.c b/Build/source/texk/mendexk/sort.c
index 169dfbb78c0..39d2f19160c 100644
--- a/Build/source/texk/mendexk/sort.c
+++ b/Build/source/texk/mendexk/sort.c
@@ -62,7 +62,7 @@ BREAK:
/* compare for sorting index */
static int wcomp(const void *p, const void *q)
{
- int i,j,prechar;
+ int i, j, prechar = 0;
const struct index *index1 = p, *index2 = q;
scount++;
diff --git a/Build/source/texk/mendexk/styfile.c b/Build/source/texk/mendexk/styfile.c
index 2e26cef8896..ccc2db238c9 100644
--- a/Build/source/texk/mendexk/styfile.c
+++ b/Build/source/texk/mendexk/styfile.c
@@ -15,16 +15,16 @@ extern KpathseaSupportInfo kp_ist;
FILE *fp;
-void convline(char *buff1, int start, char *buff2);
-int scompare(char *buff1, char *buff2);
-int getparam(char *buff, char *paraname, char *param);
-int getparachar(char *buff, char *paraname, char *param);
-size_t sstrlen(const char *buff);
-int sstrcmp(const char *s1, const char *s2);
-int sstrncmp(const char *s1, const char *s2, size_t len);
+static void convline(char *buff1, int start, char *buff2);
+static int scompare(char *buff1, const char *buff2);
+static int getparam(char *buff, const char *paraname, char *param);
+static int getparachar(char *buff, const char *paraname, char *param);
+static size_t sstrlen(const char *buff);
+static int sstrcmp(const char *s1, const char *s2);
+static int sstrncmp(const char *s1, const char *s2, size_t len);
/* read style file */
-void styread(char *filename)
+void styread(const char *filename)
{
int i,cc;
char buff[4096];
@@ -127,7 +127,7 @@ void styread(char *filename)
}
/* analize string parameter of style file */
-void convline(char *buff1, int start, char *buff2)
+static void convline(char *buff1, int start, char *buff2)
{
int i,j,cc;
@@ -172,7 +172,7 @@ void convline(char *buff1, int start, char *buff2)
}
/* compare strings */
-int scompare(char *buff1, char *buff2)
+static int scompare(char *buff1, const char *buff2)
{
int i;
@@ -197,7 +197,7 @@ int scompare(char *buff1, char *buff2)
}
/* get string of style patameter */
-int getparam(char *buff, char *paraname, char *param)
+static int getparam(char *buff, const char *paraname, char *param)
{
int cc;
@@ -210,7 +210,7 @@ int getparam(char *buff, char *paraname, char *param)
}
/* get character of style parameter */
-int getparachar(char *buff, char *paraname, char *param)
+static int getparachar(char *buff, const char *paraname, char *param)
{
int j,cc;
@@ -233,20 +233,20 @@ int getparachar(char *buff, char *paraname, char *param)
return 0;
}
-size_t sstrlen(const char *s)
+static size_t sstrlen(const char *s)
{
if (s == NULL) return 0;
return strlen(s);
}
-int sstrcmp(const char *s1, const char *s2)
+static int sstrcmp(const char *s1, const char *s2)
{
if (s1 == NULL) return -1;
if (s2 == NULL) return 1;
return strcmp(s1, s2);
}
-int sstrncmp(const char *s1, const char *s2, size_t len)
+static int sstrncmp(const char *s1, const char *s2, size_t len)
{
if (s1 == NULL) return -1;
if (s2 == NULL) return 1;
diff --git a/Build/source/texk/mendexk/var.h b/Build/source/texk/mendexk/var.h
index 2041ec48f51..9565dd791d0 100644
--- a/Build/source/texk/mendexk/var.h
+++ b/Build/source/texk/mendexk/var.h
@@ -1,3 +1,5 @@
+#include "exvar.h"
+
FILE *efp;
int lines,idxcount,acc=0,reject=0;