Skip to content

Commit 10787ee

Browse files
committed
Refactoring
- Makes doxycfg library more self contained - renames _doxygen library to doxymain - Modernizes Debug implementation - Moves Doxygen::runningTime into Debug - Moves full version string to libversion - Removed mentioning of file version in messages (when FILE_VERSION_FILTER is used) - Move substitute functions into QCString
1 parent 1284382 commit 10787ee

18 files changed

+261
-265
lines changed

addon/doxyapp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (use_libclang)
1818
endif()
1919

2020
target_link_libraries(doxyapp
21-
_doxygen
21+
doxymain
2222
qtools
2323
md5
2424
lodepng

addon/doxyparse/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (use_libclang)
1818
endif()
1919

2020
target_link_libraries(doxyparse
21-
_doxygen
21+
doxymain
2222
qtools
2323
md5
2424
lodepng

libversion/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ include_directories(
1919
add_library(doxygen_version STATIC
2020
${POST_CONFIGURE_DOXYGEN_VERSION_FILE}
2121
${POST_CONFIGURE_GIT_VERSION_FILE}
22+
fullversion.cpp
2223
)
2324

2425
add_dependencies( doxygen_version check_git_repository )

libversion/doxyversion.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "version.h"
22

3-
char *getDoxygenVersion(void)
3+
const char *getDoxygenVersion(void)
44
{
55
static char versionString[] = "@DOXYGEN_VERSION@";
66
return versionString;

libversion/fullversion.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <string.h>
2+
#include <version.h>
3+
4+
const char *getFullVersion(void)
5+
{
6+
#define BUF_SIZE 100
7+
static char fullVersionString[BUF_SIZE];
8+
static bool init = false;
9+
if (!init)
10+
{
11+
strlcpy(fullVersionString,getDoxygenVersion(),BUF_SIZE);
12+
if (strlen(getGitVersion())>0)
13+
{
14+
strlcat(fullVersionString," (",BUF_SIZE);
15+
strlcat(fullVersionString,getGitVersion(),BUF_SIZE);
16+
strlcat(fullVersionString,")",BUF_SIZE);
17+
}
18+
fullVersionString[BUF_SIZE-1]='\0';
19+
init = true;
20+
}
21+
return fullVersionString;
22+
}

libversion/gitversion.cpp.in

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
* - No git information is present (no .git directory)
77
* in those cases clear the gitVersionString (would have string GIT-NOTFOUND).
88
*/
9-
char *getGitVersion(void)
9+
const char *getGitVersion(void)
1010
{
11-
static char gitVersionString[100];
12-
strcpy(gitVersionString,"@GIT_HEAD_SHA1@");
13-
strcat(gitVersionString,!strcmp("@GIT_IS_DIRTY@","true")?"*":"");
14-
if (!strcmp("@GIT_HEAD_SHA1@", "GIT-NOTFOUND")) gitVersionString[0] = '\0';
11+
#define BUF_SIZE 100
12+
static char gitVersionString[BUF_SIZE];
13+
static bool init = false;
14+
if (!init)
15+
{
16+
strncpy(gitVersionString,"@GIT_HEAD_SHA1@",BUF_SIZE);
17+
strncat(gitVersionString,!strcmp("@GIT_IS_DIRTY@","true")?"*":"",BUF_SIZE);
18+
if (!strcmp("@GIT_HEAD_SHA1@", "GIT-NOTFOUND")) gitVersionString[0] = '\0';
19+
gitVersionString[BUF_SIZE-1]='\0';
20+
init = true;
21+
}
1522
return gitVersionString;
1623
}

libversion/version.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
/******************************************************************************
22
*
3-
*
4-
*
5-
* Copyright (C) 1997-2015 by Dimitri van Heesch.
3+
* Copyright (C) 1997-2020 by Dimitri van Heesch.
64
*
75
* Permission to use, copy, modify, and distribute this software and its
8-
* documentation under the terms of the GNU General Public License is hereby
9-
* granted. No representations are made about the suitability of this software
6+
* documentation under the terms of the GNU General Public License is hereby
7+
* granted. No representations are made about the suitability of this software
108
* for any purpose. It is provided "as is" without express or implied warranty.
119
* See the GNU General Public License for more details.
1210
*
@@ -17,6 +15,7 @@
1715

1816
#ifndef VERSION_H
1917
#define VERSION_H
20-
char *getDoxygenVersion(void);
21-
char *getGitVersion(void);
18+
const char *getDoxygenVersion(void);
19+
const char *getGitVersion(void);
20+
const char *getFullVersion(void);
2221
#endif

qtools/qcstring.cpp

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,3 +840,113 @@ inline QCString operator+( const QGString &s1, const QCString &s2 )
840840
return tmp;
841841
}
842842

843+
/// substitute all occurrences of \a src in \a s by \a dst
844+
QCString substitute(const QCString &s,const QCString &src,const QCString &dst)
845+
{
846+
if (s.isEmpty() || src.isEmpty()) return s;
847+
const char *p, *q;
848+
int srcLen = src.length();
849+
int dstLen = dst.length();
850+
int resLen;
851+
if (srcLen!=dstLen)
852+
{
853+
int count;
854+
for (count=0, p=s.data(); (q=strstr(p,src))!=0; p=q+srcLen) count++;
855+
resLen = s.length()+count*(dstLen-srcLen);
856+
}
857+
else // result has same size as s
858+
{
859+
resLen = s.length();
860+
}
861+
QCString result(resLen+1);
862+
char *r;
863+
for (r=result.rawData(), p=s; (q=strstr(p,src))!=0; p=q+srcLen)
864+
{
865+
int l = (int)(q-p);
866+
memcpy(r,p,l);
867+
r+=l;
868+
869+
if (dst) memcpy(r,dst,dstLen);
870+
r+=dstLen;
871+
}
872+
qstrcpy(r,p);
873+
//printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
874+
return result;
875+
}
876+
877+
878+
/// substitute all occurrences of \a src in \a s by \a dst, but skip
879+
/// each consecutive sequence of \a src where the number consecutive
880+
/// \a src matches \a skip_seq; if \a skip_seq is negative, skip any
881+
/// number of consecutive \a src
882+
QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq)
883+
{
884+
if (s.isEmpty() || src.isEmpty()) return s;
885+
const char *p, *q;
886+
int srcLen = src.length();
887+
int dstLen = dst.length();
888+
int resLen;
889+
if (srcLen!=dstLen)
890+
{
891+
int count;
892+
for (count=0, p=s.data(); (q=strstr(p,src))!=0; p=q+srcLen) count++;
893+
resLen = s.length()+count*(dstLen-srcLen);
894+
}
895+
else // result has same size as s
896+
{
897+
resLen = s.length();
898+
}
899+
QCString result(resLen+1);
900+
char *r;
901+
for (r=result.rawData(), p=s; (q=strstr(p,src))!=0; p=q+srcLen)
902+
{
903+
// search a consecutive sequence of src
904+
int seq = 0, skip = 0;
905+
if (skip_seq)
906+
{
907+
for (const char *n=q+srcLen; qstrncmp(n,src,srcLen)==0; seq=1+skip, n+=srcLen)
908+
++skip; // number of consecutive src after the current one
909+
910+
// verify the allowed number of consecutive src to skip
911+
if (skip_seq > 0 && skip_seq != seq)
912+
seq = skip = 0;
913+
}
914+
915+
// skip a consecutive sequence of src when necessary
916+
int l = (int)((q + seq * srcLen)-p);
917+
memcpy(r,p,l);
918+
r+=l;
919+
920+
if (skip)
921+
{
922+
// skip only the consecutive src found after the current one
923+
q += skip * srcLen;
924+
// the next loop will skip the current src, aka (p=q+srcLen)
925+
continue;
926+
}
927+
928+
if (dst) memcpy(r,dst,dstLen);
929+
r+=dstLen;
930+
}
931+
qstrcpy(r,p);
932+
result.resize((int)strlen(result.data())+1);
933+
//printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
934+
return result;
935+
}
936+
937+
/// substitute all occurrences of \a srcChar in \a s by \a dstChar
938+
QCString substitute(const QCString &s,char srcChar,char dstChar)
939+
{
940+
int l=s.length();
941+
QCString result(l+1);
942+
char *q=result.rawData();
943+
if (l>0)
944+
{
945+
const char *p=s.data();
946+
char c;
947+
while ((c=*p++)) *q++ = (c==srcChar) ? dstChar : c;
948+
}
949+
*q='\0';
950+
return result;
951+
}
952+

qtools/qcstring.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,4 +812,9 @@ inline std::string toStdString(const QCString &s)
812812
if (!s.isEmpty()) return std::string(s.data()); else return std::string();
813813
}
814814

815+
// helper functions
816+
QCString substitute(const QCString &s,const QCString &src,const QCString &dst);
817+
QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq);
818+
QCString substitute(const QCString &s,char srcChar,char dstChar);
819+
815820
#endif // QCSTRING_H

src/CMakeLists.txt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,22 @@ add_library(doxycfg STATIC
142142
${GENERATED_SRC}/configimpl.l.h
143143
${GENERATED_SRC}/configoptions.cpp
144144
${GENERATED_SRC}/configvalues.cpp
145+
${GENERATED_SRC}/settings.h
145146
portable.cpp
146147
portable_c.c
148+
ftextstream.cpp
149+
message.cpp
150+
debug.cpp
147151
)
148152

149-
add_library(_doxygen STATIC
153+
add_library(doxymain STATIC
150154
# generated for/by flex/bison
151155
#${LEX_FILES_H} #unfortunately doesn't work in older versions of CMake (like 3.6.2)
152156
#${LEX_FILES_CPP} #unfortunately doesn't work in older versions of CMake (like 3.6.2)
153157
${GENERATED_SRC}/code.l.h
154158
${GENERATED_SRC}/commentcnv.l.h
155159
${GENERATED_SRC}/commentscan.l.h
156-
${GENERATED_SRC}/configimpl.l.h
160+
${GENERATED_SRC}/constexp.cpp
157161
${GENERATED_SRC}/constexp.l.h
158162
${GENERATED_SRC}/declinfo.l.h
159163
${GENERATED_SRC}/defargs.l.h
@@ -170,8 +174,6 @@ add_library(_doxygen STATIC
170174
${GENERATED_SRC}/code.cpp
171175
${GENERATED_SRC}/commentcnv.cpp
172176
${GENERATED_SRC}/commentscan.cpp
173-
${GENERATED_SRC}/configimpl.cpp
174-
${GENERATED_SRC}/constexp.cpp
175177
${GENERATED_SRC}/declinfo.cpp
176178
${GENERATED_SRC}/defargs.cpp
177179
${GENERATED_SRC}/doctokenizer.cpp
@@ -188,10 +190,8 @@ add_library(_doxygen STATIC
188190
${GENERATED_SRC}/ce_parse.cpp
189191
# custom generated files
190192
${GENERATED_SRC}/lang_cfg.h
191-
${GENERATED_SRC}/settings.h
192193
${GENERATED_SRC}/layout_default.xml.h
193194
${GENERATED_SRC}/ce_parse.h
194-
${GENERATED_SRC}/configvalues.h
195195
${GENERATED_SRC}/resources.cpp
196196
#
197197
arguments.cpp
@@ -203,7 +203,6 @@ add_library(_doxygen STATIC
203203
condparser.cpp
204204
context.cpp
205205
cppvalue.cpp
206-
debug.cpp
207206
defgen.cpp
208207
define.cpp
209208
definition.cpp
@@ -234,7 +233,6 @@ add_library(_doxygen STATIC
234233
filedef.cpp
235234
fileparser.cpp
236235
formula.cpp
237-
ftextstream.cpp
238236
ftvhelp.cpp
239237
groupdef.cpp
240238
htags.cpp
@@ -254,7 +252,6 @@ add_library(_doxygen STATIC
254252
memberdef.cpp
255253
membergroup.cpp
256254
memberlist.cpp
257-
message.cpp
258255
msc.cpp
259256
namespacedef.cpp
260257
outputgen.cpp
@@ -291,7 +288,7 @@ set_source_files_properties(clangparser.cpp PROPERTIES COMPILE_FLAGS "-Wno-shado
291288
endif()
292289

293290
##foreach(lex_file ${LEX_FILES})
294-
##add_library(_doxygen STATIC ${GENERATED_SRC}/${lex_file}.l.h)
291+
##add_library(doxymain STATIC ${GENERATED_SRC}/${lex_file}.l.h)
295292
##endforeach()
296293

297294
add_executable(doxygen main.cpp)
@@ -302,12 +299,12 @@ if (use_libclang)
302299
find_package(Clang REQUIRED CONFIG)
303300
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
304301
cmake_minimum_required(VERSION 3.1)
305-
target_compile_features(_doxygen PRIVATE cxx_alignof)
302+
target_compile_features(doxymain PRIVATE cxx_alignof)
306303
target_compile_features(doxygen PRIVATE cxx_alignof)
307-
target_compile_options(_doxygen PRIVATE -stdlib=libc++)
304+
target_compile_options(doxymain PRIVATE -stdlib=libc++)
308305
target_compile_options(doxygen PRIVATE -stdlib=libc++)
309306
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
310-
target_compile_options(_doxygen PRIVATE -std=c++11)
307+
target_compile_options(doxymain PRIVATE -std=c++11)
311308
target_compile_options(doxygen PRIVATE -std=c++11)
312309
endif()
313310
include_directories(${LLVM_INCLUDE_DIRS})
@@ -318,8 +315,8 @@ if (use_libclang)
318315
endif()
319316

320317
target_link_libraries(doxygen
321-
_doxygen
322318
doxycfg
319+
doxymain
323320
qtools
324321
md5
325322
lodepng
@@ -335,7 +332,7 @@ target_link_libraries(doxygen
335332
)
336333

337334
set_project_warnings(doxycfg)
338-
set_project_warnings(_doxygen)
335+
set_project_warnings(doxymain)
339336
set_project_warnings(doxygen)
340337

341338
install(TARGETS doxygen DESTINATION bin)

0 commit comments

Comments
 (0)