mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 12:00:38 +00:00
util_strncmpexact
This commit is contained in:
parent
6b52c66d11
commit
99971b7806
5 changed files with 38 additions and 37 deletions
2
asm.c
2
asm.c
|
@ -576,7 +576,7 @@ static GMQCC_INLINE bool asm_parse_stmt(const char *skip, size_t line, asm_state
|
|||
*strchr(Y, ' ')='\0'; \
|
||||
} \
|
||||
for (; f<asm_symbols_elements; f++) { \
|
||||
if (!strcnmp(asm_symbols_data[f].name, (Y), strlen(Y)) && \
|
||||
if (!strncmp(asm_symbols_data[f].name, (Y), strlen(Y)) && \
|
||||
asm_symbols_data[f].type == TYPE_FUNCTION) { \
|
||||
(X)=asm_symbols_data[f].offset; \
|
||||
goto OPCCAT(foundf, __LINE__); \
|
||||
|
|
39
data/test.qs
39
data/test.qs
|
@ -82,29 +82,22 @@ FUNCTION: pow, $97
|
|||
FUNCTION: findfloat, $98
|
||||
FUNCTION: checkextension, $99
|
||||
|
||||
FUNCTION: test #0
|
||||
FLOAT: x, 100
|
||||
FLOAT: y, 200
|
||||
|
||||
;code_chars_put("m_init", 0x6);
|
||||
;code_chars_put("m_keydown", 0x9);
|
||||
;code_chars_put("m_draw", 0x6);
|
||||
;code_chars_put("m_toggle", 0x8);
|
||||
;code_chars_put("m_shutdown", 0xA);
|
||||
FLOAT: r_mul
|
||||
FLOAT: r_div
|
||||
FLOAT: r_add
|
||||
FLOAT: r_sub
|
||||
|
||||
FUNCTION: m_init #0
|
||||
CALL0 dprint
|
||||
END
|
||||
|
||||
FUNCTION: m_keydown #0
|
||||
CALL0 dprint
|
||||
END
|
||||
|
||||
FUNCTION: m_draw #3VVV
|
||||
CALL0 dprint
|
||||
END
|
||||
|
||||
FUNCTION: m_toggle #1S
|
||||
CALL0 dprint
|
||||
END
|
||||
|
||||
FUNCTION: m_shutdown #1S
|
||||
CALL0 dprint
|
||||
MUL_V x,y,r_mul
|
||||
DIV_V x,y,r_div
|
||||
ADD_V x,y,r_add
|
||||
SUV_V x,y,r_sub
|
||||
|
||||
STORE_V r_mul
|
||||
CALL0 dprint
|
||||
|
||||
STORE_V
|
||||
END
|
||||
|
|
1
gmqcc.h
1
gmqcc.h
|
@ -256,6 +256,7 @@ void util_meminfo ();
|
|||
|
||||
bool util_strupper (const char *);
|
||||
bool util_strdigit (const char *);
|
||||
bool util_strncmpexact (const char *, const char *, size_t);
|
||||
char *util_strdup (const char *);
|
||||
char *util_strrq (const char *);
|
||||
char *util_strrnl (const char *);
|
||||
|
|
25
main.c
25
main.c
|
@ -101,18 +101,18 @@ int main(int argc, char **argv) {
|
|||
case 'i': { param_argument(2); break; } /* includes */
|
||||
#undef parm_argument
|
||||
default:
|
||||
if (!strncmp(&argv[1][1], "debug" , 5)) { opts_debug = true; break; }
|
||||
if (!strncmp(&argv[1][1], "memchk", 6)) { opts_memchk = true; break; }
|
||||
if (!strncmp(&argv[1][1], "help", 4)) {
|
||||
if (util_strncmpexact(&argv[1][1], "debug" , 5)) { opts_debug = true; break; }
|
||||
if (util_strncmpexact(&argv[1][1], "memchk", 6)) { opts_memchk = true; break; }
|
||||
if (util_strncmpexact(&argv[1][1], "help", 4)) {
|
||||
return usage(app);
|
||||
break;
|
||||
}
|
||||
/* compiler type selection */
|
||||
if (!strncmp(&argv[1][1], "std=qcc" , 7 )) { opts_compiler = COMPILER_QCC; break; }
|
||||
if (!strncmp(&argv[1][1], "std=fteqcc", 10)) { opts_compiler = COMPILER_FTEQCC; break; }
|
||||
if (!strncmp(&argv[1][1], "std=qccx", 8 )) { opts_compiler = COMPILER_QCCX; break; }
|
||||
if (!strncmp(&argv[1][1], "std=gmqcc", 9 )) { opts_compiler = COMPILER_GMQCC; break; }
|
||||
if (!strncmp(&argv[1][1], "std=", 4 )) {
|
||||
if (util_strncmpexact(&argv[1][1], "std=qcc" , 7 )) { opts_compiler = COMPILER_QCC; break; }
|
||||
if (util_strncmpexact(&argv[1][1], "std=fteqcc", 10)) { opts_compiler = COMPILER_FTEQCC; break; }
|
||||
if (util_strncmpexact(&argv[1][1], "std=qccx", 8 )) { opts_compiler = COMPILER_QCCX; break; }
|
||||
if (util_strncmpexact(&argv[1][1], "std=gmqcc", 9 )) { opts_compiler = COMPILER_GMQCC; break; }
|
||||
if (util_strncmpexact(&argv[1][1], "std=", 4 )) {
|
||||
printf("invalid std selection, supported types:\n"
|
||||
" -std=qcc -- original QuakeC\n"
|
||||
" -std=ftqecc -- fteqcc QuakeC\n"
|
||||
|
@ -122,28 +122,27 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
/* code specific switches */
|
||||
if (!strcmp(&argv[1][1], "fdarkplaces-stringtablebug")) {
|
||||
if (util_strncmpexact(&argv[1][1], "fdarkplaces-stringtablebug", 26)) {
|
||||
opts_darkplaces_stringtablebug = true;
|
||||
break;
|
||||
}
|
||||
if (!strcmp(&argv[1][1], "fomit-nullcode")) {
|
||||
if (util_strncmpexact(&argv[1][1], "fomit-nullcode", 14)) {
|
||||
opts_omit_nullcode = true;
|
||||
break;
|
||||
}
|
||||
return usage(app);
|
||||
return printf("invalid command line argument: %s\n", argv[1]);
|
||||
|
||||
}
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
|
||||
/*
|
||||
* options could depend on another option, this is where option
|
||||
* validity checking like that would take place.
|
||||
*/
|
||||
if (opts_memchk && !opts_debug)
|
||||
printf("Warning: cannot enable -memchk, without -debug.\n");
|
||||
|
||||
|
||||
util_debug("COM", "starting ...\n");
|
||||
/* multi file multi path compilation system */
|
||||
for (; itr < items_elements; itr++) {
|
||||
|
|
8
util.c
8
util.c
|
@ -163,6 +163,14 @@ bool util_strdigit(const char *str) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool util_strncmpexact(const char *src, const char *ned, size_t len) {
|
||||
if (!strncmp(src, ned, len)) {
|
||||
if (!src[len])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void util_debug(const char *area, const char *ms, ...) {
|
||||
va_list va;
|
||||
if (!opts_debug)
|
||||
|
|
Loading…
Reference in a new issue