Changeset b4c270c


Ignore:
Timestamp:
Feb 11, 2009, 12:20:22 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
9d12aa5, f2fc5ad
Parents:
7980fb2
git-author:
Nelson Elhage <nelhage@mit.edu> (02/11/09 12:17:34)
git-committer:
Nelson Elhage <nelhage@mit.edu> (02/11/09 12:20:22)
Message:
owl_function_printallvars: Use a GString instead of a static buffer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r7980fb2 rb4c270c  
    16641664}
    16651665
    1666 #define PABUFLEN 5000
    16671666void owl_function_printallvars()
    16681667{
    1669   char buff[PABUFLEN], *pos, *name;
     1668  char *name;
     1669  char var[LINE];
    16701670  owl_list varnames;
    1671   int i, numvarnames, rem;
    1672 
    1673   pos = buff;
    1674   pos += sprintf(pos, "%-20s = %s\n", "VARIABLE", "VALUE");
    1675   pos += sprintf(pos, "%-20s   %s\n",  "--------", "-----");
     1671  int i, numvarnames;
     1672  GString *str   = g_string_new("");
     1673
     1674  g_string_append_printf(str, "%-20s = %s\n", "VARIABLE", "VALUE");
     1675  g_string_append_printf(str, "%-20s   %s\n",  "--------", "-----");
    16761676  owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1677   rem = (buff+PABUFLEN)-pos-1;
    16781677  numvarnames = owl_list_get_size(&varnames);
    16791678  for (i=0; i<numvarnames; i++) {
    16801679    name = owl_list_get_element(&varnames, i);
    16811680    if (name && name[0]!='_') {
    1682       rem = (buff+PABUFLEN)-pos-1;   
    1683       pos += snprintf(pos, rem, "\n%-20s = ", name);
    1684       rem = (buff+PABUFLEN)-pos-1;   
    1685       owl_variable_get_tostring(owl_global_get_vardict(&g), name, pos, rem);
    1686       pos = buff+strlen(buff);
    1687     }
    1688   }
    1689   rem = (buff+PABUFLEN)-pos-1;   
    1690   snprintf(pos, rem, "\n");
     1681      g_string_append_printf(str, "\n%-20s = ", name);
     1682      owl_variable_get_tostring(owl_global_get_vardict(&g), name, var, LINE);
     1683      g_string_append(str, var);
     1684    }
     1685  }
     1686  g_string_append(str, "\n");
    16911687  owl_variable_dict_namelist_free(&varnames);
    1692  
    1693   owl_function_popless_text(buff);
     1688
     1689  owl_function_popless_text(str->str);
     1690  g_string_free(str, TRUE);
    16941691}
    16951692
Note: See TracChangeset for help on using the changeset viewer.