[comp.bugs.4bsd] indent

mackenzi@thor.stolaf.edu (David MacKenzie) (02/09/89)

This isn't strictly a bug report or fix, but the following patches to the
4.3BSD-tahoe indent(1) program clean up some lint and allow it to be
compiled under MS-DOS, as well (if MSDOS is #defined).  It also now uses
perror() for system error messages, to be more informative.

*** Makefile.orig	Mon Dec 26 22:35:47 1988
--- Makefile	Fri Jan 13 15:18:10 1989
***************
*** 52,58 ****
  lexi.o: /usr/include/ctype.h
  parse.o: parse.c ./indent_globs.h /usr/include/stdio.h ./indent_codes.h
  pr_comment.o: pr_comment.c indent_globs.h /usr/include/stdio.h
! args.o: args.c indent_globs.h /usr/include/stdio.h /usr/include/sys/types.h
  args.o: /usr/include/ctype.h
  
  # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
--- 52,58 ----
  lexi.o: /usr/include/ctype.h
  parse.o: parse.c ./indent_globs.h /usr/include/stdio.h ./indent_codes.h
  pr_comment.o: pr_comment.c indent_globs.h /usr/include/stdio.h
! args.o: args.c indent_globs.h /usr/include/stdio.h
  args.o: /usr/include/ctype.h
  
  # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
*** args.c.orig	Fri Jan 13 14:13:28 1989
--- args.c	Tue Feb  7 14:20:24 1989
***************
*** 27,35 ****
   */
  
  #include "indent_globs.h"
- #include <sys/types.h>
  #include <ctype.h>
  
  char *getenv(), *index();
  
  /* profile types */
--- 27,38 ----
   */
  
  #include "indent_globs.h"
  #include <ctype.h>
  
+ #ifdef MSDOS
+ #define index strchr
+ #endif
+ 
  char *getenv(), *index();
  
  /* profile types */
***************
*** 124,137 ****
  {
      register FILE *f;
      char fname[BUFSIZ];
!     static char pro[] = ".indent.pro";
  
!     sprintf(fname, "%s/%s", getenv("HOME"), pro);
      if ((f = fopen(fname, "r")) != NULL) {
  	scan_profile(f);
  	(void) fclose(f);
      }
!     if ((f = fopen(pro, "r")) != NULL) {
  	scan_profile(f);
  	(void) fclose(f);
      }
--- 127,146 ----
  {
      register FILE *f;
      char fname[BUFSIZ];
! #ifdef MSDOS
!     static char profile[] = "indent.pro";
!     
!     sprintf (fname, "\\%s", profile);
! #else
!     static char profile[] = ".indent.pro";
  
!     sprintf(fname, "%s/%s", getenv("HOME"), profile);
! #endif
      if ((f = fopen(fname, "r")) != NULL) {
  	scan_profile(f);
  	(void) fclose(f);
      }
!     if ((f = fopen(profile, "r")) != NULL) {
  	scan_profile(f);
  	(void) fclose(f);
      }
*** indent.c.orig	Fri Jan 13 14:13:30 1989
--- indent.c	Tue Feb  7 14:21:27 1989
***************
*** 48,53 ****
--- 48,54 ----
  the following line should be changed, set the variable ps.i_l_follow.
  
  */
+ #define ALLOCATE
  #include "indent_globs.h"
  #include "indent_codes.h"
  
***************
*** 68,77 ****
      int         flushed_nl;	/* used when buffering up comments to
  				 * remember that a newline was passed over */
      int         force_nl;	/* when true, code must be broken */
!     int         hd_type;	/* used to store type of stmt for if
  				 * (...), for (...), etc */
      register int i;		/* local loop counter */
-     register int j;		/* local loop counter */
      int         scase;		/* set to true when we see a case, so we
  				 * will know what to do with the following
  				 * colon */
--- 69,77 ----
      int         flushed_nl;	/* used when buffering up comments to
  				 * remember that a newline was passed over */
      int         force_nl;	/* when true, code must be broken */
!     int         hd_type = 0;	/* used to store type of stmt for if
  				 * (...), for (...), etc */
      register int i;		/* local loop counter */
      int         scase;		/* set to true when we see a case, so we
  				 * will know what to do with the following
  				 * colon */
***************
*** 152,158 ****
  		in_name = argv[i];	/* remember name of input file */
  		input = fopen(in_name, "r");
  		if (input == 0) {	/* check for open error */
! 		    fprintf(stderr, "indent: can't open %s\n", argv[i]);
  		    exit(1);
  		}
  		continue;
--- 152,159 ----
  		in_name = argv[i];	/* remember name of input file */
  		input = fopen(in_name, "r");
  		if (input == 0) {	/* check for open error */
! 		    fprintf(stderr, "indent: can't open ");
! 		    perror(in_name);
  		    exit(1);
  		}
  		continue;
***************
*** 165,171 ****
  		}
  		output = fopen(out_name, "w");
  		if (output == 0) {	/* check for create error */
! 		    fprintf(stderr, "indent: can't create %s\n", argv[i]);
  		    exit(1);
  		}
  		continue;
--- 166,173 ----
  		}
  		output = fopen(out_name, "w");
  		if (output == 0) {	/* check for create error */
! 		    fprintf(stderr, "indent: can't create ");
! 		    perror(out_name);
  		    exit(1);
  		}
  		continue;
***************
*** 177,183 ****
  
      }				/* end of for */
      if (input == 0) {
! 	printf("Usage: indent file [ outfile ] [ options ]\n");
  	exit(1);
      }
      if (output == 0)
--- 179,185 ----
  
      }				/* end of for */
      if (input == 0) {
! 	fprintf(stderr, "Usage: indent file [ outfile ] [ options ]\n");
  	exit(1);
      }
      if (output == 0)
***************
*** 219,225 ****
  	    else
  		break;
  	    p++;
! 	};
  	if (col > ps.ind_size)
  	    ps.ind_level = ps.i_l_follow = col / ps.ind_size;
      }
--- 221,227 ----
  	    else
  		break;
  	    p++;
! 	}
  	if (col > ps.ind_size)
  	    ps.ind_level = ps.i_l_follow = col / ps.ind_size;
      }
***************
*** 555,561 ****
  		break;
  
  	    case binary_op:	/* any binary operation */
- 	do_binary:
  		if (ps.want_blank)
  		    *e_code++ = ' ';
  		{
--- 557,562 ----
***************
*** 984,990 ****
  			    *sc_end++ = ' ';
  			    --line_no;
  			}
! 			bcopy(com_start, sc_end, com_end - com_start);
  			sc_end += com_end - com_start;
  			e_lab = com_start;
  			while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
--- 985,991 ----
  			    *sc_end++ = ' ';
  			    --line_no;
  			}
! 			strncpy(sc_end, com_start, com_end - com_start);
  			sc_end += com_end - com_start;
  			e_lab = com_start;
  			while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
***************
*** 1036,1042 ****
  				 * printed */
  
  	    case comment:	/* we have gotten a /*  this is a biggie */
- 	proc_comment:
  		if (flushed_nl) {	/* we should force a broken line
  					 * here */
  		    flushed_nl = false;
--- 1037,1042 ----
***************
*** 1053,1059 ****
  	if (type_code != comment && type_code != newline && type_code != preesc)
  	    ps.last_token = type_code;
      }				/* end of main while (1) loop */
! };
  
  /*
   * copy input file to backup file.  If in_name is /blah/blah/blah/file, then
--- 1053,1059 ----
  	if (type_code != comment && type_code != newline && type_code != preesc)
  	    ps.last_token = type_code;
      }				/* end of main while (1) loop */
! }
  
  /*
   * copy input file to backup file.  If in_name is /blah/blah/blah/file, then
***************
*** 1066,1093 ****
                  bakchn;
      char        buff[BUFSIZ];
      register char *p;
      char *rindex();
  
      if ((p = rindex(in_name, '/')) != NULL)
  	p++;
      else
  	p = in_name;
      sprintf(bakfile, "%s.BAK", p);
  
      /* copy in_name to backup file */
      bakchn = creat(bakfile, 0600);
      if (bakchn < 0) {
! 	fprintf(stderr, "indent: can't create backup file \"%s\"\n", bakfile);
  	exit(1);
      }
      while ((n = read(fileno(input), buff, sizeof buff)) > 0)
  	if (write(bakchn, buff, n) != n) {
! 	    fprintf(stderr, "indent: error writing backup file \"%s\"\n",
! 		bakfile);
  	    exit(1);
  	}
      if (n < 0) {
! 	fprintf(stderr, "indent: error reading input file \"%s\"\n", in_name);
  	exit(1);
      }
      close(bakchn);
--- 1066,1110 ----
                  bakchn;
      char        buff[BUFSIZ];
      register char *p;
+ 
+ #ifdef MSDOS
+     char *strchr(), *strrchr(), *q;
+     
+     if ((p = strrchr(in_name, '\\')) != NULL)
+ #else
      char *rindex();
  
      if ((p = rindex(in_name, '/')) != NULL)
+ #endif
  	p++;
      else
  	p = in_name;
+ #ifdef MSDOS
+     if (q = strchr(p, '.'))
+ 	*q = 0;
+     sprintf(bakfile, "%.8s.BAK", p);
+     if (q)
+ 	*q = '.';
+ #else
      sprintf(bakfile, "%s.BAK", p);
+ #endif
  
      /* copy in_name to backup file */
      bakchn = creat(bakfile, 0600);
      if (bakchn < 0) {
! 	fprintf(stderr, "indent: can't create backup file ");
! 	perror(bakfile);
  	exit(1);
      }
      while ((n = read(fileno(input), buff, sizeof buff)) > 0)
  	if (write(bakchn, buff, n) != n) {
! 	    fprintf(stderr, "indent: error writing backup file ");
! 	    perror(bakfile);
  	    exit(1);
  	}
      if (n < 0) {
! 	fprintf(stderr, "indent: error reading input file ");
! 	perror(in_name);
  	exit(1);
      }
      close(bakchn);
***************
*** 1096,1108 ****
      /* re-open backup file as the input file */
      input = fopen(bakfile, "r");
      if (input == NULL) {
! 	fprintf(stderr, "indent: can't re-open backup file\n");
  	exit(1);
      }
      /* now the original input file will be the output */
      output = fopen(in_name, "w");
      if (output == NULL) {
! 	fprintf(stderr, "indent: can't create %s\n", in_name);
  	unlink(bakfile);
  	exit(1);
      }
--- 1113,1127 ----
      /* re-open backup file as the input file */
      input = fopen(bakfile, "r");
      if (input == NULL) {
! 	fprintf(stderr, "indent: can't re-open backup file ");
! 	perror(bakfile);
  	exit(1);
      }
      /* now the original input file will be the output */
      output = fopen(in_name, "w");
      if (output == NULL) {
! 	fprintf(stderr, "indent: can't create ");
! 	perror(in_name);
  	unlink(bakfile);
  	exit(1);
      }
*** indent_globs.h.orig	Fri Jan 13 14:13:27 1989
--- indent_globs.h	Fri Jan 13 14:39:39 1989
***************
*** 52,133 ****
  #define true  1
  
  
! FILE   *input;     /* the fid for the input file */
! FILE   *output;    /* the output file */
  
! char    labbuf[bufsize];	/* buffer for label */
! char   *s_lab;     /* start ... */
! char   *e_lab;     /* .. and end of stored label */
! 
! char    codebuf[bufsize];	/* buffer for code section */
! char   *s_code;    /* start ... */
! char   *e_code;    /* .. and end of stored code */
! 
! char    combuf[bufsize];	/* buffer for comments */
! char   *s_com;     /* start ... */
! char   *e_com;     /* ... and end of stored comments */
! 
! char    in_buffer[inp_bufs];	/* input buffer */
! char   *buf_ptr;   /* ptr to next character to be taken from in_buffer */
! char   *buf_end;   /* ptr to first after last char in in_buffer */
! 
! char    save_com[sc_size];	/* input text is saved here when looking for the brace
  		      after an if, while, etc */
! char   *sc_end;    /* pointer into save_com buffer */
  
! char   *bp_save;   /* saved value of buf_ptr when taking input from
  		      save_com */
! char   *be_save;   /* similarly saved value of buf_end */
  
! char    token[bufsize];	/* the last token scanned */
  
  
! 
! int	blanklines_after_declarations;
! int	blanklines_before_blockcomments;
! int	blanklines_after_procs;
! int	swallow_optional_blanklines;
! int	n_real_blanklines;
! int	prefix_blankline_requested;
! int	postfix_blankline_requested;
! int     break_comma;	/* when true and not in parens, break after a comma */
! int     btype_2;   /* when true, brace should be on same line as if,
  		      while, etc */
! float   case_ind;  /* indentation level to be used for a "case n:" */
! int     code_lines;/* count of lines with code */
! int     had_eof;   /* set to true when input is exhausted */
! int     line_no;   /* the current line number. */
! int     max_col;   /* the maximum allowable line length */
! int     pointer_as_binop;	/* when true, "->" is treated as a binary
  				   operator (giving, e.g., "p -> f") */
! int     verbose;   /* when true, non-essential error messages are printed 
  		   */
! int	cuddle_else;		/* true if else should cuddle up to '}' */
! int	star_comment_cont;	/* true iff comment continuation lines should
  				   have stars at the beginning of each line.
  				   */
! int     comment_delimiter_on_blankline;
! int     troff;			/* true iff were generating troff input */
! int	procnames_start_line;	/* if true, the names of procedures being
  				   defined get placed in column 1 (ie. a
  				   newline is placed between the type of the
  				   procedure and its name) */
! int	proc_calls_space;	/* If true, procedure calls look like:
  				   foo(bar) rather than foo (bar) */
! int	format_col1_comments;	/* If comments which start in column 1 are to
  				   be magically reformatted (just like comments that
  				   begin in later columns) */
! int	inhibit_formatting;	/* true if INDENT OFF is in effect */
! int	suppress_blanklines;	/* set iff following blanklines should be
  				   suppressed */
! int	continuation_indent;	/* set to the indentation between the edge of
  				   code and continuation lines */
! int	lineup_to_parens;	/* if true, continued code within parens will
  				   be lined up to the open paren */
! int	block_comment_max_col;
  
  
! struct parser_state {
      int         last_token;
      int         p_stack[50];	/* this is the parsers stack */
      int         il[50];		/* this stack stores indentation levels */
--- 52,139 ----
  #define true  1
  
  
! #ifdef ALLOCATE
! #define EXTERN
! #else
! #define EXTERN extern
! #endif
! 
! EXTERN FILE   *input;     /* the fid for the input file */
! EXTERN FILE   *output;    /* the output file */
! 
! EXTERN char    labbuf[bufsize];	/* buffer for label */
! EXTERN char   *s_lab;     /* start ... */
! EXTERN char   *e_lab;     /* .. and end of stored label */
! 
! EXTERN char    codebuf[bufsize];	/* buffer for code section */
! EXTERN char   *s_code;    /* start ... */
! EXTERN char   *e_code;    /* .. and end of stored code */
! 
! EXTERN char    combuf[bufsize];	/* buffer for comments */
! EXTERN char   *s_com;     /* start ... */
! EXTERN char   *e_com;     /* ... and end of stored comments */
! 
! EXTERN char    in_buffer[inp_bufs];	/* input buffer */
! EXTERN char   *buf_ptr;   /* ptr to next character to be taken from in_buffer */
! EXTERN char   *buf_end;   /* ptr to first after last char in in_buffer */
  
! EXTERN char    save_com[sc_size];	/* input text is saved here when looking for the brace
  		      after an if, while, etc */
! EXTERN char   *sc_end;    /* pointer into save_com buffer */
  
! EXTERN char   *bp_save;   /* saved value of buf_ptr when taking input from
  		      save_com */
! EXTERN char   *be_save;   /* similarly saved value of buf_end */
  
! EXTERN char    token[bufsize];	/* the last token scanned */
  
  
! 
! EXTERN int	blanklines_after_declarations;
! EXTERN int	blanklines_before_blockcomments;
! EXTERN int	blanklines_after_procs;
! EXTERN int	swallow_optional_blanklines;
! EXTERN int	n_real_blanklines;
! EXTERN int	prefix_blankline_requested;
! EXTERN int	postfix_blankline_requested;
! EXTERN int     break_comma;	/* when true and not in parens, break after a comma */
! EXTERN int     btype_2;   /* when true, brace should be on same line as if,
  		      while, etc */
! EXTERN float   case_ind;  /* indentation level to be used for a "case n:" */
! EXTERN int     code_lines;/* count of lines with code */
! EXTERN int     had_eof;   /* set to true when input is exhausted */
! EXTERN int     line_no;   /* the current line number. */
! EXTERN int     max_col;   /* the maximum allowable line length */
! EXTERN int     pointer_as_binop;	/* when true, "->" is treated as a binary
  				   operator (giving, e.g., "p -> f") */
! EXTERN int     verbose;   /* when true, non-essential error messages are printed 
  		   */
! EXTERN int	cuddle_else;		/* true if else should cuddle up to '}' */
! EXTERN int	star_comment_cont;	/* true iff comment continuation lines should
  				   have stars at the beginning of each line.
  				   */
! EXTERN int     comment_delimiter_on_blankline;
! EXTERN int     troff;			/* true iff were generating troff input */
! EXTERN int	procnames_start_line;	/* if true, the names of procedures being
  				   defined get placed in column 1 (ie. a
  				   newline is placed between the type of the
  				   procedure and its name) */
! EXTERN int	proc_calls_space;	/* If true, procedure calls look like:
  				   foo(bar) rather than foo (bar) */
! EXTERN int	format_col1_comments;	/* If comments which start in column 1 are to
  				   be magically reformatted (just like comments that
  				   begin in later columns) */
! EXTERN int	inhib_formatting;	/* true if INDENT OFF is in effect */
! EXTERN int	suppress_blanklines;	/* set iff following blanklines should be
  				   suppressed */
! EXTERN int	continuation_indent;	/* set to the indentation between the edge of
  				   code and continuation lines */
! EXTERN int	lineup_to_parens;	/* if true, continued code within parens will
  				   be lined up to the open paren */
! EXTERN int	block_comment_max_col;
  
  
! EXTERN struct parser_state {
      int         last_token;
      int         p_stack[50];	/* this is the parsers stack */
      int         il[50];		/* this stack stores indentation levels */
***************
*** 227,232 ****
      int		just_saw_decl;
  }           ps;
  
! int ifdef_level;
! struct parser_state state_stack[5];
! struct parser_state match_state[5];
--- 233,238 ----
      int		just_saw_decl;
  }           ps;
  
! EXTERN int ifdef_level;
! EXTERN struct parser_state state_stack[5];
! EXTERN struct parser_state match_state[5];
*** io.c.orig	Fri Jan 13 14:13:31 1989
--- io.c	Fri Jan 13 14:43:33 1989
***************
*** 76,82 ****
  
  
  
- int         ff = 014;		/* used to write a form feed */
  int         comment_open;
  static      paren_target;
  
--- 76,81 ----
***************
*** 88,94 ****
  				 * appropriate nesting level, followed by
  				 * any comments */
      register int cur_col,
-                 temp_col,
                  target_col;
  
      if (ps.procname[0]) {
--- 87,92 ----
***************
*** 104,110 ****
  	n_real_blanklines++;
  	}
      }
!     else if (!inhibit_formatting) {
  	suppress_blanklines = 0;
  	ps.bl_line = false;
  	if (prefix_blankline_requested)
--- 102,108 ----
  	n_real_blanklines++;
  	}
      }
!     else if (!inhib_formatting) {
  	suppress_blanklines = 0;
  	ps.bl_line = false;
  	if (prefix_blankline_requested)
***************
*** 135,141 ****
  	    }
  	    while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
  		e_lab--;
! 	    cur_col = pad_output(1, compute_label_target());
  	    fprintf(output, "%.*s", e_lab - s_lab, s_lab);
  	    cur_col = count_spaces(cur_col, s_lab);
  	}
--- 133,139 ----
  	    }
  	    while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
  		e_lab--;
! 	    cur_col = pad_output(1, comp_label_target());
  	    fprintf(output, "%.*s", e_lab - s_lab, s_lab);
  	    cur_col = count_spaces(cur_col, s_lab);
  	}
***************
*** 151,157 ****
  		comment_open = 0;
  		fprintf(output, ".*/\n");
  	    }
! 	    target_col = compute_code_target();
  	    {
  		register    i;
  
--- 149,155 ----
  		comment_open = 0;
  		fprintf(output, ".*/\n");
  	    }
! 	    target_col = comp_code_target();
  	    {
  		register    i;
  
***************
*** 186,192 ****
  		while (*p == ' ')
  		    p++;
  		if (*p == 0)
! 		    goto inhibit_newline;
  		if (!comment_open) {
  		    if ('a' <= *p && *p <= 'z')
  			*p = *p + 'A' - 'a';
--- 184,190 ----
  		while (*p == ' ')
  		    p++;
  		if (*p == 0)
! 		    goto inhib_newline;
  		if (!comment_open) {
  		    if ('a' <= *p && *p <= 'z')
  			*p = *p + 'A' - 'a';
***************
*** 240,246 ****
  	    putc('\014', output);
  	else
  	    putc('\n', output);
! inhibit_newline:
  	++ps.out_lines;
  	if (ps.just_saw_decl == 1 && blanklines_after_declarations) {
  	    prefix_blankline_requested = 1;
--- 238,244 ----
  	    putc('\014', output);
  	else
  	    putc('\n', output);
! inhib_newline:
  	++ps.out_lines;
  	if (ps.just_saw_decl == 1 && blanklines_after_declarations) {
  	    prefix_blankline_requested = 1;
***************
*** 267,275 ****
      ps.paren_level = ps.p_l_follow;
      paren_target = -ps.paren_indents[ps.paren_level - 1];
      return;
! };
  
! compute_code_target() {
      register    target_col = ps.ind_size * ps.ind_level + 1;
  
      if (ps.paren_level)
--- 265,273 ----
      ps.paren_level = ps.p_l_follow;
      paren_target = -ps.paren_indents[ps.paren_level - 1];
      return;
! }
  
! comp_code_target() {
      register    target_col = ps.ind_size * ps.ind_level + 1;
  
      if (ps.paren_level)
***************
*** 293,299 ****
      return target_col;
  }
  
! compute_label_target()
  {
      return
  	ps.pcase ? (int) (case_ind * ps.ind_size) +1
--- 291,297 ----
      return target_col;
  }
  
! comp_label_target()
  {
      return
  	ps.pcase ? (int) (case_ind * ps.ind_size) +1
***************
*** 321,327 ****
  int
  fill_buffer()
  {				/* this routine reads stuff from the input */
-     int         count;
      register char *p;
      register int i;
      register FILE *f = input;
--- 319,324 ----
***************
*** 337,343 ****
      }
      p = in_buffer;
      buf_ptr = p;
!     while ((*p++ = i = getc(f)) != EOF && i != '\n');
      if (i == EOF) {
  	p[-1] = ' ';
  	*p++ = '\n';
--- 334,340 ----
      }
      p = in_buffer;
      buf_ptr = p;
!     while (*p++ = i = getc(f), i != EOF && i != '\n');
      if (i == EOF) {
  	p[-1] = ' ';
  	*p++ = '\n';
***************
*** 374,380 ****
  		    if (p[0] == '*' && p[1] == '/' && p[2] == '\n' && com) {
  			if (s_com != e_com || s_lab != e_lab || s_code != e_code)
  			    dump_line();
! 			if (!(inhibit_formatting = com - 1)) {
  			    n_real_blanklines = 0;
  			    postfix_blankline_requested = 0;
  			    prefix_blankline_requested = 0;
--- 371,377 ----
  		    if (p[0] == '*' && p[1] == '/' && p[2] == '\n' && com) {
  			if (s_com != e_com || s_lab != e_lab || s_code != e_code)
  			    dump_line();
! 			if (!(inhib_formatting = com - 1)) {
  			    n_real_blanklines = 0;
  			    postfix_blankline_requested = 0;
  			    prefix_blankline_requested = 0;
***************
*** 385,391 ****
  	    }
  	}
      }
!     if (inhibit_formatting) {
  	p = in_buffer;
  	do
  	    putc(*p, output);
--- 382,388 ----
  	    }
  	}
      }
!     if (inhib_formatting) {
  	p = in_buffer;
  	do
  	    putc(*p, output);
***************
*** 392,398 ****
  	while (*p++ != '\n');
      }
      return;
! };
  
  /*
   * Copyright (C) 1976 by the Board of Trustees of the University of
--- 389,395 ----
  	while (*p++ != '\n');
      }
      return;
! }
  
  /*
   * Copyright (C) 1976 by the Board of Trustees of the University of
***************
*** 446,452 ****
  	    putc(' ', output);	/* pad with final blanks */
      }
      return (target);
! };
  
  /*
   * Copyright (C) 1976 by the Board of Trustees of the University of
--- 443,449 ----
  	    putc(' ', output);	/* pad with final blanks */
      }
      return (target);
! }
  
  /*
   * Copyright (C) 1976 by the Board of Trustees of the University of
***************
*** 506,514 ****
  	}			/* end of switch */
      }				/* end of for loop */
      return (cur);
! };
  
  int	found_err;
  diag(level, msg, a, b)
  {
      if (level)
--- 503,512 ----
  	}			/* end of switch */
      }				/* end of for loop */
      return (cur);
! }
  
  int	found_err;
+ /* VARARGS2 */
  diag(level, msg, a, b)
  {
      if (level)
*** lexi.c.orig	Fri Jan 13 14:13:33 1989
--- lexi.c	Fri Jan 13 14:26:20 1989
***************
*** 76,82 ****
  
  #include "indent_globs.h"
  #include "indent_codes.h"
! #include "ctype.h"
  
  #define alphanum 1
  #define opchar 3
--- 76,82 ----
  
  #include "indent_globs.h"
  #include "indent_codes.h"
! #include <ctype.h>
  
  #define alphanum 1
  #define opchar 3
***************
*** 523,529 ****
      ps.last_u_d = unary_delim;
      *tok = '\0';		/* null terminate the token */
      return (code);
! };
  
  /* Add the given keyword to the keyword table, using val as the keyword type
     */
--- 523,529 ----
      ps.last_u_d = unary_delim;
      *tok = '\0';		/* null terminate the token */
      return (code);
! }
  
  /* Add the given keyword to the keyword table, using val as the keyword type
     */
*** parse.c.orig	Fri Jan 13 14:13:35 1989
--- parse.c	Fri Jan 13 14:26:39 1989
***************
*** 56,63 ****
   *
   */
  
! #include "./indent_globs.h"
! #include "./indent_codes.h"
  
  
  
--- 56,63 ----
   *
   */
  
! #include "indent_globs.h"
! #include "indent_codes.h"
  
  
  
*** pr_comment.c.orig	Fri Jan 13 14:13:37 1989
--- pr_comment.c	Fri Jan 13 14:51:01 1989
***************
*** 60,69 ****
      int         now_col;	/* column we are in now */
      int         adj_max_col;	/* Adjusted max_col for when we decide to
  				 * spill comments over the right margin */
-     int         col_1_com;	/* this comment should not be touched */
      char       *last_bl;	/* points to the last blank in the output
  				 * buffer */
-     char        achar;
      char       *t_ptr;		/* used for moving string */
      int         unix_comment;	/* tri-state variable used to decide if it
  				 * is a unix-style comment. 0 means only
--- 60,67 ----
***************
*** 79,85 ****
      adj_max_col = max_col;
      ps.just_saw_decl = 0;
      last_bl = 0;		/* no blanks found so far */
!     ps.box_com = col_1_com = false;	/* at first, assume that we are
  					 * not in a boxed comment or some
  					 * other comment that should not
  					 * be touched */
--- 77,83 ----
      adj_max_col = max_col;
      ps.just_saw_decl = 0;
      last_bl = 0;		/* no blanks found so far */
!     ps.box_com = false;		/* at first, assume that we are
  					 * not in a boxed comment or some
  					 * other comment that should not
  					 * be touched */
***************
*** 93,99 ****
      if (ps.col_1 && !format_col1_comments) {	/* if comment starts in
  						 * column 1 it should not
  						 * be touched */
! 	col_1_com = ps.box_com = true;
  	ps.com_col = 1;
      } else {
  	if (*buf_ptr == '-' || *buf_ptr == '*') {
--- 91,97 ----
      if (ps.col_1 && !format_col1_comments) {	/* if comment starts in
  						 * column 1 it should not
  						 * be touched */
! 	ps.box_com = true;
  	ps.com_col = 1;
      } else {
  	if (*buf_ptr == '-' || *buf_ptr == '*') {
***************
*** 100,106 ****
  	    ps.box_com = true;	/* a comment with a '-' or '*' immediately
  				 * after the /* is assumed to be a boxed
  				 * comment */
- 	    col_1_com = true;
  	    break_delim = 0;
  	}
  	if ( /* ps.bl_line && */ (s_lab == e_lab) && (s_code == e_code)) {
--- 98,103 ----
***************
*** 117,127 ****
  	    register    target_col;
  	    break_delim = 0;
  	    if (s_code != e_code)
! 		target_col = count_spaces(compute_code_target(), s_code);
  	    else {
  		target_col = 1;
  		if (s_lab != e_lab)
! 		    target_col = count_spaces(compute_label_target(), s_lab);
  	    }
  	    ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? ps.decl_com_ind : ps.com_ind;
  	    if (ps.com_col < target_col)
--- 114,124 ----
  	    register    target_col;
  	    break_delim = 0;
  	    if (s_code != e_code)
! 		target_col = count_spaces(comp_code_target(), s_code);
  	    else {
  		target_col = 1;
  		if (s_lab != e_lab)
! 		    target_col = count_spaces(comp_label_target(), s_lab);
  	    }
  	    ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? ps.decl_com_ind : ps.com_ind;
  	    if (ps.com_col < target_col)