aboutsummaryrefslogtreecommitdiffhomepage
path: root/wutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'wutil.cpp')
-rw-r--r--wutil.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/wutil.cpp b/wutil.cpp
index f8c0caa1..661c4e93 100644
--- a/wutil.cpp
+++ b/wutil.cpp
@@ -423,3 +423,19 @@ int wrename( const wcstring &old, const wcstring &newv )
cstring new_narrow =wcs2string(newv);
return rename( old_narrow.c_str(), new_narrow.c_str() );
}
+
+int fish_wcstoi(const wchar_t *str, wchar_t ** endptr, int base)
+{
+ long ret = wcstol(str, endptr, base);
+ if (ret > INT_MAX)
+ {
+ ret = INT_MAX;
+ errno = ERANGE;
+ }
+ else if (ret < INT_MIN)
+ {
+ ret = INT_MIN;
+ errno = ERANGE;
+ }
+ return (int)ret;
+}