~ubuntu-branches/ubuntu/natty/smc/natty

« back to all changes in this revision

Viewing changes to src/core/file_parser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Muammar El Khatib
  • Date: 2008-10-20 00:31:35 UTC
  • mfrom: (1.1.4 upstream) (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081020003135-5ac8cpecomfohvv5
Tags: 1.6-1
* New upstream release. (Closes:#479415)
* Bumped standards version to 3.8.0.
* debian/control: dpatch build dependency has been removed temporarily.
* debian/control: smc-data does not depend on smc anymore. This change will
  avoid a circular dependency. (Closes: #478712)
* smc does not segfault. (Closes: #500039, #491590) 
* Icon is not missed in Gnome Menu. Thanks to Saïvann for providing a 
  solution. (Closes: #491885)
* debian/control: smc-data's and smc-music's descriptions have been improved.
  (Closes: #493630)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
                        file_parser.cpp  -  Image Settings Handler
3
 
                              -------------------
4
 
    copyright                 : (C) 2005 - 2007 by Florian Richter
 
2
 * file_parser.cpp  -  Image Settings Handler
 
3
 *
 
4
 * Copyright (C) 2005 - 2008 Florian Richter
5
5
 ***************************************************************************/
6
6
/*
7
7
   This program is free software; you can redistribute it and/or modify
55
55
 
56
56
bool cFile_parser :: Parse_Line( string command, int line )
57
57
{
58
 
        if( command.length() <= 5 || command.find_first_of( '#' ) == 0 )
59
 
        {
60
 
                return 1; // no error
61
 
        }
62
 
 
63
 
        while( command.find( '\r' ) != string::npos ) // Linux support
 
58
        // linux support
 
59
        while( command.find( '\r' ) != string::npos )
64
60
        {
65
61
                command.erase( command.find( '\r' ), 1 );
66
62
        }
67
63
 
68
 
        while( command.find( '\t' ) != string::npos ) // No Tabs
 
64
        // no tabs
 
65
        while( command.find( '\t' ) != string::npos )
69
66
        {
70
67
                command.replace( command.find( '\t' ), 1, " " );
71
68
        }
72
69
 
73
 
        while( command.find_last_of( ' ' ) == command.length() - 1  ) // No Spaces at the end
 
70
        // remove trailing spaces
 
71
        while( command.find_last_of( ' ' ) == command.length() - 1  )
74
72
        {
75
73
                command.erase( command.find_last_of( ' ' ), 1 );
76
74
        }
77
75
 
78
 
        while( command.find_first_of( ' ' ) == 0  ) // No Spaces at the beginning
 
76
        // remove beginning spaces
 
77
        while( command.find_first_of( ' ' ) == 0  )
79
78
        {
80
79
                command.erase( command.find_first_of( ' ' ), 1 );
81
80
        }
82
81
 
 
82
        // ignore comments and empty lines
 
83
        if( command.find_first_of( '#' ) == 0 || command.empty() )
 
84
        {
 
85
                // no error
 
86
                return 1;
 
87
        }
 
88
 
83
89
        string tempstr = command;
84
90
        int count = 1;
85
91
 
86
 
        while( tempstr.find( ' ' ) != string::npos  ) // Count Spaces
 
92
        // Count spaces
 
93
        while( tempstr.find( ' ' ) != string::npos  )
87
94
        {
88
95
                tempstr.erase( tempstr.find( ' ' ) , 1 );
89
96
                count++;