summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2020-01-03 14:46:15 +0200
committerAdrian Thurston <thurston@colm.net>2020-01-03 14:46:15 +0200
commit4c641cd2f8c9e8959c73ed64c6df7c0f8c8e7d4f (patch)
treeb968428b25371b7ef13202e2f1991804ac273bfa
parent249679f1ae83d72c09c058dcd7e055924378c0dd (diff)
downloadragel-4c641cd2f8c9e8959c73ed64c6df7c0f8c8e7d4f.tar.gz
colm: folding some long lines in input and stream implementations
-rw-r--r--colm/input.c54
-rw-r--r--colm/stream.c51
2 files changed, 70 insertions, 35 deletions
diff --git a/colm/input.c b/colm/input.c
index ba4643ee..b8101c6f 100644
--- a/colm/input.c
+++ b/colm/input.c
@@ -77,7 +77,8 @@ static struct seq_buf *new_seq_buf()
return rb;
}
-static void input_transfer_loc( struct colm_program *prg, location_t *loc, struct input_impl_seq *ss )
+static void input_transfer_loc( struct colm_program *prg, location_t *loc,
+ struct input_impl_seq *ss )
{
}
@@ -93,7 +94,8 @@ static void colm_input_destroy( program_t *prg, tree_t **sp, struct_t *s )
si->funcs->destructor( prg, sp, si );
}
-static void input_stream_stash_head( struct colm_program *prg, struct input_impl_seq *si, struct seq_buf *seq_buf )
+static void input_stream_stash_head( struct colm_program *prg,
+ struct input_impl_seq *si, struct seq_buf *seq_buf )
{
debug( prg, REALM_INPUT, "stash_head: stream %p buf %p\n", si, seq_buf );
seq_buf->next = si->stash;
@@ -237,18 +239,21 @@ static void input_destructor( program_t *prg, tree_t **sp, struct input_impl_seq
free( si );
}
-static int input_get_option( struct colm_program *prg, struct input_impl_seq *ii, int option )
+static int input_get_option( struct colm_program *prg, struct input_impl_seq *ii,
+ int option )
{
return ii->auto_trim;
}
-static void input_set_option( struct colm_program *prg, struct input_impl_seq *ii, int option, int value )
+static void input_set_option( struct colm_program *prg, struct input_impl_seq *ii,
+ int option, int value )
{
ii->auto_trim = value ? 1 : 0;
}
-static int input_get_parse_block( struct colm_program *prg, struct input_impl_seq *is, int *pskip, char **pdp, int *copied )
+static int input_get_parse_block( struct colm_program *prg, struct input_impl_seq *is,
+ int *pskip, char **pdp, int *copied )
{
int ret = 0;
*copied = 0;
@@ -292,7 +297,8 @@ static int input_get_parse_block( struct colm_program *prg, struct input_impl_se
switch ( ret ) {
case INPUT_DATA:
if ( *pdp != 0 ) {
- debug( prg, REALM_INPUT, "get parse block: DATA: %d %.*s\n", *copied, (int)(*copied), *pdp );
+ debug( prg, REALM_INPUT, "get parse block: DATA: %d %.*s\n",
+ *copied, (int)(*copied), *pdp );
}
else {
debug( prg, REALM_INPUT, "get parse block: DATA: %d\n", *copied );
@@ -319,7 +325,8 @@ static int input_get_parse_block( struct colm_program *prg, struct input_impl_se
return ret;
}
-static int input_get_data( struct colm_program *prg, struct input_impl_seq *is, char *dest, int length )
+static int input_get_data( struct colm_program *prg, struct input_impl_seq *is,
+ char *dest, int length )
{
int copied = 0;
@@ -364,7 +371,8 @@ static int input_get_data( struct colm_program *prg, struct input_impl_seq *is,
* Consume
*/
-static int input_consume_data( struct colm_program *prg, struct input_impl_seq *si, int length, location_t *loc )
+static int input_consume_data( struct colm_program *prg, struct input_impl_seq *si,
+ int length, location_t *loc )
{
debug( prg, REALM_INPUT, "input_consume_data: stream %p consuming %d bytes\n", si, length );
@@ -405,7 +413,8 @@ static int input_consume_data( struct colm_program *prg, struct input_impl_seq *
return consumed;
}
-static int input_undo_consume_data( struct colm_program *prg, struct input_impl_seq *si, const char *data, int length )
+static int input_undo_consume_data( struct colm_program *prg, struct input_impl_seq *si,
+ const char *data, int length )
{
/* When we push back data we need to move backwards through the block of
* text. The source stream type will */
@@ -445,7 +454,8 @@ static tree_t *input_consume_tree( struct colm_program *prg, struct input_impl_s
input_stream_stash_head( prg, si, seq_buf );
}
- assert( si->queue.head != 0 && ( si->queue.head->type == SB_TOKEN || si->queue.head->type == SB_IGNORE ) );
+ assert( si->queue.head != 0 && ( si->queue.head->type == SB_TOKEN ||
+ si->queue.head->type == SB_IGNORE ) );
{
struct seq_buf *seq_buf = input_stream_seq_pop_head( si );
@@ -459,9 +469,11 @@ static tree_t *input_consume_tree( struct colm_program *prg, struct input_impl_s
}
-static void input_undo_consume_tree( struct colm_program *prg, struct input_impl_seq *si, tree_t *tree, int ignore )
+static void input_undo_consume_tree( struct colm_program *prg, struct input_impl_seq *si,
+ tree_t *tree, int ignore )
{
- debug( prg, REALM_INPUT, "input_undo_consume_tree: stream %p undo consume tree %p\n", si, tree );
+ debug( prg, REALM_INPUT, "input_undo_consume_tree: stream %p undo "
+ "consume tree %p\n", si, tree );
while ( true ) {
debug( prg, REALM_INPUT, " stream %p consume: clearing source type\n", si );
@@ -479,7 +491,8 @@ static void input_undo_consume_tree( struct colm_program *prg, struct input_impl
/*
* Prepend
*/
-static void input_prepend_data( struct colm_program *prg, struct input_impl_seq *si, const char *data, long length )
+static void input_prepend_data( struct colm_program *prg, struct input_impl_seq *si,
+ const char *data, long length )
{
debug( prg, REALM_INPUT, "input_prepend_data: stream %p prepend data length %d\n", si, length );
@@ -497,7 +510,8 @@ static void input_prepend_data( struct colm_program *prg, struct input_impl_seq
static int input_undo_prepend_data( struct colm_program *prg, struct input_impl_seq *si, int length )
{
- debug( prg, REALM_INPUT, "input_undo_prepend_data: stream %p undo append data length %d\n", si, length );
+ debug( prg, REALM_INPUT, "input_undo_prepend_data: stream %p undo "
+ "append data length %d\n", si, length );
struct seq_buf *seq_buf = input_stream_seq_pop_head( si );
free( seq_buf );
@@ -505,7 +519,8 @@ static int input_undo_prepend_data( struct colm_program *prg, struct input_impl_
return 0;
}
-static void input_prepend_tree( struct colm_program *prg, struct input_impl_seq *si, tree_t *tree, int ignore )
+static void input_prepend_tree( struct colm_program *prg, struct input_impl_seq *si,
+ tree_t *tree, int ignore )
{
debug( prg, REALM_INPUT, "input_prepend_tree: stream %p prepend tree %p\n", si, tree );
@@ -538,7 +553,8 @@ static tree_t *input_undo_prepend_tree( struct colm_program *prg, struct input_i
}
-static void input_prepend_stream( struct colm_program *prg, struct input_impl_seq *si, struct colm_stream *stream )
+static void input_prepend_stream( struct colm_program *prg, struct input_impl_seq *si,
+ struct colm_stream *stream )
{
maybe_split( prg, si );
@@ -560,7 +576,8 @@ static tree_t *input_undo_prepend_stream( struct colm_program *prg, struct input
return 0;
}
-static void input_append_data( struct colm_program *prg, struct input_impl_seq *si, const char *data, long length )
+static void input_append_data( struct colm_program *prg, struct input_impl_seq *si,
+ const char *data, long length )
{
debug( prg, REALM_INPUT, "input_append_data: stream %p append data length %d\n", si, length );
@@ -638,7 +655,8 @@ static tree_t *input_undo_append_tree( struct colm_program *prg, struct input_im
return tree;
}
-static void input_append_stream( struct colm_program *prg, struct input_impl_seq *si, struct colm_stream *stream )
+static void input_append_stream( struct colm_program *prg, struct input_impl_seq *si,
+ struct colm_stream *stream )
{
debug( prg, REALM_INPUT, "input_append_stream: stream %p append stream %p\n", si, stream );
diff --git a/colm/stream.c b/colm/stream.c
index 341197e5..0aa836dd 100644
--- a/colm/stream.c
+++ b/colm/stream.c
@@ -207,7 +207,8 @@ void undo_position_data( struct stream_impl_data *is, const char *data, long len
* Interface
*/
-static void data_transfer_loc( struct colm_program *prg, location_t *loc, struct stream_impl_data *ss )
+static void data_transfer_loc( struct colm_program *prg, location_t *loc,
+ struct stream_impl_data *ss )
{
loc->name = ss->name;
loc->line = ss->line;
@@ -219,7 +220,8 @@ static void data_transfer_loc( struct colm_program *prg, location_t *loc, struct
* Data inputs: files, strings, etc.
*/
-static int data_get_data( struct colm_program *prg, struct stream_impl_data *ss, char *dest, int length )
+static int data_get_data( struct colm_program *prg, struct stream_impl_data *ss,
+ char *dest, int length )
{
int copied = 0;
@@ -229,7 +231,8 @@ static int data_get_data( struct colm_program *prg, struct stream_impl_data *ss,
if ( buf == 0 ) {
/* Got through the in-mem buffers without copying anything. */
struct run_buf *run_buf = new_run_buf( 0 );
- int received = ss->funcs->get_data_source( prg, (struct stream_impl*)ss, run_buf->data, FSM_BUFSIZE );
+ int received = ss->funcs->get_data_source( prg,
+ (struct stream_impl*)ss, run_buf->data, FSM_BUFSIZE );
if ( received == 0 ) {
free( run_buf );
break;
@@ -276,7 +279,8 @@ static struct stream_impl *data_split_consumed( program_t *prg, struct stream_im
return split_off;
}
-int data_append_data( struct colm_program *prg, struct stream_impl_data *sid, const char *data, int length )
+int data_append_data( struct colm_program *prg, struct stream_impl_data *sid,
+ const char *data, int length )
{
struct run_buf *tail = sid->queue.tail;
if ( tail == 0 || length > (FSM_BUFSIZE - tail->length) ) {
@@ -409,7 +413,8 @@ static void data_print_tree( struct colm_program *prg, tree_t **sp,
colm_print_tree_collect( prg, sp, si->collect, tree, trim );
}
-static int data_get_parse_block( struct colm_program *prg, struct stream_impl_data *ss, int *pskip, char **pdp, int *copied )
+static int data_get_parse_block( struct colm_program *prg, struct stream_impl_data *ss,
+ int *pskip, char **pdp, int *copied )
{
int ret = 0;
*copied = 0;
@@ -420,7 +425,8 @@ static int data_get_parse_block( struct colm_program *prg, struct stream_impl_da
if ( buf == 0 ) {
/* Got through the in-mem buffers without copying anything. */
struct run_buf *run_buf = new_run_buf( 0 );
- int received = ss->funcs->get_data_source( prg, (struct stream_impl*)ss, run_buf->data, FSM_BUFSIZE );
+ int received = ss->funcs->get_data_source( prg,
+ (struct stream_impl*)ss, run_buf->data, FSM_BUFSIZE );
if ( received == 0 ) {
free( run_buf );
ret = INPUT_EOD;
@@ -470,7 +476,8 @@ static int data_get_parse_block( struct colm_program *prg, struct stream_impl_da
return ret;
}
-static int data_consume_data( struct colm_program *prg, struct stream_impl_data *sid, int length, location_t *loc )
+static int data_consume_data( struct colm_program *prg, struct stream_impl_data *sid,
+ int length, location_t *loc )
{
int consumed = 0;
int remaining = length;
@@ -515,7 +522,8 @@ static int data_consume_data( struct colm_program *prg, struct stream_impl_data
return consumed;
}
-static int data_undo_consume_data( struct colm_program *prg, struct stream_impl_data *sid, const char *data, int length )
+static int data_undo_consume_data( struct colm_program *prg, struct stream_impl_data *sid,
+ const char *data, int length )
{
const char *end = data + length;
int amount = length;
@@ -548,7 +556,8 @@ static int data_undo_consume_data( struct colm_program *prg, struct stream_impl_
}
debug( prg, REALM_INPUT, "data_undo_consume_data: stream %p "
- "undid consume %d of %d bytes, consumed now %d, \n", sid, amount, length, sid->consumed );
+ "undid consume %d of %d bytes, consumed now %d, \n",
+ sid, amount, length, sid->consumed );
#ifdef DEBUG
dump_contents( prg, sid );
@@ -561,7 +570,8 @@ static int data_undo_consume_data( struct colm_program *prg, struct stream_impl_
* File Inputs
*/
-static int file_get_data_source( struct colm_program *prg, struct stream_impl_data *si, char *dest, int length )
+static int file_get_data_source( struct colm_program *prg, struct stream_impl_data *si,
+ char *dest, int length )
{
return fread( dest, 1, length, si->file );
}
@@ -570,7 +580,8 @@ static int file_get_data_source( struct colm_program *prg, struct stream_impl_da
* Text inputs
*/
-static int accum_get_data_source( struct colm_program *prg, struct stream_impl_data *si, char *dest, int want )
+static int accum_get_data_source( struct colm_program *prg, struct stream_impl_data *si,
+ char *dest, int want )
{
long avail = si->dlen - si->offset;
long take = avail < want ? avail : want;
@@ -655,7 +666,8 @@ static void si_data_init( struct stream_impl_data *is, char *name )
struct stream_impl *colm_impl_new_accum( char *name )
{
- struct stream_impl_data *si = (struct stream_impl_data*)malloc(sizeof(struct stream_impl_data));
+ struct stream_impl_data *si = (struct stream_impl_data*)
+ malloc(sizeof(struct stream_impl_data));
si_data_init( si, name );
si->funcs = (struct stream_funcs*)&accum_funcs;
@@ -664,7 +676,8 @@ struct stream_impl *colm_impl_new_accum( char *name )
static struct stream_impl *colm_impl_new_file( char *name, FILE *file )
{
- struct stream_impl_data *ss = (struct stream_impl_data*)malloc(sizeof(struct stream_impl_data));
+ struct stream_impl_data *ss = (struct stream_impl_data*)
+ malloc(sizeof(struct stream_impl_data));
si_data_init( ss, name );
ss->funcs = (struct stream_funcs*)&file_funcs;
ss->file = file;
@@ -673,7 +686,8 @@ static struct stream_impl *colm_impl_new_file( char *name, FILE *file )
static struct stream_impl *colm_impl_new_fd( char *name, long fd )
{
- struct stream_impl_data *si = (struct stream_impl_data*)malloc(sizeof(struct stream_impl_data));
+ struct stream_impl_data *si = (struct stream_impl_data*)
+ malloc(sizeof(struct stream_impl_data));
si_data_init( si, name );
si->funcs = (struct stream_funcs*)&file_funcs;
si->file = fdopen( fd, ( fd == 0 ) ? "r" : "w" );
@@ -682,7 +696,8 @@ static struct stream_impl *colm_impl_new_fd( char *name, long fd )
struct stream_impl *colm_impl_consumed( char *name, int len )
{
- struct stream_impl_data *si = (struct stream_impl_data*)malloc(sizeof(struct stream_impl_data));
+ struct stream_impl_data *si = (struct stream_impl_data*)
+ malloc(sizeof(struct stream_impl_data));
si_data_init( si, name );
si->funcs = (struct stream_funcs*)&accum_funcs;
@@ -697,7 +712,8 @@ struct stream_impl *colm_impl_consumed( char *name, int len )
struct stream_impl *colm_impl_new_text( char *name, const char *data, int len )
{
- struct stream_impl_data *si = (struct stream_impl_data*)malloc(sizeof(struct stream_impl_data));
+ struct stream_impl_data *si = (struct stream_impl_data*)
+ malloc(sizeof(struct stream_impl_data));
si_data_init( si, name );
si->funcs = (struct stream_funcs*)&accum_funcs;
@@ -712,7 +728,8 @@ struct stream_impl *colm_impl_new_text( char *name, const char *data, int len )
struct stream_impl *colm_impl_new_collect( char *name )
{
- struct stream_impl_data *ss = (struct stream_impl_data*)malloc(sizeof(struct stream_impl_data));
+ struct stream_impl_data *ss = (struct stream_impl_data*)
+ malloc(sizeof(struct stream_impl_data));
si_data_init( ss, name );
ss->funcs = (struct stream_funcs*)&accum_funcs;
ss->collect = (struct colm_str_collect*) malloc( sizeof( struct colm_str_collect ) );