Changeset f34dd65 for util.c


Ignore:
Timestamp:
Feb 11, 2009, 12:20:22 PM (12 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:
7980fb2
Parents:
823671c
git-author:
Nelson Elhage <nelhage@mit.edu> (02/08/09 16:31:14)
git-committer:
Nelson Elhage <nelhage@mit.edu> (02/11/09 12:20:22)
Message:
Kill a whole bunch of unused code.

I generated a list of dead functions by building with
-ffunction-sections and linking with -Wl,--gc-sections
-Wl,--print-gc-sections

I kept a number of functions that seemed to be logical parts of an
existing API, as well as stuff in varstubs.c, since that file is
autogenerated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    re97c4a30 rf34dd65  
    125125  wattroff(sepwin, A_REVERSE);
    126126  wnoutrefresh(sepwin);
    127 }
    128 
    129 
    130 void pophandler_quit(int ch)
    131 {
    132   if (ch=='q') {
    133     owl_popwin_close(owl_global_get_popwin(&g));
    134   }
    135127}
    136128
     
    380372}
    381373
    382 /* return the index of the last char before a change from the first one */
    383 int owl_util_find_trans(char *in, int len)
    384 {
    385   int i;
    386   for (i=1; i<len; i++) {
    387     if (in[i] != in[0]) return(i-1);
    388   }
    389   return(i);
    390 }
    391 
    392 int owl_util_find_trans_short(short *in, int len)
    393 {
    394   int i;
    395   for (i=1; i<len; i++) {
    396     if (in[i] != in[0]) return(i-1);
    397   }
    398   return(i);
    399 }
    400 
    401 /* Caller must free response.
    402  * Takes in strings which are space-separated lists of tokens
    403  * and returns a single string containing no token more than once.
    404  * If prohibit is non-null, no token may start with a character
    405  * in prohibit.
    406  */
    407 char *owl_util_uniq(char *A, char *B, char *prohibit)
    408 {
    409  
    410   char *cat, **tok;
    411   int toklen, i, j, first=1;
    412   cat = owl_malloc(strlen(A)+strlen(B)+3);
    413   strcpy(cat, A);
    414   strcat(cat, " ");
    415   strcat(cat, B);
    416   tok = atokenize(cat, " ", &toklen);
    417   strcpy(cat, "");
    418   for (i=0; i<toklen; i++) {
    419     int dup=0;
    420     for (j=0; j<i; j++) {
    421       if (!strcmp(tok[i], tok[j])) dup=1;
    422     }
    423     if (!dup && (!prohibit || !strchr(prohibit, tok[i][0]))) {
    424       if (!first) {
    425         strcat(cat, " ");
    426       }
    427       first=0;
    428       strcat(cat, tok[i]);
    429     }
    430   }
    431   atokenize_free(tok, toklen);
    432   return(cat);
    433 }
    434 
    435374/* hooks for doing memory allocation et. al. in owl */
    436375
     
    692631}
    693632
    694 /* add the string 'str' to the list 'list' of strings, only if it
    695  * is not already present
    696  */
    697 void owl_util_list_add_unique_string(owl_list *list, char *str)
    698 {
    699   int i, j;
    700 
    701   j=owl_list_get_size(list);
    702   for (i=0; i<j; i++) {
    703     if (!strcmp(str, owl_list_get_element(list, i))) return;
    704   }
    705   owl_list_append_element(list, owl_strdup(str));
    706 }
    707 
    708 int owl_util_common_strings_in_lists(owl_list *a, owl_list *b)
    709 {
    710   int i, j, x, y;
    711 
    712   j=owl_list_get_size(a);
    713   for (i=0; i<j; i++) {
    714     y=owl_list_get_size(b);
    715     for (x=0; x<y; x++) {
    716       if (!strcmp(owl_list_get_element(a, i), owl_list_get_element(b, x))) return(1);
    717     }
    718   }
    719   return(0);
    720 }
    721 
    722633int owl_util_max(int a, int b)
    723634{
     
    883794              !strcmp("meep", skiptokens("foo 'bar quux' meep", 2)));
    884795
    885   FAIL_UNLESS("owl_util_uniq 1",
    886               !strcmp("foo bar x", owl_util_uniq("foo", "bar x", "-")));
    887   FAIL_UNLESS("owl_util_uniq 2",
    888               !strcmp("foo bar x", owl_util_uniq("foo", "bar -y x", "-")));
    889   FAIL_UNLESS("owl_util_uniq 3",
    890               !strcmp("meep foo bar", owl_util_uniq("meep foo", "bar foo meep", "-")));
    891 
    892796  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
    893797  printf("# END testing owl_util (%d failures)\n", numfailed);
Note: See TracChangeset for help on using the changeset viewer.