1: #include "../h/rt.h"
   2: 
   3: /*
   4:  * trim(s,c) - trim trailing characters in c from s.
   5:  */
   6: 
   7: Xtrim(nargs, arg2, arg1, arg0)
   8: int nargs;
   9: struct descrip arg2, arg1, arg0;
  10:    {
  11:    char *sloc;
  12:    char sbuf[MAXSTRING];
  13:    int *cs, csbuf[CSETSIZE];
  14:    static int spcset[CSETSIZE] = /* just a blank */
  15:       cset_display(0, 0, 01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  16: 
  17:    /*
  18:     * s must be a string; c defaults to a cset containing a blank.
  19:     */
  20:    if (cvstr(&arg1, sbuf) == NULL)
  21:       runerr(103, &arg1);
  22:    defcset(&arg2, &cs, csbuf, spcset);
  23: 
  24:    /*
  25:     * Start at the end of s and then back up until a character that is
  26:     *  not in c is found.  The actual trimming is done by having a descriptor
  27:     *  that points at the string of s, but has a reduced length.
  28:     */
  29:    arg0 = arg1;
  30:    sloc = STRLOC(arg1) + STRLEN(arg1) - 1;
  31:    while (sloc >= STRLOC(arg1) && tstb(*sloc, cs)) {
  32:       sloc--;
  33:       STRLEN(arg0)--;
  34:       }
  35:    }
  36: 
  37: Procblock(trim,2)

Defined functions

Xtrim defined in line 7; never used
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 402
Valid CSS Valid XHTML 1.0 Strict