Skip to content

Commit ee31951

Browse files
committed
make batch mode output lazy
1 parent db3aa3c commit ee31951

File tree

5 files changed

+13
-56
lines changed

5 files changed

+13
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- improve search and display of builtins
99
- add `vips_image_guess_interpretation` builtin
1010
- improve display of computed multipage images
11+
- batch mode output is lazy
1112

1213
## 9.0.13 2025/09/20
1314

TODO

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
- try:
2-
3-
main = "...." ++ error "hello";
4-
5-
does not print any "..."
6-
7-
print of main should be lazyier
8-
9-
main_print_main() does strict reduction of main
10-
11-
graph_value() is also strict
12-
131
- try < > in the image titlebar
142

153
seems to get stuck on eg. mp3 files

src/heap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ shell_node(Reduce *rc, HeapNode *hn)
26172617
for (;;) {
26182618
PEPOINTLEFT(hn, &p1);
26192619
if (!reduce_pelement(rc, reduce_spine, &p1) ||
2620-
shell_pelement(rc, &p1))
2620+
!shell_pelement(rc, &p1))
26212621
return FALSE;
26222622

26232623
PEPOINTRIGHT(hn, &p2);
@@ -2672,7 +2672,8 @@ shell_pelement(Reduce *rc, PElement *base)
26722672
break;
26732673

26742674
case ELEMENT_NODE:
2675-
shell_node(rc, PEGETVAL(base));
2675+
if (!shell_node(rc, PEGETVAL(base)))
2676+
return FALSE;
26762677
break;
26772678

26782679
case ELEMENT_CHAR:

src/main-batch.c

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,15 @@ static GOptionEntry main_batch_options[] = {
6363
{ NULL }
6464
};
6565

66-
/* Accumulate startup errors here.
67-
*/
68-
static char main_start_error_txt[MAX_STRSIZE];
69-
static VipsBuf main_start_error = VIPS_BUF_STATIC(main_start_error_txt);
70-
71-
static void
72-
main_log_add(const char *fmt, ...)
73-
{
74-
va_list ap;
75-
76-
va_start(ap, fmt);
77-
vips_buf_vappendf(&main_start_error, fmt, ap);
78-
va_end(ap);
79-
}
80-
81-
static const char *
82-
main_log_get(void)
83-
{
84-
return vips_buf_all(&main_start_error);
85-
}
86-
87-
static gboolean
88-
main_log_is_empty(void)
89-
{
90-
return vips_buf_is_empty(&main_start_error);
91-
}
92-
9366
/* Print all errors and quit.
9467
*/
9568
static void
9669
main_error_exit(const char *fmt, ...)
9770
{
71+
/* We may have some half-written text .. flush before any error message.
72+
*/
73+
fflush(stdout);
74+
9875
if (fmt) {
9976
va_list args;
10077

@@ -111,17 +88,7 @@ main_error_exit(const char *fmt, ...)
11188
fprintf(stderr, "\n");
11289
}
11390

114-
if (main_option_verbose) {
115-
char txt[MAX_STRSIZE];
116-
VipsBuf buf = VIPS_BUF_STATIC(txt);
117-
118-
slist_map(expr_error_all, (SListMapFn) expr_error_print, &buf);
119-
fprintf(stderr, "%s", vips_buf_all(&buf));
120-
121-
if (!main_log_is_empty())
122-
fprintf(stderr, "%s", main_log_get());
123-
}
124-
91+
main_shutdown();
12592
exit(1);
12693
}
12794

@@ -215,7 +182,8 @@ main_print_main(Symbol *sym)
215182
main_error_exit(_( "error saving \"%s\""), symbol_name_scope(sym));
216183
}
217184
else
218-
if (!graph_value(root))
185+
if (!symbol_recalculate_check(sym) ||
186+
!graph_value(root))
219187
main_error_exit(NULL);
220188
}
221189

@@ -336,7 +304,7 @@ main_build_argv(int argc, char **argv)
336304

337305
attach_input_string(vips_buf_all(&buf));
338306
if (!parse_onedef(kit, -1))
339-
main_log_add("%s\n", error_get_sub());
307+
main_error_exit(NULL);
340308

341309
filemodel_set_modified(FILEMODEL(kit), FALSE);
342310
}
@@ -465,7 +433,7 @@ main(int argc, char **argv)
465433
printf("main_set: %s\n", main_option_set[i]);
466434

467435
if (!main_set(main_option_set[i]))
468-
main_log_add("%s\n%s", error_get_top(), error_get_sub());
436+
main_error_exit(NULL);
469437
}
470438

471439
if (main_option_test) {

test/workspaces/x.def

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)