Browse Source

change suffix of default output file name when dumping mnemonics

master
CismonX 1 year ago
parent
commit
a4d7098b3c
No known key found for this signature in database GPG Key ID: 315D6652268C5007
  1. 2
      man/u6ac.1
  2. 8
      src/u6ac.c

2
man/u6ac.1

@ -12,7 +12,7 @@ Read and compile Unlambda code from the given \fIsource\-file\fR, or \fBSTDIN\fR
.SH OPTIONS
.TP
\fB\-o\fR, \fB\-\-output\fR=\fIout\-file\fR
Save compiled bytecode to \fIout\-file\fR, defaults to \fIsource\-file\fR name with ".bc" suffix, or \fBSTDOUT\fR if the source file is read from \fBSTDIN\fR.
Save compiled bytecode to \fIout\-file\fR, defaults to \fIsource\-file\fR name with ".bc" (".bc.dump" if \fB\-S\fR option is enabled) suffix, or \fBSTDOUT\fR if the source file is read from \fBSTDIN\fR.
.TP
\fB\-\-add\-prefix\fR[=\fIprefix\-string\fR]
Add \fIprefix\-string\fR to the beginning of \fIout\-file\fR. Defaults to "#!/usr/bin/env u6a\\n".

8
src/u6ac.c

@ -153,13 +153,13 @@ process_options(struct arg_options* options, int argc, char** argv) {
if (options->input_file == stdin) {
goto write_to_stdout;
} else {
if (UNLIKELY(file_name_size + 3 > PATH_MAX - 1)) {
u6a_err_path_too_long(err_toplevel, PATH_MAX - 1, file_name_size + 3);
if (UNLIKELY(file_name_size + 8 > PATH_MAX - 1)) {
u6a_err_path_too_long(err_toplevel, PATH_MAX - 1, file_name_size + 8);
return false;
}
options->output_file_name = malloc((file_name_size + 4) * sizeof(char));
options->output_file_name = malloc((file_name_size + 9) * sizeof(char));
strcpy(options->output_file_name, options->input_file_name);
strcpy(options->output_file_name + file_name_size, ".bc\0");
strcpy(options->output_file_name + file_name_size, options->dump_mnemonics ? ".bc.dump\0" : ".bc\0");
}
} else if (strlen(options->output_file_name) == 1 && options->output_file_name[0] == '-') {
write_to_stdout:

Loading…
Cancel
Save