cleanup scoping fixes part of pr#1859 from Juergen Hannken-Illjes

This commit is contained in:
chopps 1995-12-29 20:33:49 +00:00
parent 3a89082ff4
commit 1eb383737f
39 changed files with 135 additions and 135 deletions

View File

@ -89,14 +89,14 @@ int main(int argc, char **argv)
param.comma_depth = DEFAULT_COMMA_DEPTH;
param.desc_depth = DEFAULT_DESC_DEPTH;
param.body_depth = DEFAULT_BODY_DEPTH;
for (int i = 1; i < argc && argv[i][0] == '-'; i++) {
int i; for (i = 1; i < argc && argv[i][0] == '-'; i++) {
if (argv[i][1] == '-' && argv[i][2] == '\0') {
i++;
break;
}
if (i + 1 >= argc)
usage();
for (int j = 0;; j++) {
int j; for (j = 0;; j++) {
if (j >= sizeof(param_table)/sizeof(param_table[0]))
fatal("parameter `%1' not recognized", argv[i] + 1);
if (strcmp(param_table[j].name, argv[i] + 1) == 0)

View File

@ -276,7 +276,7 @@ static void define_extensible_string(char *delim, int uid,
printf(".ds " DELIM_STRING "\n");
delimiter *d = delim_table;
int delim_len = strlen(delim);
for (int i = 0; i < DELIM_TABLE_SIZE; i++, d++)
int i; for (i = 0; i < DELIM_TABLE_SIZE; i++, d++)
if (strncmp(delim, d->name, delim_len) == 0
&& (left_or_right & d->flags) != 0)
break;

View File

@ -251,7 +251,7 @@ static struct {
void init_table(const char *device)
{
for (int i = 0; i < sizeof(token_table)/sizeof(token_table[0]); i++) {
int i; for (i = 0; i < sizeof(token_table)/sizeof(token_table[0]); i++) {
definition *def = new definition;
def->is_macro = 0;
def->tok = token_table[i].token;
@ -472,7 +472,7 @@ argument_macro_input::argument_macro_input(const char *body, int ac,
char **av, input *x)
: input(x), argc(ac), ap(0)
{
for (int i = 0; i < argc; i++)
int i; for (i = 0; i < argc; i++)
argv[i] = av[i];
p = s = strsave(body);
int j = 0;
@ -687,7 +687,7 @@ void interpolate_macro_with_args(const char *body)
{
char *argv[9];
int argc = 0;
for (int i = 0; i < 9; i++)
int i; for (i = 0; i < 9; i++)
argv[i] = 0;
int level = 0;
int c;

View File

@ -159,7 +159,7 @@ int list_box::compute_metrics(int style)
have_simple = list.p[i]->is_simple();
if (have_simple) {
printf(".nr " WIDTH_FORMAT " +\\w" DELIMITER_CHAR, uid);
for (int i = 0; i < list.len; i++)
for (i = 0; i < list.len; i++)
if (list.p[i]->is_simple())
list.p[i]->output();
printf(DELIMITER_CHAR "\n");
@ -174,7 +174,7 @@ int list_box::compute_metrics(int style)
void list_box::compute_sublist_width(int n)
{
int total_spacing = 0;
for (int i = 1; i < n + 1 && i < list.len; i++)
int i; for (i = 1; i < n + 1 && i < list.len; i++)
total_spacing += compute_spacing(is_script, list.p[i-1]->spacing_type,
list.p[i]->spacing_type);
printf(".nr " TEMP_REG " %dM", total_spacing);
@ -186,7 +186,7 @@ void list_box::compute_sublist_width(int n)
have_simple = list.p[i]->is_simple();
if (have_simple) {
printf("+\\w" DELIMITER_CHAR);
for (int i = 0; i < n; i++)
for (i = 0; i < n; i++)
if (list.p[i]->is_simple())
list.p[i]->output();
printf(DELIMITER_CHAR);

View File

@ -305,7 +305,7 @@ void dvi_printer::set_char(int index, font *f, const environment *env, int w)
if (env->size != cur_point_size || f != cur_font) {
cur_font = f;
cur_point_size = env->size;
for (int i = 0;; i++) {
int i; for (i = 0;; i++) {
if (i >= FONTS_MAX) {
fatal("too many output fonts required");
}

View File

@ -284,7 +284,7 @@ int main(int argc, char **argv)
commands[TROFF_INDEX].append_arg("-T", device);
commands[EQN_INDEX].append_arg("-T", device);
for (int first_index = 0; first_index < TROFF_INDEX; first_index++)
int first_index; for (first_index = 0; first_index < TROFF_INDEX; first_index++)
if (commands[first_index].get_name() != 0)
break;
if (optind < argc) {
@ -352,7 +352,7 @@ void handle_unknown_desc_command(const char *command, const char *arg,
void print_commands()
{
for (int last = SPOOL_INDEX; last >= 0; last--)
int last; for (last = SPOOL_INDEX; last >= 0; last--)
if (commands[last].get_name() != 0)
break;
for (int i = 0; i <= last; i++)
@ -466,7 +466,7 @@ void append_arg_to_string(const char *arg, string &str)
str += ' ';
int needs_quoting = 0;
int contains_single_quote = 0;
for (const char *p = arg; *p != '\0'; p++)
const char *p; for (p = arg; *p != '\0'; p++)
switch (*p) {
case ';':
case '&':

View File

@ -172,7 +172,7 @@ ps_output &ps_output::put_delimiter(char c)
ps_output &ps_output::put_string(const char *s, int n)
{
int len = 0;
for (int i = 0; i < n; i++) {
int i; for (i = 0; i < n; i++) {
char c = s[i];
if (isascii(c) && isprint(c)) {
if (c == '(' || c == ')' || c == '\\')
@ -646,7 +646,7 @@ const char *const WS = " \t\n\r";
void ps_printer::define_encoding(const char *encoding, int encoding_index)
{
char *vec[256];
for (int i = 0; i < 256; i++)
int i; for (i = 0; i < 256; i++)
vec[i] = 0;
char *path;
FILE *fp = font::open_file(encoding, &path);
@ -1193,7 +1193,7 @@ void ps_printer::special(char *arg, const environment *env)
"invis", &ps_printer::do_invis,
"endinvis", &ps_printer::do_endinvis,
};
for (char *p = arg; *p == ' ' || *p == '\n'; p++)
char *p; for (p = arg; *p == ' ' || *p == '\n'; p++)
;
char *tag = p;
for (; *p != '\0' && *p != ':' && *p != ' ' && *p != '\n'; p++)
@ -1340,7 +1340,7 @@ void ps_printer::do_import(char *arg, const environment *env)
flush_sbuf();
while (*arg == ' ' || *arg == '\n')
arg++;
for (char *p = arg; *p != '\0' && *p != ' ' && *p != '\n'; p++)
char *p; for (p = arg; *p != '\0' && *p != ' ' && *p != '\n'; p++)
;
if (*p != '\0')
*p++ = '\0';

View File

@ -121,7 +121,7 @@ resource *resource_manager::lookup_resource(resource_type type,
string &version,
unsigned revision)
{
for (resource *r = resource_list; r; r = r->next)
resource *r; for (r = resource_list; r; r = r->next)
if (r->type == type
&& r->name == name
&& r->version == version
@ -137,7 +137,7 @@ resource *resource_manager::lookup_resource(resource_type type,
resource *resource_manager::lookup_font(const char *name)
{
for (resource *r = resource_list; r; r = r->next)
resource *r; for (r = resource_list; r; r = r->next)
if (r->type == RESOURCE_FONT
&& strlen(name) == r->name.length()
&& memcmp(name, r->name.contents(), r->name.length()) == 0)
@ -159,14 +159,14 @@ typedef resource *Presource; // Work around g++ bug.
void resource_manager::document_setup(ps_output &out)
{
int nranks = 0;
for (resource *r = resource_list; r; r = r->next)
resource *r; for (r = resource_list; r; r = r->next)
if (r->rank >= nranks)
nranks = r->rank + 1;
if (nranks > 0) {
// Sort resource_list in reverse order of rank.
Presource *head = new Presource[nranks + 1];
Presource **tail = new Presource *[nranks + 1];
for (int i = 0; i < nranks + 1; i++) {
int i; for (i = 0; i < nranks + 1; i++) {
head[i] = 0;
tail[i] = &head[i];
}
@ -510,7 +510,7 @@ resource *resource_manager::read_resource_arg(const char **ptr)
error("missing resource type");
return 0;
}
for (int ri = 0; ri < NRESOURCES; ri++)
int ri; for (ri = 0; ri < NRESOURCES; ri++)
if (strlen(resource_table[ri]) == *ptr - name
&& memcmp(resource_table[ri], name, *ptr - name) == 0)
break;
@ -833,7 +833,7 @@ static unsigned parse_extensions(const char *ptr)
do {
++ptr;
} while (*ptr != '\0' && !white_space(*ptr));
for (int i = 0; i < NEXTENSIONS; i++)
int i; for (i = 0; i < NEXTENSIONS; i++)
if (strlen(extension_table[i]) == ptr - name
&& memcmp(extension_table[i], name, ptr - name) == 0) {
flags |= (1 << i);
@ -932,7 +932,7 @@ void resource_manager::process_file(int rank, FILE *fp, const char *filename,
if (buf[0] == '%') {
if (buf[1] == '%') {
const char *ptr;
for (int i = 0; i < NCOMMENTS; i++)
int i; for (i = 0; i < NCOMMENTS; i++)
if (ptr = matches_comment(buf, comment_table[i].name)) {
copy_this_line
= (this->*(comment_table[i].proc))(ptr, rank, fp, outfp);
@ -955,7 +955,7 @@ void resource_manager::process_file(int rank, FILE *fp, const char *filename,
had_language_level_comment = 1;
}
else {
for (int i = 0; i < NHEADER_COMMENTS; i++)
for (i = 0; i < NHEADER_COMMENTS; i++)
if (matches_comment(buf, header_comment_table[i])) {
interesting = 1;
break;
@ -1028,7 +1028,7 @@ static void print_ps_string(const string &s, FILE *outfp)
return;
}
int level = 0;
for (int i = 0; i < len; i++)
int i; for (i = 0; i < len; i++)
if (str[i] == '(')
level++;
else if (str[i] == ')' && --level < 0)

View File

@ -218,7 +218,7 @@ void tty_printer::add_char(unsigned char c, int h, int v, unsigned char mode)
// characters before normal characters at each hpos, and otherwise
// in order of occurrence.
for (glyph **pp = lines + (vpos - 1); *pp; pp = &(*pp)->next)
glyph **pp; for (pp = lines + (vpos - 1); *pp; pp = &(*pp)->next)
if (int((*pp)->hpos) < hpos
|| ((*pp)->hpos == hpos && (*pp)->draw_mode() >= g->draw_mode()))
break;
@ -270,7 +270,7 @@ void tty_printer::end_page(int page_length)
if (page_length % font::vert != 0)
error("vertical position at end of page not multiple of vertical resolution");
int lines_per_page = page_length / font::vert;
for (int last_line = nlines; last_line > 0; last_line--)
int last_line; for (last_line = nlines; last_line > 0; last_line--)
if (lines[last_line - 1])
break;
#if 0

View File

@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along
with groff; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: ptable.h,v 1.2 1993/08/02 17:43:38 mycroft Exp $
$Id: ptable.h,v 1.3 1995/12/29 20:34:32 chopps Exp $
*/
#include <assert.h>
@ -96,7 +96,7 @@ void PTABLE(T)::define(const char *key, T *val) \
{ \
assert(key != 0); \
unsigned long h = hash_string(key); \
for (unsigned n = unsigned(h % size); \
unsigned n; for (n = unsigned(h % size); \
v[n].key != 0; \
n = (n == 0 ? size - 1 : n - 1)) \
if (strcmp(v[n].key, key) == 0) { \
@ -116,7 +116,7 @@ void PTABLE(T)::define(const char *key, T *val) \
if (oldv[i].val == 0) \
a_delete oldv[i].key; \
else { \
for (unsigned j = unsigned(hash_string(oldv[i].key) % size); \
unsigned j; for (j = unsigned(hash_string(oldv[i].key) % size); \
v[j].key != 0; \
j = (j == 0 ? size - 1 : j - 1)) \
; \

View File

@ -242,7 +242,7 @@ int main(int argc, char **argv)
string path;
int lineno = 1;
for (;;) {
for (int c = getc(fp); c != '\n' && c != EOF; c = getc(fp)) {
int c; for (c = getc(fp); c != '\n' && c != EOF; c = getc(fp)) {
if (c == '\0')
error_with_file_and_line(foption, lineno,
"nul character in pathname ignored");

View File

@ -506,7 +506,7 @@ const int *index_search_item::search(const char *ptr, int length,
return first_list;
if (*second_list < 0)
return second_list;
for (const int *p = first_list; *p >= 0; p++)
const int *p; for (p = first_list; *p >= 0; p++)
;
int len = p - first_list;
for (p = second_list; *p >= 0; p++)
@ -586,7 +586,7 @@ void index_search_item::read_common_words_file()
void index_search_item::add_out_of_date_file(int fd, const char *filename,
int fid)
{
for (search_item **pp = &out_of_date_files; *pp; pp = &(*pp)->next)
search_item **pp; for (pp = &out_of_date_files; *pp; pp = &(*pp)->next)
if ((*pp)->is_named(filename))
return;
*pp = make_linear_search_item(fd, filename, fid);

View File

@ -58,7 +58,7 @@ static map_init the_map_init;
map_init::map_init()
{
for (int i = 0; i < 256; i++)
int i; for (i = 0; i < 256; i++)
map[i] = csalnum(i) ? cmlower(i) : '\0';
for (i = 0; i < 256; i++) {
if (cslower(i)) {
@ -175,7 +175,7 @@ static const char *skip_field(const char *end, const char *p)
if (*p++ == '\n') {
if (p == end || *p == '%')
break;
for (const char *q = p; *q == ' ' || *q == '\t'; q++)
const char *q; for (q = p; *q == ' ' || *q == '\t'; q++)
;
if (*q == '\n')
break;
@ -190,7 +190,7 @@ static const char *find_end(const char *bufend, const char *p)
if (*p++ == '\n') {
if (p == bufend)
break;
for (const char *q = p; *q == ' ' || *q == '\t'; q++)
const char *q; for (q = p; *q == ' ' || *q == '\t'; q++)
;
if (*q == '\n')
break;
@ -262,7 +262,7 @@ int linear_searcher::check_match(const char *buf, const char *bufend,
*start = p + 1;
return 1;
}
for (const char *q = p - 1; *q == ' ' || *q == '\t'; q--)
const char *q; for (q = p - 1; *q == ' ' || *q == '\t'; q--)
;
if (*q == '\n') {
if (start)
@ -392,7 +392,7 @@ int linear_searcher::search(const char *buffer, const char *bufend,
if (!found)
break;
const char *refend = find_end(bufend, found + keys[0]->length());
for (int i = 1; i < nkeys; i++)
int i; for (i = 1; i < nkeys; i++)
if (!search_and_check(keys[i], refstart, refend))
break;
if (i >= nkeys) {

View File

@ -62,7 +62,7 @@ void search_list::add_file(const char *filename, int silent)
p = make_linear_search_item(fd, filename, next_fid);
}
if (p) {
for (search_item **pp = &list; *pp; pp = &(*pp)->next)
search_item **pp; for (pp = &list; *pp; pp = &(*pp)->next)
;
*pp = p;
next_fid = p->next_filename_id();

View File

@ -268,7 +268,7 @@ void do_file(const char *filename)
int n;
int *p = 0;
int szp = 0;
for (int np = 0; possibly_get_integer(&n); np++) {
int np; for (np = 0; possibly_get_integer(&n); np++) {
if (np >= szp) {
if (szp == 0) {
szp = 16;
@ -290,7 +290,7 @@ void do_file(const char *filename)
env.hpos += p[0];
}
else {
for (int i = 0; i < np/2; i++) {
int i; for (i = 0; i < np/2; i++) {
env.hpos += p[i*2];
env.vpos += p[i*2 + 1];
}

View File

@ -64,7 +64,7 @@ void printer::load_font(int n, const char *nm)
if (n >= nfonts)
nfonts = n + 1;
font_table = new font *[nfonts];
for (int i = 0; i < old_nfonts; i++)
int i; for (i = 0; i < old_nfonts; i++)
font_table[i] = old_font_table[i];
for (i = old_nfonts; i < nfonts; i++)
font_table[i] = 0;

View File

@ -246,7 +246,7 @@ int font::get_width(int c, int point_size)
if (!widths_cache)
widths_cache = new font_widths_cache(point_size, ch_size);
else if (widths_cache->point_size != point_size) {
for (font_widths_cache **p = &widths_cache; *p; p = &(*p)->next)
font_widths_cache **p; for (p = &widths_cache; *p; p = &(*p)->next)
if ((*p)->point_size == point_size)
break;
if (*p) {
@ -398,7 +398,7 @@ void font::extend_ch()
void font::compact()
{
for (int i = nindices - 1; i >= 0; i--)
int i; for (i = nindices - 1; i >= 0; i--)
if (ch_index[i] >= 0)
break;
i++;
@ -728,7 +728,7 @@ int font::load_desc()
while (t.next()) {
char *p = strtok(t.buf, WS);
int found = 0;
for (int i = 0; !found && i < sizeof(table)/sizeof(table[0]); i++)
int i; for (i = 0; !found && i < sizeof(table)/sizeof(table[0]); i++)
if (strcmp(table[i].command, p) == 0)
found = 1;
if (found) {
@ -764,7 +764,7 @@ int font::load_desc()
return 0;
}
font_name_table = (const char **)new char *[nfonts+1];
for (int i = 0; i < nfonts; i++) {
for (i = 0; i < nfonts; i++) {
p = strtok(0, WS);
while (p == 0) {
if (!t.next()) {
@ -830,7 +830,7 @@ int font::load_desc()
else if (strcmp("styles", p) == 0) {
int style_table_size = 5;
style_table = (const char **)new char *[style_table_size];
for (int j = 0; j < style_table_size; j++)
int j; for (j = 0; j < style_table_size; j++)
style_table[j] = 0;
int i = 0;
for (;;) {

View File

@ -45,7 +45,7 @@ int interpret_lf_args(const char *p)
change_lineno(ln);
return 1;
}
for (const char *q = p;
const char *q; for (q = p;
*q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
q++)
;

View File

@ -51,7 +51,7 @@ private:
character_indexer::character_indexer()
: next_index(0)
{
for (int i = 0; i < 256; i++)
int i; for (i = 0; i < 256; i++)
ascii_index[i] = -1;
for (i = 0; i < NSMALL; i++)
small_number_index[i] = -1;

View File

@ -44,7 +44,7 @@ static const unsigned table_sizes[] = {
unsigned next_ptable_size(unsigned n)
{
for (const unsigned *p = table_sizes; *p <= n; p++)
const unsigned *p; for (p = table_sizes; *p <= n; p++)
if (*p == 0)
fatal("cannot expand table");
return *p;

View File

@ -281,7 +281,7 @@ char *string::extract() const
char *p = ptr;
int n = len;
int nnuls = 0;
for (int i = 0; i < n; i++)
int i; for (i = 0; i < n; i++)
if (p[i] == '\0')
nnuls++;
char *q = new char[n + 1 - nnuls];

View File

@ -96,7 +96,7 @@ main(int argc, char **argv)
if (list.nfiles() == 0)
fatal("no databases");
int total_len = 0;
for (int i = optind; i < argc; i++)
int i; for (i = optind; i < argc; i++)
total_len += strlen(argv[i]);
total_len += argc - optind - 1 + 1; // for spaces and '\0'
char *buffer = new char[total_len];
@ -110,7 +110,7 @@ main(int argc, char **argv)
search_list_iterator iter(&list, buffer);
const char *start;
int len;
for (int count = 0; iter.next(&start, &len); count++) {
int count; for (count = 0; iter.next(&start, &len); count++) {
if (fwrite(start, 1, len, stdout) != len)
fatal("write error on stdout: %1", strerror(errno));
// Can happen for last reference in file.

View File

@ -106,7 +106,7 @@ main(int argc, char **argv)
search_list_iterator iter(&list, line);
const char *start;
int len;
for (int count = 0; iter.next(&start, &len); count++) {
int count; for (count = 0; iter.next(&start, &len); count++) {
if (fwrite(start, 1, len, stdout) != len)
fatal("write error on stdout: %1", strerror(errno));
// Can happen for last reference in file.

View File

@ -361,7 +361,7 @@ void interpolate_macro_with_args(const char *body)
{
char *argv[9];
int argc = 0;
for (int i = 0; i < 9; i++)
int i; for (i = 0; i < 9; i++)
argv[i] = 0;
int level = 0;
int c;

View File

@ -512,7 +512,7 @@ void object_list::append(object *obj)
void object_list::wrap_up_block(object_list *ol)
{
for (object *p = tail; p && p->type() != MARK_OBJECT; p = p->prev)
object *p; for (p = tail; p && p->type() != MARK_OBJECT; p = p->prev)
;
assert(p != 0);
ol->head = p->next;
@ -595,7 +595,7 @@ void graphic_object::add_text(text_item *t, int a)
{
aligned = a;
int len = 0;
for (text_item *p = t; p; p = p->next)
text_item *p; for (p = t; p; p = p->next)
len++;
if (len == 0)
text = 0;
@ -1341,7 +1341,7 @@ linear_object *object_spec::make_line(position *curpos, direction *dirp)
// Absolutise all movements
position endpos = startpos;
int nsegments = 0;
for (segment *s = segment_list; s; s = s->next, nsegments++)
segment *s; for (s = segment_list; s; s = s->next, nsegments++)
if (s->is_absolute)
endpos = s->pos;
else {
@ -1767,7 +1767,7 @@ void path::append(corner c)
void path::append(char *s)
{
for (string_list **p = &label_list; *p; p = &(*p)->next)
string_list **p; for (p = &label_list; *p; p = &(*p)->next)
;
*p = new string_list(s);
}

View File

@ -940,7 +940,7 @@ object_spec:
| object_spec text %prec TEXT
{
$$ = $1;
for (text_item **p = & $$->text; *p; p = &(*p)->next)
text_item **p; for (p = & $$->text; *p; p = &(*p)->next)
;
*p = new text_item($2.str, $2.filename, $2.lineno);
}
@ -948,7 +948,7 @@ object_spec:
{
$$ = $1;
if ($$->text) {
for (text_item *p = $$->text; p->next; p = p->next)
text_item *p; for (p = $$->text; p->next; p = p->next)
;
p->adj.h = LEFT_ADJUST;
}
@ -957,7 +957,7 @@ object_spec:
{
$$ = $1;
if ($$->text) {
for (text_item *p = $$->text; p->next; p = p->next)
text_item *p; for (p = $$->text; p->next; p = p->next)
;
p->adj.h = RIGHT_ADJUST;
}
@ -966,7 +966,7 @@ object_spec:
{
$$ = $1;
if ($$->text) {
for (text_item *p = $$->text; p->next; p = p->next)
text_item *p; for (p = $$->text; p->next; p = p->next)
;
p->adj.v = ABOVE_ADJUST;
}
@ -975,7 +975,7 @@ object_spec:
{
$$ = $1;
if ($$->text) {
for (text_item *p = $$->text; p->next; p = p->next)
text_item *p; for (p = $$->text; p->next; p = p->next)
;
p->adj.v = BELOW_ADJUST;
}
@ -1162,7 +1162,7 @@ nth_primitive:
ordinal object_type
{
int count = 0;
for (object *p = olist.head; p != 0; p = p->next)
object *p; for (p = olist.head; p != 0; p = p->next)
if (p->type() == $2 && ++count == $1) {
$$ = p;
break;
@ -1176,7 +1176,7 @@ nth_primitive:
| optional_ordinal_last object_type
{
int count = 0;
for (object *p = olist.tail; p != 0; p = p->prev)
object *p; for (p = olist.tail; p != 0; p = p->prev)
if (p->type() == $2 && ++count == $1) {
$$ = p;
break;

View File

@ -872,7 +872,7 @@ int reference::merge_labels_by_number(reference **v, int n, label_type type,
if (v[0]->get_number() != num + 1
|| v[1]->get_number() != num + 2)
return 0;
for (int i = 2; i < n; i++)
int i; for (i = 2; i < n; i++)
if (v[i]->get_number() != num + i + 1)
break;
result = get_label(type);
@ -945,7 +945,7 @@ label_info *lookup_label(const string &label)
label_table[i] = 0;
}
unsigned h = hash_string(label.contents(), label.length()) % label_table_size;
for (label_info **ptr = label_table + h;
label_info **ptr; for (ptr = label_table + h;
*ptr != 0;
(ptr == label_table)
? (ptr = label_table + label_table_size - 1)
@ -970,7 +970,7 @@ label_info *lookup_label(const string &label)
if (old_table[i]) {
unsigned h = hash_string(label_pool.contents() + old_table[i]->start,
old_table[i]->length);
for (label_info **p = label_table + (h % label_table_size);
label_info **p; for (p = label_table + (h % label_table_size);
*p != 0;
(p == label_table)
? (p = label_table + label_table_size - 1)
@ -1165,7 +1165,7 @@ int reference::get_nauthors() const
{
if (nauthors < 0) {
const char *dummy;
for (int na = 0; get_author(na, &dummy) != 0; na++)
int na; for (na = 0; get_author(na, &dummy) != 0; na++)
;
((reference *)this)->nauthors = na;
}

View File

@ -54,7 +54,7 @@ reference::reference(const char *start, int len, reference_id *ridp)
: no(-1), field(0), nfields(0), h(0), merged(0), label_ptr(0),
computed_authors(0), last_needed_author(-1), nauthors(-1)
{
for (int i = 0; i < 256; i++)
int i; for (i = 0; i < 256; i++)
field_index[i] = NULL_FIELD_INDEX;
if (ridp)
rid = *ridp;
@ -199,7 +199,7 @@ void reference::insert_field(unsigned char c, string &s)
string *old_field = field;
field = new string[nfields + 1];
int pos = 0;
for (int i = 0; i < int(c); i++)
int i; for (i = 0; i < int(c); i++)
if (field_index[i] != NULL_FIELD_INDEX)
pos++;
for (i = 0; i < pos; i++)
@ -222,7 +222,7 @@ void reference::delete_field(unsigned char c)
return;
string *old_field = field;
field = new string[nfields - 1];
for (int i = 0; i < int(field_index[c]); i++)
int i; for (i = 0; i < int(field_index[c]); i++)
field[i].move(old_field[i]);
for (i = field_index[c]; i < nfields - 1; i++)
field[i].move(old_field[i + 1]);
@ -330,7 +330,7 @@ void sortify_title(const char *s, int len, string &key)
a < ae;
a = strchr(a, '\0') + 1)
if (first_word_len == strlen(a)) {
for (int j = 0; j < first_word_len; j++)
int j; for (j = 0; j < first_word_len; j++)
if (a[j] != cmlower(s[j]))
break;
if (j >= first_word_len) {
@ -395,7 +395,7 @@ void sortify_label(const char *s, int len, string &key)
{
const char *end = s + len;
for (;;) {
for (const char *ptr = s;
const char *ptr; for (ptr = s;
ptr < end && *ptr != SORT_SUB_SEP && *ptr != SORT_SUB_SUB_SEP;
ptr++)
;
@ -692,7 +692,7 @@ int join_fields(string &f)
const char *ptr = f.contents();
int len = f.length();
int nfield_seps = 0;
for (int j = 0; j < len; j++)
int j; for (j = 0; j < len; j++)
if (ptr[j] == FIELD_SEPARATOR)
nfield_seps++;
if (nfield_seps == 0)

View File

@ -179,7 +179,7 @@ int main(int argc, char **argv)
num = opt;
opt = 0;
}
for (const char *ptr = num; *ptr; ptr++)
const char *ptr; for (ptr = num; *ptr; ptr++)
if (!csdigit(*ptr)) {
error("bad character `%1' in argument to -f option", *ptr);
break;
@ -227,7 +227,7 @@ int main(int argc, char **argv)
break;
case 'a':
{
for (const char *ptr = ++opt; *ptr; ptr++)
const char *ptr; for (ptr = ++opt; *ptr; ptr++)
if (!csdigit(*ptr)) {
error("argument to `a' option not a number");
break;
@ -697,7 +697,7 @@ static unsigned store_reference(const string &str)
reference *ref = make_reference(str, &flags);
ref->compute_hash_code();
unsigned h = ref->hash();
for (reference **ptr = reference_hash_table + (h % hash_table_size);
reference **ptr; for (ptr = reference_hash_table + (h % hash_table_size);
*ptr != 0;
((ptr == reference_hash_table)
? (ptr = reference_hash_table + hash_table_size - 1)
@ -727,7 +727,7 @@ static unsigned store_reference(const string &str)
reference_hash_table[i] = 0;
for (i = 0; i < old_size; i++)
if (old_table[i]) {
for (reference **p = (reference_hash_table
reference **p; for (p = (reference_hash_table
+ (old_table[i]->hash() % hash_table_size));
*p;
((p == reference_hash_table)
@ -785,7 +785,7 @@ static void output_citation_group(reference **v, int n, label_type type,
for (int i = 1; i < n; i++) {
int num = v[i]->get_number();
reference *temp = v[i];
for (int j = i - 1; j >= 0 && v[j]->get_number() > num; j--)
int j; for (j = i - 1; j >= 0 && v[j]->get_number() > num; j--)
v[j + 1] = v[j];
v[j + 1] = temp;
}
@ -1213,7 +1213,7 @@ int next_size(int n)
16000057, 32000011, 64000031, 128000003, 0
};
for (const int *p = table_sizes; *p <= n && *p != 0; p++)
const int *p; for (p = table_sizes; *p <= n && *p != 0; p++)
;
assert(*p != 0);
return *p;

View File

@ -190,7 +190,7 @@ const token_info *lookup_token(const char *start, const char *end)
static void init_ascii()
{
for (const char *p = "abcdefghijklmnopqrstuvwxyz"; *p; p++) {
const char *p; for (p = "abcdefghijklmnopqrstuvwxyz"; *p; p++) {
char buf[2];
buf[0] = *p;
buf[1] = '\0';
@ -296,7 +296,7 @@ static void init_two_char_letter(char l1, char l2, char u1, char u2,
static void init_special_chars()
{
for (const char *p = "':^`~"; *p; p++)
const char *p; for (p = "':^`~"; *p; p++)
for (const char *q = "aeiouy"; *q; q++) {
// Use a variable to work around bug in gcc 2.0
char c = cmupper(*q);

View File

@ -690,7 +690,7 @@ void free_input_entry_format_list(input_entry_format *list)
void input_entry_format::debug_print()
{
for (int i = 0; i < pre_vline; i++)
int i; for (i = 0; i < pre_vline; i++)
putc('|', stderr);
entry_format::debug_print();
if (!width.empty()) {
@ -1174,7 +1174,7 @@ table *process_data(table_input &in, format *f, options *opt)
format_index = f->nrows - 1;
// A format row that is all lines doesn't use up a data line.
while (format_index < f->nrows - 1) {
for (int c = 0; c < ncolumns; c++) {
for (c = 0; c < ncolumns; c++) {
entry_format *e = f->entry[format_index] + c;
if (e->type != FORMAT_HLINE
&& e->type != FORMAT_DOUBLE_HLINE
@ -1393,7 +1393,7 @@ table *process_data(table_input &in, format *f, options *opt)
}
// Do this here rather than at the beginning in case continued formats
// change it.
for (int i = 0; i < ncolumns - 1; i++)
int i; for (i = 0; i < ncolumns - 1; i++)
if (f->separation[i] >= 0)
tbl->set_column_separation(i, f->separation[i]);
for (i = 0; i < ncolumns; i++)

View File

@ -663,12 +663,12 @@ void block_entry::do_divert(int alphabetic, int ncols, const string *mw,
prints(".if \\n[" SAVED_FILL_REG "] .fi\n"
".in 0\n");
prints(".ll ");
for (int i = start_col; i <= end_col; i++)
int i; for (i = start_col; i <= end_col; i++)
if (mw[i].empty())
break;
if (i > end_col) {
// Every column spanned by this entry has a minimum width.
for (int i = start_col; i <= end_col; i++) {
for (i = start_col; i <= end_col; i++) {
if (i > start_col) {
if (sep)
printfs("+%1n", as_string(sep[i - 1]));
@ -1274,7 +1274,7 @@ void table::set_equal_column(int c)
void table::add_stuff(stuff *p)
{
for (stuff **pp = &stuff_list; *pp; pp = &(*pp)->next)
stuff **pp; for (pp = &stuff_list; *pp; pp = &(*pp)->next)
;
*pp = p;
}
@ -1324,7 +1324,7 @@ void table::allocate(int r)
assert(allocated_rows > r);
while (nrows <= r) {
entry[nrows] = new table_entry*[ncolumns];
for (int i = 0; i < ncolumns; i++)
int i; for (i = 0; i < ncolumns; i++)
entry[nrows][i] = 0;
vline[nrows] = new char[ncolumns+1];
for (i = 0; i < ncolumns+1; i++)
@ -1590,7 +1590,7 @@ void table::add_entry(int r, int c, const string &str, const entry_format *f,
e->input_filename = fn;
e->start_row = e->end_row = r;
e->start_col = e->end_col = c;
for (table_entry **p = &entry_list; *p; p = &(*p)->next)
table_entry **p; for (p = &entry_list; *p; p = &(*p)->next)
;
*p = e;
entry[r][c] = e;
@ -1924,7 +1924,7 @@ void table::divide_span(int start_col, int end_col)
printfs(".nr " NEEDED_REG " \\n[%1]-(\\n[%2]",
span_width_reg(start_col, end_col),
span_width_reg(start_col, start_col));
for (int i = start_col + 1; i <= end_col; i++) {
int i; for (i = start_col + 1; i <= end_col; i++) {
// The column separation may shrink with the expand option.
if (!(flags & EXPAND))
printfs("+%1n", as_string(column_separation[i - 1]));
@ -1975,7 +1975,7 @@ void table::build_span_list()
table_entry *p = entry_list;
while (p) {
if (p->end_col != p->start_col) {
for (horizontal_span *q = span_list; q; q = q->next)
horizontal_span *q; for (q = span_list; q; q = q->next)
if (q->start_col == p->start_col
&& q->end_col == p->end_col)
break;
@ -1990,7 +1990,7 @@ void table::build_span_list()
horizontal_span *unsorted = span_list;
span_list = 0;
while (unsorted) {
for (horizontal_span **pp = &span_list; *pp; pp = &(*pp)->next)
horizontal_span **pp; for (pp = &span_list; *pp; pp = &(*pp)->next)
if (unsorted->end_col < (*pp)->end_col
|| (unsorted->end_col == (*pp)->end_col
&& (unsorted->start_col > (*pp)->start_col)))
@ -2017,7 +2017,7 @@ void table::compute_separation_factor()
}
if (flags & EXPAND) {
int total_sep = left_separation + right_separation;
for (int i = 0; i < ncolumns - 1; i++)
int i; for (i = 0; i < ncolumns - 1; i++)
total_sep += column_separation[i];
if (total_sep != 0) {
// Don't let the separation factor be negative.
@ -2035,7 +2035,7 @@ void table::compute_column_positions()
printfs(".nr %1 %2*\\n[" SEPARATION_FACTOR_REG "]\n",
column_start_reg(0),
as_string(left_separation));
for (int i = 1;; i++) {
int i; for (i = 1;; i++) {
printfs(".nr %1 \\n[%2]+\\n[%3]\n",
column_end_reg(i-1),
column_start_reg(i-1),
@ -2066,7 +2066,7 @@ void table::compute_column_positions()
void table::make_columns_equal()
{
int first = -1; // index of first equal column
for (int i = 0; i < ncolumns; i++)
int i; for (i = 0; i < ncolumns; i++)
if (equal[i]) {
if (first < 0) {
printfs(".nr %1 \\n[%1]", span_width_reg(i, i));
@ -2149,7 +2149,7 @@ void table::print_single_hline(int r)
&& entry[r][start_col] != 0
&& entry[r][start_col]->start_row != r)
start_col++;
for (int end_col = start_col;
int end_col; for (end_col = start_col;
end_col < ncolumns
&& (entry[r][end_col] == 0
|| entry[r][end_col]->start_row == r);
@ -2197,7 +2197,7 @@ void table::print_double_hline(int r)
&& entry[r][start_col] != 0
&& entry[r][start_col]->start_row != r)
start_col++;
for (int end_col = start_col;
int end_col; for (end_col = start_col;
end_col < ncolumns
&& (entry[r][end_col] == 0
|| entry[r][end_col]->start_row == r);
@ -2305,7 +2305,7 @@ void table::compute_vrule_bot_adjust(int end_row, int col, string &result)
result = "";
}
else {
for (stuff *p = stuff_list; p && p->row < end_row + 1; p = p->next)
stuff *p; for (p = stuff_list; p && p->row < end_row + 1; p = p->next)
;
if (p && p->row == end_row + 1 && p->is_double_line()) {
result = "-" DOUBLE_LINE_SEP;
@ -2399,7 +2399,7 @@ void table::build_vrule_list()
&& (end_row == nrows - 1
|| vline[end_row+1][col] != vline[end_row][col]
|| vline_spanned(end_row+1, col))) {
for (int start_row = end_row - 1;
int start_row; for (start_row = end_row - 1;
start_row >= 0
&& vline[start_row][col] == vline[end_row][col]
&& !vline_spanned(start_row, col);
@ -2498,7 +2498,7 @@ void table::do_row(int r)
if (!(flags & NOKEEP) && row_begins_section(r))
prints("." KEEP_MACRO_NAME "\n");
int had_line = 0;
for (stuff *p = stuff_list; p && p->row < r; p = p->next)
stuff *p; for (p = stuff_list; p && p->row < r; p = p->next)
;
for (stuff *p1 = p; p1 && p1->row == r; p1 = p1->next)
if (!p1->printed && (p1->is_single_line() || p1->is_double_line())) {
@ -2637,13 +2637,13 @@ void table::do_row(int r)
" 0\n");
}
int printed_one = 0;
for (vertical_rule *p = vrule_list; p; p = p->next)
if (p->end_row == r) {
for (vertical_rule *vp = vrule_list; vp; vp = vp->next)
if (vp->end_row == r) {
if (!printed_one) {
prints("." REPEATED_VPT_MACRO " 0\n");
printed_one = 1;
}
p->print();
vp->print();
}
if (printed_one)
prints("." REPEATED_VPT_MACRO " 1\n");

View File

@ -825,10 +825,10 @@ int main(int argc, char **argv)
m[4] = g.get_left_adjustment(i);
m[5] = g.get_right_adjustment(i);
printf("%s\t%d", p->ch, m[0]*MULTIPLIER);
for (int j = int(sizeof(m)/sizeof(m[0])) - 1; j > 0; j--)
int j; for (j = int(sizeof(m)/sizeof(m[0])) - 1; j > 0; j--)
if (m[j] != 0)
break;
for (int k = 1; k <= j; k++)
for (k = 1; k <= j; k++)
printf(",%d", m[k]*MULTIPLIER);
int type = 0;
if (m[2] > 0)

View File

@ -28,7 +28,7 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
static int is_good_size(int p)
{
const int SMALL = 10;
for (unsigned i = 2; i <= p/2; i++)
unsigned i; for (i = 2; i <= p/2; i++)
if (p % i == 0)
return 0;
for (i = 0x100; i != 0; i <<= 8)
@ -49,7 +49,7 @@ dictionary::dictionary(int n) : threshold(0.5), factor(1.5), used(0), size(n)
void *dictionary::lookup(symbol s, void *v)
{
for (int i = int(s.hash() % size);
int i; for (i = int(s.hash() % size);
table[i].v != 0;
i == 0 ? i = size - 1: --i)
if (s == table[i].s) {
@ -96,7 +96,7 @@ void *dictionary::lookup(const char *p)
void *dictionary::remove(symbol s)
{
// this relies on the fact that we are using linear probing
for (int i = int(s.hash() % size);
int i; for (i = int(s.hash() % size);
table[i].v != 0 && s != table[i].s;
i == 0 ? i = size - 1: --i)
;

View File

@ -446,7 +446,7 @@ trap::trap(symbol s, vunits n, trap *p)
void top_level_diversion::add_trap(symbol nm, vunits pos)
{
trap *first_free_slot = 0;
for (trap **p = &page_trap_list; *p; p = &(*p)->next) {
trap **p; for (p = &page_trap_list; *p; p = &(*p)->next) {
if ((*p)->nm.is_null()) {
if (first_free_slot == 0)
first_free_slot = *p;

View File

@ -136,7 +136,7 @@ void environment::output(node *nd, int no_fill, vunits vs, int ls,
)
curdiv->output(nd, no_fill, vs, ls, width);
else {
for (pending_output_line **p = &pending_lines; *p; p = &(*p)->next)
pending_output_line **p; for (p = &pending_lines; *p; p = &(*p)->next)
;
*p = new pending_output_line(nd, no_fill, vs, ls, width);
}
@ -1586,7 +1586,7 @@ void environment::hyphenate_line()
if (line == 0)
return;
hyphenation_type prev_type = line->get_hyphenation_type();
for (node **startp = &line->next; *startp != 0; startp = &(*startp)->next) {
node **startp; for (startp = &line->next; *startp != 0; startp = &(*startp)->next) {
hyphenation_type this_type = (*startp)->get_hyphenation_type();
if (prev_type == HYPHEN_BOUNDARY && this_type == HYPHEN_MIDDLE)
break;
@ -1705,7 +1705,7 @@ void environment::possibly_break_line(int forced)
space_total = 0;
width_total = 0;
node *first_non_discardable = 0;
for (node *tem = line; tem != 0; tem = tem->next)
node *tem; for (tem = line; tem != 0; tem = tem->next)
if (!tem->discardable())
first_non_discardable = tem;
node *to_be_discarded;
@ -2025,7 +2025,7 @@ tab_stops::~tab_stops()
tab_type tab_stops::distance_to_next_tab(hunits curpos, hunits *distance)
{
hunits lastpos = 0;
for (tab *tem = initial_list; tem && tem->pos <= curpos; tem = tem->next)
tab *tem; for (tem = initial_list; tem && tem->pos <= curpos; tem = tem->next)
lastpos = tem->pos;
if (tem) {
*distance = tem->pos - curpos;
@ -2053,7 +2053,7 @@ const char *tab_stops::to_string()
static int buf_size = 0;
// figure out a maximum on the amount of space we can need
int count = 0;
for (tab *p = initial_list; p; p = p->next)
tab *p; for (p = initial_list; p; p = p->next)
++count;
for (p = repeated_list; p; p = p->next)
++count;
@ -2149,7 +2149,7 @@ void tab_stops::clear()
void tab_stops::add_tab(hunits pos, tab_type type, int repeated)
{
for (tab **p = repeated ? &repeated_list : &initial_list; *p; p = &(*p)->next)
tab **p; for (p = repeated ? &repeated_list : &initial_list; *p; p = &(*p)->next)
;
*p = new tab(pos, type);
}
@ -2282,7 +2282,7 @@ void environment::wrap_up_tab()
field_spaces += tab_field_spaces;
}
if (tab_contents != 0) {
for (node *tem = tab_contents; tem->next != 0; tem = tem->next)
node *tem; for (tem = tab_contents; tem->next != 0; tem = tem->next)
;
tem->next = line;
line = tab_contents;
@ -2390,7 +2390,7 @@ void environment::wrap_up_field()
current_tab = TAB_NONE;
}
if (tab_contents != 0) {
for (node *tem = tab_contents; tem->next != 0; tem = tem->next)
node *tem; for (tem = tab_contents; tem->next != 0; tem = tem->next)
;
tem->next = line;
line = tab_contents;
@ -2901,7 +2901,7 @@ void hyphen_trie::insert_pattern(const char *pat, int patlen, int *num)
void hyphen_trie::hyphenate(const char *word, int len, int *hyphens)
{
for (int j = 0; j < len+1; j++)
int j; for (j = 0; j < len+1; j++)
hyphens[j] = 0;
for (j = 0; j < len - 1; j++) {
h = hyphens + j;
@ -2986,7 +2986,7 @@ void hyphenate(hyphen_list *h, unsigned flags)
int len = 0;
char hbuf[WORD_MAX+2];
char *buf = hbuf + 1;
for (hyphen_list *tem = h; tem && len < WORD_MAX; tem = tem->next) {
hyphen_list *tem; for (tem = h; tem && len < WORD_MAX; tem = tem->next) {
if (tem->hyphenation_code != 0)
buf[len++] = tem->hyphenation_code;
else

View File

@ -513,7 +513,7 @@ int input_stack::set_location(const char *filename, int lineno)
void input_stack::next_file(FILE *fp, const char *s)
{
for (input_iterator **pp = &top; *pp != &nil_iterator; pp = &(*pp)->next)
input_iterator **pp; for (pp = &top; *pp != &nil_iterator; pp = &(*pp)->next)
if ((*pp)->next_file(fp, s))
return;
if (++level > limit && limit > 0)
@ -1400,7 +1400,7 @@ void token::next()
symbol s = read_escape_name();
if (s.is_null())
break;
for (const char *p = s.contents(); *p != '\0'; p++)
const char *p; for (p = s.contents(); *p != '\0'; p++)
if (!csdigit(*p))
break;
if (*p)
@ -2730,7 +2730,7 @@ input_iterator *macro_iterator::get_arg(int i)
void macro_iterator::add_arg(const macro &m)
{
for (arg_list **p = &args; *p; p = &((*p)->next))
arg_list **p; for (p = &args; *p; p = &((*p)->next))
;
*p = new arg_list(m);
++argc;
@ -3107,7 +3107,7 @@ static void interpolate_arg(symbol nm)
}
}
else {
for (const char *p = s; *p && csdigit(*p); p++)
const char *p; for (p = s; *p && csdigit(*p); p++)
;
if (*p)
error("bad argument name `%1'", s);
@ -3245,7 +3245,7 @@ void do_define_macro(define_mode mode)
const char *s = term.contents();
int d;
// see if it matches term
for (int i = 0; s[i] != 0; i++) {
int i; for (i = 0; s[i] != 0; i++) {
d = get_copy(&n);
if ((unsigned char)s[i] != d)
break;

View File

@ -610,7 +610,7 @@ tfont::tfont(tfont_spec &spec) : tfont_spec(spec)
next = tfont_list;
tfont_list = this;
tfont_spec plain_spec = plain();
for (tfont *p = tfont_list; p; p = p->next)
tfont *p; for (p = tfont_list; p; p = p->next)
if (*p == plain_spec) {
plain_version = p;
break;
@ -2374,7 +2374,7 @@ void overstrike_node::overstrike(node *n)
hunits w = n->width();
if (w > max_width)
max_width = w;
for (node **p = &list; *p; p = &(*p)->next)
node **p; for (p = &list; *p; p = &(*p)->next)
;
n->next = 0;
*p = n;
@ -2968,7 +2968,7 @@ void dbreak_node::split(int where, node **prep, node **postp)
if (pre == 0)
*prep = next;
else {
for (node *tem = pre; tem->next != 0; tem = tem->next)
node *tem; for (tem = pre; tem->next != 0; tem = tem->next)
;
tem->next = next;
*prep = pre;
@ -3519,7 +3519,7 @@ void bracket_node::tprint(troff_output_file *out)
if (list == 0)
return;
int npieces = 0;
for (node *tem = list; tem; tem = tem->next)
node *tem; for (tem = list; tem; tem = tem->next)
++npieces;
vunits h = list->size();
vunits totalh = h*npieces;
@ -4552,7 +4552,7 @@ void special_request()
int next_available_font_position()
{
for (int i = 1; i < font_table_size && font_table[i] != 0; i++)
int i; for (i = 1; i < font_table_size && font_table[i] != 0; i++)
;
return i;
}

View File

@ -82,7 +82,7 @@ symbol::symbol(const char *p, int how)
table_used = 0;
}
unsigned int hc = hash_string(p);
for (const char **pp = table + hc % table_size;
const char **pp; for (pp = table + hc % table_size;
*pp != 0;
(pp == table ? pp = table + table_size - 1 : --pp))
if (strcmp(p, *pp) == 0) {
@ -96,7 +96,7 @@ symbol::symbol(const char *p, int how)
if (table_used >= table_size - 1 || table_used >= table_size*FULL_MAX) {
const char **old_table = table;
unsigned int old_table_size = table_size;
for (int i = 1; table_sizes[i] <= old_table_size; i++)
int i; for (i = 1; table_sizes[i] <= old_table_size; i++)
if (table_sizes[i] == 0)
fatal("too many symbols");
table_size = table_sizes[i];