Cleanups and simplifications in read_file().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@117 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -158,17 +158,17 @@ char *topic = NULL;
|
|||||||
char *subject = NULL;
|
char *subject = NULL;
|
||||||
int item_number = 0;
|
int item_number = 0;
|
||||||
int topics = 0;
|
int topics = 0;
|
||||||
fgets(line, sizeof(line)-1, help_file);
|
|
||||||
if (line)
|
while (fgets(line, sizeof line, help_file))
|
||||||
line[strlen(line)-1] = '\0';
|
|
||||||
while (!feof(help_file))
|
|
||||||
{
|
{
|
||||||
if (!line || !*line || *line == '#')
|
size_t len = strlen(line);
|
||||||
{
|
if (line[len - 1] == '\n')
|
||||||
fgets(line, sizeof(line)-1, help_file);
|
line[len - 1] = '\0';
|
||||||
|
|
||||||
|
if (!*line || *line == '#')
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
else if (*line && (*line != ' ')) /* we got a topic copy to topic */
|
if (*line != ' ') /* we got a topic copy to topic */
|
||||||
{
|
{
|
||||||
topics++;
|
topics++;
|
||||||
item_number = 0;
|
item_number = 0;
|
||||||
@@ -199,15 +199,9 @@ int topics = 0;
|
|||||||
help_index[topics-1]->title = m_strdup(line);
|
help_index[topics-1]->title = m_strdup(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fgets(line, sizeof(line)-1, help_file);
|
|
||||||
if (line)
|
|
||||||
line[strlen(line)-1] = '\0';
|
|
||||||
}
|
}
|
||||||
else if (topic && *topic)
|
else if (topic && *topic)
|
||||||
{ /* we found the subject material */
|
{ /* we found the subject material */
|
||||||
do {
|
|
||||||
if (!line || (line && *line != ' '))
|
|
||||||
break;
|
|
||||||
if (helpfunc)
|
if (helpfunc)
|
||||||
{
|
{
|
||||||
RESIZE(script_help[topics-1]->contents, char **, ++item_number);
|
RESIZE(script_help[topics-1]->contents, char **, ++item_number);
|
||||||
@@ -218,10 +212,6 @@ int topics = 0;
|
|||||||
RESIZE(help_index[topics-1]->contents, char **, ++item_number);
|
RESIZE(help_index[topics-1]->contents, char **, ++item_number);
|
||||||
help_index[topics-1]->contents[item_number-1] = m_strdup(line);
|
help_index[topics-1]->contents[item_number-1] = m_strdup(line);
|
||||||
}
|
}
|
||||||
fgets(line, sizeof(line)-1, help_file);
|
|
||||||
if (line)
|
|
||||||
line[strlen(line)-1] = '\0';
|
|
||||||
} while (!feof(help_file));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user