[xiph-cvs] cvs commit: ogg-tools/oggsplit ChangeLog oggsplit.1 oggsplit.c output.c output.h

Timothy Terriberry tterribe at xiph.org
Mon Aug 11 11:11:35 PDT 2003



tterribe    03/08/11 14:11:35

  Modified:    oggsplit ChangeLog oggsplit.1 oggsplit.c output.c output.h
  Log:
  Applied the latest patch from Philip.
  
     * moved all output filename calculation to one place and tidied it up.
     * changed how the output filenames are calculated. Now any suffix of
       length 4 or less is stripped out and used (might be good for .spx).
     * output files are now placed in CWD by default, instead of the same dir
  
  Also fixed a grammatical error in the man page.

Revision  Changes    Path
1.3       +3 -0      ogg-tools/oggsplit/ChangeLog

Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/ChangeLog,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ChangeLog	8 Aug 2003 17:50:55 -0000	1.2
+++ ChangeLog	11 Aug 2003 18:11:35 -0000	1.3
@@ -1,4 +1,7 @@
+-*- text -*-
+
 oggsplit (0.1.1)
+  * moved all output filename calculation to one place and tidied it up.
   * changed how the output filenames are calculated. Now any suffix of
     length 4 or less is stripped out and used (might be good for .spx).
   * output files are now placed in CWD by default, instead of the same dir

<p><p>1.3       +1 -1      ogg-tools/oggsplit/oggsplit.1

Index: oggsplit.1
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/oggsplit.1,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- oggsplit.1	8 Aug 2003 17:50:55 -0000	1.2
+++ oggsplit.1	11 Aug 2003 18:11:35 -0000	1.3
@@ -32,7 +32,7 @@
 \fBcat(1)\fP or a similar tool.
 .PP
 By default \fBoggsplit\fP extracts all streams, chained as well as grouped.
-Since \fBoggsplit\fP does not care about about stream formats and thus works
+Since \fBoggsplit\fP does not care about about stream formats, it works
 with any type of stream. For the same reason, it cannot split the file at an
 arbitrary point. For such functionality, use a specialized tool like
 \fBvcut(1)\fP.

<p><p>1.4       +3 -25     ogg-tools/oggsplit/oggsplit.c

Index: oggsplit.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/oggsplit.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- oggsplit.c	8 Aug 2003 17:50:55 -0000	1.3
+++ oggsplit.c	11 Aug 2003 18:11:35 -0000	1.4
@@ -80,9 +80,6 @@
 
 static int process_file(const char *pathname)
 {
-  int i;
-  char *filename;
-
   FILE *infile;
 
   output_t *junk=NULL;
@@ -107,25 +104,8 @@
     return 0;
   }
 
-  /* take out the path section from pathname */
-  for(i=strlen(pathname)-1; i>=0; i--){
-    if(pathname[i]=='/'){
-      i++;
-      break;
-    }
-  }
-
-  if(outdir!=NULL){
-    filename=xmalloc(strlen(outdir)+strlen(&pathname[i])+2);
-    strcpy(filename, outdir);
-    filename[strlen(outdir)]='/';
-    strcpy(&filename[strlen(outdir)+1], &pathname[i]);
-  }else{
-    filename=xstrdup(&pathname[i]);    
-  }
-
   stream_ctrl_init(&sc);
-  output_ctrl_init(&oc, filename);
+  output_ctrl_init(&oc, pathname);
 
   ogg_sync_init(&oy);
 
@@ -187,7 +167,7 @@
                     "  in `%s'.\n"
                     "  All data from this stream and any further such streams will be written\n"
                     "  to `%s'.\n\n%s",
-		    ogg_page_serialno(&og), filename,
+		    ogg_page_serialno(&og), pathname,
                     junk->filename, broken_ogg);
           }
           output_page_write(junk, &og);
@@ -229,9 +209,7 @@
             "  of `%s'.\n"
             "  The logical streams may have been trunctated in an incomplete\n"
             "  transfer or an aborted encoding process.\n\n%s",
-	    sc.streams_used, filename, broken_ogg);
-
-  free(filename);
+	    sc.streams_used, pathname, broken_ogg);
 
   output_ctrl_free(&oc);
   stream_ctrl_free(&sc);

<p><p>1.4       +46 -11    ogg-tools/oggsplit/output.c

Index: output.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/output.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- output.c	8 Aug 2003 17:50:55 -0000	1.3
+++ output.c	11 Aug 2003 18:11:35 -0000	1.4
@@ -16,9 +16,15 @@
 #include "output.h"
 #include "common.h"
 
-int output_ctrl_init(output_ctrl_t *oc, char *filename)
+/* outdir given on command line */
+extern char *outdir;
+
+int output_ctrl_init(output_ctrl_t *oc, char *pathname)
 {
-  int fnlen, i;
+  int pathname_len, i;
+  /* indexes in pathname where basname begs ends ends.*/
+  int bnb=-1, bne=-1;
+  int basename_len;
 
   /* Begin with 8 (output_t *):s
    * We are using an array of (output_t *) instead of just output_t since the
@@ -34,18 +40,47 @@
   oc->basename=NULL;
   oc->suffix=NULL;
 
-  fnlen=strlen(filename);
-  for(i=fnlen-1; i>fnlen-6; i--){
-    if(filename[i]=='.'){
-      oc->basename=xmalloc(i+1);
-      strncpy(oc->basename, filename, i+1);
-      oc->basename[i]='\0';
-      oc->suffix=xstrdup(&filename[i]);
+  pathname_len=strlen(pathname);
+
+  /* calc bnb */
+  for(i=pathname_len; i>0; i--){
+    if(pathname[i-1]=='/'){
+      bnb=i;
+      break;
+    }
+  }
+  if(bnb==-1)bnb=0;
+
+  /* calc bne */
+  for(i=pathname_len-1; i>pathname_len-6 && i>bnb; i--){
+    if(pathname[i]=='.'){
+      bne=i;
+      break;
     }
   }
 
-  if(oc->basename==NULL)oc->basename=xstrdup(filename);
-  if(oc->suffix==NULL)oc->suffix=xstrdup(".ogg");
+  if(bne==-1)
+    basename_len=pathname_len-bnb;
+  else
+    basename_len=bne-bnb;
+
+  if(outdir!=NULL){
+    int outdirlen=strlen(outdir);
+    oc->basename=xmalloc(outdirlen+basename_len+2);
+    strcpy(oc->basename, outdir);
+    oc->basename[outdirlen]='/';
+    strncpy(&oc->basename[outdirlen+1], &pathname[bnb], basename_len);
+    oc->basename[outdirlen+basename_len+2]='\0';
+  }else{
+    oc->basename=xmalloc(basename_len+1);
+    strncpy(oc->basename, &pathname[bnb], basename_len);
+    oc->basename[basename_len]='\0';
+  }
+
+  if(bne==-1)
+    oc->suffix=xstrdup(".ogg");
+  else
+    oc->suffix=xstrdup(&pathname[bne]);
 
   return 1;
 }

<p><p>1.3       +1 -1      ogg-tools/oggsplit/output.h

Index: output.h
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/output.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- output.h	8 Aug 2003 17:50:55 -0000	1.2
+++ output.h	11 Aug 2003 18:11:35 -0000	1.3
@@ -34,7 +34,7 @@
 } output_ctrl_t;
 
 
-int       output_ctrl_init(output_ctrl_t *oc, char *filename);
+int       output_ctrl_init(output_ctrl_t *oc, char *pathname);
 int       output_ctrl_free(output_ctrl_t *oc);
 output_t *output_ctrl_output_new(output_ctrl_t *oc, int chain_c, int group_c);
 int       output_ctrl_output_free(output_ctrl_t *oc, int id);

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list