1) Const enough things to avoid warnings.

2) Cast ifdef_level to a size_t before comparing it to a ratio of size_ts.
   Ifdef_level should always be positive.
3) Complete prototype for chfont.
4) Cast some ptrdiff_ts to ints before using as a field width.
5) Avoid shadowing a local variable p with another local variable p.
This commit is contained in:
David Malone 2002-03-30 17:10:20 +00:00
parent bb9bc62f9a
commit 8c7e769852
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=93440
6 changed files with 31 additions and 30 deletions

View File

@ -72,7 +72,7 @@ static const char rcsid[] =
static void scan_profile(FILE *);
char *option_source = "?";
const char *option_source = "?";
/*
* N.B.: because of the way the table here is scanned, options whose names are
@ -81,7 +81,7 @@ char *option_source = "?";
* default value is the one actually assigned.
*/
struct pro {
char *p_name; /* name, eg -bl, -cli */
const char *p_name; /* name, eg -bl, -cli */
int p_type; /* type (int, bool, special) */
int p_default; /* the default value (if int) */
int p_special; /* depends on type */
@ -200,10 +200,10 @@ scan_profile(register FILE *f)
}
}
char *param_start;
const char *param_start;
static int
eqin(char *s1, char *s2)
eqin(const char *s1, const char *s2)
{
while (*s1) {
if (*s1++ != *s2++)

View File

@ -63,9 +63,9 @@ static const char rcsid[] =
static void bakcopy(void);
char *in_name = "Standard Input"; /* will always point to name of input
const char *in_name = "Standard Input"; /* will always point to name of input
* file */
char *out_name = "Standard Output"; /* will always point to name
const char *out_name = "Standard Output"; /* will always point to name
* of output file */
char bakfile[MAXPATHLEN] = "";
@ -89,7 +89,7 @@ main(int argc, char **argv)
int squest; /* when this is positive, we have seen a ?
* without the matching : in a <c>?<s>:<s>
* construct */
register char *t_ptr; /* used for copying tokens */
const char *t_ptr; /* used for copying tokens */
int type_code; /* the type of token, returned by lexi */
int last_else = 0; /* true iff last keyword was an else */
@ -267,7 +267,7 @@ main(int argc, char **argv)
ps.ind_level = ps.i_l_follow = col / ps.ind_size;
}
if (troff) {
register char *p = in_name,
const char *p = in_name,
*beg = in_name;
while (*p)
@ -574,7 +574,7 @@ main(int argc, char **argv)
e_code += strlen(e_code);
}
else {
char *res = token;
const char *res = token;
if (ps.in_decl && !ps.block_init) { /* if this is a unary op
* in a declaration, we
@ -600,7 +600,7 @@ main(int argc, char **argv)
if (ps.want_blank)
*e_code++ = ' ';
{
char *res = token;
const char *res = token;
if (troff)
switch (token[0]) {
@ -1077,7 +1077,7 @@ main(int argc, char **argv)
while ((c = getc(input)) == '\n');
ungetc(c, input);
}
if (ifdef_level < sizeof state_stack / sizeof state_stack[0]) {
if ((size_t)ifdef_level < sizeof(state_stack)/sizeof(state_stack[0])) {
match_state[ifdef_level].tos = -1;
state_stack[ifdef_level++] = ps;
}
@ -1143,7 +1143,7 @@ bakcopy(void)
int n,
bakchn;
char buff[8 * 1024];
register char *p;
const char *p;
/* construct file name .Bfile */
for (p = in_name; *p; p++); /* skip to end of string */

View File

@ -33,13 +33,13 @@ int compute_code_target(void);
int compute_label_target(void);
int count_spaces(int, char *);
int lexi(void);
void diag2(int, char *);
void diag3(int, char *, int);
void diag4(int, char *, int, int);
void diag2(int, const char *);
void diag3(int, const char *, int);
void diag4(int, const char *, int, int);
void dump_line(void);
void fill_buffer(void);
void parse(int);
void parsefont(struct fstate *, char *);
void parsefont(struct fstate *, const char *);
void pr_comment(void);
void set_defaults(void);
void set_option(char *);

View File

@ -199,7 +199,7 @@ struct fstate {
char size;
int allcaps:1;
};
char *chfont();
char *chfont(struct fstate *, struct fstate *, char *);
struct fstate
keywordf, /* keyword font */

View File

@ -126,9 +126,9 @@ dump_line(void)
s++;
if (s < e_lab)
fprintf(output, s[0]=='/' && s[1]=='*' ? "\t%.*s" : "\t/* %.*s */",
e_lab - s, s);
(int)(e_lab - s), s);
}
else fprintf(output, "%.*s", e_lab - s_lab, s_lab);
else fprintf(output, "%.*s", (int)(e_lab - s_lab), s_lab);
cur_col = count_spaces(cur_col, s_lab);
}
else
@ -539,7 +539,7 @@ count_spaces(int current, char *buffer)
int found_err;
void
diag4(int level, char *msg, int a, int b)
diag4(int level, const char *msg, int a, int b)
{
if (level)
found_err = 1;
@ -556,7 +556,7 @@ diag4(int level, char *msg, int a, int b)
}
void
diag3(int level, char *msg, int a)
diag3(int level, const char *msg, int a)
{
if (level)
found_err = 1;
@ -573,7 +573,7 @@ diag3(int level, char *msg, int a)
}
void
diag2(int level, char *msg)
diag2(int level, const char *msg)
{
if (level)
found_err = 1;
@ -627,9 +627,9 @@ chfont(struct fstate *of, struct fstate *nf, char *s)
}
void
parsefont(struct fstate *f, char *s0)
parsefont(struct fstate *f, const char *s0)
{
register char *s = s0;
const char *s = s0;
int sizedelta = 0;
bzero(f, sizeof *f);

View File

@ -53,6 +53,7 @@ static const char rcsid[] =
#include <string.h>
#include "indent_globs.h"
#include "indent_codes.h"
#include "indent.h"
#define alphanum 1
#define opchar 3
@ -60,7 +61,7 @@ static const char rcsid[] =
void fill_buffer(void);
struct templ {
char *rwd;
const char *rwd;
int rwcode;
};
@ -149,7 +150,7 @@ lexi(void)
/*
* we have a character or number
*/
register char *j; /* used for searching thru list of
const char *j; /* used for searching thru list of
*
* reserved words */
register struct templ *p;
@ -249,15 +250,15 @@ lexi(void)
* This loop will check if the token is a keyword.
*/
for (p = specials; (j = p->rwd) != 0; p++) {
register char *p = s_token; /* point at scanned token */
if (*j++ != *p++ || *j++ != *p++)
const char *q = s_token; /* point at scanned token */
if (*j++ != *q++ || *j++ != *q++)
continue; /* This test depends on the fact that
* identifiers are always at least 1 character
* long (ie. the first two bytes of the
* identifier are always meaningful) */
if (p[-1] == 0)
if (q[-1] == 0)
break; /* If its a one-character identifier */
while (*p++ == *j)
while (*q++ == *j)
if (*j++ == 0)
goto found_keyword; /* I wish that C had a multi-level
* break... */