- What if an input page specifies /Rotate?
- "-f" switch
- Help
-- Clean up debugging messages, use more levels
+- Parameters vs. arguments
+- More precise parsing errors
| # Position bbox on a new paper
| paper("a4")
st.scale = scale_to_fit(image, window);
st.fill_factor = (st.scale*image.width() * st.scale*image.height()) / (st.paper_w * st.paper_h);
- debug("Try: %dx%d on %.3f x %.3f => scale %.3f, fill %.6f",
- st.cols, st.rows,
- st.paper_w, st.paper_h,
- st.scale, st.fill_factor);
+ if (debug_level > 1)
+ debug("Try: %dx%d on %.3f x %.3f => scale %.3f, fill %.6f",
+ st.cols, st.rows,
+ st.paper_w, st.paper_h,
+ st.scale, st.fill_factor);
if (!found_solution || best.fill_factor < st.fill_factor)
{
if (!found_solution)
err("No feasible solution found");
- debug("Best: %dx%d on %.3f x %.3f", best.cols, best.rows, best.paper_w, best.paper_h);
+ debug("Best: %dx%d on %.3f x %.3f => scale %.3f, fill %.6f",
+ best.cols, best.rows,
+ best.paper_w, best.paper_h,
+ best.scale, best.fill_factor);
debug_indent -= 4;
}
extern const char *in_name, *out_name;
extern bool recalc_bbox;
-extern int debug_mode;
+extern int debug_level;
extern int debug_indent;
void debug(const char *msg, ...) FORMAT_CHECK(printf, 1, 2);
const char *in_name;
const char *out_name;
bool recalc_bbox;
-int debug_mode;
+int debug_level;
int debug_indent;
/*** Messages ***/
void debug(const char *msg, ...)
{
- if (!debug_mode)
+ if (!debug_level)
return;
va_list args;
va_start(args, msg);
recalc_bbox = 1;
break;
case 'd':
- debug_mode++;
+ debug_level++;
break;
case OPT_VERSION:
printf("This is paperjam with no version yet.\n"); // FIXME
void parse(const char *in, list<cmd *> &cmds)
{
+ debug("### Parsing commands");
in_pos = in;
parse_commands(cmds);
if (next_token() != TOK_END)
parse_error("Extra tokens after commands");
- debug_cmds(cmds);
+ if (debug_level > 1)
+ debug_cmds(cmds);
instantiate(cmds);
}
void debug_pages(vector<page *> &pages)
{
- if (!debug_mode)
+ if (!debug_level)
return;
for (auto pg: pages)
void process(list<cmd *> &cmds)
{
+ debug("### Reading input");
in_pdf.processFile(in_name);
in_pdf.pushInheritedAttributesToPage();
out_pdf.emptyPDF();
if (recalc_bbox)
do_recalc_bbox(pages, in_name);
+ debug("### Running commands");
pages = run_command_list(cmds, pages);
+ debug("### Writing output");
for (auto pg: pages)
{
out_context out;
// Write the output file
QPDFWriter writer(out_pdf, out_name);
writer.write();
+ debug("### Done");
}
/*** Re-calculation of bboxes ***/