projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update RPM requires
[yaz-moved-to-github.git]
/
src
/
atoin.c
diff --git
a/src/atoin.c
b/src/atoin.c
index
b1d9fda
..
4ee0313
100644
(file)
--- a/
src/atoin.c
+++ b/
src/atoin.c
@@
-1,9
+1,9
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
-/**
+/**
* \file atoin.c
* \brief Implements atoi_n function.
*/
* \file atoin.c
* \brief Implements atoi_n function.
*/
@@
-13,28
+13,36
@@
#endif
#include <string.h>
#endif
#include <string.h>
-#include <ctype.h>
#include <yaz/marcdisp.h>
#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
-/**
- * atoi_n: like atoi but reads at most len characters.
- */
-int atoi_n (const char *buf, int len)
+int atoi_n(const char *buf, int len)
{
int val = 0;
while (--len >= 0)
{
{
int val = 0;
while (--len >= 0)
{
- if (isdigit (*(const unsigned char *) buf))
+ if (yaz_isdigit(*buf))
val = val*10 + (*buf - '0');
buf++;
}
return val;
}
val = val*10 + (*buf - '0');
buf++;
}
return val;
}
+int atoi_n_check(const char *buf, int size, int *val)
+{
+ int i;
+ for (i = 0; i < size; i++)
+ if (!yaz_isdigit(buf[i]))
+ return 0;
+ *val = atoi_n(buf, size);
+ return 1;
+}
+
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab