(#885) Remove amount of supa script lines from the level format
parent
f7d71b2763
commit
9d9a8f5891
|
@ -88,17 +88,7 @@ Script *create_script_from_line_stream(LineStream *line_stream, Broadcast *broad
|
|||
{
|
||||
trace_assert(line_stream);
|
||||
|
||||
const char *line = line_stream_next(line_stream);
|
||||
if (line == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t n = 0;
|
||||
if (sscanf(line, "%lu", &n) == EOF) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *source_code = line_stream_collect_n_lines(line_stream, n);
|
||||
const char *source_code = line_stream_collect_until_end(line_stream);
|
||||
if (source_code == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -116,3 +116,17 @@ char *line_stream_collect_n_lines(LineStream *line_stream, size_t n)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *line_stream_collect_until_end(LineStream *line_stream)
|
||||
{
|
||||
char *result = string_append(NULL, "");
|
||||
const char *line = line_stream_next(line_stream);
|
||||
|
||||
/* TODO: line_stream_collect_until_end does not distinguish between EOF and error during reading */
|
||||
while (line != NULL) {
|
||||
result = string_append(result, line);
|
||||
line = line_stream_next(line_stream);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -13,5 +13,6 @@ void destroy_line_stream(LineStream *line_stream);
|
|||
const char *line_stream_next_chunk(LineStream *line_stream);
|
||||
const char *line_stream_next(LineStream *line_stream);
|
||||
char *line_stream_collect_n_lines(LineStream *line_stream, size_t n);
|
||||
char *line_stream_collect_until_end(LineStream *line_stream);
|
||||
|
||||
#endif // LINE_STREAM_H_
|
||||
|
|
Loading…
Reference in New Issue