make_punctation.c

MudOSa4DGD/mudlib/dgd/sfun/make_punctation.c · 736 B

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * make_punctation.c
 *
 * SFUN: End a sentece with a .
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */

/* get rid of "blablabla. ." */
#define STRIP_TRAILING_WHITESPACE


/* end a sentence with a puntuation */
static varargs string make_punctation(string str, string end) {
  int t;
  string strorig;

  strorig = str;
  t = str[strlen(str)-1];

#ifdef STRIP_TRAILING_WHITESPACE
  while (t == ' ') {
    str = str[0..strlen(str)-2];
    t = str[strlen(str)-1];
  }
#endif

  /* default <end> is "." */
  if (!end) end = ".";

  /* return original string? */
  switch (t) {
  case '!':
  case '?':
  case '.':
    return strorig;
  }
  if (t == end[strlen(end)-1]) return strorig;

  /* make punctation at end */
  return str+end;
}

Site Stats

Snippets: 1791
Codebases: 571