Rename _buffer to buffer, expand tabs to spaces in src/ and tests/ and move up BUFFER_SIZE macro definition

This commit is contained in:
Benjamin Loison 2023-01-03 22:58:38 +01:00
parent 5cabb042fc
commit 69e84f0a8e
5 changed files with 15 additions and 16 deletions

View File

@ -315,7 +315,7 @@ let ast_to_c fmt verbose debug prog =
let prog_st_types = make_state_types prog in
debug (Format.asprintf "%a" dump_var_locations prog_st_types);
let iprog: i_nodelist = ast_to_intermediate_ast prog prog_st_types in
Format.fprintf fmt "%a\n\n%a\n\n%a\n\n/* Nodes: */\n%a%a\n"
Format.fprintf fmt "%a\n\n#define BUFFER_SIZE 1024\n\n%a\n\n%a\n\n/* Nodes: */\n%a%a\n"
cp_includes (Config.c_includes)
cp_state_types prog_st_types
cp_state_frees (iprog, prog_st_types)

View File

@ -424,21 +424,20 @@ let cp_main_fn fmt (prog, sts) =
| Some node ->
Format.fprintf fmt "int main (int argc, char **argv)\n\
{\n%a\n\
\t#define BUFFER_SIZE 1024\n\
\tchar _buffer[BUFFER_SIZE];\n\
\tchar buffer[BUFFER_SIZE];\n\
\tt_state_main state;\n\
\tstate.is_init = true;\n\
\tstate.is_reset = false;\n\
\twhile(true) {\n\
\t\tprintf(\"input: \");\n\
\t\tfor(unsigned short idx = 0; idx < BUFFER_SIZE; idx++) {\n\
\t\t\tif(idx == (BUFFER_SIZE - 1) || (_buffer[idx] = getchar()) == '\\n') {\n\
\t\t\t\t_buffer[idx] = '\\0';\n\
\t\t\tif(idx == (BUFFER_SIZE - 1) || (buffer[idx] = getchar()) == '\\n') {\n\
\t\t\t\tbuffer[idx] = '\\0';\n\
\t\t\t\tbreak;\n\
\t\t\t}\n\
\t\t}\n\
\t\tif(!strcmp(_buffer, \"exit\")) { break; }\n\
\t\tsscanf(_buffer, %a);\n%a\
\t\tif(!strcmp(buffer, \"exit\")) { break; }\n\
\t\tsscanf(buffer, %a);\n%a\
\t\tfn_main(&state, %a);\n\
\t\tprintf(\"output: \");\n\
\t\tprintf(%a);\n\