void
pr_comment(void)
{ 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 */ char *last_bl; /* points to the last blank in the output
* buffer */ char *t_ptr; /* used for moving string */ int break_delim = comment_delimiter_on_blankline; int l_just_saw_decl = ps.just_saw_decl;
adj_max_col = max_col;
ps.just_saw_decl = 0;
last_bl = NULL; /* no blanks found so far */
ps.box_com = false; /* at first, assume that we are not in *aboxedcommentorsomeother
* comment that should not be touched */
++ps.out_coms; /* keep track of number of comments */
/* Figure where to align and how to treat the comment */
if (ps.col_1 && !format_col1_comments) { /* if comment starts in column
* 1 it should not be touched */
ps.box_com = true;
break_delim = false;
ps.com_col = 1;
} else { if (*buf_ptr == '-' || *buf_ptr == '*' ||
(*buf_ptr == '\n' && !format_block_comments)) {
ps.box_com = true; /* A comment with a '-' or '*' immediately *afterthe/+*isassumedtobeaboxed *comment.Acommentwithanewline *immediatelyafterthe/+*isassumedto *beablockcommentandistreatedasa *boxcommentunlessformat_block_comments
* is nonzero (the default). */
break_delim = false;
} if ( /* ps.bl_line && */ (s_lab == e_lab) && (s_code == e_code)) { /* klg: check only if this line is blank */ /* *Ifthis(*andpreviouslinesare*)blank,dontputcommentway *outatleft
*/
ps.com_col = (ps.ind_level - ps.unindent_displace) * ps.ind_size + 1;
adj_max_col = block_comment_max_col; if (ps.com_col <= 1)
ps.com_col = 1 + !format_col1_comments;
} else { int target_col;
break_delim = false; 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);
} if (s_lab != e_lab && s_lab[1] == 'e' &&
(strncmp(s_lab, "#endif", 6) == 0 ||
strncmp(s_lab, "#else", 5) == 0))
ps.com_col = else_endif_com_ind <= target_col
? target_col + 1 : else_endif_com_ind; else
ps.com_col = ps.decl_on_line || ps.ind_level == 0
? ps.decl_com_ind : ps.com_ind; if (ps.com_col <= target_col)
ps.com_col = tabsize * (1 + (target_col - 1) / tabsize) + 1; if (ps.com_col + 24 > adj_max_col)
adj_max_col = ps.com_col + 24;
}
} if (ps.box_com) { /* *Findouthowmuchindentationtherewasoriginally,becausethat *muchwillhavetobeignoredbypad_output()indump_line().This *isaboxcomment,sonothingchanges--notevenindentation. * *Thecommentwe'reabouttoreadusuallycomesfromin_buffer, *unlessithasbeencopiedintosave_com.
*/ char *start;
while (1) { /* this loop will go until the comment is
* copied */ switch (*buf_ptr) { /* this checks for various spcl cases */ case014: /* check for a form feed */
CHECK_SIZE_COM(3); if (!ps.box_com) { /* in a text comment, break the line here */
ps.use_ff = true; /* fix so dump_line uses a form feed */
dump_line();
last_bl = NULL; if (!ps.box_com && star_comment_cont)
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; while (*++buf_ptr == ' ' || *buf_ptr == '\t')
;
} else { if (++buf_ptr >= buf_end)
fill_buffer();
*e_com++ = 014;
} break;
case'\n': if (had_eof) { /* check for unexpected eof */
printf("Unterminated comment\n");
dump_line(); return;
}
last_bl = NULL;
CHECK_SIZE_COM(4); if (ps.box_com || ps.last_nl) { /* if this is a boxed comment,
* we dont ignore the newline */ if (s_com == e_com)
*e_com++ = ' '; if (!ps.box_com && e_com - s_com > 3) {
dump_line(); if (star_comment_cont)
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
}
dump_line(); if (!ps.box_com && star_comment_cont)
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
} else {
ps.last_nl = 1; if (*(e_com - 1) == ' ' || *(e_com - 1) == '\t')
last_bl = e_com - 1; /* *iftherewasaspaceattheendofthelastline,remember *whereitwas
*/ else { /* otherwise, insert one */
last_bl = e_com;
*e_com++ = ' ';
}
}
++line_no; /* keep track of input line number */ if (!ps.box_com) { int nstar = 1; do { /* flush any blanks and/or tabs at start of
* next line */ if (++buf_ptr >= buf_end)
fill_buffer(); if (*buf_ptr == '*' && --nstar >= 0) { if (++buf_ptr >= buf_end)
fill_buffer(); if (*buf_ptr == '/') goto end_of_comment;
}
} while (*buf_ptr == ' ' || *buf_ptr == '\t');
} elseif (++buf_ptr >= buf_end)
fill_buffer(); break; /* end of case for newline */
case'*': /* must check for possibility of being at end
* of comment */ if (++buf_ptr >= buf_end) /* get to next char after * */
fill_buffer();
CHECK_SIZE_COM(4); if (*buf_ptr == '/') { /* it is the end!!! */
end_of_comment: if (++buf_ptr >= buf_end)
fill_buffer(); if (break_delim) { if (e_com > s_com + 3) {
dump_line();
} else
s_com = e_com;
*e_com++ = ' ';
} if (e_com[-1] != ' ' && e_com[-1] != '\t' && !ps.box_com)
*e_com++ = ' '; /* ensure blank before end */
*e_com++ = '*', *e_com++ = '/', *e_com = '\0';
ps.just_saw_decl = l_just_saw_decl; return;
} else/* handle isolated '*' */
*e_com++ = '*'; break; default: /* we have a random char */
now_col = count_spaces_until(ps.com_col, s_com, e_com); do {
CHECK_SIZE_COM(1);
*e_com = *buf_ptr++; if (buf_ptr >= buf_end)
fill_buffer(); if (*e_com == ' ' || *e_com == '\t')
last_bl = e_com; /* remember we saw a blank */
++e_com;
now_col++;
} while (!memchr("*\n\r\b\t", *buf_ptr, 6) &&
(now_col <= adj_max_col || !last_bl));
ps.last_nl = false; if (now_col > adj_max_col && !ps.box_com && e_com[-1] > ' ') { /* *thecommentistoolong,itmustbebrokenup
*/ if (last_bl == NULL) {
dump_line(); if (!ps.box_com && star_comment_cont)
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; break;
}
*e_com = '\0';
e_com = last_bl;
dump_line(); if (!ps.box_com && star_comment_cont)
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' '; for (t_ptr = last_bl + 1; *t_ptr == ' ' || *t_ptr == '\t';
t_ptr++)
;
last_bl = NULL; /* *t_ptrwillbesomewherebetweene_com(dump_line()reset) *andl_com.Soit'ssafetocopybytebybytefromt_ptr *toe_comwithoutanyCHECK_SIZE_COM().
*/ while (*t_ptr != '\0') { if (*t_ptr == ' ' || *t_ptr == '\t')
last_bl = e_com;
*e_com++ = *t_ptr++;
}
} break;
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.