home *** CD-ROM | disk | FTP | other *** search
/ Best Objectech Shareware Selections / UNTITLED.iso / boss / word / text / 019 / word.c < prev    next >
Text File  |  1993-01-19  |  1KB  |  61 lines

  1. /*
  2.  *  Copyright (c) 1992 John E. Davis  (davis@amy.tch.harvard.edu)
  3.  *  All Rights Reserved.
  4.  */
  5. /* delete next word through whitespace.  What is a word?
  6.  
  7.    Here I consider two types of words:
  8.  
  9.       a) is a sequence of alphanumeric characters.
  10.  
  11.       b) consists of non-whitespace, non-alphanumeric charcters.
  12.  
  13.    Delete word means:
  14.  
  15.       1. Delete whitespace.
  16.       2. Delete word (type (a) or type (b))
  17.       3. If the word was type (a) then done.
  18.       4. If the word was type (b) consisting of only a single character and
  19.          the next non-deleted character is not whitespace then delete the
  20.      next word and exit.
  21. */
  22.  
  23. int delete_word()
  24. {
  25.    volatile unsigned char *p;
  26.    int len = 0;
  27.  
  28.    /* delete whitespace */
  29.  
  30.    while(1)
  31.      {
  32.     p = CLine->data + Point;
  33.     if (*p <= ' ') del(); else break;
  34.      }
  35.  
  36.    if (isalpha(*p) || isdigit(*p))
  37.      {
  38.     do
  39.       {
  40.          del();
  41.          p = CLine->data + Point;
  42.       }
  43.     while (isalpha(*p) || isdigit(*p));
  44.     return(1);
  45.      }
  46.  
  47.    /* type b */
  48.  
  49.    del();
  50.    p = CLine->data + Point;
  51.    if (isalpha(*p) || isdigit(*p)) return(delete_word());
  52.  
  53.    while(*p >= ' ')
  54.      {
  55.     if ((isalpha(*p) || isdigit(*p))) break;
  56.     del();
  57.     p = CLine->data + Point;
  58.      }
  59.    return(1);
  60. }
  61.