aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-17 00:30:20 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-17 00:30:20 +0000
commita830197f59d61b2734ecc872fd7c7905ac36af37 (patch)
tree229869ad2041213821dce08717912dbc99ff7916
parenta3ec1e1f94edf547932e109b93b3ea9d443b1758 (diff)
downloadriscv-openocd-a830197f59d61b2734ecc872fd7c7905ac36af37.zip
riscv-openocd-a830197f59d61b2734ecc872fd7c7905ac36af37.tar.gz
riscv-openocd-a830197f59d61b2734ecc872fd7c7905ac36af37.tar.bz2
Add improved support for parsing signed integers.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2255 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r--src/helper/command.c2
-rw-r--r--src/helper/command.h10
2 files changed, 12 insertions, 0 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index 7196cbe..30c5b12 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -873,4 +873,6 @@ long jim_global_long(const char *variable)
}
DEFINE_PARSE_NUM_TYPE(_ulong, unsigned long , strtoul, ULONG_MAX)
DEFINE_PARSE_NUM_TYPE(_ullong, unsigned long long, strtoull, ULLONG_MAX)
+DEFINE_PARSE_NUM_TYPE(_long, long , strtol, LONG_MAX)
+DEFINE_PARSE_NUM_TYPE(_llong, long long, strtoll, LLONG_MAX)
diff --git a/src/helper/command.h b/src/helper/command.h
index fb80d59..4e7180f 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -110,6 +110,9 @@ long jim_global_long(const char *variable);
int parse_ulong(const char *str, unsigned long *ul);
int parse_ullong(const char *str, unsigned long long *ul);
+int parse_long(const char *str, long *ul);
+int parse_llong(const char *str, long long *ul);
+
#define DEFINE_PARSE_NUM_WRAP(name, type, max, functype, funcname) \
static inline int parse_##name(const char *str, type *ul) \
{ \
@@ -126,6 +129,13 @@ DEFINE_PARSE_ULONG(u32, uint32_t, UINT32_MAX)
DEFINE_PARSE_ULONG(u16, uint16_t, UINT16_MAX)
DEFINE_PARSE_ULONG(u8, uint8_t, UINT8_MAX)
+#define DEFINE_PARSE_LONG(name, type, max) \
+ DEFINE_PARSE_NUM_WRAP(name, type, max, long, _long)
+DEFINE_PARSE_LONG(int, int, INT_MAX)
+DEFINE_PARSE_LONG(s32, int32_t, INT32_MAX)
+DEFINE_PARSE_LONG(s16, int16_t, INT16_MAX)
+DEFINE_PARSE_LONG(s8, int8_t, INT8_MAX)
+
void script_debug(Jim_Interp *interp, const char *cmd, int argc, Jim_Obj *const *argv);
#endif /* COMMAND_H */