|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: doxystar.cxx 7514 2010-04-16 14:25:20Z AlbrechtS $" 00003 // 00004 // Doxygen pre-formatting program for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 2010 by Matthias Melcher. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 #include <stdio.h> 00029 #include <string.h> 00030 00031 char linebuf[1024]; 00032 00033 00034 00035 int main(int argc, char **argv) { 00036 if (argc!=1) { 00037 puts("Add stars (*) in front of multi-line doxygen comments"); 00038 puts("to protect comment indentation from code beautifiers."); 00039 puts("usage: cat file | doxystar"); 00040 return 0; 00041 } 00042 00043 int state = 0; 00044 char *commentStart; 00045 int i, commentCol; 00046 for (;;) { 00047 if (!fgets(linebuf, 1020, stdin)) break; // EOF or error 00048 switch (state) { 00049 case 0: // line start is source code 00050 commentStart = strstr(linebuf, "/*"); 00051 if (commentStart) { 00052 // check if this comment spans multiple lines 00053 if (strstr(commentStart, "*/")==0) { 00054 if ((commentStart[2]=='*' || commentStart[2]=='!') && commentStart[3]!='*') { 00055 state = 2; // Doxygen multiline comment 00056 commentCol = commentStart - linebuf; 00057 } else { 00058 state = 1; // regular multiline comment 00059 } 00060 } else { 00061 // single line comment, do nothing 00062 } 00063 } 00064 fputs(linebuf, stdout); 00065 break; 00066 case 1: // line start is inside a regular multiline comment 00067 if (strstr(linebuf, "*/")) { 00068 state = 0; 00069 } else { 00070 // still inside comment 00071 } 00072 fputs(linebuf, stdout); 00073 break; 00074 case 2: // line start is inside a doxygen multiline comment 00075 for (i=0; i<commentCol; i++) fputc(' ', stdout); 00076 fputs(" *", stdout); 00077 if (strstr(linebuf, "*/")) { 00078 state = 0; 00079 } else { 00080 // still inside comment 00081 } 00082 for (i=0; i<commentCol+1; i++) 00083 if (linebuf[i]!=' ') 00084 break; 00085 if (linebuf[i]=='*') { 00086 if (linebuf[i+1]==' ') { 00087 i+=2; 00088 } else { 00089 i+=1; 00090 } 00091 } 00092 fputs(linebuf+i, stdout); 00093 break; 00094 } 00095 } 00096 00097 return 0; 00098 } 00099 00100 // 00101 // End of "$Id: doxystar.cxx 7514 2010-04-16 14:25:20Z AlbrechtS $". 00102 //