scripts/logging: Add support for numbered %ll and %hh
Python does not support values of long-long (ll) or short-short (hh) in
string-formatting. The current parser is correctly removing the first "h"
or "l" from the format, to make it possible to correctly parse these
strings when they are in the dictionary.
However, the current implementation does not correctly handle the case of
having a number before the "ll" or "hh" argument - which is supported by
both C and Python.
This commit updates the parser to correctly handle these cases, by changing
the simple replace operator with a regex replace, which is able to
correctly handle this case.
Before this commit, the string of:
"This is my long variable: %08llX"
will stay the same, which will throw a ValueError when parsing this
dictionary message:
"ValueError: unsupported format character 'h' (0x68) at index ".
After this commit, the string will be correctly fixed to
"This is my long variable: %08lX"
which is parsed correctly.
Signed-off-by:
Omri Sarig <omsi@demant.com>
Loading
Please sign in to comment