The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=2bc180ef045e5911cce0cea1c2a139cffd2b577a
commit 2bc180ef045e5911cce0cea1c2a139cffd2b577a Merge: 0f5c86ddb025 95286bbb7907 Author: Baptiste Daroussin <b...@freebsd.org> AuthorDate: 2025-06-26 07:12:41 +0000 Commit: Baptiste Daroussin <b...@freebsd.org> CommitDate: 2025-06-26 07:15:08 +0000 lyaml: vendor import lua bindings for libyaml contrib/lyaml/.gitignore | 9 + contrib/lyaml/.luacov | 8 + contrib/lyaml/AUTHORS | 6 + contrib/lyaml/LICENSE | 27 + contrib/lyaml/NEWS.md | 352 ++++++++++++ contrib/lyaml/README.md | 232 ++++++++ contrib/lyaml/build-aux/config.ld.in | 34 ++ contrib/lyaml/build-aux/luke | 672 ++++++++++++++++++++++ contrib/lyaml/doc/index.html | 97 ++++ contrib/lyaml/doc/ldoc.css | 303 ++++++++++ contrib/lyaml/doc/modules/lyaml.explicit.html | 267 +++++++++ contrib/lyaml/doc/modules/lyaml.functional.html | 236 ++++++++ contrib/lyaml/doc/modules/lyaml.html | 224 ++++++++ contrib/lyaml/doc/modules/lyaml.implicit.html | 533 +++++++++++++++++ contrib/lyaml/ext/yaml/emitter.c | 459 +++++++++++++++ contrib/lyaml/ext/yaml/lyaml.h | 161 ++++++ contrib/lyaml/ext/yaml/parser.c | 410 +++++++++++++ contrib/lyaml/ext/yaml/scanner.c | 340 +++++++++++ contrib/lyaml/ext/yaml/yaml.c | 66 +++ contrib/lyaml/lib/lyaml/explicit.lua | 120 ++++ contrib/lyaml/lib/lyaml/functional.lua | 87 +++ contrib/lyaml/lib/lyaml/implicit.lua | 283 +++++++++ contrib/lyaml/lib/lyaml/init.lua | 534 +++++++++++++++++ contrib/lyaml/lukefile | 47 ++ contrib/lyaml/lyaml-6.2.8-1.rockspec | 59 ++ contrib/lyaml/spec/ext_yaml_emitter_spec.yaml | 239 ++++++++ contrib/lyaml/spec/ext_yaml_parser_spec.yaml | 391 +++++++++++++ contrib/lyaml/spec/ext_yaml_scanner_spec.yaml | 380 ++++++++++++ contrib/lyaml/spec/lib_lyaml_functional_spec.yaml | 121 ++++ contrib/lyaml/spec/lib_lyaml_spec.yaml | 343 +++++++++++ contrib/lyaml/spec/spec_helper.lua | 277 +++++++++ libexec/flua/Makefile | 1 + libexec/flua/liblyaml/Makefile | 22 + 33 files changed, 7340 insertions(+) diff --cc contrib/lyaml/.gitignore index 000000000000,000000000000..19d7cbb6dd7d new file mode 100644 --- /dev/null +++ b/contrib/lyaml/.gitignore @@@ -1,0 -1,0 +1,9 @@@ ++*~ ++*.o ++*.so ++*.src.rock ++/ChangeLog ++/build-aux/config.ld ++/luacov.*.out ++/lyaml-*.tar.gz ++/TAGS diff --cc contrib/lyaml/.luacov index 000000000000,0aa52d25e0ea..0aa52d25e0ea mode 000000,100644..100644 --- a/contrib/lyaml/.luacov +++ b/contrib/lyaml/.luacov diff --cc contrib/lyaml/AUTHORS index 000000000000,1eb673371bf7..1eb673371bf7 mode 000000,100644..100644 --- a/contrib/lyaml/AUTHORS +++ b/contrib/lyaml/AUTHORS diff --cc contrib/lyaml/LICENSE index 000000000000,402e64dfec29..402e64dfec29 mode 000000,100644..100644 --- a/contrib/lyaml/LICENSE +++ b/contrib/lyaml/LICENSE diff --cc contrib/lyaml/NEWS.md index 000000000000,32611d83671a..32611d83671a mode 000000,100644..100644 --- a/contrib/lyaml/NEWS.md +++ b/contrib/lyaml/NEWS.md diff --cc contrib/lyaml/README.md index 000000000000,000000000000..d1e96845ddfa new file mode 100644 --- /dev/null +++ b/contrib/lyaml/README.md @@@ -1,0 -1,0 +1,232 @@@ ++LYAML ++===== ++ ++Copyright (C) 2013-2022 Gary V. Vaughan ++ ++[](https://mit-license.org) ++[](https://github.com/gvvaughan/lyaml/actions) ++[](https://codecov.io/github/gvvaughan/lyaml?branch=release-v6.2.8) ++ ++[LibYAML] binding for [Lua], with a fast C implementation ++for converting between [%YAML 1.1][yaml11] and [Lua] tables, ++and a low-level [YAML] event parser for implementing more ++intricate [YAML] document loading. ++ ++Usage ++----- ++ ++### High Level API ++ ++These functions quickly convert back and forth between Lua tables ++and [%YAML 1.1][yaml11] format strings. ++ ++```lua ++local lyaml = require "lyaml" ++local t = lyaml.load (YAML-STRING, [OPTS-TABLE]) ++local yamlstr = lyaml.dump (LUA-TABLE, [OPTS-TABLE]) ++local null = lyaml.null () ++``` ++ ++#### `lyaml.load` ++ ++`lyaml.load` accepts a YAML string for parsing. If the YAML string contains ++multiple documents, only the first document will be returned by default. To ++return multiple documents as a table, set `all = true` in the second ++argument OPTS-TABLE. ++ ++```lua ++lyaml.load("foo: bar") ++--> { foo = "bar" } ++ ++lyaml.load("foo: bar", { all = true }) ++--> { { foo = "bar" } } ++ ++multi_doc_yaml = [[ ++--- ++one ++... ++--- ++two ++... ++]] ++ ++lyaml.load(multi_doc_yaml) ++--> "one" ++ ++lyaml.load(multi_doc_yaml, { all = true }) ++--> { "one", "two" } ++``` ++ ++You can supply an alternative function for converting implicit plain ++scalar values in the `implicit_scalar` field of the OPTS-TABLE argument; ++otherwise a default is composed from the functions in the `lyaml.implicit` ++module. ++ ++You can also supply an alternative table for coverting explicitly tagged ++scalar values in the `explicit_scalar` field of the OPTS-TABLE argument; ++otherwise all supported tags are parsed by default using the functions ++from the `lyaml.explicit` module. ++ ++#### `lyaml.dump` ++ ++`lyaml.dump` accepts a table of values to dump. Each value in the table ++represents a single YAML document. To dump a table of lua values this means ++the table must be wrapped in another table (the outer table represents the ++YAML documents, the inner table is the single document table to dump). ++ ++```lua ++lyaml.dump({ { foo = "bar" } }) ++--> --- ++--> foo: bar ++--> ... ++ ++lyaml.dump({ "one", "two" }) ++--> --- one ++--> ... ++--> --- two ++--> ... ++``` ++ ++If you need to round-trip load a dumped document, and you used a custom ++function for converting implicit scalars, then you should pass that same ++function in the `implicit_scalar` field of the OPTS-TABLE argument to ++`lyaml.dump` so that it can quote strings that might otherwise be ++implicitly converted on reload. ++ ++#### Nil Values ++ ++[Lua] tables treat `nil` valued keys as if they were not there, ++where [YAML] explicitly supports `null` values (and keys!). Lyaml ++will retain [YAML] `null` values as `lyaml.null ()` by default, ++though it is straight forward to wrap the low level APIs to use `nil`, ++subject to the usual caveats of how nil values work in [Lua] tables. ++ ++ ++### Low Level APIs ++ ++```lua ++local emitter = require ("yaml").emitter () ++ ++emitter.emit {type = "STREAM_START"} ++for _, event in ipairs (event_list) do ++ emitter.emit (event) ++end ++str = emitter.emit {type = "STREAM_END"} ++``` ++ ++The `yaml.emitter` function returns an emitter object that has a ++single emit function, which you call with event tables, the last ++`STREAM_END` event returns a string formatted as a [YAML 1.1][yaml11] ++document. ++ ++```lua ++local iter = require ("yaml").scanner (YAML-STRING) ++ ++for token_table in iter () do ++ -- process token table ++end ++``` ++ ++Each time the iterator returned by `scanner` is called, it returns ++a table describing the next token of YAML-STRING. See LibYAML's ++[yaml.h] for details of the contents and semantics of the various ++tokens produced by `yaml_parser_scan`, the underlying call made by ++the iterator. ++ ++[LibYAML] implements a fast parser in C using `yaml_parser_scan`, which ++is also bound to lyaml, and easier to use than the token API above: ++ ++```lua ++local iter = require ("yaml").parser (YAML-STRING) ++ ++for event_table in iter () do ++ -- process event table ++end ++``` ++ ++Each time the iterator returned by `parser` is called, it returns ++a table describing the next event from the "Parse" process of the ++"Parse, Compose, Construct" processing model described in the ++[YAML 1.1][yaml11] specification using [LibYAML]. ++ ++Implementing the remaining "Compose" and "Construct" processes in ++[Lua] is left as an exercise for the reader -- though, unlike the ++high-level API, `lyaml.parser` exposes all details of the input ++stream events, such as line and column numbers. ++ ++ ++Installation ++------------ ++ ++There's no need to download an [lyaml] release, or clone the git repo, ++unless you want to modify the code. If you use [LuaRocks], you can ++use it to install the latest release from its repository: ++ ++ luarocks --server=http://rocks.moonscript.org install lyaml ++ ++Or from the rockspec in a release tarball: ++ ++ luarocks make lyaml-?-1.rockspec ++ ++To install current git master from [GitHub][lyaml] (for testing): ++ ++ luarocks install http://raw.github.com/gvvaughan/lyaml/master/lyaml-git-1.rockspec ++ ++To install without [LuaRocks], clone the sources from the ++[repository][lyaml], and then run the following commands: ++ ++```sh ++cd lyaml ++build-aux/luke LYAML_DIR=LIBYAML-INSTALL-PREFIX ++sudo build-aux/luke PREFIX=LYAML-INSTALL-PREFIX install ++specl -v1freport spec/*_spec.yaml ++``` ++ ++The dependencies are listed in the dependencies entry of the file ++[rockspec][L15]. ++ ++ ++Bug reports and code contributions ++---------------------------------- ++ ++This library is maintained by its users. ++ ++Please make bug reports and suggestions as [GitHub Issues][issues]. ++Pull requests are especially appreciated. ++ ++But first, please check that your issue has not already been reported by ++someone else, and that it is not already fixed by [master][lyaml] in ++preparation for the next release (see Installation section above for how ++to temporarily install master with [LuaRocks][]). ++ ++There is no strict coding style, but please bear in mind the following ++points when proposing changes: ++ ++0. Follow existing code. There are a lot of useful patterns and avoided ++ traps there. ++ ++1. 3-character indentation using SPACES in Lua sources: It makes rogue ++ TABs easier to see, and lines up nicely with 'if' and 'end' keywords. ++ ++2. Simple strings are easiest to type using single-quote delimiters, ++ saving double-quotes for where a string contains apostrophes. ++ ++3. Save horizontal space by only using SPACEs where the parser requires ++ them. ++ ++4. Use vertical space to separate out compound statements to help the ++ coverage reports discover untested lines. ++ ++5. Prefer explicit string function calls over object methods, to mitigate ++ issues with monkey-patching in caller environment. ++ ++ ++[issues]: http://github.com/gvvaughas/lyaml/issues ++[libyaml]: http://pyyaml.org/wiki/LibYAML ++[lua]: http://www.lua.org ++[luarocks]: http://www.luarocks.org ++[lyaml]: http://github.com/gvvaughan/lyaml ++[L15]: http://github.com/gvvaughan/lyaml/blob/master/lyaml-git-1.rockspec#L15 ++[yaml.h]: http://pyyaml.org/browser/libyaml/branches/stable/include/yaml.h ++[yaml]: http://yaml.org ++[yaml11]: http://yaml.org/spec/1.1/ diff --cc contrib/lyaml/build-aux/config.ld.in index 000000000000,0d55b9e94c30..0d55b9e94c30 mode 000000,100644..100644 --- a/contrib/lyaml/build-aux/config.ld.in +++ b/contrib/lyaml/build-aux/config.ld.in diff --cc contrib/lyaml/build-aux/luke index 000000000000,3d61f784cbca..3d61f784cbca mode 000000,100755..100755 --- a/contrib/lyaml/build-aux/luke +++ b/contrib/lyaml/build-aux/luke diff --cc contrib/lyaml/doc/index.html index 000000000000,bf7a957f51bd..bf7a957f51bd mode 000000,100644..100644 --- a/contrib/lyaml/doc/index.html +++ b/contrib/lyaml/doc/index.html diff --cc contrib/lyaml/doc/ldoc.css index 000000000000,52c4ad2bd8a2..52c4ad2bd8a2 mode 000000,100644..100644 --- a/contrib/lyaml/doc/ldoc.css +++ b/contrib/lyaml/doc/ldoc.css diff --cc contrib/lyaml/doc/modules/lyaml.explicit.html index 000000000000,2667c4e006b2..2667c4e006b2 mode 000000,100644..100644 --- a/contrib/lyaml/doc/modules/lyaml.explicit.html +++ b/contrib/lyaml/doc/modules/lyaml.explicit.html diff --cc contrib/lyaml/doc/modules/lyaml.functional.html index 000000000000,b003a961ff28..b003a961ff28 mode 000000,100644..100644 --- a/contrib/lyaml/doc/modules/lyaml.functional.html +++ b/contrib/lyaml/doc/modules/lyaml.functional.html diff --cc contrib/lyaml/doc/modules/lyaml.html index 000000000000,2deb6a4b6be7..2deb6a4b6be7 mode 000000,100644..100644 --- a/contrib/lyaml/doc/modules/lyaml.html +++ b/contrib/lyaml/doc/modules/lyaml.html diff --cc contrib/lyaml/doc/modules/lyaml.implicit.html index 000000000000,935579f705c6..935579f705c6 mode 000000,100644..100644 --- a/contrib/lyaml/doc/modules/lyaml.implicit.html +++ b/contrib/lyaml/doc/modules/lyaml.implicit.html diff --cc contrib/lyaml/ext/yaml/emitter.c index 000000000000,b71fd14f4c1d..b71fd14f4c1d mode 000000,100644..100644 --- a/contrib/lyaml/ext/yaml/emitter.c +++ b/contrib/lyaml/ext/yaml/emitter.c diff --cc contrib/lyaml/ext/yaml/lyaml.h index 000000000000,9892a48ea4c4..9892a48ea4c4 mode 000000,100644..100644 --- a/contrib/lyaml/ext/yaml/lyaml.h +++ b/contrib/lyaml/ext/yaml/lyaml.h diff --cc contrib/lyaml/ext/yaml/parser.c index 000000000000,3136abd49045..3136abd49045 mode 000000,100644..100644 --- a/contrib/lyaml/ext/yaml/parser.c +++ b/contrib/lyaml/ext/yaml/parser.c diff --cc contrib/lyaml/ext/yaml/scanner.c index 000000000000,6d7276517f42..6d7276517f42 mode 000000,100644..100644 --- a/contrib/lyaml/ext/yaml/scanner.c +++ b/contrib/lyaml/ext/yaml/scanner.c diff --cc contrib/lyaml/ext/yaml/yaml.c index 000000000000,54478610134f..54478610134f mode 000000,100644..100644 --- a/contrib/lyaml/ext/yaml/yaml.c +++ b/contrib/lyaml/ext/yaml/yaml.c diff --cc contrib/lyaml/lib/lyaml/explicit.lua index 000000000000,98a38331ead6..98a38331ead6 mode 000000,100644..100644 --- a/contrib/lyaml/lib/lyaml/explicit.lua +++ b/contrib/lyaml/lib/lyaml/explicit.lua diff --cc contrib/lyaml/lib/lyaml/functional.lua index 000000000000,556e9489505a..556e9489505a mode 000000,100644..100644 --- a/contrib/lyaml/lib/lyaml/functional.lua +++ b/contrib/lyaml/lib/lyaml/functional.lua diff --cc contrib/lyaml/lib/lyaml/implicit.lua index 000000000000,fe58025b560d..fe58025b560d mode 000000,100644..100644 --- a/contrib/lyaml/lib/lyaml/implicit.lua +++ b/contrib/lyaml/lib/lyaml/implicit.lua diff --cc contrib/lyaml/lib/lyaml/init.lua index 000000000000,95e4036ea7c9..95e4036ea7c9 mode 000000,100644..100644 --- a/contrib/lyaml/lib/lyaml/init.lua +++ b/contrib/lyaml/lib/lyaml/init.lua diff --cc contrib/lyaml/lukefile index 000000000000,318281fd78e7..318281fd78e7 mode 000000,100644..100644 --- a/contrib/lyaml/lukefile +++ b/contrib/lyaml/lukefile diff --cc contrib/lyaml/lyaml-6.2.8-1.rockspec index 000000000000,dce9e45a56cf..dce9e45a56cf mode 000000,100644..100644 --- a/contrib/lyaml/lyaml-6.2.8-1.rockspec +++ b/contrib/lyaml/lyaml-6.2.8-1.rockspec diff --cc contrib/lyaml/spec/ext_yaml_emitter_spec.yaml index 000000000000,385d58f7de3c..385d58f7de3c mode 000000,100644..100644 --- a/contrib/lyaml/spec/ext_yaml_emitter_spec.yaml +++ b/contrib/lyaml/spec/ext_yaml_emitter_spec.yaml diff --cc contrib/lyaml/spec/ext_yaml_parser_spec.yaml index 000000000000,2438c42188e0..2438c42188e0 mode 000000,100644..100644 --- a/contrib/lyaml/spec/ext_yaml_parser_spec.yaml +++ b/contrib/lyaml/spec/ext_yaml_parser_spec.yaml diff --cc contrib/lyaml/spec/ext_yaml_scanner_spec.yaml index 000000000000,4d8e633d2cc2..4d8e633d2cc2 mode 000000,100644..100644 --- a/contrib/lyaml/spec/ext_yaml_scanner_spec.yaml +++ b/contrib/lyaml/spec/ext_yaml_scanner_spec.yaml diff --cc contrib/lyaml/spec/lib_lyaml_functional_spec.yaml index 000000000000,cfd8676f0176..cfd8676f0176 mode 000000,100644..100644 --- a/contrib/lyaml/spec/lib_lyaml_functional_spec.yaml +++ b/contrib/lyaml/spec/lib_lyaml_functional_spec.yaml diff --cc contrib/lyaml/spec/lib_lyaml_spec.yaml index 000000000000,f6c7e1ef4bed..f6c7e1ef4bed mode 000000,100644..100644 --- a/contrib/lyaml/spec/lib_lyaml_spec.yaml +++ b/contrib/lyaml/spec/lib_lyaml_spec.yaml diff --cc contrib/lyaml/spec/spec_helper.lua index 000000000000,1ba7a3a7559f..1ba7a3a7559f mode 000000,100644..100644 --- a/contrib/lyaml/spec/spec_helper.lua +++ b/contrib/lyaml/spec/spec_helper.lua diff --cc libexec/flua/Makefile index 770f05bf2938,000000000000..86d27c0653d4 mode 100644,000000..100644 --- a/libexec/flua/Makefile +++ b/libexec/flua/Makefile @@@ -1,38 -1,0 +1,39 @@@ +.include <src.lua.mk> + +SUBDIR+= libfreebsd +SUBDIR+= libhash +SUBDIR+= libjail +SUBDIR+= libucl ++SUBDIR+= liblyaml + +LUASRC?= ${SRCTOP}/contrib/lua/src +.PATH: ${LUASRC} + +PROG= flua +WARNS?= 3 + +CWARNFLAGS.gcc+= -Wno-format-nonliteral + +LIBADD= lua + +# Entry point +SRCS+= lua.c + +# FreeBSD Extensions +.PATH: ${.CURDIR}/modules +SRCS+= linit_flua.c +SRCS+= lfs.c lposix.c lfbsd.c + +CFLAGS+= -I${SRCTOP}/lib/liblua -I${.CURDIR}/modules -I${LUASRC} +CFLAGS+= -DLUA_PROGNAME="\"${PROG}\"" + +# readline bits; these aren't needed if we're building a bootstrap flua, as we +# don't expect that one to see any REPL usage. +.if !defined(BOOTSTRAPPING) +CFLAGS+= -DLUA_USE_READLINE +CFLAGS+= -I${SRCTOP}/lib/libedit -I${SRCTOP}/contrib/libedit +LIBADD+= edit +LDFLAGS+= -Wl,-E +.endif + +.include <bsd.prog.mk> diff --cc libexec/flua/liblyaml/Makefile index 000000000000,000000000000..e7a89d09bb9e new file mode 100644 --- /dev/null +++ b/libexec/flua/liblyaml/Makefile @@@ -1,0 -1,0 +1,22 @@@ ++SHLIB_NAME= yaml.so ++ ++WARNS= 1 ++LYAMLSRC?= ${SRCTOP}/contrib/lyaml ++.PATH: ${LYAMLSRC}/ext/yaml ${LYAMLSRC}/lib/lyaml ++SRCS= emitter.c \ ++ parser.c \ ++ scanner.c \ ++ yaml.c ++CFLAGS+= \ ++ -I${LYAMLSRC}/ext/yaml \ ++ -I${SRCTOP}/contrib/libyaml/include \ ++ -DVERSION=\"6.2.8\" ++LIBADD+= yaml ++ ++FILES= explicit.lua \ ++ functional.lua \ ++ implicit.lua \ ++ init.lua ++FILESDIR= ${SHAREDIR}/flua/lyaml ++ ++.include <bsd.lib.mk>