Changeset e50cd56 for util.c


Ignore:
Timestamp:
Jul 11, 2002, 12:47:16 AM (22 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
aa2f33b3
Parents:
e173507
Message:
Fixed some buffer overruns in the "reply" command.
When repying to "all" on a message that begins with "CC:" (eg, sent
         with "zwrite -C", the reply line will be constructed
         from the sender and the usernames on the CC: line
         of the message being replied to.
There is no such thing as C-R, so left C-r as it is but added:
         M-r --- edit reply to all
         M-R --- edit reply to sender
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    re1c4636 re50cd56  
    298298  return(ret);
    299299}
     300
     301/* Caller must free response.
     302   Takes in strings which are space-separated lists of tokens
     303   and returns a single string containing no token more than once.
     304   If prohibit is non-null, no token may start with a character
     305   in prohibit.
     306*/
     307char *owl_util_uniq(char *A, char *B, char *prohibit) {
     308  char *cat, **tok;
     309  int toklen, i, j, first=1;
     310  cat = owl_malloc(strlen(A)+strlen(B)+3);
     311  strcpy(cat, A);
     312  strcat(cat, " ");
     313  strcat(cat, B);
     314  tok = atokenize(cat, " ", &toklen);
     315  strcpy(cat, "");
     316  for (i=0; i<toklen; i++) {
     317    int dup=0;
     318    for (j=0; j<i; j++) {
     319      if (!strcmp(tok[i], tok[j])) dup=1;
     320    }
     321    if (!dup && (!prohibit || !strchr(prohibit, tok[i][0]))) {
     322      if (!first) {
     323        strcat(cat, " ");
     324      }
     325      first=0;
     326      strcat(cat, tok[i]);
     327    }
     328  }
     329  atokenize_free(tok, toklen);
     330  return(cat);
     331}
     332
     333
    300334
    301335/* returns if a string is only whitespace */
     
    482516              !strcmp("meep", skiptokens("foo 'bar quux' meep", 2)));
    483517
     518  FAIL_UNLESS("owl_util_uniq 1",
     519              !strcmp("foo bar x", owl_util_uniq("foo", "bar x", "-")));
     520  FAIL_UNLESS("owl_util_uniq 2",
     521              !strcmp("foo bar x", owl_util_uniq("foo", "bar -y x", "-")));
     522  FAIL_UNLESS("owl_util_uniq 3",
     523              !strcmp("meep foo bar", owl_util_uniq("meep foo", "bar foo meep", "-")));
     524
    484525  if (numfailed) printf("*** WARNING: failures encountered with owl_util\n");
    485526  printf("END testing owl_util (%d failures)\n", numfailed);
Note: See TracChangeset for help on using the changeset viewer.