Changeset dde1b4d


Ignore:
Timestamp:
Jul 15, 2011, 11:40:47 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
c6332f5
Parents:
30d0cf7
git-author:
David Benjamin <davidben@mit.edu> (07/12/11 11:58:02)
git-committer:
David Benjamin <davidben@mit.edu> (07/15/11 23:40:47)
Message:
Use g_build_filename instead of g_strdup_printf to build paths

Saves us a duplicate slash in a few places, although most of the time it
doesn't do anything. Eh, may as well use it and be more explicit or
something.

Also change the one existing call to g_build_path to g_build_filename
instead. It's much less of a pain to use.
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    refeec7f rdde1b4d  
    410410  old_msg = g_strdup(owl_zwrite_get_message(z));
    411411
    412   zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
     412  zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
    413413  argv[0] = "zcrypt";
    414414  argv[1] = "-E";
  • global.c

    r16cf182d rdde1b4d  
    7777  g->confdir = NULL;
    7878  g->startupfile = NULL;
    79   cd = g_strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR);
     79  cd = g_build_filename(g->homedir, OWL_CONFIG_DIR, NULL);
    8080  owl_global_set_confdir(g, cd);
    8181  g_free(cd);
     
    364364  g->confdir = g_strdup(cd);
    365365  g_free(g->startupfile);
    366   g->startupfile = g_strdup_printf("%s/startup", cd);
     366  g->startupfile = g_build_filename(cd, "startup", NULL);
    367367}
    368368
  • logging.c

    r6829afc rdde1b4d  
    224224    while (cc != NULL) {
    225225      temp = short_zuser(cc->data);
    226       filename = g_strdup_printf("%s/%s", logpath, temp);
     226      filename = g_build_filename(logpath, temp, NULL);
    227227      owl_log_append(m, filename);
    228228
     
    248248  }
    249249
    250   filename = g_strdup_printf("%s/%s", logpath, to);
     250  filename = g_build_filename(logpath, to, NULL);
    251251  owl_log_append(m, filename);
    252252  g_free(to);
    253253  g_free(filename);
    254254
    255   filename = g_strdup_printf("%s/all", logpath);
     255  filename = g_build_filename(logpath, "all", NULL);
    256256  owl_log_append(m, filename);
    257257  g_free(logpath);
     
    285285  /* expand ~ in path names */
    286286  logpath = owl_util_makepath(owl_global_get_logpath(&g));
    287   filename = g_strdup_printf("%s/%s", logpath, tobuff);
     287  filename = g_build_filename(logpath, tobuff, NULL);
    288288  msgbuf = g_string_new("");
    289289  g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);
     
    294294  g_string_free(msgbuf, TRUE);
    295295
    296   filename = g_strdup_printf("%s/all", logpath);
     296  filename = g_build_filename(logpath, "all", NULL);
    297297  g_free(logpath);
    298298  msgbuf = g_string_new("");
     
    393393  if (personal) {
    394394    logpath = owl_util_makepath(owl_global_get_logpath(&g));
    395     filename = g_strdup_printf("%s/%s", logpath, from);
    396     allfilename = g_strdup_printf("%s/all", logpath);
     395    filename = g_build_filename(logpath, from, NULL);
     396    allfilename = g_build_filename(logpath, "all", NULL);
    397397    owl_log_append(m, allfilename);
    398398    g_free(allfilename);
    399399  } else {
    400400    logpath = owl_util_makepath(owl_global_get_classlogpath(&g));
    401     filename = g_strdup_printf("%s/%s", logpath, from);
     401    filename = g_build_filename(logpath, from, NULL);
    402402  }
    403403
     
    415415      temp = short_zuser(cc->data);
    416416      if (strcasecmp(temp, frombuff) != 0) {
    417         filename = g_strdup_printf("%s/%s", logpath, temp);
     417        filename = g_build_filename(logpath, temp, NULL);
    418418        owl_log_append(m, filename);
    419419        g_free(filename);
  • message.c

    rf9df2f0 rdde1b4d  
    884884    char *zcrypt;
    885885
    886     zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
     886    zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
    887887
    888888    rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status);
  • perlconfig.c

    rce68f23 rdde1b4d  
    406406  /* Add the system lib path to @INC */
    407407  inc = get_av("INC", 0);
    408   path = g_strdup_printf("%s/lib", owl_get_datadir());
     408  path = g_build_filename(owl_get_datadir(), "lib", NULL);
    409409  av_unshift(inc, 1);
    410410  av_store(inc, 0, owl_new_sv(path));
  • util.c

    rc0c48d14 rdde1b4d  
    388388    if (!g_path_is_absolute(link_path)) {
    389389      char *last_dir = g_path_get_dirname(last_path);
    390       char *tmp = g_build_path(G_DIR_SEPARATOR_S,
    391                                last_dir,
    392                                link_path,
    393                                NULL);
     390      char *tmp = g_build_filename(last_dir, link_path, NULL);
    394391      g_free(last_dir);
    395392      g_free(link_path);
  • zcrypt.c

    r6829afc rdde1b4d  
    433433
    434434  /* Open~/.crypt-table */
    435   filename = g_strdup_printf("%s/.crypt-table", getenv("HOME"));
     435  filename = g_build_filename(home, ".crypt-table", NULL);
    436436  fsearch = fopen(filename, "r");
    437437  if (fsearch)
  • zephyr.c

    recffae6 rdde1b4d  
    3838    return g_strdup(input);
    3939  else
    40     return g_strdup_printf("%s/%s", owl_global_get_homedir(&g), name);
     40    return g_build_filename(owl_global_get_homedir(&g), name, NULL);
    4141}
    4242
Note: See TracChangeset for help on using the changeset viewer.