Skip to content

Commit

Permalink
better argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jub3i authored and illegalprime committed Jun 1, 2016
1 parent 0e457ba commit 4501a8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <nan.h>
#include <v8.h>
#include <vector>
#include "string.h"
#include "mouse.h"
#include "deadbeef_rand.h"
#include "keypress.h"
Expand Down Expand Up @@ -690,13 +689,9 @@ NAN_METHOD(setXDisplayName)
{
NanScope();

//Convert arg to c-string
//NOTE: surely better way to go from v8::String to char* ?
std::string name =
std::string(*v8::String::Utf8Value(args[0]->ToString()));
char *display_name = strdup(name.c_str());
NanUtf8String name(args[0]);
setXDisplay(*name);

setXDisplay(display_name);
NanReturnUndefined();
}

Expand Down
2 changes: 1 addition & 1 deletion src/xdisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ char *getXDisplay(void)
}

void setXDisplay(char *name) {
displayName = name;
displayName = strdup(name);
hasDisplayNameChanged = 1;
}

0 comments on commit 4501a8b

Please sign in to comment.