aboutsummaryrefslogtreecommitdiffstats
path: root/libpatch_get_zu__.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpatch_get_zu__.c')
-rw-r--r--libpatch_get_zu__.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libpatch_get_zu__.c b/libpatch_get_zu__.c
new file mode 100644
index 0000000..050f3d2
--- /dev/null
+++ b/libpatch_get_zu__.c
@@ -0,0 +1,17 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+size_t
+libpatch_get_zu__(const char *text, size_t len, size_t *out)
+{
+ size_t i = 0, digit;
+ *out = 0;
+ for (; i < len; i++) {
+ digit = (size_t)(text[i] - '0');
+ if (digit > 9U)
+ break;
+ *out = *out * 10U + digit;
+ }
+ return i;
+}