Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #96

Merged
merged 27 commits into from Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c74190a
Change glibmm version for checking GMemVTable (main.cpp)
Oct 4, 2017
2422aeb
Simplify SKELETON::JDTreeViewBase::goto_bottom()
Oct 4, 2017
76a745e
Fix method to get color for Gtk::Entry
Oct 4, 2017
03c8061
Use std::string constructor instead of Glib::ustring for PangoLayout
Oct 4, 2017
1ab69d5
Fix off-by-one error for DrawAreaBase
Oct 4, 2017
369e53e
Fix buffer iteration for DrawAreaBase
Oct 4, 2017
9b9e47b
Fix BBSList select_item command for URL
Oct 4, 2017
b0ac8d4
Fix search method for URL scheme part of external board
Oct 4, 2017
4dcfe8d
Fix opening URL to no-op for thread/image history
Oct 4, 2017
75e1acd
Set to enable resizing column for about:config
Oct 4, 2017
c5b7a7a
Change construction timing for CONFIG::ConfigItems
Oct 4, 2017
390a3f2
Fix off-by-one error for Css_Manager
Oct 4, 2017
0b9fafe
Fix to add missing scheme for redirect board URL
Oct 4, 2017
7ec1b83
Fix update DB to list thread which is newer than subject.txt
Oct 4, 2017
5140925
Fix off-by-one error for Css_Manager
Oct 4, 2017
24f702a
Set error handling for HTTP status 301 and 416
Oct 4, 2017
e69cb86
Update debug print to show url boardbase for DBTREE::SettingLoader
Oct 4, 2017
9de8f0c
Assume only UTF-8 for MISC::split_line and MISC::remove_space
ma8ma Jul 6, 2019
37080e0
Add test case for MISC::split_line
ma8ma Jul 10, 2019
10965c2
Add test case for MISC::remove_space
ma8ma Jul 10, 2019
7f176bc
Update URL scheme judgement for SSSP
Oct 4, 2017
e4e0c59
Add test case for MISC::is_url_scheme
ma8ma Jul 10, 2019
47354c2
Fix regex for post message which includes Unicode
Oct 4, 2017
10b254d
Fix show/hide tabs for DragableNoteBook
Oct 4, 2017
2015cfc
Fix the position of showing menu for menu button
Oct 4, 2017
b532248
Fix to close all view before deleting article
Oct 4, 2017
963fa27
Remove test/gtest_examples.cpp
ma8ma Jul 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/article/drawareabase.cpp
Expand Up @@ -3091,7 +3091,11 @@ void DrawAreaBase::draw_string( LAYOUT* node, const CLIPINFO& ci,
pango_cairo_show_layout( text_cr, m_pango_layout->gobj() );
}
#else
m_pango_layout->set_text( Glib::ustring( node->text + pos_start, n_ustr ) );
// Glib::ustringのコンストラクタでchar*から変換するとUTF-8が
// 壊れている場合にインスタンスが生成されない
// (例外をキャッチしないとクラッシュする)ので
// std::stringからGlib::ustringに変換するコンストラクタを使う
m_pango_layout->set_text( std::string( node->text + pos_start, n_byte ) );
m_backscreen->draw_layout( m_gc,x, y, m_pango_layout, m_color[ color ], m_color[ color_back ] );

if( node->bold ){
Expand Down Expand Up @@ -3850,7 +3854,7 @@ int DrawAreaBase::search( const std::list< std::string >& list_query, const bool

const size_t lng = strlen( tmplayout->text );

if( buffer_lng + lng > SEARCH_BUFFER_SIZE ){
if( buffer_lng + lng >= SEARCH_BUFFER_SIZE ){

MISC::ERRMSG( "DrawAreaBase::search : buffer overflow." );
break;
Expand Down Expand Up @@ -4494,7 +4498,7 @@ bool DrawAreaBase::set_carets_dclick( CARET_POSITION& caret_left, CARET_POSITION

) pos_left = pos_tmp + byte_char;

pos_tmp += byte_char;
pos_tmp += ( byte_char ? byte_char : 1 );
}

// 右位置を求める
Expand All @@ -4512,7 +4516,7 @@ bool DrawAreaBase::set_carets_dclick( CARET_POSITION& caret_left, CARET_POSITION
// 区切り文字が来たらbreak
if( is_separate_char( ucs2 ) ) break;

pos_right += byte_char;
pos_right += ( byte_char ? byte_char : 1 );

// 文字種が変わった
if( ucs2_next == '\0'
Expand Down
7 changes: 5 additions & 2 deletions src/bbslist/bbslistadmin.cpp
Expand Up @@ -247,9 +247,12 @@ void BBSListAdmin::command_local( const COMMAND_ARGS& command )

// 板のアイコン表示を更新
else if( command.command == "toggle_boardicon" ) view->set_command( "toggle_boardicon", command.arg1 );
}

// URLを選択
else if( command.command == "select_item" ) view->set_command( "select_item", command.arg1 );
// URLを選択
if( command.command == "select_item" ){
view = get_current_view();
if( view ) view->set_command( "select_item", command.arg1 );
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/bbslist/bbslistviewbase.cpp
Expand Up @@ -1469,8 +1469,8 @@ void BBSListViewBase::add_newetcboard( const bool move, // true なら編集モ
return;
}

// http が無ければ付ける
if( url.find( "http://" ) != 0 && url.find( "https://" ) != 0 ) url = "http://" + url;
// http[s] が無ければ付ける
if( url.find( "://" ) == std::string::npos ) url = "http://" + url;

// .htmlを取り除く
JDLIB::Regex regex;
Expand Down Expand Up @@ -2524,6 +2524,10 @@ void BBSListViewBase::select_item( const std::string& url )
// スレまたは画像の場合
}
else {
// 板以外の履歴は処理しない
if( get_url() == URL_HISTTHREADVIEW || get_url() == URL_HISTCLOSEVIEW ||
get_url() == URL_HISTCLOSEIMGVIEW ) return;

// 板の場合
url_item = DBTREE::url_boardbase( url );

Expand Down
3 changes: 3 additions & 0 deletions src/config/aboutconfig.cpp
Expand Up @@ -49,6 +49,7 @@ void AboutConfig::pack_widgets()
m_label.set_text( "動作保証外です。高度な設定を変更するとJDimが誤作動する場合があります。" );

m_liststore = Gtk::ListStore::create( m_columns );
m_treeview.property_fixed_height_mode() = true;
m_treeview.set_model( m_liststore );
m_treeview.set_size_request( 700, 400 );
m_treeview.signal_row_activated().connect( sigc::mem_fun( *this, &AboutConfig::slot_row_activated ) );
Expand All @@ -62,6 +63,8 @@ void AboutConfig::pack_widgets()
if( cell ) column->set_cell_data_func( *cell, sigc::mem_fun( *this, &AboutConfig::slot_cell_data ) );

column = Gtk::manage( new Gtk::TreeViewColumn( "値", m_columns.m_col_value ) );
column->set_sizing( Gtk::TREE_VIEW_COLUMN_FIXED );
column->set_resizable( true );
m_treeview.append_column( *column );
cell = column->get_first_cell();
if( cell ) column->set_cell_data_func( *cell, sigc::mem_fun( *this, &AboutConfig::slot_cell_data ) );
Expand Down
2 changes: 1 addition & 1 deletion src/config/globalconf.cpp
Expand Up @@ -19,7 +19,6 @@ CONFIG::ConfigItems* instance_confitem_bkup = NULL;

CONFIG::ConfigItems* CONFIG::get_confitem()
{
if( ! instance_confitem ) instance_confitem = new CONFIG::ConfigItems();
return instance_confitem;
}

Expand All @@ -36,6 +35,7 @@ void CONFIG::delete_confitem()

bool CONFIG::load_conf()
{
if( ! instance_confitem ) instance_confitem = new CONFIG::ConfigItems();
return get_confitem()->load();
}

Expand Down
8 changes: 4 additions & 4 deletions src/core.cpp
Expand Up @@ -2295,10 +2295,6 @@ void Core::set_command( const COMMAND_ARGS& command )
}
}

DBTREE::delete_article( command.url, ( command.arg1 == "reget" ) );

if( DBTREE::article_is_cached( command.url ) ) return;

ARTICLE::get_admin()->set_command( "unlock_views", command.url );
ARTICLE::get_admin()->set_command( "close_view", command.url,
"closeall" // command.url を含む全てのビューを閉じる
Expand All @@ -2309,6 +2305,10 @@ void Core::set_command( const COMMAND_ARGS& command )
"closeall" // command.url を含む全てのビューを閉じる
);

DBTREE::delete_article( command.url, ( command.arg1 == "reget" ) );

if( DBTREE::article_is_cached( command.url ) ) return;

// ポップアップも削除して対象となるarticlebaseのロックを解除 (注) ポップアップは遅延してdeleteされる
// そうしないと articlebase::unlock_impl()が呼び出されないためnotetreebaseが削除されない
ARTICLE::get_admin()->set_command( "delete_all_popups" );
Expand Down
2 changes: 1 addition & 1 deletion src/cssmanager.cpp
Expand Up @@ -661,7 +661,7 @@ DOM* Css_Manager::create_textnode( const char* text )
#endif

DOM* tmpdom = create_domnode( DOMNODE_TEXT );
tmpdom->chardat = ( char* ) m_heap.heap_alloc( lng );
tmpdom->chardat = ( char* ) m_heap.heap_alloc( lng + 1 );
strncpy( tmpdom->chardat, text, lng );

return tmpdom;
Expand Down
29 changes: 19 additions & 10 deletions src/dbtree/boardbase.cpp
Expand Up @@ -1164,7 +1164,13 @@ void BoardBase::receive_finish()
std::string query = ".*window.location.href=\"([^\"]*)\".*";
if( regex.exec( query, m_rawdata, offset, icase, newline, usemigemo, wchar ) ){

const std::string new_url = regex.str( 1 );
std::string new_url = regex.str( 1 );
if( new_url.compare( 0, 2, "//" ) == 0 ){
std::string tmp_url = url_boardbase();
size_t pos = tmp_url.find("://");
if( pos != std::string::npos )
new_url.insert( 0, tmp_url.substr( 0, pos + 1 ) );
}
int ret = Gtk::RESPONSE_YES;

if( CONFIG::get_show_movediag() ){
Expand Down Expand Up @@ -1280,17 +1286,20 @@ void BoardBase::receive_finish()

// 一度全てのarticleをdat落ち状態にして subject.txt に
// 含まれているものだけ regist_article()の中で通常状態にする
if( m_is_online
|| m_is_booting // ブート中の時も状態を変えないと起動直後にスレ一覧を復元した時にdat落ちしたスレが表示されない
){

ArticleHashIterator it = m_hash_article->begin();
for( ; it != m_hash_article->end(); ++it ){

int status = ( *it )->get_status();
ArticleHashIterator hash_it = m_hash_article->begin();
for( ; hash_it != m_hash_article->end(); ++hash_it ){

if( read_from_cache && ! ( *hash_it )->is_924()
&& ( *hash_it )->get_since_time() > m_last_access_time ){
// キャッシュから読み込む場合にsubject.txtよりも新しいスレは残す
( *hash_it )->read_info();
if( ! is_abone_thread( *hash_it ) ) m_list_subject.push_back( *hash_it );
}
else{
int status = ( *hash_it )->get_status();
status &= ~STATUS_NORMAL;
status |= STATUS_OLD;
( *it )->set_status( status );
( *hash_it )->set_status( status );
}
}

Expand Down
13 changes: 7 additions & 6 deletions src/dbtree/nodetreebase.cpp
Expand Up @@ -935,7 +935,7 @@ NODE* NodeTreeBase::create_node_link( const char* text, const int n, const char*
tmpnode->type = NODE_LINK;

// リンク情報作成
char *tmplink = ( char* )m_heap.heap_alloc( n_link +4 );
char *tmplink = ( char* )m_heap.heap_alloc( n_link + 1 );
memcpy( tmplink, link, n_link );
tmplink[ n_link ] = '\0';

Expand Down Expand Up @@ -975,7 +975,7 @@ NODE* NodeTreeBase::create_node_sssp( const char* link, const int n_link )
tmpnode->type = NODE_SSSP;

// リンク情報作成
char *tmplink = ( char* )m_heap.heap_alloc( n_link +4 );
char *tmplink = ( char* )m_heap.heap_alloc( n_link + 1 );
memcpy( tmplink, link, n_link );
tmplink[ n_link ] = '\0';

Expand Down Expand Up @@ -1013,7 +1013,7 @@ NODE* NodeTreeBase::create_node_thumbnail( const char* text, const int n, const

if( tmpnode ){
// サムネイル画像のURLをセット
char *tmpthumb = ( char* )m_heap.heap_alloc( n_thumb +4 );
char *tmpthumb = ( char* )m_heap.heap_alloc( n_thumb + 1 );
memcpy( tmpthumb, thumb, n_thumb );
tmpthumb[ n_thumb ] = '\0';

Expand Down Expand Up @@ -1159,7 +1159,7 @@ void NodeTreeBase::set_resume_data( const char* data, size_t length )

// レジューム時のチェック用に生データの先頭から RESUME_CHKSIZE バイト分をコピーしておく
// 詳しくは NodeTreeBase::receive_data() を参照せよ
const size_t length_chk = MIN( RESUME_CHKSIZE, length );
const size_t length_chk = MIN( (RESUME_CHKSIZE - 1), length );
memcpy( m_resume_head, data, length_chk );
m_resume_head[ length_chk ] = '\0';
}
Expand Down Expand Up @@ -1364,14 +1364,15 @@ void NodeTreeBase::receive_finish()
&& get_code() != HTTP_OK
&& get_code() != HTTP_PARTIAL_CONTENT
&& get_code() != HTTP_NOT_MODIFIED
&& get_code() != HTTP_RANGE_ERR
&& get_code() != HTTP_OLD
){
is_error = true;

std::ostringstream err;
err << m_url << std::endl
<< "load failed. : " << get_str_code();
if( get_code() == HTTP_REDIRECT || get_code() == HTTP_REDIRECT ) err << " location = " << location();
if( get_code() == HTTP_MOVED_PERM || get_code() == HTTP_REDIRECT ) err << " location = " << location();
MISC::ERRMSG( err.str() );
}

Expand Down Expand Up @@ -1464,7 +1465,7 @@ void NodeTreeBase::add_raw_lines( char* rawlines, size_t size )
#endif

// 先頭からdatを送ってきたかチェック
const size_t length_chk = MIN( lng, MIN( RESUME_CHKSIZE, strlen( m_resume_head ) ) );
const size_t length_chk = MIN( lng, MIN( (RESUME_CHKSIZE - 1), strlen( m_resume_head ) ) );
if( strncmp( rawlines, m_resume_head, length_chk ) == 0 ){
m_resume = RESUME_MODE3;
m_resume_lng = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/dbtree/settingloader.cpp
Expand Up @@ -24,7 +24,7 @@ SettingLoader::SettingLoader( const std::string& url_boadbase )
m_message_count( 0 )
{
#ifdef _DEBUG
std::cout << "SettingLoader::SettingLoader : " << get_url() << std::endl;
std::cout << "SettingLoader::SettingLoader : " << m_url_boadbase << std::endl;
#endif

set_date_modified( DBTREE::board_get_modified_setting( m_url_boadbase ) );
Expand All @@ -34,7 +34,7 @@ SettingLoader::SettingLoader( const std::string& url_boadbase )
SettingLoader::~SettingLoader()
{
#ifdef _DEBUG
std::cout << "SettingLoader::~SettingLoader : " << get_url() << std::endl;
std::cout << "SettingLoader::~SettingLoader : " << m_url_boadbase << std::endl;
#endif
}

Expand Down
14 changes: 14 additions & 0 deletions src/jdlib/miscgtk.cpp
Expand Up @@ -148,6 +148,13 @@ std::string MISC::get_entry_color_text()
auto rgba = entry.get_style_context()->get_color( Gtk::STATE_FLAG_NORMAL );
return color_to_str( rgba );
#else
Gtk::Window win( Gtk::WINDOW_POPUP );

win.add( entry );
win.move( 0,0 );
win.resize( 1,1 );
win.show_all();

return color_to_str( entry.get_style()->get_text( Gtk::STATE_NORMAL ) );
#endif
}
Expand All @@ -169,6 +176,13 @@ std::string MISC::get_entry_color_base()
}
return color_to_str( rgba );
#else
Gtk::Window win( Gtk::WINDOW_POPUP );

win.add( entry );
win.move( 0,0 );
win.resize( 1,1 );
win.show_all();

return color_to_str( entry.get_style()->get_base( Gtk::STATE_NORMAL ) );
#endif
}
Expand Down
34 changes: 18 additions & 16 deletions src/jdlib/miscutil.cpp
Expand Up @@ -111,8 +111,8 @@ std::list< std::string > MISC::get_elisp_lists( const std::string& str )
//
std::list< std::string > MISC::split_line( const std::string& str )
{
std::string str_space = " ";
size_t lng_space = str_space.length();
constexpr const char* str_space = u8"\u3000"; // "\xE3\x80\x80" 全角スペース
constexpr size_t lng_space = 3;
bool dquote;

std::list< std::string > list_str;
Expand All @@ -129,7 +129,7 @@ std::list< std::string > MISC::split_line( const std::string& str )
// 全角
else if( str[ i ] == str_space[ 0 ] &&
str[ i +1 ] == str_space[ 1 ] &&
( lng_space == 2 || str[ i +2 ] == str_space[ 2 ] ) ) i += lng_space;
str[ i +2 ] == str_space[ 2 ] ) i += lng_space;

else break;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ std::list< std::string > MISC::split_line( const std::string& str )
// 全角
else if( str[ i2 ] == str_space[ 0 ] &&
str[ i2 +1 ] == str_space[ 1 ] &&
( lng_space == 2 || str[ i2 +2 ] == str_space[ 2 ] ) ){
str[ i2 +2 ] == str_space[ 2 ] ){
lng_tmp = lng_space;
break;
}
Expand Down Expand Up @@ -294,13 +294,13 @@ std::string MISC::listtostr( const std::list< std::string >& list_in )
//
std::string MISC::remove_space( const std::string& str )
{
std::string str_space = " ";
size_t lng_space = str_space.length();
constexpr const char* str_space = u8"\u3000"; // "\xE3\x80\x80" 全角スペース
constexpr size_t lng_space = 3;

size_t lng = str.length();

if( lng == 0 ) return str;
if( str.find( " " ) == std::string::npos ) return str;
if( str.find( ' ' ) == std::string::npos ) return str;

// 前
size_t i = 0;
Expand All @@ -312,7 +312,7 @@ std::string MISC::remove_space( const std::string& str )
// 全角
else if( str[ i ] == str_space[ 0 ] &&
str[ i +1 ] == str_space[ 1 ] &&
( lng_space == 2 || str[ i +2 ] == str_space[ 2 ] ) ) i += lng_space;
str[ i +2 ] == str_space[ 2 ] ) i += lng_space;
else break;
}

Expand All @@ -327,7 +327,7 @@ std::string MISC::remove_space( const std::string& str )
else if( i2 +1 >= lng_space &&
str[ i2 - lng_space +1 ] == str_space[ 0 ] &&
str[ i2 - lng_space +2 ] == str_space[ 1 ] &&
( lng_space == 2 || str[ i2 - lng_space +3 ] == str_space[ 2 ] ) ) i2 -= lng_space;
str[ i2 - lng_space +3 ] == str_space[ 2 ] ) i2 -= lng_space;
else break;
}

Expand Down Expand Up @@ -970,13 +970,15 @@ int MISC::is_url_scheme_impl( const char* str_in, int* length )
if( *( str_in + len ) == 's' ) ++len;
}
// sssp
// デフォルトでモザイクを解除するのでimg.2ch以外のアドレスにはリンクを張らない
else if( *str_in == 's' && *( str_in + 1 ) == 's' && *( str_in + 2 ) == 's' && *( str_in + 3 ) == 'p'
&& *( str_in + 7 ) == 'i' && *( str_in + 8 ) == 'm' && *( str_in + 9 ) == 'g' && *( str_in + 10 ) == '.'
&& *( str_in + 11 ) == '2' && *( str_in + 12 ) == 'c' && *( str_in + 13 ) == 'h'
)
{
scheme = SCHEME_SSSP;
else if( *str_in == 's' && *( str_in + 1 ) == 's' && *( str_in + 2 ) == 's' && *( str_in + 3 ) == 'p' ){
if( *( str_in + 7 ) == 'i' && *( str_in + 8 ) == 'm' && *( str_in + 9 ) == 'g' && *( str_in + 10 ) == '.'
&& *( str_in + 11 ) == '2' && *( str_in + 12 ) == 'c' && *( str_in + 13 ) == 'h'){
scheme = SCHEME_SSSP;
}
else{
// XXX img.2ch以外のアドレスはHTTPスキームにする
scheme = SCHEME_HTTP;
}
len = 4;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -487,7 +487,7 @@ int main( int argc, char **argv )
}
#endif

#if ! GLIB_CHECK_VERSION(2, 46, 0)
#if !GLIB_CHECK_VERSION(2,45,5)
#ifdef _DEBUG_MEM_PROFILE
g_mem_set_vtable( glib_mem_profiler_table );
atexit( g_mem_profile );
Expand Down
2 changes: 1 addition & 1 deletion src/message/messageviewbase.cpp
Expand Up @@ -673,7 +673,7 @@ void MessageViewBase::write()
const bool newline = true;
const bool usemigemo = false;
const bool wchar = false;
if( regex.exec( "%26%23[0-9]*%3b", msg, offset, icase, newline, usemigemo, wchar ) ){
if( regex.exec( "%26%23[0-9]+%3b", msg, offset, icase, newline, usemigemo, wchar ) ){

SKELETON::MsgDiag mdiag( get_parent_win(),
"ユニコード文字が含まれていますが、この板ではユニコード文字は文字化けします(BBS_UNICODE=change)。\n\n書き込みますか?",
Expand Down