Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r4727d31 rc314f39  
    6161  owl_pair *p = NULL, *pair = NULL;
    6262
     63  attrname = g_intern_string(attrname);
     64
    6365  /* look for an existing pair with this key, */
    6466  j=owl_list_get_size(&(m->attributes));
    6567  for (i=0; i<j; i++) {
    6668    p=owl_list_get_element(&(m->attributes), i);
    67     if (!strcmp(owl_pair_get_key(p), attrname)) {
     69    if (owl_pair_get_key(p) == attrname) {
    6870      owl_free(owl_pair_get_value(p));
    6971      pair = p;
     
    7476  if(pair ==  NULL) {
    7577    pair = owl_malloc(sizeof(owl_pair));
    76     owl_pair_create(pair, owl_global_intern(&g, attrname), NULL);
     78    owl_pair_create(pair, attrname, NULL);
    7779    owl_list_append_element(&(m->attributes), pair);
    7880  }
     
    8789  int i, j;
    8890  owl_pair *p;
     91  GQuark quark;
     92
     93  quark = g_quark_try_string(attrname);
     94  if (quark == 0)
     95    /* don't bother inserting into string table */
     96    return NULL;
     97  attrname = g_quark_to_string(quark);
    8998
    9099  j=owl_list_get_size(&(m->attributes));
    91100  for (i=0; i<j; i++) {
    92101    p=owl_list_get_element(&(m->attributes), i);
    93     if (!strcmp(owl_pair_get_key(p), attrname)) {
     102    if (owl_pair_get_key(p) == attrname) {
    94103      return(owl_pair_get_value(p));
    95104    }
     
    496505void owl_message_set_hostname(owl_message *m, const char *hostname)
    497506{
    498   m->hostname=owl_global_intern(&g, hostname);
     507  m->hostname = g_intern_string(hostname);
    499508}
    500509
     
    584593
    585594/* caller must free return value */
    586 GList *owl_message_get_cc_without_recipient(const owl_message *m)
    587 {
    588   char *cc, *shortuser, *recip;
     595char *owl_message_get_cc_without_recipient(const owl_message *m)
     596{
     597  char *cc, *out, *end, *shortuser, *recip;
    589598  const char *user;
    590   GList *out = NULL;
    591599
    592600  cc = owl_message_get_cc(m);
     
    595603
    596604  recip = short_zuser(owl_message_get_recipient(m));
     605  out = owl_malloc(strlen(cc) + 2);
     606  end = out;
    597607
    598608  user = strtok(cc, " ");
     
    600610    shortuser = short_zuser(user);
    601611    if (strcasecmp(shortuser, recip) != 0) {
    602       out = g_list_prepend(out, owl_strdup(user));
     612      strcpy(end, user);
     613      end[strlen(user)] = ' ';
     614      end += strlen(user) + 1;
    603615    }
    604616    owl_free(shortuser);
    605617    user = strtok(NULL, " ");
    606618  }
     619  end[0] = '\0';
    607620
    608621  owl_free(recip);
    609622  owl_free(cc);
     623
     624  if (strlen(out) == 0) {
     625    owl_free(out);
     626    out = NULL;
     627  }
    610628
    611629  return(out);
     
    723741  owl_message_set_recipient(m, "looprecip");
    724742  owl_message_set_isprivate(m);
    725 }
    726 
    727 void owl_message_save_ccs(owl_message *m) {
    728   GList *cc;
    729   char *tmp;
    730 
    731   cc = owl_message_get_cc_without_recipient(m);
    732 
    733   if (cc != NULL) {
    734     GString *recips = g_string_new("");
    735     cc = g_list_prepend(cc, short_zuser(owl_message_get_sender(m)));
    736     cc = g_list_prepend(cc, short_zuser(owl_message_get_recipient(m)));
    737     cc = g_list_sort(cc, (GCompareFunc)strcasecmp);
    738 
    739     while(cc != NULL) {
    740       /* Collapse any identical entries */
    741       while (cc->next && strcasecmp(cc->data, cc->next->data) == 0) {
    742         owl_free(cc->data);
    743         cc = g_list_delete_link(cc, cc);
    744       }
    745 
    746       tmp = short_zuser(cc->data);
    747       g_string_append(recips, tmp);
    748 
    749       owl_free(tmp);
    750       owl_free(cc->data);
    751       cc = g_list_delete_link(cc, cc);
    752 
    753       if (cc)
    754         g_string_append_c(recips, ' ');
    755     }
    756 
    757     owl_message_set_attribute(m, "zephyr_ccs", recips->str);
    758     g_string_free(recips, true);
    759   }
    760743}
    761744
     
    895878    }
    896879  }
    897 
    898   owl_message_save_ccs(m);
    899880}
    900881#else
     
    991972    owl_message_set_isprivate(m);
    992973  }
    993 
    994   owl_message_save_ccs(m);
    995974}
    996975
Note: See TracChangeset for help on using the changeset viewer.