mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
* util.h (digitp, hexdigitp): New ctype like macros.
(atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New.
This commit is contained in:
parent
b020999687
commit
317bccd134
17
common/ChangeLog
Normal file
17
common/ChangeLog
Normal file
@ -0,0 +1,17 @@
|
||||
2001-12-14 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* util.h (digitp, hexdigitp): New ctype like macros.
|
||||
(atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New.
|
||||
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software; as a special exception the author gives
|
||||
unlimited permission to copy and/or distribute it, with or without
|
||||
modifications, as long as this notice is preserved.
|
||||
|
||||
This file is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
|
@ -55,6 +55,21 @@ int map_kbx_err (int err);
|
||||
int map_assuan_err (int err);
|
||||
|
||||
|
||||
/* some macros to replace ctype ones and avoid locale problems */
|
||||
#define digitp(p) (*(p) >= '0' && *(p) <= '9')
|
||||
#define hexdigitp(a) (digitp (a) \
|
||||
|| ((a) >= 'A' && (a) <= 'F') \
|
||||
|| ((a) >= 'a' && (a) <= 'f'))
|
||||
/* the atoi macros assume that the buffer has only valid digits */
|
||||
#define atoi_1(p) (*(p) - '0' )
|
||||
#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
|
||||
#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
|
||||
#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
|
||||
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
|
||||
#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
|
||||
|
||||
|
||||
|
||||
#endif /*GNUPG_COMMON_UTIL_H*/
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user