settings.c
static void
parse_padding(struct padding *padding, const char * const value)
{
	static const char *pattern = "%lf %lf %lf %lf";
	double top, right, bottom, left;
	switch (sscanf(value, pattern, &top, &right, &bottom, &left)) {
	case 1:
		padding->top    = top;
		padding->right  = top;
		padding->bottom = top;
		padding->left   = top;
		break;
	case 4:
		padding->top    = top;
		padding->right  = right;
		padding->bottom = bottom;
		padding->left   = left;
		break;
	default:
		errx(1, "invalid padding string '%s' encountered", value);
	}
}
/*
 * This parses a a string into a padding. The string can either be a single
 * number ("%lf") in which case all 4 components of the struct padding are set
 * to the extracted number, or a string with all four components listed.
 * No allocations done here.
 */
This parses a a string into a padding. The string can either be a single
number ("%lf") in which case all 4 components of the struct padding are set
to the extracted number, or a string with all four components listed.
No allocations done here.
This parses a a string into a padding . The string can either be a single number ( " %lf " ) in which case all 4 components of the struct padding are set to the extracted number or a string with all four components listed . No allocations done here .
static void
parse_padding(struct padding *padding, const char * const value)
{
	static const char *pattern = "%lf %lf %lf %lf";
	double top, right, bottom, left;
	switch (sscanf(value, pattern, &top, &right, &bottom, &left)) {
	case 1:
		padding->top    = top;
		padding->right  = top;
		padding->bottom = top;
		padding->left   = top;
		break;
	case 4:
		padding->top    = top;
		padding->right  = right;
		padding->bottom = bottom;
		padding->left   = left;
		break;
	default:
		errx(1, "invalid padding string '%s' encountered", value);
	}
}
static void parse_padding ( struct padding * padding , const char * const value ) { static const char * pattern = " " ; double top , right , bottom , left ; switch ( sscanf ( value , pattern , & top , & right , & bottom , & left ) ) { case 1 : padding -> top = top ; padding -> right = top ; padding -> bottom = top ; padding -> left = top ; break ; case 4 : padding -> top = top ; padding -> right = right ; padding -> bottom = bottom ; padding -> left = left ; break ; default : errx ( 1 , " " , value ) ; } }
This parses a a string into a padding.
This parses a a string into a padding .