libc: Fix strerror for unix.
							parent
							
								
									df452dfb91
								
							
						
					
					
						commit
						dbba9f931b
					
				| 
						 | 
				
			
			@ -9,6 +9,10 @@ IN: libc
 | 
			
		|||
 | 
			
		||||
HOOK: strerror os ( errno -- str )
 | 
			
		||||
 | 
			
		||||
! For strerror on Unix all platforms
 | 
			
		||||
<< os windows? [ "libc.unix" require ] unless >>
 | 
			
		||||
 | 
			
		||||
! For libc.linux, libc.windows, libc.macosx...
 | 
			
		||||
<< "libc." os unparse append require >>
 | 
			
		||||
 | 
			
		||||
LIBRARY: factor
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Doug Coleman
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
unix
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
! Copyright (C) 2014 Doug Coleman.
 | 
			
		||||
! See http://factorcode.org/license.txt for BSD license.
 | 
			
		||||
USING: alien.strings destructors kernel libc system ;
 | 
			
		||||
IN: libc.unix
 | 
			
		||||
 | 
			
		||||
M: unix strerror ( errno -- str )
 | 
			
		||||
    [
 | 
			
		||||
        1024 [ malloc &free ] keep [ strerror_r ] 2keep drop nip
 | 
			
		||||
        alien>native-string
 | 
			
		||||
    ] with-destructors ;
 | 
			
		||||
		Loading…
	
		Reference in New Issue