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:
@@ -153,22 +153,22 @@ static int first_time = 1;
|
|||||||
|
|
||||||
int read_file(FILE *help_file, int helpfunc)
|
int read_file(FILE *help_file, int helpfunc)
|
||||||
{
|
{
|
||||||
char line[BIG_BUFFER_SIZE + 1];
|
char line[BIG_BUFFER_SIZE + 1];
|
||||||
char *topic = NULL;
|
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,29 +199,19 @@ 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 (helpfunc)
|
||||||
if (!line || (line && *line != ' '))
|
{
|
||||||
break;
|
RESIZE(script_help[topics-1]->contents, char **, ++item_number);
|
||||||
if (helpfunc)
|
script_help[topics-1]->contents[item_number-1] = m_strdup(line);
|
||||||
{
|
}
|
||||||
RESIZE(script_help[topics-1]->contents, char **, ++item_number);
|
else
|
||||||
script_help[topics-1]->contents[item_number-1] = m_strdup(line);
|
{
|
||||||
}
|
RESIZE(help_index[topics-1]->contents, char **, ++item_number);
|
||||||
else
|
help_index[topics-1]->contents[item_number-1] = m_strdup(line);
|
||||||
{
|
}
|
||||||
RESIZE(help_index[topics-1]->contents, char **, ++item_number);
|
|
||||||
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