Add RCons.isWindows() and update mini graph test

This commit is contained in:
pancake 2021-09-17 09:24:27 +02:00
parent 34d5c13776
commit d520902ce8
6 changed files with 35 additions and 12 deletions

View File

@ -1,5 +1,5 @@
BIN=r2r BIN=r2r
BINDEPS=r_util BINDEPS=r_util r_cons
OBJ=load.o run.o OBJ=load.o run.o
include ../rules.mk include ../rules.mk

View File

@ -4,6 +4,7 @@ if get_option('enable_r2r')
include_directories: [platform_inc], include_directories: [platform_inc],
dependencies: [ dependencies: [
r_util_dep, r_util_dep,
r_cons_dep,
lrt, lrt,
], ],
install: true, install: true,

View File

@ -875,13 +875,19 @@ static void interact(R2RState *state) {
goto beach; goto beach;
} }
bool use_fancy_stuff = !r_cons_is_windows ();
#if __WINDOWS__ #if __WINDOWS__
// XXX move to rcons
(void)SetConsoleOutputCP (65001); // UTF-8 (void)SetConsoleOutputCP (65001); // UTF-8
#endif #endif
printf ("\n"); printf ("\n");
printf ("#####################\n"); printf ("#####################\n");
printf (" %"PFMT64u" failed test(s) "R_UTF8_POLICE_CARS_REVOLVING_LIGHT"\n", if (use_fancy_stuff) {
(ut64)r_pvector_len (&failed_results)); printf (" %"PFMT64u" failed test(s)"R_UTF8_POLICE_CARS_REVOLVING_LIGHT"\n",
(ut64)r_pvector_len (&failed_results));
} else {
printf (" %"PFMT64u" failed test(s)\n", (ut64)r_pvector_len (&failed_results));
}
r_pvector_foreach (&failed_results, it) { r_pvector_foreach (&failed_results, it) {
R2RTestResultInfo *result = *it; R2RTestResultInfo *result = *it;
@ -893,13 +899,17 @@ static void interact(R2RState *state) {
printf ("#####################\n\n"); printf ("#####################\n\n");
print_result_diff (&state->run_config, result); print_result_diff (&state->run_config, result);
menu: menu:
printf ("Wat do? " if (use_fancy_stuff) {
"(f)ix "R_UTF8_WHITE_HEAVY_CHECK_MARK R_UTF8_VS16 R_UTF8_VS16 R_UTF8_VS16" " printf ("Wat do? "
"(i)gnore "R_UTF8_SEE_NO_EVIL_MONKEY" " "(f)ix "R_UTF8_WHITE_HEAVY_CHECK_MARK R_UTF8_VS16 R_UTF8_VS16 R_UTF8_VS16" "
"(b)roken "R_UTF8_SKULL_AND_CROSSBONES R_UTF8_VS16 R_UTF8_VS16 R_UTF8_VS16" " "(i)gnore "R_UTF8_SEE_NO_EVIL_MONKEY" "
"(c)ommands "R_UTF8_KEYBOARD R_UTF8_VS16" " "(b)roken "R_UTF8_SKULL_AND_CROSSBONES R_UTF8_VS16 R_UTF8_VS16 R_UTF8_VS16" "
"(d)iffchar "R_UTF8_LEFT_POINTING_MAGNIFYING_GLASS" " "(c)ommands "R_UTF8_KEYBOARD R_UTF8_VS16" "
"(q)uit "R_UTF8_DOOR"\n"); "(d)iffchar "R_UTF8_LEFT_POINTING_MAGNIFYING_GLASS" "
"(q)uit "R_UTF8_DOOR"\n");
} else {
printf ("Wat do? (f)ix (i)gnore (b)roken (c)ommands (d)iffchar (q)uit\n");
}
printf ("> "); printf ("> ");
char buf[0x30]; char buf[0x30];
if (!fgets (buf, sizeof (buf), stdin)) { if (!fgets (buf, sizeof (buf), stdin)) {

View File

@ -1438,6 +1438,17 @@ R_API int r_cons_get_cursor(int *rows) {
return col; return col;
} }
R_API bool r_cons_is_windows(void) {
#if __WINDOWS__
return true;
#else
char *e = r_sys_getenv ("WSL_INTEROP");
bool res = R_STR_ISNOTEMPTY (e);
free (e);
return res;
#endif
}
R_API bool r_cons_isatty(void) { R_API bool r_cons_isatty(void) {
#if EMSCRIPTEN || __wasi__ #if EMSCRIPTEN || __wasi__
return false; return false;

View File

@ -884,6 +884,7 @@ R_API void r_cons_memset(char ch, int len);
R_API void r_cons_visual_flush(void); R_API void r_cons_visual_flush(void);
R_API void r_cons_visual_write(char *buffer); R_API void r_cons_visual_write(char *buffer);
R_API bool r_cons_is_utf8(void); R_API bool r_cons_is_utf8(void);
R_API bool r_cons_is_windows(void);
R_API void r_cons_cmd_help(const char * help[], bool use_color); R_API void r_cons_cmd_help(const char * help[], bool use_color);
R_API void r_cons_log_stub(const char *output, const char *funcname, const char *filename, R_API void r_cons_log_stub(const char *output, const char *funcname, const char *filename,
unsigned int lineno, unsigned int level, const char *tag, const char *fmtstr, ...) R_PRINTF_CHECK(7, 8); unsigned int lineno, unsigned int level, const char *tag, const char *fmtstr, ...) R_PRINTF_CHECK(7, 8);

View File

@ -342,7 +342,7 @@ agraph.nodes.sym.imp.strlen.y=0x92
agraph.w=0x146 agraph.w=0x146
() () () () () () () () () () () () * * * * * * * * * * * *
() () () () () () () * * * * * * *
EOF EOF
RUN RUN