170a3049eSPedro F. Giffuni /*- 2df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3df57947fSPedro F. Giffuni * 49b50d902SRodney W. Grimes * Copyright (c) 1985 Sun Microsystems, Inc. 59b50d902SRodney W. Grimes * Copyright (c) 1980, 1993 69b50d902SRodney W. Grimes * The Regents of the University of California. All rights reserved. 79b50d902SRodney W. Grimes * All rights reserved. 89b50d902SRodney W. Grimes * 99b50d902SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 109b50d902SRodney W. Grimes * modification, are permitted provided that the following conditions 119b50d902SRodney W. Grimes * are met: 129b50d902SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 139b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 149b50d902SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 159b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 169b50d902SRodney W. Grimes * documentation and/or other materials provided with the distribution. 179b50d902SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 189b50d902SRodney W. Grimes * must display the following acknowledgement: 199b50d902SRodney W. Grimes * This product includes software developed by the University of 209b50d902SRodney W. Grimes * California, Berkeley and its contributors. 219b50d902SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 229b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software 239b50d902SRodney W. Grimes * without specific prior written permission. 249b50d902SRodney W. Grimes * 259b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 269b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 279b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 289b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 299b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 309b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 319b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 329b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 339b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 349b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 359b50d902SRodney W. Grimes * SUCH DAMAGE. 369b50d902SRodney W. Grimes */ 37e026a48cSDavid E. O'Brien 38e026a48cSDavid E. O'Brien #if 0 39d0054952SPhilippe Charnier #ifndef lint 409b50d902SRodney W. Grimes static char sccsid[] = "@(#)pr_comment.c 8.1 (Berkeley) 6/6/93"; 41e026a48cSDavid E. O'Brien #endif /* not lint */ 42d0054952SPhilippe Charnier #endif 43d0054952SPhilippe Charnier 44e026a48cSDavid E. O'Brien #include <sys/cdefs.h> 45e026a48cSDavid E. O'Brien __FBSDID("$FreeBSD$"); 46e026a48cSDavid E. O'Brien 47d0054952SPhilippe Charnier #include <err.h> 489b50d902SRodney W. Grimes #include <stdio.h> 499b50d902SRodney W. Grimes #include <stdlib.h> 5054d57555SPedro F. Giffuni #include <string.h> 519b50d902SRodney W. Grimes #include "indent_globs.h" 52f30beab3SPiotr Pawel Stefaniak #include "indent_codes.h" 537916863dSJens Schweikhardt #include "indent.h" 549b50d902SRodney W. Grimes /* 559b50d902SRodney W. Grimes * NAME: 569b50d902SRodney W. Grimes * pr_comment 579b50d902SRodney W. Grimes * 589b50d902SRodney W. Grimes * FUNCTION: 599b50d902SRodney W. Grimes * This routine takes care of scanning and printing comments. 609b50d902SRodney W. Grimes * 619b50d902SRodney W. Grimes * ALGORITHM: 629b50d902SRodney W. Grimes * 1) Decide where the comment should be aligned, and if lines should 639b50d902SRodney W. Grimes * be broken. 649b50d902SRodney W. Grimes * 2) If lines should not be broken and filled, just copy up to end of 659b50d902SRodney W. Grimes * comment. 669b50d902SRodney W. Grimes * 3) If lines should be filled, then scan thru input_buffer copying 679b50d902SRodney W. Grimes * characters to com_buf. Remember where the last blank, tab, or 689b50d902SRodney W. Grimes * newline was. When line is filled, print up to last blank and 699b50d902SRodney W. Grimes * continue copying. 709b50d902SRodney W. Grimes * 719b50d902SRodney W. Grimes * HISTORY: 729b50d902SRodney W. Grimes * November 1976 D A Willcox of CAC Initial coding 739b50d902SRodney W. Grimes * 12/6/76 D A Willcox of CAC Modification to handle 749b50d902SRodney W. Grimes * UNIX-style comments 759b50d902SRodney W. Grimes * 769b50d902SRodney W. Grimes */ 779b50d902SRodney W. Grimes 789b50d902SRodney W. Grimes /* 799b50d902SRodney W. Grimes * this routine processes comments. It makes an attempt to keep comments from 809b50d902SRodney W. Grimes * going over the max line length. If a line is too long, it moves everything 819b50d902SRodney W. Grimes * from the last blank to the next comment line. Blanks and tabs from the 829b50d902SRodney W. Grimes * beginning of the input line are removed 839b50d902SRodney W. Grimes */ 849b50d902SRodney W. Grimes 857916863dSJens Schweikhardt void 867916863dSJens Schweikhardt pr_comment(void) 879b50d902SRodney W. Grimes { 889b50d902SRodney W. Grimes int now_col; /* column we are in now */ 899b50d902SRodney W. Grimes int adj_max_col; /* Adjusted max_col for when we decide to 909b50d902SRodney W. Grimes * spill comments over the right margin */ 919b50d902SRodney W. Grimes char *last_bl; /* points to the last blank in the output 929b50d902SRodney W. Grimes * buffer */ 939b50d902SRodney W. Grimes char *t_ptr; /* used for moving string */ 94*7e53aaedSPiotr Pawel Stefaniak int break_delim = opt.comment_delimiter_on_blankline; 959b50d902SRodney W. Grimes int l_just_saw_decl = ps.just_saw_decl; 96*7e53aaedSPiotr Pawel Stefaniak 97*7e53aaedSPiotr Pawel Stefaniak adj_max_col = opt.max_col; 989b50d902SRodney W. Grimes ps.just_saw_decl = 0; 99c917a54bSPedro F. Giffuni last_bl = NULL; /* no blanks found so far */ 1009b50d902SRodney W. Grimes ps.box_com = false; /* at first, assume that we are not in 1019b50d902SRodney W. Grimes * a boxed comment or some other 1029b50d902SRodney W. Grimes * comment that should not be touched */ 1039b50d902SRodney W. Grimes ++ps.out_coms; /* keep track of number of comments */ 1049b50d902SRodney W. Grimes 1059b50d902SRodney W. Grimes /* Figure where to align and how to treat the comment */ 1069b50d902SRodney W. Grimes 107*7e53aaedSPiotr Pawel Stefaniak if (ps.col_1 && !opt.format_col1_comments) { /* if comment starts in column 1089b50d902SRodney W. Grimes * 1 it should not be touched */ 1099b50d902SRodney W. Grimes ps.box_com = true; 11054d57555SPedro F. Giffuni break_delim = false; 1119b50d902SRodney W. Grimes ps.com_col = 1; 1129b50d902SRodney W. Grimes } 1139b50d902SRodney W. Grimes else { 114a5e1cac0SDavid E. O'Brien if (*buf_ptr == '-' || *buf_ptr == '*' || 115*7e53aaedSPiotr Pawel Stefaniak (*buf_ptr == '\n' && !opt.format_block_comments)) { 116a5e1cac0SDavid E. O'Brien ps.box_com = true; /* A comment with a '-' or '*' immediately 1177916863dSJens Schweikhardt * after the /+* is assumed to be a boxed 118a5e1cac0SDavid E. O'Brien * comment. A comment with a newline 1197916863dSJens Schweikhardt * immediately after the /+* is assumed to 120a5e1cac0SDavid E. O'Brien * be a block comment and is treated as a 121a5e1cac0SDavid E. O'Brien * box comment unless format_block_comments 122a5e1cac0SDavid E. O'Brien * is nonzero (the default). */ 12354d57555SPedro F. Giffuni break_delim = false; 1249b50d902SRodney W. Grimes } 1259b50d902SRodney W. Grimes if ( /* ps.bl_line && */ (s_lab == e_lab) && (s_code == e_code)) { 1269b50d902SRodney W. Grimes /* klg: check only if this line is blank */ 1279b50d902SRodney W. Grimes /* 1289b50d902SRodney W. Grimes * If this (*and previous lines are*) blank, dont put comment way 1299b50d902SRodney W. Grimes * out at left 1309b50d902SRodney W. Grimes */ 131*7e53aaedSPiotr Pawel Stefaniak ps.com_col = (ps.ind_level - opt.unindent_displace) * opt.ind_size + 1; 132*7e53aaedSPiotr Pawel Stefaniak adj_max_col = opt.block_comment_max_col; 1339b50d902SRodney W. Grimes if (ps.com_col <= 1) 134*7e53aaedSPiotr Pawel Stefaniak ps.com_col = 1 + !opt.format_col1_comments; 1359b50d902SRodney W. Grimes } 1369b50d902SRodney W. Grimes else { 13790af6a72SJuli Mallett int target_col; 13854d57555SPedro F. Giffuni break_delim = false; 1399b50d902SRodney W. Grimes if (s_code != e_code) 1409b50d902SRodney W. Grimes target_col = count_spaces(compute_code_target(), s_code); 1419b50d902SRodney W. Grimes else { 1429b50d902SRodney W. Grimes target_col = 1; 1439b50d902SRodney W. Grimes if (s_lab != e_lab) 1449b50d902SRodney W. Grimes target_col = count_spaces(compute_label_target(), s_lab); 1459b50d902SRodney W. Grimes } 146*7e53aaedSPiotr Pawel Stefaniak ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? opt.decl_com_ind : opt.com_ind; 1473e2c1447SPiotr Pawel Stefaniak if (ps.com_col <= target_col) 148*7e53aaedSPiotr Pawel Stefaniak ps.com_col = opt.tabsize * (1 + (target_col - 1) / opt.tabsize) + 1; 1499b50d902SRodney W. Grimes if (ps.com_col + 24 > adj_max_col) 1509b50d902SRodney W. Grimes adj_max_col = ps.com_col + 24; 1519b50d902SRodney W. Grimes } 1529b50d902SRodney W. Grimes } 1539b50d902SRodney W. Grimes if (ps.box_com) { 154458051a5SPedro F. Giffuni /* 155458051a5SPedro F. Giffuni * Find out how much indentation there was originally, because that 156458051a5SPedro F. Giffuni * much will have to be ignored by pad_output() in dump_line(). This 157458051a5SPedro F. Giffuni * is a box comment, so nothing changes -- not even indentation. 158458051a5SPedro F. Giffuni * 159458051a5SPedro F. Giffuni * The comment we're about to read usually comes from in_buffer, 160458051a5SPedro F. Giffuni * unless it has been copied into save_com. 161458051a5SPedro F. Giffuni */ 1623c51c3cfSPiotr Pawel Stefaniak char *start; 1633c51c3cfSPiotr Pawel Stefaniak 1643c51c3cfSPiotr Pawel Stefaniak start = buf_ptr >= save_com && buf_ptr < save_com + sc_size ? 1653c51c3cfSPiotr Pawel Stefaniak sc_buf : in_buffer; 1663c51c3cfSPiotr Pawel Stefaniak ps.n_comment_delta = 1 - count_spaces_until(1, start, buf_ptr - 2); 1679b50d902SRodney W. Grimes } 1689b50d902SRodney W. Grimes else { 1699b50d902SRodney W. Grimes ps.n_comment_delta = 0; 1709b50d902SRodney W. Grimes while (*buf_ptr == ' ' || *buf_ptr == '\t') 1719b50d902SRodney W. Grimes buf_ptr++; 1729b50d902SRodney W. Grimes } 1739b50d902SRodney W. Grimes ps.comment_delta = 0; 1747916863dSJens Schweikhardt *e_com++ = '/'; /* put '/' followed by '*' into buffer */ 1759b50d902SRodney W. Grimes *e_com++ = '*'; 1769b50d902SRodney W. Grimes if (*buf_ptr != ' ' && !ps.box_com) 1779b50d902SRodney W. Grimes *e_com++ = ' '; 1789b50d902SRodney W. Grimes 1796daffe6eSPedro F. Giffuni /* 1806daffe6eSPedro F. Giffuni * Don't put a break delimiter if this is a one-liner that won't wrap. 1816daffe6eSPedro F. Giffuni */ 1826daffe6eSPedro F. Giffuni if (break_delim) 18354d57555SPedro F. Giffuni for (t_ptr = buf_ptr; *t_ptr != '\0' && *t_ptr != '\n'; t_ptr++) { 18454d57555SPedro F. Giffuni if (t_ptr >= buf_end) 18554d57555SPedro F. Giffuni fill_buffer(); 18654d57555SPedro F. Giffuni if (t_ptr[0] == '*' && t_ptr[1] == '/') { 1876daffe6eSPedro F. Giffuni if (adj_max_col >= count_spaces_until(ps.com_col, buf_ptr, t_ptr + 2)) 18854d57555SPedro F. Giffuni break_delim = false; 18954d57555SPedro F. Giffuni break; 1909b50d902SRodney W. Grimes } 19154d57555SPedro F. Giffuni } 19254d57555SPedro F. Giffuni 19354d57555SPedro F. Giffuni if (break_delim) { 19454d57555SPedro F. Giffuni char *t = e_com; 19554d57555SPedro F. Giffuni e_com = s_com + 2; 19654d57555SPedro F. Giffuni *e_com = 0; 197*7e53aaedSPiotr Pawel Stefaniak if (opt.blanklines_before_blockcomments && ps.last_token != lbrace) 19854d57555SPedro F. Giffuni prefix_blankline_requested = 1; 19954d57555SPedro F. Giffuni dump_line(); 20069e66b43SPedro F. Giffuni e_com = s_com = t; 201*7e53aaedSPiotr Pawel Stefaniak if (!ps.box_com && opt.star_comment_cont) 20269e66b43SPedro F. Giffuni *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; 20354d57555SPedro F. Giffuni } 20454d57555SPedro F. Giffuni 2059b50d902SRodney W. Grimes /* Start to copy the comment */ 2069b50d902SRodney W. Grimes 2079b50d902SRodney W. Grimes while (1) { /* this loop will go until the comment is 2089b50d902SRodney W. Grimes * copied */ 2099b50d902SRodney W. Grimes switch (*buf_ptr) { /* this checks for various spcl cases */ 2109b50d902SRodney W. Grimes case 014: /* check for a form feed */ 2119de29bfbSPiotr Pawel Stefaniak CHECK_SIZE_COM(3); 2129b50d902SRodney W. Grimes if (!ps.box_com) { /* in a text comment, break the line here */ 2139b50d902SRodney W. Grimes ps.use_ff = true; 2149b50d902SRodney W. Grimes /* fix so dump_line uses a form feed */ 2159b50d902SRodney W. Grimes dump_line(); 216c917a54bSPedro F. Giffuni last_bl = NULL; 217*7e53aaedSPiotr Pawel Stefaniak if (!ps.box_com && opt.star_comment_cont) 21869e66b43SPedro F. Giffuni *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; 21969e66b43SPedro F. Giffuni while (*++buf_ptr == ' ' || *buf_ptr == '\t') 22069e66b43SPedro F. Giffuni ; 2219b50d902SRodney W. Grimes } 2229b50d902SRodney W. Grimes else { 2239b50d902SRodney W. Grimes if (++buf_ptr >= buf_end) 2249b50d902SRodney W. Grimes fill_buffer(); 2259b50d902SRodney W. Grimes *e_com++ = 014; 2269b50d902SRodney W. Grimes } 2279b50d902SRodney W. Grimes break; 2289b50d902SRodney W. Grimes 2299b50d902SRodney W. Grimes case '\n': 2309b50d902SRodney W. Grimes if (had_eof) { /* check for unexpected eof */ 2319b50d902SRodney W. Grimes printf("Unterminated comment\n"); 2329b50d902SRodney W. Grimes dump_line(); 2339b50d902SRodney W. Grimes return; 2349b50d902SRodney W. Grimes } 2358ad92a65SPedro F. Giffuni last_bl = NULL; 2369de29bfbSPiotr Pawel Stefaniak CHECK_SIZE_COM(4); 2379b50d902SRodney W. Grimes if (ps.box_com || ps.last_nl) { /* if this is a boxed comment, 2389b50d902SRodney W. Grimes * we dont ignore the newline */ 23969e66b43SPedro F. Giffuni if (s_com == e_com) 2409b50d902SRodney W. Grimes *e_com++ = ' '; 2419b50d902SRodney W. Grimes if (!ps.box_com && e_com - s_com > 3) { 2429b50d902SRodney W. Grimes dump_line(); 243*7e53aaedSPiotr Pawel Stefaniak if (opt.star_comment_cont) 24469e66b43SPedro F. Giffuni *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; 2459b50d902SRodney W. Grimes } 2469b50d902SRodney W. Grimes dump_line(); 247*7e53aaedSPiotr Pawel Stefaniak if (!ps.box_com && opt.star_comment_cont) 24869e66b43SPedro F. Giffuni *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; 2499b50d902SRodney W. Grimes } 2509b50d902SRodney W. Grimes else { 2519b50d902SRodney W. Grimes ps.last_nl = 1; 2529b50d902SRodney W. Grimes if (*(e_com - 1) == ' ' || *(e_com - 1) == '\t') 2539b50d902SRodney W. Grimes last_bl = e_com - 1; 2549b50d902SRodney W. Grimes /* 2559b50d902SRodney W. Grimes * if there was a space at the end of the last line, remember 2569b50d902SRodney W. Grimes * where it was 2579b50d902SRodney W. Grimes */ 2589b50d902SRodney W. Grimes else { /* otherwise, insert one */ 2599b50d902SRodney W. Grimes last_bl = e_com; 2609b50d902SRodney W. Grimes *e_com++ = ' '; 2619b50d902SRodney W. Grimes } 2629b50d902SRodney W. Grimes } 2639b50d902SRodney W. Grimes ++line_no; /* keep track of input line number */ 2649b50d902SRodney W. Grimes if (!ps.box_com) { 2659b50d902SRodney W. Grimes int nstar = 1; 2669b50d902SRodney W. Grimes do { /* flush any blanks and/or tabs at start of 2679b50d902SRodney W. Grimes * next line */ 2689b50d902SRodney W. Grimes if (++buf_ptr >= buf_end) 2699b50d902SRodney W. Grimes fill_buffer(); 2709b50d902SRodney W. Grimes if (*buf_ptr == '*' && --nstar >= 0) { 2719b50d902SRodney W. Grimes if (++buf_ptr >= buf_end) 2729b50d902SRodney W. Grimes fill_buffer(); 2739b50d902SRodney W. Grimes if (*buf_ptr == '/') 2749b50d902SRodney W. Grimes goto end_of_comment; 2759b50d902SRodney W. Grimes } 2769b50d902SRodney W. Grimes } while (*buf_ptr == ' ' || *buf_ptr == '\t'); 2779b50d902SRodney W. Grimes } 2789b50d902SRodney W. Grimes else if (++buf_ptr >= buf_end) 2799b50d902SRodney W. Grimes fill_buffer(); 2809b50d902SRodney W. Grimes break; /* end of case for newline */ 2819b50d902SRodney W. Grimes 2829b50d902SRodney W. Grimes case '*': /* must check for possibility of being at end 2839b50d902SRodney W. Grimes * of comment */ 2849b50d902SRodney W. Grimes if (++buf_ptr >= buf_end) /* get to next char after * */ 2859b50d902SRodney W. Grimes fill_buffer(); 2869de29bfbSPiotr Pawel Stefaniak CHECK_SIZE_COM(4); 2879b50d902SRodney W. Grimes if (*buf_ptr == '/') { /* it is the end!!! */ 2889b50d902SRodney W. Grimes end_of_comment: 2899b50d902SRodney W. Grimes if (++buf_ptr >= buf_end) 2909b50d902SRodney W. Grimes fill_buffer(); 29154d57555SPedro F. Giffuni if (break_delim) { 29254d57555SPedro F. Giffuni if (e_com > s_com + 3) { 2939b50d902SRodney W. Grimes dump_line(); 29454d57555SPedro F. Giffuni } 29569e66b43SPedro F. Giffuni else 29669e66b43SPedro F. Giffuni s_com = e_com; 29769e66b43SPedro F. Giffuni *e_com++ = ' '; 2989b50d902SRodney W. Grimes } 299909f007fSPedro F. Giffuni if (e_com[-1] != ' ' && e_com[-1] != '\t' && !ps.box_com) 30069e66b43SPedro F. Giffuni *e_com++ = ' '; /* ensure blank before end */ 30169e66b43SPedro F. Giffuni *e_com++ = '*', *e_com++ = '/', *e_com = '\0'; 3029b50d902SRodney W. Grimes ps.just_saw_decl = l_just_saw_decl; 3039b50d902SRodney W. Grimes return; 3049b50d902SRodney W. Grimes } 30554d57555SPedro F. Giffuni else /* handle isolated '*' */ 3069b50d902SRodney W. Grimes *e_com++ = '*'; 3079b50d902SRodney W. Grimes break; 3089b50d902SRodney W. Grimes default: /* we have a random char */ 30954d57555SPedro F. Giffuni now_col = count_spaces_until(ps.com_col, s_com, e_com); 31054d57555SPedro F. Giffuni do { 3119de29bfbSPiotr Pawel Stefaniak CHECK_SIZE_COM(1); 3129b50d902SRodney W. Grimes *e_com = *buf_ptr++; 3139b50d902SRodney W. Grimes if (buf_ptr >= buf_end) 3149b50d902SRodney W. Grimes fill_buffer(); 3159b50d902SRodney W. Grimes if (*e_com == ' ' || *e_com == '\t') 31654d57555SPedro F. Giffuni last_bl = e_com; /* remember we saw a blank */ 3179b50d902SRodney W. Grimes ++e_com; 31854d57555SPedro F. Giffuni now_col++; 31954d57555SPedro F. Giffuni } while (!memchr("*\n\r\b\t", *buf_ptr, 6) && 32069e66b43SPedro F. Giffuni (now_col <= adj_max_col || !last_bl)); 32154d57555SPedro F. Giffuni ps.last_nl = false; 322267c7470SPedro F. Giffuni if (now_col > adj_max_col && !ps.box_com && e_com[-1] > ' ') { 3239b50d902SRodney W. Grimes /* 3249b50d902SRodney W. Grimes * the comment is too long, it must be broken up 3259b50d902SRodney W. Grimes */ 32669e66b43SPedro F. Giffuni if (last_bl == NULL) { 32769e66b43SPedro F. Giffuni dump_line(); 328*7e53aaedSPiotr Pawel Stefaniak if (!ps.box_com && opt.star_comment_cont) 32969e66b43SPedro F. Giffuni *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; 33069e66b43SPedro F. Giffuni break; 3319b50d902SRodney W. Grimes } 33269e66b43SPedro F. Giffuni *e_com = '\0'; 3339b50d902SRodney W. Grimes e_com = last_bl; 3349b50d902SRodney W. Grimes dump_line(); 335*7e53aaedSPiotr Pawel Stefaniak if (!ps.box_com && opt.star_comment_cont) 33669e66b43SPedro F. Giffuni *e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; 33769e66b43SPedro F. Giffuni for (t_ptr = last_bl + 1; *t_ptr == ' ' || *t_ptr == '\t'; 33869e66b43SPedro F. Giffuni t_ptr++) 33969e66b43SPedro F. Giffuni ; 340c917a54bSPedro F. Giffuni last_bl = NULL; 3419de29bfbSPiotr Pawel Stefaniak /* 3429de29bfbSPiotr Pawel Stefaniak * t_ptr will be somewhere between e_com (dump_line() reset) 3439de29bfbSPiotr Pawel Stefaniak * and l_com. So it's safe to copy byte by byte from t_ptr 3449de29bfbSPiotr Pawel Stefaniak * to e_com without any CHECK_SIZE_COM(). 3459de29bfbSPiotr Pawel Stefaniak */ 34669e66b43SPedro F. Giffuni while (*t_ptr != '\0') { 3479b50d902SRodney W. Grimes if (*t_ptr == ' ' || *t_ptr == '\t') 3489b50d902SRodney W. Grimes last_bl = e_com; 3499b50d902SRodney W. Grimes *e_com++ = *t_ptr++; 3509b50d902SRodney W. Grimes } 3519b50d902SRodney W. Grimes } 3529b50d902SRodney W. Grimes break; 3539b50d902SRodney W. Grimes } 3549b50d902SRodney W. Grimes } 3559b50d902SRodney W. Grimes } 356