204 Commits

Author SHA1 Message Date
Ingy döt Net
55a405c420 Need newer bash and make for Macos testing 2020-05-31 09:31:11 -07:00
Tina Müller (tinita)
9deee01508
Use GitHub Actions (#184) 2020-05-29 21:39:56 +02:00
Tina Müller
0032321756 Remove unnecessary include and malloc 2020-05-21 18:10:59 +02:00
Tina Müller
ce8357938c Add specific files back to .gitignore
Seems this was an oversight in d050fe3f3006b55edf33a2ef91019a67d6c3fb10.
We don't want to ignore all those file, but only the compiled executables.

Also added '/' to several files.
2020-05-21 18:04:15 +02:00
Tina Müller
fec20d3fe6 Output error position in run-parser-test-suite.c 2020-05-21 14:50:20 +02:00
Tina Müller
72e2f75277 Changes for v0.2.4 release 0.2.4 2020-04-19 13:15:10 +02:00
Tina Müller
3694a4af7d Fix logic for document end before directive
open_ended can have three states now:
0: The previous document was ended explicitly with '...'
1: The previous document wasn't ended with '...'
2: The last scalar event was a block scalar with trailing empty lines |+, and
   last document wasn't ended with '...'.
   Important at stream end.

This was broken in the past, and fixed in fa1293a.
With my last PR #162 I added the faulty behaviour again.

The problematic behaviour showed only when all of the following conditions were
true:
* writing YAML directives
* writing unquoted top level scalars
* writing more than one document

================== BROKEN ==============================

The first example shows that the document end marker is not emitted before
the next document. This would be valid in YAML 1.1 if the scalar was quoted,
but not if it is plain.

This commit fixes this.

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1

%YAML 1.1
--- foo
%YAML 1.1
--- bar

================== FIXED ==============================

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

=======================================================

Other examples which should look like this (and were correct already before
this fix):

Open ended scalars like |+ need '...' at the end of the stream:

echo '--- |+
  a

--- |+
  a

' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite
--- |+
  a

--- |+
  a

...

=======================================================

If a document is ended with an explicit '...', the code should not
print '...' twice:

echo '--- foo
...
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

==========================================================
2020-04-19 12:47:41 +02:00
Tina Müller
4e5cea6419 Allow emitting 1.2 directive
Before `1.1` was hardcoded in the emitter.

* Also add --directive option to run-emitter-test-suite
  Allows to easily test how output looks like if %YAML directives
  are output.
2020-04-19 12:47:41 +02:00
Tina Müller (tinita)
47bf3f086f
Add packaging/docker-dist to Makefile.am (#143) 2020-04-19 12:36:01 +02:00
Tina Müller
bf52902899 Changes for v0.2.3 release 0.2.3 2020-04-11 19:08:22 +02:00
Mark Sheahan
a1dc7861f8 Change dllexport controlling macro to use _WIN32
(provided by msvc compiler) instead of WIN32 (which is user configurable, and
omitted by default on some x64 builds); this fixes an issue with 64 bit windows
static library builds (#66)

Co-authored-by: Mark Sheahan <mark.sheahan@upguard.com>
2020-04-11 16:10:50 +02:00
Tina Müller (tinita)
3d5b7e65db
Support %YAML 1.2 directives (#172)
This will simply allow `%YAML 1.2` directives additionally to `%YAML 1.1`.
There is no change in behaviour.

See also #20

No changes are needed regarding tag directives.

In YAML 1.2 tag directives are for the following document only.
This is already implemented like that in libyaml.

We would rather have to fix the code if we want to have the correct behaviour
(global directives) in YAML 1.1. This would be a bit more complicated, as we
would have to save the default version and the current version in the parser
object.

New passing parser tests:

* 27NA: Spec Example 5.9. Directive Indicator
* 6ZKB: Spec Example 9.6. Stream
* 9DXL: Spec Example 9.6. Stream [1.3]
* RTP8: Spec Example 9.2. Document Markers

New failing error parser tests (before they were errors for the wrong reason):

* EB22: Missing document-end marker before directive
* RHX7: YAML directive without document end marker
2020-04-10 21:45:15 +02:00
Michael Drake
1b5bac0d3d
Avoid recursion in the document loader. (#127)
The document loading API (yaml_parser_load) was susseptable to a
stack overflow issue when given input data which opened many
mappings and/or sequences without closing them.

This was due to the use of recurion in the implementation.

With this change, we avoid recursion, and maintain our own loader
context stack on the heap.

The loader context contains a stack of document node indexes.
Each time a sequence or mapping start event is encountered,
the node index corrasponding to the event is pushed to the
stack.  Each time a sequence or mapping end event is encountered,
the corrasponding node's index is popped from the stack.

The yaml_parser_load_nodes() function sits on the event stream,
issuing events to the appropriate handlers by type.

When an event handler function constructs a node, it needs to
connect the new node to its parent (unless it's the root node).
This is where the loader context stack is used to find the
parent node.  The way that the new node is added to the tree
depends on whether the parent node is a mapping (with a
yaml_node_pair_t to fill), or a sequence (with a yaml_node_item_t).

Fixes: https://github.com/yaml/libyaml/issues/107
2020-04-10 21:30:28 +02:00
Ashutosh Chauhan
d0cb513b33
Fix missing token in example (#169) 2020-04-10 21:28:01 +02:00
Junde Yhi
e0b9e42d82
include/yaml.h: fix comments (#155)
* include/yaml.h: fix indentation of comments

* include/yaml.h: fix documentation style comment

* include/yaml.h: fix doc command returns

* include/yaml.h: fix typo
2020-03-28 18:17:28 +01:00
Liao Tonglang
9f9e4a29b7
Change cmake target name from libOFF.a to libyaml.a (#157)
option can only be ON or OFF. Use set() instead of option() to set default name of target.
2020-03-28 18:12:22 +01:00
Tina Müller (tinita)
fa1293a11f
Output document end marker after open ended scalars (#162) 2020-03-28 18:06:58 +01:00
Tina Müller
9afa10a8b0 Always output document end before directive (YAML 1.2 compatibility)
In YAML 1.1, the document end marker `...` is optional even if the next document starts with a directive:
https://github.com/yaml/pyyaml/blob/master/tests/data/spec-07-09.canonical
```
%YAML 1.1
---
!!str "foo"
%YAML 1.1
---
!!str "bar"
%YAML 1.1
---
!!str "baz"
```
It is only required if the scalar is "open ended", for example for plain scalars.

In YAML 1.2 the `...` marker is always required before a directive.

My suggestion would be to make the output 1.2 compatible. It will still be 1.1 compatible, so that shouldn't be a problem.

I believe this will also make it easier to fix #123 which was introduced with the last fixes regarding `open_ended`. I think I can make a fix for this soon after this issue is fixed.
Fixing #123 without this would be a bit more complicated.

If we do this, we also need to adjust PyYAML to behave the same.

Related issues/commits:
- https://github.com/yaml/libyaml/issues/60
- https://github.com/yaml/libyaml/pull/122
- 56400d9, 8ee83c0, 56f4b17
2020-03-26 22:28:39 +01:00
Tina Müller (tinita)
21429b031f Add CHANGES file (#159) 2020-03-26 22:24:32 +01:00
Ingy döt Net
42a370d6b0 Move appveyor.yml to .appveyor.yml 2020-03-26 22:20:56 +01:00
Ingy döt Net
94ecadc50e Makefile test-suite rule builds libyaml first 2019-12-21 11:11:26 -08:00
HonkingGoose
53f5b86823 Fix spelling 2019-07-25 11:59:16 +02:00
Michael Drake
aa2e89362f Squash a couple of warnings in example-deconstructor-alt
example-deconstructor-alt.c: In function ‘main’:
example-deconstructor-alt.c:649:51: warning:
  comparison between ‘yaml_sequence_style_t {aka enum yaml_sequence_style_e}’
  and ‘enum yaml_mapping_style_e’ [-Wenum-compare]

example-deconstructor-alt.c:650:36: warning:
  comparison between ‘yaml_sequence_style_t {aka enum yaml_sequence_style_e}’
  and ‘enum yaml_mapping_style_e’ [-Wenum-compare]
2019-06-06 20:20:58 +02:00
criptych
a21fc21697 Use pointer to const for strings that aren't/shouldn't be modified 2019-06-06 19:25:18 +02:00
林博仁(Buo-ren Lin)
b4ca139010 Fix typo in comment
s/intendation/indentation/

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
2019-06-06 19:11:29 +02:00
SHIBATA Hiroshi
567353cee9 Fixed typo. 2019-06-06 19:08:57 +02:00
Tina Mueller
641adbf244 Fix typo in README 2019-06-06 15:28:02 +02:00
Tina Mueller
fce3597003 Add required packages to README 2019-06-06 14:52:59 +02:00
Ingy döt Net
690a781ef6 Update configure.ac for 0.2.2 0.2.2 2019-03-12 18:04:00 -07:00
Tina Müller
24a020a1a2 Changes for v0.2.2 release 2019-03-12 22:05:30 +01:00
Matt Davis
e7a5f0bc0b
Merge pull request #136 from nitzmahone/win_fixes
allow override of Windows static lib name
0.2.2-pre3
2019-03-04 08:03:10 -08:00
Matt Davis
99e0a150ff allow override of Windows static lib name
* also changed name back to original default of yaml, as the change in #10 to `yaml_static` broke things that relied on that
2019-03-01 17:32:13 -08:00
Tina Müller
78e6ebfb20 Remove stdbool
Might not be available everywhere
0.2.2-pre2
2019-02-28 19:50:04 +01:00
Tina Müller
1560fc82ad Make declarations before other statements 2019-02-28 19:40:53 +01:00
Marty E. Plummer
85d1f168ef appveyor.yml: fix Release build
I suspect this this was a bit of an oversight when first setting up
appveyor for Windows/msvc, but 'release' does not match any target
cmake knows about; 'Release', however, does.

Signed-off-by: Marty E. Plummer <hanetzer@protonmail.com>
2018-07-19 14:53:50 -07:00
Marty E. Plummer
12dc1bef1f build: do not install config.h
'config.h' is meant to be a convenience header to be #included at build
time, but not installed. Installing it can cause a host of problems for
various other projects (for instance, attempting to build u-boot from
source while another project's 'config.h' exists in the compiler search
path will cause build failures similar to:
https://github.com/pepe2k/u-boot_mod/issues/148

Further, I've changed '#include <config.h>' to '#include "config.h"',
which should constrain the search path to the current build directories,
so if another package with a bugged build has this file installed, it
will not cause yaml to miscompile/fail.

If you have a file `/usr/include/config.h` on your filesystem, query
your package manager to find out what package owns it, and file a bug
report against it with your distro maintainers.

Signed-off-by: Marty E. Plummer <hanetzer@protonmail.com>
2018-07-19 14:49:53 -07:00
Tina Müller
df5c05e120 Fix unconditional yaml_free()
Thanks to @tlsa for spotting this
2018-07-18 23:36:58 +02:00
Reini Urban
f033001839 fix version_directive memory leak
detected by coverity
2018-07-18 22:10:31 +02:00
Florian Weimer
96a49a1d9c yaml_stack_extend: guard against integer overflow 2018-07-18 21:56:11 +02:00
Reini Urban
5b8859f728 fix C++ g++-6 errors
yaml_emitter_write_indicator const char *indicator
2018-07-18 21:26:40 +02:00
Reini Urban
551ad48994 fix clang -Wlogical-op warnings
Commit amended by @perlpunk after suggestion from @tlsa
2018-07-18 21:22:15 +02:00
Reini Urban
75eddf785f fix C++-compat error
we cannot malloc to an anon struct in C++.
typedef yaml_anchors_t
2018-07-17 23:08:09 +02:00
Tina Müller
20496ee288 Allow colons in plain scalars inside flow collections
This is a followup to #28

See http://yaml.org/spec/1.1/#nb-plain-char(c) and the following
productions.

This commit will allow `[http://example]`, but still fail for:
- `[:foo]`
- `[foo:]`

See https://gist.github.com/perlpunk/de2c631a7b0e9002de351a680eadb573
for all the relevant cases where this change applies.
0.2.2-pre1
2018-06-30 15:12:39 -07:00
Reini Urban
31bb2aaa34 Fix yaml_document_delete
Remove unneeded context, which is not set in any macro.
2018-06-30 14:47:34 -07:00
Tina Müller
1049e04067 Fix comparison in tests/run-emitter.c 2018-06-30 14:47:34 -07:00
whiteUnicorn
4657431277 Fix typo error
nessesary to necessary
2018-06-30 14:47:34 -07:00
Tina Müller
baf636a74b The closing single quote needs to be indented...
if it's on its own line.

```
% cd libyaml
% echo "+STR
+DOC
+SEQ
=VAL '\\\n
-SEQ
-DOC
-STR" | ./tests/run-emitter-test-suite
- '

'
% # fix
% make
...

% echo "+STR
+DOC
+SEQ
=VAL '\\\n
-SEQ
-DOC
-STR" | ./tests/run-emitter-test-suite
- '

  '
```
2018-06-30 14:47:33 -07:00
Viktor Szakats
2e849b3651 Fix token name typos in comments 2018-06-30 14:47:25 -07:00
Tina Müller
56f4b17221 Don't emit document-end marker at the end of stream
(only when explicitly requested)

@jrtc27++ for the patch.

See #60
2018-06-30 00:16:34 +02:00
Tina Müller
8ee83c0da2 Revert removing of open_ended after top level plain scalar
See also issue #60

Revert "This code is not needed and breaks tests"

This reverts commit 56400d976a1999156b1abfd674c3122843980260.
2018-06-29 21:44:19 +02:00