bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PgDown Problem


From: Anton Kulchitsky
Subject: PgDown Problem
Date: Mon, 20 Oct 2003 17:14:12 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007

I am again about the bug,

From the Manual: "Taking forever to complete a command can be a bug, but you must make
certain that it was really Emacs's fault."

The following command make emacs taking forever to complete a command for all tested versions (21.x) up to ver. 21.2 ., that is the last I have.

PageDown from the start of the file of the exact lengths for the exact window sizes in KDE.

My current system is

GNU Emacs 21.2.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2003-10-20 on zeus
Linux 2.4.something (distr. Red Hat 9.0)
KDE 3.1-10
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

No operands were given when Emacs was installed

I did not do any modifications into emacs. However, there are a few quite unusual specifications in .emacs: There are

=========

;;font size
(set-face-font 'default "7x14")

;;my favorite scrolling and margins
(setq scroll-conservatively 100)
(setq scroll-margin 4)

======

There are many different files where this bug occur. However, I attached one which definitely reproduce the bug at any time on my system.

You regret any guessing from my side. However, I guess, that the window size is very important. Thus, if I changed the window size this bug sometimes disappears and sometimes appears again. It occurs definitely if the window size is 611x632 px (which is default on my system for emacs) and mostly does not for the different window sizes. This 611x632 size concerns only to the attached files. For different files there are different "critical resolutions."

This bug is really terrible because it happens rather often and is very unexpected. I found it more than a year ago on my previous machine when I started emacs and found that it depends on my settings in .emacs file. However, different setting are inconvenient for me. I hoped also it will be found and fixed by others. I thought it is because of my previous computer first. However, nothing changed when I changed the computer and installed latest versions.

Thanks in advance,

Anton Kulchitsky.















/*

  Class Cdreader 2002 Anton Kulchitsky implementation

  ver. 1.01

  see file dreader.h for details

 */

#include <string>
#include <fstream>
#include <iostream>

#include <stdlib.h>
#include <stdio.h> 

using namespace std;

#include "dreader.h"

//local function to define size of file. Return 0 for mistake
int filesize(const char* name)
{
  FILE* F = fopen(name,"r");

  if(F==NULL) return 0;

  fseek(F,0,SEEK_END); //set position to the end of file
  int length = ftell(F);   //define number of position=> this is its length
  fclose(F);  //close file

  return length; //we found it
}

Cdreader::Cdreader()
{
  //file must be opened by Cdreader.open() if you use this constructor
}

Cdreader::Cdreader(const char* filename)
{
  open(filename);
}

Cdreader::~Cdreader()
{
  delete []buffer;  //never forget?
  delete []group;
}

//open and reading file
void Cdreader::open(const char* filename)
{
  //creating and reading buffer for file content
  int length = filesize(filename);  //filesize (already checked for overflow)

  if(length==0){
    ErrorMsg(BAD_FILE,filename);
    exit(1);
  }

  //allocate memory for the buffer;
  buffer = new char[length+1];
  group = new char[length+1];

  //reading file in buffer (skip all 0 characters)
  ifstream In(filename);
  char ch;
  for(int i=0;i<length;++i){
    In.get(ch); 
    if(ch!=char(0)) buffer[i]=ch;
    else buffer[i]=char(1);
  }
  buffer[length]=char(0); //last character means the end of string
}

//read integer number after string str in the current file
int Cdreader::iread(const char* FieldName, const char* GroupName)
{
  int n=0;  //result

  //Locate a group for work
  switch(LocateGroup(GroupName)){  //locate group
  case 0: break; //everything is fine
  case NO_GROUP_START: 
    ErrorMsg(NO_GROUP_START,FieldName,GroupName);
    return n;
  case NO_GROUP_END: 
    ErrorMsg(NO_GROUP_END,FieldName,GroupName);
    return n;
  }

  char *p = strstr(group,FieldName);
  if(p==NULL) ErrorMsg(NOT_FOUND, FieldName, GroupName);
  else  n = atoi(p+strlen(FieldName));

  return n;
}

//read float (double) number after string str in the current file
double Cdreader::fread(const char* FieldName, const char* GroupName)
{
  double f=0; //result, default=0

  //Locate a group for work
  switch(LocateGroup(GroupName)){  //locate group
  case 0: break; //everything is fine
  case NO_GROUP_START: 
    ErrorMsg(NO_GROUP_START,FieldName,GroupName);
    return f;
  case NO_GROUP_END: 
    ErrorMsg(NO_GROUP_END,FieldName,GroupName);
    return f;
  }

  char *p = strstr(group,FieldName);
  if(p==NULL) ErrorMsg(NOT_FOUND, FieldName, GroupName);
  else  f = atof(p+strlen(FieldName));

  return f;
}

//read string outstr after string str in the current file
//(between ""), not more than maxlength simbols
//do not check if outstr has enough length!!! must be at least maxlength+1 !!!
void Cdreader::strread(char* outstr, int maxlength,
               const char* FieldName, const char* GroupName)
{
  outstr[0]=char(0); //initial meaning

  //Locate a group for work
  switch(LocateGroup(GroupName)){  //locate group
  case 0: break; //everything is fine
  case NO_GROUP_START: 
    ErrorMsg(NO_GROUP_START,FieldName,GroupName);
    return;
  case NO_GROUP_END: 
    ErrorMsg(NO_GROUP_END,FieldName,GroupName);
    return;
  }

  char *p = strstr(group,FieldName);
  if(p==NULL){
    ErrorMsg(NOT_FOUND, FieldName, GroupName);
    return;  //immidiate exit
  }
  p = p+strlen(FieldName); //shift to the end of str

  //seeking for "
  char* quat1 = strchr(p,'\"');
  if(quat1==NULL){
    ErrorMsg(NO_LEFT_QUAT,FieldName,GroupName);
    return; //immidiate exit
  }
  //seeking for closed "
  char* quat2 = strchr(quat1+1,'\"');
  if(quat2==NULL){
    ErrorMsg(NO_RIGHT_QUAT,FieldName,GroupName);
    return;  //immidiate exit
  }

  int length = (int)quat2-(int)quat1 -1;
  if(maxlength<length){
    ErrorMsg(TOO_LONG_STRING, FieldName, GroupName);
    length = maxlength;
  }

  //we have now the location of the string
  //end write this string into the output string
  for(int i=0;i<length;++i){
    outstr[i] = quat1[i+1];
  }

  outstr[length] = char(0);  //end of string!
}

//Group definition and locator!!! Group format is defined here
int Cdreader::LocateGroup(const char* GroupName)
{
  //trivial case
  if(GroupName==NULL){
    strcpy(group,buffer);  //whole buffer is a group
    return 0;  //no error return
  }

  /*
    I have tried to avoid allocation memory for the group,
    but it was not convenient and worked bad.
    Current solution takes twice memory but works
    very clear and simple 
  */

  //start to seek a group location
  char* GStartWord = new char[strlen(GroupName)+4];
  char* GEndWord = new char[strlen(GroupName)+4];

  (void)sprintf(GStartWord,"[%s::",GroupName);  //begin of group
  (void)sprintf(GEndWord,"::%s]",GroupName);  //end of group

  char* GStart=strstr(buffer,GStartWord);  //real start
  if(GStart==NULL) return NO_GROUP_START; //no group start
  else{
    GStart+=(strlen(GStartWord)); //shift to the start of group content
  }

  char* GEnd=strstr(GStart,GEndWord);  //real end: seek after beginning
  if(GEnd==NULL) return NO_GROUP_END; //no group start

  //now the only copy grooup from buffer to group
  int length = int(GEnd)-int(GStart);
  strncpy(group,GStart,length);
  group[length]=char(0);

  //time to release the memory
  delete [] GStartWord;
  delete [] GEndWord;

  return 0;
}

//Error Messages all located in the function ErrorMsg:
void Cdreader::ErrorMsg(int nError, const char* FieldName, const char* 
GroupName)
{
  switch(nError){

  case NOT_FOUND:
    cerr << "Warning (dreader): substring \"" << FieldName 
         << "\" is not found in data file";
    if(GroupName!=NULL) cerr << " in its group \"" << GroupName << "\"" << endl;
    else cerr << endl;
    cerr << "Accordance variable will be set at 0" << endl;
    break;

  case NO_GROUP_START:
    cerr << "Warning (dreader): Group name \"" << GroupName 
         << "\" is not found in data file" << endl;
    cerr << "Accordance variable will be set at 0" << endl;
    break;

  case NO_GROUP_END:
    cerr << "Warning (dreader): Group \"" << GroupName 
         << "\" has no end operator: group is not recognized" << endl;
    cerr << "Accordance variable will be set at 0" << endl;
    break;

  case NO_LEFT_QUAT:
    cerr << "Warning (dreader): open \" sign was not found after string " 
         << FieldName;
    if(GroupName!=NULL) cerr << " in its group \"" << GroupName << "\"" << endl;
    else cerr << endl;
    cerr << "Accordance string will be set at 0" << endl;
    break;

  case NO_RIGHT_QUAT:
    cerr << "Warning (dreader): close \" sign was not found for the string 
field " 
         << FieldName;
    if(GroupName!=NULL) cerr << " in its group \"" << GroupName << "\"" << endl;
    else cerr << endl;
    cerr << "Accordance string will be set at 0" << endl;
    break;

  case TOO_LONG_STRING:
    cerr << "Warning (dreader): the string placed after " << FieldName;
    if(GroupName!=NULL) cerr << "in its group \"" << GroupName << "\"" << endl;
    cerr << "is longer than supposed in program" << endl;
    cerr << "Only part of the string will be read" << endl;
    break;

  case BAD_FILE:
    cerr << "Error (dreader): \"" << FieldName 
         << "\" empty or not-existing file" << endl;
    break;

  default:
    cerr << "Unrecognized error (dreader)" << endl;
    break;
  }
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]