home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / TEXT / UTILITY / SSPELL12.ZIP / UTILITY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-04  |  4.1 KB  |  133 lines

  1. /* **************************************************************** */
  2. /*             sspell - similar to Unix spell                       */
  3. /*                        version 1.2                               */
  4. /*                                                                  */
  5. /* Author: Maurice Castro                                           */
  6. /* Release Date: 26 Jan 1992                                        */
  7. /* Bug Reports: maurice@bruce.cs.monash.edu.au                      */
  8. /*                                                                  */
  9. /* This code has been placed by the Author into the Public Domain.  */
  10. /* The code is NOT covered by any warranty, the user of the code is */
  11. /* solely responsible for determining the fitness of the program    */
  12. /* for their purpose. No liability is accepted by the author for    */
  13. /* the direct or indirect losses incurred through the use of this   */
  14. /* program.                                                         */
  15. /*                                                                  */
  16. /* Segments of this code may be used for any purpose that the user  */
  17. /* deems appropriate. It would be polite to acknowledge the source  */
  18. /* of the code. If you modify the code and redistribute it please   */
  19. /* include a message indicating your changes and how users may      */
  20. /* contact you for support.                                         */
  21. /*                                                                  */
  22. /* The author reserves the right to issue the official version of   */
  23. /* this program. If you have useful suggestions or changes for the  */
  24. /* code, please forward them to the author so that they might be    */
  25. /* incorporated into the official version                           */
  26. /*                                                                  */
  27. /* Please forward bug reports to the author via Internet.           */
  28. /*                                                                  */
  29. /* **************************************************************** */
  30.  
  31. #include "utility.h"
  32. #include <stdio.h>
  33. #include "strfn.h"
  34.  
  35. char *strip(a,b)
  36. char *a;
  37. char *b;
  38. {
  39.     char *match;
  40.     char *pt;
  41.     /* if the string 'a' contains any of string 'b' then chop them off */
  42.     pt = a;
  43.     while (*pt != NULL)
  44.     {
  45.         match = b;
  46.         while (*match != NULL)
  47.         {
  48.             if (*match == *pt)
  49.             {
  50.                *pt = NULL;
  51.                return(a);
  52.                }
  53.             match++;
  54.             }
  55.         pt++;
  56.         }
  57.     return(a);
  58.     }
  59.  
  60. char *strltok(st,c,sthold)
  61. char *st;
  62. char *c;
  63. char **sthold;
  64. {
  65.     char *stpt;
  66.     int cl;
  67.     int flag;
  68.  
  69.     if ((st == NULL) && (**sthold == NULL)) return(NULL); 
  70.  
  71.     if (st != NULL)
  72.     {
  73.         *sthold = st; 
  74.     }
  75.  
  76.     /* skip leading */
  77.     stpt = *sthold;
  78.     while (*stpt != NULL)
  79.     {
  80.         cl = 0;
  81.         flag = 1;
  82.         while (c[cl] != NULL)
  83.         {
  84.             if (*stpt == c[cl])
  85.                flag = 0;
  86.             cl++;
  87.             }
  88.         if (flag) break;
  89.         stpt++;
  90.         }
  91.  
  92.     if (*stpt == NULL) return(NULL);  /* hit end of string */
  93.  
  94.     *sthold = stpt;
  95.  
  96.     /* if trailing clobber and exit */
  97.     while (**sthold != NULL) 
  98.     {
  99.         cl = 0;
  100.         while (c[cl] != NULL)
  101.     {
  102.         if (**sthold == c[cl])
  103.         {
  104.         **sthold = NULL;
  105.                 (*sthold)++;
  106.         return(stpt);
  107.         }
  108.         cl++;
  109.         }
  110.     (*sthold)++;
  111.     }
  112.     return(stpt);
  113.     }
  114.  
  115. /* some machines have difficulties with a NULL being presented as a string
  116.    to the string copy operation. This new function prevents the problem,
  117.    unfortunately it causes a minor performance loss - so it is only used
  118.    in the root routine where the problem has been observed */
  119.  
  120. char *lstrcpy(s, ct)               /* the requirement for this check */
  121. char *s;                           /* was found by Mike O'Carroll */
  122. char *ct;                          /* M. Castro 4/3/92 */
  123. {
  124.      if (ct == NULL)
  125.      {
  126.          return(strcpy(s,""));
  127.          }
  128.      else
  129.      {
  130.          return(strcpy(s,ct));
  131.          }
  132.      }
  133.