MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / parseString

Function parseString

External/tiny-json/tiny-json.c:132–156  ·  view source on GitHub ↗

Parse a string and replace the scape characters by their meaning characters. * This parser stops when finds the character '\"'. Then replaces '\"' by '\0'. * @param str Pointer to first character. * @retval Pointer to first non white space after the string. If success. * @retval Null pointer if any error occur. */

Source from the content-addressed store, hash-verified

130 * @retval Pointer to first non white space after the string. If success.
131 * @retval Null pointer if any error occur. */
132static char* parseString( char* str ) {
133 unsigned char* head = (unsigned char*)str;
134 unsigned char* tail = (unsigned char*)str;
135 for( ; *head >= ' '; ++head, ++tail ) {
136 if ( *head == '\"' ) {
137 *tail = '\0';
138 return (char*)++head;
139 }
140 if ( *head == '\\' ) {
141 if ( *++head == 'u' ) {
142 char const ch = getCharFromUnicode( ++head );
143 if ( ch == '\0' ) return 0;
144 *tail = ch;
145 head += 3;
146 }
147 else {
148 char const esc = getEscape( *head );
149 if ( esc == '\0' ) return 0;
150 *tail = esc;
151 }
152 }
153 else *tail = *head;
154 }
155 return 0;
156}
157
158/** Parse a string to get the name of a property.
159 * @param str Pointer to first character.

Callers 2

propertyNameFunction · 0.85
textValueFunction · 0.85

Calls 2

getCharFromUnicodeFunction · 0.85
getEscapeFunction · 0.85

Tested by

no test coverage detected