add: dprintf for Windows
This commit is contained in:
@@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
extern int dprintf(int stream, const char *format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
void api_put() {
|
void api_put() {
|
||||||
int mode = state->STACK[state->STACK_IDX--]; // 1 for char, 2 for num
|
int mode = state->STACK[state->STACK_IDX--]; // 1 for char, 2 for num
|
||||||
if (mode != 1 && mode != 2) return;
|
if (mode != 1 && mode != 2) return;
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
#define MAX_LINE 1024
|
#define MAX_LINE 1024
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
extern int dprintf(int stream, const char *format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t line_count = 0;
|
size_t line_count = 0;
|
||||||
int read_script(const char *filename, char ***buf, size_t *lines) {
|
int read_script(const char *filename, char ***buf, size_t *lines) {
|
||||||
FILE *script = fopen(filename, "r");
|
FILE *script = fopen(filename, "r");
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
extern int dprintf(int stream, const char *format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
s_state *state = NULL;
|
s_state *state = NULL;
|
||||||
int init_state() {
|
int init_state() {
|
||||||
state = malloc(sizeof(s_state));
|
state = malloc(sizeof(s_state));
|
||||||
|
|||||||
16
src/pasm.c
16
src/pasm.c
@@ -8,6 +8,22 @@
|
|||||||
|
|
||||||
int fstream = 0;
|
int fstream = 0;
|
||||||
int pasm_debug_mode = 0;
|
int pasm_debug_mode = 0;
|
||||||
|
|
||||||
|
#ifdef _WIN32 // i swear i hate windows at this point
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
int dprintf(int stream, const char * format, ...) {
|
||||||
|
char buf[256] = {0}; //might overflow but whatever, fuck Windows
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
int wrote = vsprintf(buf, format, args);
|
||||||
|
_write(stream, buf, sizeof(buf));
|
||||||
|
va_end(args);
|
||||||
|
return wrote;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void show_error(size_t line, char *line_) {
|
void show_error(size_t line, char *line_) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int wrote = dprintf(fstream, "%llu| ", line + 1);
|
int wrote = dprintf(fstream, "%llu| ", line + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user