summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-07-22 14:47:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-22 16:17:01 +0200
commitcf7c8f37d6c65c5fa9ab89c8a7001faf18bda319 (patch)
tree4f1749ec3324008e2ebe901a7f2f3fabfbebf479 /scripts
parent1ee484f3829e3f69d43fa46aa210a12ffc610908 (diff)
downloadbarebox-cf7c8f37d6c65c5fa9ab89c8a7001faf18bda319.tar.gz
barebox-cf7c8f37d6c65c5fa9ab89c8a7001faf18bda319.tar.xz
scripts: imx-image: allow semicolon as command delimiter
When we want to pass the imxcfg files through cpp we also want to allow defines which define multiple commands. For this to work we have to use an additional command delimiter as we can't pass '\n' though cpp. Use ';' for this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-image.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 2f52015ae1..09fdc5f1c0 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -492,12 +492,40 @@ struct command cmds[] = {
},
};
+static char *readcmd(FILE *f)
+{
+ static char *buf;
+ char *str;
+ ssize_t ret;
+
+ if (!buf) {
+ buf = malloc(4096);
+ if (!buf)
+ return NULL;
+ }
+
+ str = buf;
+ *str = 0;
+
+ while (1) {
+ ret = fread(str, 1, 1, f);
+ if (!ret)
+ return strlen(buf) ? buf : NULL;
+
+ if (*str == '\n' || *str == ';') {
+ *str = 0;
+ return buf;
+ }
+
+ str++;
+ }
+}
+
static int parse_config(const char *filename)
{
FILE *f;
int lineno = 0;
char *line = NULL, *tmp;
- size_t len;
char *argv[MAXARGS];
int nargs, i, ret;
@@ -507,15 +535,16 @@ static int parse_config(const char *filename)
exit(1);
}
- while ((getline(&line, &len, f)) > 0) {
+ while (1) {
+ line = readcmd(f);
+ if (!line)
+ break;
+
lineno++;
tmp = strchr(line, '#');
if (tmp)
*tmp = 0;
- tmp = strrchr(line, '\n');
- if (tmp)
- *tmp = 0;
nargs = parse_line(line, argv);
if (!nargs)