Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5018 in orxonox.OLD


Ignore:
Timestamp:
Aug 14, 2005, 11:05:01 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: NO MORE SEGFAULT again :)

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/util/ini_parser.cc

    r5017 r5018  
    4040  this->sections = NULL;
    4141  if (fileName != NULL)
    42     this->openFile(fileName);
     42    this->readFile(fileName);
    4343}
    4444
     
    9191 * @return true on success false otherwise;
    9292*/
    93 bool IniParser::openFile(const char* fileName)
     93bool IniParser::readFile(const char* fileName)
    9494{
    9595  FILE*    stream;           //!< The stream we use to read the file.
    96 
    97 
    9896  if (sections != NULL)
    9997    deleteSections();
     
    10199    return false;
    102100
     101  printf("1\n");
    103102  if( (stream = fopen (fileName, "r")) == NULL)
    104103  {
     
    108107  else
    109108  {
     109    printf("2\n");
    110110    this->currentEntry = NULL;
    111111    this->currentSection = NULL;
     
    119119    char* ptr;
    120120
    121     rewind (stream);
    122121    while( !feof( stream))
    123122    {
    124123      // get next line
    125124      fgets (lineBuffer, PARSELINELENGHT, stream);
     125      printf("%s", lineBuffer);
    126126      // remove newline char, and \0-terminate
    127127      if( (ptr = strchr( lineBuffer, '\n')) != NULL)
    128128        *ptr = 0;
    129129      // check for section identifyer
    130       if( sscanf (lineBuffer, "[%s", buffer) == 1)
     130      if (strlen(lineBuffer) <= 1)
     131        printf("empty Line\n");
     132      else if( sscanf (lineBuffer, "[%s", buffer) == 1)
    131133      {
    132134        if( (ptr = strchr( buffer, ']')) != NULL)
     
    137139          strcpy(newSection->name, buffer);
    138140          newSection->entries = new tList<IniEntry>;
     141          this->currentSection = newSection;
    139142          this->sections->add(newSection);
    140           this->currentSection = newSection;
    141143        }
    142144      }
     145      // check for Entry identifier (Entry = Value)
    143146      else if( (ptr = strchr( lineBuffer, '=')) != NULL)
    144147      {
     
    150153        if( ptr == lineBuffer)
    151154          continue;
    152         IniEntry* newEntry = new IniEntry;
    153 
    154155        char* valueBegin = ptr+1;
    155156        while ((*valueBegin == ' ' || *valueBegin == '\t') && valueBegin <= lineBuffer + strlen(lineBuffer))
    156157          ++valueBegin;
    157         newEntry->value = new char[strlen(valueBegin)+1];
    158         strcpy(newEntry->value, valueBegin);
    159         char* nameEnd = ptr-1, *nameBegin = lineBuffer;
     158        char* nameBegin = lineBuffer;
    160159        while ((*nameBegin == ' ' || *nameBegin == '\t') && nameBegin < ptr)
    161160          ++nameBegin;
     161        char* nameEnd = ptr-1;
    162162        while ((*nameEnd == ' ' || *nameEnd == '\t' ) && nameEnd >= nameBegin)
    163163          --nameEnd;
    164164        nameEnd[1] = '\0';
    165         newEntry->name = new char[strlen (nameBegin)];
     165
     166        IniEntry* newEntry = new IniEntry;
     167        newEntry->value = new char[strlen(valueBegin)+1];
     168        strcpy(newEntry->value, valueBegin);
     169        newEntry->name = new char[strlen (nameBegin)+1];
    166170        strcpy(newEntry->name, nameBegin);
    167171
  • orxonox/trunk/src/lib/util/ini_parser.h

    r5017 r5018  
    4242    ~IniParser ();
    4343
    44     bool openFile(const char* name);
     44    bool readFile(const char* name);
    4545
    4646    bool getSection(const char* sectionName);
  • orxonox/trunk/src/orxonox.cc

    r5015 r5018  
    139139
    140140  // initialize the Config-file
     141  printf("wet\n");
    141142  this->getConfigFile();
    142 
    143143
    144144  // initialize everything
     
    375375    }
    376376
     377    printf("finished inizialisation\n");
    377378  orx->start();
    378379
  • orxonox/trunk/src/orxonox.h

    r4866 r5018  
    11/*!
    2     \file orxonox.h
    3   * Orxonox core functions
     2 * @file orxonox.h
     3 * Orxonox core functions
    44*/
    55
Note: See TracChangeset for help on using the changeset viewer.