Example #1
0
void MCExecPoint::lower()
{
	uint4 length = svalue.getlength();
	MCU_lower(getbuffer(length), svalue);
	svalue.set(buffer, length);
}
Example #2
0
void MCSort::additem(MCExecPoint &ep, MCSortnode *&items, uint4 &nitems, Sort_type form, MCString &s, MCExpression *by)
{
	if (by != NULL)
	{
		MCerrorlock++;
		ep.setsvalue(s);
		MCeach->store(ep, False);
		if (by->eval(ep) == ES_NORMAL)
			s = ep.getsvalue();
		else
			s = MCnullmcstring;
		MCerrorlock--;
	}
	switch (form)
	{
	case ST_DATETIME:
		ep.setsvalue(s);
		if (MCD_convert(ep, CF_UNDEFINED, CF_UNDEFINED, CF_SECONDS, CF_UNDEFINED))
		{
			if (!MCU_stor8(ep.getsvalue(), items[nitems].nvalue))
				items[nitems].nvalue = -MAXREAL8;
		}
		else
			items[nitems].nvalue = -MAXREAL8;
		break;
	case ST_NUMERIC:
		{
			const char *sptr = s.getstring();
			uint4 length = s.getlength();
			
			// MW-2013-03-21: [[ Bug ]] Make sure we skip any whitespace before the
			//   number starts - making it consistent with string->number conversions
			//   elsewhere.
			MCU_skip_spaces(sptr, length);
			
		    // REVIEW - at the moment the numeric prefix of the string is used to
			//   derive the sort key e.g. 1000abc would get processed as 1000.
			while (length && (isdigit((uint1)*sptr) ||
			                  *sptr == '.' || *sptr == '-' || *sptr == '+'))
			{
				sptr++;
				length--;
			}
			s.setlength(s.getlength() - length);
			if (!MCU_stor8(s, items[nitems].nvalue))
				items[nitems].nvalue = -MAXREAL8;
		}
		break;
	default:
		if (ep.getcasesensitive() && by == NULL)
			items[nitems].svalue = (char *)s.getstring();
		else
			if (ep.getcasesensitive())
				items[nitems].svalue = s.clone();
			else
			{
#if defined(_MAC_DESKTOP) || defined(_IOS_MOBILE)
				if (form == ST_INTERNATIONAL)
				{
					extern char *MCSystemLowercaseInternational(const MCString& s);
					items[nitems].svalue = MCSystemLowercaseInternational(s);
				}
				else
#endif

				{
					items[nitems].svalue = new char[s.getlength() + 1];
					MCU_lower(items[nitems].svalue, s);
					items[nitems].svalue[s.getlength()] = '\0';
				}
			}
		break;
	}
	nitems++;
}
Example #3
0
MCOldFontnode::MCOldFontnode(const MCString &fname, uint2 &size, uint2 style)
{
	char fontname[XLFD_LENGTH];

	uint4 length = fname.getlength();
	reqname = new char[length + 1];
	MCU_lower(reqname, fname);
	reqname[length] = '\0';
	reqsize = size;
	reqstyle = style;
	
	uint2 t_original_size;
	t_original_size = size;
	
	XFontStruct *fs = NULL;
	
	memset(&font, 0, sizeof(MCFontStruct));
	
	font.charset = 0;
	if (MCnoui)
		return;

		Boolean t_is_unicode = False;

		// MW-2005-02-08: We aren't going to use XMBTEXT for now, instead we will
		//   search for an appropriate ISO10646 font if in 'encoding mode'.
		if (strchr(reqname, ',') != NULL)
		{
			sprintf(fontname, "-*-%.*s-%s-%s-%s--%d-*-*-*-*-*-iso10646-*",
			        strchr(reqname, ',') - reqname, reqname, MCF_getweightstring(style),
			        MCF_getslantshortstring(style),
			        MCF_getexpandstring(style), size);
			t_is_unicode = True;
		}
		else
			sprintf(fontname, "-*-%s-%s-%s-%s--%d-*-*-*-*-*-iso8859-%d",
			        reqname, MCF_getweightstring(style),
			        MCF_getslantshortstring(style),
			        MCF_getexpandstring(style), size, MCcharset);
		
		if ((fs = XLoadQueryFont(MCdpy, fontname)) == NULL)
			fs = lookup(reqname, size, style);
		else
			font.unicode = t_is_unicode;

		if (fs == NULL)
			if ((fs = XLoadQueryFont(MCdpy, reqname)) != NULL)
			{
				if (pixelsize == 0)
					pixelsize = XInternAtom(MCdpy, "PIXEL_SIZE", True);
				uint2 i = fs->n_properties;
				while (i--)
					if (fs->properties[i].name == pixelsize)
					{
						size = reqsize = fs->properties[i].card32;
						break;
					}
				size = reqsize = fs->ascent + fs->descent - 2;
			}

		if (fs == NULL)
			fs = lookup(DEFAULT_TEXT_FONT, size, style);
		if (fs == NULL)
			fs = XLoadQueryFont(MCdpy, "fixed");

	
		font.reqname = strdup(reqname) ;
		font.reqsize = reqsize ;
		font.reqstyle = reqstyle ;
	
		font.fstruct = fs;
		font.max_byte1 = fs -> max_byte1;

		font.ascent = fs -> ascent;
		font.descent = fs -> descent;

		font.unicode = t_is_unicode;
		if (t_is_unicode)
			font.charset = LCH_UNICODE;
}
Example #4
0
MCStack *MCDispatch::findstackname(const MCString &s)
{
	if (s.getlength() == 0)
		return NULL;

	MCStack *tstk = stacks;
	if (tstk != NULL)
	{
		do
		{
			MCStack *foundstk;
			if ((foundstk = (MCStack *)tstk->findsubstackname(s)) != NULL)
				return foundstk;
			tstk = (MCStack *)tstk->next();
		}
		while (tstk != stacks);
	}

	tstk = stacks;
	if (tstk != NULL)
	{
		do
		{
			MCStack *foundstk;
			if ((foundstk = (MCStack *)tstk->findstackfile(s)) != NULL)
				return foundstk;
			tstk = (MCStack *)tstk->next();
		}
		while (tstk != stacks);
	}

	char *sname = s.clone();
	if (loadfile(sname, tstk) != IO_NORMAL)
	{
		char *buffer = new char[s.getlength() + 5];
		MCU_lower(buffer, s);
		strcpy(&buffer[s.getlength()], ".mc");
		delete sname;
		char *sptr = buffer;
		while (*sptr)
		{
			if (strchr("\r\n\t *?*<>/\\()[]{}|'`\"", *sptr) != NULL)
				*sptr = '_';
			sptr++;
		}
		if (loadfile(buffer, tstk) != IO_NORMAL)
		{
			strcpy(&buffer[s.getlength()], ".rev");
			if (loadfile(buffer, tstk) != IO_NORMAL)
			{
				delete buffer;
				return NULL;
			}
		}
		delete buffer;
	}
	else
		delete sname;

	return tstk;
}