return 0;
}
-static inline int uci_parse_delta_tuple(struct uci_context *ctx, char **buf, struct uci_ptr *ptr)
+static inline int uci_parse_delta_tuple(struct uci_context *ctx, struct uci_ptr *ptr)
{
+ struct uci_parse_context *pctx = ctx->pctx;
+ char *str = pctx_cur_str(pctx), *arg;
int c = UCI_CMD_CHANGE;
- switch(**buf) {
+ UCI_INTERNAL(uci_parse_argument, ctx, ctx->pctx->file, &str, &arg);
+ switch(*arg) {
case '^':
c = UCI_CMD_REORDER;
break;
}
if (c != UCI_CMD_CHANGE)
- *buf += 1;
+ arg += 1;
- UCI_INTERNAL(uci_parse_ptr, ctx, ptr, *buf);
+ UCI_INTERNAL(uci_parse_ptr, ctx, ptr, arg);
if (!ptr->section)
goto error;
return 0;
}
-static void uci_parse_delta_line(struct uci_context *ctx, struct uci_package *p, char *buf)
+static void uci_parse_delta_line(struct uci_context *ctx, struct uci_package *p)
{
struct uci_element *e = NULL;
struct uci_ptr ptr;
int cmd;
- cmd = uci_parse_delta_tuple(ctx, &buf, &ptr);
+ cmd = uci_parse_delta_tuple(ctx, &ptr);
if (strcmp(ptr.package, p->e.name) != 0)
goto error;
pctx->file = stream;
while (!feof(pctx->file)) {
+ pctx->pos = 0;
uci_getln(ctx, 0);
if (!pctx->buf[0])
continue;
* delta as possible
*/
UCI_TRAP_SAVE(ctx, error);
- uci_parse_delta_line(ctx, p, pctx->buf);
+ uci_parse_delta_line(ctx, p);
UCI_TRAP_RESTORE(ctx);
changes++;
error:
pctx->file = f;
while (!feof(f)) {
struct uci_element *e;
- char *buf;
+ pctx->pos = 0;
uci_getln(ctx, 0);
- buf = pctx->buf;
- if (!buf[0])
+ if (!pctx->buf[0])
continue;
/* NB: need to allocate the element before the call to
e = uci_alloc_generic(ctx, UCI_TYPE_DELTA, pctx->buf, sizeof(struct uci_element));
uci_list_add(&list, &e->list);
- uci_parse_delta_tuple(ctx, &buf, &ptr);
+ uci_parse_delta_tuple(ctx, &ptr);
if (section) {
if (!ptr.section || (strcmp(section, ptr.section) != 0))
continue;
uci_alloc_parse_context(ctx);
ctx->pctx->file = stream;
-
- if (!*str) {
+ if (!*str)
uci_getln(ctx, 0);
- *str = ctx->pctx->buf;
- } else {
- UCI_ASSERT(ctx, ctx->pctx->pos == *str - ctx->pctx->buf);
- }
/*FIXME do we need to skip empty lines? */
ofs_result = next_arg(ctx, false, false);