@ -7,66 +7,45 @@
# include <stdlib.h>
# include <stdlib.h>
# include <string.h>
# include <string.h>
# include "log.h"
# include "log.h"
# include "stringop.h"
int escape_markup_text ( const char * src , char * dest , int dest_length ) {
size_t escape_markup_text ( const char * src , char * dest ) {
int length = 0 ;
size_t length = 0 ;
if ( dest ) {
dest [ 0 ] = ' \0 ' ;
}
while ( src [ 0 ] ) {
while ( src [ 0 ] ) {
switch ( src [ 0 ] ) {
switch ( src [ 0 ] ) {
case ' & ' :
case ' & ' :
length + = 5 ;
length + = 5 ;
if ( dest & & dest_length - length > = 0 ) {
lenient_strcat ( dest , " & " ) ;
dest + = sprintf ( dest , " %s " , " & " ) ;
} else {
dest_length = - 1 ;
}
break ;
break ;
case ' < ' :
case ' < ' :
length + = 4 ;
length + = 4 ;
if ( dest & & dest_length - length > = 0 ) {
lenient_strcat ( dest , " < " ) ;
dest + = sprintf ( dest , " %s " , " < " ) ;
} else {
dest_length = - 1 ;
}
break ;
break ;
case ' > ' :
case ' > ' :
length + = 4 ;
length + = 4 ;
if ( dest & & dest_length - length > = 0 ) {
lenient_strcat ( dest , " > " ) ;
dest + = sprintf ( dest , " %s " , " > " ) ;
} else {
dest_length = - 1 ;
}
break ;
break ;
case ' \' ' :
case ' \' ' :
length + = 6 ;
length + = 6 ;
if ( dest & & dest_length - length > = 0 ) {
lenient_strcat ( dest , " ' " ) ;
dest + = sprintf ( dest , " %s " , " ' " ) ;
} else {
dest_length = - 1 ;
}
break ;
break ;
case ' " ' :
case ' " ' :
length + = 6 ;
length + = 6 ;
if ( dest & & dest_length - length > = 0 ) {
lenient_strcat ( dest , " " " ) ;
dest + = sprintf ( dest , " %s " , " " " ) ;
} else {
dest_length = - 1 ;
}
break ;
break ;
default :
default :
length + = 1 ;
if ( dest ) {
if ( dest & & dest_length - length > = 0 ) {
dest [ length ] = * src ;
* ( dest + + ) = * src ;
dest [ length + 1 ] = ' \0 ' ;
} else {
dest_length = - 1 ;
}
}
length + = 1 ;
}
}
src + + ;
src + + ;
}
}
// if we could not fit the escaped string in dest, return -1
if ( dest & & dest_length = = - 1 ) {
return - 1 ;
}
return length ;
return length ;
}
}
@ -75,11 +54,9 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
PangoLayout * layout = pango_cairo_create_layout ( cairo ) ;
PangoLayout * layout = pango_cairo_create_layout ( cairo ) ;
PangoAttrList * attrs ;
PangoAttrList * attrs ;
if ( markup ) {
if ( markup ) {
char * buf ;
GError * error = NULL ;
GError * error = NULL ;
if ( pango_parse_markup ( text , - 1 , 0 , & attrs , & buf , NULL , & error ) ) {
if ( pango_parse_markup ( text , - 1 , 0 , & attrs , NULL , NULL , & error ) ) {
pango_layout_set_markup ( layout , buf , - 1 ) ;
pango_layout_set_markup ( layout , text , - 1 ) ;
free ( buf ) ;
} else {
} else {
wlr_log ( WLR_ERROR , " pango_parse_markup '%s' -> error %s " , text ,
wlr_log ( WLR_ERROR , " pango_parse_markup '%s' -> error %s " , text ,
error - > message ) ;
error - > message ) ;