#663336 shnsplit: can't be forced to split with no split points given

Package:
shntool
Source:
shntool
Description:
multi-purpose tool for manipulating and analyzing WAV files
Submitter:
Aleksey Sergushichev
Date:
2024-08-21 14:57:04 UTC
Severity:
wishlist
#663336#5
Date:
2012-03-10 13:12:36 UTC
From:
To:
I want to be able to use shntool split even if there is no split points
(i.e. there is only one track in cue sheet) but I can't. It's not so
pointless as it may seem to be - this may be useful when running
cue2tracks script for multiple albums and some of them may contain only
one track.

The patch introduces flag -F to force splitting:
--- src/mode_split.c	2008-02-19 02:25:14.000000000 +0300
+++ src/mode_split.c	2012-03-10 16:58:44.000000000 +0400
@@ -57,6 +57,7 @@
 static char *leadout = NULL;
 static char *extract_tracks = NULL;
 static char *manipulate_chars = NULL;
+static int force_split = 0;

 typedef struct _cue_info {
   /* global */
@@ -101,6 +102,7 @@
   st_info("          (%%p = performer, %%a = album, %%t = track title, %%n = track number)\n");
   st_info("  -u len  postfix each track with len amount of lead-out from next track (*)\n");
   st_info("  -x list only extract tracks in list (comma-separated, may contain ranges)\n");
+  st_info("  -F force split even if no split points are given (outputs one file)\n");
   st_info("\n");
   st_info("          (*) len must be in bytes, m:ss, m:ss.ff or m:ss.nnn format\n");
   st_info("\n");
@@ -116,7 +118,7 @@
   st_ops.output_prefix = SPLIT_PREFIX;
   cueinfo.format = NULL;

-  while ((c = st_getopt(argc,argv,"c:e:f:l:n:m:t:u:x:")) != -1) {
+  while ((c = st_getopt(argc,argv,"c:e:f:l:n:m:t:u:x:F")) != -1) {
     switch (c) {
       case 'c':
         if (NULL == optarg)
@@ -168,6 +170,9 @@
           st_error("missing track numbers to extract");
         extract_tracks = optarg;
         break;
+      case 'F':
+        force_split = 1;
+        break;
     }
   }

@@ -736,8 +741,14 @@
   if (split_point_file)
     fclose(fd);

-  if (1 == numfiles)
-    st_error("no split points given -- nothing to do");
+  if (1 == numfiles) {
+    if (force_split) {
+      st_warning("no split points given");
+    }
+    else {
+      st_error("no split points given -- nothing to do");
+    }
+  }

   if (SPLIT_INPUT_CUE == input_type && cueinfo.format) {
     if (cueinfo.trackno < numfiles)
@@ -860,16 +871,16 @@
   else
     read_split_points_file(info);

-  if (files[numfiles-2]->beginning_byte > info->data_size)
+  if (numfiles > 1 && files[numfiles-2]->beginning_byte > info->data_size)
     st_error("split points go beyond input file's data size");

-  if (files[numfiles-2]->beginning_byte == info->data_size) {
+  if (numfiles > 1 && files[numfiles-2]->beginning_byte == info->data_size) {
     st_free(files[numfiles-1]);
     numfiles--;
   }
   else {
     files[numfiles-1]->beginning_byte = info->data_size;
-    files[numfiles-1]->data_size = info->data_size - files[numfiles-2]->beginning_byte;
+    files[numfiles-1]->data_size = info->data_size - (numfiles > 1 ? files[numfiles-2]->beginning_byte : 0);

     adjust_splitfile(numfiles-1);
   }

#663336#12
Date:
2024-08-21 07:20:14 UTC
From:
To:
Hi Aleksey,

since shntool came up in the Bug of the Day[1] I tried to apply all
patches provided and close according bugs.  Unfortunately your patch
does not apply to the latest upstream version any more.  If you are
continuously interested in this feature it would be great if you would
provide a MR to the repository on Salsa[2].  Otherwise please tag the
bug `wontfix`.

Thanks a lot for your patch anyway
   Andreas.


[1] https://salsa.debian.org/tille/tiny_qa_tools/-/wikis/Tiny-QA-tasks
[2] https://salsa.debian.org/debian/shntool

#663336#19
Date:
2024-08-21 14:53:35 UTC
From:
To:
Hi Andreas,

I haven't been using this tool, I guess, for at least 10 years :) I'm not
that interested in this fix anymore, and can't confirm if the bug is still
present.

Also, I don't know how to the bug with `wontfix`. If you could do it
instead, that would be great.

Thanks,
Alexey