lib/standard: Added errno and strerror bindings to stdlib.
[nit.git] / lib / standard / string.nit
index 29a25ff..2ba5772 100644 (file)
@@ -19,6 +19,7 @@ intrude import collection # FIXME should be collection::array
 
 `{
 #include <stdio.h>
+#include <string.h>
 `}
 
 ###############################################################################
@@ -1341,6 +1342,15 @@ redef class Bool
 end
 
 redef class Int
+
+       # Wrapper of strerror C function
+       private fun strerror_ext: NativeString is extern `{
+               return strerror(recv);
+       `}
+
+       # Returns a string describing error number
+       fun strerror: String do return strerror_ext.to_s
+
        # Fill `s` with the digits in base `base` of `self` (and with the '-' sign if 'signed' and negative).
        # assume < to_c max const of char
        fun fill_buffer(s: Buffer, base: Int, signed: Bool)