CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
|
|
@ -0,0 +1,19 @@
|
|||
(load "@lib/gcc.l")
|
||||
|
||||
(gcc "str" NIL # The 'gcc' function passes all text
|
||||
'duptest ) # until /**/ to the C compiler
|
||||
|
||||
any duptest(any ex) {
|
||||
any x = evSym(cdr(ex)); // Accept a symbol (string)
|
||||
char str[bufSize(x)]; // Create a buffer to unpack the name
|
||||
char *s;
|
||||
|
||||
bufString(x, str); // Upack the string
|
||||
s = strdup(str); // Make a duplicate
|
||||
x = mkStr(s); // Build a new Lisp string
|
||||
free(s); // Dispose the duplicate
|
||||
return x;
|
||||
}
|
||||
/**/
|
||||
|
||||
(println 'Duplicate (duptest "Hello world!"))
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
(load "@lib/native.l")
|
||||
|
||||
(gcc "str" NIL
|
||||
(duptest (Str) duptest 'S Str) )
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *duptest(char *str) {
|
||||
static char *s;
|
||||
|
||||
free(s); // We simply dispose the result of the last call
|
||||
return s = strdup(str);
|
||||
}
|
||||
/**/
|
||||
|
||||
(println 'Duplicate (duptest "Hello world!"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue