[Mono-dev] Mono newbie - weird stack behaviour (possible bug)

MrJ Man auxsvr at yahoo.com
Fri Mar 10 17:19:12 EST 2006


Hi all,

First of all, this is my first program in C# (actually
an adaptation of a 
filter in beagle), so please forgive me if I am wrong
in any of the following 
or posting to the wrong maillist:

stack EnvironmentDataStack has .Count changed without
any pushes or pops 
taking place, as seen when running the filter using
ExtractContent.exe. The 
lines are marked with BUG. Did a quick search in
google and bugzilla without 
results.

Thanks in advance.

private ErrorCodes HandleControlWordArgument ()
                {
                        int aByte = -1;
                        char ch;
                        StringBuilder strCtrlWordArg =
new StringBuilder ();
                        string strTemp = null;
                        TeXControlWordType
ctrlWrdType; 
                        
                        aByte = SReaderTeX.Read ();
                        if (aByte == -1)
                                return
ErrorCodes.ERROR_TEX_EOF;
                        ch = (char) aByte;
                        
                        while (aByte != -1) {
                                strCtrlWordArg.Append
(ch);
                                aByte =
SReaderTeX.Peek ();
                                ch = (char) aByte;
                                if (Char.IsLetter
(ch)) {
                                        aByte =
SReaderTeX.Read ();
                                        ch = (char)
aByte;
                                }
                                else 
                                        break;
                        }
                        
                        if (EnvironmentDataStack.Count
> 0) {
                                strTemp = (string)
EnvironmentDataStack.Pop();
                                if (String.Compare
(strTemp, "begin") == 0) {
                                       
EnvironmentDataStack.Push ("begin");
                                       
Console.WriteLine ("Argument1: {0}",
strCtrlWordArg.ToString());
                                       
EnvironmentDataStack.Push (strCtrlWordArg.ToString());
                                         //Closing
block, stack handling
                                } else if
(String.Compare (strTemp, "end") == 0) {
                                       
Console.WriteLine ("Argument2: {0}, {1}",
strCtrlWordArg.ToString(), 
EnvironmentDataStack.Count);
                                
                                        // Check
whether there is an enclosing environment
                                        if
(EnvironmentDataStack.Count > 3) {
                                               
strTemp = (string) EnvironmentDataStack.Pop ();
                                               
Console.WriteLine ("Weirdness: {0}", strTemp);
                                                if
(String.Compare (strCtrlWordArg.ToString (), strTemp)
== 0) {
                                                      
 strCtrlWordArg.Remove (0, strCtrlWordArg.Length);
                                                      
 // Get rid of "begin"
                                                      
 strTemp = (string) EnvironmentDataStack.Pop ();
                                                      
 Console.WriteLine ("assuming begin: {0}, {1}",
strTemp, 
EnvironmentDataStack.Count);
                                                      
 //Retrieve previous environment
                                                      
 strCtrlWordArg.Append ((string)
EnvironmentDataStack.Pop ());
                                                      
 //Reset bBlockBegin
                                                      
 //bBlockBegin = false;
                                                      
 // BUG: Difference from here
                                                      
 Console.WriteLine ("...becomes: {0}, {1}"
,strCtrlWordArg.ToString(), 
EnvironmentDataStack.Count);
                                                      
 //EnvironmentDataStack.Push (strCtrlWordArg);
                                                } else
                                                      
 Console.WriteLine ("Reached the impossible!\n");
                                                      
 EnvironmentDataStack.Push (strTemp); //FIXME
Shouldn't reach it
                                        }
                                }
                        }
                        // BUG To here
                        Console.WriteLine ("count:
{0}", EnvironmentDataStack.Count);

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Mono-devel-list mailing list