View Issue Details

IDProjectCategoryView StatusLast Update
0000799OpenMPTlibopenmptpublic2016-05-20 19:37
Reporterjcowgill Assigned Tomanx  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Platformx64OSDebian LinuxOS Versionsid
Product VersionOpenMPT 1.25.04.00 / libopenmpt 0.2-beta16 (upgrade first) 
Target VersionOpenMPT 1.26.01.00 / libopenmpt 0.2-beta17 (upgrade first)Fixed in VersionOpenMPT 1.26.01.00 / libopenmpt 0.2-beta17 (upgrade first) 
Summary0000799: format_pattern_row_channel unlimited width does not work
Description

Hi,

The documentation for openmpt::module::format_pattern_row_channel (and other methods) says:
width The maximum number of characters the string should contain. 0 means no limit.

However, if I pass 0 as the width I always get an empty string.

James

TagsNo tags attached.
Attached Files
bug-799-fix-v1.patch (2,469 bytes)   
Index: libopenmpt/libopenmpt_impl.cpp
===================================================================
--- libopenmpt/libopenmpt_impl.cpp	(revision 6388)
+++ libopenmpt/libopenmpt_impl.cpp	(working copy)
@@ -1273,9 +1273,6 @@
 	if ( c < 0 || c >= numchannels ) {
 		return std::make_pair( text, high );
 	}
-	if ( width == 0 ) {
-		return std::make_pair( text, high );
-	}
 	//  0000000001111
 	//  1234567890123
 	// "NNN IIvVV EFF"
@@ -1284,30 +1281,30 @@
 	high.clear();
 	text += ( cell.IsNote() || cell.IsSpecialNote() ) ? m_sndFile->GetNoteName( cell.note, cell.instr ) : std::string("...");
 	high += ( cell.IsNote() ) ? std::string("nnn") : cell.IsSpecialNote() ? std::string("mmm") : std::string("...");
-	if ( width >= 6 ) {
+	if ( ( width == 0 ) || ( width >= 6 ) ) {
 		text += std::string(" ");
 		high += std::string(" ");
 		text += cell.instr ? mpt::fmt::HEX0<2>( cell.instr ) : std::string("..");
 		high += cell.instr ? std::string("ii") : std::string("..");
 	}
-	if ( width >= 9 ) {
+	if ( ( width == 0 ) || ( width >= 9 ) ) {
 		text += cell.IsPcNote() ? std::string(" ") + mpt::fmt::HEX0<2>( cell.GetValueVolCol() & 0xff ) : cell.volcmd != VOLCMD_NONE ? std::string( 1, m_sndFile->GetModSpecifications().GetVolEffectLetter( cell.volcmd ) ) + mpt::fmt::HEX0<2>( cell.vol ) : std::string(" ..");
 		high += cell.IsPcNote() ? std::string(" vv") : cell.volcmd != VOLCMD_NONE ? std::string("uvv") : std::string(" ..");
 	}
-	if ( width >= 13 ) {
+	if ( ( width == 0 ) || ( width >= 13 ) ) {
 		text += std::string(" ");
 		high += std::string(" ");
 		text += cell.IsPcNote() ? mpt::fmt::HEX0<3>( cell.GetValueEffectCol() & 0x0fff ) : cell.command != CMD_NONE ? std::string( 1, m_sndFile->GetModSpecifications().GetEffectLetter( cell.command ) ) + mpt::fmt::HEX0<2>( cell.param ) : std::string("...");
 		high += cell.IsPcNote() ? std::string("eff") : cell.command != CMD_NONE ? std::string("eff") : std::string("...");
 	}
-	if ( text.length() > width ) {
+	if ( ( width != 0 ) && ( text.length() > width ) ) {
 		text = text.substr( 0, width );
-	} else if ( pad ) {
+	} else if ( ( width != 0 ) && pad ) {
 		text += std::string( width - text.length(), ' ' );
 	}
-	if ( high.length() > width ) {
+	if ( ( width != 0 ) && ( high.length() > width ) ) {
 		high = high.substr( 0, width );
-	} else if ( pad ) {
+	} else if ( ( width != 0 ) && pad ) {
 		high += std::string( width - high.length(), ' ' );
 	}
 	return std::make_pair( text, high );
bug-799-fix-v1.patch (2,469 bytes)   
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Activities

manx

manx

2016-05-20 19:37

administrator   ~0002405

Should be fixed in r6389.

Issue History

Date Modified Username Field Change
2016-05-20 19:08 jcowgill New Issue
2016-05-20 19:15 manx Assigned To => manx
2016-05-20 19:15 manx Status new => assigned
2016-05-20 19:28 manx Status assigned => confirmed
2016-05-20 19:28 manx Target Version => OpenMPT 1.26.01.00 / libopenmpt 0.2-beta17 (upgrade first)
2016-05-20 19:37 manx Note Added: 0002405
2016-05-20 19:37 manx Status confirmed => resolved
2016-05-20 19:37 manx Fixed in Version => OpenMPT 1.26.01.00 / libopenmpt 0.2-beta17 (upgrade first)
2016-05-20 19:37 manx Resolution open => fixed
2016-05-20 19:37 manx File Added: bug-799-fix-v1.patch