# HG changeset patch # User Matti Hamalainen # Date 1457005465 -7200 # Node ID 3f878ae15050ff60d345b6130f401697b7e6b15f # Parent 56ec224421a60f7b4cee002ffceeddb01a468333 Prepare to handle variable width and precision given as arguments. diff -r 56ec224421a6 -r 3f878ae15050 th_string.c --- a/th_string.c Thu Mar 03 13:17:40 2016 +0200 +++ b/th_string.c Thu Mar 03 13:44:25 2016 +0200 @@ -411,17 +411,36 @@ } // Get field width - while (th_isdigit(*fmt)) - f_width = f_width * 10 + (*fmt++ - '0'); + if (*fmt == '*') + { + f_width = va_arg(ap, int); + if (f_width < 0) + { + f_flags |= TH_PF_LEFT; + f_width = -f_width; + } + } + else + { + while (th_isdigit(*fmt)) + f_width = f_width * 10 + (*fmt++ - '0'); + } // Check for field precision if (*fmt == '.') { fmt++; - // If no digit after '.', precision is to be 0 - f_prec = 0; - while (th_isdigit(*fmt)) - f_prec = f_prec * 10 + (*fmt++ - '0'); + if (*fmt == '*') + { + f_prec = va_arg(ap, int); + } + else + { + // If no digit after '.', precision is to be 0 + f_prec = 0; + while (th_isdigit(*fmt)) + f_prec = f_prec * 10 + (*fmt++ - '0'); + } } // Check for length modifiers (NOT SUPPORTED CURRENTLY)