error() публичный Метод

public error ( byte buf, int ptr, string msg ) : void
buf byte
ptr int
msg string
Результат void
Пример #1
0
        public override int parseBody(Patch script, int end)
        {
            byte[] buf = File.Buffer;
            int    c   = RawParseUtils.nextLF(buf, StartOffset);

            _old.ForEach(coi =>
            {
                coi.LinesAdded   = 0;
                coi.LinesDeleted = 0;
                coi.LinesContext = 0;
            });

            LinesContext = 0;
            int nAdded = 0;

            for (int eol; c < end; c = eol)
            {
                eol = RawParseUtils.nextLF(buf, c);

                if (eol - c < _old.Count + 1)
                {
                    // Line isn't long enough to mention the state of each
                    // ancestor. It must be the end of the hunk.
                    break;
                }

                bool break_scan = false;
                switch (buf[c])
                {
                case (byte)' ':
                case (byte)'-':
                case (byte)'+':
                    break;

                default:
                    // Line can't possibly be part of this hunk; the first
                    // ancestor information isn't recognizable.
                    //
                    break_scan = true;
                    break;
                }
                if (break_scan)
                {
                    break;
                }

                int localcontext = 0;
                for (int ancestor = 0; ancestor < _old.Count; ancestor++)
                {
                    switch (buf[c + ancestor])
                    {
                    case (byte)' ':
                        localcontext++;
                        _old[ancestor].LinesContext++;
                        continue;

                    case (byte)'-':
                        _old[ancestor].LinesDeleted++;
                        continue;

                    case (byte)'+':
                        _old[ancestor].LinesAdded++;
                        nAdded++;
                        continue;

                    default:
                        break_scan = true;
                        break;
                    }
                    if (break_scan)
                    {
                        break;
                    }
                }
                if (break_scan)
                {
                    break;
                }

                if (localcontext == _old.Count)
                {
                    LinesContext++;
                }
            }

            for (int ancestor = 0; ancestor < _old.Count; ancestor++)
            {
                CombinedOldImage o = _old[ancestor];
                int cmp            = o.LinesContext + o.LinesDeleted;
                if (cmp < o.LineCount)
                {
                    int missingCnt = o.LineCount - cmp;
                    script.error(buf, StartOffset, "Truncated hunk, at least "
                                 + missingCnt + " lines is missing for ancestor "
                                 + (ancestor + 1));
                }
            }

            if (LinesContext + nAdded < NewLineCount)
            {
                int missingCount = NewLineCount - (LinesContext + nAdded);
                script.error(buf, StartOffset, "Truncated hunk, at least "
                             + missingCount + " new lines is missing");
            }

            return(c);
        }
        public override int parseBody(Patch script, int end)
        {
            byte[] buf = File.Buffer;
            int c = RawParseUtils.nextLF(buf, StartOffset);

            _old.ForEach(coi =>
                         	{
                         		coi.LinesAdded = 0;
                         		coi.LinesDeleted = 0;
                         		coi.LinesContext = 0;
                         	});

            LinesContext = 0;
            int nAdded = 0;

            for (int eol; c < end; c = eol)
            {
                eol = RawParseUtils.nextLF(buf, c);

                if (eol - c < _old.Count + 1)
                {
                    // Line isn't long enough to mention the state of each
                    // ancestor. It must be the end of the hunk.
                    break;
                }

                bool break_scan = false;
                switch (buf[c])
                {
                    case (byte)' ':
                    case (byte)'-':
                    case (byte)'+':
                        break;

                    default:
                        // Line can't possibly be part of this hunk; the first
                        // ancestor information isn't recognizable.
                        //
                        break_scan = true;
                        break;
                }
                if (break_scan)
                    break;

                int localcontext = 0;
                for (int ancestor = 0; ancestor < _old.Count; ancestor++)
                {
                    switch (buf[c + ancestor])
                    {
                        case (byte)' ':
                            localcontext++;
                            _old[ancestor].LinesContext++;
                            continue;

                        case (byte)'-':
                            _old[ancestor].LinesDeleted++;
                            continue;

                        case (byte)'+':
                            _old[ancestor].LinesAdded++;
                            nAdded++;
                            continue;

                        default:
                            break_scan = true;
                            break;
                    }
                    if (break_scan)
                        break;
                }
                if (break_scan)
                    break;

                if (localcontext == _old.Count)
                {
                    LinesContext++;
                }
            }

            for (int ancestor = 0; ancestor < _old.Count; ancestor++)
            {
                CombinedOldImage o = _old[ancestor];
                int cmp = o.LinesContext + o.LinesDeleted;
                if (cmp < o.LineCount)
                {
                    int missingCnt = o.LineCount - cmp;
                    script.error(buf, StartOffset, "Truncated hunk, at least "
                            + missingCnt + " lines is missing for ancestor "
                            + (ancestor + 1));
                }
            }

            if (LinesContext + nAdded < NewLineCount)
            {
                int missingCount = NewLineCount - (LinesContext + nAdded);
                script.error(buf, StartOffset, "Truncated hunk, at least "
                        + missingCount + " new lines is missing");
            }

            return c;
        }
Пример #3
0
		public virtual int parseBody(Patch script, int end)
		{
			byte[] buf = _file.Buffer;
			int c = RawParseUtils.nextLF(buf, _startOffset), last = c;

			_oldImage.LinesDeleted = 0;
			_oldImage.LinesAdded = 0;

			for (; c < end; last = c, c = RawParseUtils.nextLF(buf, c))
			{
				bool breakScan;
				switch (buf[c])
				{
					case (byte)' ':
					case (byte)'\n':
						LinesContext++;
						continue;

					case (byte)'-':
						_oldImage.LinesDeleted++;
						continue;

					case (byte)'+':
						_oldImage.LinesAdded++;
						continue;

					case (byte)'\\': // Matches "\ No newline at end of file"
						continue;

					default:
						breakScan = true;
						break;
				}

				if (breakScan)
				{
					break;
				}
			}

			if (last < end && LinesContext + _oldImage.LinesDeleted - 1 == _oldImage.LineCount
				&& LinesContext + _oldImage.LinesAdded == NewLineCount
				&& RawParseUtils.match(buf, last, Patch.SigFooter) >= 0)
			{
				// This is an extremely common occurrence of "corruption".
				// Users add footers with their signatures After this mark,
				// and git diff adds the git executable version number.
				// Let it slide; the hunk otherwise looked sound.
				//
				_oldImage.LinesDeleted--;
				return last;
			}

			if (LinesContext + _oldImage.LinesDeleted < _oldImage.LineCount)
			{
				int missingCount = _oldImage.LineCount - (LinesContext + _oldImage.LinesDeleted);
				script.error(buf, _startOffset, "Truncated hunk, at least "
												+ missingCount + " old lines is missing");
			}
			else if (LinesContext + _oldImage.LinesAdded < NewLineCount)
			{
				int missingCount = NewLineCount - (LinesContext + _oldImage.LinesAdded);
				script.error(buf, _startOffset, "Truncated hunk, at least "
												+ missingCount + " new lines is missing");
			}
			else if (LinesContext + _oldImage.LinesDeleted > _oldImage.LineCount
					 || LinesContext + _oldImage.LinesAdded > NewLineCount)
			{
				string oldcnt = _oldImage.LineCount + ":" + NewLineCount;
				string newcnt = (LinesContext + _oldImage.LinesDeleted) + ":"
								+ (LinesContext + _oldImage.LinesAdded);
				script.warn(buf, _startOffset, "Hunk header " + oldcnt
											   + " does not match body line count of " + newcnt);
			}

			return c;
		}
Пример #4
0
        public virtual int parseBody(Patch script, int end)
        {
            byte[] buf = _file.Buffer;
            int    c = RawParseUtils.nextLF(buf, _startOffset), last = c;

            _oldImage.LinesDeleted = 0;
            _oldImage.LinesAdded   = 0;

            for (; c < end; last = c, c = RawParseUtils.nextLF(buf, c))
            {
                bool breakScan;
                switch (buf[c])
                {
                case (byte)' ':
                case (byte)'\n':
                    LinesContext++;
                    continue;

                case (byte)'-':
                    _oldImage.LinesDeleted++;
                    continue;

                case (byte)'+':
                    _oldImage.LinesAdded++;
                    continue;

                case (byte)'\\':                         // Matches "\ No newline at end of file"
                    continue;

                default:
                    breakScan = true;
                    break;
                }

                if (breakScan)
                {
                    break;
                }
            }

            if (last < end && LinesContext + _oldImage.LinesDeleted - 1 == _oldImage.LineCount &&
                LinesContext + _oldImage.LinesAdded == NewLineCount &&
                RawParseUtils.match(buf, last, Patch.SigFooter) >= 0)
            {
                // This is an extremely common occurrence of "corruption".
                // Users add footers with their signatures After this mark,
                // and git diff adds the git executable version number.
                // Let it slide; the hunk otherwise looked sound.
                //
                _oldImage.LinesDeleted--;
                return(last);
            }

            if (LinesContext + _oldImage.LinesDeleted < _oldImage.LineCount)
            {
                int missingCount = _oldImage.LineCount - (LinesContext + _oldImage.LinesDeleted);
                script.error(buf, _startOffset, "Truncated hunk, at least "
                             + missingCount + " old lines is missing");
            }
            else if (LinesContext + _oldImage.LinesAdded < NewLineCount)
            {
                int missingCount = NewLineCount - (LinesContext + _oldImage.LinesAdded);
                script.error(buf, _startOffset, "Truncated hunk, at least "
                             + missingCount + " new lines is missing");
            }
            else if (LinesContext + _oldImage.LinesDeleted > _oldImage.LineCount ||
                     LinesContext + _oldImage.LinesAdded > NewLineCount)
            {
                string oldcnt = _oldImage.LineCount + ":" + NewLineCount;
                string newcnt = (LinesContext + _oldImage.LinesDeleted) + ":"
                                + (LinesContext + _oldImage.LinesAdded);
                script.warn(buf, _startOffset, "Hunk header " + oldcnt
                            + " does not match body line count of " + newcnt);
            }

            return(c);
        }