Compare commits

..

3 Commits

Author SHA1 Message Date
9388844acb add IS_64_BIT macro to interface.h 2024-07-25 22:14:06 +01:00
955edb781c get new len from strcspn
remove reset input buffer
2024-07-25 21:35:56 +01:00
a719af8265 use ++i 2024-07-25 17:34:38 +01:00
5 changed files with 12 additions and 11 deletions

View File

@ -10,6 +10,8 @@
#include "VoicemeeterRemote.h"
#define IS_64_BIT sizeof(void *) == 8
PT_VMR create_interface();
#endif /* __IVMR_H__ */

View File

@ -81,7 +81,7 @@ static long initialize_dll_interfaces(PT_VMR vmr)
return -100;
}
// use right dll according to O/S type
if (sizeof(void *) == 8)
if (IS_64_BIT)
strncat(dll_fullpath, DLL64_NAME, DLL_FULLPATH_SZ - strlen(DLL64_NAME) - 1);
else
strncat(dll_fullpath, DLL32_NAME, DLL_FULLPATH_SZ - strlen(DLL32_NAME) - 1);

View File

@ -118,7 +118,7 @@ void log_set_quiet(bool enable)
int log_add_callback(log_LogFn fn, void *udata, int level)
{
for (int i = 0; i < MAX_CALLBACKS; i++)
for (int i = 0; i < MAX_CALLBACKS; ++i)
{
if (!L.callbacks[i].fn)
{
@ -163,7 +163,7 @@ void log_log(int level, const char *file, int line, const char *fmt, ...)
va_end(ev.ap);
}
for (int i = 0; i < MAX_CALLBACKS && L.callbacks[i].fn; i++)
for (int i = 0; i < MAX_CALLBACKS && L.callbacks[i].fn; ++i)
{
Callback *cb = &L.callbacks[i];
if (level >= cb->level)

View File

@ -92,7 +92,7 @@ bool is_comment(char *s)
*/
struct quickcommand *command_in_quickcommands(const char *command_key, const struct quickcommand *quickcommands, int n)
{
for (int i = 0; i < n; i++)
for (int i = 0; i < n; ++i)
{
if (strcmp(command_key, quickcommands[i].name) == 0)
{

View File

@ -191,7 +191,7 @@ int main(int argc, char *argv[])
}
else
{
for (int i = optind; i < argc; i++)
for (int i = optind; i < argc; ++i)
{
parse_input(vmr, argv[i]);
}
@ -240,11 +240,11 @@ static void usage()
static enum kind set_kind(char *kval)
{
if (strcmp(kval, "basic") == 0)
return sizeof(void *) == 8 ? BASICX64 : BASIC;
return IS_64_BIT ? BASICX64 : BASIC;
else if (strcmp(kval, "banana") == 0)
return sizeof(void *) == 8 ? BANANAX64 : BANANA;
return IS_64_BIT ? BANANAX64 : BANANA;
else if (strcmp(kval, "potato") == 0)
return sizeof(void *) == 8 ? POTATOX64 : POTATO;
return IS_64_BIT ? POTATOX64 : POTATO;
else
return UNKNOWN;
}
@ -266,12 +266,11 @@ static void interactive(PT_VMR vmr, bool with_prompt)
printf(">> ");
while (fgets(input, MAX_LINE, stdin) != NULL)
{
input[strcspn(input, "\n")] = 0;
if ((len = strlen(input)) == 1 && toupper(input[0]) == 'Q')
input[(len = strcspn(input, "\n"))] = 0;
if (len == 1 && toupper(input[0]) == 'Q')
break;
parse_input(vmr, input);
memset(input, 0, len); /* reset input buffer */
if (with_prompt)
printf(">> ");