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.h77
1 files changed, 40 insertions, 37 deletions
diff --git a/wrapper/plugin-parse.h b/wrapper/plugin-parse.h
index 4cad0bc..e4bfe2b 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"
@@ -58,6 +58,16 @@ plugin_parse_escape(FILE *file)
return c;
}
+#define _parse_share(string) \
+ case '#':\
+ plugin_parse_comment(file);\
+ break;\
+ case '\\':\
+ c[0]=plugin_parse_escape(file);\
+ default:\
+ stradds(&nbytes,string,(char *)&c);\
+ break;
+
char *
plugin_parse_depend (FILE *file)
{
@@ -72,14 +82,7 @@ plugin_parse_depend (FILE *file)
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;
+ _parse_share(&string)
}
}
return string;
@@ -88,38 +91,38 @@ plugin_parse_depend (FILE *file)
struct plugin_command *
plugin_parse (FILE *file)
{
- struct plugin_command *command=plugin_mk_command();
-
- size_t nbytes = 10;
- command->name = (char *)xmalloc(nbytes);
- command->name[0]='\0';
+ struct plugin_command *command;
char c[2] = " \0";
-
c[0]=getc(file);
- if (c[0]==EOF) return NULL;
- else ungetc (c[0], file);
- while ( (c[0]=getc(file)) != EOF ) {
- 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;
+ if (c[0]==EOF)
+ command=NULL;
+ else {
+ ungetc (c[0], file);
+ command=plugin_mk_command();
+
+ size_t nbytes = 10;
+ command->name = (char *)xmalloc(nbytes);
+ command->name[0]='\0';
+
+ while ( (c[0]=getc(file)) != EOF ) {
+ switch (c[0]) {
+ case '\n':
+ /*if (strlen(command->name)==0) {*/
+ if (c[0]=='\n') {
+ plugin_free_command(command);
+ return plugin_parse(file);
+ } else
+ command->next=plugin_parse(
+ file);
+ break;
+ case ':':
+ command->depends=plugin_parse_depend(
+ file);
+ break;
+ _parse_share(&(command->name))
+ }
}
}
return command;