Technical Capabilities
Having trouble finding what you need?
Get in touch with us, so we can answer your specific questions directly.
Get In Touch

STR$ – STRING Interface Routines

Overview

VX/STR$ is a call-compatible implementation of the OpenVMS STR$ string manipulation run-time library for x86 and ARM Linux. It is not a standalone product or daemon: it is a set of callable routines compiled into the shared VX/RT archive libvxrt.a. A migrated OpenVMS application, whether in translated C, COBOL, FORTRAN, BASIC, or Pascal, links against that archive and calls STR$TRIM, STR$CONCAT, and the rest exactly as it did on VMS.

The library covers string manipulation, searching, formatting, and decimal-string numeric operations across the OpenVMS VMS descriptor model, auto-detecting 32-bit and 64-bit descriptors so the same routine handles both. It preserves OpenVMS string handling behavior, including its condition-code return convention, so applications that depend on STR$ services migrate and run without rewriting the calling code.

Architecture: how a STR$ call reaches the code

VX/STR$ has no process model to administer. Each OpenVMS STR$xxx entry point is implemented as its own C++ function body, compiled to an object file, and archived into libvxrt.a. The relevant architecture is the symbol and entry-point plumbing that lets a single C++ body answer to VMS-style names and to language-specific calling conventions. The product surface is therefore one archive, roughly 40 built entry points, four external symbol names each, and one descriptor model.

LayerMechanism
Canonical C++ bodySTR_D_<NAME>(...) (for example STR_D_TRIM): the real implementation.
VMS-style aliasesAn __AliasF4() macro emits assembler .set aliases mapping STR$NAME and str$name to the canonical body.
FORTRAN entry pointF4_STR_D_<NAME>(...): unpacks the hidden trailing string-length arguments, builds descriptors, then tail-calls the C++ body.
FORTRAN aliasesThe same macro maps the trailing-underscore names STR$NAME_ and str$name_ to the FORTRAN entry.
Descriptor helpersvxrt_strptr64, vxrt_dsc64t, vxrt_setlen, and vxrt_is_dsc64 resolve 32-bit, 64-bit, and varying descriptors.

Four external symbols per routine

A single alias line at the foot of each source file emits four external symbols. For STR$TRIM the names are STR$TRIM and str$trim (aliases of the C++ body STR_D_TRIM), plus STR$TRIM_ and str$trim_ (trailing-underscore FORTRAN names, aliases of the FORTRAN thunk F4_STR_D_TRIM). C, C++, and COBOL callers bind to STR$TRIM; FORTRAN callers bind to STR$TRIM_. The alias macro:

/* Linux build */
#define __MkAlias(sym, alias)                          \
  __asm__(".global " alias);                            \
  __asm__(".set " alias ", " sym)

#define __AliasF4(sym, symF, aliasU, aliasL)           \
  __MkAlias2(#sym,  #aliasU,      #aliasL);               \
  __MkAlias2(#symF, #aliasU "_",  #aliasL "_")
One body, four names. F4_STR_D_NAME is the internal FORTRAN thunk symbol, not itself a public alias. The four externally visible names are STR$NAME, str$name, STR$NAME_, and str$name_. On Apple and Cygwin builds the macro prepends a leading underscore to every symbol; production Linux builds use the plain names.

The canonical call pattern

Every routine follows the same shape: validate the pointers, resolve the source string through vxrt_strptr64 (which is aware of 32-bit, 64-bit, and varying descriptors), do the work into a scratch buffer, then funnel the result through STR$COPY_R64, the universal class-aware copy primitive.

Caller
STR$NAMECalls STR_D_NAME(dest, source, ...).
01ValidateReturn SS$_ACCVIO immediately if a required pointer is null.
02Resolvevxrt_strptr64 resolves a 32-bit, 64-bit, or varying descriptor.
03TransformPerform the routine's work in a scratch buffer.
04CopySTR_D_COPY_R64(dest, &len, buf) writes through the shared class-aware primitive.
Return
Condition value returns to the callerThe least-significant bit is 1 for success.

The descriptor model

The one data structure a caller must understand is the VMS descriptor. Every string argument is a descriptor passed by reference. The runtime auto-detects 32-bit versus 64-bit layout with vxrt_is_dsc64, and the class field selects the storage model. The STR$ routines actively handle three classes: Static (1), Dynamic (2), and Varying (11). Any other class returns STR$_ILLSTRCLA.

Class symbolValueNameStorage model
DSC_sK_CLASS_S1StaticFixed buffer; the length field is both capacity and valid length.
DSC_sK_CLASS_D2DynamicRuntime-allocated buffer, resizable via STR$GET1_DX, owned by the descriptor.
DSC_sK_CLASS_VS11VaryingPascal-style: buffer prefixed by a 16-bit current-length word.
DSC_sK_CLASS_SD9Scaled decimalPresent in headers; not a STR$ string class.
DSC_sK_CLASS_VSA12Varying arrayPresent in headers.
DSC_sK_CLASS_SB15Static boundedPresent in headers.

The datatype field is normally DSC_sK_DTYPE_T (value 14, text). The high bit 0x80 of the datatype marks a temporary string handed out by STR$GET_TEMPSTR; it is cleared by STR$COPY_DX when the temporary is consumed.

Descriptor auto-detection is transparent. Because the runtime detects 32-bit versus 64-bit descriptors at call time, the same routine handles both widths. A 64-bit variant such as STR$COPY_R64 exists for callers that build 64-bit descriptors directly, but the class-aware primitive underneath is shared.

Callable routine catalogue

VX/STR$ builds 40 public STR$ entry points into libvxrt.a, covering manipulation, searching, formatting, comparison, descriptor management, and decimal-string arithmetic. Two further routines are present in the source but not built. The status column marks the 40 built routines live and the two decimal-math routines that are not linked into the archive not built.

STR$ APIFunctionStatus
STR$ADDDecimal-string addition on a sign, exponent, and digit-string triple.live
STR$ANALYZE_SDESCExtract length and data pointer from a 32-bit-length descriptor.live
STR$ANALYZE_SDESC_6464-bit-length variant; sets the descriptor-type flag.live
STR$APPENDIn-place append onto a Dynamic or Varying destination.live
STR$BYTES_COPIEDResolve the number of bytes that fit, min(origlen, dsclen).live
STR$CASE_BLIND_COMPARECase-insensitive compare.live
STR$COMPARESpace-padded byte compare; returns -1, 0, or 1.live
STR$COMPARE_EQLStrict length and content equality (0 equal, 1 not equal).live
STR$COMPARE_MULTIFlag-dispatched blind or exact compare for sorting and validation.live
STR$CONCATVariadic append chain, terminated by a -1 or NULL argument.live
STR$COPY_DXDescriptor-to-descriptor copy; clears the temporary bit.live
STR$COPY_DX_TO_RDescriptor to C buffer, NUL-terminated.live
STR$COPY_RClass-aware copy primitive (32-bit length).live
STR$COPY_R6464-bit-length copy primitive; the workhorse everything funnels through.live
STR$COPY_R0Copy a NUL-terminated C string into a descriptor.live
STR$DIVIDEDecimal-string long division, with a truncate or round flag.live
STR$DUPL_CHARFill a destination with N copies of one byte.live
STR$ELEMENTExtract the Nth delimiter-split token (0-based).live
STR$FIND_FIRST_IN_SET1-based position of the first character present in a set.live
STR$FIND_FIRST_NOT_IN_SET1-based position of the first character absent from a set.live
STR$FIND_FIRST_SUBSTRINGLeftmost match of any of several variadic substrings.live
STR$FREE1_DXFree a Dynamic buffer and zero the descriptor fields.live
STR$GET1_DXAllocate or reallocate a Dynamic buffer (16-bit length).live
STR$GET1_DX_6464-bit-length dynamic allocation or reallocation.live
STR$GET_TEMPSTRPool-allocate a temporary Static descriptor (up to 2000 concurrent).live
STR$LEFTCopy the leftmost N characters (position clamped).live
STR$LEN_EXTRExtract len characters from a 1-based start.live
STR$LENGTHEffective string length (flag handling defaults only).live
STR$MATCH_WILDWildcard match with * and % and backtracking.live
STR$MULDecimal-string multiply (see the divergences section for the precision caveat).live
STR$POINTERReturn the bare data pointer for a descriptor.live
STR$POSITION1-based position of a substring, with optional start.live
STR$POS_EXTRCopy the substring between a 1-based start and end.live
STR$PREFIXIn-place insert a prefix at the front of a destination.live
STR$REPLACEReplace a substring: source[..start-1] + repl + source[end+1..].live
STR$RIGHTCopy the substring from a 1-based position to the end.live
STR$SETVSLENSet the current-length word of a Varying string.live
STR$TRANSLATEPer-byte translate via match and translation tables.live
STR$TRIMCopy while dropping trailing spaces and tabs.live
STR$UPCASECopy folding lowercase to uppercase.live
STR$RECIPDecimal-string reciprocal.not built
STR$ROUNDRound or truncate a decimal string to N places.not built

The count is 42 public STR$ names across the source, 40 built into libvxrt.a and 2 not built (STR$RECIP and STR$ROUND). Calling either of the two unbuilt routines produces a link error rather than a run-time failure.

Status and signal conventions

Return values are 32-bit VMS condition codes. The success test is the same as on OpenVMS: the least significant bit set (ret & 1) means success. The two common outcomes returned as ordinary values are SS$_NORMAL and the truncation warning STR$_TRU. The table lists the condition codes the library returns, with their VMS-visible names and values.

VMS nameValueMeaning
SS$_NORMAL1Success.
SS$_ACCVIO12Access violation (NULL pointer or no buffer).
STR$_TRU0x248200Truncation warning.
STR$_FATINTERR0x248044Fatal internal error.
STR$_DIVBY_ZER0x24804CDivisor is zero.
STR$_ILLSTRCLA0x248054Illegal string class.
STR$_WRONUMARG0x248064Wrong number of arguments.
STR$_INSVIRMEM0x24806CInsufficient virtual memory.
STR$_STRTOOLON0x248074Source longer than destination (internal).
STR$_ERRFREDYN0x24807CError freeing a dynamic string.
STR$_NOMATCH0x248208Wildcard: no match.
STR$_INVDELIM0x248210Invalid delimiter.
STR$_NOELEM0x248218Element does not exist.
STR$_ILLSTRPOS0x248409Illegal string position.
STR$_ILLSTRSPE0x248411Illegal start or end specifier.
STR$_MATCH0x248419Wildcard: matched.
Test the low bit, not equality. Success covers any odd value, so callers should test ret & 1 (or ODD(ret) in VMS languages) rather than comparing against a single success constant. A truncation warning is a success value that still delivered a result.

A real call path

STR$TRIM is small enough to show both entry points, and it is the template every routine in the library follows. The canonical descriptor body validates its pointers, resolves the source through vxrt_strptr64, scans off trailing spaces and tabs, and hands the result to the copy primitive:

/* canonical descriptor body */
U32 STR_D_TRIM( VMS_DESCR *dest, VMS_DESCR *source, U16 *length )
{
    U64  i, splen;
    char *s_pointer;

    if (!dest || !source)      return SS$_ACCVIO;
    s_pointer = (char *)vxrt_strptr64(source, &splen);   /* 32/64/varying aware */
    if (!s_pointer)            return SS$_ACCVIO;

    i = splen;
    while (i) {                /* drop trailing ' ' and '\t' */
        i--;
        if (s_pointer[i] != ' ' && s_pointer[i] != '\t') { i++; break; }
    }
    Msw( length, i );          /* store length only if the pointer is non-NULL */
    return STR_D_COPY_R64(dest, &i, (void*)s_pointer);
}

The FORTRAN thunk

A separate FORTRAN-callable entry unpacks the hidden trailing length arguments the FORTRAN compiler passes for each string, builds descriptors, and tail-calls the same C++ body. A single __AliasF4 line then wires up all four public names:

extern "C"
U32 F4_STR_D_TRIM( F4STR(dest), F4STR(source), U16 *len,
                   F4STR_N(dest), F4STR_N(source) )   /* hidden length args */
{
    F4STR_DECL(dest);  F4STR_DECL(source);
    F4STR_INIT_2(dest, source);        /* build DESCR64 from ptr + len pairs */
    return STR_D_TRIM(dest, source, len);
}
__AliasF4(STR_D_TRIM, F4_STR_D_TRIM, STR$TRIM, str$trim);

Variadic routines need a terminator

STR$CONCAT illustrates the one calling-convention gotcha a migration engineer must know. The C, C++, and COBOL entry walks its argument list until it hits a -1 or NULL descriptor, so callers must terminate the list explicitly or the loop reads past the call frame. The FORTRAN thunk instead guesses pointer versus length by the numeric magnitude of each argument, treating values above 32768 as pointers:

/* C/C++/COBOL entry: list terminated by (VMS_DESCR *)-1 or NULL */
U32 STR_D_CONCAT(VMS_DESCR *dst, ...) {
    va_list ap;  U32 ret = SS$_ACCVIO;
    va_start(ap, dst);
    while (1) {
        void *tstr = va_arg(ap, VMS_DESCR *);
        if (tstr == (VMS_DESCR *)-1 || tstr == (VMS_DESCR *)0) break;
        ret = STR_D_APPEND(dst, tstr);      /* APPEND handles Dynamic and Varying */
        if (!(ret & 1)) break;             /* stop on first failure */
    }
    return ret;
}
__AliasF4(STR_D_CONCAT, F4_STR_D_CONCAT, STR$CONCAT, str$concat);

The same pattern appears in a migrated application. A translated program links this unchanged against libvxrt.a and tests each result with the VMS ODD() convention:

! trim an account holder name field and build a display label
status = STR$TRIM   (TRIMMED_NAME, ACCT_HOLDER_NAME)
IF (.NOT. ODD(status)) CALL LIB$SIGNAL(status)

status = STR$CONCAT (DISPLAY_LABEL,
                     'ACCOUNT: ',
                     ACCT_NUMBER,
                     '  ',
                     TRIMMED_NAME)      ! FORTRAN thunk pads to a fixed slot count
IF (.NOT. ODD(status)) CALL LIB$SIGNAL(status)

Behavior notes and divergences

VX/STR$ aims for bug-for-bug OpenVMS compatibility, and in a few places it deliberately or knowingly diverges from the original specification. These are the behaviors a migration engineer should confirm against their own workload before cutover.

AreaBehaviorImpact
STR$RECIP, STR$ROUNDPresent in source but not built into the archive.Calling either produces a link error. Decimal-math reciprocal and rounding are deferred.
STR$MULUses 64-bit integer multiply rather than digit-by-digit decimal math.Loses precision beyond roughly 18 significant digits. Confirm before relying on wide decimal operands.
STR$LENGTHFlag bits are parsed but only the default length behavior is implemented.Non-default flag combinations behave as the default rather than raising an error.
NULL-pointer pathsSeveral routines return SS$_ACCVIO where VMS would raise LIB$_INVARG or STR$_ILLSTRCLA.Error codes differ on invalid input, though both are failure values under the odd-success test.
STR$TRANSLATEUses a fixed stack scratch buffer of about 100000 bytes with no allocation fallback.Source strings larger than roughly 100 KB overflow the stack. Other routines fall back to allocation above the fast path.
STR$ADDA Varying zero result writes a single-byte Ctrl-A (0x01).Intentional bug-for-bug VMS compatibility; matches the original behavior.
STR$COMPAREReturns a three-valued -1, 0, or 1 with space-padding of the shorter operand.Callers that assumed a two-valued result on some historical documentation should test the sign.
Decimal-math caveat. The decimal-string arithmetic routines are the area most worth validating: STR$MUL is integer-backed and loses precision on wide operands, and STR$RECIP and STR$ROUND are not built. Workloads that lean on full-precision decimal math should be reviewed as part of the migration.

Constants, limits, build and test

Real constants and limits

ConstantValueApplies to
Max decimal digits per operand250Decimal operands in STR$ADD and STR$DIVIDE; over-length returns STR$_TRU.
Temporary-string pool size2000Maximum concurrent STR$GET_TEMPSTR descriptors.
Stack scratch buffer100000 bytesFast path before allocation fallback (except STR$TRANSLATE, which has no fallback).
Temporary datatype bit0x80Marks a temporary string; cleared by STR$COPY_DX.
FORTRAN pointer or length threshold32768The STR$CONCAT FORTRAN thunk treats values above this as pointers.

Build

The library is built with make in the STR$ source directory, which compiles each source file to an object and archives it into libvxrt.a. A migrated application links against that archive alongside the rest of VX/RT. There is no separate run-time service to install or configure.

Regression testing

A standalone regression driver exercises the major routines against both 32-bit and 64-bit descriptor classes. It is a separate test program and is not part of the shipped archive. The upstream reference is the OpenVMS RTL String Manipulation Reference Manual, and where the historical documentation disagrees with the current implementation, the implementation is authoritative.

Quick reference

Manipulation and formatting

STR$APPEND
STR$CONCAT
STR$PREFIX
STR$REPLACE
STR$TRIM
STR$UPCASE
STR$TRANSLATE
STR$DUPL_CHAR
STR$LEFT
STR$RIGHT
STR$POS_EXTR
STR$LEN_EXTR
STR$ELEMENT

Searching and comparison

STR$COMPARE
STR$COMPARE_EQL
STR$COMPARE_MULTI
STR$CASE_BLIND_COMPARE
STR$POSITION
STR$FIND_FIRST_SUBSTRING
STR$FIND_FIRST_IN_SET
STR$FIND_FIRST_NOT_IN_SET
STR$MATCH_WILD
STR$LENGTH

Descriptor and memory management

STR$GET1_DX
STR$GET1_DX_64
STR$FREE1_DX
STR$GET_TEMPSTR
STR$ANALYZE_SDESC
STR$ANALYZE_SDESC_64
STR$COPY_DX
STR$COPY_DX_TO_R
STR$COPY_R
STR$COPY_R64
STR$COPY_R0
STR$POINTER
STR$SETVSLEN
STR$BYTES_COPIED

Decimal-string arithmetic

STR$ADD
STR$DIVIDE
STR$MUL

Things to remember

TopicRule
Link againstlibvxrt.a, the shared VX/RT archive.
Call any ofSTR$NAME or str$name from C, C++, and COBOL; STR$NAME_ or str$name_ from FORTRAN.
Copy primitiveEverything funnels through STR$COPY_R64(dest, &len, src).
Classes handledStatic (1), Dynamic (2), Varying (11); anything else returns STR$_ILLSTRCLA.
Success testret & 1: the low bit set means success.
Variadic terminatorSTR$CONCAT and STR$FIND_FIRST_SUBSTRING need a -1 terminator.
Not builtSTR$RECIP and STR$ROUND cause a link error if called.
Decimal-math caveatSTR$MUL is integer-backed, not full-precision.

Frequently Asked Questions

Curious about how Sector7 can facilitate your application migration? Explore our FAQs for expert insights.

What is VX/STR$ and how does it help with OpenVMS migration?

VX/STR$ provides a call-compatible implementation of OpenVMS string processing functions for x86 and ARM Linux. It ensures that OpenVMS applications can manipulate, compare, and process strings while preserving compatibility with existing logic and execution behavior, making migration seamless without requiring major code modifications.

For organizations planning their modernization strategy, contact us to discuss how VX/STR$ can support your specific migration requirements.

Which string operations does VX/STR$ support?

VX/STR$ supports comprehensive string manipulation including searching, formatting, numeric operations, concatenation, comparison, trimming, case conversion, and wildcard matching.

How does VX/STR$ integrate with other VX tools?

VX/STR$ seamlessly integrates with VX/RT to provide full OpenVMS string processing capabilities on x86 and ARM Linux platforms.

Does VX/STR$ maintain OpenVMS string handling behavior?

Yes, VX/STR$ maintains OpenVMS string handling behavior, ensuring consistent results across platforms and preserving the exact execution logic of your original applications.

What types of string descriptors does VX/STR$ handle?

VX/STR$ handles various OpenVMS string descriptors including standard descriptors, 64-bit descriptors, and right-aligned descriptors. It provides functions like STR$ANALYZE_SDESC, STR$ANALYZE_SDESC_64, STR$COPY_DX, and STR$GET1_DX_64 for comprehensive descriptor management. Companies like Telstra have successfully leveraged similar string processing capabilities during their migrations.

Can VX/STR$ perform arithmetic operations on string data?

VX/STR$ supports arithmetic operations on string-based numeric data through functions like STR$ADD, STR$DIVIDE, and STR$MUL, maintaining OpenVMS compatibility for numeric string processing.

How does VX/STR$ handle memory management for strings?

VX/STR$ provides descriptor-based memory management through functions like STR$GET1_DX for allocating descriptors, STR$FREE1_DX for releasing memory, and STR$GET_TEMPSTR for temporary string buffers, ensuring proper memory handling consistent with OpenVMS practices.

What is VX/STR$?

VX/STR$ is a call-compatible implementation of the OpenVMS STR$ string processing routines for x86 and ARM Linux. It lets OpenVMS applications manipulate, compare, and process strings while preserving compatibility with existing logic and execution behavior. It ships as callable routines inside the shared VX/RT archive, so migrated code links against it and calls the STR$ routines exactly as it did on VMS.

Which categories of string operations does VX/STR$ cover?

VX/STR$ covers string manipulation, searching, formatting, and decimal-string numeric operations. That spans concatenation, appending and prefixing, comparison including case-blind compare, substring searching and positioning, trimming, case conversion, character translation, and wildcard matching, alongside descriptor and memory management routines.

Can VX/STR$ perform arithmetic on numeric strings?

Yes. It provides STR$ADD and STR$DIVIDE for addition and division on string-based decimal numeric data, and STR$MUL for multiplication. Note that STR$MUL is integer-backed rather than full-precision decimal math, so workloads that rely on wide decimal operands should validate precision as part of the migration.

How does VX/STR$ manage string descriptors and memory?

It offers descriptor-based memory management. STR$GET1_DX and STR$GET1_DX_64 obtain dynamic descriptors, STR$FREE1_DX releases them, STR$GET_TEMPSTR provides a temporary buffer, and STR$ANALYZE_SDESC and STR$ANALYZE_SDESC_64 analyze standard and 64-bit descriptors. The runtime handles Static, Dynamic, and Varying descriptor classes.

Does VX/STR$ support 64-bit string descriptors?

Yes. Routines such as STR$ANALYZE_SDESC_64, STR$GET1_DX_64, and STR$COPY_R64 operate on 64-bit descriptors and strings alongside their 32-bit equivalents. The runtime auto-detects 32-bit versus 64-bit descriptors, so the same routine handles both widths.

On which platforms does VX/STR$ run?

VX/STR$ runs on x86 and ARM Linux. It is delivered inside VX/RT to provide full OpenVMS string processing capabilities on those platforms, and a migrated application links against the shared VX/RT archive to use it.

Will string results match what the application saw on OpenVMS?

VX/STR$ maintains OpenVMS string handling behavior to keep results consistent across platforms, including the VMS condition-code return convention where the low bit set means success. A small number of documented edge cases diverge, so those areas should be validated, but applications that rely on STR$ routines behave the same after migration.

How much application code has to change to adopt VX/STR$?

Little to none for the string handling itself. Because the STR$ routines are call-compatible and exported under the same VMS-visible names, applications that depend on STR$ services migrate without major modifications. This preserves productivity and minimizes development cost and project risk.

Transform Your Legacy Software Today!

Get In Touch
Unlock the potential of your legacy software with our expert migration services.