int include_version_id;
int indent_preambles;
word bullet;
+ char *filename;
} textconfig;
static int text_convert(wchar_t *, char **);
ret.atitle.underline = L'=';
ret.achapter.align = LEFT;
ret.achapter.just_numbers = FALSE;
- ret.achapter.number_suffix = ustrdup(L": ");
+ ret.achapter.number_suffix = L": ";
ret.achapter.underline = L'-';
ret.nasect = 1;
ret.asect = mknewa(alignstruct, ret.nasect);
ret.asect[0].align = LEFTPLUS;
ret.asect[0].just_numbers = TRUE;
- ret.asect[0].number_suffix = ustrdup(L" ");
+ ret.asect[0].number_suffix = L" ";
ret.asect[0].underline = L'\0';
ret.include_version_id = TRUE;
ret.indent_preambles = FALSE;
- ret.bullet.text = ustrdup(L"-");
+ ret.bullet.text = L"-";
+ ret.filename = dupstr("output.txt");
for (; source; source = source->next) {
if (source->type == para_Config) {
if (!ustricmp(source->keyword, L"text-indent")) {
ret.indent = utoi(uadv(source->keyword));
+ } else if (!ustricmp(source->keyword, L"text-filename")) {
+ sfree(ret.filename);
+ ret.filename = utoa_dup(uadv(source->keyword));
} else if (!ustricmp(source->keyword, L"text-indent-code")) {
ret.indent_code = utoi(uadv(source->keyword));
} else if (!ustricmp(source->keyword, L"text-width")) {
} else if (!ustricmp(source->keyword, L"text-chapter-numeric")) {
ret.achapter.just_numbers = utob(uadv(source->keyword));
} else if (!ustricmp(source->keyword, L"text-chapter-suffix")) {
- ret.achapter.number_suffix = ustrdup(uadv(source->keyword));
+ ret.achapter.number_suffix = uadv(source->keyword);
} else if (!ustricmp(source->keyword, L"text-section-align")) {
wchar_t *p = uadv(source->keyword);
int n = 0;
if (n >= ret.nasect) {
int i;
ret.asect = resize(ret.asect, n+1);
- for (i = ret.nasect; i <= n; i++)
+ for (i = ret.nasect; i <= n; i++) {
ret.asect[i] = ret.asect[ret.nasect-1];
+ }
ret.nasect = n+1;
}
- ret.asect[n].number_suffix = ustrdup(p);
+ ret.asect[n].number_suffix = p;
} else if (!ustricmp(source->keyword, L"text-title-align")) {
ret.atitle.align = utoalign(uadv(source->keyword));
} else if (!ustricmp(source->keyword, L"text-title-underline")) {
return ret;
}
+paragraph *text_config_filename(char *filename)
+{
+ paragraph *p;
+ wchar_t *ufilename, *up;
+ int len;
+
+ p = mknew(paragraph);
+ memset(p, 0, sizeof(*p));
+ p->type = para_Config;
+ p->next = NULL;
+ p->fpos.filename = "<command line>";
+ p->fpos.line = p->fpos.col = -1;
+
+ ufilename = ufroma_dup(filename);
+ len = ustrlen(ufilename) + 2 + lenof(L"text-filename");
+ p->keyword = mknewa(wchar_t, len);
+ up = p->keyword;
+ ustrcpy(up, L"text-filename");
+ up = uadv(up);
+ ustrcpy(up, ufilename);
+ up = uadv(up);
+ *up = L'\0';
+ assert(up - p->keyword < len);
+ sfree(ufilename);
+
+ return p;
+}
+
void text_backend(paragraph *sourceform, keywordlist *keywords,
indexdata *idx) {
paragraph *p;
conf = text_configure(sourceform);
/*
- * Determine the output file name, and open the output file
- *
- * FIXME: want configurable output file names here. For the
- * moment, we'll just call it `output.txt'.
+ * Open the output file.
*/
- fp = fopen("output.txt", "w");
+ fp = fopen(conf.filename, "w");
if (!fp) {
- error(err_cantopenw, "output.txt");
+ error(err_cantopenw, conf.filename);
return;
}
* Tidy up
*/
fclose(fp);
- {
- int i;
- sfree(conf.achapter.number_suffix);
- for (i = 0; i < conf.nasect; i++)
- sfree(conf.asect[i].number_suffix);
- sfree(conf.asect);
- sfree(conf.bullet.text);
- }
+ sfree(conf.asect);
+ sfree(conf.filename);
}
/*