]> git.lizzy.rs Git - nothing.git/commitdiff
Delete LineStream from the existance
authorrexim <reximkut@gmail.com>
Sat, 4 Jan 2020 21:04:56 +0000 (04:04 +0700)
committerrexim <reximkut@gmail.com>
Sat, 4 Jan 2020 21:04:56 +0000 (04:04 +0700)
31 files changed:
CMakeLists.txt
nothing.c
src/game/level.c
src/game/level/background.c
src/game/level/boxes.c
src/game/level/goals.c
src/game/level/labels.c
src/game/level/lava.c
src/game/level/lava/wavy_rect.c
src/game/level/level_editor.c
src/game/level/level_editor/background_layer.c
src/game/level/level_editor/background_layer.h
src/game/level/level_editor/color_picker.c
src/game/level/level_editor/color_picker.h
src/game/level/level_editor/label_layer.c
src/game/level/level_editor/label_layer.h
src/game/level/level_editor/player_layer.c
src/game/level/level_editor/player_layer.h
src/game/level/level_editor/point_layer.c
src/game/level/level_editor/point_layer.h
src/game/level/level_editor/rect_layer.c
src/game/level/level_editor/rect_layer.h
src/game/level/platforms.c
src/game/level/player.c
src/game/level/regions.c
src/game/level/rigid_bodies.c
src/system/line_stream.c [deleted file]
src/system/line_stream.h [deleted file]
src/system/s.h
src/system/str.c
src/system/str.h

index 218247375ba39f97ba8bc805a91ed6ca898df0f7..23e623e45922095de400dfd251ff40efec0804b6 100644 (file)
@@ -145,8 +145,6 @@ add_executable(nothing
   src/game/level/level_editor/undo_history.c
   src/game/level/level_editor/action_picker.h
   src/game/level/level_editor/action_picker.c
-  src/system/line_stream.h
-  src/system/line_stream.c
   src/system/log.h
   src/system/log.c
   src/system/lt.h
index d460dba188ec545104d5f86ce0889a1c73394c82..ba503438a35e219ff976c0f7c86a638fd992bb31 100644 (file)
--- a/nothing.c
+++ b/nothing.c
@@ -43,7 +43,6 @@
 #include "src/game/level/level_editor/background_layer.c"
 #include "src/game/level/level_editor/undo_history.c"
 #include "src/game/level/level_editor/action_picker.c"
-#include "src/system/line_stream.c"
 #include "src/system/log.c"
 #include "src/system/lt_adapters.c"
 #include "src/system/nth_alloc.c"
index b833895740fc21a8ab8046d76ad6f51114d1bab9..eeb5b65478b93c2a4145b50a22b23eddec18bd23 100644 (file)
@@ -18,7 +18,6 @@
 #include "game/level/level_editor/player_layer.h"
 #include "game/level/level_editor/label_layer.h"
 #include "game/level/level_editor/background_layer.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index ba6ed8fb3e538a943a40f27cba51860d661b61fc..7b13823f14e1a873687b08dd33cee5c333d0d787 100644 (file)
@@ -3,7 +3,6 @@
 #include "game/level/background.h"
 #include "math/rand.h"
 #include "math/rect.h"
-#include "system/line_stream.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
 #include "system/log.h"
index 64bdd893f8eca25add81184c21960e7f9b65f7d8..fa6827df341471080e4d169eb4b85e4776c38f84 100644 (file)
@@ -6,7 +6,6 @@
 #include "game/level/player.h"
 #include "game/level/rigid_bodies.h"
 #include "math/rand.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 885383d0e064e3fc1b591e3cf9d1bcc28a183387..1d675f2f5f9debbad1487bda5468e8c0c2be1aa7 100644 (file)
@@ -7,7 +7,6 @@
 #include "goals.h"
 #include "math/pi.h"
 #include "math/triangle.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 95ea708775fe2f2b184209775de286888f404271..9526463c1f58c02a57cd631dafafa0214e2a7801 100644 (file)
@@ -5,7 +5,6 @@
 #include "game/camera.h"
 #include "game/level/labels.h"
 #include "game/level/level_editor/label_layer.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index b6f66515ad393d40cc32708a9aa301ba70b5e611..ec580d4c075fe526ffac321a4f0ba7d5ee13990e 100644 (file)
@@ -7,7 +7,6 @@
 #include "lava.h"
 #include "math/rect.h"
 #include "system/lt.h"
-#include "system/line_stream.h"
 #include "system/nth_alloc.h"
 #include "system/log.h"
 #include "game/level/level_editor/rect_layer.h"
index 5c3e14081e13cee1e5917f7ca0e10992be8747b4..d41bc4398e104e89d83240cb7d6dda39b208af48 100644 (file)
@@ -5,7 +5,6 @@
 #include <time.h>
 
 #include "math/pi.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index d39d8d9f50a7342a882dc03bfdfbaa8e868d367e..36f80f45ae80d86fb832cf3ada2464040feab5e9 100644 (file)
 #include "system/str.h"
 #include "config.h"
 #include "math/extrema.h"
+#include "system/file.h"
 
 #include "level_editor.h"
 
 #define LEVEL_FOLDER_MAX_LENGTH 512
-#define LEVEL_LINE_MAX_LENGTH 512
 #define LEVEL_EDITOR_EDIT_FIELD_SIZE vec(5.0f, 5.0f)
 #define LEVEL_EDITOR_EDIT_FIELD_COLOR COLOR_BLACK
 
index 74945dcf7360bb64abd58eaa5370639534eaa22d..3ac3c5da4646b2e1891ccc5be1c940bc41cf0927 100644 (file)
@@ -17,20 +17,6 @@ BackgroundLayer create_background_layer(Color color)
     return layer;
 }
 
-int background_layer_read_from_line_stream(BackgroundLayer *layer,
-                                           LineStream *line_stream)
-{
-    if (color_picker_read_from_line_stream(
-            &layer->color_picker,
-            line_stream) < 0) {
-        return -1;
-    }
-
-    layer->prev_color = color_picker_rgba(&layer->color_picker);
-
-    return 0;
-}
-
 BackgroundLayer chop_background_layer(String *input)
 {
     String line = trim(chop_by_delim(input, '\n'));
index bb01f338b72e27f1a599f9ef2bf6ecf251fa3634..998309c22bcbe05a675143a213bd2e2262d7c0d1 100644 (file)
@@ -10,8 +10,6 @@ typedef struct {
 } BackgroundLayer;
 
 BackgroundLayer create_background_layer(Color color);
-int background_layer_read_from_line_stream(BackgroundLayer *layer,
-                                           LineStream *line_stream);
 BackgroundLayer chop_background_layer(String *input);
 
 static inline
index 6cacb7eb1f2e4ea063ae50e652a0c3c4fa728a54..c317f3279eff4d7cc0830be853c5c630c3e68039 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "game/level/boxes.h"
 #include "system/stacktrace.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "game/camera.h"
 #include "color_picker.h"
@@ -36,24 +35,6 @@ ColorPicker create_color_picker_from_rgba(Color color)
     return color_picker;
 }
 
-int color_picker_read_from_line_stream(ColorPicker *color_picker,
-                                       LineStream *line_stream)
-{
-    char color[7];
-    const char *line = line_stream_next(line_stream);
-    if (line == NULL) {
-        return -1;
-    }
-
-    if (sscanf(line, "%6s", color) == EOF) {
-        log_fail("Could not read color\n");
-    }
-
-    *color_picker = create_color_picker_from_rgba(hexstr(color));
-
-    return 0;
-}
-
 int color_picker_render(const ColorPicker *color_picker,
                         const Camera *camera)
 {
index 2d60a085fdb132ae9ca6141f7ef3f9a03d6ede30..f0c4817bc2cb5d7e876cd014e8efab7fd75e629a 100644 (file)
@@ -16,13 +16,9 @@ typedef struct {
     Slider sliders[COLOR_SLIDER_N];
 } ColorPicker;
 
-typedef struct LineStream LineStream;
 
 ColorPicker create_color_picker_from_rgba(Color color);
 
-int color_picker_read_from_line_stream(ColorPicker *color_picker,
-                                       LineStream *line_stream);
-
 int color_picker_render(const ColorPicker *color_picker,
                         const Camera *camera);
 int color_picker_event(ColorPicker *color_picker,
index a133301b77558df99d1e16777aa08d9dc0401243..9c7bf9c2507f02a2748c56080c4e8816e0c9913d 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <SDL.h>
 
-#include "system/line_stream.h"
 #include "system/stacktrace.h"
 #include "system/nth_alloc.h"
 #include "system/lt.h"
@@ -200,66 +199,6 @@ LabelLayer *create_label_layer(const char *id_name_prefix)
     return label_layer;
 }
 
-LabelLayer *create_label_layer_from_line_stream(LineStream *line_stream, const char *id_name_prefix)
-{
-    trace_assert(line_stream);
-    LabelLayer *label_layer = create_label_layer(id_name_prefix);
-
-    if (label_layer == NULL) {
-        RETURN_LT(label_layer->lt, NULL);
-    }
-
-    const char *line = line_stream_next(line_stream);
-    if (line == NULL) {
-        log_fail("Could not read amount of labels\n");
-        RETURN_LT(label_layer->lt, NULL);
-    }
-
-    size_t n = 0;
-    if (sscanf(line, "%zu", &n) == EOF) {
-        log_fail("Could not parse amount of labels\n");
-        RETURN_LT(label_layer->lt, NULL);
-    }
-
-    for (size_t i = 0; i < n; ++i) {
-        char hex[7];
-        char id[LABEL_LAYER_ID_MAX_SIZE];
-        Vec2f position;
-
-        line = line_stream_next(line_stream);
-        if (line == NULL) {
-            log_fail("Could not read label meta info\n");
-            RETURN_LT(label_layer->lt, NULL);
-        }
-
-        if (sscanf(
-                line,
-                "%"STRINGIFY(LABEL_LAYER_ID_MAX_SIZE)"s%f%f%6s\n",
-                id, &position.x, &position.y, hex) == EOF) {
-            log_fail("Could not parse label meta info\n");
-            RETURN_LT(label_layer->lt, NULL);
-        }
-
-        Color color = hexstr(hex);
-
-        dynarray_push(&label_layer->ids, id);
-        dynarray_push(&label_layer->positions, &position);
-        dynarray_push(&label_layer->colors, &color);
-
-        line = line_stream_next(line_stream);
-        if (line == NULL) {
-            log_fail("Could not read label text\n");
-        }
-
-        char label_text[LABEL_LAYER_TEXT_MAX_SIZE] = {0};
-        memcpy(label_text, line, LABEL_LAYER_TEXT_MAX_SIZE - 1);
-        trim_endline(label_text);
-        dynarray_push(&label_layer->texts, &label_text);
-    }
-
-    return label_layer;
-}
-
 LabelLayer *chop_label_layer(Memory *memory,
                              String *input,
                              const char *id_name_prefix)
index d2f296b46aea4cb0022bb3bf4cfd340834b72144..00454a1bbf159f72f9fea845f8eb19d856d23246 100644 (file)
 #define LABEL_LAYER_TEXT_MAX_SIZE 256
 
 typedef struct LabelLayer LabelLayer;
-typedef struct LineStream LineStream;
 
 LayerPtr label_layer_as_layer(LabelLayer *label_layer);
 
 // NOTE: create_label_layer and create_label_layer_from_line_stream do
 // not own id_name_prefix
 LabelLayer *create_label_layer(const char *id_name_prefix);
-LabelLayer *create_label_layer_from_line_stream(LineStream *line_stream,
-                                                const char *id_name_prefix);
 LabelLayer *chop_label_layer(Memory *memory,
                              String *input,
                              const char *id_name_prefix);
index f3c312fe12206034a8ae944c7d85c1e551213320..0e7bd8d8e635a9920e7e66ae07c37ba7e84eca3c 100644 (file)
@@ -51,29 +51,6 @@ PlayerLayer create_player_layer(Vec2f position, Color color)
     };
 }
 
-PlayerLayer create_player_layer_from_line_stream(LineStream *line_stream)
-{
-    trace_assert(line_stream);
-
-    const char *line = line_stream_next(line_stream);
-    trace_assert(line);
-
-    char colorstr[7] = "000000";
-    Vec2f position = vec(0.0f, 0.0f);
-
-    const int bound =
-        sscanf(line, "%f%f%6s", &position.x, &position.y, colorstr);
-
-#define BOUND_EXPECTED 3
-    if (bound != BOUND_EXPECTED) {
-        log_fail("Could not read Player Layer properly. Parsed tokens: %d. Expected: %d\n",
-                 bound, BOUND_EXPECTED);
-    }
-#undef BOUND_EXPECTED
-
-    return create_player_layer(position, hexstr(colorstr));
-}
-
 PlayerLayer chop_player_layer(Memory *memory, String *input)
 {
     trace_assert(memory);
index f89d22f147da37fd5f67008b2a67846a9ae25940..6144f3ff0ffa50d56c06a3e0cf99ebdea122e3f9 100644 (file)
@@ -4,7 +4,6 @@
 #include "color_picker.h"
 #include "layer.h"
 #include "system/lt.h"
-#include "system/line_stream.h"
 #include "system/memory.h"
 #include "system/s.h"
 
@@ -15,7 +14,6 @@ typedef struct {
 } PlayerLayer;
 
 PlayerLayer create_player_layer(Vec2f position, Color color);
-PlayerLayer create_player_layer_from_line_stream(LineStream *line_stream);
 PlayerLayer chop_player_layer(Memory *memory, String *input);
 
 LayerPtr player_layer_as_layer(PlayerLayer *player_layer);
index 5eac7322fa226f4b27193d6d54f9f9ba99ecdec3..c0550919315a9e954b5d361825177c25b82059f1 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "dynarray.h"
 #include "game/camera.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
@@ -197,48 +196,6 @@ PointLayer *create_point_layer(const char *id_name_prefix)
     return point_layer;
 }
 
-PointLayer *create_point_layer_from_line_stream(LineStream *line_stream,
-                                                const char *id_name_prefix)
-{
-    trace_assert(line_stream);
-
-    PointLayer *point_layer = create_point_layer(id_name_prefix);
-
-    size_t count = 0;
-    if (sscanf(
-            line_stream_next(line_stream),
-            "%zu",
-            &count) == EOF) {
-        log_fail("Could not read amount of points");
-        RETURN_LT(point_layer->lt, NULL);
-    }
-
-    char color_name[7];
-    char id[ID_MAX_SIZE];
-    float x, y;
-    for (size_t i = 0; i < count; ++i) {
-        if (sscanf(
-                line_stream_next(line_stream),
-                "%"STRINGIFY(ID_MAX_SIZE)"s%f%f%6s",
-                id, &x, &y, color_name) < 0) {
-            log_fail("Could not read %dth goal\n", i);
-            RETURN_LT(point_layer->lt, NULL);
-        }
-        const Color color = hexstr(color_name);
-        const Vec2f point = vec(x, y);
-
-        dynarray_push(&point_layer->colors, &color);
-        dynarray_push(&point_layer->positions, &point);
-        dynarray_push(&point_layer->ids, id);
-    }
-
-    point_layer->selection = -1;
-
-    point_layer->color_picker = create_color_picker_from_rgba(COLOR_RED);
-
-    return point_layer;
-}
-
 PointLayer *chop_point_layer(Memory *memory,
                              String *input,
                              const char *id_name_prefix)
index 81a9d40fa96febdf42b0a74e4d2491d5fb961bd9..d08df7104b541a4f8e86edd2faa9f61f4b1fa9cb 100644 (file)
@@ -8,14 +8,11 @@
 #define ID_MAX_SIZE 36
 
 typedef struct PointLayer PointLayer;
-typedef struct LineStream LineStream;
 
 LayerPtr point_layer_as_layer(PointLayer *point_layer);
 // NOTE: create_point_layer and create_point_layer_from_line_stream do
 // not own id_name_prefix
 PointLayer *create_point_layer(const char *id_name_prefix);
-PointLayer *create_point_layer_from_line_stream(LineStream *line_stream,
-                                                const char *id_name_prefix);
 PointLayer *chop_point_layer(Memory *memory,
                              String *input,
                              const char *id_name_prefix);
index 871197687bbdab1f5e1bb69f1bae11d160f08810..ab2fd14a2f49a0ac39e3a31c7c34755d07bbd881 100644 (file)
@@ -10,7 +10,6 @@
 #include "color.h"
 #include "rect_layer.h"
 #include "dynarray.h"
-#include "system/line_stream.h"
 #include "color_picker.h"
 #include "system/str.h"
 #include "ui/edit_field.h"
@@ -18,6 +17,7 @@
 #include "game/level/action.h"
 #include "action_picker.h"
 #include "game.h"
+#include "math/extrema.h"
 
 #define RECT_LAYER_SELECTION_THICCNESS 15.0f
 #define RECT_LAYER_ID_LABEL_SIZE vec(3.0f, 3.0f)
@@ -886,82 +886,6 @@ RectLayer *create_rect_layer(const char *id_name_prefix, Cursor *cursor)
     return layer;
 }
 
-RectLayer *create_rect_layer_from_line_stream(LineStream *line_stream,
-                                              const char *id_name_prefix,
-                                              Cursor *cursor)
-{
-    trace_assert(line_stream);
-
-    RectLayer *layer = create_rect_layer(id_name_prefix, cursor);
-    if (layer == NULL) {
-        return NULL;
-    }
-
-    const char *line = line_stream_next(line_stream);
-    if (line == NULL) {
-        RETURN_LT(layer->lt, NULL);
-    }
-
-    size_t count = 0;
-    if (sscanf(line, "%zu", &count) < 0) {
-        RETURN_LT(layer->lt, NULL);
-    }
-
-    for (size_t i = 0; i < count; ++i) {
-        line = line_stream_next(line_stream);
-        if (line == NULL) {
-            RETURN_LT(layer->lt, NULL);
-        }
-
-        char hex[7];
-        Rect rect;
-        char id[ENTITY_MAX_ID_SIZE];
-
-        int n = 0;
-        if (sscanf(line,
-                   "%"STRINGIFY(ENTITY_MAX_ID_SIZE)"s%f%f%f%f%6s%n",
-                   id,
-                   &rect.x, &rect.y,
-                   &rect.w, &rect.h,
-                   hex, &n) <= 0) {
-            log_fail("%s\n", strerror(errno));
-            RETURN_LT(layer->lt, NULL);
-        }
-        line += n;
-
-        Color color = hexstr(hex);
-        dynarray_push(&layer->rects, &rect);
-        dynarray_push(&layer->ids, id);
-        dynarray_push(&layer->colors, &color);
-
-        Action action = {
-            .type = ACTION_NONE,
-            .entity_id = {0}
-        };
-
-        if (sscanf(line, "%d%n", (int*)&action.type, &n) > 0) {
-            line += n;
-            switch (action.type) {
-            case ACTION_NONE: break;
-
-            case ACTION_TOGGLE_GOAL:
-            case ACTION_HIDE_LABEL: {
-                if (sscanf(line, "%"STRINGIFY(ENTITY_MAX_ID_SIZE)"s", action.entity_id) <= 0) {
-                    log_fail("%s\n", strerror(errno));
-                    RETURN_LT(layer->lt, NULL);
-                }
-            } break;
-
-            case ACTION_N: break;
-            }
-        }
-
-        dynarray_push(&layer->actions, &action);
-    }
-
-    return layer;
-}
-
 RectLayer *chop_rect_layer(Memory *memory,
                            String *input,
                            const char *id_name_prefix,
index 85bf7979246ee8f397d2e6fb447139a9ad57b317..03ae371732ffbb5b36b7ac3fb6b58a4a3ec58320 100644 (file)
@@ -6,17 +6,12 @@
 #include "ui/cursor.h"
 
 typedef struct RectLayer RectLayer;
-typedef struct LineStream LineStream;
 
 LayerPtr rect_layer_as_layer(RectLayer *layer);
 // NOTE: create_rect_layer and create_rect_layer_from_line_stream does
 // not own id_name_prefix
 RectLayer *create_rect_layer(const char *id_name_prefix,
                              Cursor *cursor);
-RectLayer *create_rect_layer_from_line_stream(
-    LineStream *line_stream,
-    const char *id_name_prefix,
-    Cursor *cursor);
 RectLayer *chop_rect_layer(Memory *memory,
                            String *input,
                            const char *id_name_prefix,
index 6a670db9d60138254806bbd3baebf6b84bf30b4f..67b552ff874ecec977c6cfc81ef153acbaab5f82 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "platforms.h"
 #include "system/lt.h"
-#include "system/line_stream.h"
 #include "system/nth_alloc.h"
 #include "system/log.h"
 #include "game/level/level_editor/rect_layer.h"
index 7f23fc4e56bb66ee5b78a9c7eb6b17de613680dd..373c400b55754ad4dd7934aa3757c6d56e9b3fb3 100644 (file)
@@ -9,7 +9,6 @@
 #include "math/vec.h"
 #include "platforms.h"
 #include "player.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 276c41f0c2fff90ea00f924a28905552b183fc5e..dd34a01fc39e16761ba7dc403d861f21cecf0dd8 100644 (file)
@@ -4,7 +4,6 @@
 #include "player.h"
 #include "regions.h"
 #include "system/str.h"
-#include "system/line_stream.h"
 #include "system/log.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
index 4282f206c4593c7b984525af5e705d7c6a8b1360..019e1f4e7f074a0d1f14ce1f755f85db850b895d 100644 (file)
@@ -6,7 +6,6 @@
 #include "system/lt.h"
 #include "system/nth_alloc.h"
 #include "system/stacktrace.h"
-#include "system/line_stream.h"
 #include "system/str.h"
 #include "system/log.h"
 
@@ -222,7 +221,7 @@ int rigid_bodies_render(RigidBodies *rigid_bodies,
         return -1;
     }
 
-    snprintf(text_buffer, 256, 
+    snprintf(text_buffer, 256,
         "id: %zd\n"
         "p:(%.2f, %.2f)\n"
         "v:(%.2f, %.2f)\n"
diff --git a/src/system/line_stream.c b/src/system/line_stream.c
deleted file mode 100644 (file)
index a061793..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-#include "system/stacktrace.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "line_stream.h"
-#include "lt.h"
-#include "lt_adapters.h"
-#include "system/nth_alloc.h"
-#include "system/log.h"
-#include "system/str.h"
-
-struct LineStream
-{
-    Lt *lt;
-    FILE *stream;
-    char *buffer;
-    size_t capacity;
-    bool unfinished;
-};
-
-// TODO(#905): create_line_stream probably does not need mode
-//   Because LineStream interface doesn't even have anything
-//   for writing to files. So we can just hardcode the mode
-//   inside of the ctor.
-LineStream *create_line_stream(const char *filename,
-                               const char *mode,
-                               size_t capacity)
-{
-    trace_assert(filename);
-    trace_assert(mode);
-
-    Lt *lt = create_lt();
-
-    LineStream *line_stream = PUSH_LT(
-        lt,
-        nth_calloc(1, sizeof(LineStream)),
-        free);
-    if (line_stream == NULL) {
-        RETURN_LT(lt, NULL);
-    }
-    line_stream->lt = lt;
-
-    line_stream->stream = PUSH_LT(
-        lt,
-        fopen(filename, mode),
-        fclose_lt);
-    if (line_stream->stream == NULL) {
-        log_fail("Could not open file '%s': %s\n", filename, strerror(errno));
-        RETURN_LT(lt, NULL);
-    }
-
-    line_stream->buffer = PUSH_LT(
-        lt,
-        nth_calloc(1, sizeof(char) * capacity),
-        free);
-    if (line_stream->buffer == NULL) {
-        RETURN_LT(lt, NULL);
-    }
-
-    line_stream->capacity = capacity;
-    line_stream->unfinished = false;
-
-    return line_stream;
-}
-
-void destroy_line_stream(LineStream *line_stream)
-{
-    trace_assert(line_stream);
-
-    RETURN_LT0(line_stream->lt);
-}
-
-
-const char *line_stream_next_chunk(LineStream *line_stream)
-{
-    trace_assert(line_stream);
-
-    const char *s = fgets(line_stream->buffer,
-                          (int) line_stream->capacity,
-                          line_stream->stream);
-    if (s == NULL) {
-        return NULL;
-    }
-    size_t n = strlen(s);
-    line_stream->unfinished = s[n - 1] != '\n';
-
-    return s;
-}
-
-const char *line_stream_next(LineStream *line_stream)
-{
-    trace_assert(line_stream);
-
-    while (line_stream->unfinished) {
-        line_stream_next_chunk(line_stream);
-    }
-
-    return line_stream_next_chunk(line_stream);
-}
-
-char *line_stream_collect_n_lines(LineStream *line_stream, size_t n)
-{
-    char *result = string_append(NULL, "");
-    for (size_t i = 0; i < n; ++i) {
-        const char *line = line_stream_next(line_stream);
-        if (line == NULL) {
-            free(result);
-            return NULL;
-        }
-
-        result = string_append(result, line);
-    }
-
-    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(#906): 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;
-}
diff --git a/src/system/line_stream.h b/src/system/line_stream.h
deleted file mode 100644 (file)
index 6b90cf5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef LINE_STREAM_H_
-#define LINE_STREAM_H_
-
-#include <stdlib.h>
-
-typedef struct LineStream LineStream;
-
-LineStream *create_line_stream(const char *filename,
-                               const char *mode,
-                               size_t capacity);
-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_
index 688af2d1939effe22e6b3df574492956a012cda0..43ff261cdf590ceb86b306d0c67926b483187ff0 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include "system/stacktrace.h"
 #include "system/memory.h"
 
index 60016b0339d5f5aeac5eb793f441b574b1d80b19..04f81003a40a633f6e3af6a632b7282de30e72f4 100644 (file)
@@ -42,15 +42,3 @@ char *trim_endline(char *s)
 
     return s;
 }
-
-char *string_append(char *prefix, const char *suffix)
-{
-    trace_assert(suffix);
-
-    if (prefix == NULL) {
-        return string_duplicate(suffix, NULL);
-    }
-
-    prefix = nth_realloc(prefix, strlen(prefix) + strlen(suffix) + 1);
-    return strcat(prefix, suffix);
-}
index b780bc220c12dc503de718f4234a10a53e2decf9..f6331031f96f6d79961c15549f635e5e73ad55ab 100644 (file)
@@ -6,8 +6,6 @@
 
 char *string_duplicate(const char *str,
                        const char *str_end);
-char *string_append(char *prefix,
-                    const char *suffix);
 char *trim_endline(char *s);
 
 #endif  // STR_H_