Expanded tabs in all source files. Added vim/emacs local variables
[yaz-moved-to-github.git] / src / atoin.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: atoin.c,v 1.7 2005-06-25 15:46:03 adam Exp $
6  */
7
8 /** 
9  * \file atoin.c
10  * \brief Implements atoi_n function.
11  */
12
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17 #include <string.h>
18 #include <ctype.h>
19 #include <yaz/marcdisp.h>
20
21 /**
22  * atoi_n: like atoi but reads at most len characters.
23  */
24 int atoi_n (const char *buf, int len)
25 {
26     int val = 0;
27
28     while (--len >= 0)
29     {
30         if (isdigit (*(const unsigned char *) buf))
31             val = val*10 + (*buf - '0');
32         buf++;
33     }
34     return val;
35 }
36
37 /*
38  * Local variables:
39  * c-basic-offset: 4
40  * indent-tabs-mode: nil
41  * End:
42  * vim: shiftwidth=4 tabstop=8 expandtab
43  */
44