unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* syntax coloring tight-loop bug
@ 2006-04-14  9:52 Tim Love
  2006-04-15 17:32 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Love @ 2006-04-14  9:52 UTC (permalink / raw


This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.3.1 (hppa2.0w-hp-hpux11.11, Motif Version 2.1.0)
 of 2003-07-15 on last
configured using `configure  --with-gcc=no --prefix=/opt/emacs-21.3 --with-x-toolkit=motif --x-includes=/usr/include/Motif2.1 --x-libraries=/usr/lib/Motif2.1'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:


With certain C++ files, users can input characters that cause the emacs
window to freeze while emacs uses all available CPU. It's repeatable on 
HP-UX (details above) and on SuSE 10.0 with Gnu Emacs 21.3.1.

Here's a repeat-by
* Load the text below into buffer (apologies for the length)
* append  " (" to the "if (volume ==0)" line
* wait a second or 2 for the file to be recolorized

--- snip here ---
// OurTradingFunctions2.cc
// File containing function definitions written for part 2

// Standard library header files
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vogle.h>
#include <vogleextras.h>
#include <trading.h>

// User-defined constants, data structures and function prototypes
#include "OurTradingHeader.h"


using namespace std;
// Function to initialise trading account and connect to exchange
void InitialiseAccount(int dataSet, int labGroup, TradingAccount &account)
{
   int ec, day= 0;

   // Set data members of TradingAccount structure for day = 0
   account.today = day;
   account.price[day] = 20.0;
   account.transaction[day] = TT_PASS;
   account.volume[day] = 0;
   account.stock[day] = 0;
   account.balance[day] = 20000.0;

   // Call trading library function and handle exit (return) code
   ec = TE_InitialiseTrading(dataSet, labGroup);
   HandleExitCode(ec);



}

// Function definition to display error messages from trading exchange
// The program is terminated with exit(-1) if there is an error
void HandleExitCode(int errorCode)
{
   switch(errorCode)
   {
      case TE_OKAY:
         break;

      case TE_FAIL:
         cout << "Trading error: bad parameter." << endl;
         exit(-1);

      case TE_ALREADY_CONNECTED:
         cout << "Trading error: already connected to server." << endl;
         exit(-1);

      case TE_NOT_CONNECTED:
         cout << "Trading error: not connected to server." << endl;
         exit(-1);

      case TE_AUTH_FAILED:
         cout << "Trading error: authorisation failed." << endl;
         exit(-1);

      case TE_TOO_EARLY:
         cout << "Trading error: must agree price every day." << endl;
         exit(-1);

      case TE_TOO_LATE:
         cout << "Trading error: transaction already made for today." << endl;
         exit(-1);

      case TE_NO_FUNDS:
         cout << "Trading error: insufficient funds for purchase." << endl;
         exit(-1);

      case TE_NO_STOCK:
         cout << "Trading error: insufficient stock for sale." << endl;
         exit(-1);

      default:
         cout << "Trading error: trading system failure." << endl;
         exit(-1);
  }
}
//Gets todays price and calls the decision making function

void MyTrader(TradingAccount &account ModelData data)


{

  int ec, i, volume;


for (int i=1; i<51; i++)
{

     ec =  TE_GetPrice(i, account.price[i]);
    //loops through 50 days

     HandleExitCode(ec);
     //checks for a valid return code
     account.today = i;

     MakeDecision1(account,volume);

     ec =  TE_Trade(account.transaction[account.today], volume);

     HandleExitCode(ec);

     UpdateAccount(account,volume);
 }


}

int MakeDecision2(TradingAccount &account, int &volume, ModelData data)
{

  float PricePred, PriceAct, Square, M;

  PricePred = data.a + (data.b*(account.today+100));
  //predicted price from bet fit line for this day
  PriceAct = account.price[i];
  //actual price
  Square = (PricePred - PriceAct)*(PricePred - PriceAct);
  //difference sqaured to compare to variance
  M = 20/(data.variance)
    //gradient of model line for volume to buy or sell
  volume = M*Square
    //model line





    //dec buy sell pass
    if (volume == 0)

{

 account.transaction[account.today]=0

}

    else  if ((PricePred - PriceAct) > 0)
{
account.transaction[account.today] = 1
}

    else ((PricePred - PriceAct) < 0)
      {

account.transaction[account.today] = -1
      }


}



int MakeDecision1(TradingAccount &account, int &volume)

{

  if(account.today == 50)
    {
    account.transaction[account.today] = 1;
    volume = 1000;
    }
  else
    {
      account.transaction[account.today] = 0;
      volume = 0;
    }


  return volume;

}


void UpdateAccount(TradingAccount &account, int volume)

{
  account.volume[account.today] = volume;

  account.stock[account.today] = account.stock[(account.today) - 1]
+(volume*(account.transaction[account.today]));

  account.balance[account.today] = account.balance[(account.today) - 1] -(
(account.price[account.today]) * volume * account.transaction[account.today]);

}



void CloseAccount(TradingAccount &account)

{

  int ec, finalstock;
  float finalbalance;

  ec = TE_CloseTrading(finalbalance, finalstock);

  HandleExitCode(ec);

  cout << "Our final Balance is" << account.balance[50] << endl;

  cout << "Our Final Stock is" << account.stock[50] << endl;

  cout << finalbalance << endl;
  cout << finalstock << endl;

}


void writeresults(TradingAccount account)

{

  ofstream fout;

  fout.open("output.dat");
  if (fout.good())
    {

      fout << "Price  Transaction  Volume  Stock  Balance" << endl;

for (int i=1; i<51; i++)
  {
      fout << account.price[i] << "    ";
      fout << account.transaction[i]<<"          ";
      fout << account.volume[i]<<"    ";
      fout << account.stock[i]<<"      ";
      fout << account.balance[i]<<"       "<<endl;
  }
    } // brace for if
  else
    {

      cout << "Cannot open file";
    }

}


--- snip here ---

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: syntax coloring tight-loop bug
  2006-04-14  9:52 syntax coloring tight-loop bug Tim Love
@ 2006-04-15 17:32 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2006-04-15 17:32 UTC (permalink / raw
  Cc: bug-gnu-emacs

I think this is fixed in the latest development Emacs,
from CVS on savannah.gnu.org.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-15 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-14  9:52 syntax coloring tight-loop bug Tim Love
2006-04-15 17:32 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).