MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / textaux_CopyTextLine

Function textaux_CopyTextLine

grtext/textaux.cpp:125–156  ·  view source on GitHub ↗

textaux_CopyTextLine This function goes hand-in-hand with textaux_WordWrap(). Given a buffer of data it will fill in the dest buffer until it hits a /n or /0. It returns a pointer to the start position of the next line, or NULL if it's done with the buffer (it hit a /0).

Source from the content-addressed store, hash-verified

123// the dest buffer until it hits a /n or /0. It returns a pointer to the start position of the next line,
124// or NULL if it's done with the buffer (it hit a /0).
125const char *textaux_CopyTextLine(const char *src, char *dest) {
126 // make sure src and dest are allocated
127 if (!src) {
128 if (dest)
129 dest[0] = '\0';
130 return nullptr;
131 }
132 if (!dest)
133 return nullptr;
134 // see if we are at the end of the src
135 if (src[0] == '\0') {
136 dest[0] = '\0';
137 return nullptr;
138 }
139 int i;
140 i = 0;
141 // find the end
142 while ((src[i] != '\n') && (src[i] != '\0'))
143 i++;
144 if (src[i] == '\0') {
145 // no more lines left after this
146 strncpy(dest, src, i);
147 dest[i] = '\0';
148 return nullptr;
149 } else {
150 // we hit a newline char
151 strncpy(dest, src, i);
152 dest[i] = '\0';
153 i++;
154 return &src[i];
155 }
156}
157
158// textaux_ClipString
159// Given a width (in pixels), and a string, this function will truncate the string

Callers 7

DoStuffMethod · 0.85
BriefEditSaveScreensFunction · 0.85
TCSSSCallbackFunction · 0.85
RenderTextStaticFunction · 0.85
RenderTextTypeFunction · 0.85
RenderTextFadeFunction · 0.85
TCGoalsRenderCallbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected