2 // "$Id: doxystar.cxx 7514 2010-04-16 14:25:20Z AlbrechtS $"
4 // Doxygen pre-formatting program for the Fast Light Tool Kit (FLTK).
6 // Copyright 2010 by Matthias Melcher.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
35 int main(int argc
, char **argv
) {
37 puts("Add stars (*) in front of multi-line doxygen comments");
38 puts("to protect comment indentation from code beautifiers.");
39 puts("usage: cat file | doxystar");
47 if (!fgets(linebuf
, 1020, stdin
)) break; // EOF or error
49 case 0: // line start is source code
50 commentStart
= strstr(linebuf
, "/*");
52 // check if this comment spans multiple lines
53 if (strstr(commentStart
, "*/")==0) {
54 if ((commentStart
[2]=='*' || commentStart
[2]=='!') && commentStart
[3]!='*') {
55 state
= 2; // Doxygen multiline comment
56 commentCol
= commentStart
- linebuf
;
58 state
= 1; // regular multiline comment
61 // single line comment, do nothing
64 fputs(linebuf
, stdout
);
66 case 1: // line start is inside a regular multiline comment
67 if (strstr(linebuf
, "*/")) {
70 // still inside comment
72 fputs(linebuf
, stdout
);
74 case 2: // line start is inside a doxygen multiline comment
75 for (i
=0; i
<commentCol
; i
++) fputc(' ', stdout
);
77 if (strstr(linebuf
, "*/")) {
80 // still inside comment
82 for (i
=0; i
<commentCol
+1; i
++)
85 if (linebuf
[i
]=='*') {
86 if (linebuf
[i
+1]==' ') {
92 fputs(linebuf
+i
, stdout
);
101 // End of "$Id: doxystar.cxx 7514 2010-04-16 14:25:20Z AlbrechtS $".