From 405da09494f61d2dfebaaf157d1e37f042880490 Mon Sep 17 00:00:00 2001 From: Masayuki Yamamoto Date: Fri, 7 Dec 2018 21:31:23 +0900 Subject: [PATCH 1/4] Rename the macro JDDATE to JDDATE_FALLBACK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit バージョン番号とgitリビジョンについて説明をjdversion.hに追加する --- src/environment.cpp | 2 +- src/jdversion.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index 726a88ea4..5aa933f07 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -220,7 +220,7 @@ std::string ENVIRONMENT::get_jdversion() jd_version << MAJORVERSION << "." << MINORVERSION << "." << MICROVERSION << "-" - << JDTAG << get_git_revision(GIT_DATE, GIT_HASH, GIT_DIRTY, JDDATE); + << JDTAG << get_git_revision(GIT_DATE, GIT_HASH, GIT_DIRTY, JDDATE_FALLBACK); #endif // JDVERSION_SVN return jd_version.str(); diff --git a/src/jdversion.h b/src/jdversion.h index 9b5f0e95c..7f91e250c 100644 --- a/src/jdversion.h +++ b/src/jdversion.h @@ -13,16 +13,20 @@ // svn 版の時は JDVERSION_SVN をdefineする //#define JDVERSION_SVN +// gitのリポジトリを使ってビルドしているときはリビジョンから日付を取得する +// リビジョンが参照できない場合はJDDATE_FALLBACKを使う +// SEE ALSO: ENVIRONMENT::get_jdversion() + #define MAJORVERSION 2 #define MINORVERSION 8 #define MICROVERSION 9 -#define JDDATE "180424" +#define JDDATE_FALLBACK "180424" #define JDTAG "" //--------------------------------- #define JDVERSION ( MAJORVERSION * 100 + MINORVERSION * 10 + MICROVERSION ) -#define JDVERSION_FULL ( JDVERSION * 1000000 + atoi( JDDATE ) ) +#define JDVERSION_FULL ( JDVERSION * 1000000 + atoi( JDDATE_FALLBACK ) ) //--------------------------------- @@ -76,7 +80,7 @@ #define JDRC_VERSION_FMT(a,b,c,d,e) #a "." #b "." #c "-" d e #endif #define JDRC_VERSION_STR JDRC_VERSION_EXP( \ - MAJORVERSION, MINORVERSION, MICROVERSION, JDTAG, JDDATE) + MAJORVERSION, MINORVERSION, MICROVERSION, JDTAG, JDDATE_FALLBACK) #define JDRC_FILEVERSION JDRC_VERSION_STR #define JDRC_PRODUCTVERSION JDRC_FILEVERSION From 69da80e7c055db6e239a79769e304e38c20d67db Mon Sep 17 00:00:00 2001 From: Masayuki Yamamoto Date: Sat, 8 Dec 2018 19:00:26 +0900 Subject: [PATCH 2/4] Fix debug log for std::thread --- src/jdlib/jdthread.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/jdlib/jdthread.cpp b/src/jdlib/jdthread.cpp index 2b1040683..00e5e93e2 100644 --- a/src/jdlib/jdthread.cpp +++ b/src/jdlib/jdthread.cpp @@ -15,6 +15,18 @@ using namespace JDLIB; +#ifdef _DEBUG +#ifdef WITH_STD_THREAD +template < class CharT, class Traits > +static std::basic_ostream< CharT, Traits >& +operator<<( std::basic_ostream< CharT, Traits >& ost, const std::thread& pth ) +{ + return ost << pth.get_id(); +} +#endif // WITH_STD_THREAD +#endif // _DEBUG + + Thread::Thread() { JDTH_CLEAR( m_thread ); From b46e404e0d451cdfa1679380005be3819a84e36c Mon Sep 17 00:00:00 2001 From: Masayuki Yamamoto Date: Fri, 23 Nov 2018 21:01:53 +0900 Subject: [PATCH 3/4] Use compiler flag "-pedantic-errors" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit コンパイラの拡張機能を禁止し標準に準拠する。 ./configureの引数に与えられたCXXFLAGSをJDのフラグより後ろに展開する。 clangは後ろのフラグを優先するため前で展開すると上書きできない場合がある。 --- configure.ac | 2 +- src/bbslist/bbslistview.h | 2 +- src/bbslist/bbslistviewbase.h | 4 ++-- src/bbslist/editlistwin.h | 2 +- src/bbslist/selectdialog.h | 2 +- src/bbslist/selectlistview.h | 2 +- src/board/boardview.h | 2 +- src/board/boardviewbase.h | 2 +- src/board/boardviewlog.h | 2 +- src/board/boardviewnext.h | 2 +- src/board/boardviewsidebar.h | 2 +- src/dbtree/interface.h | 2 +- src/dbtree/nodetreebase.cpp | 12 ++++++------ src/history/historymanager.h | 2 +- src/image/imageadmin.h | 2 +- src/jdlib/jdiconv.cpp | 4 ++-- src/jdlib/loader.h | 4 ++-- src/jdlib/misctrip.cpp | 10 +++++----- src/jdlib/misctrip.h | 2 +- src/jdlib/miscutil.cpp | 17 +++++++---------- src/openurldiag.h | 2 +- src/session.h | 2 +- src/skeleton/msgdiag.cpp | 2 +- 23 files changed, 41 insertions(+), 44 deletions(-) diff --git a/configure.ac b/configure.ac index ae5e0aa75..ca0e1db4b 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ dnl ユーザー設定 dnl dnl 追加コンパイルオプション -CXXFLAGS="$CXXFLAGS -ggdb -Wall" +CXXFLAGS="-ggdb -Wall -pedantic-errors $CXXFLAGS" dnl --------------------------------------------------- dnl --------------------------------------------------- diff --git a/src/bbslist/bbslistview.h b/src/bbslist/bbslistview.h index 672fe466f..abb5e654d 100644 --- a/src/bbslist/bbslistview.h +++ b/src/bbslist/bbslistview.h @@ -34,7 +34,7 @@ namespace BBSLIST virtual void delete_view_impl(); }; -}; +} #endif diff --git a/src/bbslist/bbslistviewbase.h b/src/bbslist/bbslistviewbase.h index 89c5c11ff..cdc3d33af 100644 --- a/src/bbslist/bbslistviewbase.h +++ b/src/bbslist/bbslistviewbase.h @@ -21,7 +21,7 @@ namespace SKELETON { class Admin; -}; +} #define SUBDIR_ETCLIST "外部板" @@ -323,7 +323,7 @@ namespace BBSLIST // ツリーの編集ウィンドウが閉じた void slot_hide_editlistwin(); }; -}; +} #endif diff --git a/src/bbslist/editlistwin.h b/src/bbslist/editlistwin.h index efebe3f17..0f9b0bc33 100644 --- a/src/bbslist/editlistwin.h +++ b/src/bbslist/editlistwin.h @@ -46,6 +46,6 @@ namespace BBSLIST void slot_redo(); void slot_undo_buffer_changed(); }; -}; +} #endif diff --git a/src/bbslist/selectdialog.h b/src/bbslist/selectdialog.h index 5ff52bfba..d3d0df70c 100644 --- a/src/bbslist/selectdialog.h +++ b/src/bbslist/selectdialog.h @@ -48,7 +48,7 @@ namespace BBSLIST void slot_show_tree(); virtual void timeout(); }; -}; +} #endif diff --git a/src/bbslist/selectlistview.h b/src/bbslist/selectlistview.h index c98baa6c6..ee4198ab8 100644 --- a/src/bbslist/selectlistview.h +++ b/src/bbslist/selectlistview.h @@ -40,7 +40,7 @@ namespace BBSLIST virtual Gtk::Menu* get_popupmenu( const std::string& url ); }; -}; +} #endif diff --git a/src/board/boardview.h b/src/board/boardview.h index bff7f2916..fdcce7a56 100644 --- a/src/board/boardview.h +++ b/src/board/boardview.h @@ -28,6 +28,6 @@ namespace BOARD virtual void update_view(); virtual void update_boardname(); }; -}; +} #endif diff --git a/src/board/boardviewbase.h b/src/board/boardviewbase.h index 8d9207199..e2b6822bc 100644 --- a/src/board/boardviewbase.h +++ b/src/board/boardviewbase.h @@ -300,7 +300,7 @@ namespace BOARD void draw_bg_articles(); }; -}; +} #endif diff --git a/src/board/boardviewlog.h b/src/board/boardviewlog.h index 6e4264bee..ab21bde85 100644 --- a/src/board/boardviewlog.h +++ b/src/board/boardviewlog.h @@ -48,6 +48,6 @@ namespace BOARD virtual void save_column_width(){} // 保存しない }; -}; +} #endif diff --git a/src/board/boardviewnext.h b/src/board/boardviewnext.h index 50ee17835..ac0cc0513 100644 --- a/src/board/boardviewnext.h +++ b/src/board/boardviewnext.h @@ -60,6 +60,6 @@ namespace BOARD virtual void save_column_width(){} // 保存しない }; -}; +} #endif diff --git a/src/board/boardviewsidebar.h b/src/board/boardviewsidebar.h index 8d3aae466..07d761174 100644 --- a/src/board/boardviewsidebar.h +++ b/src/board/boardviewsidebar.h @@ -51,6 +51,6 @@ namespace BOARD virtual void save_column_width(){} // 保存しない }; -}; +} #endif diff --git a/src/dbtree/interface.h b/src/dbtree/interface.h index a9899eb24..94677c70e 100644 --- a/src/dbtree/interface.h +++ b/src/dbtree/interface.h @@ -18,7 +18,7 @@ namespace XML { class Document; -}; +} namespace DBTREE { diff --git a/src/dbtree/nodetreebase.cpp b/src/dbtree/nodetreebase.cpp index da18604db..25ec00843 100644 --- a/src/dbtree/nodetreebase.cpp +++ b/src/dbtree/nodetreebase.cpp @@ -2540,9 +2540,9 @@ const bool NodeTreeBase::check_anchor( const int mode, const char* str_in, // utf-8で">" else if( ( unsigned char )( *pos ) == 0xef && ( unsigned char ) ( *( pos + 1 ) ) == 0xbc && ( unsigned char ) ( *( pos + 2 ) ) == 0x9e ){ - tmp_out[ lng_out++ ] = 0xef; - tmp_out[ lng_out++ ] = 0xbc; - tmp_out[ lng_out++ ] = 0x9e; + tmp_out[ lng_out++ ] = static_cast< char >( 0xef ); + tmp_out[ lng_out++ ] = static_cast< char >( 0xbc ); + tmp_out[ lng_out++ ] = static_cast< char >( 0x9e ); pos += 3; } else if( i == 0 ) return false; @@ -2567,9 +2567,9 @@ const bool NodeTreeBase::check_anchor( const int mode, const char* str_in, else if( ( unsigned char )( *pos ) == 0xe3 && ( unsigned char ) ( *( pos + 1 ) ) == 0x80 && ( unsigned char ) ( *( pos + 2 ) ) == 0x81 ){ - tmp_out[ lng_out++ ] = 0xe3; - tmp_out[ lng_out++ ] = 0x80; - tmp_out[ lng_out++ ] = 0x81; + tmp_out[ lng_out++ ] = static_cast< char >( 0xe3 ); + tmp_out[ lng_out++ ] = static_cast< char >( 0x80 ); + tmp_out[ lng_out++ ] = static_cast< char >( 0x81 ); str_link[ 0 ] = ','; ++str_link; diff --git a/src/history/historymanager.h b/src/history/historymanager.h index b75df506d..57859ec1d 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -15,7 +15,7 @@ namespace Gtk { class Menu; class MenuItem; -}; +} namespace HISTORY diff --git a/src/image/imageadmin.h b/src/image/imageadmin.h index 98d1be801..411ac5d51 100644 --- a/src/image/imageadmin.h +++ b/src/image/imageadmin.h @@ -124,7 +124,7 @@ namespace IMAGE IMAGE::ImageAdmin* get_admin(); void delete_admin(); -}; +} #endif diff --git a/src/jdlib/jdiconv.cpp b/src/jdlib/jdiconv.cpp index 56a1c0240..607395c98 100644 --- a/src/jdlib/jdiconv.cpp +++ b/src/jdlib/jdiconv.cpp @@ -145,8 +145,8 @@ const char* Iconv::convert( char* str_in, int size_in, int& size_out ) if( ( code0 >= 0x81 && code0 <=0x9F ) || ( code0 >= 0xe0 && code0 <=0xef ) ){ - *m_buf_in_tmp = 0x81; - *(m_buf_in_tmp+1) = 0xa0; + *m_buf_in_tmp = static_cast< char >( 0x81 ); + *(m_buf_in_tmp+1) = static_cast< char >( 0xa0 ); #ifdef _DEBUG_ICONV snprintf( str_tmp, 256, "iconv 0x%x%x -> □ (0x81a0) ", code0, code1 ); diff --git a/src/jdlib/loader.h b/src/jdlib/loader.h index d1c5fe5d6..58f091145 100644 --- a/src/jdlib/loader.h +++ b/src/jdlib/loader.h @@ -59,8 +59,8 @@ namespace JDLIB char* m_buf; // zlib 用のバッファ - unsigned long m_lng_buf_zlib_in; - unsigned long m_lng_buf_zlib_out;; + unsigned long m_lng_buf_zlib_in; + unsigned long m_lng_buf_zlib_out; Bytef* m_buf_zlib_in; Bytef* m_buf_zlib_out; diff --git a/src/jdlib/misctrip.cpp b/src/jdlib/misctrip.cpp index 213265546..16bdd680e 100644 --- a/src/jdlib/misctrip.cpp +++ b/src/jdlib/misctrip.cpp @@ -51,20 +51,20 @@ const std::string create_sha1( const std::string& key ) #ifdef USE_OPENSSL - const unsigned int digest_length = SHA_DIGEST_LENGTH; + constexpr const unsigned int digest_length = SHA_DIGEST_LENGTH; - unsigned char digest[ digest_length ]; + std::array< unsigned char, digest_length > digest; // unsigned char *SHA1( const unsigned char *, size_t, unsigned char * ); - SHA1( (const unsigned char *)key.c_str(), key.length(), digest ); + SHA1( (const unsigned char *)key.c_str(), key.length(), digest.data() ); #else // defined USE_GNUTLS const unsigned int digest_length = gcry_md_get_algo_dlen( GCRY_MD_SHA1 ); - unsigned char digest[ digest_length ]; + std::vector< unsigned char > digest( digest_length ); - gcry_md_hash_buffer( GCRY_MD_SHA1, digest, key.c_str(), key.length() ); + gcry_md_hash_buffer( GCRY_MD_SHA1, digest.data(), key.c_str(), key.length() ); #endif diff --git a/src/jdlib/misctrip.h b/src/jdlib/misctrip.h index 1373cb9c0..37c515fde 100644 --- a/src/jdlib/misctrip.h +++ b/src/jdlib/misctrip.h @@ -11,6 +11,6 @@ namespace MISC { // トリップを取得 (SHA1等の新方式対応) const std::string get_trip( const std::string& str, const std::string& charset ); -}; +} #endif diff --git a/src/jdlib/miscutil.cpp b/src/jdlib/miscutil.cpp index ddae0e12c..310263e5d 100644 --- a/src/jdlib/miscutil.cpp +++ b/src/jdlib/miscutil.cpp @@ -1060,8 +1060,7 @@ const std::string MISC::url_decode( const std::string& url ) const size_t url_length = url.length(); - char decoded[ url_length + 1 ]; - memset( decoded, 0, sizeof( decoded ) ); + std::vector< char > decoded( url_length + 1, '\0' ); unsigned int a, b; for( a = 0, b = a; a < url_length; ++a, ++b ) @@ -1093,7 +1092,7 @@ const std::string MISC::url_decode( const std::string& url ) } } - return std::string( decoded ); + return decoded.data(); } @@ -1124,7 +1123,7 @@ const std::string MISC::url_encode( const char* str, const size_t n ) ( c != '@' ) && ( c != '_' )){ - snprintf( str_tmp, tmplng , "\%%%02x", c ); + snprintf( str_tmp, tmplng , "%%%02x", c ); } else { str_tmp[ 0 ] = c; @@ -1641,15 +1640,13 @@ const std::string MISC::getenv_limited( const char *name, const size_t size ) { if( ! name || ! getenv( name ) ) return std::string(); - char env[ size + 1 ]; - env[ size ] = '\0'; - - strncpy( env, getenv( name ), size ); + std::vector< char > env( size + 1, '\0' ); + strncpy( env.data(), getenv( name ), size ); #ifdef _WIN32 - return recover_path( Glib::locale_to_utf8( std::string( env ) ) ); + return recover_path( Glib::locale_to_utf8( std::string( env.data() ) ); #else - return std::string( env ); + return env.data(); #endif } diff --git a/src/openurldiag.h b/src/openurldiag.h index ca9883f8e..3781cc036 100644 --- a/src/openurldiag.h +++ b/src/openurldiag.h @@ -25,7 +25,7 @@ namespace CORE virtual void slot_ok_clicked(); }; -}; +} #endif diff --git a/src/session.h b/src/session.h index 04591d735..9019eafcf 100644 --- a/src/session.h +++ b/src/session.h @@ -16,7 +16,7 @@ namespace ARTICLE { class DrawAreaBase; -}; +} namespace SESSION { diff --git a/src/skeleton/msgdiag.cpp b/src/skeleton/msgdiag.cpp index ca79fe368..d6faba9cc 100644 --- a/src/skeleton/msgdiag.cpp +++ b/src/skeleton/msgdiag.cpp @@ -217,4 +217,4 @@ MsgOverwriteDiag::MsgOverwriteDiag( Gtk::Window* parent ) add_button( "上書き", OVERWRITE_YES ); add_button( "すべていいえ", OVERWRITE_NO_ALL ); add_button( "すべて上書き", OVERWRITE_YES_ALL ); -}; +} From 386d3d2bc18c3b590124dd64b10adda069979503 Mon Sep 17 00:00:00 2001 From: Masayuki Yamamoto Date: Mon, 24 Dec 2018 08:38:34 +0900 Subject: [PATCH 4/4] Use compiler option "-pedantic" instead of "-pedantic-errors" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ライブラリヘッダーのエラーを避けるためコンパイラの拡張機能は警告にする https://github.com/yama-natuki/JD/pull/20#issuecomment-449643098 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ca0e1db4b..0af9b8f16 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ dnl ユーザー設定 dnl dnl 追加コンパイルオプション -CXXFLAGS="-ggdb -Wall -pedantic-errors $CXXFLAGS" +CXXFLAGS="-ggdb -Wall -pedantic $CXXFLAGS" dnl --------------------------------------------------- dnl ---------------------------------------------------