Code: Select all
(import "msvcrt" "printf" "cdecl")
(set 'cprintf (fcall printf c_int c_void_p c_int))
(cprintf "The answer is %i" 42)
(exit 0)
Code: Select all
(import "msvcrt" "printf" "cdecl")
(set 'cprintf (fcall printf c_int c_void_p c_int))
(cprintf "The answer is %i" 42)
(exit 0)
Code: Select all
(import "msvcrt.dll" "log10")
log10<77C4D060>
; define a fcall object return type is double, takes one double as parameter
(set 'clog10 (fcall log10 c_double c_double))
log10<77C4D060>
(clog10 1000)
3
(number? (clog10 1000))
true
(format "%.2f" (clog10 1000))
"3.00"
(format "%.8f" (clog10 3.1415926))
"0.49714987"
Code: Select all
CELL * p_makeDir(CELL * params)
{
char * dirString;
UINT mode;
mode = 0777; /* drwxrwxrwx gets user masked to drwxr-xr-x on most UNIX */
/* consume param regardless of OS */
params = getString(params, &dirString);
if(params != nilCell)
{
getInteger(params, &mode);
}
#ifdef WIN_32
return(mkdir(dirString) == 0 ? trueCell : nilCell);
#else
return(mkdir(dirString, (mode_t)mode) == 0 ? trueCell : nilCell);
#endif
}
Code: Select all
--- ../newlisp-10.3.6/nl-filesys.c 2011-11-18 20:05:00 +0100
+++ nl-filesys.c 2011-11-22 21:15:50 +0100
@@ -771,17 +771,17 @@
CELL * p_makeDir(CELL * params)
{
char * dirString;
-mode_t mode;
-UINT inMode;
+UINT mode;
+mode = 0777; /* drwxrwxrwx gets user masked to drwxr-xr-x on most UNIX */
+
+/* consume param regardless of OS */
params = getString(params, &dirString);
+
if(params != nilCell)
{
- getInteger(params, &inMode);
- mode = inMode;
+ getInteger(params, &mode);
}
-else
- mode = 0777; /* drwxrwxrwx gets user masked to drwxr-xr-x on most UNIX */
#ifdef WIN_32
return(mkdir(dirString) == 0 ? trueCell : nilCell);
Code: Select all
...
getInteger(params, &mode);
mode = mode > 0xfff ? 0xfff : mode;
...
Code: Select all
(import "msvcrt" "sprintf")
(set 'res (dup " " 50))
(set 'csprintf (fcall sprintf c_int c_string c_string c_int c_double))
(set 'PI 3.1415926)
(println (csprintf res "the answer is always %i, or %.8f" 42 PI))
(println res)
(exit 0)
Code: Select all
newlisp.exe fsprintf.lsp
38
the answer is always 42, or 3.14159260