Example #1
0
        /***************************************************************************
         * Function: AbsorbAnyBlanks
         * Purpose:
         * Update PLINE by making it point to the first non-blank
         * at-or-after from but not after limit.
         * If they are all blank then make it point to limit
         * If from is non-blank then leave it alone.
         * Return true iff PLINE was updated.
         * It is legit for limit to be null (meaning end of file).*/
        public static bool AbsorbAnyBlanks(ref Line from , Line limit, bool bMoveToNext )
        {
            bool progress = false;

            while ( ( from != null ) && ( from.IsBlank() ) && ( from != limit ) ) {
                if( bMoveToNext ) from = (Line)from.GetNext();
                else			  from = (Line)from.GetPrev();
                progress = true;
            }
            return progress;
        }
Example #2
0
 /***************************************************************************
  * Function: NextNonIgnorable
  * Purpose:
  * An ignorable line is a blank line with no link and isIgnoreBlanks set
  * Given that line is initially not null and not ignorable:
  * If line is the last line in the list then return null
  * Else If isIgnoreBlanks is false then return the next line after line
  * else return next line which has a link or which is non-blank.
  * If there is no such line then return the last line in the list.
  * Note that this does always make progress (at the cost of sometimes returning null). */
 public static Line NextNonIgnorable(Line line,bool isIgnoreBlanks)
 {
     Line next = (Line)line.GetNext();
     if (next==null) return null;
     for(;;){
         line = next;
         if( line.link != null )	return line;
         if( !isIgnoreBlanks )	return line;
         if( !line.IsBlank() )	return line;
         next = (Line)line.GetNext();
         if( next == null ) return line;
     }
 }
Example #3
0
 /***************************************************************************
  * Function: FindEndOfUnmatched
  * Purpose:
  * Returns a Line which is the last line in an unmatched section
  * containing (probably starting with) Line.
  * Note that it does not necessarily make progress.
  * As noted above, even if blank lines are being ignored, we don't
  * mind tagging them onto the end of an already unmatching section.
  * This means we carry on until we find the first real link */
 public static Line FindEndOfUnmatched(Line line)
 {
     for(;;){
         Line next = (Line)line.GetNext();
         if( next == null ) return line;
         if( next.link != null ) return line;
         line = next;
     }
 }