[systemd-devel] [PATCH 3/8] add atoi function
Joonas Lahtinen
joonas.lahtinen at linux.intel.com
Mon Dec 9 23:50:43 PST 2013
Add generic purpose number parsing function to be used by modeline
parsing.
Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Reviewed-by: Darren Hart <dvhart at linux.intel.com>
Reviewed-by: Mikko Ylinen <mikko.ylinen at intel.com>
---
src/efi/gummiboot.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/efi/gummiboot.c b/src/efi/gummiboot.c
index 127db22..8a83474 100644
--- a/src/efi/gummiboot.c
+++ b/src/efi/gummiboot.c
@@ -1356,6 +1356,32 @@ static CHAR8 *strchra(CHAR8 *s, CHAR8 c) {
return NULL;
}
+static INTN atoi(CHAR16 *str)
+{
+ INTN i;
+ BOOLEAN sign = FALSE;
+ CHAR16 c;
+
+ while (*str && *str == ' ') {
+ str += 1;
+ }
+
+ if(*str == '-') {
+ sign = TRUE;
+ str += 1;
+ }
+
+ i = 0;
+ while (c = *(str++)) {
+ if (c >= '0' && c <= '9') {
+ i = (i * 10) + (c - '0');
+ } else {
+ break;
+ }
+ }
+ return sign ? -i : i;
+}
+
static CHAR8 *line_get_key_value(CHAR8 *content, UINTN *pos, CHAR8
**key_ret, CHAR8 **value_ret) {
CHAR8 *line;
UINTN linelen;
--
1.8.1.4
More information about the systemd-devel
mailing list