MODULE STRCMP ( IDENT = 'X00.04' %TITLE 'XST$CMP String Comparison Function' %BLISS32( ,ADDRESSING_MODE( EXTERNAL=LONG_RELATIVE ) ) %BLISS36( ,ENTRY( XST$CMP ),OTS='' ) ) = BEGIN ! ! COPYRIGHT (c) 1980 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: BLISS Library ! ! ABSTRACT: ! ! This module implements the $STR_COMPARE function. ! ! ENVIRONMENT: User mode - multiple host operating/file systems ! ! AUTHOR: Ward Clark, CREATION DATE: 15-Feb-80 ! !-- ! ! TABLE OF CONTENTS: ! FORWARD ROUTINE XST$CMP; ! String comparison routine ! ! INCLUDE FILES: ! LIBRARY 'XPORT' ; ! Public XPORT control block and macro definitions LIBRARY 'XPOSYS' ; ! Internal XPORT macro definitions $XPO_SYS_TEST( $ALL ) ! ! MACROS: ! ! ! EQUATED SYMBOLS: ! ! ! PSECT DECLARATIONS: ! $XPO_PSECTS ! Declare XPORT PSECT names and attributes ! ! OWN STORAGE: ! OWN function_text : $STR_DESCRIPTOR( STRING = ' compared to ' ); ! ! EXTERNAL REFERENCES: ! GLOBAL ROUTINE XST$CMP( options, string1, string2, fill, success_action, failure_action ) = !++ ! ! FUNCTIONAL DESCRIPTION: ! ! This routine implements the $STR_COMPARE function. ! ! FORMAL PARAMETERS: ! ! options - string handling options ! string1 - address of a string descriptor ! string2 - address of a string descriptor ! fill - optional fill character ! success_action - address of a success action routine ! failure_action - address of a failure action routine ! ! IMPLICIT INPUTS: ! ! None ! ! IMPLICIT OUTPUTS: ! ! None ! ! COMPLETION CODES: (secondary passed to action routine only) ! ! completion code from CH$COMPARE function ( -1, 0, 1 ) or equivalent ! ! STR$_BAD_STRNG1 - invalid primary string ! secondary = failure completion code from $STR_VALIDATE ! STR$_BAD_STRNG2 - invalid secondary string ! secondary = failure completion code from $STR_VALIDATE ! ! SIDE EFFECTS: ! ! None ! !-- BEGIN MAP options : $STR_OPTIONS, string1 : REF $STR_DESCRIPTOR(), string2 : REF $STR_DESCRIPTOR(); MACRO length1 = string1[STR$H_LENGTH] %, pointer1 = string1[STR$A_POINTER] %, length2 = string2[STR$H_LENGTH] %, pointer2 = string2[STR$A_POINTER] %; ! ! Initialization ! $STR_MAIN_BEGIN( COMPARE ) $STR_VALIDATE( .string1, BAD_STRNG1 ); ! Validate the two input string descriptors. $STR_VALIDATE( .string2, BAD_STRNG2 ); ! ! Perform a normal comparison if a fill character was specified or the strings are the same length. ! IF .fill NEQ -1 OR .length1 EQL .length2 THEN $STR_QUIT(( CH$COMPARE( .length1, .pointer1, .length2, .pointer2, .fill ) )); ! ! Perform special comparison processing if no fill character was specified. ! IF .length1 LSS .length2 THEN IF CH$LEQ( .length1, .pointer1, .length1, .pointer2, 0 ) THEN $STR_QUIT( (-1) ) ELSE $STR_QUIT( (1) ) ELSE IF CH$LSS( .length2, .pointer1, .length2, .pointer2, 0 ) THEN $STR_QUIT( (-1) ) ELSE $STR_QUIT( (1) ); $STR_MAIN_END; ! ! Call an appropriate action routine. ! $STR_ACTION_RTN( function_text, .string1, .string2 ); ! ! Free any temporary XPORT strings input to this comparison function. ! IF NOT .options[STR$V_NO_FREE_T] ! Unless this is an internal XPORT call, THEN ! BEGIN ! $STR_FREE_TEMP( .string1 ); ! free any temporary input strings. $STR_FREE_TEMP( .string2 ); END; ! ! Return the final completion code to the caller. ! RETURN .primary_code END; END ELUDOM