diff options
| author | BossCode45 <boss@tehbox.org> | 2025-05-11 18:17:27 +1200 |
|---|---|---|
| committer | BossCode45 <boss@tehbox.org> | 2025-06-08 23:29:33 +1200 |
| commit | 6698e92f6d7574a31a6d0e17acf63edf9f689102 (patch) | |
| tree | 96dec36f65651889a5f6ee80bb917b5bfc0f2bc3 /src/commands.cpp | |
| parent | 7dd44834f0af18cca87786a2050ae69928b7a397 (diff) | |
| download | YATwm-6698e92f6d7574a31a6d0e17acf63edf9f689102.tar.gz YATwm-6698e92f6d7574a31a6d0e17acf63edf9f689102.zip | |
Fixed keybinding errors
Hopefully fixed multiple monitor status bar workspaces
Refactored EWMH module
Diffstat (limited to 'src/commands.cpp')
| -rw-r--r-- | src/commands.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index caa82eb..460c45b 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -12,6 +12,8 @@ #include <cstring> #include <fstream> +#include "debug.h" + using std::cout, std::endl, std::string, std::vector; const void CommandsModule::echo(const CommandArg* argv) @@ -181,7 +183,12 @@ CommandArg* CommandsModule::getCommandArgs(vector<string>& split, const CommandA { switch(argTypes[i-1]) { - case STR: args[i-1].str = (char*)split[i].c_str(); break; + case STR: + { + args[i-1].str = new char[split[i].length() + 1]; + strncpy(args[i-1].str, split[i].c_str(), split[i].length() + 1); + break; + } case NUM: { try @@ -194,6 +201,7 @@ CommandArg* CommandsModule::getCommandArgs(vector<string>& split, const CommandA delete[] args; throw Err(CMD_ERR_WRONG_ARGS, split[i] + " is not a number!"); } + break; } case MOVDIR: { @@ -221,8 +229,8 @@ CommandArg* CommandsModule::getCommandArgs(vector<string>& split, const CommandA if(j != split.size() - 1) rest += " "; } - args[i-1].str = new char[rest.size()]; - strncpy(args[i-1].str, rest.c_str(), rest.size()); + args[i-1].str = new char[rest.size() + 1]; + strncpy(args[i-1].str, rest.c_str(), rest.size() + 1); return args; } case NUM_ARR_REST: @@ -252,6 +260,7 @@ CommandArg* CommandsModule::getCommandArgs(vector<string>& split, const CommandA void CommandsModule::runCommand(string command) { + debug(cout << command << endl); vector<string> split = splitCommand(command); vector<string>::const_iterator start = split.begin(); int count = 0; @@ -303,7 +312,7 @@ void CommandsModule::runCommand(vector<string> split) { for(int i = 0; i < cmd->argc; i++) { - if(cmd->argTypes[i] == STR_REST) + if(cmd->argTypes[i] == STR_REST || cmd->argTypes[i] == STR) delete[] args[i].str; } delete[] args; @@ -311,7 +320,7 @@ void CommandsModule::runCommand(vector<string> split) } for(int i = 0; i < cmd->argc; i++) { - if(cmd->argTypes[i] == STR_REST) + if(cmd->argTypes[i] == STR_REST || cmd->argTypes[i] == STR) delete[] args[i].str; } delete[] args; |
