MCPcopy Create free account
hub / github.com/Kitware/VTK / pj_mkparam_ws

Function pj_mkparam_ws

ThirdParty/libproj/vtklibproj/src/param.cpp:54–95  ·  view source on GitHub ↗

As pj_mkparam, but payload ends at first whitespace, rather than at end of */

Source from the content-addressed store, hash-verified

52
53/* As pj_mkparam, but payload ends at first whitespace, rather than at end of <str> */
54paralist *pj_mkparam_ws (const char *str, const char **next_str) {
55 paralist *newitem;
56 size_t len = 0;
57
58 if (nullptr==str)
59 return nullptr;
60
61 /* Find start and length of string */
62 while (isspace (*str))
63 str++;
64 if (*str == '+')
65 str++;
66 bool in_string = false;
67 for( ; str[len] != '\0'; len++ ) {
68 if( in_string ) {
69 if( str[len] == '"' && str[len+1] == '"' ) {
70 len++;
71 } else if( str[len] == '"' ) {
72 in_string = false;
73 }
74 } else if( str[len] == '=' && str[len+1] == '"' ) {
75 in_string = true;
76 } else if( isspace(str[len]) ) {
77 break;
78 }
79 }
80
81 if( next_str )
82 *next_str = str + len;
83
84 /* Use calloc to automagically 0-terminate the copy */
85 newitem = (paralist *) calloc (1, sizeof(paralist) + len + 1);
86 if (nullptr==newitem)
87 return nullptr;
88 memcpy(newitem->param, str, len);
89 unquote_string(newitem->param);
90
91 newitem->used = 0;
92 newitem->next = nullptr;
93
94 return newitem;
95}
96
97/**************************************************************************************/
98paralist *pj_param_exists (paralist *list, const char *parameter) {

Callers 1

string_to_paralistFunction · 0.85

Calls 1

unquote_stringFunction · 0.85

Tested by

no test coverage detected