[comp.sources.bugs] Indent on older SysV, cpp problems

scs@lokkur.UUCP (Steve Simmons) (04/10/89)

The recent posting of indent required a number of changes to get running
on my UNIX-PC.  In particular one of the macros needed to be massively
redone and a couple of the file names were too long for RCS to make
library names of.  These patches make those changes.  I suspect that
the resulting code will be somewhat more portable.

These assume Gary Trujillos system V patches have already been applied.

Steve

*** /tmp/,RCSt1a03209	Sun Apr  9 12:47:20 1989
--- args.c	Sat Apr  8 15:48:15 1989
***************
*** 27,33 ****
   * here as well.
   */
  
! #include "indent_globs.h"
  #include <sys/types.h>
  #include <ctype.h>
  
--- 27,33 ----
   * here as well.
   */
  
! #include "i_globs.h"
  #include <sys/types.h>
  #include <ctype.h>
  
*** /tmp/,RCSt1a03209	Sun Apr  9 12:47:32 1989
--- indent.c	Sat Apr  8 15:48:18 1989
***************
*** 30,37 ****
  static char sccsid[] = "@(#)indent.c	5.11 (Berkeley) 9/15/88";
  #endif /* not lint */
  
! #include "indent_globs.h"
! #include "indent_codes.h"
  #include <sys/param.h>
  #include <ctype.h>
  
--- 30,37 ----
  static char sccsid[] = "@(#)indent.c	5.11 (Berkeley) 9/15/88";
  #endif /* not lint */
  
! #include "i_globs.h"
! #include "i_codes.h"
  #include <sys/param.h>
  #include <ctype.h>
  
***************
*** 427,433 ****
  					 * in a line. fix it */
  		*e_code++ = ' ';
  		for (t_ptr = s_com; *t_ptr; ++t_ptr) {
! 		    check_size(code);
  		    *e_code++ = *t_ptr;
  		}
  		*e_code++ = ' ';
--- 427,433 ----
  					 * in a line. fix it */
  		*e_code++ = ' ';
  		for (t_ptr = s_com; *t_ptr; ++t_ptr) {
! 		    check_code_size;
  		    *e_code++ = *t_ptr;
  		}
  		*e_code++ = ' ';
***************
*** 445,451 ****
  	/*-----------------------------------------------------*\
  	|	   do switch on type of token scanned		|
  	\*-----------------------------------------------------*/
! 	check_size(code);
  	switch (type_code) {	/* now, decide what to do with the token */
  
  	case form_feed:	/* found a form feed in line */
--- 445,451 ----
  	/*-----------------------------------------------------*\
  	|	   do switch on type of token scanned		|
  	\*-----------------------------------------------------*/
! 	check_code_size;
  	switch (type_code) {	/* now, decide what to do with the token */
  
  	case form_feed:	/* found a form feed in line */
***************
*** 477,483 ****
  		}
  		else {
  		    while ((e_code - s_code) < dec_ind) {
! 			check_size(code);
  			*e_code++ = ' ';
  		    }
  		    *e_code++ = token[0];
--- 477,483 ----
  		}
  		else {
  		    while ((e_code - s_code) < dec_ind) {
! 			check_code_size;
  			*e_code++ = ' ';
  		    }
  		    *e_code++ = token[0];
***************
*** 554,560 ****
  							 * token */
  		    for (i = 0; token[i]; ++i);	/* find length of token */
  		    while ((e_code - s_code) < (dec_ind - i)) {
! 			check_size(code);
  			*e_code++ = ' ';	/* pad it */
  		    }
  		}
--- 554,560 ----
  							 * token */
  		    for (i = 0; token[i]; ++i);	/* find length of token */
  		    while ((e_code - s_code) < (dec_ind - i)) {
! 			check_code_size;
  			*e_code++ = ' ';	/* pad it */
  		    }
  		}
***************
*** 561,567 ****
  		if (troff && token[0] == '-' && token[1] == '>')
  		    res = "\\(->";
  		for (t_ptr = res; *t_ptr; ++t_ptr) {
! 		    check_size(code);
  		    *e_code++ = *t_ptr;
  		}
  	    }
--- 561,567 ----
  		if (troff && token[0] == '-' && token[1] == '>')
  		    res = "\\(->";
  		for (t_ptr = res; *t_ptr; ++t_ptr) {
! 		    check_code_size;
  		    *e_code++ = *t_ptr;
  		}
  	    }
***************
*** 597,603 ****
  			break;
  		    }
  		for (t_ptr = res; *t_ptr; ++t_ptr) {
! 		    check_size(code);
  		    *e_code++ = *t_ptr;	/* move the operator */
  		}
  	    }
--- 597,603 ----
  			break;
  		    }
  		for (t_ptr = res; *t_ptr; ++t_ptr) {
! 		    check_code_size;
  		    *e_code++ = *t_ptr;	/* move the operator */
  		}
  	    }
***************
*** 671,677 ****
  
  	    if (ps.in_decl && s_code == e_code && !ps.block_init)
  		while ((e_code - s_code) < (dec_ind - 1)) {
! 		    check_size(code);
  		    *e_code++ = ' ';
  		}
  
--- 671,677 ----
  
  	    if (ps.in_decl && s_code == e_code && !ps.block_init)
  		while ((e_code - s_code) < (dec_ind - 1)) {
! 		    check_code_size;
  		    *e_code++ = ' ';
  		}
  
***************
*** 890,896 ****
  			}
  			else
  			    while ((e_code - s_code) < dec_ind) {
! 				check_size(code);
  				*e_code++ = ' ';
  			    }
  		}
--- 890,896 ----
  			}
  			else
  			    while ((e_code - s_code) < dec_ind) {
! 				check_code_size;
  				*e_code++ = ' ';
  			    }
  		}
***************
*** 914,920 ****
  	    if (troff && ps.its_a_keyword) {
  		e_code = chfont(&bodyf, &keywordf, e_code);
  		for (t_ptr = token; *t_ptr; ++t_ptr) {
! 		    check_size(code);
  		    *e_code++ = keywordf.allcaps && islower(*t_ptr)
  			? toupper(*t_ptr) : *t_ptr;
  		}
--- 914,920 ----
  	    if (troff && ps.its_a_keyword) {
  		e_code = chfont(&bodyf, &keywordf, e_code);
  		for (t_ptr = token; *t_ptr; ++t_ptr) {
! 		    check_code_size;
  		    *e_code++ = keywordf.allcaps && islower(*t_ptr)
  			? toupper(*t_ptr) : *t_ptr;
  		}
***************
*** 922,928 ****
  	    }
  	    else
  		for (t_ptr = token; *t_ptr; ++t_ptr) {
! 		    check_size(code);
  		    *e_code++ = *t_ptr;
  		}
  	    ps.want_blank = true;
--- 922,928 ----
  	    }
  	    else
  		for (t_ptr = token; *t_ptr; ++t_ptr) {
! 		    check_code_size;
  		    *e_code++ = *t_ptr;
  		}
  	    ps.want_blank = true;
***************
*** 940,946 ****
  						 * line */
  	    if (ps.in_decl && is_procname == 0 && !ps.block_init)
  		while ((e_code - s_code) < (dec_ind - 1)) {
! 		    check_size(code);
  		    *e_code++ = ' ';
  		}
  
--- 940,946 ----
  						 * line */
  	    if (ps.in_decl && is_procname == 0 && !ps.block_init)
  		while ((e_code - s_code) < (dec_ind - 1)) {
! 		    check_code_size;
  		    *e_code++ = ' ';
  		}
  
***************
*** 966,972 ****
  		int         com_end = 0;
  
  		while (*buf_ptr != '\n' || in_comment) {
! 		    check_size(lab);
  		    *e_lab = *buf_ptr++;
  		    if (buf_ptr >= buf_end)
  			fill_buffer();
--- 966,972 ----
  		int         com_end = 0;
  
  		while (*buf_ptr != '\n' || in_comment) {
! 		    check_lab_size;
  		    *e_lab = *buf_ptr++;
  		    if (buf_ptr >= buf_end)
  			fill_buffer();
*** /tmp/,RCSt1a03209	Sun Apr  9 12:47:43 1989
--- io.c	Sat Apr  8 15:48:20 1989
***************
*** 22,28 ****
  static char sccsid[] = "@(#)io.c	5.10 (Berkeley) 9/15/88";
  #endif /* not lint */
  
! #include "indent_globs.h"
  #include <ctype.h>
  
  
--- 22,28 ----
  static char sccsid[] = "@(#)io.c	5.10 (Berkeley) 9/15/88";
  #endif /* not lint */
  
! #include "i_globs.h"
  #include <ctype.h>
  
  
*** /tmp/,RCSt1a03209	Sun Apr  9 12:47:51 1989
--- lexi.c	Sat Apr  8 15:48:23 1989
***************
*** 28,35 ****
   * of token scanned.
   */
  
! #include "indent_globs.h"
! #include "indent_codes.h"
  #include "ctype.h"
  
  #define alphanum 1
--- 28,35 ----
   * of token scanned.
   */
  
! #include "i_globs.h"
! #include "i_codes.h"
  #include "ctype.h"
  
  #define alphanum 1
*** /tmp/,RCSt1a03209	Sun Apr  9 12:47:59 1989
--- parse.c	Sat Apr  8 15:52:13 1989
***************
*** 22,29 ****
  static char sccsid[] = "@(#)parse.c	5.8 (Berkeley) 9/15/88";
  #endif /* not lint */
  
! #include "./indent_globs.h"
! #include "./indent_codes.h"
  
  
  
--- 22,29 ----
  static char sccsid[] = "@(#)parse.c	5.8 (Berkeley) 9/15/88";
  #endif /* not lint */
  
! #include "./i_globs.h"
! #include "./i_codes.h"
  
  
  
*** /tmp/,RCSt1a03209	Sun Apr  9 12:48:07 1989
--- pr_comment.c	Sat Apr  8 15:48:28 1989
***************
*** 54,60 ****
   */
  
  
! #include "indent_globs.h"
  
  
  pr_comment()
--- 54,60 ----
   */
  
  
! #include "i_globs.h"
  
  
  pr_comment()
***************
*** 162,168 ****
  				 * copied */
  	if (*buf_ptr > 040 && *buf_ptr != '*')
  	    ps.last_nl = 0;
! 	check_size(com);
  	switch (*buf_ptr) {	/* this checks for various spcl cases */
  	case 014:		/* check for a form feed */
  	    if (!ps.box_com) {	/* in a text comment, break the line here */
--- 162,168 ----
  				 * copied */
  	if (*buf_ptr > 040 && *buf_ptr != '*')
  	    ps.last_nl = 0;
! 	check_com_size;
  	switch (*buf_ptr) {	/* this checks for various spcl cases */
  	case 014:		/* check for a form feed */
  	    if (!ps.box_com) {	/* in a text comment, break the line here */
***************
*** 211,217 ****
  			s_com[0] = s_com[1] = s_com[2] = ' ';
  		    }
  		    dump_line();
! 		    check_size(com);
  		    *e_com++ = ' ';
  		    *e_com++ = ' ';
  		}
--- 211,217 ----
  			s_com[0] = s_com[1] = s_com[2] = ' ';
  		    }
  		    dump_line();
! 		    check_com_size;
  		    *e_com++ = ' ';
  		    *e_com++ = ' ';
  		}
***************
*** 256,262 ****
  		 */
  		else {		/* otherwise, insert one */
  		    last_bl = e_com;
! 		    check_size(com);
  		    *e_com++ = ' ';
  		    ++now_col;
  		}
--- 256,262 ----
  		 */
  		else {		/* otherwise, insert one */
  		    last_bl = e_com;
! 		    check_com_size;
  		    *e_com++ = ' ';
  		    ++now_col;
  		}
***************
*** 317,323 ****
  		    dump_line();
  		    now_col = ps.com_col;
  		}
! 		check_size(com);
  		*e_com++ = '*';
  		*e_com++ = '/';
  		*e_com = '\0';
--- 317,323 ----
  		    dump_line();
  		    now_col = ps.com_col;
  		}
! 		check_com_size;
  		*e_com++ = '*';
  		*e_com++ = '/';
  		*e_com = '\0';
*** /tmp/,RCSt1a03209	Sun Apr  9 12:48:20 1989
--- i_globs.h	Sat Apr  8 15:42:18 1989
***************
*** 41,53 ****
  FILE       *input;		/* the fid for the input file */
  FILE       *output;		/* the output file */
  
! #define check_size(name) \
! 	if (e_/**/name >= l_/**/name) { \
! 	    register nsize = l_/**/name-s_/**/name+400; \
! 	    name/**/buf = (char *) realloc(name/**/buf, nsize); \
! 	    e_/**/name = name/**/buf + (e_/**/name-s_/**/name) + 1; \
! 	    l_/**/name = name/**/buf + nsize - 5; \
! 	    s_/**/name = name/**/buf + 1; \
  	}
  
  char       *labbuf;		/* buffer for label */
--- 41,71 ----
  FILE       *input;		/* the fid for the input file */
  FILE       *output;		/* the output file */
  
! #define check_code_size \
! 	if (e_code >= l_code) { \
! 	    register nsize = l_code-s_code+400; \
! 	    codebuf = (char *) realloc(codebuf, nsize); \
! 	    e_code = codebuf + (e_code-s_code) + 1; \
! 	    l_code = codebuf + nsize - 5; \
! 	    s_code = codebuf + 1; \
! 	}
! 
! #define check_com_size \
! 	if (e_com >= l_com) { \
! 	    register nsize = l_com-s_com+400; \
! 	    combuf = (char *) realloc(combuf, nsize); \
! 	    e_com = combuf + (e_com-s_com) + 1; \
! 	    l_com = combuf + nsize - 5; \
! 	    s_com = combuf + 1; \
! 	}
! 
! #define check_lab_size \
! 	if (e_lab >= l_lab) { \
! 	    register nsize = l_lab-s_lab+400; \
! 	    labbuf = (char *) realloc(labbuf, nsize); \
! 	    e_lab = labbuf + (e_lab-s_lab) + 1; \
! 	    l_lab = labbuf + nsize - 5; \
! 	    s_lab = labbuf + 1; \
  	}
  
  char       *labbuf;		/* buffer for label */
-- 
+ Steve Simmons, Inland Sea Software, Ltd.         scs@lokkur.dexter.mi.us +
|    9353 Hidden Lake, Dexter, MI. 48130                   313-426-8981    |
+          "When Dexter's on the Internet can Hell be far behind?"         +