ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/inifile_reader.c
(Generate patch)

Comparing Daodan/src/inifile_reader.c (file contents):
Revision 346 by rossy, Tue Jun 9 12:00:41 2009 UTC vs.
Revision 349 by rossy, Wed Jun 10 12:40:16 2009 UTC

# Line 5 | Line 5
5   #include <ctype.h>
6  
7   #include "inifile.h"
8 <
8 > /*
9 > char* inifile_cleanstr(char* str)
10 > {
11 >        while (isspace(*str))
12 >                str++;
13 >        
14 >        int i;
15 >        for (i = 0; str[i]; i ++)
16 >        {
17 >                if
18 >        }
19 >        
20 >        return str;
21 > }
22 > */
23   bool inifile_read(char* filename, inifile_callback callback)
24   {
25          FILE* fp = fopen(filename, "r");
# Line 42 | Line 56 | bool inifile_read(char* filename, inifil
56                          
57                          if (inisection[0])
58                                  free(inisection);
59 <                        inisection = strdup(readptr + 1);
59 >                        inisection = strdup(readptr + 1); // Skip the first [
60                          newsection = true;
61                  }
62                  else // It's a value.
# Line 56 | Line 70 | bool inifile_read(char* filename, inifil
70                          if (readptr[i - 1] == '\n')
71                                  readptr[i - 1] = '\0'; // Remove the trailing newline.
72                          
73 <                        if (equals) // If there's no equals, crash with error.
73 >                        if (equals)
74                          {
75                                  readptr[equals] = '\0';
76                                  if (!callback(inisection, newsection, readptr, readptr + equals + 1)) // If the callback is false, exit.
77                                          break;
78                                  newsection = false;
79                          }
80 <                        else
80 >                        else // If there's no equals, crash with error.
81                          {
82                                  success = false;
83                                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)