From 554974acf20aae4f31f87a55a3d3d3649b9a1aee Mon Sep 17 00:00:00 2001 From: albert-github Date: Fri, 12 Jul 2019 14:47:06 +0200 Subject: issue #7120 Markdown generator does not consider extension mapping for files with no extension Better handling of the determination of what is an extension. - don't see a file references like: `./LICENSE` as extension - use the qt way of extension determination and in case of no extension use the no extension placeholder for it. --- src/util.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 7107e83..bf02d7e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -7418,20 +7418,16 @@ void addCodeOnlyMappings() SrcLangExt getLanguageFromFileName(const QCString& fileName) { - int i = fileName.findRev('.'); - if (i!=-1) // name has an extension - { - QCString extStr=fileName.right(fileName.length()-i).lower(); - if (!extStr.isEmpty()) // non-empty extension + QFileInfo fi(fileName); + QCString extName = fi.extension().lower().data(); + if (extName.isEmpty()) extName=".no_extension"; + if (extName.at(0)!='.') extName.prepend("."); + int *pVal=g_extLookup.find(extName.data()); + if (pVal) // listed extension { - int *pVal=g_extLookup.find(extStr); - if (pVal) // listed extension - { - //printf("getLanguageFromFileName(%s)=%x\n",extStr.data(),*pVal); - return (SrcLangExt)*pVal; - } + //printf("getLanguageFromFileName(%s)=%x\n",fi.extension().data(),*pVal); + return (SrcLangExt)*pVal; } - } //printf("getLanguageFromFileName(%s) not found!\n",fileName.data()); return SrcLangExt_Cpp; // not listed => assume C-ish language. } -- cgit v0.12