コード例 #1
0
JXPSPrintSetupDialog*
CBPSPrinter::CreatePrintSetupDialog
	(
	const Destination	destination,
	const JCharacter*	printCmd,
	const JCharacter*	fileName,
	const JBoolean		collate,
	const JBoolean		bw
	)
{
	assert( itsCBPrintSetupDialog == NULL );

	if (itsFontSize == kUnsetFontSize)
		{
		JString fontName;
		CBGetPrefsManager()->GetDefaultFont(&fontName, &itsFontSize);

		JArray<JIndexRange> matchList;
		if (nxmRegex.Match(fontName, &matchList))
			{
			const JString hStr = fontName.GetSubstring(matchList.GetElement(2));
			const JBoolean ok  = hStr.ConvertToUInt(&itsFontSize);
			assert( ok );
			itsFontSize--;
			}
		}

	itsCBPrintSetupDialog =
		CBPSPrintSetupDialog::Create(destination, printCmd, fileName,
									 collate, bw, itsFontSize,
									 (CBGetPTTextPrinter())->WillPrintHeader());
	return itsCBPrintSetupDialog;
}
コード例 #2
0
void
SVNTabBase::ComparePrev
	(
	const JCharacter* revStr
	)
{
	JString r = "PREV";
	if (!JStringEmpty(revStr))
		{
		JString s = revStr;
		JUInt rev;
		if (s.ConvertToUInt(&rev) && rev > 0)
			{
			r  = JString(rev-1, JString::kBase10);
			r += ":";
			r += JString(rev, JString::kBase10);
			}
		else
			{
			r += ":";
			r += revStr;
			}
		}

	Compare(r, kJTrue);
}
コード例 #3
0
ファイル: jFileUtil.cpp プロジェクト: mta1309/mulberry-lib-jx
void
JExtractFileAndLine
	(
	const JCharacter*	str,
	JString*			fileName,
	JIndex*				startLineIndex,
	JIndex*				endLineIndex
	)
{
	static JRegex lineIndexRegex(":([0-9]+)(-([0-9]+))?$");

	*fileName = str;

	JArray<JIndexRange> matchList;
	if (lineIndexRegex.Match(*fileName, &matchList))
		{
		JString s   = fileName->GetSubstring(matchList.GetElement(2));
		JBoolean ok = s.ConvertToUInt(startLineIndex);
		assert( ok );

		const JIndexRange endRange = matchList.GetElement(4);
		if (endLineIndex != NULL && !endRange.IsEmpty())
			{
			s  = fileName->GetSubstring(endRange);
			ok = s.ConvertToUInt(endLineIndex);
			assert( ok );
			}
		else if (endLineIndex != NULL)
			{
			*endLineIndex = *startLineIndex;
			}

		fileName->RemoveSubstring(matchList.GetElement(1));
		}
	else
		{
		*startLineIndex = 0;
		if (endLineIndex != NULL)
			{
			*endLineIndex = 0;
			}
		}
}
コード例 #4
0
void
GDBGetFrame::HandleSuccess
	(
	const JString& cmdData
	)
{
	const JString& data = GetLastResult();

	JIndexRange r;
	if (framePattern.Match(data, &r))
		{
		std::istringstream stream(data.GetCString());
		stream.seekg(r.last);

		JStringPtrMap<JString> map(JPtrArrayT::kDeleteAll);
		JString* s;
		JIndex frameIndex;
		if (!GDBLink::ParseMap(stream, &map))
			{
			(CMGetLink())->Log("invalid data map");
			}
		else if (!map.GetElement("level", &s))
			{
			(CMGetLink())->Log("missing frame index");
			}
		else if (!s->ConvertToUInt(&frameIndex))
			{
			(CMGetLink())->Log("frame index is not integer");
			}
		else
			{
			itsWidget->SelectFrame(frameIndex);
			}
		}
	else
		{
		(CMGetLink())->Log("GDBGetFrame failed to match");
		}
}
コード例 #5
0
void
XDLink::ReceiveMessageFromDebugger()
{
	itsLink->StopTimer();

	JString data;
	const JBoolean ok = itsLink->GetNextMessage(&data);
	assert( ok );

	if (data.IsEmpty() || data.GetFirstCharacter() != '<')
		{
		return;
		}

	Broadcast(DebugOutput(data, kOutputType));

	if (itsInitFinishedFlag)
		{
		if (!itsProgramIsStoppedFlag)
			{
			itsProgramIsStoppedFlag = kJTrue;
			Broadcast(ProgramStopped(CMLocation("", 1)));
			}

		itsDebuggerBusyFlag = kJFalse;
		Broadcast(DebuggerReadyForInput());
		}

	xmlDoc* doc = xmlReadMemory(data.GetCString(), data.GetLength(),
								NULL, NULL, XML_PARSE_NOCDATA);
	if (doc != NULL)
		{
		xmlNode* root = xmlDocGetRootElement(doc);

		if (root != NULL && strcmp((char*) root->name, "init") == 0)
			{
			itsIDEKey         = JGetXMLNodeAttr(root, "idekey");
			const JString uri = JGetXMLNodeAttr(root, "fileuri");

			const JCharacter* map[] =
				{
				"idekey", itsIDEKey,
				"uri",    uri
				};
			JString msg = JGetString("ConnectionInfo::XDLink", map, sizeof(map));
			Broadcast(UserOutput(msg, kJFalse));

			Send("feature_set -n show_hidden -v 1");
			Send("step_into");

			JString programName;
			GetProgram(&programName);

			Broadcast(AttachedToProcess());
			Broadcast(SymbolsLoaded(JI2B(uri == itsScriptURI), programName));

			itsInitFinishedFlag = kJTrue;
			itsScriptURI        = uri;
			}
		else if (root != NULL && strcmp((char*) root->name, "response") == 0)
			{
			const JString status = JGetXMLNodeAttr(root, "status");
			const JString reason = JGetXMLNodeAttr(root, "reason");
			if (status == "break" && reason == "error" &&
				root->children != NULL && root->children->children != NULL &&
				strcmp((char*) root->children->name, "error") == 0 &&
				root->children->children->type == XML_TEXT_NODE)
				{
				JString msg            = (char*) root->children->children->content;
				const JString encoding = JGetXMLNodeAttr(root->children, "encoding");
				if (encoding == "base64")
					{
					msg.DecodeBase64(&msg);
					}
				msg += "\n";
				Broadcast(UserOutput(msg, kJTrue));
				}

			const JString idStr = JGetXMLNodeAttr(root, "transaction_id");
			JUInt id;
			if (idStr.ConvertToUInt(&id))
				{
				HandleCommandRunning(id);
				}

			CMCommand* cmd;
			if (GetRunningCommand(&cmd))
				{
				itsParsedDataRoot = root;

				cmd->Finished(JI2B(
					root->children == NULL || strcmp((char*) root->children->name, "error") != 0));

				itsParsedDataRoot = NULL;

				SetRunningCommand(NULL);
				if (!HasForegroundCommands())
					{
					RunNextCommand();
					}
				}

			if (status == "stopping" || status == "stopped")
				{
				CancelAllCommands();

				XDCloseSocketTask* task = new XDCloseSocketTask(itsLink);
				assert( task != NULL );
				task->Go();
				}
			}

		xmlFreeDoc(doc);
		}
}
コード例 #6
0
void
GFGLink::ParseLine
	(
	const JString& data
	)
{
	// we only care about virtual functions
	JBoolean required	= kJFalse;
	if (data.Contains("implementation:pure virtual"))
		{
		required	= kJTrue;
		}
	else if (!data.Contains("implementation:virtual"))
		{
		return;
		}

	JArray<JIndexRange> subList;
	if (memberLine.Match(data, &subList))
		{
		JIndexRange sRange	= subList.GetElement(2);
		JString name		= data.GetSubstring(sRange);
		if (name.BeginsWith("~"))
			{
			return;
			}

		GFGMemberFunction* fn	= jnew GFGMemberFunction();
		assert(fn != NULL);

		fn->SetFnName(name);
		fn->ShouldBeRequired(required);

		sRange	= subList.GetElement(3);
		JIndex line;
		JString lineStr		= data.GetSubstring(sRange);
		lineStr.ConvertToUInt(&line);

		sRange	= subList.GetElement(4);
		JString base		= data.GetSubstring(sRange);
		if (base != itsCurrentClass)
			{
			jdelete fn;
			return;
			}

		sRange	= subList.GetElement(5);
		JString access		= data.GetSubstring(sRange);
		if (access == "protected")
			{
			fn->ShouldBeProtected(kJTrue);
			}

		ParseInterface(fn, line);

		// Override entry from base class so function will only be
		// marked as pure virtual if nobody implemented it.

		JBoolean found;
		const JIndex i =
			itsClassList->SearchSorted1(fn, JOrderedSetT::kAnyMatch, &found);
		if (found)
			{
			itsClassList->DeleteElement(i);
			}
		itsClassList->InsertAtIndex(i, fn);
		}
}
コード例 #7
0
JBoolean
CBCtagsUser::HasExuberantCtags()
{
	if (itsHasExuberantCtagsFlag == kUntested)
		{
		itsHasExuberantCtagsFlag = kFailure;

		// this hack is required on Linux kernel 2.3.x (4/19/2000)
		j_sig_func*	origHandler = signal(SIGCHLD, emptyHandler);

		pid_t pid;

		#if defined _J_SUNOS
		pid_t* ppid = NULL;
		#else
		pid_t* ppid = &pid;
		#endif

		int fromFD;
		JError err = JExecute(kCheckVersionCmd, ppid,
							  kJIgnoreConnection, NULL,
							  kJCreatePipe, &fromFD,
							  kJTossOutput, NULL);
		if (err.OK())
			{
			JString vers;
			JReadAll(fromFD, &vers);

			JArray<JIndexRange> matchList;
			if (versionPattern.Match(vers, &matchList))
				{
				matchList.RemoveElement(1);

				const JSize count = matchList.GetElementCount();
				JString s;
				for (JIndex i=1; i<=count; i++)
					{
					JUInt v = 0;
					const JIndexRange r = matchList.GetElement(i);
					if (!r.IsEmpty())
						{
						s = vers.GetSubstring(r);
						while (!isdigit(s.GetFirstCharacter()))
							{
							s.RemoveSubstring(1, 1);
							}
						const JBoolean ok = s.ConvertToUInt(&v);
						assert( ok );
						}

					if (v > kMinVersion[i-1] ||
						(i == count && v == kMinVersion[i-1]))
						{
						itsHasExuberantCtagsFlag = kSuccess;
						break;
						}
					else if (v < kMinVersion[i-1])
						{
						break;
						}
					}
				}
			}

		if (origHandler != SIG_ERR)
			{
			signal(SIGCHLD, origHandler);
			}
		}

	return JI2B( itsHasExuberantCtagsFlag == kSuccess );
}
コード例 #8
0
void
CMVarNode::ConvertToBase()
{
	itsCanConvertBaseFlag = kJFalse;
	if (itsOrigValue != NULL && !itsOrigValue->IsEmpty())
		{
		JTree* tree;
		if (itsValue != *itsOrigValue && GetTree(&tree))
			{
			tree->BroadcastChange(this);
			}
		itsValue = *itsOrigValue;
		}

	if (itsBase == 0 || itsIsPointerFlag)
		{
		return;		// avoid constructing matchList
		}

	JArray<JIndexRange> matchList;
	if (valuePattern.Match(itsValue, &matchList))
		{
		JString vStr = itsValue.GetSubstring(matchList.GetElement(2));

		JUInt v;
		itsCanConvertBaseFlag = JI2B(
			vStr.ConvertToUInt(&v, vStr.GetFirstCharacter() == '0' ? 8 : 10) &&
			(itsBase != 1 || (0 <= v && v <= 255)));
		if (itsCanConvertBaseFlag)
			{
			// save value for when base reset to "default"

			itsOrigValue = new JString(itsValue);
			assert( itsOrigValue != NULL );

			// replace only the value, preserving whatever else is there

			if (itsBase == 1)
				{
				assert( 0 <= v && v <= 255 );

				vStr  = JString(v, JString::kBase16, kJTrue);
				vStr += " '";

				JBoolean found = kJFalse;
				for (JIndex i=0; i<kSpecialCharCount; i++)
					{
					if (JCharacter(v) == kSpecialCharInfo[i].c)
						{
						vStr += kSpecialCharInfo[i].s;
						found = kJTrue;
						}
					}
				if (!found)
					{
					vStr.AppendCharacter(v);
					}

				vStr.AppendCharacter('\'');
				}
			else
				{
				vStr = JString(v, (JString::Base) itsBase, kJTrue);
				if (itsBase == 8)
					{
					vStr.PrependCharacter('0');
					}
				}

			JIndexRange r;
			itsValue.ReplaceSubstring(matchList.GetElement(2), vStr, &r);

			JTree* tree;
			if (GetTree(&tree))
				{
				tree->BroadcastChange(this);
				}
			}
		}
}
コード例 #9
0
void
GMessageHeader::SetHeader
	(
	const JString& header
	)
{
	itsHeader = header;
	itsHeader.TrimWhitespace();
	return;
	JArray<JIndexRange> subList;
	JBoolean matched = yearRegex.Match(itsHeader, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(2);
		JString year = itsHeader.GetSubstring(sRange);
		year.ConvertToUInt(&itsYear);
		}

	matched = timeRegex1.Match(itsHeader, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(2);
		itsTime = itsHeader.GetSubstring(sRange);
		if (itsYear == 0)
			{
			sRange = subList.GetElement(3);
			JString year = itsHeader.GetSubstring(sRange);
			year.ConvertToUInt(&itsYear);
			}
		}
	else
		{
		matched = timeRegex2.Match(itsHeader, &subList);
		if (matched)
			{
			JIndexRange sRange = subList.GetElement(2);
			itsTime = itsHeader.GetSubstring(sRange);
			if (itsYear == 0)
				{
				sRange = subList.GetElement(3);
				JString year = itsHeader.GetSubstring(sRange);
				year.ConvertToUInt(&itsYear);
				}
			}
		}
	matched = dateRegex.Match(itsHeader, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(2);
		JString dow	= itsHeader.GetSubstring(sRange);
		sRange		= subList.GetElement(3);
		itsMonth	= itsHeader.GetSubstring(sRange);
		sRange = subList.GetElement(4);
		JString day = itsHeader.GetSubstring(sRange);
		day.ConvertToUInt(&itsDay);
		itsShortDate	= itsMonth + " " + day;

		time_t now;
		struct tm *local_time;
		time(&now);
		local_time = localtime(&now);
		if (itsYear != (JIndex)(local_time->tm_year + 1900))
			{
			JString year	= JString(itsYear, JString::kBase10);
			itsShortDate += " " + year;
			}

		itsDate			= dow + ", " + day + " " + itsMonth + " " + JString(itsYear) + " " + itsTime;
		}
}
コード例 #10
0
void
GMessageHeader::SetDate
	(
	const JString& date
	)
{
	itsDate = date;
	itsDate.TrimWhitespace();
	const JSize count	= itsDate.GetLength();
	if (count == 0)
		{
		return;
		}
	JIndex findex;
	JIndex current	= 0;
	JString day;
	// dow and day of month
	if (itsDate.LocateSubstring(" ", &findex) && findex > 1)
		{
		// check for day of week (Mon|Monday|Tue...)
		if (itsDate.GetCharacter(findex - 1) == ',')
			{
			// ignore dow for now
			findex ++;
			while (findex <= itsDate.GetLength() &&
				   itsDate.GetCharacter(findex) == ' ')
				{
				findex++;
				}
			current	= findex;
			if (itsDate.LocateNextSubstring(" ", &findex) && 
				findex < count &&
				current < findex)
				{
				day	= itsDate.GetSubstring(current, findex - 1);
				}
			}
		else
			{
			day	= itsDate.GetSubstring(1, findex - 1);
			}
		if (!day.IsEmpty())
			{
			if (day.GetFirstCharacter() == '0')
				{
				day.RemoveSubstring(1,1);
				}
			}
		day.ConvertToUInt(&itsDay);

		findex ++;
		current	= findex;
		}
	else
		{
		return;
		}

	if (itsDate.LocateNextSubstring(" ", &findex) && findex > current)
		{
		itsMonth	= itsDate.GetSubstring(current, findex - 1);
		findex ++;
		current	= findex;
		}
	else
		{
		return;
		}

	if (itsDate.LocateNextSubstring(" ", &findex) && findex > current)
		{
		JString year	= itsDate.GetSubstring(current, findex - 1);
		year.ConvertToUInt(&itsYear);
		findex ++;
		current	= findex;
		}
	else
		{
		return;
		}

	if (itsDate.LocateNextSubstring(" ", &findex) && findex > current)
		{
		itsTime	= itsDate.GetSubstring(current, findex - 1);
		findex ++;
		current	= findex;
		}
	else
		{
		return;
		}

	itsShortDate = itsMonth + " " + day;
	time_t now;
	struct tm *local_time;
	time(&now);
	local_time = localtime(&now);
	if (itsYear != (JIndex)(local_time->tm_year + 1900))
		{
		JString year	= JString(itsYear, JString::kBase10);
		itsShortDate += " " + year;
		}

	return;			
	
/*	JArray<JIndexRange> subList;
	JString year	= JString(itsYear, JString::kBase10);
	JBoolean matched = monthRegex1.Match(itsDate, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(3);
		itsMonth = itsDate.GetSubstring(sRange);
		sRange = subList.GetElement(2);
		JString day = itsDate.GetSubstring(sRange);
		if (!day.IsEmpty())
			{
			if (day.GetFirstCharacter() == '0')
				{
				day.RemoveSubstring(1,1);
				}
			}
		day.ConvertToUInt(&itsDay);
		itsShortDate = itsMonth + " " + day;
		time_t now;
		struct tm *local_time;
		time(&now);
		local_time = localtime(&now);
		if (itsYear != (JIndex)(local_time->tm_year + 1900))
			{
			JString year	= JString(itsYear, JString::kBase10);
			itsShortDate += " " + year;
			}

		return;
		}
	matched = monthRegex2.Match(itsDate, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(3);
		itsMonth = itsDate.GetSubstring(sRange);
		sRange = subList.GetElement(2);
		JString day = itsDate.GetSubstring(sRange);
		if (!day.IsEmpty())
			{
			if (day.GetFirstCharacter() == '0')
				{
				day.RemoveSubstring(1,1);
				}
			}
		day.ConvertToUInt(&itsDay);
		itsShortDate = itsMonth + " " + day;
		time_t now;
		struct tm *local_time;
		time(&now);
		local_time = localtime(&now);
		if (itsYear != (JIndex)(local_time->tm_year + 1900))
			{
			JString year	= JString(itsYear, JString::kBase10);
			itsShortDate += " " + year;
			}
		return;
		}
	else
		{
		itsShortDate = itsDate;
		}*/
}
コード例 #11
0
void
GARMessageHeader::SetDate
	(
	const JString& date
	)
{
	itsDate = date;
	itsDate.TrimWhitespace();
	JArray<JIndexRange> subList;
	JString year	= JString(itsYear, JString::kBase10);
	JBoolean matched = monthRegex1.Match(itsDate, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(3);
		itsMonth = itsDate.GetSubstring(sRange);
		sRange = subList.GetElement(2);
		JString day = itsDate.GetSubstring(sRange);
		if (!day.IsEmpty())
			{
			if (day.GetFirstCharacter() == '0')
				{
				day.RemoveSubstring(1,1);
				}
			}
		day.ConvertToUInt(&itsDay);
		itsShortDate = itsMonth + " " + day;
		time_t now;
		struct tm *local_time;
		time(&now);
		local_time = localtime(&now);
		if (itsYear != (JIndex)(local_time->tm_year + 1900))
			{
			JString year	= JString(itsYear, JString::kBase10);
			itsShortDate += " " + year;
			}

		return;
		}
	matched = monthRegex2.Match(itsDate, &subList);
	if (matched)
		{
		JIndexRange sRange = subList.GetElement(3);
		itsMonth = itsDate.GetSubstring(sRange);
		sRange = subList.GetElement(2);
		JString day = itsDate.GetSubstring(sRange);
		if (!day.IsEmpty())
			{
			if (day.GetFirstCharacter() == '0')
				{
				day.RemoveSubstring(1,1);
				}
			}
		day.ConvertToUInt(&itsDay);
		itsShortDate = itsMonth + " " + day;
		time_t now;
		struct tm *local_time;
		time(&now);
		local_time = localtime(&now);
		if (itsYear != (JIndex)(local_time->tm_year + 1900))
			{
			JString year	= JString(itsYear, JString::kBase10);
			itsShortDate += " " + year;
			}
		return;
		}
	else
		{
		itsShortDate = itsDate;
		}
}
コード例 #12
0
void
GDBGetStack::HandleSuccess
	(
	const JString& cmdData
	)
{
	JTreeNode* root       = (GetTree())->GetRoot();
	JIndex initFrameIndex = 0;

	const JString& data = GetLastResult();
	std::istringstream stream(data.GetCString());

	JIndexRange origRange, newRange;
	JStringPtrMap<JString> map(JPtrArrayT::kDeleteAll);
	JString frameName, fileName;
	while (framePattern.MatchAfter(data, origRange, &newRange))
		{
		stream.seekg(newRange.last);
		if (!GDBLink::ParseMap(stream, &map))
			{
			(CMGetLink())->Log("invalid data map");
			break;
			}
		origRange.first = origRange.last = ((std::streamoff) stream.tellg()) + 1;

		JString* s;
		JIndex frameIndex;
		if (!map.GetElement("level", &s))
			{
			(CMGetLink())->Log("missing frame index");
			continue;
			}
		if (!s->ConvertToUInt(&frameIndex))
			{
			(CMGetLink())->Log("frame index is not integer");
			continue;
			}

		frameName = *s;
		while (frameName.GetLength() < kFrameIndexWidth)
			{
			frameName.PrependCharacter('0');
			}
		frameName += ":  ";

		JString* fnName;
		if (!map.GetElement("func", &fnName))
			{
			(CMGetLink())->Log("missing function name");
			continue;
			}
		frameName += *fnName;

		if (map.GetElement("file", &s))
			{
			fileName = *s;
			}

		JIndex lineIndex = 0;
		if (map.GetElement("line", &s) &&
			!s->ConvertToUInt(&lineIndex))
			{
			(CMGetLink())->Log("line number is not integer");
			continue;
			}

		CMStackFrameNode* node =
			new CMStackFrameNode(root, frameIndex, frameName,
								 fileName, lineIndex);
		assert( node != NULL );
		root->Prepend(node);

		if (assertPattern.Match(*fnName))
			{
			initFrameIndex = frameIndex + 1;
			}
		}

	itsArgsCmd->Send();

	(GetWidget())->FinishedLoading(initFrameIndex);
}