Skip to content

Commit 3f106bf

Browse files
committed
adding custom *pfe* development files
1 parent 515981b commit 3f106bf

File tree

11 files changed

+367
-0
lines changed

11 files changed

+367
-0
lines changed

.vscode/launch.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "lldb",
9+
"request": "launch",
10+
"name": "lldb launch",
11+
"cwd": "${workspaceFolder}",
12+
"program": "./calc",
13+
"env": {
14+
"DYLD_LIBRARY_PATH": ".",
15+
},
16+
"preRunCommands": [
17+
"command script import .vscode/launch/_env.py .vscode/launch/env.py",
18+
],
19+
"args": ["-Cpf", "custom/pfe-launch.cal"],
20+
},
21+
{
22+
"preLaunchTask": "compiledb make clobber all #DEBUG=… w/ macports readline",
23+
"type": "lldb",
24+
"request": "launch",
25+
"name": "lldb launch + compiledb make clobber all #DEBUG=… w/ macports readline",
26+
"cwd": "${workspaceFolder}",
27+
"program": "./calc",
28+
"env": {
29+
"DYLD_LIBRARY_PATH": ".",
30+
},
31+
"preRunCommands": [
32+
"command script import .vscode/launch/_env.py .vscode/launch/env.py",
33+
],
34+
"args": ["-Cpf", "custom/pfe-launch.cal"],
35+
},
36+
{
37+
"preLaunchTask": "compiledb make clobber all #… w/ macports readline",
38+
"type": "lldb",
39+
"request": "launch",
40+
"name": "lldb launch + compiledb make clobber all #… w/ macports readline",
41+
"cwd": "${workspaceFolder}",
42+
"program": "./calc",
43+
"env": {
44+
"DYLD_LIBRARY_PATH": ".",
45+
},
46+
"preRunCommands": [
47+
"command script import .vscode/launch/_env.py .vscode/launch/env.py",
48+
],
49+
"args": ["-Cpf", "custom/pfe-launch.cal"],
50+
},
51+
]
52+
}

.vscode/launch/.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# customized dotenv format allowing for any space in key to align keys and values but retain any space in values
3+
4+
# general
5+
verbose =1
6+
# specific
7+
wait =1
8+
leaks =0

.vscode/launch/_env.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
3+
os.environ['ENV_PY'] = '.vscode/launch/.env'

.vscode/launch/env.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
import os
3+
import re
4+
import lldb
5+
#from pprint import pprint
6+
7+
class EnvPyFormatException(Exception):
8+
pass
9+
10+
env_array = []
11+
12+
with open(os.path.join(os.environ['ENV_PY'])) as file:
13+
for line in file:
14+
if not re.match("^\s*(#.*)?$" , line):
15+
if m := re.match("^\s*(?P<key>\S+)\s*=(?P<value>.*)$" , line):
16+
env_array.append(m.group('key')+"="+m.group('value'))
17+
else:
18+
raise EnvPyFormatException("Line doesn't match ` `, ` # comment` or ` key =value` where space is optional:"
19+
, line)
20+
21+
target = lldb.debugger.GetSelectedTarget()
22+
23+
launch_info = target.GetLaunchInfo()
24+
launch_info.SetEnvironmentEntries(env_array, True)
25+
target.SetLaunchInfo(launch_info)

.vscode/tasks.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "compiledb make clobber all #… w/ macports readline",
8+
"type": "shell",
9+
"command": "~/Library/Python/3.8/bin/compiledb make clobber all READLINE_INCLUDE=' -I/opt/local/include/readline' READLINE_LIB=' -L/opt/local/lib -l''readline'",
10+
"problemMatcher": ["$gcc"]
11+
},
12+
{
13+
"label": "compiledb make clobber all #DEBUG=… w/ macports readline",
14+
"type": "shell",
15+
"command": "~/Library/Python/3.8/bin/compiledb make clobber all DEBUG='-O0 -g' READLINE_INCLUDE=' -I/opt/local/include/readline' READLINE_LIB=' -L/opt/local/lib -l''readline'",
16+
"problemMatcher": ["$gcc"]
17+
},
18+
]
19+
}

compile_flags.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-DCALC_SRC
2+
-DCUSTOM

custom/pfe+conf.cal

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
; _ = config("resource_debug" ,0)
3+
## ; _ = config("trace" ,2)
4+
; _ = config("tilde" ,0)
5+
; _ = config("display" ,8)
6+
7+
; define inputname ( ) = custom("inputname" )
8+
; define dirname (path ) = custom("dirname",path )
9+
; p = strcat(dirname(inputname()),"/pfe.cal" )
10+
;read $p
11+

custom/pfe-dev.cal

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
##//cspell:ignore strprintf
2+
3+
; _ = config("resource_debug" ,0)
4+
; define inputname ( ) = custom("inputname" )
5+
; define dirname (path ) = custom("dirname",path )
6+
; p = strcat(dirname(inputname()),"/pfe+conf.cal" )
7+
;read $p
8+
9+
; NULL = null()
10+
; TRUE = 1
11+
; FALSE = 0
12+
13+
; err = 2
14+
; out = 1
15+
; in = 0
16+
17+
; LEAKS = eval(getenv("leaks" )||"" )
18+
19+
; WRITE = eval(getenv("write" )||"1" )
20+
; WAIT = eval(getenv("wait" )||"" )
21+
22+
; v = eval(getenv("verbose" )||"" )
23+
24+
; di = pipe() ##// dn in
25+
; uo = pipe() ##// up out
26+
; ue = pipe() ##// up err
27+
28+
;if( pid = fork()){
29+
; e = close ( di[ in ] )
30+
; e = close ( ue[ out ] )
31+
; e = close ( uo[ out ] )
32+
/*
33+
; wtl = list ( di[ out ] )
34+
; s = fds (null(),wtl)
35+
; print "parent wtl bef. wt:":wtl
36+
/**/##end
37+
; if( v) print "parent writing to child"
38+
;if( WRITE
39+
) c = wt ( di[ out ] ,"parent to child")
40+
; e = close ( di[ out ] )
41+
/*
42+
; rcl = list ( uo[ in ]
43+
, ue[ in ] )
44+
; s = fds \
45+
( rcl )
46+
; print "parent rcl aft. wt bef. sleep:":rcl
47+
48+
; s = 1
49+
; sleep ( s)
50+
51+
; rcl = list ( uo[ in ]
52+
, ue[ in ] )
53+
; s = fds \
54+
( rcl )
55+
; print "parent rcl bef. rd:":rcl
56+
/**/##end
57+
; rbl = list ( uo[ in ]
58+
, ue[ in ] ) ##// read base list
59+
; s = -1
60+
;while( rbz = size \
61+
( rbl ) ){
62+
/**/
63+
;if( v && s == -1
64+
) s\
65+
= WAIT
66+
;else if( s){
67+
; if( v) printf( "parent ------ sleep %d; read base size %d\n"
68+
, s
69+
, rbz )
70+
; sleep ( s ) ;}
71+
/**/##end
72+
; rcl\
73+
= rbl ##// read check list
74+
; exl = list ( uo[ in ]
75+
, ue[ in ] )
76+
; if( v) print "parent before select"
77+
(! WAIT
78+
?"" :strprintf ( " waiting %f"
79+
, WAIT/2))
80+
/**/
81+
; fdc\
82+
= fds\
83+
( & rcl,! WAIT
84+
? NULL: WAIT/2)
85+
/*##else
86+
; fdc\
87+
= fds\
88+
( rcl
89+
, NULL
90+
, exl, WAIT)
91+
/**/##end
92+
;if(0 < fdc ){
93+
; rcz = size \
94+
( rcl ) ;
95+
; if( v) print "parent select read size"\
96+
: ":" rcz ;
97+
;for( rcs = 0
98+
; rcs
99+
< rcz
100+
; rcs++){
101+
; if( v) print "parent select read "\
102+
: rcs \
103+
:":" \
104+
: rcl \
105+
[ rcs] ;
106+
; rcd = rd \
107+
( rcl
108+
[ rcs])
109+
;if( rcl
110+
[ rcs]
111+
== uo[ in ]
112+
)if( rcd!=NULL) print ##"out:\n"
113+
: rcd:
114+
else{ delete \
115+
( rbl
116+
, search
117+
(rbl, uo[ in ]))
118+
; if( v) print "parent read eof - child out"
119+
;}
120+
;if( rcl
121+
[ rcs]
122+
== ue[ in ]
123+
)if( rcd!=NULL) print ##"err:\n"
124+
: rcd:
125+
else{ delete \
126+
( rbl
127+
, search
128+
(rbl, ue[ in ]))
129+
; if( v) print "parent read eof - child err"
130+
;}
131+
;}
132+
/*
133+
; exz = size \
134+
( exl ) ;
135+
; print "parent select exception size"\
136+
: ":" exz ;
137+
;for( exs = 0
138+
; exs
139+
< exz
140+
; exs++){
141+
; print "parent select exception "\
142+
: exs \
143+
:":" \
144+
: exl \
145+
[ exs] ;
146+
;}
147+
/**/##end
148+
;}
149+
;}
150+
; stt = assoc()
151+
; w = wait4(pid,& stt)
152+
;if( v && stt["exited" ] ){
153+
; print "parent: child exited with status"
154+
:" ": stt["exitstatus"];}
155+
;if( v && stt["signaled" ] ){
156+
; print "parent: child signaled by "
157+
: stt["termsig" ]
158+
: ( stt["coredump" ]
159+
? " (with dump)"
160+
: " (no dump)" ) ;}
161+
;if( v && stt["stopped" ] ){
162+
; print "parent: child stopped by "
163+
: stt["stopsig" ] ;}
164+
;print "stt" \
165+
: (! stt["exited" ]
166+
?0: stt["exitstatus"] )
167+
+ (! stt["stopped" ]
168+
?0: 127+stt["stopsig" ] )
169+
+ (! stt["signaled" ]
170+
?0: 127+stt["termsig" ] )
171+
;}\
172+
else{
173+
; e = close ( uo[ in ] )
174+
; e = close ( ue[ in ] )
175+
; e = close ( di[ out ] )
176+
177+
; scpt\
178+
= strprintf("read; echo \"outA:$REPLY\"; echo 'errA' >&2;%s echo 'outZ'; exec >&-; echo 'errZ' >&2; exec 2>&-;exit 2"
179+
, ! WAIT ? "" : strprintf(" sleep %d;"
180+
, floor ( WAIT*2.5) ))
181+
; if( v) print scpt
182+
183+
; args = list\
184+
( "bash"
185+
, "-c")
186+
; append ( args, scpt)
187+
188+
; d = dup2 ( di[ in ]
189+
, in )
190+
; d = dup2 ( uo[ out ]
191+
, out )
192+
; d = dup2 ( ue[ out ]
193+
, err )
194+
195+
; e = execvp ( args[0]
196+
, args)
197+
198+
;}
199+
200+
;if( LEAKS ){
201+
; print getpid()
202+
; rd ( in )
203+
;}

custom/pfe-launch.cal

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; null( config("resource_debug" ,0))
2+
; define inputname ( ) = custom("inputname" )
3+
; define dirname (path ) = custom("dirname",path )
4+
; p = strcat(dirname(inputname()),"/pfe+conf.cal" )
5+
;read $p
6+
7+
;pfe_test()
8+

custom/pfe-v.cal

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; null( config("resource_debug" ,0));
2+
; define inputname ( ) = custom("inputname" )
3+
; define dirname (path ) = custom("dirname",path )
4+
; p = strcat(dirname(inputname()),"/pfe+conf.cal" )
5+
;read $p
6+
7+
##// executing personal file with `#!/usr/bin/env bash` in dirs under PATH; vbash cause-of vscode fails to retrieve env (for PATH)
8+
;define vbhu(a1,a2,a3,a4,a5){local i,o,e,z,s,args=list("/Users/vike/shell/library/script/system/vbash","vbhu",a1,a2,a3,a4,a5);for(z=size(args),s=0;s<z;s++){local a=args[s];if(!isstr(args[s]))args[s]=strprintf("%d",args[s])};if(local child=pfe(&i,&o,&e,args)){print "i:":i, "o:":o, "e:":e;close(i);local r=pread(child,o,e);if(r[2]){print r[2]:;abort}else return eval( r[1]) }}
9+
;define vbuh(a1,a2,a3,a4,a5){local i,o,e,z,s,args=list("/Users/vike/shell/library/script/system/vbash","vbuh",a1,a2,a3,a4,a5);for(z=size(args),s=0;s<z;s++){local a=args[s];if(!isstr(args[s]))args[s]=strprintf("%d",args[s])};if(local child=pfe(&i,&o,&e,args)){print "i:":i, "o:":o, "e:":e;close(i);local r=pread(child,o,e);if(r[2]){print r[2]:;abort}else return r[1] }}
10+
11+
;print vbuh(vbhu("10m")) ##// 10m expected
12+

0 commit comments

Comments
 (0)