some coverity fixes.
[minix.git] / lib / libc / stdlib / a64l.c
blob2e616b98ce7ae6c67c7d4b51f999bff1fbae5441
1 /*
2 * Written by J.T. Conklin <jtc@NetBSD.org>.
3 * Public domain.
4 */
6 #include <sys/cdefs.h>
7 #if defined(LIBC_SCCS) && !defined(lint)
8 __RCSID("$NetBSD: a64l.c,v 1.9 2003/07/26 19:24:53 salo Exp $");
9 #endif
11 #include "namespace.h"
13 #include <assert.h>
14 #include <stdlib.h>
16 #ifdef __weak_alias
17 __weak_alias(a64l,_a64l)
18 #endif
20 long
21 a64l(s)
22 const char *s;
24 long value, digit, shift;
25 int i;
27 _DIAGASSERT(s != NULL);
29 value = 0;
30 shift = 0;
31 for (i = 0; *s && i < 6; i++, s++) {
32 if (*s <= '/')
33 digit = *s - '.';
34 else if (*s <= '9')
35 digit = *s - '0' + 2;
36 else if (*s <= 'Z')
37 digit = *s - 'A' + 12;
38 else
39 digit = *s - 'a' + 38;
41 value |= digit << shift;
42 shift += 6;
45 return (long) value;