v0.3.3: is lib word, UTF–8 string support
This commit is contained in:
@@ -533,19 +533,3 @@ func NewClyx(libfname string, libCode string) *Clyx {
|
|||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunFile(filePath string, libCode string) {
|
|
||||||
content, err := os.ReadFile(filePath)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "Error executing %s: %v\n", filePath, err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil { fmt.Fprintf(os.Stderr, "Error executing %s: %v\n", filePath, r); os.Exit(1) }
|
|
||||||
}()
|
|
||||||
c := NewClyx("", libCode)
|
|
||||||
c.Run(string(content))
|
|
||||||
if c.HasWord("_main") {
|
|
||||||
c.Run("_main")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,10 @@ replpath = _fpath(f'{scriptdir}/clyx_repl.clx', f'{scriptdir}/../../clyx_repl.cl
|
|||||||
|
|
||||||
class Sock:
|
class Sock:
|
||||||
def __init__(self, s): self.s = s
|
def __init__(self, s): self.s = s
|
||||||
def write(self, d):
|
|
||||||
data = d.encode('utf-8') if isinstance(d, str) else d
|
|
||||||
return self.s.write(data) if hasattr(self.s, 'write') else self.send(data)
|
|
||||||
def send(self, d):
|
def send(self, d):
|
||||||
data = d.encode('utf-8') if isinstance(d, str) else d
|
data = d.encode('utf-8') if isinstance(d, str) else d
|
||||||
return self.s.send(data) if hasattr(self.s, 'send') else getattr(self.s, 'write', lambda *a: 0)(data)
|
return self.s.send(data) if hasattr(self.s, 'send') else getattr(self.s, 'write', lambda *a: 0)(data)
|
||||||
|
def write(self, d): return self.send(d)
|
||||||
def recv(self, n):
|
def recv(self, n):
|
||||||
b = bytearray(n); return bytes(b[:self.s.recv_into(b)]) if hasattr(self.s, 'recv_into') else getattr(self.s, 'read', lambda *a: b'')(n)
|
b = bytearray(n); return bytes(b[:self.s.recv_into(b)]) if hasattr(self.s, 'recv_into') else getattr(self.s, 'read', lambda *a: b'')(n)
|
||||||
def readline(self):
|
def readline(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user