/* * as close as we can come to Latin1Create without knowing the charset of * Latin1. This imposes the semantic of \n meaning separator. */ XmString XmStringLtoRCreate( char *text, XmStringTag tag ) { char *start, *end; Boolean done; XmString string; _XmProcessLock(); if (!text) { _XmProcessUnlock(); return (NULL); } start = text; done = FALSE; /* Set the direction once only at the beginning. */ string = XmStringDirectionCreate(XmSTRING_DIRECTION_L_TO_R); while ( ! done) /* loop thu local copy */ { /* looking for \n */ end = start; while ((*end != '\0') && (*end != '\n')) end++; if (*end == '\0') done = TRUE; /* we are at the end */ /* Don't convert empty string unless it's an initial newline. */ /* Done so StringHeight has clue to size of empty lines. */ if ((start != end) || (start == text)) string = XmStringConcatAndFree (string, _XmStringNCreate(start, tag, (int)(end - start))); /* Wyoming 64-bit fix */ /* Make a separator if this isn't the last segment. */ if (!done) { string = XmStringConcatAndFree(string, XmStringSeparatorCreate()); start = ++end; /* start at next char */ } } _XmProcessUnlock(); return (string); }
/* ** CreateListData(): routine to convert the ** poem into an array of compound strings */ XmStringTable CreateListData (int *count) { XmStringTable table = (XmStringTable) 0 ; int line = 0 ; int column = 0 ; int index = 0 ; XmString entry ; XmString row =NULL; XmString tmp =NULL; XmString tab; tab = XmStringComponentCreate (XmSTRING_COMPONENT_TAB, 0, NULL); while (poem[index] != (char *) 0) { /* create a compound string, using the rendition tag */ entry = XmStringGenerate ((XtPointer) poem[index], NULL, XmCHARSET_TEXT, rendition_data[column].tag) ; if (row != (XmString)NULL) { tmp = XmStringConcat (row, tab) ; XmStringFree (row) ; row = XmStringConcatAndFree (tmp, entry) ; } else { row = entry ; } ++column ; if (column == MAX_COLUMNS) { if (table == (XmStringTable) 0) { table = (XmStringTable) XtMalloc((unsigned) 1 * sizeof (XmString)) ; } else { table = (XmStringTable) XtRealloc((char *) table, (unsigned) (line + 1) * sizeof (XmString)) ; } table[line++] = row ; row = (XmString) 0 ; column = 0 ; } index++ ; } XmStringFree (tab) ; table[line] = (XmString) 0 ; *count = line ; return table ; }
*/ XmString XmStringSegmentCreate( char *text, XmStringTag tag, #if NeedWidePrototypes int direction, int separator ) #else XmStringDirection direction, Boolean separator ) #endif /* NeedWidePrototypes */ { XmString result; result = XmStringConcatAndFree (XmStringDirectionCreate (direction), XmStringCreate (text, tag)); if (separator) result = XmStringConcatAndFree (result, XmStringSeparatorCreate ()); return result; } /* * Convenience routine to create an XmString from a NULL terminated string. */ XmString XmStringCreateSimple( char *text ) { return (XmStringCreate(text, XmSTRING_DEFAULT_CHARSET));