home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / dbase_c.zip / DBSTRIP.C < prev    next >
Text File  |  1989-03-20  |  2KB  |  46 lines

  1. /*********************************************************
  2. * strip(str,len) strips the non-printing ascii characters*
  3. * from the string "str".  First the 8th bit is stripped  *
  4. * from  each  character and then the  following  rule is *
  5. * applied                                                *
  6. *                                                        *
  7. * (i)   If the character is <= 32 (space), except for ^Z *
  8. *       CP/M end of file, it is converted to a space     *
  9. *                                                        *
  10. * (ii)  Any character in the first position other than a *
  11. *       '*' (DBASE deleted record marker), a space or a  *
  12. *       ^Z is reset to a space (NORMAL status)           *
  13. *********************************************************/
  14. strip(buff,len) 
  15.      char buff[];
  16.      int  len;
  17. {
  18.      int      bad_char;
  19.      bad_char = 0;
  20.  
  21.      /*----- process the last n-1 charaters in the string -----*/
  22.      while ( --len > 0 ) 
  23.        {
  24.         if( buff[len] & 128 ) 
  25.           {
  26.            buff[len] = buff[len] & 127;
  27.            bad_char++;
  28.           }
  29.         if( buff[len] < 32 )
  30.           {
  31.            buff[len] = 32;
  32.            bad_char++;
  33.           }
  34.         }
  35.  
  36.      if( buff[0] != '*' && buff[0] != ' ' && buff[0] != CPM_EOF ) 
  37.        {
  38.         buff[0] = ' ';
  39.         bad_char++;
  40.        }
  41.  
  42.      return( bad_char );
  43. }
  44.  
  45. /* end of dbstrip.c */
  46.