@@ -198,7 +198,6 @@ static int _sha1(struct mb_interpreter_t* s, void** l) {
198198 int result = MB_FUNC_OK ;
199199
200200 mb_check (mb_attempt_open_bracket (s, l));
201-
202201 char * m;
203202
204203 mb_check (mb_pop_string (s, l, &m));
@@ -211,6 +210,53 @@ static int _sha1(struct mb_interpreter_t* s, void** l) {
211210 mb_check (mb_push_string (s, l, mb_memdup (buf, (unsigned )(strlen (buf) + 1 ))));
212211 return result;
213212}
213+ /* ---------*/
214+ static int _csvtolist (struct mb_interpreter_t * s, void ** l) {
215+ int result = MB_FUNC_OK ;
216+
217+ mb_check (mb_attempt_open_bracket (s, l));
218+
219+ char * strInputString;
220+
221+ mb_check (mb_pop_string (s, l, &strInputString));
222+ mb_check (mb_attempt_close_bracket (s, l));
223+
224+ std::vector<String> vValues;
225+ String strInput (strInputString);
226+ int start = 0 ;
227+ int end = strInput.indexOf (' ,' );
228+
229+ while (end != -1 ) {
230+ vValues.push_back (strInput.substring (start, end));
231+ start = end + 1 ;
232+ end = strInput.indexOf (' ,' , start);
233+ }
234+
235+ // Add the last substring (or the entire string if no comma was found)
236+ vValues.push_back (strInput.substring (start));
237+
238+ mb_value_t val;
239+ mb_make_nil (val);
240+
241+ mb_value_t coll;
242+ coll.type = MB_DT_LIST ;
243+ mb_init_coll (s, l, &coll);
244+
245+ int feedback_index = 0 ;
246+ for (size_t i = 0 ; i < vValues.size (); ++i) {
247+ mb_value_t mb_feedback_index;
248+ mb_value_t feedback_value;
249+ mb_make_int (mb_feedback_index, feedback_index++);
250+ mb_make_string (feedback_value, const_cast <char *>(vValues[i].c_str ()));
251+ mb_set_coll (s, l, coll, mb_feedback_index, feedback_value);
252+ }
253+
254+
255+ // Push the comparison result onto the stack
256+ mb_check (mb_push_value (s, l, coll));
257+ return result;
258+ }
259+
214260/* ---------*/
215261static int _hextobin (struct mb_interpreter_t * s, void ** l) {
216262 int result = MB_FUNC_OK ;
0 commit comments