Skip to content

Commit 0174ed6

Browse files
committed
Add win32 fixes and project files for VC6.
1 parent e27a3c8 commit 0174ed6

File tree

10 files changed

+366
-32
lines changed

10 files changed

+366
-32
lines changed

src/api.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ YAML_DECLARE(int)
7474
yaml_string_extend(yaml_char_t **start,
7575
yaml_char_t **pointer, yaml_char_t **end)
7676
{
77-
void *new_start = yaml_realloc(*start, (*end - *start)*2);
77+
yaml_char_t *new_start = yaml_realloc(*start, (*end - *start)*2);
7878

7979
if (!new_start) return 0;
8080

@@ -117,12 +117,12 @@ yaml_string_join(
117117
YAML_DECLARE(int)
118118
yaml_stack_extend(void **start, void **top, void **end)
119119
{
120-
void *new_start = yaml_realloc(*start, (*end - *start)*2);
120+
void *new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
121121

122122
if (!new_start) return 0;
123123

124-
*top = new_start + (*top - *start);
125-
*end = new_start + (*end - *start)*2;
124+
*top = (char *)new_start + ((char *)*top - (char *)*start);
125+
*end = (char *)new_start + ((char *)*end - (char *)*start)*2;
126126
*start = new_start;
127127

128128
return 1;
@@ -138,23 +138,24 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end)
138138
/* Check if we need to resize the queue. */
139139

140140
if (*start == *head && *tail == *end) {
141-
void *new_start = yaml_realloc(*start, (*end - *start)*2);
141+
void *new_start = yaml_realloc(*start,
142+
((char *)*end - (char *)*start)*2);
142143

143144
if (!new_start) return 0;
144145

145-
*head = new_start + (*head - *start);
146-
*tail = new_start + (*tail - *start);
147-
*end = new_start + (*end - *start)*2;
146+
*head = (char *)new_start + ((char *)*head - (char *)*start);
147+
*tail = (char *)new_start + ((char *)*tail - (char *)*start);
148+
*end = (char *)new_start + ((char *)*end - (char *)*start)*2;
148149
*start = new_start;
149150
}
150151

151152
/* Check if we need to move the queue at the beginning of the buffer. */
152153

153154
if (*tail == *end) {
154155
if (*head != *tail) {
155-
memmove(*start, *head, *tail - *head);
156+
memmove(*start, *head, (char *)*tail - (char *)*head);
156157
}
157-
*tail -= *head - *start;
158+
*tail = (char *)*tail - (char *)*head + (char *)*start;
158159
*head = *start;
159160
}
160161

@@ -249,7 +250,8 @@ yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
249250
return 1;
250251
}
251252

252-
if (size > (parser->input.string.end - parser->input.string.current)) {
253+
if (size > (size_t)(parser->input.string.end
254+
- parser->input.string.current)) {
253255
size = parser->input.string.end - parser->input.string.current;
254256
}
255257

@@ -624,7 +626,7 @@ yaml_check_utf8(yaml_char_t *start, size_t length)
624626
unsigned char octet;
625627
unsigned int width;
626628
unsigned int value;
627-
int k;
629+
size_t k;
628630

629631
octet = pointer[0];
630632
width = (octet & 0x80) == 0x00 ? 1 :
@@ -1116,7 +1118,7 @@ yaml_document_delete(yaml_document_t *document)
11161118
{
11171119
struct {
11181120
yaml_error_type_t error;
1119-
} context;
1121+
} context = { YAML_NO_ERROR };
11201122
yaml_tag_directive_t *tag_directive;
11211123

11221124
assert(document); /* Non-NULL document object is expected. */
@@ -1381,3 +1383,4 @@ yaml_document_append_mapping_pair(yaml_document_t *document,
13811383
return 1;
13821384
}
13831385

1386+

src/emitter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
14191419
for (tag_directive = emitter->tag_directives.start;
14201420
tag_directive != emitter->tag_directives.top; tag_directive ++) {
14211421
size_t prefix_length = strlen((char *)tag_directive->prefix);
1422-
if (prefix_length < (string.end - string.start)
1422+
if (prefix_length < (size_t)(string.end - string.start)
14231423
&& strncmp((char *)tag_directive->prefix, (char *)string.start,
14241424
prefix_length) == 0)
14251425
{
@@ -2026,7 +2026,7 @@ yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
20262026
unsigned char octet;
20272027
unsigned int width;
20282028
unsigned int value;
2029-
int k;
2029+
size_t k;
20302030

20312031
octet = string.pointer[0];
20322032
width = (octet & 0x80) == 0x00 ? 1 :

src/loader.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,13 @@ static int
225225
yaml_parser_register_anchor(yaml_parser_t *parser,
226226
int index, yaml_char_t *anchor)
227227
{
228-
yaml_alias_data_t data = { anchor, index,
229-
parser->document->nodes.start[index-1].start_mark };
228+
yaml_alias_data_t data = { anchor, index, { 0, 0, 0 } };
230229
yaml_alias_data_t *alias_data;
231230

232231
if (!anchor) return 1;
233232

233+
data.mark = parser->document->nodes.start[index-1].start_mark;
234+
234235
for (alias_data = parser->aliases.start;
235236
alias_data != parser->aliases.top; alias_data ++) {
236237
if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {

src/reader.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
190190
int incomplete = 0;
191191
unsigned char octet;
192192
unsigned int width = 0;
193-
int k, low, high;
194-
int raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer;
193+
int low, high;
194+
size_t k;
195+
size_t raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer;
195196

196197
/* Decode the next character. */
197198

src/scanner.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
11031103
*/
11041104

11051105
int required = (!parser->flow_level
1106-
&& parser->indent == parser->mark.column);
1106+
&& parser->indent == (int)parser->mark.column);
11071107

11081108
/*
11091109
* A simple key is required only when it is the first token in the current
@@ -1120,7 +1120,8 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
11201120
{
11211121
yaml_simple_key_t simple_key = { 1, required,
11221122
parser->tokens_parsed + parser->tokens.tail - parser->tokens.head,
1123-
parser->mark };
1123+
{ 0, 0, 0 } };
1124+
simple_key.mark = parser->mark;
11241125

11251126
if (!yaml_parser_remove_simple_key(parser)) return 0;
11261127

@@ -2569,7 +2570,7 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
25692570

25702571
/* Resize the string to include the head. */
25712572

2572-
while (string.end - string.start <= length) {
2573+
while (string.end - string.start <= (int)length) {
25732574
if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
25742575
parser->error = YAML_MEMORY_ERROR;
25752576
goto error;
@@ -2851,7 +2852,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
28512852

28522853
if (!CACHE(parser, 1)) goto error;
28532854

2854-
while (parser->mark.column == indent && !IS_Z(parser->buffer))
2855+
while ((int)parser->mark.column == indent && !IS_Z(parser->buffer))
28552856
{
28562857
/*
28572858
* We are at the beginning of a non-empty line.
@@ -2958,18 +2959,18 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
29582959

29592960
if (!CACHE(parser, 1)) return 0;
29602961

2961-
while ((!*indent || parser->mark.column < *indent)
2962+
while ((!*indent || (int)parser->mark.column < *indent)
29622963
&& IS_SPACE(parser->buffer)) {
29632964
SKIP(parser);
29642965
if (!CACHE(parser, 1)) return 0;
29652966
}
29662967

2967-
if (parser->mark.column > max_indent)
2968-
max_indent = parser->mark.column;
2968+
if ((int)parser->mark.column > max_indent)
2969+
max_indent = (int)parser->mark.column;
29692970

29702971
/* Check for a tab character messing the intendation. */
29712972

2972-
if ((!*indent || parser->mark.column < *indent)
2973+
if ((!*indent || (int)parser->mark.column < *indent)
29732974
&& IS_TAB(parser->buffer)) {
29742975
return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
29752976
start_mark, "found a tab character where an intendation space is expected");
@@ -3098,7 +3099,7 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
30983099

30993100
else if (!single && CHECK(parser->buffer, '\\'))
31003101
{
3101-
int code_length = 0;
3102+
size_t code_length = 0;
31023103

31033104
if (!STRING_EXTEND(parser, string)) goto error;
31043105

@@ -3207,7 +3208,7 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
32073208
if (code_length)
32083209
{
32093210
unsigned int value = 0;
3210-
int k;
3211+
size_t k;
32113212

32123213
/* Scan the character value. */
32133214

@@ -3495,7 +3496,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
34953496
{
34963497
/* Check for tab character that abuse intendation. */
34973498

3498-
if (leading_blanks && parser->mark.column < indent
3499+
if (leading_blanks && (int)parser->mark.column < indent
34993500
&& IS_TAB(parser->buffer)) {
35003501
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
35013502
start_mark, "found a tab character that violate intendation");
@@ -3533,7 +3534,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
35333534

35343535
/* Check intendation level. */
35353536

3536-
if (!parser->flow_level && parser->mark.column < indent)
3537+
if (!parser->flow_level && (int)parser->mark.column < indent)
35373538
break;
35383539
}
35393540

src/writer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ yaml_emitter_flush(yaml_emitter_t *emitter)
7272
unsigned char octet;
7373
unsigned int width;
7474
unsigned int value;
75-
int k;
75+
size_t k;
7676

7777
/*
7878
* See the "reader.c" code for more details on UTF-8 encoding. Note

win32/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define YAML_VERSION_MAJOR 0
2+
#define YAML_VERSION_MINOR 0
3+
#define YAML_VERSION_PATCH 1
4+
#define YAML_VERSION_STRING "0.0.1"

win32/vc6/libyaml.dsw

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Microsoft Developer Studio Workspace File, Format Version 6.00
2+
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3+
4+
###############################################################################
5+
6+
Project: "yaml"=".\yaml\yaml.dsp" - Package Owner=<4>
7+
8+
Package=<5>
9+
{{{
10+
}}}
11+
12+
Package=<4>
13+
{{{
14+
}}}
15+
16+
###############################################################################
17+
18+
Project: "yamldll"=".\yamldll\yamldll.dsp" - Package Owner=<4>
19+
20+
Package=<5>
21+
{{{
22+
}}}
23+
24+
Package=<4>
25+
{{{
26+
}}}
27+
28+
###############################################################################
29+
30+
Global:
31+
32+
Package=<5>
33+
{{{
34+
}}}
35+
36+
Package=<3>
37+
{{{
38+
}}}
39+
40+
###############################################################################
41+

0 commit comments

Comments
 (0)