Cube  Diff

Differences From Artifact [5ae3539b0c]:

To Artifact [4117ae0f6a]:


236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
	char *p = copy;
	const int MAXWORDS = 25; // limit, remove
	OFString *w[MAXWORDS];
	int val = 0;
	for (bool cont = true; cont;) {
		// for each ; seperated statement
		int numargs = MAXWORDS;
		loopi(MAXWORDS)
		{
			// collect all argument values
			w[i] = @"";
			if (i > numargs)
				continue;
			// parse and evaluate exps
			char *s = parseword(&p);
			if (!s) {







|
<







236
237
238
239
240
241
242
243

244
245
246
247
248
249
250
	char *p = copy;
	const int MAXWORDS = 25; // limit, remove
	OFString *w[MAXWORDS];
	int val = 0;
	for (bool cont = true; cont;) {
		// for each ; seperated statement
		int numargs = MAXWORDS;
		for (int i = 0; i < MAXWORDS; i++) {

			// collect all argument values
			w[i] = @"";
			if (i > numargs)
				continue;
			// parse and evaluate exps
			char *s = parseword(&p);
			if (!s) {
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
}

void
loopa(OFString *times, OFString *body)
{
	int t = times.cube_intValue;

	loopi(t)
	{
		intset(@"i", i);
		execute(body, true);
	}
}

void
whilea(OFString *cond, OFString *body)







|
<







416
417
418
419
420
421
422
423

424
425
426
427
428
429
430
}

void
loopa(OFString *times, OFString *body)
{
	int t = times.cube_intValue;

	for (int i = 0; i < t; i++) {

		intset(@"i", i);
		execute(body, true);
	}
}

void
whilea(OFString *cond, OFString *body)
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
void
at(OFString *s_, OFString *pos)
{
	int n = pos.cube_intValue;
	char *copy __attribute__((__cleanup__(cleanup))) =
	    strdup(s_.UTF8String);
	char *s = copy;
	loopi(n)
	{
		s += strcspn(s, " \0");
		s += strspn(s, " ");
	}
	s[strcspn(s, " \0")] = 0;
	concat(@(s));
}








|
<







471
472
473
474
475
476
477
478

479
480
481
482
483
484
485
void
at(OFString *s_, OFString *pos)
{
	int n = pos.cube_intValue;
	char *copy __attribute__((__cleanup__(cleanup))) =
	    strdup(s_.UTF8String);
	char *s = copy;
	for (int i = 0; i < n; i++) {

		s += strcspn(s, " \0");
		s += strspn(s, " ");
	}
	s[strcspn(s, " \0")] = 0;
	concat(@(s));
}