Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / lib / libc / stdlib / a64l.c
blob3d4d664316c84ea9f63bae55d0c2c36d7d13b0e2
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.8 2000/01/22 22:19:19 mycroft 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;