home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / STRTRANS.C < prev    next >
C/C++ Source or Header  |  1984-12-31  |  2KB  |  46 lines

  1. /*  File   : strtrans.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 2 June 1984
  4.     Defines: strtrans()
  5.  
  6.     strtrans(dst, src, from, to)
  7.     copies characters from src[] to dst[], stopping when dst gets a  NUL
  8.     character,  translating  characters  in  from[] to the corresponding
  9.     characters in to[]. Courtesy of _str2map, if from or to is null  its
  10.     previous  value  will be used, and if both are NullS the table won't
  11.     be rebuilt.  Note that copying stops when a NUL is put  into  dst[],
  12.     which  can  normally  happen  only  when a NUL has been fetched from
  13.     src[], but if you have built your own translation table  it  may  be
  14.     earlier  (if  some  character  is mapped to NUL) or later (if NUL is
  15.     mapped to something else).  No value is returned.
  16.  
  17.     The VaxAsm version only works from strlen(src) < 2^16.
  18. */
  19.  
  20. #include "strings.h"
  21. #include "_str2map.h"
  22.  
  23. #if    VaxAsm
  24.  
  25. void strtrans(dst, src, from, to)
  26.     _char_ *dst, *src, *from, *to;
  27.     {
  28.     _str2map(0, from, to);
  29.     asm("movtuc $65535,*8(ap),$0,__map_vec,$65535,*4(ap)");
  30.     /*  That stops when the "escape" is found, and we want to move it */
  31.     asm("movb $0,(r5)");
  32.     }
  33.  
  34. #else  ~VaxAsm
  35.  
  36. void strtrans(dst, src, from, to)
  37.     register _char_ *dst, *src;
  38.     _char_ *from, *to;
  39.     {
  40.     _str2map(0, from, to);
  41.     while (*dst++ = _map_vec[*src++]) ;
  42.     }
  43.  
  44. #endif    VaxAsm
  45.