Changeset 098376e for perlconfig.c


Ignore:
Timestamp:
Jan 24, 2009, 8:53:45 PM (12 years ago)
Author:
Evan Broder <broder@mit.edu>
Children:
92f8fc2
Parents:
209ea94 (diff), b940b91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge commit 'barnowl-1.0.4.1' into debian
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    r5b37c063 r098376e  
    4444  h = newHV();
    4545
    46 #define MSG2H(h,field) hv_store(h, #field, strlen(#field), \
    47                               newSVpv(owl_message_get_##field(m),0), 0)
     46#define MSG2H(h,field) (void)hv_store(h, #field, strlen(#field),        \
     47                                      newSVpv(owl_message_get_##field(m),0), 0)
    4848
    4949  if (owl_message_is_type_zephyr(m)
     
    5959      owl_free(ptr);
    6060    }
    61     hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
    62 
    63     hv_store(h, "auth", strlen("auth"),
    64              newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0);
     61    (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
     62
     63    (void)hv_store(h, "auth", strlen("auth"),
     64                   newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0);
    6565  }
    6666
     
    6868  for(i=0; i<j; i++) {
    6969    pair=owl_list_get_element(&(m->attributes), i);
    70     hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    71              newSVpv(owl_pair_get_value(pair),0),0);
     70    (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
     71                   newSVpv(owl_pair_get_value(pair),0),0);
    7272  }
    7373 
     
    8888    MSG2H(h, header);
    8989  }
    90   hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);
    91   hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);
    92   hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
    93   hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
    94   hv_store(h, "should_wordwrap",
    95            strlen("should_wordwrap"), newSViv(
    96                                               owl_filter_message_match(wrap, m)),0);
     90  (void)hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);
     91  (void)hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);
     92  (void)hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
     93  (void)hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
     94  (void)hv_store(h, "should_wordwrap",
     95                 strlen("should_wordwrap"), newSViv(
     96                                                    owl_filter_message_match(wrap, m)),0);
    9797
    9898  type = owl_message_get_type(m);
     
    102102  blessas = owl_sprintf("BarnOwl::Message::%s", type);
    103103
    104   hr = sv_2mortal(newRV_noinc((SV*)h));
     104  hr = newRV_noinc((SV*)h);
    105105  stash =  gv_stashpv(blessas,0);
    106106  if(!stash) {
     
    182182  dSP ;
    183183  int count;
    184   unsigned int len;
    185184  SV *msgref, *srv;
    186   char *out, *preout;
     185  char *out;
    187186 
    188187  ENTER ;
     
    191190  PUSHMARK(SP) ;
    192191  msgref = owl_perlconfig_message2hashref(m);
    193   XPUSHs(msgref);
     192  XPUSHs(sv_2mortal(msgref));
    194193  PUTBACK ;
    195194 
     
    199198
    200199  if (SvTRUE(ERRSV)) {
    201     STRLEN n_a;
    202     owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a));
     200    owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
    203201    /* and clear the error */
    204202    sv_setsv (ERRSV, &PL_sv_undef);
     
    213211
    214212  if (srv) {
    215     preout=SvPV(srv, len);
    216     out = owl_malloc(strlen(preout)+1);
    217     strncpy(out, preout, len);
    218     out[len] = '\0';
     213    out = owl_strdup(SvPV_nolen(srv));
    219214  } else {
    220215    out = NULL;
     
    235230{
    236231  dSP;
    237   unsigned int count, len, i;
     232  unsigned int count, i;
    238233  SV *msgref, *srv;
    239   char *out, *preout;
     234  char *out;
    240235
    241236  msgref = owl_perlconfig_message2hashref(m);
     
    245240
    246241  PUSHMARK(SP);
    247   XPUSHs(msgref);
     242  XPUSHs(sv_2mortal(msgref));
    248243  for(i=0;i<argc;i++) {
    249244    XPUSHs(sv_2mortal(newSVpv(argv[i], 0)));
     
    261256
    262257  if (SvTRUE(ERRSV)) {
    263     STRLEN n_a;
    264     owl_function_error("Error: '%s'", SvPV(ERRSV, n_a));
     258    owl_function_error("Error: '%s'", SvPV_nolen(ERRSV));
    265259    /* and clear the error */
    266260    sv_setsv (ERRSV, &PL_sv_undef);
     
    270264
    271265  if (srv) {
    272     preout=SvPV(srv, len);
    273     out = owl_malloc(strlen(preout)+1);
    274     strncpy(out, preout, len);
    275     out[len] = '\0';
     266    out = owl_strdup(SvPV_nolen(srv));
    276267  } else {
    277268    out = NULL;
     
    304295  ret=perl_parse(p, owl_perl_xs_init, 2, args, NULL);
    305296  if (ret || SvTRUE(ERRSV)) {
    306     STRLEN n_a;
    307     err=owl_strdup(SvPV(ERRSV, n_a));
     297    err=owl_strdup(SvPV_nolen(ERRSV));
    308298    sv_setsv(ERRSV, &PL_sv_undef);     /* and clear the error */
    309299    return(err);
     
    312302  ret=perl_run(p);
    313303  if (ret || SvTRUE(ERRSV)) {
    314     STRLEN n_a;
    315     err=owl_strdup(SvPV(ERRSV, n_a));
     304    err=owl_strdup(SvPV_nolen(ERRSV));
    316305    sv_setsv(ERRSV, &PL_sv_undef);     /* and clear the error */
    317306    return(err);
     
    342331
    343332  if (SvTRUE(ERRSV)) {
    344     STRLEN n_a;
    345     err=owl_strdup(SvPV(ERRSV, n_a));
     333    err=owl_strdup(SvPV_nolen(ERRSV));
    346334    sv_setsv (ERRSV, &PL_sv_undef);     /* and clear the error */
    347335    return(err);
     
    396384
    397385  if (SvTRUE(ERRSV)) {
    398     STRLEN n_a;
    399     owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a));
     386    owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
    400387    sv_setsv (ERRSV, &PL_sv_undef);     /* and clear the error */
    401388  }
    402389
    403390  preout=SvPV(response, len);
    404   /* leave enough space in case we have to add a newline */
    405   out = owl_malloc(strlen(preout)+2);
    406   strncpy(out, preout, len);
    407   out[len] = '\0';
    408   if (!strlen(out) || out[strlen(out)-1]!='\n') {
    409     strcat(out, "\n");
    410   }
     391  if (len == 0 || preout[len - 1] != '\n')
     392    out = owl_sprintf("%s\n", preout);
     393  else
     394    out = owl_strdup(preout);
    411395
    412396  return(out);
     
    439423  char * ret = NULL;
    440424  SV *rv;
    441   STRLEN n_a;
    442425  dSP;
    443426
     
    458441
    459442  if(SvTRUE(ERRSV)) {
    460     owl_function_error("%s", SvPV(ERRSV, n_a));
     443    owl_function_error("%s", SvPV_nolen(ERRSV));
    461444    (void)POPs;
    462445  } else {
     
    465448    rv = POPs;
    466449    if(SvTRUE(rv)) {
    467       ret = owl_strdup(SvPV(rv, n_a));
     450      ret = owl_strdup(SvPV_nolen(rv));
    468451    }
    469452  }
     
    489472  SV *cb = (SV*)(e->cbdata);
    490473  SV *text;
    491   unsigned int n_a;
    492474  dSP;
    493475
     
    508490
    509491  if(SvTRUE(ERRSV)) {
    510     owl_function_error("%s", SvPV(ERRSV, n_a));
     492    owl_function_error("%s", SvPV_nolen(ERRSV));
    511493  }
    512494
     
    526508  call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
    527509  if(SvTRUE(ERRSV)) {
    528     STRLEN n_a;
    529     owl_function_error("%s", SvPV(ERRSV, n_a));
     510    owl_function_error("%s", SvPV_nolen(ERRSV));
    530511  }
    531512  return;
     
    535516{
    536517  SV *cb = d->pfunc;
    537   unsigned int n_a;
    538518  dSP;
    539519  if(cb == NULL) {
     
    550530
    551531  if(SvTRUE(ERRSV)) {
    552     owl_function_error("%s", SvPV(ERRSV, n_a));
     532    owl_function_error("%s", SvPV_nolen(ERRSV));
    553533  }
    554534
Note: See TracChangeset for help on using the changeset viewer.