summaryrefslogtreecommitdiff
path: root/wrapper/plugin-parse.h
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper/plugin-parse.h')
-rw-r--r--wrapper/plugin-parse.h90
1 files changed, 38 insertions, 52 deletions
diff --git a/wrapper/plugin-parse.h b/wrapper/plugin-parse.h
index c75b1fe..4cad0bc 100644
--- a/wrapper/plugin-parse.h
+++ b/wrapper/plugin-parse.h
@@ -23,7 +23,7 @@
#define FILE_plugin_parse_h_SEEN
#include <stdio.h>
-#include <error.h> /* only used in `plugin_parse_escape' for `error' */
+#include <error.h> /* only used in `plugin_parse_escape' for `error'*/
#include "rvs.h"
#include "plugins.h"
@@ -66,24 +66,20 @@ plugin_parse_depend (FILE *file)
string[0]='\0';
char c[2] = " \0";
- char *cs = (char *)&c;
while ( (c[0]=getc(file)) != EOF ) {
- if (c[0] == '\n') {
- ungetc (c[0], file);
- break;
- } else {
- switch (c[0]) {
- case '\\':
- c[0]=plugin_parse_escape(file);
- stradds(&nbytes,&string,cs);
- break;
- case '#':
- plugin_parse_comment(file);
- break;
- default:
- stradds(&nbytes,&string,cs);
- break;
- }
+ switch (c[0]) {
+ case '\n':
+ ungetc (c[0], file);
+ return string;
+ break;
+ case '#':
+ plugin_parse_comment(file);
+ break;
+ case '\\':
+ c[0]=plugin_parse_escape(file);
+ default:
+ stradds(&nbytes,&string,(char *)&c);
+ break;
}
}
return string;
@@ -95,45 +91,35 @@ plugin_parse (FILE *file)
struct plugin_command *command=plugin_mk_command();
size_t nbytes = 10;
- char *string = (char *)xmalloc(nbytes);
- string[0]='\0';
+ command->name = (char *)xmalloc(nbytes);
+ command->name[0]='\0';
char c[2] = " \0";
- char *cs = (char *)&c;
- if ( (c[0]=getc(file)) == EOF )
- return NULL;
- else
- ungetc (c[0], file);
+ c[0]=getc(file);
+ if (c[0]==EOF) return NULL;
+ else ungetc (c[0], file);
while ( (c[0]=getc(file)) != EOF ) {
- if (c[0] == '\n') {
- if (strlen(string)==0) {
- xfree(command);
- xfree(string);
- command=plugin_parse(file);
- } else {
- command->name=string;
- command->next=plugin_parse(file);
- }
- break;
- } else {
- switch (c[0]) {
- case '\\':
- c[0]=plugin_parse_escape(file);
- stradds(&nbytes,&string,cs);
- break;
- case '#':
- plugin_parse_comment(file);
- break;
- case ':':
- command->depends=plugin_parse_depend(
- file);
- break;
- default:
- stradds(&nbytes,&string,cs);
- break;
- }
+ switch (c[0]) {
+ case '\n':
+ if (strlen(command->name)==0) {
+ plugin_free_command(command);
+ command=plugin_parse(file);
+ } else
+ command->next=plugin_parse(file);
+ break;
+ case ':':
+ command->depends=plugin_parse_depend(file);
+ break;
+ case '#':
+ plugin_parse_comment(file);
+ break;
+ case '\\':
+ c[0]=plugin_parse_escape(file);
+ default:
+ stradds(&nbytes,&(command->name),(char *)&c);
+ break;
}
}
return command;