-Kanen [fan of newLISP since 2004]
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
nl-filesys.c: In function 'p_spawn':
nl-filesys.c:1498:42: error: 'MAP_ANON' undeclared (first use in this function)
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0)) == (void*)-1)
^
nl-filesys.c:1498:42: note: each undeclared identifier is reported only once for each function it appears in
nl-filesys.c: In function 'p_share':
nl-filesys.c:2152:55: error: 'MAP_ANON' undeclared (first use in this function)
0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0)) == (void*)-1)
^
make[5]: *** [nl-filesys.o] Error 1
make[4]: *** [default] Error 2
make[3]: *** [/Volumes/OpenPipe/build_dir/target-i386_i486_uClibc-0.9.33.2/newlisp-10.6.2/.configured_] Error 2
make[3]: Leaving directory `/Volumes/OpenPipe/package/devel/newlisp'
make[2]: *** [package/devel/newlisp/compile] Error 2
make[2]: Leaving directory `/Volumes/OpenPipe'
make[1]: *** [/Volumes/OpenPipe/staging_dir/target-i386_i486_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/Volumes/OpenPipe'
make: *** [world] Error 2
# makefile for newLISP v.10.x.x on Openwrt LINUX without readline support
# I use upx to compress as hell as I can on newlisp
# Note, that readline support may require different libraries on different OSs
#
OBJS = newlisp.o nl-liststr.o nl-symbol.o pcre.o
nl-debug.o nl-math.o nl-utf8.o unix-lib.o
nl-filesys.o nl-matrix.o nl-web.o win32-path.o
nl-import.o nl-sock.o nl-xml-json.o win32-util.o
nl-list.o nl-string.o pcre-chartables.o win32dll.o
#CFLAGS = -Wall -pedantic -Wno-uninitialized -c -O2 -g -DLINUX
CFLAGS = -Wall -Wl,--gc-sections -ffunction-sections -fdata-sections
-c -Os -fno-threadsafe-statics -DLINUX -I$(TARGET_DIR)/usr/include/
-std=gnu99
LDFLAGS = -L$(TARGET_DIR)/usr/lib/ -W1,--gc-sections -lm -ldl
CC = openwrt-linux-gcc
LD = openwrt-linux-ld
default: $(OBJS)
$(CC) $(OBJS) -o newlisp $(LDFLAGS) #for openwrt
# $(CC) $(OBJS) -g -lm -ldl -lreadline -ltermcap -o newlisp # slackware
# $(CC) $(OBJS) -g -lm -ldl -lreadline -lncurses -o newlisp # other Linux Dist
# $(CC) $(OBJS) -g -lm -ldl -o newlisp # without readline support
$(STRIP) newlisp
upx --best -o newlisp_s newlisp
rm newlisp
mv newlisp_s newlisp
.c.o:
$(CC) $(CFLAGS) $<
$(OBJS): primes.h protos.h pcre.h pcre-config.h
{
"name": false,
"age": 32,
"employed": true,
"address": {
"street": "701 First Ave.",
"city": "Sunnyvale, CA 95125",
"country": "United States"
} }
(setf json_text (read-file "test.json"))
setf json_lisp (json-parse json_text))
; the result below should be (name nil) and not (name false)
(("name" false) ("age" 32) ("employed" true) ("address"
(("street" "701 First Ave.")
("city" "Sunnyvale, CA 95125")
("country" "United States"))) )
(lookup "name" json_lisp)
; false
(nil? (lookup "name" json_lisp))
; nil
In newLISP, nil and true represent both the symbols and the Boolean values false and true. Depending on their context, nil and true are treated differently. The following examples use nil, but they can be applied to true by simply reversing the logic.Quote
Evaluation of nil yields a Boolean false and is treated as such inside flow control expressions such as if, unless, while, until, and not. Likewise, evaluating true yields true.
(setf foo (rand 1000 100000))
(save "foo.lsp" 'foo)
(set 'foo '(477 628 364 513 952 916 635 717 141 606 16 242 137 804 156 400 129 108
998 218 512 839 612 296 637 524 493 972 292 771 526 769 400 891 283 352 807 919
69 949 525 86 192 663 890 348 64 20 457 63 238 970 902 850 266 539 375 760 512
...
(set 'foo '(477 628 364 513 952 916 635 717 141 606 16 242 137 804 156 400 129 108 998 218 512 839 612 296 637 524 493 972 292 771 526 769 400 891 283 352 807 919 69 949 525 86 192 663 890 348 64 20 457 63 238 970 902 850 266 539 375 760 512 ...
(exec "ls")
and also have the result return to a variable, but not display to the screen at runtime.
#!/usr/bin/newlisp
(silent (setf res (exec "ls")))
(println "Exiting")
(exit)
#!/usr/bin/newlisp
(setf tarme (string "zip -r -X /tmp/foo.zip /etc/") )
(silent (exec tarme))
(println "Exiting")
(exit)
(setf big-list '( ((5 0 0 0 3 14 0 1 0 0 1 0 0 0 0 0 0) 1006) ((8 97 108 45 106 105 110 97 110 3 110 101 116 0 0 1 0 1) 1001) ((8 97 49 45 106 105 110 97 110 3 110 101 116 0 0 1 0 1) 1001) ((6 97 114 100 100 114 97 4 104 111 115 116 2 115 107 0 0 1 0 1) 1001) ((3 119 119 119 5 106 111 45 117 102 3 110 101 116 0 0 1 0 1) 1001) ((3 119 119 119 12 106 111 102 112 109 117 121 116 114 118 99 102 3 99 111 109 0 0 1 0 1) 1001) ((71 69 84 32) 1001) ((46 46 47 46 46 47 46 46 47) 232) ((205 128 232 215 255 255 255) 232) ((7 10 0 0 0 75 0 208 0) 286) ((7 0 0 0 0 75 0 208 0) 286) ((0 0 0 0 3 97 112 105 7) 1010) ))
;
(setf small-list '(59 126 1 0 0 1 0 0 0 0 0 0 3 97 112 105 7 116 119 105 116 116 101 114 3 99 111 109 0 0 1 0 1) )
> (last big-list)
((0 0 0 0 3 97 112 105 7) 1010)
(intersect ((last big-list) 0) small-list)
; (0 3 97 112 105 7)
(set (global 'me) '(
(80 (1010 ((84 114 117 115 116 80 105 112 101 73 115 65 119 101 115 111 109 101))) )
(25 (1010 ((84 114 117 115 116 80 105 112 101 73 115 65 119 101 115 111 109 101))) )
))
(assoc 80 me) ; returns all "80" results
(assoc (list 80 1010) me) ; returns all "80" + "1010" results
(last (assoc (list 80 1010) me)) ; returns the list for 80 + 1010
> (setf text_enc (encrypt "My name is Earl." "foobar")
"+ 22O 12 00 31 03O 06 17A7 07 29 03L"))
> (encrypt("My name is Earl.", "foobar")
043022079012000031003079006017065055007029003076
> (unpack (dup "c" (length str)) str)
(43 22 79 12 0 31 3 79 6 17 65 55 7 29 3 76)
(join (map (fn (x) (format "%03d" x)) (unpack (dup "c" (length text_enc)) text_enc)) )
> "043022079012000031003079006017065055007029003076"
> (join (map (fn (x) (pack (dup "c" 3) x)) (explode js_text 3)))
"Ѐ?0? 00 16 0@P`p???"
kanen (~/Code/android-ndk)$ ./ndk-build -C newlisp-ndk/
make: Entering directory `/Users/kanen/Code/android-ndk/newlisp-ndk'
Compile thumb : newlisp <= newlisp.c
Compile thumb : newlisp <= nl-symbol.c
Compile thumb : newlisp <= nl-math.c
Compile thumb : newlisp <= nl-list.c
Compile thumb : newlisp <= nl-liststr.c
Compile thumb : newlisp <= nl-string.c
Compile thumb : newlisp <= nl-sock.c
Compile thumb : newlisp <= nl-import.c
Compile thumb : newlisp <= nl-xml.c
Compile thumb : newlisp <= nl-web.c
Compile thumb : newlisp <= nl-matrix.c
Compile thumb : newlisp <= nl-debug.c
Compile thumb : newlisp <= pcre.c
Compile thumb : newlisp <= nl-filesys.c
Executable : newlisp
Install : newlisp => libs/armeabi/newlisp
make: Leaving directory `/Users/kanen/Code/android-ndk/newlisp-ndk'
kanen (~/Code/android-sdk/tools)$ ./android list targets
Available Android targets:
id: 4 or "Google Inc.:Google APIs:15"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 4.0.3 (API level 15)
ABIs : armeabi-v7a
kanen (~/Code/android-sdk/tools)$ ./android create avd -n MyEmulator -t 4
kanen (~/Code/android-sdk/tools)$ ./emulator -avd MyEmulator
kanen (~/Code/android-sdk/platform-tools)$ ./adb shell
# mkdir /data/nl
# chmod 777 /data/nl
# exit
./adb push ~/Code/android-ndk/newlisp-ndk/libs/armeabi/newlisp /data/nl
kanen (~/Code/android-sdk/platform-tools)$ ./adb shell
# cd /data
# cd nl
# ls
newlisp
# ./newlisp
newLISP v.10.4.5 on Linux IPv4/6, execute 'newlisp -h' for more info.
>
{
"auto_complete": true,
"close_windows_when_empty": false,
"color_scheme": "Packages/Theme - Phoenix/Color Scheme/Tomorrow-Night.tmTheme",
"draw_white_space": "selection",
"find_selected_text": true,
"fold_buttons": true,
"font_face": "Inconsolata",
"font_options": [ "subpixel_antialias" ],
"font_size": 14.0,
"highlight_line": true,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"save_on_focus_lost":true,
"tab_size": 2,
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "_build", "dist", "build", "site"]
}