MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / stringfile

Function stringfile

src/openboardview/FileFormats/BRDFileBase.cpp:10–48  ·  view source on GitHub ↗

from stb.h

Source from the content-addressed store, hash-verified

8
9// from stb.h
10void stringfile(char *buffer, std::vector<char*> &lines) {
11 char *s;
12 size_t count, i;
13
14 // two passes through: first time count lines, second time set them
15 for (i = 0; i < 2; ++i) {
16 s = buffer;
17 if (i == 1) lines[0] = s;
18 count = 1; // was '1', but C arrays are 0-indexed
19 while (*s) {
20 if (*s == '\n' || *s == '\r') {
21
22 // If this is the 2nd pass, then terminate the line at the first line break char
23 if (i == 1) *s = 0;
24
25 s++; // next char
26
27 // if the termination is a CRLF combo, then jump to the next char
28 if ((*s == '\r') || (*s == '\n')) s++;
29
30 // if the char is valid (first after line break), set up the next item in the line array
31 if (*s) { // it's not over yet
32 if (i == 1) {
33 lines[count] = s;
34 // list[count+1] = NULL;
35 // fprintf(stdout,"%s\n",list[count]);
36 }
37 ++count;
38 }
39 }
40 s++;
41 } // while s
42
43 // Generate the required array to hold all the line starting points
44 if (i == 0) {
45 lines.resize(count);
46 }
47 }
48}
49
50char *fix_to_utf8(char *s, char **arena, char *arena_end) {
51 if (!utf8valid(s)) {

Callers 9

parseMethod · 0.85
BDVFileMethod · 0.85
BRDFileMethod · 0.85
CADFileMethod · 0.85
BRD2FileMethod · 0.85
ADFileMethod · 0.85
read_ascMethod · 0.85
BVRFileMethod · 0.85
BVR3FileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected