Skip to content

Commit

Permalink
Fixed to_s for Binary terms
Browse files Browse the repository at this point in the history
  • Loading branch information
paukul committed Mar 20, 2010
1 parent b6c5f90 commit 4fbecce
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
lib_dir = ei_dir + '/lib/'

$LDFLAGS << " -L#{lib_dir} -lei -lerl_interface"
$CPPFLAGS << ' -D_REENTRANT -g'
$CPPFLAGS << ' -D_REENTRANT -g -g3 -gdwarf-2'

if find_header('ei.h', include_dir)
create_makefile(extension_name, src_dir)
Expand Down
5 changes: 3 additions & 2 deletions src/erlix_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ void fill_string(VALUE *str,ETERM *ep){
rb_funcall(*str,concat,1,rb_str_new2("\'"));
}
}else if(ERL_IS_PID(ep)){
char tmp_buf_pid[24];
memset(tmp_buf_pid,0,24);
int buffsize = 9 + strlen(ERL_PID_NODE(ep));
char tmp_buf_pid[buffsize];
memset(tmp_buf_pid,0,buffsize);
sprintf(tmp_buf_pid,"<%s.%d.%d>",ERL_PID_NODE(ep),ERL_PID_NUMBER(ep), ERL_PID_SERIAL(ep));
rb_funcall(*str,concat,1,rb_str_new2(tmp_buf_pid));
}else if(ERL_IS_PORT(ep)){
Expand Down
1 change: 1 addition & 0 deletions src/erlix_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ei.h"

#include <ctype.h>
#include <string.h>

void fill_string(VALUE *str, ETERM *ep);

Expand Down
3 changes: 3 additions & 0 deletions src/mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ VALUE intruder_mod_rpc(VALUE self, VALUE args) {
tuplep = erl_decode(result.buff);
ei_x_free(&rpcargs);
ei_x_free(&result);
/* printf("result: \n"); */
/* erl_print_term(stdout, tuplep); */
/* fflush(stdout); */
return rb_value_from_eterm(tuplep);
}

Expand Down
4 changes: 4 additions & 0 deletions src/term.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ VALUE intruder_term_to_s(VALUE self) {
Data_Get_Struct(self, INTRUDER_TERM, iterm);
ETERM *eterm = iterm->eterm;
VALUE ret = rb_str_new2("");
/* int ei_s_print_term(char** s, const char* buf, int* index) */
/* int index = 0; */
/* char *buff; */
/* int ei_s_print_term(&buff, , int* index); */
fill_string(&ret, eterm);
return ret;
}
Expand Down

0 comments on commit 4fbecce

Please sign in to comment.