[BusyBox 0000984]: Split missing from busybox

bugs at busybox.net bugs at busybox.net
Sat Mar 24 15:17:58 UTC 2007


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=984 
====================================================================== 
Reported By:                Sadara
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   984
Category:                   New Features
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             08-05-2006 22:53 PDT
Last Modified:              03-24-2007 08:17 PDT
====================================================================== 
Summary:                    Split missing from busybox
Description: 
Coreutils split is currently not included in busybox.
Would it be possible to provide a cutdown applet with the most commonly
used features?
====================================================================== 

---------------------------------------------------------------------- 
 bernhardf - 08-17-06 02:28  
---------------------------------------------------------------------- 
It certainly can be added.
What are the most commonly used features of split? 

---------------------------------------------------------------------- 
 Sadara - 08-28-06 22:21  
---------------------------------------------------------------------- 
IMO:
 -b/--bytes=SIZE
 -l/--lines=LINES
Would also be nice if SIZE could have a multiplier suffix(b,k,m,g) as
several scripts floating around use it, but needed scripts could be
modified. 

---------------------------------------------------------------------- 
 sega32x - 02-07-07 14:26  
---------------------------------------------------------------------- 
Just curious, has there been any progress with adding this in the past few
months? Havent seen it on SVN, and this would make busybox complete
(atleast for me!) 

---------------------------------------------------------------------- 
 jkolb - 03-23-07 11:06  
---------------------------------------------------------------------- 
Patch against 1.4.1 implementing -a, -b, -d, and -l options.  Fancy
configuration supports k, b, m suffixes on sizes.  It's not too pretty,
but it Works For Me(tm). 

---------------------------------------------------------------------- 
 vda - 03-24-07 08:17  
---------------------------------------------------------------------- 
Code review:

FILE *open_next_file(char **filename)
{
...
    return fopen(*filename, "wb");
}
void bytes_split(FILE *infile)
{
...
               do {
                       if (bytes_remaining <= 0) {
                               if (outfile) fclose(outfile);
                               outfile = open_next_file(&filename);
                               bytes_remaining = split_size;
                       }
                       to_write = ...
                       bytes_written = fwrite(src, 1, to_write, outfile);

What will happen if fopen() failed (returned NULL)?

       opt_complementary = "b--l:l--b";
       opt = getopt32(argc, argv, "a:b:dl:", &new_suffix_size,
                       &new_split_size, &new_split_size);
       if(opt & BB_GETOPT_ERROR)
               bb_show_usage();

Just add "?:" to opt_complementary and you can get rid of BB_GETOPT_ERROR
check then.

Also:

* outfile is only used for fwrite -> maybe use 'simple' I/O
(non-stdio-based), open(), not fopen()?
* use xatoi instead of atoi
* many variables and functions can be made static
* space/tab indentation is mixed. Use tabs only 
* bb_error_msg("should start with small letter") 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
08-05-06 22:53  Sadara         New Issue                                    
08-05-06 22:53  Sadara         Status                   new => assigned     
08-05-06 22:53  Sadara         Assigned To               => BusyBox         
08-17-06 02:28  bernhardf      Note Added: 0001568                          
08-28-06 22:21  Sadara         Note Added: 0001598                          
02-07-07 14:26  sega32x        Note Added: 0002137                          
03-23-07 11:05  jkolb          File Added: busybox-1.4.1-split.patch            
       
03-23-07 11:06  jkolb          Note Added: 0002273                          
03-24-07 08:17  vda            Note Added: 0002274                          
======================================================================




More information about the busybox-cvs mailing list