Skip to content

Commit

Permalink
Changes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
jahfer committed Mar 21, 2017
1 parent c42c834 commit 1a76b68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
23 changes: 8 additions & 15 deletions ext/rotoscope/rotoscope.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,37 +128,30 @@ static rs_callsite_t tracearg_path(rb_trace_arg_t *trace_arg)
{
rb_event_flag_t event_flag = rb_tracearg_event_flag(trace_arg);
rs_callsite_t callsite;

callsite.lineno = 0;
VALUE path;
char *endptr;
char *caller_str = NULL;

switch (event_flag)
{
case RUBY_EVENT_C_CALL:
path = rb_tracearg_path(trace_arg);
callsite.filepath = RTEST(path) ? RSTRING_PTR(path) : "";
strncpy((char *)callsite.filepath, RTEST(path) ? RSTRING_PTR(path) : "", sizeof(callsite.filepath));
callsite.lineno = FIX2INT(rb_tracearg_lineno(trace_arg));
break;
case RUBY_EVENT_C_RETURN:
caller_str = caller_location(0) + 1; // +1 to drop opening quote
// drop down to default on purpose
// drop down to default on purpose
default:
caller_str = (caller_str == NULL) ? (caller_location(1) + 1) : caller_str;
if (caller_str != NULL)
if (caller_str || (caller_str = (caller_location(1) + 1)))
{
char *data = strdup(caller_str);
callsite.filepath = strtok(data, ":");
caller_str = strtok(NULL, ":");
if (caller_str)
strncpy((char *)callsite.filepath, caller_str, sizeof(callsite.filepath));
strtok((char *)callsite.filepath, ":");
if (caller_str = strtok(NULL, ":"))
{
callsite.lineno = (unsigned int)strtol(caller_str, &endptr, 10);
callsite.lineno = (unsigned int)strtoul(caller_str, NULL, 10);
}
}
else
{
callsite.filepath = UNKNOWN_FILE_PATH;
}
}

return callsite;
Expand Down
2 changes: 1 addition & 1 deletion ext/rotoscope/rotoscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct

typedef struct
{
const char *filepath;
const char filepath[200];
unsigned int lineno;
} rs_callsite_t;

Expand Down
2 changes: 1 addition & 1 deletion test/rotoscope_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setup
end

def teardown
# FileUtils.remove_file(@logfile)
FileUtils.remove_file(@logfile)
end

def test_instance_method
Expand Down

0 comments on commit 1a76b68

Please sign in to comment.