示例#1
0
        internal static void NormalizeSpace(ProcessingContext context)
        {
            StackFrame    topArg  = context.TopArg;
            StringBuilder builder = new StringBuilder();

            while (topArg.basePtr <= topArg.endPtr)
            {
                char[] trimChars = new char[] { ' ', '\t', '\r', '\n' };
                string str       = context.PeekString(topArg.basePtr).Trim(trimChars);
                bool   flag      = false;
                builder.Length = 0;
                for (int i = 0; i < str.Length; i++)
                {
                    char c = str[i];
                    if (XPathCharTypes.IsWhitespace(c))
                    {
                        if (!flag)
                        {
                            builder.Append(' ');
                            flag = true;
                        }
                    }
                    else
                    {
                        builder.Append(c);
                        flag = false;
                    }
                }
                context.SetValue(context, topArg.basePtr, builder.ToString());
                topArg.basePtr++;
            }
        }
示例#2
0
        internal static void NormalizeSpace(ProcessingContext context)
        {
            StackFrame argStr = context.TopArg;

            StringBuilder builder = new StringBuilder();

            while (argStr.basePtr <= argStr.endPtr)
            {
                char[] whitespace = new char[] { ' ', '\t', '\r', '\n' };
                string str        = context.PeekString(argStr.basePtr).Trim(whitespace);

                bool eatingWhitespace = false;
                builder.Length = 0;
                for (int i = 0; i < str.Length; ++i)
                {
                    char c = str[i];
                    if (XPathCharTypes.IsWhitespace(c))
                    {
                        if (!eatingWhitespace)
                        {
                            builder.Append(' ');
                            eatingWhitespace = true;
                        }
                    }
                    else
                    {
                        builder.Append(c);
                        eatingWhitespace = false;
                    }
                }

                context.SetValue(context, argStr.basePtr, builder.ToString());
                argStr.basePtr++;
            }
        }
示例#3
0
 private void ConsumeWhitespace()
 {
     while (XPathCharTypes.IsWhitespace(this.PeekChar()))
     {
         this.AdvanceChar();
     }
     this.ConsumeToken();
 }
 private void ConsumeWhitespace()
 {
     // Advance over all whitespace characters and consume the all recently read characters
     for (; XPathCharTypes.IsWhitespace(PeekChar()); AdvanceChar())
     {
         ;
     }
     ConsumeToken();
 }