Changeset 3472845


Ignore:
Timestamp:
Feb 11, 2011, 5:18:45 PM (14 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
8a97586
Parents:
d4927a7
git-author:
Anders Kaseorg <andersk@mit.edu> (08/27/09 00:56:39)
git-committer:
Anders Kaseorg <andersk@mit.edu> (02/11/11 17:18:45)
Message:
Replace owl_sprintf with g_strdup_printf.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Karl Ramm <kcr@mit.edu>
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    rd4927a7 r3472845  
    201201  owl_global_set_doaimevents(&g); /* this should already be on */
    202202  owl_function_makemsg("%s logged in", screenname);
    203   buff=owl_sprintf("Logged in to AIM as %s", screenname);
     203  buff=g_strdup_printf("Logged in to AIM as %s", screenname);
    204204  owl_function_adminmsg("", buff);
    205205  g_free(buff);
  • cmd.c

    rd4927a7 r3472845  
    147147  cmd->name = g_strdup(name);
    148148  cmd->cmd_aliased_to = g_strdup(aliased_to);
    149   cmd->summary = owl_sprintf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
     149  cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
    150150  return(0);
    151151}
     
    186186    } else {
    187187      cmdbuffargs = skiptokens(cmdbuff, 1);
    188       newcmd = owl_sprintf("%s %s", cmd->cmd_aliased_to, cmdbuffargs);
     188      newcmd = g_strdup_printf("%s %s", cmd->cmd_aliased_to, cmdbuffargs);
    189189      rv = owl_function_command(newcmd);
    190190      g_free(newcmd);
     
    247247char *owl_cmd_describe(const owl_cmd *cmd) {
    248248  if (!cmd || !cmd->name || !cmd->summary) return NULL;
    249   return owl_sprintf("%-25s - %s", cmd->name, cmd->summary);
     249  return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary);
    250250}
    251251
  • commands.c

    rd4927a7 r3472845  
    14131413    return NULL;
    14141414  }
    1415   return owl_sprintf("%d", owl_global_get_rightshift(&g));
     1415  return g_strdup_printf("%d", owl_global_get_rightshift(&g));
    14161416}
    14171417
  • functions.c

    rd4927a7 r3472845  
    9696  owl_fmtext *fm = user_data;
    9797  owl_timer *timer = data;
    98   char *str = owl_sprintf("- %s: in %d seconds",
    99                           timer->name ? timer->name : "(unnamed)",
    100                           (int)(timer->time - time(NULL)));
     98  char *str = g_strdup_printf("- %s: in %d seconds",
     99                              timer->name ? timer->name : "(unnamed)",
     100                              (int)(timer->time - time(NULL)));
    101101  owl_fmtext_append_normal(fm, str);
    102102  g_free(str);
    103103  if (timer->interval) {
    104     str = owl_sprintf(", repeat every %d seconds", timer->interval);
     104    str = g_strdup_printf(", repeat every %d seconds", timer->interval);
    105105    owl_fmtext_append_normal(fm, str);
    106106    g_free(str);
     
    133133    desc = "???";
    134134  }
    135   s = owl_sprintf("%-20s - %s%s", name,
    136                   0==owl_style_validate(style)?"":"[INVALID] ",
    137                   desc);
     135  s = g_strdup_printf("%-20s - %s%s", name,
     136                      0 == owl_style_validate(style) ? "" : "[INVALID] ",
     137                      desc);
    138138  return s;
    139139}
     
    216216        char *perlquickstart = owl_perlconfig_execute("BarnOwl::Hooks::_get_quickstart()");
    217217        if (perlquickstart) {
    218             char *result = owl_sprintf("%s%s", message, perlquickstart);
     218            char *result = g_strdup_printf("%s%s", message, perlquickstart);
    219219            owl_function_adminmsg("BarnOwl Quickstart", result);
    220220            g_free(result);
     
    311311                                   owl_global_get_msg_history(&g));
    312312  owl_editwin_set_dotsend(e);
    313   s = owl_sprintf("----> %s\n", line);
     313  s = g_strdup_printf("----> %s\n", line);
    314314  owl_editwin_set_locktext(e, s);
    315315  g_free(s);
     
    354354  /* TODO: We probably actually want an owl_aimwrite object like
    355355   * owl_zwrite. */
    356   char *line = owl_sprintf("aimwrite %s", to);
     356  char *line = g_strdup_printf("aimwrite %s", to);
    357357  owl_function_write_setup("message");
    358358  owl_function_start_edit_win(line,
     
    438438  old_msg = g_strdup(owl_zwrite_get_message(z));
    439439
    440   zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir());
     440  zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
    441441  argv[0] = "zcrypt";
    442442  argv[1] = "-E";
     
    19911991
    19921992  buff = skiptokens(buff, 1);
    1993   newbuff = owl_sprintf("%s%s", buff, redirect);
     1993  newbuff = g_strdup_printf("%s%s", buff, redirect);
    19941994
    19951995  if (type == OWL_OUTPUT_POPUP) {
     
    21932193    newname=g_strdup(filtername+4);
    21942194  } else {
    2195     newname=owl_sprintf("not-%s", filtername);
     2195    newname=g_strdup_printf("not-%s", filtername);
    21962196  }
    21972197
     
    22452245  }
    22462246  tmp = owl_filter_print(f);
    2247   buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp);
     2247  buff = g_strdup_printf("%s: %s", owl_filter_get_name(f), tmp);
    22482248  owl_function_popless_text(buff);
    22492249  g_free(buff);
     
    23052305  /* name for the filter */
    23062306  if (!instance) {
    2307     filtname = owl_sprintf("%sclass-%s", related ? "related-" : "", class);
    2308   } else {
    2309     filtname = owl_sprintf("%sclass-%s-instance-%s", related ? "related-" : "", class, instance);
     2307    filtname = g_strdup_printf("%sclass-%s", related ? "related-" : "", class);
     2308  } else {
     2309    filtname = g_strdup_printf("%sclass-%s-instance-%s", related ? "related-" : "", class, instance);
    23102310  }
    23112311  /* downcase it */
     
    23792379  /* name for the filter */
    23802380  shortuser = short_zuser(longuser);
    2381   filtname = owl_sprintf("user-%s", shortuser);
     2381  filtname = g_strdup_printf("user-%s", shortuser);
    23822382  g_free(shortuser);
    23832383
     
    24252425
    24262426  /* name for the filter */
    2427   filtname=owl_sprintf("aimuser-%s", user);
     2427  filtname=g_strdup_printf("aimuser-%s", user);
    24282428
    24292429  /* if it already exists then go with it.  This lets users override */
     
    24352435  escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    24362436
    2437   argbuff = owl_sprintf(
     2437  argbuff = g_strdup_printf(
    24382438      "( type ^aim$ and ( ( sender ^%1$s$ and recipient ^%2$s$ ) or "
    24392439      "( sender ^%2$s$ and recipient ^%1$s$ ) ) )",
     
    24622462
    24632463  /* name for the filter */
    2464   filtname=owl_sprintf("type-%s", type);
     2464  filtname=g_strdup_printf("type-%s", type);
    24652465
    24662466  /* if it already exists then go with it.  This lets users override */
     
    25212521  ccs = owl_message_get_attribute_value(m, "zephyr_ccs");
    25222522
    2523   filtname = owl_sprintf("conversation-%s", ccs);
     2523  filtname = g_strdup_printf("conversation-%s", ccs);
    25242524  owl_text_tr(filtname, ' ', '-');
    25252525
     
    27632763
    27642764  for(i = 8; i < COLORS; ++i) {
    2765     char* str1 = owl_sprintf("%4i:     ",i);
    2766     char* str2 = owl_sprintf("%i\n",i);
     2765    char* str1 = g_strdup_printf("%4i:     ",i);
     2766    char* str2 = g_strdup_printf("%i\n",i);
    27672767    owl_fmtext_append_normal(&fm,str1);
    27682768    owl_fmtext_append_normal_color(&fm, str2, i, OWL_COLOR_DEFAULT);
     
    33923392  date[strlen(date)-1]='\0';
    33933393
    3394   buff = owl_sprintf("%s %s", date, string);
     3394  buff = g_strdup_printf("%s %s", date, string);
    33953395
    33963396  owl_errqueue_append_err(owl_global_get_errqueue(&g), buff);
  • global.c

    rd4927a7 r3472845  
    9494  g->confdir = NULL;
    9595  g->startupfile = NULL;
    96   cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);
     96  cd = g_strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR);
    9797  owl_global_set_confdir(g, cd);
    9898  g_free(cd);
     
    382382  g->confdir = g_strdup(cd);
    383383  g_free(g->startupfile);
    384   g->startupfile = owl_sprintf("%s/startup", cd);
     384  g->startupfile = g_strdup_printf("%s/startup", cd);
    385385}
    386386
     
    965965    g->debug_file = NULL;
    966966
    967     path = owl_sprintf("%s.%d", filename, getpid());
     967    path = g_strdup_printf("%s.%d", filename, getpid());
    968968    fd = open(path, O_CREAT|O_WRONLY|O_EXCL, 0600);
    969969    g_free(path);
  • keymap.c

    rd4927a7 r3472845  
    8585{
    8686  if (!km || !km->name || !km->desc) return NULL;
    87   return owl_sprintf("%-15s - %s", km->name, km->desc);
     87  return g_strdup_printf("%-15s - %s", km->name, km->desc);
    8888}
    8989
  • logging.c

    rd4927a7 r3472845  
    149149    to = short_zuser(owl_message_get_recipient(m));
    150150  } else if (owl_message_is_type_jabber(m)) {
    151     to = owl_sprintf("jabber:%s", owl_message_get_recipient(m));
     151    to = g_strdup_printf("jabber:%s", owl_message_get_recipient(m));
    152152    owl_text_tr(to, '/', '_');
    153153  } else if (owl_message_is_type_aim(m)) {
     
    155155    temp = owl_aim_normalize_screenname(owl_message_get_recipient(m));
    156156    temp2 = g_utf8_strdown(temp,-1);
    157     to = owl_sprintf("aim:%s", temp2);
     157    to = g_strdup_printf("aim:%s", temp2);
    158158    g_free(temp2);
    159159    g_free(temp);
     
    269269    temp = owl_aim_normalize_screenname(owl_message_get_sender(m));
    270270    normalto = g_utf8_strdown(temp, -1);
    271     from=frombuff=owl_sprintf("aim:%s", normalto);
     271    from=frombuff=g_strdup_printf("aim:%s", normalto);
    272272    g_free(normalto);
    273273    g_free(temp);
     
    276276  } else if (owl_message_is_type_jabber(m)) {
    277277    if (personal) {
    278       from=frombuff=owl_sprintf("jabber:%s",owl_message_get_sender(m));
    279     } else {
    280       from=frombuff=owl_sprintf("jabber:%s",owl_message_get_recipient(m));
     278      from=frombuff=g_strdup_printf("jabber:%s",owl_message_get_sender(m));
     279    } else {
     280      from=frombuff=g_strdup_printf("jabber:%s",owl_message_get_recipient(m));
    281281    }
    282282  } else {
  • message.c

    rd4927a7 r3472845  
    127127  for (i=0; i<j; i++) {
    128128    p=owl_list_get_element(&(m->attributes), i);
    129     buff=owl_sprintf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p));
     129    buff=g_strdup_printf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p));
    130130    if(buff == NULL) {
    131       buff=owl_sprintf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), "<error>");
     131      buff=g_strdup_printf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), "<error>");
    132132      if(buff == NULL)
    133133        buff=g_strdup("   <error>\n");
     
    888888    char *zcrypt;
    889889
    890     zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir());
     890    zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
    891891
    892892    rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status);
  • owl.c

    rd4927a7 r3472845  
    434434  }
    435435
    436   err = owl_sprintf("[stderr]\n%s", buf);
     436  err = g_strdup_printf("[stderr]\n%s", buf);
    437437
    438438  owl_function_log_err(err);
  • perlconfig.c

    rd4927a7 r3472845  
    150150  utype = g_strdup(type);
    151151  utype[0] = toupper(type[0]);
    152   blessas = owl_sprintf("BarnOwl::Message::%s", utype);
     152  blessas = g_strdup_printf("BarnOwl::Message::%s", utype);
    153153
    154154  hr = newRV_noinc((SV*)h);
     
    240240    n->z_multinotice = zstr("[zephyr created from perl]");
    241241    n->z_num_other_fields = 0;
    242     n->z_message = owl_sprintf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));
     242    n->z_message = g_strdup_printf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));
    243243    n->z_message_len = strlen(owl_message_get_zsig(m)) + strlen(owl_message_get_body(m)) + 1;
    244244  }
     
    404404  /* Add the system lib path to @INC */
    405405  inc = get_av("INC", 0);
    406   path = owl_sprintf("%s/lib", owl_get_datadir());
     406  path = g_strdup_printf("%s/lib", owl_get_datadir());
    407407  av_unshift(inc, 1);
    408408  av_store(inc, 0, owl_new_sv(path));
  • util.c

    rd4927a7 r3472845  
    285285
    286286  if (days>0) {
    287     out=owl_sprintf("%i d %2.2i:%2.2li", days, hours, run);
     287    out=g_strdup_printf("%i d %2.2i:%2.2li", days, hours, run);
    288288  } else {
    289     out=owl_sprintf("    %2.2i:%2.2li", hours, run);
     289    out=g_strdup_printf("    %2.2i:%2.2li", hours, run);
    290290  }
    291291  return(out);
    292 }
    293 
    294 /* allocates memory and returns the string or null.
    295  * caller must free the string.
    296  */
    297 char *owl_sprintf(const char *fmt, ...)
    298 {
    299   va_list ap;
    300   char *ret = NULL;
    301   va_start(ap, fmt);
    302   ret = g_strdup_vprintf(fmt, ap);
    303   va_end(ap);
    304   return ret;
    305292}
    306293
     
    468455    return -1; /* resolving the symlink failed, but we already logged this error */
    469456
    470   newfile = owl_sprintf("%s.new", actual_filename);
     457  newfile = g_strdup_printf("%s.new", actual_filename);
    471458  if ((new = fopen(newfile, "w")) == NULL) {
    472459    owl_function_error("Cannot open %s (for writing): %s",
     
    500487
    501488  if (backup) {
    502     backupfile = owl_sprintf("%s.backup", actual_filename);
     489    backupfile = g_strdup_printf("%s.backup", actual_filename);
    503490    unlink(backupfile);
    504491    if (link(actual_filename, backupfile) != 0) {
  • zephyr.c

    rd4927a7 r3472845  
    2525    return g_strdup(input);
    2626  else
    27     return owl_sprintf("%s/%s", owl_global_get_homedir(&g), name);
     27    return g_strdup_printf("%s/%s", owl_global_get_homedir(&g), name);
    2828}
    2929
     
    588588    field4 = owl_zephyr_get_field(n, 4);
    589589
    590     msg = owl_sprintf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4);
     590    msg = g_strdup_printf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4);
    591591    g_free(field3);
    592592    g_free(field4);
     
    606606    field5 = owl_zephyr_get_field(n, 5);
    607607   
    608     msg = owl_sprintf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", field1, field2, field3, field5, field4);
     608    msg = g_strdup_printf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", field1, field2, field3, field5, field4);
    609609    g_free(field1);
    610610    g_free(field2);
     
    622622    field1 = owl_zephyr_get_field(n, 1);
    623623   
    624     msg = owl_sprintf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1);
     624    msg = g_strdup_printf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1);
    625625    g_free(field1);
    626626    if (msg) {
     
    882882  myuser=short_zuser(to);
    883883  if (!strcasecmp(owl_message_get_instance(m), "personal")) {
    884     tmpbuff = owl_sprintf("zwrite %s", myuser);
     884    tmpbuff = g_strdup_printf("zwrite %s", myuser);
    885885  } else {
    886     tmpbuff = owl_sprintf("zwrite -i %s %s", owl_message_get_instance(m), myuser);
     886    tmpbuff = g_strdup_printf("zwrite -i %s %s", owl_message_get_instance(m), myuser);
    887887  }
    888888  g_free(myuser);
     
    927927  ret = ZLocateUser(zstr(user), &numlocs, auth ? ZAUTH : ZNOAUTH);
    928928  if (ret != ZERR_NONE)
    929     return owl_sprintf("Error locating user %s: %s\n",
    930                        user, error_message(ret));
     929    return g_strdup_printf("Error locating user %s: %s\n",
     930                           user, error_message(ret));
    931931
    932932  myuser = short_zuser(user);
    933933  if (numlocs == 0) {
    934     result = owl_sprintf("%s: Hidden or not logged in\n", myuser);
     934    result = g_strdup_printf("%s: Hidden or not logged in\n", myuser);
    935935  } else {
    936936    result = g_strdup("");
    937937    for (; numlocs; numlocs--) {
    938938      ZGetLocations(&locations, &one);
    939       p = owl_sprintf("%s%s: %s\t%s\t%s\n",
     939      p = g_strdup_printf("%s%s: %s\t%s\t%s\n",
    940940                          result, myuser,
    941941                          locations.host ? locations.host : "?",
     
    10171017char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    10181018{
    1019   return owl_sprintf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
     1019  return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
    10201020}
    10211021
     
    11461146    } else {
    11471147      /* g_string_append_printf would be backwards. */
    1148       char *tmp = owl_sprintf("<%s,%s,%s>\n",
    1149                               sub.zsub_class,
    1150                               sub.zsub_classinst,
    1151                               sub.zsub_recipient);
     1148      char *tmp = g_strdup_printf("<%s,%s,%s>\n",
     1149                                  sub.zsub_class,
     1150                                  sub.zsub_classinst,
     1151                                  sub.zsub_recipient);
    11521152      g_string_prepend(buf, tmp);
    11531153      g_free(tmp);
     
    12031203    return(g_strdup(in));
    12041204  }
    1205   return(owl_sprintf("%s@%s", in, owl_zephyr_get_realm()));
     1205  return(g_strdup_printf("%s@%s", in, owl_zephyr_get_realm()));
    12061206}
    12071207
  • zwrite.c

    rd4927a7 r3472845  
    176176  for (i=0; i<j; i++) {
    177177    if (strcmp(z->realm, "")) {
    178       to = owl_sprintf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);
     178      to = g_strdup_printf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);
    179179    } else {
    180180      to = g_strdup(owl_list_get_element(&(z->recips), i));
     
    207207      tmp = toline;
    208208      if (strcmp(z->realm, "")) {
    209         toline = owl_sprintf( "%s%s@%s ", toline, (const char *) owl_list_get_element(&(z->recips), i), z->realm);
     209        toline = g_strdup_printf( "%s%s@%s ", toline, (const char *) owl_list_get_element(&(z->recips), i), z->realm);
    210210      } else {
    211         toline = owl_sprintf( "%s%s ", toline, (const char *) owl_list_get_element(&(z->recips), i));
     211        toline = g_strdup_printf( "%s%s ", toline, (const char *) owl_list_get_element(&(z->recips), i));
    212212      }
    213213      g_free(tmp);
     
    216216    tmp = owl_validate_utf8(msg);
    217217    tmp2 = owl_text_expand_tabs(tmp);
    218     z->message=owl_sprintf("%s\n%s", toline, tmp2);
     218    z->message=g_strdup_printf("%s\n%s", toline, tmp2);
    219219    g_free(toline);
    220220    g_free(tmp);
     
    250250    for (i=0; i<j; i++) {
    251251      if (strcmp(z->realm, "")) {
    252         to = owl_sprintf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);
     252        to = g_strdup_printf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);
    253253      } else {
    254254        to = g_strdup( owl_list_get_element(&(z->recips), i));
     
    262262    }
    263263  } else {
    264     to = owl_sprintf( "@%s", z->realm);
     264    to = g_strdup_printf( "@%s", z->realm);
    265265    ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
    266266  }
Note: See TracChangeset for help on using the changeset viewer.