mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-16 17:01:53 +00:00
[util] Support utf-8 strings in Sys_Printf
By default. Conversion of quake strings needs to be requested (which is done by nq and qw clients and servers, as well as qfprogs via an option). I got tired of seeing mangled source code in the disassembly.
This commit is contained in:
parent
30f2abb0ad
commit
8ff2c5a747
6 changed files with 18 additions and 7 deletions
|
@ -47,7 +47,7 @@ extern int sys_sleep;
|
||||||
|
|
||||||
extern int developer;
|
extern int developer;
|
||||||
|
|
||||||
|
extern bool sys_quake_encoding;
|
||||||
extern const char sys_char_map[256];
|
extern const char sys_char_map[256];
|
||||||
|
|
||||||
typedef struct date_s {
|
typedef struct date_s {
|
||||||
|
|
|
@ -164,6 +164,7 @@ bool stdin_ready;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The translation table between the graphical font and plain ASCII --KB */
|
/* The translation table between the graphical font and plain ASCII --KB */
|
||||||
|
VISIBLE bool sys_quake_encoding;
|
||||||
VISIBLE const char sys_char_map[256] = {
|
VISIBLE const char sys_char_map[256] = {
|
||||||
0, '#', '#', '#', '#', '.', '#', '#',
|
0, '#', '#', '#', '#', '.', '#', '#',
|
||||||
'#', 9, 10, '#', ' ', 13, '.', '.',
|
'#', 9, 10, '#', ' ', 13, '.', '.',
|
||||||
|
@ -200,9 +201,6 @@ VISIBLE const char sys_char_map[256] = {
|
||||||
'x', 'y', 'z', '{', '|', '}', '~', '<'
|
'x', 'y', 'z', '{', '|', '}', '~', '<'
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXPRINTMSG 4096
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_INTEL_ASM
|
#ifndef USE_INTEL_ASM
|
||||||
void
|
void
|
||||||
Sys_MaskFPUExceptions (void)
|
Sys_MaskFPUExceptions (void)
|
||||||
|
@ -319,9 +317,13 @@ Sys_Print (FILE *stream, const char *fmt, va_list args)
|
||||||
fputs ("Fatal Error: ", stream);
|
fputs ("Fatal Error: ", stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sys_quake_encoding) {
|
||||||
/* translate to ASCII instead of printing [xx] --KB */
|
/* translate to ASCII instead of printing [xx] --KB */
|
||||||
for (p = (unsigned char *) sys_print_msg->str; *p; p++)
|
for (p = (unsigned char *) sys_print_msg->str; *p; p++)
|
||||||
putc (sys_char_map[*p], stream);
|
putc (sys_char_map[*p], stream);
|
||||||
|
} else {
|
||||||
|
fputs (sys_print_msg->str, stream);
|
||||||
|
}
|
||||||
|
|
||||||
if (stream == stderr) {
|
if (stream == stderr) {
|
||||||
fputs ("\n", stream);
|
fputs ("\n", stream);
|
||||||
|
|
|
@ -904,6 +904,7 @@ Host_ExecConfig (cbuf_t *cbuf, int skip_quakerc)
|
||||||
void
|
void
|
||||||
Host_Init (void)
|
Host_Init (void)
|
||||||
{
|
{
|
||||||
|
sys_quake_encoding = true;
|
||||||
Sys_RegisterShutdown (Host_Shutdown, 0);
|
Sys_RegisterShutdown (Host_Shutdown, 0);
|
||||||
Sys_Printf ("Host_Init\n");
|
Sys_Printf ("Host_Init\n");
|
||||||
|
|
||||||
|
|
|
@ -2052,6 +2052,7 @@ Host_Init (void)
|
||||||
cl_cbuf = Cbuf_New (&id_interp);
|
cl_cbuf = Cbuf_New (&id_interp);
|
||||||
cl_stbuf = Cbuf_New (&id_interp);
|
cl_stbuf = Cbuf_New (&id_interp);
|
||||||
|
|
||||||
|
sys_quake_encoding = true;
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
GIB_Init (true);
|
GIB_Init (true);
|
||||||
GIB_Key_Init ();
|
GIB_Key_Init ();
|
||||||
|
|
|
@ -2663,6 +2663,7 @@ SV_Init (void)
|
||||||
sv_cbuf = Cbuf_New (&id_interp);
|
sv_cbuf = Cbuf_New (&id_interp);
|
||||||
sv_args = Cbuf_ArgsNew ();
|
sv_args = Cbuf_ArgsNew ();
|
||||||
|
|
||||||
|
sys_quake_encoding = true;
|
||||||
Sys_RegisterShutdown (SV_Shutdown, 0);
|
Sys_RegisterShutdown (SV_Shutdown, 0);
|
||||||
|
|
||||||
Sys_Init ();
|
Sys_Init ();
|
||||||
|
|
|
@ -102,6 +102,7 @@ static const struct option long_options[] = {
|
||||||
{"modules", no_argument, 0, 'M'},
|
{"modules", no_argument, 0, 'M'},
|
||||||
{"numeric", no_argument, 0, 'n'},
|
{"numeric", no_argument, 0, 'n'},
|
||||||
{"path", required_argument, 0, 'P'},
|
{"path", required_argument, 0, 'P'},
|
||||||
|
{"quake", no_argument, 0, 'Q'},
|
||||||
{"relocs", no_argument, 0, 'r'},
|
{"relocs", no_argument, 0, 'r'},
|
||||||
{"strings", no_argument, 0, 's'},
|
{"strings", no_argument, 0, 's'},
|
||||||
{"types", no_argument, 0, 't'},
|
{"types", no_argument, 0, 't'},
|
||||||
|
@ -119,6 +120,7 @@ static const char *short_options =
|
||||||
"M" // modules
|
"M" // modules
|
||||||
"n" // numeric
|
"n" // numeric
|
||||||
"P:" // path
|
"P:" // path
|
||||||
|
"Q" // quake
|
||||||
"r" // relocs
|
"r" // relocs
|
||||||
"s" // strings
|
"s" // strings
|
||||||
"t" // types
|
"t" // types
|
||||||
|
@ -150,6 +152,7 @@ usage (int status)
|
||||||
" -M, --modules Dump Objective-QuakeC data.\n"
|
" -M, --modules Dump Objective-QuakeC data.\n"
|
||||||
" -n, --numeric Sort globals by address.\n"
|
" -n, --numeric Sort globals by address.\n"
|
||||||
" -P, --path DIR Source path.\n"
|
" -P, --path DIR Source path.\n"
|
||||||
|
" -Q, --quake Expect quake encoding instead of utf-8.\n"
|
||||||
" -r, --relocs Dump reloc information.\n"
|
" -r, --relocs Dump reloc information.\n"
|
||||||
" -s, --strings Dump static strings.\n"
|
" -s, --strings Dump static strings.\n"
|
||||||
" -t, --types Dump type encodings.\n"
|
" -t, --types Dump type encodings.\n"
|
||||||
|
@ -354,6 +357,9 @@ main (int argc, char **argv)
|
||||||
case 'P':
|
case 'P':
|
||||||
source_path = strdup (optarg);
|
source_path = strdup (optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'Q':
|
||||||
|
sys_quake_encoding = true;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
func = &operations[7];
|
func = &operations[7];
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue