cwText,cwPianoScore : Added textCopy()
This commit is contained in:
parent
11cfb2cedc
commit
b5eaa633ef
@ -167,7 +167,7 @@ namespace cw
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(e->sci_pitch,sci_pitch,sizeof(e->sci_pitch));
|
strncpy(e->sci_pitch,sci_pitch,sizeof(e->sci_pitch)-1);
|
||||||
|
|
||||||
if( p->end == nullptr )
|
if( p->end == nullptr )
|
||||||
{
|
{
|
||||||
@ -570,16 +570,21 @@ namespace cw
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
textCopy( e->sci_pitch,sizeof(e->sci_pitch),sci_pitch);
|
||||||
|
textCopy( e->dmark,sizeof(e->dmark),dmark);
|
||||||
|
textCopy( e->grace_mark, sizeof(e->grace_mark),grace_mark);
|
||||||
|
/*
|
||||||
if( sci_pitch != nullptr )
|
if( sci_pitch != nullptr )
|
||||||
strncpy(e->sci_pitch,sci_pitch,sizeof(e->sci_pitch));
|
strncpy(e->sci_pitch,sci_pitch,sizeof(e->sci_pitch)-1);
|
||||||
|
|
||||||
if( dmark != nullptr )
|
if( dmark != nullptr )
|
||||||
strncpy(e->dmark,dmark,sizeof(e->dmark));
|
strncpy(e->dmark,dmark,sizeof(e->dmark)-1);
|
||||||
|
|
||||||
if( grace_mark != nullptr )
|
if( grace_mark != nullptr )
|
||||||
strncpy(e->grace_mark,grace_mark,sizeof(e->grace_mark));
|
strncpy(e->grace_mark,grace_mark,sizeof(e->grace_mark)-1);
|
||||||
|
*/
|
||||||
|
|
||||||
// assign the UID
|
// assign the UID
|
||||||
e->uid = i;
|
e->uid = i;
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ namespace cw
|
|||||||
|
|
||||||
rc_t _parse_note_on_row( score_parse_t* p, csv::handle_t csvH, event_t* e )
|
rc_t _parse_note_on_row( score_parse_t* p, csv::handle_t csvH, event_t* e )
|
||||||
{
|
{
|
||||||
rc_t rc,rc0,rc1,rc2;
|
rc_t rc,rc0=kOkRC,rc1=kOkRC,rc2=kOkRC;
|
||||||
const char* sciPitch = nullptr;
|
const char* sciPitch = nullptr;
|
||||||
const char* dmark = nullptr;
|
const char* dmark = nullptr;
|
||||||
const char* graceLabel = nullptr;
|
const char* graceLabel = nullptr;
|
||||||
|
24
cwText.cpp
24
cwText.cpp
@ -54,6 +54,30 @@ namespace cw
|
|||||||
unsigned cw::textLength( const char* s )
|
unsigned cw::textLength( const char* s )
|
||||||
{ return s == nullptr ? 0 : strlen(s); }
|
{ return s == nullptr ? 0 : strlen(s); }
|
||||||
|
|
||||||
|
const char* cw::textCopy( char* dst, unsigned dstN, const char* src, unsigned srcN )
|
||||||
|
{
|
||||||
|
if( dst == nullptr || dstN == 0 )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if( srcN == 0 )
|
||||||
|
srcN = textLength(src);
|
||||||
|
|
||||||
|
if( src == nullptr || srcN==0 || dstN==1 )
|
||||||
|
{
|
||||||
|
dst[0] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
assert( dstN >= 2 );
|
||||||
|
unsigned n = std::min( dstN-1, srcN );
|
||||||
|
memcpy(dst,src,n);
|
||||||
|
dst[n] = 0;
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void textToLower( char* s )
|
void textToLower( char* s )
|
||||||
{
|
{
|
||||||
if( s != nullptr )
|
if( s != nullptr )
|
||||||
|
7
cwText.h
7
cwText.h
@ -7,6 +7,13 @@ namespace cw
|
|||||||
// Return 0 if s is null.
|
// Return 0 if s is null.
|
||||||
unsigned textLength( const char* s );
|
unsigned textLength( const char* s );
|
||||||
|
|
||||||
|
// If dst is non-null then dst is always 0-terminated.
|
||||||
|
// If src will be truncated if srcN > dstN-1.
|
||||||
|
// If dst is null then null is returned
|
||||||
|
// if src is null then dst[0] = 0.
|
||||||
|
// if srcN is 0 then textLength(src) is used for srcN
|
||||||
|
const char* textCopy( char* dst, unsigned dstN, const char* src, unsigned srcN=0 );
|
||||||
|
|
||||||
void textToLower( char* s );
|
void textToLower( char* s );
|
||||||
void textToUpper( char* s );
|
void textToUpper( char* s );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user