on master help sign in
Move over to libyaml from Github (fixes #105)
commit1ecada5b620cc18808cfb30d8908213c7ee834af authorMichael Snoyman <michael@snoyman.com> dateThu 16 Feb 2017, 09:06 (10 years ago) parent02b2d5d
15 files changed+73−74
.gitmodules+3 copy-libyaml.sh+10 libyaml/LICENSE+1−1 libyaml/Makefile−9 libyaml/api.c+9−11 libyaml/emitter.c+8−13 libyaml/loader.c+2−2 libyaml/parser.c+1−1 libyaml/reader.c+3−3 libyaml/scanner.c+28−25 libyaml/writer.c+1−1 libyaml/yaml.h+2−4 libyaml/yaml_private.h+3−3 test/Data/YamlSpec.hs+1−1 vendor/libyaml+1
.gitmodulesnew file+3
@@ -0,0 +1,3 @@
1+[submodule "vendor/libyaml"]
2+ path = vendor/libyaml
3+ url = https://github.com/snoyberg/libyaml
copy-libyaml.shnew file+10
@@ -0,0 +1,10 @@
1+#!/usr/bin/env bash
2+
3+set -ex
4+
5+rm -rf libyaml
6+mkdir -p libyaml
7+cp vendor/libyaml/LICENSE libyaml
8+cp vendor/libyaml/src/*.c libyaml
9+cp vendor/libyaml/src/*.h libyaml
10+cp vendor/libyaml/include/*.h libyaml
libyaml/LICENSE+1−1
@@ -1,4 +1,4 @@
1−Copyright (c) 2006 Kirill Simonov
1+Copyright (c) 2006-2016 Kirill Simonov
22
33Permission is hereby granted, free of charge, to any person obtaining a copy of
44this software and associated documentation files (the "Software"), to deal in
libyaml/Makefiledeleted−9
@@ -1,9 +0,0 @@
1−CC = gcc
2−CFLAGS = -shared
3−OBJECTS = api.o dumper.o emitter.o loader.o parser.o reader.o scanner.o writer.o
4−LIB = libyaml.so
5−LFLAGS = -shared -Wl,-soname,libyaml.so
6−%.o: %.c
7− $(CC) $(CFLAGS) -c -fPIC $<
8−yaml: $(OBJECTS)
9− $(CC) $(LFLAGS) -o $(LIB) $(OBJECTS)
libyaml/api.c+9−11
@@ -5,15 +5,6 @@
55 * Get the library version.
66 */
77
8−/*
9− * added to support _WIN64
10− */
11−#if _WIN64
12−#define STRDUP _strdup
13−#else
14−#define STRDUP strdup
15−#endif
16−
178YAML_DECLARE(const char *)
189yaml_get_version_string(void)
1910{
@@ -72,7 +63,14 @@ yaml_strdup(const yaml_char_t *str)
7263 if (!str)
7364 return NULL;
7465
75− return (yaml_char_t *) STRDUP((char *)str);
66+/*
67+ * Haskell yaml package: added to support _WIN64
68+ */
69+#if _WIN64
70+ return (yaml_char_t *)_strdup((char *)str);
71+#else
72+ return (yaml_char_t *)strdup((char *)str);
73+#endif
7674}
7775
7876/*
@@ -834,7 +832,7 @@ yaml_scalar_event_initialize(yaml_event_t *event,
834832
835833 assert(event); /* Non-NULL event object is expected. */
836834 /* following line added for Haskell yaml library */
837− if (!value && !length) value = "";
835+ if (!value && !length) value = (unsigned char*)"";
838836 assert(value); /* Non-NULL anchor is expected. */
839837
840838 if (anchor) {
libyaml/emitter.c+8−13
@@ -517,7 +517,7 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
517517 if (emitter->best_width < 0) {
518518 emitter->best_width = INT_MAX;
519519 }
520−
520+
521521 if (!emitter->line_break) {
522522 emitter->line_break = YAML_LN_BREAK;
523523 }
@@ -607,7 +607,7 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
607607 if (!yaml_emitter_write_indent(emitter))
608608 return 0;
609609 }
610−
610+
611611 if (event->data.document_start.tag_directives.start
612612 != event->data.document_start.tag_directives.end) {
613613 implicit = 0;
@@ -721,7 +721,7 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
721721}
722722
723723/*
724− *
724+ *
725725 * Expect a flow item node.
726726 */
727727
@@ -1402,7 +1402,7 @@ yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
14021402{
14031403 size_t anchor_length;
14041404 yaml_string_t string;
1405−
1405+
14061406 anchor_length = strlen((char *)anchor);
14071407 STRING_ASSIGN(string, anchor, anchor_length);
14081408
@@ -1493,7 +1493,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
14931493 int break_space = 0;
14941494 int space_break = 0;
14951495
1496− int preceeded_by_whitespace = 0;
1496+ int preceded_by_whitespace = 0;
14971497 int followed_by_whitespace = 0;
14981498 int previous_space = 0;
14991499 int previous_break = 0;
@@ -1524,7 +1524,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
15241524 flow_indicators = 1;
15251525 }
15261526
1527− preceeded_by_whitespace = 1;
1527+ preceded_by_whitespace = 1;
15281528 followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
15291529
15301530 while (string.pointer != string.end)
@@ -1570,7 +1570,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
15701570 }
15711571 }
15721572
1573− if (CHECK(string, '#') && preceeded_by_whitespace) {
1573+ if (CHECK(string, '#') && preceded_by_whitespace) {
15741574 flow_indicators = 1;
15751575 block_indicators = 1;
15761576 }
@@ -1619,7 +1619,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
16191619 previous_break = 0;
16201620 }
16211621
1622− preceeded_by_whitespace = IS_BLANKZ(string);
1622+ preceded_by_whitespace = IS_BLANKZ(string);
16231623 MOVE(string);
16241624 if (string.pointer != string.end) {
16251625 followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
@@ -1946,10 +1946,6 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
19461946
19471947 emitter->whitespace = 0;
19481948 emitter->indention = 0;
1949− if (emitter->root_context)
1950− {
1951− emitter->open_ended = 1;
1952− }
19531949
19541950 return 1;
19551951}
@@ -2326,4 +2322,3 @@ yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
23262322
23272323 return 1;
23282324}
2329−
libyaml/loader.c+2−2
@@ -239,8 +239,8 @@ yaml_parser_register_anchor(yaml_parser_t *parser,
239239 if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
240240 yaml_free(anchor);
241241 return yaml_parser_set_composer_error_context(parser,
242− "found duplicate anchor; first occurence",
243− alias_data->mark, "second occurence", data.mark);
242+ "found duplicate anchor; first occurrence",
243+ alias_data->mark, "second occurrence", data.mark);
244244 }
245245 }
246246
libyaml/parser.c+1−1
@@ -1295,7 +1295,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
12951295 token = PEEK_TOKEN(parser);
12961296 if (!token) goto error;
12971297 }
1298−
1298+
12991299 for (default_tag_directive = default_tag_directives;
13001300 default_tag_directive->handle; default_tag_directive++) {
13011301 if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
libyaml/reader.c+3−3
@@ -52,7 +52,7 @@ yaml_parser_determine_encoding(yaml_parser_t *parser)
5252{
5353 /* Ensure that we had enough bytes in the raw buffer. */
5454
55− while (!parser->eof
55+ while (!parser->eof
5656 && parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
5757 if (!yaml_parser_update_raw_buffer(parser)) {
5858 return 0;
@@ -295,7 +295,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
295295 parser->offset, value);
296296
297297 break;
298−
298+
299299 case YAML_UTF16LE_ENCODING:
300300 case YAML_UTF16BE_ENCODING:
301301
@@ -318,7 +318,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
318318 *
319319 * The following formulas are used for decoding
320320 * and encoding characters using surrogate pairs:
321− *
321+ *
322322 * U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
323323 * U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
324324 * W1 = 110110yyyyyyyyyy
libyaml/scanner.c+28−25
@@ -70,7 +70,7 @@
7070 * %TAG !yaml! tag:yaml.org,2002:
7171 * ---
7272 *
73− * The correspoding sequence of tokens:
73+ * The corresponding sequence of tokens:
7474 *
7575 * STREAM-START(utf-8)
7676 * VERSION-DIRECTIVE(1,1)
@@ -762,7 +762,7 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
762762 }
763763
764764 /* Fetch the next token from the queue. */
765−
765+
766766 *token = DEQUEUE(parser, parser->tokens);
767767 parser->token_available = 0;
768768 parser->tokens_parsed ++;
@@ -1114,7 +1114,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
11141114 yaml_simple_key_t simple_key;
11151115 simple_key.possible = 1;
11161116 simple_key.required = required;
1117− simple_key.token_number =
1117+ simple_key.token_number =
11181118 parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
11191119 simple_key.mark = parser->mark;
11201120
@@ -1200,7 +1200,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
12001200 * Push the current indentation level to the stack and set the new level
12011201 * the current column is greater than the indentation level. In this case,
12021202 * append or insert the specified token into the token queue.
1203− *
1203+ *
12041204 */
12051205
12061206static int
@@ -1251,7 +1251,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
12511251
12521252/*
12531253 * Pop indentation levels from the indents stack until the current level
1254− * becomes less or equal to the column. For each intendation level, append
1254+ * becomes less or equal to the column. For each indentation level, append
12551255 * the BLOCK-END token.
12561256 */
12571257
@@ -1266,7 +1266,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
12661266 if (parser->flow_level)
12671267 return 1;
12681268
1269− /* Loop through the intendation levels in the stack. */
1269+ /* Loop through the indentation levels in the stack. */
12701270
12711271 while (parser->indent > column)
12721272 {
@@ -1938,7 +1938,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
19381938 *
19391939 * - in the flow context;
19401940 * - in the block context, but not at the beginning of the line or
1941− * after '-', '?', or ':' (complex value).
1941+ * after '-', '?', or ':' (complex value).
19421942 */
19431943
19441944 if (!CACHE(parser, 1)) return 0;
@@ -2053,7 +2053,7 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
20532053 else
20542054 {
20552055 yaml_parser_set_scanner_error(parser, "while scanning a directive",
2056− start_mark, "found uknown directive name");
2056+ start_mark, "found unknown directive name");
20572057 goto error;
20582058 }
20592059
@@ -2775,15 +2775,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
27752775
27762776 if (IS_DIGIT(parser->buffer))
27772777 {
2778− /* Check that the intendation is greater than 0. */
2778+ /* Check that the indentation is greater than 0. */
27792779
27802780 if (CHECK(parser->buffer, '0')) {
27812781 yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
2782− start_mark, "found an intendation indicator equal to 0");
2782+ start_mark, "found an indentation indicator equal to 0");
27832783 goto error;
27842784 }
27852785
2786− /* Get the intendation level and eat the indicator. */
2786+ /* Get the indentation level and eat the indicator. */
27872787
27882788 increment = AS_DIGIT(parser->buffer);
27892789
@@ -2797,7 +2797,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
27972797 {
27982798 if (CHECK(parser->buffer, '0')) {
27992799 yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
2800− start_mark, "found an intendation indicator equal to 0");
2800+ start_mark, "found an indentation indicator equal to 0");
28012801 goto error;
28022802 }
28032803
@@ -2847,7 +2847,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
28472847
28482848 end_mark = parser->mark;
28492849
2850− /* Set the intendation level if it was specified. */
2850+ /* Set the indentation level if it was specified. */
28512851
28522852 if (increment) {
28532853 indent = parser->indent >= 0 ? parser->indent+increment : increment;
@@ -2913,7 +2913,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
29132913
29142914 if (!READ_LINE(parser, leading_break)) goto error;
29152915
2916− /* Eat the following intendation spaces and line breaks. */
2916+ /* Eat the following indentation spaces and line breaks. */
29172917
29182918 if (!yaml_parser_scan_block_scalar_breaks(parser,
29192919 &indent, &trailing_breaks, start_mark, &end_mark)) goto error;
@@ -2948,8 +2948,8 @@ error:
29482948}
29492949
29502950/*
2951− * Scan intendation spaces and line breaks for a block scalar. Determine the
2952− * intendation level if needed.
2951+ * Scan indentation spaces and line breaks for a block scalar. Determine the
2952+ * indentation level if needed.
29532953 */
29542954
29552955static int
@@ -2961,11 +2961,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
29612961
29622962 *end_mark = parser->mark;
29632963
2964− /* Eat the intendation spaces and line breaks. */
2964+ /* Eat the indentation spaces and line breaks. */
29652965
29662966 while (1)
29672967 {
2968− /* Eat the intendation spaces. */
2968+ /* Eat the indentation spaces. */
29692969
29702970 if (!CACHE(parser, 1)) return 0;
29712971
@@ -2978,12 +2978,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
29782978 if ((int)parser->mark.column > max_indent)
29792979 max_indent = (int)parser->mark.column;
29802980
2981− /* Check for a tab character messing the intendation. */
2981+ /* Check for a tab character messing the indentation. */
29822982
29832983 if ((!*indent || (int)parser->mark.column < *indent)
29842984 && IS_TAB(parser->buffer)) {
29852985 return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
2986− start_mark, "found a tab character where an intendation space is expected");
2986+ start_mark, "found a tab character where an indentation space is expected");
29872987 }
29882988
29892989 /* Have we found a non-empty line? */
@@ -3007,7 +3007,7 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
30073007 *indent = 1;
30083008 }
30093009
3010− return 1;
3010+ return 1;
30113011}
30123012
30133013/*
@@ -3162,6 +3162,10 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
31623162 *(string.pointer++) = '"';
31633163 break;
31643164
3165+ case '/':
3166+ *(string.pointer++) = '/';
3167+ break;
3168+
31653169 case '\'':
31663170 *(string.pointer++) = '\'';
31673171 break;
@@ -3504,12 +3508,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
35043508 {
35053509 if (IS_BLANK(parser->buffer))
35063510 {
3507− /* Check for tab character that abuse intendation. */
3511+ /* Check for tab character that abuse indentation. */
35083512
35093513 if (leading_blanks && (int)parser->mark.column < indent
35103514 && IS_TAB(parser->buffer)) {
35113515 yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
3512− start_mark, "found a tab character that violate intendation");
3516+ start_mark, "found a tab character that violate indentation");
35133517 goto error;
35143518 }
35153519
@@ -3542,7 +3546,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
35423546 if (!CACHE(parser, 1)) goto error;
35433547 }
35443548
3545− /* Check intendation level. */
3549+ /* Check indentation level. */
35463550
35473551 if (!parser->flow_level && (int)parser->mark.column < indent)
35483552 break;
@@ -3573,4 +3577,3 @@ error:
35733577
35743578 return 0;
35753579}
3576−
libyaml/writer.c+1−1
@@ -74,7 +74,7 @@ yaml_emitter_flush(yaml_emitter_t *emitter)
7474 unsigned int value;
7575 size_t k;
7676
77− /*
77+ /*
7878 * See the "reader.c" code for more details on UTF-8 encoding. Note
7979 * that we assume that the buffer contains a valid UTF-8 sequence.
8080 */
libyaml/yaml.h+2−4
@@ -26,9 +26,7 @@ extern "C" {
2626
2727/** The public API declaration. */
2828
29−#if defined(__MINGW32__)
30−# define YAML_DECLARE(type) type
31−#elif defined(_WIN32)
29+#ifdef _WIN32
3230# if defined(YAML_DECLARE_STATIC)
3331# define YAML_DECLARE(type) type
3432# elif defined(YAML_DECLARE_EXPORT)
@@ -665,7 +663,7 @@ yaml_event_delete(yaml_event_t *event);
665663
666664/** The tag @c !!null with the only possible value: @c null. */
667665#define YAML_NULL_TAG "tag:yaml.org,2002:null"
668−/** The tag @c !!bool with the values: @c true and @c falce. */
666+/** The tag @c !!bool with the values: @c true and @c false. */
669667#define YAML_BOOL_TAG "tag:yaml.org,2002:bool"
670668/** The tag @c !!str for string values. */
671669#define YAML_STR_TAG "tag:yaml.org,2002:str"
libyaml/yaml_private.h+3−3
@@ -1,4 +1,3 @@
1−
21#if HAVE_CONFIG_H
32#include <config.h>
43#endif
@@ -242,9 +241,9 @@ yaml_string_join(
242241 (string).pointer[offset] <= (yaml_char_t) 'f') ? \
243242 ((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
244243 ((string).pointer[offset] - (yaml_char_t) '0'))
245−
244+
246245#define AS_HEX(string) AS_HEX_AT((string),0)
247−
246+
248247/*
249248 * Check if the character is ASCII.
250249 */
@@ -658,6 +657,7 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
658657 (node).data.mapping.pairs.top = (node_pairs_start), \
659658 (node).data.mapping.style = (node_style))
660659
660+/* For Haskell yaml package, since we do not use the configure script */
661661#define YAML_VERSION_STRING "0.1.7"
662662#define YAML_VERSION_MAJOR 0
663663#define YAML_VERSION_MINOR 1
test/Data/YamlSpec.hs+1−1
@@ -450,7 +450,7 @@ caseQuotedNumber, caseUnquotedNumber, caseAttribNumber, caseIntegerDecimals :: A
450450caseQuotedNumber = D.decode "foo: \"1234\"" @?= Just (object [("foo", D.String "1234")])
451451caseUnquotedNumber = D.decode "foo: 1234" @?= Just (object [("foo", D.Number 1234)])
452452caseAttribNumber = D.decode "foo: !!str 1234" @?= Just (object [("foo", D.String "1234")])
453−caseIntegerDecimals = D.encode (1 :: Int) @?= "1\n...\n"
453+caseIntegerDecimals = D.encode (1 :: Int) @?= "1\n"
454454
455455obj :: Maybe D.Value
456456obj = Just (object [("foo", D.Bool False), ("bar", D.Bool True), ("baz", D.Bool True)])
vendor/libyamlnew file+1

Submodule changed.