If chapter separator string is empty or starts with a dash, do not include chapter numbers in file name

Closes #3
This commit is contained in:
Fabian Kurz 2020-12-24 22:01:48 +01:00
parent a3de8cc162
commit c996d889e7
3 changed files with 17 additions and 3 deletions

View File

@ -1,3 +1,8 @@
0.8.4 / unreleased Fabian Kurz <fabian@fkurz.net>
* If chapter separator is empty (-c "") or starts with
a dash (-c "-"), do not append a chapter number to filenames
(tnx F6FLF)
0.8.3 / 2020-05-23 Fabian Kurz <fabian@fkurz.net>
* Added lowercase Greek alphabet
* Added multiple language support by GNU gettext.

View File

@ -29,7 +29,7 @@ endif
all: ebook2cw
ebook2cw: ebook2cw.c codetables.h
gcc ebook2cw.c -pedantic -Wall -lm $(LDFLAGS) $(CFLAGS) -o ebook2cw
gcc ebook2cw.c -pedantic -Wall -Wno-format-truncation -lm $(LDFLAGS) $(CFLAGS) -o ebook2cw
msgfmt -o po/de.mo po/de.po
cgi: ebook2cw.c codetables.h

View File

@ -401,7 +401,9 @@ cw.encoding = UTF8;
init_cw(&cw); /* generate raw dit, dah */
strcat(cw.chapterstr, " ");
if (strlen(cw.chapterstr)) {
strcat(cw.chapterstr, " ");
}
cw.original_wpm = cw.wpm; /* may be changed by QRQing */
chapter = 0;
@ -885,8 +887,15 @@ void openfile (int chapter, CWP *cw) {
ogg_packet hdr_code;
#endif
snprintf(cw->outfilename, 80, "%s%04d.%s", cw->chapterfilename, chapter,
/* If we have a chapter separator string, use format Chapter0001.mp3 */
if (strlen(cw->chapterstr) && cw->chapterstr[0] != '-') {
snprintf(cw->outfilename, 80, "%s%04d.%s", cw->chapterfilename,
chapter, (cw->encoder == MP3) ? "mp3" : "ogg");
}
else { /* otherwise just Chapter.mp3 */
snprintf(cw->outfilename, 80, "%s.%s", cw->chapterfilename,
(cw->encoder == MP3) ? "mp3" : "ogg");
}
printf(_("Starting %s\n"), cw->outfilename);
if ((cw->encoder != NOENC) &&