From: VZDMZA::IN%"HUBER%DM0MPI53.BITNET@vm.gmd.de" "Joseph Huber, MPI Muenchen" 19-FEB-1992 14:33:46.94 To: IN%"WIEHL@VKCMZD.Chemie.Uni-Mainz.de" CC: Subj: INDENT PART 4 of 5 Received: from vm.gmd.de by VzdmzA.ZDV.Uni-Mainz.DE (PMDF #12046) id <01GGPFU4N5TS8WW2KM@VzdmzA.ZDV.Uni-Mainz.DE>; Wed, 19 Feb 1992 14:24 GMT +0100 Received: from DM0MPI11 by vm.gmd.de (IBM VM SMTP R1.2.2MX) with BSMTP id 3047; Wed, 19 Feb 92 14:25:56 CET Received: from DM0MPI53.BITNET (DM0MPI53@DM0MPI12) by DM0MPI11 (Mailer R2.08) with BSMTP id 9512; Wed, 19 Feb 92 14:26:52 GMT Date: Wed, 19 Feb 92 13:34 +0200 From: "Joseph Huber, MPI Muenchen" Subject: INDENT PART 4 of 5 To: WIEHL@VKCMZD.Chemie.Uni-Mainz.de Message-id: <01GGPFU4N5TS8WW2KM@VzdmzA.ZDV.Uni-Mainz.DE> Organization: Max-Planck-Institut fuer Physik, Muenchen X-Envelope-to: WIEHL@VKCMZD.Chemie.Uni-Mainz.de X-Delivery-Notice: SMTP MAIL FROM does not correspond to sender. X-Original-To: RSCS%"WIEHL@VKCMZD.CHEMIE.UNI-MAINZ.DE" Comments: This is gatewayed mail. WARNING: Mail may not necessarily be returnable thru this path. -+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+ X`09`09`09 ); X`09`09`09--i); X`09`09ps.i_l_follow = ps.il`5Bi`5D; X`09`09/* X`09`09 * for the time being, we will assume that there is no else on X`09`09 * this if, and set the indentation level accordingly. If an X`09`09 * else is scanned, it will be fixed up later X`09`09 */ X`09`09break; X X`09 case swstmt: X`09`09/* */ X`09`09case_ind = ps.cstk`5Bps.tos - 1`5D; X X`09 case decl:`09`09/* finish of a declaration */ X`09 case elsehead: X`09`09/* < else> */ X`09 case forstmt: X`09`09/* */ X`09 case whilestmt: X`09`09/* */ X`09`09ps.p_stack`5B--ps.tos`5D = stmt; X`09`09ps.i_l_follow = ps.il`5Bps.tos`5D; X`09`09break; X X`09 default:`09`09/* */ X`09`09return; X X`09 `7D`09`09`09/* end of section for on top of stack */ X`09 break; X X`09case whilestmt:`09/* while (...) on top */ X`09 if (ps.p_stack`5Bps.tos - 1`5D == dohead) `7B X`09`09/* it is termination of a do while */ X`09`09ps.p_stack`5B--ps.tos`5D = stmt; X`09`09break; X`09 `7D X`09 else X`09`09return; X X`09default:`09`09/* anything else on top */ X`09 return; X X`09`7D X `7D X`7D $ CALL UNPACK PARSE.C;4 1160558241 $ create 'f' X/* X * Copyright (c) 1985 Sun Microsystems, Inc. X * Copyright (c) 1980 The Regents of the University of California. X * Copyright (c) 1976 Board of Trustees of the University of Illinois. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that: (1) source distributions retain this entire copyright X * notice and comment, and (2) distributions including binaries display X * the following acknowledgement: `60`60This product includes software X * developed by the University of California, Berkeley and its contributors' V' X * in the documentation or other materials provided with the distribution X * and in all advertising materials mentioning features or use of this X * software. Neither the name of the University nor the names of its X * contributors may be used to endorse or promote products derived X * from this software without specific prior written permission. X * THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X */ X X#ifndef lint Xstatic char sccsid`5B`5D = "@(#)pr_comment.c`095.11 (Berkeley) 6/1/90"; X#endif /* not lint */ X X/* X * NAME: X *`09pr_comment X * X * FUNCTION: X *`09This routine takes care of scanning and printing comments. X * X * ALGORITHM: X *`091) Decide where the comment should be aligned, and if lines should X *`09 be broken. X *`092) If lines should not be broken and filled, just copy up to end of X *`09 comment. X *`093) If lines should be filled, then scan thru input_buffer copying X *`09 characters to com_buf. Remember where the last blank, tab, or X *`09 newline was. When line is filled, print up to last blank and X *`09 continue copying. X * X * HISTORY: X *`09November 1976`09D A Willcox of CAC`09Initial coding X *`0912/6/76`09`09D A Willcox of CAC`09Modification to handle X *`09`09`09`09`09`09UNIX-style comments X * X */`0C X X/* X * this routine processes comments. It makes an attempt to keep comments fr Vom X * going over the max line length. If a line is too long, it moves everythi Vng X * from the last blank to the next comment line. Blanks and tabs from the X * beginning of the input line are removed X */ X X X#include "indent_globs.h" X X Xpr_comment() X`7B X int now_col;`09/* column we are in now */ X int adj_max_col;`09/* Adjusted max_col for when we decide to X`09`09`09`09 * spill comments over the right margin */ X char *last_bl;`09/* points to the last blank in the output X`09`09`09`09 * buffer */ X char *t_ptr;`09`09/* used for moving string */ X int unix_comment;`09/* tri-state variable used to decide if it i Vs X`09`09`09`09 * a unix-style comment. 0 means only blanks X`09`09`09`09 * since /*, 1 means regular style comment, 2 X`09`09`09`09 * means unix style comment */ X int break_delim = comment_delimiter_on_blankline; X int l_just_saw_decl = ps.just_saw_decl; X /* X * int ps.last_nl = 0;`09/* true iff the last significant thing X * weve seen is a newline X */ X int one_liner = 1;`09/* true iff this comment is a one-liner */ X`09int`09this_level = ps.ind_level; X adj_max_col = max_col; X ps.just_saw_decl = 0; X last_bl = 0;`09`09/* no blanks found so far */ X ps.box_com = false;`09`09/* at first, assume that we are not in X`09`09`09`09`09 * a boxed comment or some other X`09`09`09`09`09 * comment that should not be touched */ X ++ps.out_coms;`09`09/* keep track of number of comments */ X unix_comment = 1;`09`09/* set flag to let us figure out if there is a X`09`09`09`09 * unix-style comment ** DISABLED: use 0 to X`09`09`09`09 * reenable this hack! */ X X /* Figure where to align and how to treat the comment */ X X if (ps.col_1 && !format_col1_comments) `7B`09/* if comment starts in col Vumn X`09`09`09`09`09`09 * 1 it should not be touched */ X`09if (break_delim) ps.box_com = true; X`09ps.com_col = 1; X `7D X else `7B X`09if ((*buf_ptr == '-' `7C`7C *buf_ptr == '*') && break_delim) `7B X`09 ps.box_com = true;`09/* a comment with a '-' or '*' immediately X`09`09`09`09 * after the /* is assumed to be a boxed X`09`09`09`09 * comment */ X`09 break_delim = 0; X`09`7D X`09if ( /* ps.bl_line && */ (s_lab == e_lab) && (s_code == e_code)) `7B X`09 /* klg: check only if this line is blank */ X`09 /* X`09 * If this (*and previous lines are*) blank, dont put comment way X`09 * out at left X`09 */ X`09 ps.com_col = (ps.ind_level - ps.unindent_displace) * ps.ind_size + 1; X`09 adj_max_col = block_comment_max_col; X`09 if (ps.com_col <= 1) X`09`09ps.com_col = 1 + !format_col1_comments; X`09`7D X`09else `7B X`09 register target_col; X`09 break_delim = 0; X`09 if (s_code != e_code) X`09`09target_col = count_spaces(compute_code_target(), s_code); X`09 else `7B X`09`09target_col = 1; X`09`09if (s_lab != e_lab) X`09`09 target_col = count_spaces(compute_label_target(), s_lab); X`09 `7D X`09 ps.com_col = ps.decl_on_line `7C`7C ps.ind_level == 0 ? ps.decl_com_i Vnd : ps.com_ind; X`09 if (ps.com_col < target_col) X`09`09ps.com_col = ((target_col + 7) & `7E7) + 1; X`09 if (ps.com_col + 24 > adj_max_col) X`09`09adj_max_col = ps.com_col + 24; X`09`7D X `7D X if (ps.box_com) `7B X`09buf_ptr`5B-2`5D = 0; X`09ps.n_comment_delta = 1 - count_spaces(1, in_buffer); X`09buf_ptr`5B-2`5D = '/'; X `7D X else `7B X`09ps.n_comment_delta = 0; X/*`09while (*buf_ptr == ' ' `7C`7C *buf_ptr == '\t') X`09 buf_ptr++; */ /* Leave preceding spaces alone! */ X `7D X ps.comment_delta = 0; X *e_com++ = '/';`09`09/* put '/*' into buffer */ X *e_com++ = '*'; X *e_com = '\0'; X if (troff) `7B X`09now_col = 1; X`09adj_max_col = 80; X `7D X else X`09now_col = count_spaces(ps.com_col, s_com);`09/* figure what column we X`09`09`09`09`09`09`09 * would be in if we X`09`09`09`09`09`09`09 * printed the comment X`09`09`09`09`09`09`09 * now */ X X /* Start to copy the comment */ X X while (1) `7B`09`09`09/* this loop will go until the comment is X`09`09`09`09 * copied */ X`09if (*buf_ptr > 040 && *buf_ptr != '*') X`09 ps.last_nl = 0; X`09CHECK_SIZE_COM; X`09switch (*buf_ptr) `7B`09/* this checks for various spcl cases */ X`09case 014:`09`09/* check for a form feed */ X`09 if (!ps.box_com) `7B`09/* in a text comment, break the line here */ X`09`09ps.use_ff = true; X`09`09/* fix so dump_line uses a form feed */ X`09`09dump_line(); X`09`09last_bl = 0; X`09`09*e_com++ = ' '; X`09`09*e_com++ = '*'; X`09`09*e_com++ = ' '; X`09`09while (*++buf_ptr == ' ' `7C`7C *buf_ptr == '\t'); X`09 `7D X`09 else `7B X`09`09if (++buf_ptr >= buf_end) X`09`09 fill_buffer(); X`09`09*e_com++ = 014; X`09 `7D X`09 break; X X`09case '\n': X`09 if (had_eof) `7B`09/* check for unexpected eof */ X`09`09printf("Unterminated comment\n"); X`09`09*e_com = '\0'; X`09`09dump_line(); X`09`09return; X`09 `7D X`09 if (!break_delim `7C`7C ps.box_com `7C`7C ps.last_nl) `7B`09/* if thi Vs is a boxed comment, X`09`09`09`09`09`09 * we dont ignore the newline */ X`09`09if (s_com == e_com) `7B X`09`09 *e_com++ = ' '; X`09`09 *e_com++ = ' '; X`09`09`7D X`09`09*e_com = '\0'; X`09 if (!ps.box_com && !one_liner) X`09`09 ps.com_col = 1 +`20 X`09`09`09`09this_indent + com_col_actual - com_col_start; X`09`09else if (ps.ind_stmt) X`09`09 ps.com_col = ps.ind_size * this_level + 1 +`20 X`09`09`09`09this_indent - prev_indent; X`09`09if (!ps.box_com && e_com - s_com > 3) `7B X`09`09 if (break_delim == 1 && s_com`5B0`5D == '/' X`09`09`09 && s_com`5B1`5D == '*' && s_com`5B2`5D == ' ') `7B X`09`09`09char *t = e_com; X`09`09`09break_delim = 2; X`09`09`09e_com = s_com + 2; X`09`09`09*e_com = 0; X`09`09`09if (blanklines_before_blockcomments) X`09`09`09 prefix_blankline_requested = 1; X`09`09`09dump_line(); X`09`09`09e_com = t; X`09`09`09s_com`5B0`5D = s_com`5B1`5D = s_com`5B2`5D = ' '; X`09`09 `7D X`09`09 dump_line(); X`09`09`7D else `7B X`09`09 dump_line(); X`09 `7D X`09`09now_col = ps.com_col; X`09 this_indent = 0; X`09 `7D X`09 else `7B X`09`09ps.last_nl = 1; X`09`09if (unix_comment != 1) `7B`09/* we not are in unix_style X`09`09`09`09`09`09 * comment */ X`09`09 if (unix_comment == 0 && s_code == e_code) `7B X`09`09`09/* X`09`09`09 * if it is a UNIX-style comment, ignore the X`09`09`09 * requirement that previous line be blank for X`09`09`09 * unindention X`09`09`09 */ X`09`09`09ps.com_col = (ps.ind_level - ps.unindent_displace) * ps.ind_size + V 1; X`09`09`09if (ps.com_col <= 1) X`09`09`09 ps.com_col = 2; X`09`09 `7D X`09`09 unix_comment = 2;`09/* permanently remember that we are in X`09`09`09`09`09 * this type of comment */ X`09`09 dump_line(); X`09`09 ++line_no; X`09`09 now_col = ps.com_col; X`09`09 *e_com++ = ' '; X`09`09 /* X`09`09 * fix so that the star at the start of the line will line X`09`09 * up X`09`09 */ X`09`09 do`09`09/* flush leading white space */ X`09`09`09if (++buf_ptr >= buf_end) X`09`09`09 fill_buffer(); X`09`09 while (*buf_ptr == ' ' `7C`7C *buf_ptr == '\t'); X`09`09 break; X`09`09`7D X`09`09if (*(e_com - 1) == ' ' `7C`7C *(e_com - 1) == '\t') X`09`09 last_bl = e_com - 1; X`09`09/* X`09`09 * if there was a space at the end of the last line, remember X`09`09 * where it was X`09`09 */ X`09`09else `7B`09`09/* otherwise, insert one */ X`09`09 last_bl = e_com; X`09`09 CHECK_SIZE_COM; X`09`09 *e_com++ = ' '; X`09`09 ++now_col; X`09`09`7D X`09 `7D X`09 one_liner = 0; X`09 ++line_no;`09`09/* keep track of input line number */ X`09 if (!ps.box_com) `7B X`09`09int nstar = 1; X`09`09do `7B`09`09/* flush any blanks and/or tabs at start of X`09`09`09`09 * next line */ X`09`09 if (++buf_ptr >= buf_end) X`09`09`09fill_buffer(); X `09 if (*buf_ptr == ' ') this_indent++; X `09 else if (*buf_ptr == '\t') X `09this_indent = ((this_indent + 8) / 8) * 8; X`09`09 if (star_comment_cont && *buf_ptr == '*' && --nstar >= 0) `7B X`09`09`09if (++buf_ptr >= buf_end) X`09`09`09 fill_buffer(); X`09`09`09this_indent--; X`09`09`09if (*buf_ptr == '/') X`09`09`09 goto end_of_comment; X`09`09 `7D X`09`09`7D while (*buf_ptr == ' ' `7C`7C *buf_ptr == '\t'); X`09 `7D X`09 else if (++buf_ptr >= buf_end) X`09`09fill_buffer(); X`09 break;`09`09/* end of case for newline */ X X`09case '*':`09`09/* must check for possibility of being at end X`09`09`09`09 * of comment */ X`09 if (++buf_ptr >= buf_end)`09/* get to next char after * */ X`09`09fill_buffer(); X X`09 if (unix_comment == 0)`09/* set flag to show we are not in X`09`09`09`09`09 * unix-style comment */ X`09`09unix_comment = 1; X X`09 if (*buf_ptr == '/') `7B`09/* it is the end!!! */ X`09end_of_comment: X`09`09if (++buf_ptr >= buf_end) X`09`09 fill_buffer(); X X`09 if (!ps.box_com && !one_liner) X`09`09 ps.com_col = 1 +`20 X`09`09`09`09this_indent + com_col_actual - com_col_start; X`09`09else if (ps.ind_stmt) X`09`09 ps.com_col = ps.ind_size * this_level + 1 +`20 X`09`09`09`09this_indent - prev_indent; X`09`09if (break_delim == 1 && !one_liner && s_com`5B0`5D == '/' X`09`09`09&& s_com`5B1`5D == '*' && s_com`5B2`5D == ' ') `7B X`09`09 char *t = e_com; X`09`09 break_delim = 2; X`09`09 e_com = s_com + 2; X`09`09 *e_com = 0; X`09`09 if (blanklines_before_blockcomments) X`09`09`09prefix_blankline_requested = 1; X`09`09 dump_line(); X`09`09 e_com = t; X`09`09 s_com`5B0`5D = s_com`5B1`5D = s_com`5B2`5D = ' '; X`09`09`7D X`09`09if (break_delim == 2 && e_com > s_com + 3 X`09`09`09 /* now_col > adj_max_col - 2 && !ps.box_com */ ) `7B X`09`09 *e_com = '\0'; X`09`09 dump_line(); X`09`09 now_col = ps.com_col; X`09`09`7D X`09`09CHECK_SIZE_COM; X`09`09*e_com++ = '*'; X`09`09*e_com++ = '/'; X`09`09*e_com = '\0'; X`09`09ps.just_saw_decl = l_just_saw_decl; X`09`09return; X`09 `7D X`09 else `7B`09`09/* handle isolated '*' */ X`09`09*e_com++ = '*'; X`09`09++now_col; X`09 `7D X`09 break; X`09default:`09`09/* we have a random char */ X`09 if (unix_comment == 0 && *buf_ptr != ' ' && *buf_ptr != '\t') X`09`09unix_comment = 1;`09/* we are not in unix-style comment */ X X`09 *e_com = *buf_ptr++; X`09 if (buf_ptr >= buf_end) X`09`09fill_buffer(); X X`09 if (*e_com == '\t')`09/* keep track of column */ X`09`09now_col = ((now_col - 1) & tabmask) + tabsize + 1; X`09 else if (*e_com == '\b')`09/* this is a backspace */ X`09`09--now_col; X`09 else X`09`09++now_col; X X`09 if (*e_com == ' ' `7C`7C *e_com == '\t') X`09`09last_bl = e_com; X`09 /* remember we saw a blank */ X X`09 ++e_com; X`09 if (now_col > adj_max_col && !ps.box_com && unix_comment == 1 && e_co Vm`5B-1`5D > ' ') `7B X`09`09/* X`09`09 * the comment is too long, it must be broken up X`09`09 */ X`09`09if (break_delim == 1 && s_com`5B0`5D == '/' X`09`09`09&& s_com`5B1`5D == '*' && s_com`5B2`5D == ' ') `7B X`09`09 char *t = e_com; X`09`09 break_delim = 2; X`09`09 e_com = s_com + 2; X`09`09 *e_com = 0; X`09`09 if (blanklines_before_blockcomments) X`09`09`09prefix_blankline_requested = 1; X`09`09 dump_line(); X`09`09 e_com = t; X`09`09 s_com`5B0`5D = s_com`5B1`5D = s_com`5B2`5D = ' '; X`09`09`7D X`09`09if (last_bl == 0) `7B`09/* we have seen no blanks */ X`09`09 last_bl = e_com;`09/* fake it */ X`09`09 *e_com++ = ' '; X`09`09`7D X`09`09*e_com = '\0';`09/* print what we have */ X`09`09*last_bl = '\0'; X`09`09while (last_bl > s_com && last_bl`5B-1`5D < 040) X`09`09 *--last_bl = 0; X`09`09e_com = last_bl; X`09`09dump_line(); X X`09`09*e_com++ = ' ';`09/* add blanks for continuation */ X`09`09*e_com++ = ' '; X`09`09*e_com++ = ' '; X X`09`09t_ptr = last_bl + 1; X`09`09last_bl = 0; X`09`09if (t_ptr >= e_com) `7B X`09`09 while (*t_ptr == ' ' `7C`7C *t_ptr == '\t') X`09`09`09t_ptr++; X`09`09 while (*t_ptr != '\0') `7B`09/* move unprinted part of X`09`09`09`09`09`09 * comment down in buffer */ X`09`09`09if (*t_ptr == ' ' `7C`7C *t_ptr == '\t') X`09`09`09 last_bl = e_com; X`09`09`09*e_com++ = *t_ptr++; X`09`09 `7D X`09`09`7D X`09`09*e_com = '\0'; X`09`09now_col = count_spaces(ps.com_col, s_com);`09/* recompute current X`09`09`09`09`09`09`09`09 * position */ X`09 `7D X`09 break; X`09`7D X `7D X`7D $ CALL UNPACK PR_COMMENT.C;21 1650910500 $ create 'f' X/* X * Copyright (c) 1985 Sun Microsystems, Inc. X * Copyright (c) 1980 The Regents of the University of California. X * Copyright (c) 1976 Board of Trustees of the University of Illinois. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that: (1) source distributions retain this entire copyright X * notice and comment, and (2) distributions including binaries display X * the following acknowledgement: `60`60This product includes software X * developed by the University of California, Berkeley and its contributors' V' X * in the documentation or other materials provided with the distribution X * and in all advertising materials mentioning features or use of this X * software. Neither the name of the University nor the names of its X * contributors may be used to endorse or promote products derived X * from this software without specific prior written permission. X * THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X *`09@(#)indent_codes.h`095.7 (Berkeley) 6/1/90 X */ X X#define newline`09`091 X#define lparen`09`092 X#define rparen`09`093 X#define unary_op`094 X#define binary_op`095 X#define postop`09`096 X#define question`097 X#define casestmt`098 X#define colon`09`099 X#define semicolon`0910 X#define lbrace`09`0911 X#define rbrace`09`0912 X#define ident`09`0913 X#define comma`09`0914 X#define comment`09`0915 X#define swstmt`09`0916 X#define preesc`09`0917 X#define form_feed`0918 X#define decl`09`0919 X#define sp_paren`0920 X#define sp_nparen`0921 X#define ifstmt`09`0922 X#define whilestmt`0923 X#define forstmt`09`0924 X#define stmt`09`0925 X#define stmtl`09`0926 X#define elselit`09`0927 X#define dolit`09`0928 X#define dohead`09`0929 X#define ifhead`09`0930 X#define elsehead`0931 X#define period`09`0932 $ CALL UNPACK INDENT_CODES.H;2 859326297 $ create 'f' X/* X * Copyright (c) 1985 Sun Microsystems, Inc. X * Copyright (c) 1980 The Regents of the University of California. X * Copyright (c) 1976 Board of Trustees of the University of Illinois. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that: (1) source distributions retain this entire copyright X * notice and comment, and (2) distributions including binaries display X * the following acknowledgement: `60`60This product includes software X * developed by the University of California, Berkeley and its contributors' V' X * in the documentation or other materials provided with the distribution X * and in all advertising materials mentioning features or use of this X * software. Neither the name of the University nor the names of its X * contributors may be used to endorse or promote products derived X * from this software without specific prior written permission. X * THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X *`09@(#)indent_globs.h`095.10 (Berkeley) 6/1/90 X */ X X#include X X#define BACKSLASH '\\' X#define bufsize 200`09`09/* size of internal buffers */ X#define sc_size 5000`09`09/* size of save_com buffer */ X#define label_offset 2`09`09/* number of levels a label is placed to left X`09`09`09`09 * of code */ X X#define tabsize 8`09`09/* the size of a tab */ X#define tabmask 0177770`09`09/* mask used when figuring length of lines X`09`09`09`09 * with tabs */ X X X#define false 0 X#define true 1 X X XFILE *input;`09`09/* the fid for the input file */ XFILE *output;`09`09/* the output file */ X X#define CHECK_SIZE_CODE \ X`09if (e_code >= l_code) `7B \ X`09 register nsize = l_code-s_code+400; \ X`09 codebuf = (char *) realloc(codebuf, nsize); \ X`09 e_code = codebuf + (e_code-s_code) + 1; \ X`09 l_code = codebuf + nsize - 5; \ X`09 s_code = codebuf + 1; \ X`09`7D X#define CHECK_SIZE_COM \ X`09if (e_com >= l_com) `7B \ X`09 register nsize = l_com-s_com+400; \ X`09 combuf = (char *) realloc(combuf, nsize); \ X`09 e_com = combuf + (e_com-s_com) + 1; \ X`09 l_com = combuf + nsize - 5; \ X`09 s_com = combuf + 1; \ X`09`7D X#define CHECK_SIZE_LAB \ X`09if (e_lab >= l_lab) `7B \ X`09 register nsize = l_lab-s_lab+400; \ X`09 labbuf = (char *) realloc(labbuf, nsize); \ X`09 e_lab = labbuf + (e_lab-s_lab) + 1; \ X`09 l_lab = labbuf + nsize - 5; \ X`09 s_lab = labbuf + 1; \ X`09`7D X#define CHECK_SIZE_TOKEN \ X`09if (e_token >= l_token) `7B \ X`09 register nsize = l_token-s_token+400; \ X`09 tokenbuf = (char *) realloc(tokenbuf, nsize); \ X`09 e_token = tokenbuf + (e_token-s_token) + 1; \ X`09 l_token = tokenbuf + nsize - 5; \ X`09 s_token = tokenbuf + 1; \ X`09`7D X Xchar *labbuf;`09`09/* buffer for label */ Xchar *s_lab;`09`09/* start ... */ Xchar *e_lab;`09`09/* .. and end of stored label */ Xchar *l_lab;`09`09/* limit of label buffer */ X Xchar *codebuf;`09`09/* buffer for code section */ Xchar *s_code;`09`09/* start ... */ Xchar *e_code;`09`09/* .. and end of stored code */ Xchar *l_code;`09`09/* limit of code section */ X Xchar *combuf;`09`09/* buffer for comments */ Xchar *s_com;`09`09/* start ... */ Xchar *e_com;`09`09/* ... and end of stored comments */ Xchar *l_com;`09`09/* limit of comment buffer */ X X#define token s_token Xchar *tokenbuf;`09`09/* the last token scanned */ Xchar`09 *s_token; Xchar *e_token; Xchar`09 *l_token; X Xchar *in_buffer;`09`09/* input buffer */ Xchar`09 *in_buffer_limit;`09/* the end of the input buffer */ Xchar *buf_ptr;`09`09/* ptr to next character to be taken from X`09`09`09`09 * in_buffer */ Xchar *buf_end;`09`09/* ptr to first after last char in in_buffer */ X Xchar save_com`5Bsc_size`5D;`09/* input text is saved here when lookin Vg for X`09`09`09`09 * the brace after an if, while, etc */ Xchar *sc_end;`09`09/* pointer into save_com buffer */ X Xchar *bp_save;`09`09/* saved value of buf_ptr when taking input X`09`09`09`09 * from save_com */ Xchar *be_save;`09`09/* similarly saved value of buf_end */ X X Xint pointer_as_binop; Xint blanklines_after_declarations; Xint blanklines_before_blockcomments; Xint blanklines_after_procs; Xint blank_conditional_compilation; Xint swallow_optional_blanklines; Xint n_real_blanklines; Xint prefix_blankline_requested; Xint postfix_blankline_requested; Xint break_comma;`09/* when true and not in parens, break after a X`09`09`09`09 * comma */ Xint btype_2;`09`09/* when true, brace should be on same line as X`09`09`09`09 * if, while, etc */ Xfloat case_ind;`09`09/* indentation level to be used for a "case X`09`09`09`09 * n:" */ Xint code_lines;`09`09/* count of lines with code */ Xint had_eof;`09`09/* set to true when input is exhausted */ Xint line_no;`09`09/* the current line number. */ Xint max_col;`09`09/* the maximum allowable line length */ Xint verbose;`09`09/* when true, non-essential error messages are X`09`09`09`09 * printed */ Xint cuddle_else;`09/* true if else should cuddle up to '`7D' */ Xint star_comment_cont;`09/* true iff comment continuation lines shou Vld X`09`09`09`09 * have stars at the beginning of each line. */ Xint comment_delimiter_on_blankline; Xint troff;`09`09/* true iff were generating troff input */ Xint procnames_start_line;`09/* if true, the names of procedures X`09`09`09`09`09 * being defined get placed in column X`09`09`09`09`09 * 1 (ie. a newline is placed between X`09`09`09`09`09 * the type of the procedure and its X`09`09`09`09`09 * name) */ Xint proc_calls_space;`09/* If true, procedure calls look like: X`09`09`09`09 * foo(bar) rather than foo (bar) */ Xint format_col1_comments;`09/* If comments which start in column 1 X`09`09`09`09`09 * are to be magically reformatted X`09`09`09`09`09 * (just like comments that begin in X`09`09`09`09`09 * later columns) */ Xint inhibit_formatting;`09/* true if INDENT OFF is in effect */ Xint suppress_blanklines;/* set iff following blanklines should be X`09`09`09`09 * suppressed */ Xint continuation_indent;/* set to the indentation between the edge o Vf X`09`09`09`09 * code and continuation lines */ Xint lineup_to_parens;`09/* if true, continued code within parens wil Vl X`09`09`09`09 * be lined up to the open paren */ Xint Bill_Shannon;`09/* true iff a blank should always be inserted X`09`09`09`09 * after sizeof */ Xint blank_declarations_at_proctop;`09/* This is vaguely X`09`09`09`09`09`09`09 * similar to X`09`09`09`09`09`09`09 * blanklines_after_decla X`09`09`09`09`09`09`09 * rations except that X`09`09`09`09`09`09`09 * it only applies to X`09`09`09`09`09`09`09 * the first set of X`09`09`09`09`09`09`09 * declarations in a X`09`09`09`09`09`09`09 * procedure (just after X`09`09`09`09`09`09`09 * the first '`7B') and it X`09`09`09`09`09`09`09 * causes a blank line X`09`09`09`09`09`09`09 * to be generated even X`09`09`09`09`09`09`09 * if there are no X`09`09`09`09`09`09`09 * declarations */ Xint block_comment_max_col; Xint extra_expression_indent;`09/* True if continuation lines from th Ve X`09`09`09`09`09 * expression part of "if(e)", X`09`09`09`09`09 * "while(e)", "for(e;e;e)" should be X`09`09`09`09`09 * indented an extra tab stop so that X`09`09`09`09`09 * they don't conflict with the code X`09`09`09`09`09 * that follows */ Xint spaces_after_comma;`09`09/* if true, leave blank after comma */ Xint break_single_line;`09`09/* breakup "if() stmt;" into 2 lines */ X X/* -troff font state information */ X Xstruct fstate `7B X char font`5B4`5D; X char size; X int allcaps:1; X`7D; Xchar *chfont(); X Xstruct fstate X keywordf,`09`09/* keyword font */ X stringf,`09`09/* string font */ X boxcomf,`09`09/* Box comment font */ X blkcomf,`09`09/* Block comment font */ X scomf,`09`09/* Same line comment font */ X bodyf;`09`09/* major body font */ X X X#define STACKSIZE 150 X Xstruct parser_state `7B X int last_token; X struct fstate cfont;`09/* Current font */ X int p_stack`5BSTACKSIZE`5D;`09/* this is the parsers stack */ X int il`5BSTACKSIZE`5D;`09/* this stack stores indentation levels V */ X float cstk`5BSTACKSIZE`5D;/* used to store case stmt indentation l Vevels */ X int box_com;`09/* set to true when we are in a "boxed" X`09`09`09`09 * comment. In that case, the first non-blank X`09`09`09`09 * char should be lined up with the / in /* */ X int comment_delta, X n_comment_delta; X int cast_mask;`09/* indicates which close parens close off X`09`09`09`09 * casts */ X int sizeof_mask;`09/* indicates which close parens close off X`09`09`09`09 * sizeof''s */ X int block_init;`09/* true iff inside a block initialization */ X int block_init_level;`09/* The level of brace nesting in an X`09`09`09`09`09 * initialization */ X int last_nl;`09/* this is true if the last thing scanned was X`09`09`09`09 * a newline */ X int in_or_st;`09/* Will be true iff there has been a X`09`09`09`09 * declarator (e.g. int or char) and no left X`09`09`09`09 * paren since the last semicolon. When true, X`09`09`09`09 * a '`7B' is starting a structure definition or X`09`09`09`09 * an initialization list */ X int bl_line;`09/* set to 1 by dump_line if the line is blank */ X int col_1;`09`09/* set to true if the last token started in X`09`09`09`09 * column 1 */ X int com_col;`09/* this is the column in which the current X`09`09`09`09 * coment should start */ X int com_ind;`09/* the column in which comments to the right X`09`09`09`09 * of code should start */ X int com_lines;`09/* the number of lines with comments, set by X`09`09`09`09 * dump_line */ X int dec_nest;`09/* current nesting level for structure or init * V/ X int decl_com_ind;`09/* the column in which comments after X`09`09`09`09 * declarations should be put */ X int decl_on_line;`09/* set to true if this line of code has part X`09`09`09`09 * of a declaration on it */ X int i_l_follow;`09/* the level to which ind_level should be set X`09`09`09`09 * after the current line is printed */ X int in_decl;`09/* set to true when we are in a declaration X`09`09`09`09 * stmt. The processing of braces is then X`09`09`09`09 * slightly different */ X int in_stmt;`09/* set to 1 while in a stmt */ X int ind_level;`09/* the current indentation level */ X int ind_size;`09/* the size of one indentation level */ X int ind_stmt;`09/* set to 1 if next line should have an extra X`09`09`09`09 * indentation level because we are in the X`09`09`09`09 * middle of a stmt */ X int last_u_d;`09/* set to true after scanning a token which X`09`09`09`09 * forces a following operator to be unary */ X int leave_comma;`09/* if true, never break declarations after X`09`09`09`09 * commas */ X int ljust_decl;`09/* true if declarations should be left X`09`09`09`09 * justified */ X int out_coms;`09/* the number of comments processed, set by X`09`09`09`09 * pr_comment */ X int out_lines;`09/* the number of lines written, set by X`09`09`09`09 * dump_line */ X int p_l_follow;`09/* used to remember how to indent following X`09`09`09`09 * statement */ X int paren_level;`09/* parenthesization level. used to indent X`09`09`09`09 * within stmts */ X short paren_indents`5B20`5D;`09/* column positions of each paren * V/ X int pcase;`09`09/* set to 1 if the current line label is a X`09`09`09`09 * case. It is printed differently from a X`09`09`09`09 * regular label */ X int search_brace;`09/* set to true by parse when it is necessary X`09`09`09`09 * to buffer up all info up to the start of a X`09`09`09`09 * stmt after an if, while, etc */ X int unindent_displace;`09/* comments not to the right of code X`09`09`09`09`09 * will be placed this many X`09`09`09`09`09 * indentation levels to the left of X`09`09`09`09`09 * code */ X int use_ff;`09`09/* set to one if the current line should be X`09`09`09`09 * terminated with a form feed */ X int want_blank;`09/* set to true when the following token should X`09`09`09`09 * be prefixed by a blank. (Said prefixing is X`09`09`09`09 * ignored in some cases.) */ X int else_if;`09/* True iff else if pairs should be handled X`09`09`09`09 * specially */ X int decl_indent;`09/* column to indent declared identifiers to * V/ X int its_a_keyword; X int sizeof_keyword; X int dumped_decl_indent; X float case_indent;`09/* The distance to indent case labels from th Ve X`09`09`09`09 * switch statement */ X float case_code_indent;/* The distance to indent case code from th Ve X`09`09`09`09 * case label */ X int in_parameter_declaration; X int indent_parameters; X int tos;`09`09/* pointer to top of stack */ X char procname`5B100`5D;`09/* The name of the current procedure */ X int just_saw_decl; X`7D ps; X Xint ifdef_level; Xint`09 rparen_count; Xstruct parser_state state_stack`5B5`5D; Xstruct parser_state match_state`5B5`5D; Xint this_indent=0,prev_indent=0,com_col_start,com_col_actual,cplus,paren_spa Vce; $ CALL UNPACK INDENT_GLOBS.H;11 1866979575 $ create 'f' X#define MAXPATHLEN 20 $ CALL UNPACK PARAM.H;1 1747996979 $ create 'f' X.\" Copyright (c) 1980, 1990 The Regents of the University of California. X.\" Copyright (c) 1985 Sun Microsystems, Inc. X.\" Copyright (c) 1976 Board of Trustees of the University of Illinois. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms are permitted provided X.\" that: (1) source distributions retain this entire copyright notice and X.\" comment, and (2) distributions including binaries display the following X.\" acknowledgement: `60`60This product includes software developed by the X.\" University of California, Berkeley and its contributors'' in the X.\" documentation or other materials provided with the distribution and in X.\" all advertising materials mentioning features or use of this software. X.\" Neither the name of the University nor the names of its contributors may X.\" be used to endorse or promote products derived from this software withou Vt X.\" specific prior written permission. X.\" THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR IMPLI VED X.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X.\" X.\" @(#)indent.1`096.8 (Berkeley) 7/24/90 X.\" X.Dd July 24, 1990 X.Dt INDENT 1 X.Sh NAME X.Nm indent X.Nd indent and format C program source X.Sh SYNOPSIS X.Nm indent X.Op Ar input-file Op Ar output-file X.Cx \&`5B X.Fl bad X.Cx \&\ `7C\ \& X.Fl nbad X.Cx \&`5D X.Cx X.Cx \&`5B X.Fl bap X.Cx \&\ `7C\ \& X.Fl nbap X.Cx \&`5D X.Cx X.Cx \&`5B X.Fl bbb X.Cx \&\ `7C\ \& X.Fl nbbb X.Cx \&`5D X.Cx X.Cx \&`5B X.Fl bc X.Cx \&\ `7C\ \& X.Fl nbc X.Cx \&`5D X.Cx X.Op Fl bl X.Op Fl br X.Oo X.Op Fl c Ar n X.Op Fl cd Ar n X.Oo X.Cx \&`5B X.Fl cdb X.Cx \&\ `7C\ \& X.Fl ncdb X.Cx \&`5D X.Cx X.Cx \&`5B X.Fl ce X.Cx \&\ `7C\ \& X.Fl nce X.Cx \&`5D X.Cx X.Oo X.Op Fl ci Ar n X.Op Fl cli Ar n X.Op Fl d Ar n X.Op Fl di Ar n X.Oo +-+-+-+-+-+-+-+- END OF PART 4 +-+-+-+-+-+-+-+-