/***************************************************************************** * * * Copyright (c) 1983 * * by Digital Equipment Corporation, Maynard, Mass. * * * * This software is furnished under a license and may be used and copied * * only in accordance with the terms of such license and with the * * inclusion of the above copyright notice. This software or any other * * copies thereof may not be provided or otherwise made available to any * * other person. No title to and ownership of the software is hereby * * transferred. * * * * The information in this software is subject to change without notice * * and should not be construed as a commitment by Digital Equipment * * Corporation. * * * * Digital assumes no responsibility for the use or reliability of its * * software on equipment which is not supplied by Digital. * * * *****************************************************************************/ /** * * FACILITY: SDL * * ABSTRACT: This module converts a string according to the replacement * rules supplied. It expands out such characters as ' to '' * which some languages may require in their strings. * * ENVIRONMENT: VAX/VMS * * AUTHOR: P. Goodwin * * CREATION DATE: 11-Jan-1988 * * MODIFIED BY: /* C H A N G E L O G Date ! Name ! Description ________________!_______!______________________________________________________ | | ________________|_______|______________________________________________________ * **/ /** * FUNCTIONAL DESCRIPTION: SDL$CVTSTR * * Takes a string and expands out special characters * * * FORMAL PARAMETERS: * * inbuf input buffer * outbuf output buffer * cvtstr convert string in the format 'xyy' where x is the * character to look for, yy is the replacement. For example * in CC, '"' is replaced by '\"' so xyy is '"\"'. * * IMPLICIT INPUTS: * * None. * * IMPLICIT OUTPUTS: * * None. * * ROUTINE VALUE: * COMPLETION CODES: * * None. * */ sdl$cvtstr: proc (inbuf, outbuf, cvtstr) options(ident('X3.2-0')); dcl inbuf char(128) var; /* input string */ dcl outbuf char(128) var; /* output string */ dcl cvtstr char(128) var; /* conversion rules */ dcl (i,j) fixed bin; /* indexes into input string and conversion rules */ dcl flag fixed bin(1); /* to say if conversion has occured */ /* empty the output string */ outbuf=''; /* step along input string */ do i=1 to length(inbuf) by 1; flag = 0; /* step along conversion rules, which are packed in groups of three characters */ do j=1 to length(cvtstr) by 3; /* does the input match the current conversion character? */ if substr(inbuf,i,1) = substr(cvtstr,j,1) then do; /* there is a match, set the flag, and output the converted characters */ flag = 1; outbuf = outbuf || substr(cvtstr,j+1,2); end; end; /* if there was no match at all, pass the input straight to the output */ if flag = 0 then outbuf = outbuf || substr(inbuf,i,1); end; end;