aboutsummaryrefslogtreecommitdiff
path: root/include/xatonum.h
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 14:43:21 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 14:43:21 +0000
commitd686a045c8134d3a42fa5cc6b2e09118e08d603f (patch)
tree38f509fc9556f68f758c77b06b480cc33b2725eb /include/xatonum.h
parent8a0a83d503a7971895254efa9e79cf15ba1850d4 (diff)
downloadbusybox-w32-d686a045c8134d3a42fa5cc6b2e09118e08d603f.tar.gz
busybox-w32-d686a045c8134d3a42fa5cc6b2e09118e08d603f.tar.bz2
busybox-w32-d686a045c8134d3a42fa5cc6b2e09118e08d603f.zip
safe_strtoXX interface proved to be a bit unconvenient.
Remove it, introduce saner bb_strtoXX. Saved ~350 bytes.
Diffstat (limited to 'include/xatonum.h')
-rw-r--r--include/xatonum.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/xatonum.h b/include/xatonum.h
index 46e49b0eb..585d84623 100644
--- a/include/xatonum.h
+++ b/include/xatonum.h
@@ -104,3 +104,54 @@ extern inline uint32_t xatou32(const char *numstr)
104 return xatoul(numstr); 104 return xatoul(numstr);
105 return BUG_xatou32_unimplemented(); 105 return BUG_xatou32_unimplemented();
106} 106}
107
108/* Non-aborting kind of convertors */
109
110unsigned long long bb_strtoull(const char *arg, char **endp, int base);
111long long bb_strtoll(const char *arg, char **endp, int base);
112
113#if ULONG_MAX == ULLONG_MAX
114extern inline
115unsigned long bb_strtoul(const char *arg, char **endp, int base)
116{ return bb_strtoull(arg, endp, base); }
117extern inline
118unsigned long bb_strtol(const char *arg, char **endp, int base)
119{ return bb_strtoll(arg, endp, base); }
120#else
121unsigned long bb_strtoul(const char *arg, char **endp, int base);
122long bb_strtol(const char *arg, char **endp, int base);
123#endif
124
125#if UINT_MAX == ULLONG_MAX
126extern inline
127unsigned long bb_strtou(const char *arg, char **endp, int base)
128{ return bb_strtoull(arg, endp, base); }
129extern inline
130unsigned long bb_strtoi(const char *arg, char **endp, int base)
131{ return bb_strtoll(arg, endp, base); }
132#elif UINT_MAX == ULONG_MAX
133extern inline
134unsigned long bb_strtou(const char *arg, char **endp, int base)
135{ return bb_strtoul(arg, endp, base); }
136extern inline
137unsigned long bb_strtoi(const char *arg, char **endp, int base)
138{ return bb_strtol(arg, endp, base); }
139#else
140unsigned long bb_strtou(const char *arg, char **endp, int base);
141long bb_strtoi(const char *arg, char **endp, int base);
142#endif
143
144int BUG_bb_strtou32_unimplemented(void);
145extern inline
146uint32_t bb_strtou32(const char *arg, char **endp, int base)
147{
148 if (sizeof(uint32_t) == sizeof(unsigned))
149 return bb_strtou(arg, endp, base);
150 if (sizeof(uint32_t) == sizeof(unsigned long))
151 return bb_strtoul(arg, endp, base);
152 return BUG_bb_strtou32_unimplemented();
153}
154
155/* Floating point */
156
157/* double bb_strtod(const char *arg, char **endp); */