[PATCH 08/15] lib: Move common digit-parsing code into a function