SPL to HP C/XL Migration Guide (30231-90001)

5-35
you may use the HP C/XL equivalent:
if isdigit(*(s1-1)).../* move stopped on a digit */
______________________________________________________________________
| |
| enum COND { A, AN, AS, N, ANS }; |
| |
| int MOVEBW(to,from,cond,sdec,source_adr,dest_adr) |
| enum COND cond; |
| char *to, *from, **source_adr, **dest_adr; |
| int sdec; |
| { |
| char *temp; |
| temp = to; |
| switch (cond) |
| { |
| case A: while (isalpha(*from)) *to++=*from++; |
| break; |
| case AN: while (isalnum(*from)) *to++=*from++; |
| break; |
| case AS: while (isalpha(*from)) *to++=toupper(*from++);|
| break; |
| case N: while (isdigit(*from)) *to++ = *from++; |
| break; |
| case ANS: while (isalnum(*from)) *to++=toupper(*from++);|
| break; |
| } |
| |
| switch (sdec) |
| { |
| case 0: ; /* fall through to case 1 */ |
| case 1: *source_adr = from; |
| case 2: *dest_adr = to; |
| } |
| |
| return(to-temp); |
| } |
______________________________________________________________________
Figure 5-23. HP C/XL MOVEBW Function: MOVE Bytes WHILE Statement
Moving a string constant into a byte array or through a byte pointer may
require the HP C/XL MOVESB function, shown in Figure 5-24.
______________________________________________________
| |
| int MOVESB(to,str,sdec,source_adr,dest_adr) |
| char *to, *str, **source_adr, **dest_adr; |
| int sdec; |
| { |
| char *temp; |
| temp = to; |
| while (*str != '\0') *to++ = *str++; |
| switch (sdec) |
| { |
| case 0: ; /* fall through to case 1 */|
| case 1: *source_adr = str; |
| case 2: *dest_adr = to; |
| case 3: ; /* nil */ |
| } |
| return(to - temp); |
| } |
______________________________________________________
Figure 5-24. HP C/XL MOVESB Function: MOVE String Bytes Statement