File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -100,10 +100,10 @@ static bool pushline(LacoState* laco, bool isFirstLine) {
100100 return result ;
101101}
102102
103- static inline void ignore_extra_spaces ( char * * string_ptr ) {
103+ static inline void ignore_extra ( const char chr , char * * string_ptr ) {
104104 if (* string_ptr == NULL ) return ;
105105
106- while (* * string_ptr == ' ' ) {
106+ while (* * string_ptr == chr ) {
107107 * string_ptr += 1 ;
108108 }
109109}
@@ -179,7 +179,8 @@ int laco_is_match(const char** matches, const char* test_string) {
179179 return false;
180180}
181181
182- char * * laco_split_by (const char * split_with , char * string ) {
182+ char * * laco_split_by (const char * split_with , char * string ,
183+ int ignore_repeats ) {
183184 if (string == NULL ) return NULL ;
184185
185186 char * * result = calloc (16 , sizeof (char * ));
@@ -190,7 +191,7 @@ char** laco_split_by(const char* split_with, char* string) {
190191
191192 if (result [i ] == NULL ) break ;
192193
193- ignore_extra_spaces ( & string );
194+ if ( ignore_repeats ) ignore_extra ( split_with [ 0 ], & string );
194195
195196 i += 1 ;
196197 }
Original file line number Diff line number Diff line change @@ -42,10 +42,11 @@ int laco_is_match(const char** matches, const char* test_string);
4242 * Break the provided string into an array of strings that are between the
4343 * split_with value. The last value of this array will be NULL.
4444 */
45- char * * laco_split_by (const char * split_with , char * string );
45+ char * * laco_split_by (const char * split_with , char * string ,
46+ int ignore_repeats );
4647
4748/* Macro for splitting with spaces */
4849#define laco_line_to_words (line ) \
49- laco_split_by(" ", line)
50+ laco_split_by(" ", line, 1 )
5051
5152#endif /* LACO_UTIL_H */
You can’t perform that action at this time.
0 commit comments