*/
pv->last_entry_number = entry_number;
resync = 0;
- if( *pv->current_entry.text )
+ if (*pv->current_entry.text != '\0')
{
long length;
char *p, *q;
length = strlen( pv->current_entry.text );
- for( q = p = pv->current_entry.text; *p; p++)
+ for (q = p = pv->current_entry.text; *p != '\0'; p++)
{
- if( *p == '\n' )
+ if (*p == '\n' || *p == '\r')
{
- if ( line == 1 )
+ if (*(p + 1) == '\n' || *(p + 1) == '\0')
{
- *q = *p;
+ // followed by line break or last character, skip it
+ length--;
+ continue;
+ }
+ else if (line == 1)
+ {
+ // replace '\r' with '\n'
+ *q = '\n';
line = 2;
}
else
{
+ // all subtitles on one line
+ // replace line breaks with spaces
*q = ' ';
}
q++;
}
- else if( *p != '\r' )
+ else
{
*q = *p;
q++;
}
- else
- {
- length--;
- }
}
*q = '\0';
}
hb_buffer_t *buffer = NULL;
- if( *pv->current_entry.text )
+ if (*pv->current_entry.text != '\0')
{
long length;
char *p, *q;
length = strlen( pv->current_entry.text );
- for( q = p = pv->current_entry.text; *p; p++)
+ for (q = p = pv->current_entry.text; *p != '\0'; p++)
{
- if( *p == '\n' )
+ if (*p == '\n' || *p == '\r')
{
- if ( line == 1 )
+ if (*(p + 1) == '\n' || *(p + 1) == '\0')
{
- *q = *p;
+ // followed by line break or last character, skip it
+ length--;
+ continue;
+ }
+ else if (line == 1)
+ {
+ // replace '\r' with '\n'
+ *q = '\n';
line = 2;
}
else
{
+ // all subtitles on one line
+ // replace line breaks with spaces
*q = ' ';
}
q++;
}
- else if( *p != '\r' )
+ else
{
*q = *p;
q++;
}
- else
- {
- length--;
- }
}
*q = '\0';