write fewer spaces to C file
This commit is contained in:
parent
e4b7f5335f
commit
46145fa975
10
src/main.cc
10
src/main.cc
@ -43,19 +43,18 @@ bool preprocess(const char * input_fname)
|
|||||||
|
|
||||||
void write_node(FILE * file, Node * node)
|
void write_node(FILE * file, Node * node)
|
||||||
{
|
{
|
||||||
|
static bool write_space = false;
|
||||||
switch (node->type)
|
switch (node->type)
|
||||||
{
|
{
|
||||||
case NODE_TYPE_LIST:
|
case NODE_TYPE_LIST:
|
||||||
{
|
{
|
||||||
bool space = false;
|
|
||||||
for (auto subnode : *node->list)
|
for (auto subnode : *node->list)
|
||||||
{
|
{
|
||||||
if (space)
|
if (write_space)
|
||||||
{
|
{
|
||||||
fprintf(file, " ");
|
fprintf(file, " ");
|
||||||
}
|
}
|
||||||
write_node(file, subnode);
|
write_node(file, subnode);
|
||||||
space = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -64,6 +63,11 @@ void write_node(FILE * file, Node * node)
|
|||||||
if (*node->token.text == ";")
|
if (*node->token.text == ";")
|
||||||
{
|
{
|
||||||
fprintf(file, "\n");
|
fprintf(file, "\n");
|
||||||
|
write_space = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
write_space = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user