From 6011411211d262d6f594cc9d239d57dbfc95047b Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Thu, 11 Jun 2020 19:52:08 +0200 Subject: bessere Steuerung für inline/static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csv-test.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'csv-test.c') diff --git a/csv-test.c b/csv-test.c index c414c98..ccf9bad 100644 --- a/csv-test.c +++ b/csv-test.c @@ -4,6 +4,8 @@ #include #include +#define INLINE static inline + /* === CSV-STRING Interface === */ typedef struct { @@ -11,7 +13,7 @@ typedef struct { int cap, pos; } csv_string_t; -static void +INLINE void csv_string_init(csv_string_t *csv_string) { static const int INITIAL_CAP = 16; @@ -22,19 +24,19 @@ csv_string_init(csv_string_t *csv_string) } } -static void +INLINE void csv_string_reset(csv_string_t *csv_string) { csv_string->pos = 0; } -static bool +INLINE bool csv_string_empty(csv_string_t *csv_string) { return ( csv_string->pos == 0 ) ? true : false; } -inline static void +INLINE void csv_string_append(csv_string_t *csv_string, int ch) { if ( csv_string->pos == csv_string->cap ) { /* grow if needed */ @@ -50,7 +52,7 @@ csv_string_append(csv_string_t *csv_string, int ch) csv_string->str[csv_string->pos++] = ch; /* append char */ } -static void +INLINE void csv_string_free(csv_string_t *csv_string) { free(csv_string->str); @@ -63,7 +65,7 @@ typedef struct { int cap, pos; } csv_field_t; -static void +INLINE void csv_field_init(csv_field_t *csv_field) { static const size_t INITIAL_CAP = 16; @@ -74,13 +76,13 @@ csv_field_init(csv_field_t *csv_field) } } -static void +INLINE void csv_field_reset(csv_field_t *csv_field) { csv_field->pos = 0; } -static void +INLINE void csv_field_append(csv_field_t *csv_field, int idx) { if ( csv_field->pos == csv_field->cap ) { /* grow if needed */ @@ -96,7 +98,7 @@ csv_field_append(csv_field_t *csv_field, int idx) csv_field->fields[csv_field->pos++] = idx; /* append idx */ } -static void +INLINE void csv_field_free(csv_field_t *csv_field) { free(csv_field->fields); @@ -297,6 +299,8 @@ main(void) csv_t csv[1]; int n, line = 0; + setvbuf(stdin, NULL, _IOFBF, 16384); + #if 0 char data[] = "\"\"aaa\",\"b\"\"bb\",\"ccc\"\n" "zzz,,yyy,xxx\n" -- cgit v1.3