Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package cutmp3 for openSUSE:Factory checked in at 2026-10-18 19:25:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cutmp3 (Old) and /work/SRC/openSUSE:Factory/.cutmp3.new.3698736 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cutmp3" Sun Oct 18 19:25:52 2026 rev:5 rq:1385895 version:4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/cutmp3/cutmp3.changes 2025-07-02 18:18:02.644747301 +0200 +++ /work/SRC/openSUSE:Factory/.cutmp3.new.3698736/cutmp3.changes 2026-10-18 19:26:27.312617553 +0200 @@ -1,0 +2,13 @@ +Sat Oct 17 16:45:48 UTC 2026 - Martin Pluskal <[email protected]> + +- Update to version 4.0: + * Optimised file copy + * Cleaner id3tag handling + * Option for linenoise instead of readline + * Skip first file frame that tends to hold meta information + * Fix signal handler prototypes (fixed upstream, drop + cutmp3-gcc15.patch) + * Drop the empty BUGS file from the docs (upstream ships it + zero-length) + +------------------------------------------------------------------- Old: ---- cutmp3-3.0.3.tar.gz cutmp3-gcc15.patch New: ---- cutmp3-4.0.tar.gz ----------(Old B)---------- Old: * Fix signal handler prototypes (fixed upstream, drop cutmp3-gcc15.patch) * Drop the empty BUGS file from the docs (upstream ships it ----------(Old E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cutmp3.spec ++++++ --- /var/tmp/diff_new_pack.xdcSNA/_old 2026-10-18 19:26:28.078649618 +0200 +++ /var/tmp/diff_new_pack.xdcSNA/_new 2026-10-18 19:26:28.083649827 +0200 @@ -1,7 +1,7 @@ # # spec file for package cutmp3 # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # Copyright (c) 2013 Packman Team <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -18,22 +18,19 @@ Name: cutmp3 -Version: 3.0.3 +Version: 4.0 Release: 0 Summary: Command line based lossless MP3 editor License: GPL-2.0-or-later -Group: Productivity/Multimedia/Sound/Editors and Convertors URL: https://www.puchalla-online.de/cutmp3.html #Source: https://www.puchalla-online.de/cutmp3-%%{version}.tar.bz2 Source0: https://github.com/tarjanm-movidius/cutmp3/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz Source1: https://www.puchalla-online.de/cutmp3-keys.pdf Source2: https://www.puchalla-online.de/cutmp3-keys.jpg Source99: %{name}-rpmlintrc -# https://github.com/tarjanm-movidius/cutmp3/issues/2 -Patch0: cutmp3-gcc15.patch -BuildRequires: ncurses-devel BuildRequires: pkgconfig -BuildRequires: readline-devel +BuildRequires: pkgconfig(ncurses) +BuildRequires: pkgconfig(readline) Requires: mpg123 Obsoletes: %{name}-kde3 @@ -46,9 +43,8 @@ %package doc Summary: Documentation for %{name} -Group: Documentation/Other -BuildArch: noarch Requires: %{name} = %{version} +BuildArch: noarch %description doc This is a program to edit MP3 files without quality loss, using an @@ -60,7 +56,9 @@ %autosetup -p1 %build -%make_build CFLAGS="%{optflags}" +# Upstream Makefile sets -DVERSION only via a target-specific CFLAGS+=, +# which a command-line CFLAGS= discards — pass it explicitly. +%make_build CFLAGS="%{optflags} -DVERSION=\"%{version}\"" %install install -m 0755 -D cutmp3 "%{buildroot}%{_bindir}/cutmp3" @@ -69,6 +67,7 @@ D="$PWD/main.doc.lst" echo -n >"$D" for f in BUGS USAGE README*; do + test -s "$f" || continue b="${f##*/}" install -m0644 "$f" "%{buildroot}%{_docdir}/%{name}/$b" echo "%doc %{_docdir}/%{name}/$b" >>"$D" @@ -86,7 +85,7 @@ %license COPYING %dir %doc %{_docdir}/%{name} %{_bindir}/%{name} -%{_mandir}/man1/%{name}.1%{ext_man} +%{_mandir}/man1/%{name}.1%{?ext_man} %files doc -f doc.doc.lst %dir %doc %{_docdir}/%{name} ++++++ cutmp3-3.0.3.tar.gz -> cutmp3-4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/.gitignore new/cutmp3-4.0/.gitignore --- old/cutmp3-3.0.3/.gitignore 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/.gitignore 2025-06-30 19:23:14.000000000 +0200 @@ -1,3 +1,5 @@ *~ *.o cutmp3 +gmon.out +gmon.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/.gitmodules new/cutmp3-4.0/.gitmodules --- old/cutmp3-3.0.3/.gitmodules 1970-01-01 01:00:00.000000000 +0100 +++ new/cutmp3-4.0/.gitmodules 2025-06-30 19:23:14.000000000 +0200 @@ -0,0 +1,4 @@ +[submodule "linenoise"] + path = linenoise + url = https://github.com/antirez/linenoise.git + branch = master diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/BUGS new/cutmp3-4.0/BUGS --- old/cutmp3-3.0.3/BUGS 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/BUGS 2025-06-30 19:23:14.000000000 +0200 @@ -1 +0,0 @@ -cutmp3 may crash with segmentation fault in silence seeking. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/Changelog new/cutmp3-4.0/Changelog --- old/cutmp3-3.0.3/Changelog 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/Changelog 2025-06-30 19:23:14.000000000 +0200 @@ -1,3 +1,12 @@ +version 4.0: +Optimised file copy +Cleaner id3tag handling +Option for linenoise instead of readline +Skipping file's first frame that tends to have some meta information + +version 3.0.4: +Fixed gcc15 compilation failing on bad signal handler prototypes +Updated linenoise submodule version 3.0.3: Quickfix, eliminated warnings -Wunused-result and -Wformat-security diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/Makefile new/cutmp3-4.0/Makefile --- old/cutmp3-3.0.3/Makefile 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/Makefile 2025-06-30 19:23:14.000000000 +0200 @@ -1,44 +1,57 @@ NAME=cutmp3 -VERSION=3.0.3 +VERSION=4.0 PREFIX?=/usr/local -BINDIR=${PREFIX}/bin -DATADIR=${PREFIX}/share -MANDIR=${PREFIX}/share/man/man1 -DOCDIR=${DATADIR}/doc/${NAME}-${VERSION} -CFLAGS?=-Wall -Wformat-security -Wunused-result -#CFLAGS+=-DDEBUG - -all: - @echo -e "\n\n*** You need readline-devel, ncurses-devel or similar to compile ${NAME} ***\n*** Maybe you want to try the binary on compile failures? ***\n\n" - gcc -O2 ${CFLAGS} -c mpglib.c - gcc -O2 ${CFLAGS} -c main.c - gcc main.o mpglib.o -o ${NAME} -lm -lreadline -#-lncurses - -i386: - gcc -Wall -O2 -c mpglib.c - gcc -Wall -O2 -c main.c - gcc main.o mpglib.o -o ${NAME} -lm -lreadline +BINDIR=$(PREFIX)/bin +DATADIR=$(PREFIX)/share +MANDIR=$(PREFIX)/share/man/man1 +DOCDIR=$(DATADIR)/doc/$(NAME)-$(VERSION) +CC=gcc +CFLAGS?=-Wall -Wformat-security -Wunused-result -O2 +LDFLAGS?=-lm -lreadline +DBGFLAGS:=-DDEBUG -g +LNSFLAGS:=-DLINENOISE +OBJECTS:=main.o mpglib.o + +.PHONY: clean debug install uninstall + +all: $(NAME) +debug: CFLAGS+=$(DBGFLAGS) +debug: $(NAME) +main.o: cutmp3.h +main.o: CFLAGS+=-DVERSION=\"$(VERSION)\" +*.o: Makefile mpglib.h + +ifeq ($(LNOISE), yes) +CFLAGS+=$(LNSFLAGS) +OBJECTS+=linenoise/linenoise.o +LDFLAGS:=$(filter-out -lreadline,$(LDFLAGS)) +*.o: linenoise/linenoise.h +linenoise/linenoise.o: Makefile linenoise/linenoise.h +endif + +all: $(info ) +all: $(info *** You need readline-devel or similar to compile $(NAME). Alternatively call 'make LNOISE=yes' ***) +all: $(info *** to build with linenoise, a self contained line editor. (see README for more information) ***) +all: $(info ) + +$(NAME): $(OBJECTS) + $(CC) -o $(NAME) $(OBJECTS) $(LDFLAGS) + @echo "" clean: - rm -f *.o - rm -f ${NAME} + @rm -vf *.o linenoise/*.o $(NAME) -install: - install -d ${BINDIR} - install ${NAME} ${BINDIR} - strip ${BINDIR}/${NAME} - if [ ! -z "${KDEDIR}" ]; then install -m 644 ${NAME}.desktop ${KDEDIR}/share/apps/konqueror/servicemenus; elif [ -d /usr/share/apps/konqueror/servicemenus ]; then install -m 644 ${NAME}.desktop /usr/share/apps/konqueror/servicemenus; elif [ -d /opt/kde/share/apps/konqueror/servicemenus ]; then install -m 644 ${NAME}.desktop /opt/kde/share/apps/konqueror/servicemenus; elif [ -d /opt/kde3/share/apps/konqueror/servicemenus ]; then install -m 644 ${NAME}.desktop /opt/kde3/share/apps/konqueror/servicemenus; fi - install -d ${DOCDIR}/${NAME} - install -m 644 README* USAGE ${DOCDIR}/${NAME} - install -d ${MANDIR} - gzip ${NAME}.1 - install -m 644 ${NAME}.1.gz ${MANDIR} - gunzip ${NAME}.1.gz +install: $(NAME) + @install -vd $(BINDIR) + @install -vd $(MANDIR) + @install -vd $(DOCDIR) + @echo -n "strip: " && strip -vso $(BINDIR)/$(NAME) $(NAME) + @gzip -vc9 $(NAME).1 2>&1 1> $(MANDIR)/$(NAME).1.gz | sed 's|stdout|$(MANDIR)/$(NAME).1.gz|' + @install -vm 644 README* USAGE $(DOCDIR) + @if [ ! -z "$(KDEDIR)" ]; then install -vm 644 $(NAME).desktop $(KDEDIR)/share/apps/konqueror/servicemenus; elif [ -d /usr/share/apps/konqueror/servicemenus ]; then install -vm 644 $(NAME).desktop /usr/share/apps/konqueror/servicemenus; elif [ -d /opt/kde/share/apps/konqueror/servicemenus ]; then install -vm 644 $(NAME).desktop /opt/kde/share/apps/konqueror/servicemenus; elif [ -d /opt/kde3/share/apps/konqueror/servicemenus ]; then install -vm 644 $(NAME).desktop /opt/kde3/share/apps/konqueror/servicemenus; fi uninstall: - rm -f ${BINDIR}/${NAME} - rm -f ${KDEDIR}/share/apps/konqueror/servicemenus/${NAME}.desktop + @rm -rvf $(BINDIR)/$(NAME) $(MANDIR)/$(NAME).1.gz $(DOCDIR) $(KDEDIR)/share/apps/konqueror/servicemenus/$(NAME).desktop /usr/share/apps/konqueror/servicemenus/$(NAME).desktop /opt/kde3/share/apps/konqueror/servicemenus/$(NAME).desktop -debug: - gcc ${CFLAGS} -DDEBUG -g mpglib.c main.c -o ${NAME} -lm -lreadline +prof: + if [ ! -e "$(NAME)" ]; then gcc $(CFLAGS) $(DBGFLAGS) -pg -DVERSION=\"$(VERSION)\" main.c mpglib.c $(LDFLAGS) -o $(NAME); elif [ -e "gmon.out" ]; then gprof -c --inline-file-names $(NAME) gmon.out > gmon.txt; fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/README new/cutmp3-4.0/README --- old/cutmp3-3.0.3/README 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/README 2025-06-30 19:23:14.000000000 +0200 @@ -12,18 +12,31 @@ If you want a working graphical software you can try mp3directcut, which runs fairly well in WINE after I asked the author about a WINEd version. -Compile cutmp3 with a simple -(you will need readline-devel or similar!) +-------------------------------------------------------------------------------- + +*** Compiling cutmp3 *** + +- If you have readline-devel or similar installed on your system: $ make -install it to /usr/local/bin with +- If you don't: + There is a self-contained minimalistic line editor included as a git + submodule. Kudos to antirez: https://github.com/antirez/linenoise + To check out and use: + +$ git submodule update --init +$ make LNOISE=yes + +- Installing to /usr/local/bin: $ make install ..or to /usr/bin with -$ PREFIX=/usr make install +$ make install PREFIX=/usr + +-------------------------------------------------------------------------------- Please read "USAGE" on detailed info on how to use cutmp3. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/TODO new/cutmp3-4.0/TODO --- old/cutmp3-3.0.3/TODO 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/TODO 2025-06-30 19:23:14.000000000 +0200 @@ -1,5 +1,7 @@ fading would be great fix volume() -Makefile /dev/shm +https://github.com/lieff/minimp3.git +1 scan at the beginning +id3 tags from buffer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/USAGE new/cutmp3-4.0/USAGE --- old/cutmp3-3.0.3/USAGE 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/USAGE 2025-06-30 19:23:14.000000000 +0200 @@ -2,7 +2,7 @@ By calling "cutmp3" you will get this: -cutmp3 version 3.0.3 +cutmp3 version 4.0 Usage: cutmp3 -i file.mp3 [-a inpoint] [-b outpoint] [-f timetable] [-o outputprefix] [-c] [-C] [-k] [-q] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/cutmp3.1 new/cutmp3-4.0/cutmp3.1 --- old/cutmp3-3.0.3/cutmp3.1 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/cutmp3.1 2025-06-30 19:23:14.000000000 +0200 @@ -1,4 +1,4 @@ -.TH CUTMP3 1 "Aug 31, 2022" "cutmp3 3.0.3" "Utility Commands" +.TH CUTMP3 1 "5 Apr 2023" "cutmp3 4.0" "Utility Commands" .SH NAME cutmp3 \- a fast and leightweight mp3 editor .SH SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/cutmp3.h new/cutmp3-4.0/cutmp3.h --- old/cutmp3-3.0.3/cutmp3.h 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/cutmp3.h 2025-06-30 19:23:14.000000000 +0200 @@ -10,8 +10,13 @@ #include <sys/time.h> #include <sys/types.h> -#include <readline/readline.h> -#include <readline/history.h> +#ifdef LINENOISE +# include "linenoise/linenoise.h" +# define readline linenoise +#else +# include <readline/readline.h> +# include <readline/history.h> +#endif #include "mpglib.h" @@ -25,7 +30,7 @@ unsigned int sampfreq(unsigned char secondbyte, unsigned char thirdbyte); unsigned int channelmode(unsigned char fourthbyte); unsigned int channels(unsigned char fourthbyte); -unsigned int bitrate(unsigned char secondbyte,unsigned char thirdbyte); +unsigned int bitrate(unsigned char secondbyte, unsigned char thirdbyte); unsigned int paddingbit(unsigned char thirdbyte); unsigned int framesize(unsigned char secondbyte,unsigned char thirdbyte,unsigned char fourthbyte); unsigned int is_header(int secondbyte, int thirdbyte, int fourthbyte); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/cutmp3.spec new/cutmp3-4.0/cutmp3.spec --- old/cutmp3-3.0.3/cutmp3.spec 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/cutmp3.spec 2025-06-30 19:23:14.000000000 +0200 @@ -1,6 +1,6 @@ Summary: Small and fast command line MP3 editor. Name: cutmp3 -Version: 3.0.3 +Version: 4.0 Release: 1 #Epoch: 1 License: GPL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cutmp3-3.0.3/main.c new/cutmp3-4.0/main.c --- old/cutmp3-3.0.3/main.c 2023-10-06 19:30:38.000000000 +0200 +++ new/cutmp3-4.0/main.c 2025-06-30 19:23:14.000000000 +0200 @@ -16,13 +16,10 @@ #include "cutmp3.h" -#define VERSION "3.0.3" -#define YEAR "2022" - /* general buffersize */ #define BUFFER 32000 #define FN_LEN 8191 -#define TAG_LEN 8191 +#define FS_BLOCK_SIZE 4096 /* 10 MB for VBR scanning */ #define SCANAREA 10485759 @@ -83,7 +80,6 @@ or "artist - title.mp3", so leave it empty here! */ char title[255]=""; - int hastable=0; unsigned char ttable[BUFFER]; FILE *tblfile; char tblname[17] = "/tmp/tableXXXXXX"; @@ -234,7 +230,7 @@ #define INVALID_HDR { 0x00, 0x08, 0xFC, 0x02 } -unsigned int is_hdr(unsigned char *buf) +inline unsigned int is_hdr(unsigned char *buf) { /* http://www.mp3-tech.org/programmer/frame_header.html */ if (buf[0] == 255 @@ -715,6 +711,25 @@ } +void copyfile(FILE *outfile, FILE *infile, size_t nbyte) +{ + char *buf = malloc(FS_BLOCK_SIZE); + ssize_t read_sz, write_sz; + + while(nbyte) { + read_sz = fread(buf, 1, nbyte < FS_BLOCK_SIZE ? nbyte : FS_BLOCK_SIZE, infile); + if(read_sz < 0) {perror("copyfile read()"); exitseq(10);} + nbyte -= read_sz; + while(read_sz>0) { + write_sz = fwrite(buf, 1, read_sz, outfile); + if(write_sz < 0) {perror("copyfile write()"); exitseq(10);} + read_sz -= write_sz; + } + } + free(buf); +} + + /* Determination of average VBR bitrate */ real avbitrate(void) { @@ -1752,7 +1767,7 @@ FILE *conffile; char filename1[FN_LEN]; - snprintf(filename1,FN_LEN-1,"%s/%s",getenv("HOME"),".cutmp3rc"); + snprintf(filename1, FN_LEN, "%s/%s", getenv("HOME"), ".cutmp3rc"); /* check for conffile */ if (NULL== (conffile = fopen(filename1,"wb"))) { @@ -1787,7 +1802,6 @@ /* This function plays sound at the current position */ void playsel(long playpos) { - long bytesin; long playsize; int skipframes=(real)howlong*(real)1000/fix_frametime; /* real time */ long pos; @@ -1821,13 +1835,13 @@ if (playpos > filesize) playpos=filesize; if ((fd = mkstemp(playname)) == -1 || (NULL== (outfile = fdopen(fd, "w+b"))) ) { - perror("\ncutmp3: failed writing temporary mp3 in /tmp");exitseq(9); + perror("\ncutmp3: failed writing temporary mp3 in /tmp"); exitseq(9); } else { strncpy(prev_playname, playname, 16); + fseek(mp3file, playpos, SEEK_SET); + copyfile(outfile, mp3file, playsize); + fclose(outfile); } - fseek(mp3file, playpos, SEEK_SET); - for (bytesin=0; bytesin < playsize; bytesin++) fputc(getc(mp3file),outfile); - fclose(outfile); } pos=playpos; @@ -1914,8 +1928,8 @@ unsigned char conf[BUFFER]; char filename1[FN_LEN]; - snprintf(filename1,FN_LEN-1,"%s/%s",getenv("HOME"),".cutmp3rc"); /* get name of conffile */ - if (NULL == (conffile = fopen(filename1,"rb"))) return; /* check for conffile */ + snprintf(filename1, FN_LEN, "%s/%s", getenv("HOME"), ".cutmp3rc"); /* get name of conffile */ + if (NULL == (conffile = fopen(filename1, "rb"))) return; /* check for conffile */ fseek(conffile, 0, SEEK_END); confsize=ftell(conffile); /* size of conffile */ @@ -2015,7 +2029,6 @@ { char *outname=malloc(FN_LEN); unsigned int number=1; - long bytesin=0; long endm, startm; real ends, starts; // int a; @@ -2038,8 +2051,8 @@ /* title known? */ if (!usefilename && !no_tags && !forced_prefix && strlen(title)>0) { - snprintf(outname,FN_LEN-1, "%s - %s.mp3",artist,title); - fp = fopen(outname,"r"); + snprintf(outname, FN_LEN, "%s - %s.mp3", artist, title); + fp = fopen(outname, "r"); if (fp != NULL) /* file exists? */ { while(fp != NULL) /* test if file exists */ @@ -2051,19 +2064,19 @@ printf("\n\nFilename already exists 99 times.\nPlease save with tag (press t) and choose another title. \n"); goto savesel_ret; } - snprintf(outname,FN_LEN-1, "%s - %s_%02u.mp3",artist,title,number); + snprintf(outname, FN_LEN, "%s - %s_%02u.mp3", artist, title, number); fp = fopen(outname,"r"); } number=number-overwrite; /* step one number back in case of overwrite mode */ - if (number==1) snprintf(outname,FN_LEN-1, "%s - %s.mp3",artist,title); /* overwrite file without number */ - else snprintf(outname,FN_LEN-1, "%s - %s_%02u.mp3",artist,title,number); + if (number==1) snprintf(outname, FN_LEN, "%s - %s.mp3", artist, title); /* overwrite file without number */ + else snprintf(outname, FN_LEN, "%s - %s_%02u.mp3", artist, title, number); } } else /* title not known */ { /* outname = prefix number . suffix */ - snprintf(outname,FN_LEN-1, "%s%04u.mp3",prefix,number); + snprintf(outname, FN_LEN, "%s%04u.mp3", prefix, number); if (inpoint > filesize) { @@ -2127,16 +2140,16 @@ number++; fclose(fp); if (number>9999) usage("9999 files written. Please choose another prefix via '-o prefix.'"); - snprintf(outname,FN_LEN-1, "%s%04u.mp3",prefix,number); + snprintf(outname, FN_LEN, "%s%04u.mp3", prefix, number); fp = fopen(outname,"r"); } number=number-overwrite; /* step one number back in case of overwrite mode */ if (number==0) number=1; - snprintf(outname,FN_LEN-1, "%s%04u.mp3",prefix,number); + snprintf(outname, FN_LEN, "%s%04u.mp3", prefix, number); } /* forced output file name used? */ - if (forced_file==1) snprintf (outname, FN_LEN-1,"%s", forcedname); + if (forced_file==1) strncpy (outname, forcedname, FN_LEN-1); /* open outfile */ // if (NULL== (outfile = fopen(outname,"wb"))){perror("\ncutmp3: cannot not write output file! read-only filesystem?");exitseq(10);} @@ -2150,11 +2163,7 @@ /* COPY DATA HERE */ fseek(mp3file, inpoint, SEEK_SET); - for (bytesin=0 ; bytesin < outpoint-inpoint ; bytesin++) - { - if (stdoutwrite==1) putchar(getc(mp3file)); - else fputc(getc(mp3file),outfile); - } + copyfile(outfile, mp3file, outpoint-inpoint); /* copy tag in case of -c switch */ if (copytags==1 && importid3v1(filesize)>0) @@ -2213,39 +2222,42 @@ /* This function saves the selection interactively with ID3 tags */ void savewithtag(void) { - char *tempartist=malloc(TAG_LEN); - char *temptitle=malloc(TAG_LEN); - char *tempalbum=malloc(TAG_LEN); - char *tempyear=malloc(TAG_LEN); - char *tempcomment=malloc(TAG_LEN); - char *title1=malloc(TAG_LEN); /* Title from Tag V1 */ - char *title2=malloc(TAG_LEN); /* Title from Tag V2 */ -// int a; - int i, tagver=0, hasid3=0, hastag=0; + +#define QRY_AND_UPD(tempvar_, len_, querystr_) if(1) { \ + char *tmp = NULL; \ + printf("\n\nPress <ENTER> for '%s'\n", (tempvar_)); \ + tmp = readline(querystr_); \ + if(tmp) { \ + if(tmp[0]) { \ + register unsigned ii; \ + for(ii=0; ii<(len_) && tmp[ii]; ii++) (tempvar_)[ii] = tmp[ii]; \ + /*for(ii=0; ii<(len_) ; ii++) (tempvar_)[ii] = ' ';*/ \ + (tempvar_)[ii] = 0; \ + } \ + free(tmp); \ + } \ + fprintf(outfile, "%-" #len_ "s", (tempvar_)); \ +} + + static char tempartist[31] = {0}; + static char temptitle[31] = {0}; + static char tempalbum[31] = {0}; + static char tempyear[5] = {0}; + static char tempcomment[31] = {0}; + int i = 1, tags = 0, tagver = 0; //, hasid3=0, hastag=0; unsigned int number=1; char outname[FN_LEN]="cutmp3.tmp"; - char outname2[FN_LEN]="\0"; - char *newname=outname2; - char *tmp; + char *newname; FILE *fp; FILE *outfile; long oldinpoint=inpoint; long oldoutpoint=outpoint; - long bytesin; - long length; - - temptitle[0]='\0'; - tempartist[0]='\0'; - tempalbum[0]='\0'; - tempyear[0]='\0'; - tempcomment[0]='\0'; - title1[0]='\0'; - title2[0]='\0'; + long length = 0; if (inpoint > filesize) { printf(" ERROR: startpoint (%u:%05.2f) must be before end of file (%u:%05.2f)! \n",pos2mins(inpoint),pos2secs(inpoint),pos2mins(filesize),pos2secs(filesize)); - goto savewithtag_ret; + return; } if (inpoint < audiobegin) { @@ -2260,95 +2272,71 @@ if (outpoint <= inpoint) { printf(" ERROR: endpoint (%u:%05.2f) must be after startpoint (%u:%05.2f)! \n",pos2mins(outpoint),pos2secs(outpoint),pos2mins(inpoint),pos2secs(inpoint)); - goto savewithtag_ret; + return; } + newname = (char*)malloc(FN_LEN); /*********************************/ /* Choose ID3 V2 or V1 or custom */ /*********************************/ - hasid3=hastag=0; -// inpoint=rewind3v2(inpoint); not always useful! - - zaptitle(); importid3v1(outpoint); - if (strlen(title)>0) {hastag=1; snprintf(title1,31,"%s",title);} /* check if selection has tag v1 */ - - zaptitle(); length=importid3v2(inpoint); - if (strlen(title)>0) {hasid3=1; snprintf(title2,31,"%s",title);} /* check if selection has tag v2 */ - if (hastag+hasid3==2) /* has both tags in selection */ - { - printf("\n\nImported titles from selection:"); - printf("\nPress 1 for this title: %s",title1); - printf("\nPress 2 for this title: %s",title2); - printf("\nOr press any other key for a custom tag "); - tagver=getchar(); - if (tagver=='1') - { + /* check if selection has tag v1 */ + if(outpoint < filesize) { + if (rewind3v1(outpoint) != outpoint) { importid3v1(outpoint); + printf("\n\nImported from selection:"); + printf("\n Press 1 to copy ID3v1 with this title: %s", title); + tags |= 0x1; + i++; } - else if (tagver=='2') - { - length=importid3v2(inpoint); + } + + /* check if selection has tag v2 */ + if(inpoint) { + if (skipid3v2(inpoint) != inpoint) { + length = importid3v2(inpoint); + if(!tags) printf("\n\nImported from selection:"); + printf("\n Press %d to copy ID3v2 with this title: %s", i, title); + tags |= 0x2; + i++; } } - else if (hasid3>hastag) /* only V2 */ - { - length=importid3v2(inpoint); - printf("\n\nImported title from %s:",filename); - printf("\nPress 2 for this title: %s",title); - printf("\nOr press any other key for a custom tag "); - tagver=getchar(); - if (tagver!='2') tagver='3'; /* just in case someone pressed 1 */ - } - else if (hastag>hasid3) /* only V1 */ - { - importid3v1(outpoint); - printf("\n\nImported title from %s:",filename); - printf("\nPress 1 for this title: %s",title); - printf("\nOr press any other key for a custom tag "); - tagver=getchar(); - if (tagver!='1') tagver='3'; /* just in case someone pressed 2 */ - } - - else if (hastag+hasid3==0) /* no tag at all, get them from whole file */ - { - hasid3=hastag=0; - zaptitle(); importid3v1(filesize); if (strlen(title)>0) {hastag=1; snprintf(title1,31,"%s",title);} - zaptitle(); length=importid3v2(0); if (strlen(title)>0) {hasid3=1; snprintf(title2,31,"%s",title);} - if (hastag+hasid3==2) /* whole file has both tags */ - { - printf("\n\nImported titles from %s:",filename); - printf("\nPress 1 for this title: %s",title1); - printf("\nPress 2 for this title: %s",title2); - printf("\nOr press any other key for a custom tag "); - tagver=getchar(); - if (tagver=='1') importid3v1(filesize); - else if (tagver=='2') length=importid3v2(0); - } - else if (hasid3>hastag) /* has V2 info from whole file */ - { - length=importid3v2(0); - printf("\n\nImported title from %s:",filename); - printf("\nPress 2 for this title: %s",title); - printf("\nOr press any other key for a custom tag "); - tagver=getchar(); - if (tagver!='2') tagver='3'; /* just in case someone pressed 1 */ - } - else if (hastag>hasid3) /* has V1 info from whole file */ - { - importid3v1(filesize); - printf("\n\nImported title from %s:",filename); - printf("\nPress 1 for this title: %s",title); - printf("\nOr press any other key for a custom tag "); - tagver=getchar(); - if (tagver!='1') tagver='3'; /* just in case someone pressed 2 */ + + /* check if file has tag v1 */ + if (rewind3v1(filesize) != filesize) { + importid3v1(filesize); + if(!tags) printf("\n"); + printf("\nImported from file %s:", filename); + printf("\n Press %d to copy ID3v1 with this title: %s", i, title); + tags |= 0x4; + i++; + } + + /* check if file has tag v2 */ + if (skipid3v2(0) != 0) { + length = importid3v2(0); + if(!tags) printf("\n"); + if(!(tags & 0x04)) printf("\nImported from file %s:", filename); + printf("\n Press %d to copy ID3v2 with this title: %s", i, title); + tags |= 0x8; + i++; + } + + if (tags) { + printf("\n Or press any other key for a custom tag "); + tagver = getchar(); + if(tagver < '1' || tagver >= i + '0') { + tagver = 0; + } else { + tagver -= '0'; + for (i = 0; i < 3; i++) if(!(tags & (1<<i)) && i < tagver) tagver++; } } /* forced output file name used? */ if (forced_file==1) { - snprintf (outname, FN_LEN-1,"%s", forcedname); + strncpy (outname, forcedname, FN_LEN-1); } /*******************/ @@ -2358,102 +2346,40 @@ printf("\nwriting audio data..."); - if (tagver=='1') /* if chosen to copy ID3 V1 */ - { - inpoint=skipid3v2(inpoint); /* remove possible id3 at beginning */ - fseek(mp3file, inpoint, SEEK_SET); - /* copy audio data */ - for (bytesin=0; bytesin < outpoint-inpoint; bytesin++) fputc(getc(mp3file),outfile); - /* copy id3 v1 tag from end of file if not from selection */ - if (importid3v1(filesize)>0 && importid3v1(outpoint)==0) - { - for (i=0;i<128;i++) fputc(id3v1[i],outfile); - } - printf(" finished.\n"); + if (tagver == 2 || tagver == 4) { /* copy ID3v2 */ + if(tagver == 2 && (tags & 0x8)) length = importid3v2(inpoint); /* Not the last tag we read */ + fwrite(id3v2, 1, length, outfile); } - else if (tagver=='2') /* if chosen to copy ID3 V2 */ - { - /* copy id3 v2 tag */ - DBGPRINT(5, " ID3V2 length=%ld ",length); - if (length>0) for (i=0;i<length;i++) fputc(id3v2[i],outfile); - outpoint=rewind3v1(outpoint); /* remove possible V1 tag at end */ - inpoint=skipid3v2(inpoint); /* remove possible id3 at beginning */ + if(tagver == 1 && (tags & 0xE)) importid3v1(outpoint); /* Not the last tag we read */ + if(tagver == 3 && (tags & 0x8)) importid3v1(filesize); - /* copy audio data */ - for (bytesin=0; bytesin < outpoint-inpoint; bytesin++) fputc(getc(mp3file),outfile); - printf(" finished.\n"); - } - else /* custom tag */ - { - inpoint=skipid3v2(inpoint); /* remove possible id3 at beginning */ - outpoint=rewind3v1(outpoint); /* remove possible tag at end */ + inpoint = skipid3v2(inpoint); /* remove possible id3 tags */ + outpoint = rewind3v1(outpoint); - fseek(mp3file, inpoint, SEEK_SET); + fseek(mp3file, inpoint, SEEK_SET); + copyfile(outfile, mp3file, outpoint-inpoint); - /* copy audio data */ - for (bytesin=0; bytesin < outpoint-inpoint; bytesin++) fputc(getc(mp3file),outfile); + printf(" finished."); - printf(" finished."); + if (tagver == 1 || tagver == 3) { + /* copy ID3v1 */ + fwrite(id3v1, 1, 128, outfile); - /* write tag here */ + } else if (tagver == 0) { + /* custom tag */ fputs("TAG",outfile); - printf("\n\nPress <ENTER> for '%s'",temptitle); - tmp=readline("\nTitle? "); - tmp[30]='\0'; - if (strlen(tmp)>0) {snprintf(temptitle,31,"%s",tmp);} - else snprintf(tmp,31,"%s",temptitle); /* recycle old title name when hitting ENTER */ - tmp[30]='\0'; - fprintf(outfile,"%s",tmp); - for (i=strlen(tmp) ; i<30 ; i++) fputc(32,outfile); - free(tmp); - - printf("\nPress <ENTER> for '%s'",tempartist); - tmp=readline("\nArtist? "); - tmp[30]='\0'; - if (strlen(tmp)>0) {snprintf(tempartist,31,"%s",tmp);} - else snprintf(tmp,31,"%s",tempartist); /* recycle old artist name when hitting ENTER */ - tmp[30]='\0'; - fprintf(outfile,"%s",tmp); - for (i=strlen(tmp) ; i<30 ; i++) fputc(32,outfile); - free(tmp); - - printf("\nPress <ENTER> for '%s'",tempalbum); - tmp=readline("\nAlbum? "); - tmp[30]='\0'; - if (strlen(tmp)>0) {snprintf(tempalbum,31,"%s",tmp);} - else snprintf(tmp,31,"%s",tempalbum); /* recycle old album name when hitting ENTER */ - tmp[30]='\0'; - fprintf(outfile,"%s",tmp); - for (i=strlen(tmp) ; i<30 ; i++) fputc(32,outfile); - free(tmp); - - printf("\nPress <ENTER> for '%s'",tempyear); - tmp=readline("\nYear? "); - tmp[4]='\0'; - if (strlen(tmp)>0) {snprintf(tempyear,5,"%s",tmp);} - else snprintf(tmp,5,"%s",tempyear); /* recycle old year when hitting ENTER */ - tmp[4]='\0'; - fprintf(outfile,"%s",tmp); - for (i=strlen(tmp) ; i<4 ; i++) fputc(32,outfile); - free(tmp); - - printf("\nPress <ENTER> for '%s'",tempcomment); - tmp=readline("\nComment? "); - tmp[30]='\0'; - if (strlen(tmp)>0) {snprintf(tempcomment,31,"%s",tmp);} - else snprintf(tmp,31,"%s",tempcomment); /* recycle old comment when hitting ENTER */ - tmp[30]='\0'; - fprintf(outfile,"%s",tmp); - for (i=strlen(tmp) ; i<30 ; i++) fputc(32,outfile); - free(tmp); + QRY_AND_UPD(temptitle, 30, "Title? ") + QRY_AND_UPD(tempartist, 30, "Artist? ") + QRY_AND_UPD(tempalbum, 30, "Album? ") + QRY_AND_UPD(tempyear, 4, "Year? ") + QRY_AND_UPD(tempcomment, 30, "Comment? ") fputc(genre,outfile); - genre=-1; - snprintf(title,31,"%s",temptitle); - snprintf(artist,31,"%s",tempartist); + strncpy(title, temptitle, 31); + strncpy(artist, tempartist, 31); } fclose(outfile); @@ -2465,8 +2391,8 @@ /********************/ /* file rename part */ /********************/ - snprintf(newname,FN_LEN-1, "%s - %s.mp3",artist,title); - fp = fopen(newname,"r"); + snprintf(newname, FN_LEN, "%s - %s.mp3", artist, title); + fp = fopen(newname, "r"); if (fp != NULL) /* file exists? */ { while(fp != NULL) /* test if file exists */ @@ -2476,34 +2402,26 @@ if (number>99) { printf("\n File NOT written. Please choose another title. \n"); - goto savewithtag_ret; + return; } - snprintf(newname,FN_LEN-1, "%s - %s_%02u.mp3",artist,title,number); - fp = fopen(newname,"r"); + snprintf(newname, FN_LEN, "%s - %s_%02u.mp3", artist, title, number); + fp = fopen(newname, "r"); } number=number-overwrite; /* step one number back in case of overwrite mode */ - if (number==1) snprintf(newname,FN_LEN-1, "%s - %s.mp3",artist,title); /* overwrite file without number */ - else snprintf(newname,FN_LEN-1, "%s - %s_%02u.mp3",artist,title,number); + if (number==1) snprintf(newname, FN_LEN, "%s - %s.mp3", artist, title); /* overwrite file without number */ + else snprintf(newname, FN_LEN, "%s - %s_%02u.mp3", artist, title, number); } /* forced output file name used? Then show correct file name in summary. */ - if (forced_file==1) snprintf (newname, FN_LEN-1,"%s", forcedname); + if (forced_file==1) strncpy (newname, forcedname, FN_LEN-1); /* rename file only if not forced name: ** ** Only after writing ID3 tag we know the name, so it must be renamed after writing. */ else rename(outname, newname); - if (tagver=='2') printf("\n saved %u:%02.0f - %u:%02.0f with ID3 V2 tag to '%s'. \n",pos2mins(inpoint),pos2secs(inpoint),pos2mins(outpoint),pos2secs(outpoint),newname); - else printf("\n saved %u:%02.0f - %u:%02.0f with ID3 V1 tag to '%s'. \n",pos2mins(inpoint),pos2secs(inpoint),pos2mins(outpoint),pos2secs(outpoint),newname); + printf("\n saved %u:%02.0f - %u:%02.0f with ID3v%c tag to '%s'. \n", pos2mins(inpoint),pos2secs(inpoint), pos2mins(outpoint),pos2secs(outpoint), (tagver==2||tagver==4)?'2':'1', newname); overwrite=0; -savewithtag_ret: - free(tempartist); - free(temptitle); - free(tempalbum); - free(tempyear); - free(tempcomment); - free(title1); - free(title2); + free(newname); return; } @@ -2519,21 +2437,21 @@ } /* term_restore */ /* Clean up terminal; called on exit */ -void term_exit () { +void term_exit (int) { term_restore(); printf("\n\nbugreports to [email protected]\n\n"); exitseq(0); } /* term_exit */ /* Will be called when ctrl-z is pressed, this correctly handles the terminal */ -void term_ctrlz () { +void term_ctrlz (int) { signal(SIGTSTP, term_ctrlz); term_restore(); kill(getpid(), SIGSTOP); } /* term_ctrlz */ /* Will be called when application is continued after having been stopped */ -void term_cont () { +void term_cont (int) { signal(SIGCONT, term_cont); tcsetattr(0, TCSANOW, ¤t); } /* term_cont */ @@ -2673,10 +2591,7 @@ { perror("\ncutmp3: failed writing temporary timetable in /tmp");exitseq(11); } - fprintf(tblfile, "%s", userin); - fprintf(tblfile, " "); - fprintf(tblfile, "%s", userout); - fprintf(tblfile, "\n"); + fprintf(tblfile, "%s %s\n", userin, userout); fclose(tblfile); a_b_used=1; return; @@ -2891,7 +2806,7 @@ int b,c,d,char1,showinfo=0,rawmode=0,fix_channels=0; unsigned long pos, startpos; real ft_factor = 2; - char *tablename = malloc(FN_LEN); + char *tablename = NULL; char *prefix = malloc(FN_LEN); void (*play)(long playpos) = playsel; prefix[0] = 0; @@ -2942,12 +2857,11 @@ // exactmode=1; break; case 'f': - if (NULL == (timefile = fopen(optarg,"rb") ) ) - { + if (NULL == (timefile = fopen(optarg,"rb") ) ) { perror(optarg); exitseq(3); } - else { tablename=optarg; hastable=1; } + else tablename = optarg; break; case 'h': usage(""); @@ -2977,7 +2891,7 @@ rawmode=1; break; case 'o': - if (optarg!=0) snprintf(prefix,FN_LEN-1,"%s",optarg); + if (optarg!=0) strncpy(prefix, optarg, FN_LEN-1); // else usage("Error: missing outputprefix"); forced_prefix=1; break; @@ -3035,6 +2949,7 @@ else audiobegin=inpoint; } if(audiobegin) audiobegin=nextframe(audiobegin-1); /* in case there is invalid data after an ID3 V2 tag */ + audiobegin=nextframe(audiobegin); // Skip first frame containing original file length startpos=inpoint=audiobegin; @@ -3098,7 +3013,7 @@ } /* timetable used? */ - if (hastable==1) + if (tablename) { nonint=1; cutfromtable(tablename,prefix);
