Commit graph

1014 commits

Author SHA1 Message Date
Justine Tunney
9877c04fac Fix MODE=tiny build 2022-07-11 06:11:39 -07:00
Justine Tunney
3f015b1e51 Make some minor fixups to bug reporting, etc. 2022-07-11 05:58:24 -07:00
ProducerMatt
84764ce7b8
lre_test.lua: Benchmark() fails on some systems (#474) 2022-07-10 23:05:50 -07:00
Justine Tunney
68ca49bfdd Improve APE install scripts and add uninstaller
See #350 thanks @tkchia
2022-07-10 14:13:45 -07:00
Justine Tunney
331fdd1d29 Fix some broken builds and broken hearts 2022-07-10 09:08:38 -07:00
Gautham
c0b325bafa
Add json.org tests for DecodeJson (#473) 2022-07-10 08:35:51 -07:00
Justine Tunney
5fa77f1e8f Make _Thread_local more seamlessly working 2022-07-10 08:27:50 -07:00
Justine Tunney
5f4f6b0e69 Make _Thread_local work across platforms
We now rewrite the binary image at runtime on Windows and XNU to change
mov %fs:0,%reg instructions to use %gs instead. There's also simpler
threading API introduced by this change and it's called _spawn() and
_join(), which has replaced most clone() usage.
2022-07-10 04:01:17 -07:00
Justine Tunney
e4d6e263d4 Rename ParseJson() to DecodeJson() for consistency 2022-07-09 17:34:41 -07:00
Justine Tunney
28f0104330 Bump redbean up to 2.0.10 2022-07-09 17:28:14 -07:00
William Chargin
4a1419fefa
ttyraster: restore colors at start of each line (#471)
The patch in #469 was buggy for images where the start of a row matched
the end of the previous row. We don't re-issue the `setbgfg` ANSI codes
when we think that the color hasn't changed. But by sending an `\e[0m`
sequence at the end of the line without updating `bg` or `fg`, we
desynced `bg` and `fg` from the actual ANSI state. Now, we simply follow
that line-terminating `\e[0m` with another `setbgfg` call.

This bug was visible in images with a constant-color matte border:

![Screenshot of `printimage` output before and after this commit when
run on `lemurs.png` and `lemursborder.png`, where `lemursborder.png` has
a thick blue border around the outside of the image. Both versions look
fine for `lemurs.png`. For `lemursborder.png`, the "before" version has
a chess board pattern for the left border (except for the first row) and
the bottom border. The "after" version looks correct.][ss]

[ss]: https://user-images.githubusercontent.com/4317806/178120511-c1b89348-2376-4bf2-a2d3-8723d2663bd4.png

Fixes: 85aecbda67 ("ttyraster: reset ANSI attributes after each line (#469)")
wchargin-branch: ttyraster-restore-each-line
wchargin-source: 621a788cfa0a87ce360e142a6004e325cca70caa
2022-07-09 16:47:42 -07:00
Justine Tunney
ee82cee432 Further improve json / lua serialization 2022-07-09 16:27:26 -07:00
Paul Kulchenko
9e86980191
Redbean fix listen leak (#470)
* Fix release of resources allocated to skipped sockets
* Update log messages for consistency
2022-07-09 12:16:44 -07:00
Justine Tunney
7756e27993 Fix GitHub build 2022-07-09 12:00:57 -07:00
Justine Tunney
2189877856 Implement new JSON parser for redbean 2022-07-09 11:44:19 -07:00
Justine Tunney
d37536bd4b Fix oops w/ array serialization ordering 2022-07-09 10:29:26 -07:00
Justine Tunney
727d9cbf56 Bump redbean to 2.0.9 2022-07-09 05:50:05 -07:00
Justine Tunney
896db8843f Loosen restriction on valid hostnames
This changes fixes an issue with GitPod integration, where large numbers
in a hostname were incorrectly causing redbean to refuse a request.
2022-07-09 04:26:29 -07:00
Justine Tunney
c9e68b0ebc Make redbean serialization deterministic 2022-07-09 04:09:51 -07:00
William Chargin
85aecbda67
ttyraster: reset ANSI attributes after each line (#469) 2022-07-09 01:38:35 -07:00
William Chargin
a9145e7f1e
printimage: keep aspect ratio with -w xor -h (#468) 2022-07-09 01:38:13 -07:00
Justine Tunney
182d7720cf Fix GitHub actions
Our build was flaking due to ETXTBSY errors running multiple redbean
instances in parallel. This is due to the StoreAsset() support which
seems to cause enough problems it's worth making a *breaking change*
turning it off by default for now. There's a new -* flag, to restore
redbean's old self-modifying behavior.
2022-07-09 01:18:55 -07:00
Justine Tunney
1c83670229 Write more redbean unit tests
- Fix DescribeSigset()
- Introduce new unix.rmrf() API
- Fix redbean sigaction() doc example code
- Fix unix.sigaction() w/ more than two args
- Improve redbean re module API (non-breaking)
- Enhance Lua with Python string multiplication
- Make third parameter of unix.socket() default to 0
2022-07-08 23:10:02 -07:00
Justine Tunney
c5b9902ac9 Add ansi terminal audio prototype
It's never worked very well having nesemu1.com and printvideo.com
spawning an ffmpeg or sox subprocess and streaming audio samples via
pipes. Since these programs don't work very well for that purpose, and
if you're SSH'ing into the cloud, the speaker could be very far away.

This change is part of an experiment to instead patch desktop terminals
such as PuTTY, KiTTY, gnome-terminal, etc. to support receiving inband
audio samples as ANSI code, and then playing them on the speakers of the
local machine that's being used. This way we can use printf() as a cross
platform audio playback library.
2022-07-08 15:11:46 -07:00
Justine Tunney
50a6df89b8 Fix Lua type of zero
This change fixes a regression from 281a0f27 which resulted in the
integer literal `0` being interpreted as a floating point number. This
should also fix a reported issue with Fennel integration.
2022-07-08 10:12:19 -07:00
Justine Tunney
fe5c475f83 Add Deflate() / Inflate() to redbean and fix bugs
The Compress() and Uncompress() APIs were a mistake. The functions
themselves work fine, but it's a design blemish and does superfluous
work. Since they were only introduced in the last few weeks, they're now
deprecated and references to them have been scrubbed from the website
and other documentation. Please use the new APIs since the old APIs will
be removed at some point in the future.

This change introduces automated Lua unit tests for the Redbean APIs.
There's a few functions that were broken which have now been fixed, e.g.
Underlong() and Decimate().
2022-07-08 09:47:04 -07:00
Paul Kulchenko
a18044c504
Add OnServerListen hook to configure listen() (#459) 2022-07-08 07:17:25 -07:00
Paul Kulchenko
11ac8f11a9
Reduce redbean logging for EBADF (#461)
This may happen on explicitly closed client connections, so reduce the
logging level similar to other errors.
2022-07-08 07:14:50 -07:00
Paul Kulchenko
059fe22ea3
Improve redbean fetch() (#460)
* Updated Fetch to return `nil,error` on errors
* Fix localhost connect when only IP address is specified
2022-07-08 07:13:51 -07:00
Justine Tunney
853b6c3864 Improve system calls
- Wrap clock_getres()
- Wrap sched_setscheduler()
- Make sleep() api conformant
- Polyfill sleep() using select()
- Improve clock_gettime() polyfill
- Make nanosleep() POSIX conformant
- Slightly improve some DNS functions
- Further strengthen pledge() sandboxing
- Improve rounding of timeval / timespec
- Allow layering of pledge() calls on Linux
- Polyfill sched_yield() using select() on XNU
- Delete more system constants we probably don't need
2022-07-08 06:42:03 -07:00
Paul Kulchenko
5df3e4e7a8
Redbean zip and unix.poll doc update (#457) 2022-06-30 17:41:51 -07:00
Joseph Stewart
2eebb198a9
Add antirez picol (tiny Tcl clone) (#340) 2022-06-29 08:52:22 -07:00
Daniil Kulchenko
9f8e6c10dd
Work around Rosetta clobbering startup registers on M1 Macs (issue #429) (#453)
Rosetta doesn't correctly respect the startup registers as defined in LC_UNIXTHREAD
which makes platform detection go awry. But at least Rosetta appears to consistently
set rbx to 0x00000000ffffffff and rdx to 0x0000000000000001 at startup for every
x64 executable I could get my hands on. So we use that to detect Rosetta's presence
and set up the correct registers for XNU.
2022-06-27 16:28:59 -07:00
Justine Tunney
5297897ba1 Add fixups for previous change 2022-06-27 15:00:51 -07:00
Justine Tunney
3c92adfd6e Strengthen the pledge() polyfill 2022-06-27 13:02:17 -07:00
Gautham
a6f65eea7c
Scan fixed-width integers in vcscanf (#424)
When a format string like %2x is provided, the width parameter was read
correctly as 2, but it was not used when decoding the number from the
input string (ie instead of reading 2 characters from the input string,
vcscanf read all the characters).

This change uses the value of width within the number decoding loop to
read fixed number of digits correctly. if width is zero (not provided),
the default of width is set as bits.

Fixes #423
2022-06-26 21:27:07 -07:00
Paul Kulchenko
32eec7df4c
Update FATALF to exit without stack trace (#452) 2022-06-26 21:25:02 -07:00
Paul Kulchenko
283729dfe0
Redbean report write lock failure (#450)
This change updates redbean to report a non-writable path
when using StoreAsset, instead of crashing the worker.
2022-06-26 21:16:13 -07:00
Paul Kulchenko
b4e9a77e74
Improve redbean ZeroBrane integration (#451) 2022-06-26 21:13:53 -07:00
Justine Tunney
f6dab99f44 Release redbean 2.0.8 2022-06-26 17:25:54 -07:00
Gautham
b535937fca
Add sys.meta_path entry for APE zip store (#425) 2022-06-26 05:51:00 -07:00
Justine Tunney
893cc06fc2 Fix libunwind stubs 2022-06-26 05:29:25 -07:00
Justine Tunney
5cd0e876bd Scrub double-conversion and add quick wrapper 2022-06-26 05:03:25 -07:00
Gautham
b1de862e16
Add double-conversion to third_party (#447) 2022-06-26 03:41:55 -07:00
Justine Tunney
2f515ac5e3 Fix code completion bug in Lua REPL 2022-06-26 03:11:56 -07:00
Justine Tunney
61257d48d4 Make some quick fixes and cleanup 2022-06-26 02:58:36 -07:00
Theta Nil
fa5c2a24b5
Add tiny / opt to CI matrix (#448) 2022-06-25 22:08:41 -07:00
Justine Tunney
fbc053e018 Make fixes and improvements
- Introduce __assert_disable global
- Improve strsignal() thread safety
- Make system call tracing thread safe
- Fix SO_RCVTIMEO / SO_SNDTIMEO on Windows
- Refactor DescribeFoo() functions into one place
- Fix fork() on Windows when TLS and MAP_STACK exist
- Round upwards in setsockopt(SO_RCVTIMEO) on Windows
- Disable futexes on OpenBSD which seem extremely broken
- Implement a better kludge for monotonic time on Windows
2022-06-25 21:09:09 -07:00
Gautham
5d837c4e7c
Add complex math from musl (#422) 2022-06-23 18:56:10 -07:00
Paul Kulchenko
1bce1ca2e0
Polish redbean APIs and docs (#446)
* Remove undocumented ProgramSslCompression
* Rename GetLastModified to GetAssetLastModified
* Rename IsCompressed to IsAssetCompressed
* Reorganize currently deprecated functions
* Update sockopt documentation for clarity
2022-06-23 18:54:35 -07:00