Changeset a0e6082 for functions.c


Ignore:
Timestamp:
Feb 11, 2009, 12:20:21 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
c894c15
Parents:
c1d166b
git-author:
Nelson Elhage <nelhage@mit.edu> (02/10/09 18:35:46)
git-committer:
Nelson Elhage <nelhage@mit.edu> (02/11/09 12:20:21)
Message:
owl_function_classinstfilt: Replace sprintf with owl_sprintf.

The old code should be safe, but this is cleaner and more obviously
correct.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rc1d166b ra0e6082  
    23982398  char *tmpclass, *tmpinstance = NULL;
    23992399  char *class, *instance = NULL;
    2400   int len;
    24012400
    24022401  class = owl_util_baseclass(c);
     
    24082407
    24092408  /* name for the filter */
    2410   len=strlen(class)+30;
    2411   if (instance) len+=strlen(instance);
    2412   filtname=owl_malloc(len);
    24132409  if (!instance) {
    2414     sprintf(filtname, "class-%s", class);
    2415   } else {
    2416     sprintf(filtname, "class-%s-instance-%s", class, instance);
     2410    filtname = owl_sprintf("class-%s", class);
     2411  } else {
     2412    filtname = owl_sprintf("class-%s-instance-%s", class, instance);
    24172413  }
    24182414  /* downcase it */
     
    24452441    owl_text_tr(tmpinstance, '"', '.');
    24462442  }
    2447   len = strlen(tmpclass);
    2448   if(tmpinstance) len += strlen(tmpinstance);
    2449   len += 60;
    2450   argbuff = owl_malloc(len);
    2451   sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass);
     2443
     2444  argbuff = owl_sprintf("class ^(un)*%s(\\.d)*$", tmpclass);
    24522445  if (tmpinstance) {
    2453     sprintf(argbuff + strlen(argbuff), " and ( instance ^(un)*%s(\\.d)*$ )", tmpinstance);
     2446    char *tmp = argbuff;
     2447    argbuff = owl_sprintf("%s and ( instance ^(un)*%s(\\.d)*$ )", tmp, tmpinstance);
     2448    owl_free(tmp);
    24542449  }
    24552450  owl_free(tmpclass);
Note: See TracChangeset for help on using the changeset viewer.