mirror of
https://github.com/ksherlock/merlin-utils.git
synced 2024-09-11 07:54:30 +00:00
make it compile.
This commit is contained in:
parent
6d57976091
commit
671c81a754
28
link.cpp
28
link.cpp
@ -26,6 +26,7 @@
|
||||
#include "omf.h"
|
||||
#include "rel.h"
|
||||
#include "link.h"
|
||||
#include "script.h"
|
||||
|
||||
void save_omf(const std::string &path, std::vector<omf::segment> &segments, bool compress, bool expressload);
|
||||
int set_file_type(const std::string &path, uint16_t file_type, uint32_t aux_type, std::error_code &ec);
|
||||
@ -420,7 +421,7 @@ namespace {
|
||||
uint32_t active_bits = 1;
|
||||
bool active = true;
|
||||
|
||||
std::unordered_map<std::string, uint32_t> symbol_table;
|
||||
std::unordered_map<std::string, uint32_t> local_symbol_table;
|
||||
|
||||
}
|
||||
|
||||
@ -463,7 +464,8 @@ void evaluate(label_t label, opcode_t opcode, operand_t operand) {
|
||||
if (!end && lkv == 2) {
|
||||
/* finish up */
|
||||
segments.pop_back();
|
||||
finish();
|
||||
if (!segments.empty())
|
||||
finish();
|
||||
}
|
||||
end = true;
|
||||
break;
|
||||
@ -471,13 +473,13 @@ void evaluate(label_t label, opcode_t opcode, operand_t operand) {
|
||||
case OP_DAT: {
|
||||
/* 29-DEC-88 4:18:37 PM */
|
||||
time_t t = time(nullptr);
|
||||
struct tm tm = localtime(&t);
|
||||
struct tm *tm = localtime(&t);
|
||||
char buffer[32];
|
||||
|
||||
strftime(buffer, sizeof(buffer), "%d-%b-%y %H:%M:%S %p", tm);
|
||||
for(char &c : buffer) c = std::toupper(c);
|
||||
|
||||
printf(stdout, "%s\n", buffer);
|
||||
fprintf(stdout, "%s\n", buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -539,7 +541,6 @@ void evaluate(label_t label, opcode_t opcode, operand_t operand) {
|
||||
seg.segname = std::get<std::string>(operand);
|
||||
seg.kind = kind;
|
||||
|
||||
/* if this is the first segment, also save the
|
||||
/* add a new segment */
|
||||
segments.emplace_back();
|
||||
}
|
||||
@ -560,13 +561,17 @@ void process_script(const char *path) {
|
||||
|
||||
extern void parse_line(const char *);
|
||||
|
||||
FILE *fp;
|
||||
fp = fopen(path, "r");
|
||||
if (!fp) {
|
||||
warn("Unable to open %s", path);
|
||||
return -1;
|
||||
FILE *fp = nullptr;
|
||||
|
||||
if (!path || !strcmp(path, "-")) fp = stdin;
|
||||
else {
|
||||
fp = fopen(path, "r");
|
||||
if (!fp) {
|
||||
err(1, "Unable to open %s", path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int no = 1;
|
||||
int errors = 0;
|
||||
char *line = NULL;
|
||||
@ -598,7 +603,8 @@ void process_script(const char *path) {
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
free(line);
|
||||
exit(errors ? EX_DATAERR : 0);
|
||||
}
|
||||
|
2
main.cpp
2
main.cpp
@ -150,7 +150,7 @@ int main(int argc, char **argv) {
|
||||
if (script && argc > 1) usage(EX_USAGE);
|
||||
if (argc == 1 && is_S(*argv)) script = true;
|
||||
|
||||
if (script) process_script(*argv);
|
||||
if (script) process_script(argc ? *argv : nullptr);
|
||||
else process_files(argc, argv);
|
||||
|
||||
exit(0);
|
||||
|
26
script.h
Normal file
26
script.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef script_h
|
||||
#define script_h
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
typedef std::string label_t;
|
||||
typedef std::variant<std::monostate, uint32_t, std::string> operand_t;
|
||||
|
||||
enum opcode_t {
|
||||
|
||||
OP_NONE = 0,
|
||||
#define x(op) OP_##op,
|
||||
#include "ops.h"
|
||||
#undef x
|
||||
OP_EQ
|
||||
};
|
||||
|
||||
enum {
|
||||
OVR_NONE = 1,
|
||||
OVR_ALL = -1,
|
||||
OVR_OFF = 0
|
||||
};
|
||||
|
||||
#endif
|
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
namespace {
|
||||
std::unordered_map<std::string, int> opcodes = {
|
||||
std::unordered_map<std::string, opcode_t> opcodes = {
|
||||
#define x(op) { #op, OP_##op },
|
||||
|
||||
#include "ops.h"
|
||||
@ -496,7 +496,7 @@ operand:
|
||||
}
|
||||
|
||||
case OP_CMD:
|
||||
str_operand = std::string(YYCURSOR);
|
||||
operand = std::string(YYCURSOR);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user