home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 400-499 / ff473.lzh / CNewsSrc / cnews_src.lzh / man / split.man < prev    next >
Text File  |  1991-01-05  |  4KB  |  133 lines

  1.  
  2.  
  3.  
  4. SPLIT(3)               C LIBRARY FUNCTIONS               SPLIT(3)
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      split - split string into fields
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      iiiinnnntttt sssspppplllliiiitttt((((ssssttttrrrriiiinnnngggg,,,, ffffiiiieeeellllddddssss,,,, nnnnffffiiiieeeellllddddssss,,,, sssseeeeppppaaaarrrraaaattttoooorrrrssss))))
  13.      cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg;;;;
  14.      cccchhhhaaaarrrr ****ffffiiiieeeellllddddssss[[[[]]]];;;;
  15.      iiiinnnntttt nnnnffffiiiieeeellllddddssss;;;;
  16.      cccchhhhaaaarrrr ****sssseeeeppppaaaarrrraaaattttoooorrrrssss;;;;
  17.  
  18. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  19.      _S_p_l_i_t splits the _s_t_r_i_n_g into _f_i_e_l_d_s according to the _s_e_p_a_r_a_-
  20.      _t_o_r_s,  much  in  the  manner  of  _a_w_k(1)'s field facilities.
  21.      _S_t_r_i_n_g has NUL s written into it to do  the  splitting,  and
  22.      pointers to the resulting strings are placed into the _f_i_e_l_d_s
  23.      array, up to the number specified by _n_f_i_e_l_d_s.  If the number
  24.      of fields found exceeds _n_f_i_e_l_d_s, the writing of NUL s stops,
  25.      so that the last entry in _f_i_e_l_d_s points to the remainder  of
  26.      the string.
  27.  
  28.      The returned value  is  the  number  of  fields  present  in
  29.      _s_t_r_i_n_g,  which may exceed _n_f_i_e_l_d_s.  If the returned value is
  30.      less than _n_f_i_e_l_d_s, the contents of the remaining entries  in
  31.      _f_i_e_l_d_s  (up  to  the  limit  set  by _n_f_i_e_l_d_s) are undefined.
  32.      (Note, in particular, that _s_p_l_i_t does not terminate the list
  33.      of fields with a NULL pointer.)
  34.  
  35.      If _s_e_p_a_r_a_t_o_r_s is a string of length 1, that character is the
  36.      separator:   each  occurrence  of  it  separates the current
  37.      field from a new field, which may be of length 0 if  another
  38.      separator follows immediately.
  39.  
  40.      If _s_e_p_a_r_a_t_o_r_s is a string of length >1, all  the  characters
  41.      in  it  are separators:  any sequence of characters composed
  42.      entirely of separators separates the current  field  from  a
  43.      new  field, which is of length 0 only if it is at the begin-
  44.      ning or end of the _s_t_r_i_n_g.  Characters may be duplicated  in
  45.      _s_e_p_a_r_a_t_o_r_s; in particular, a _s_e_p_a_r_a_t_o_r_s string consisting of
  46.      the same character twice gives fields separated by sequences
  47.      of that character.
  48.  
  49.      As a special case, if _s_e_p_a_r_a_t_o_r_s is a string  of  length  0,
  50.      sequences  of white-space characters (here defined as blanks
  51.      and tabs) are the separators, and sequences of separators at
  52.      the beginning or end of the _s_t_r_i_n_g are ignored, so there can
  53.      be no fields of length 0.
  54.  
  55.      In all cases, an empty _s_t_r_i_n_g (or, in the case of a  _s_e_p_a_r_a_-
  56.      _t_o_r_s  of  length 0, a _s_t_r_i_n_g consisting only of white space)
  57.      has 0 fields.
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Sun Microsystems     Last change: 8 Dec 1990                    1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SPLIT(3)               C LIBRARY FUNCTIONS               SPLIT(3)
  71.  
  72.  
  73.  
  74. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  75.      awk(1), regexp(3), strtok(3)
  76.  
  77. HHHHIIIISSSSTTTTOOOORRRRYYYY
  78.      Written at University of Toronto by Henry Spencer, with con-
  79.      tributions from Geoff Collyer and Mark Moraes.
  80.  
  81. BBBBUUUUGGGGSSSS
  82.      Too many different decisions are  bundled  into  the  single
  83.      _s_e_p_a_r_a_t_o_r_s  argument.   Arguably  it  should  be  a  regular
  84.      expression instead.
  85.  
  86.      Specifying several characters as _s_e_p_a_r_a_t_o_r_s is rather  inef-
  87.      ficient; if speed is a priority in such a case, it is better
  88.      to custom-build code that knows about the particular separa-
  89.      tors desired.
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sun Microsystems     Last change: 8 Dec 1990                    2
  130.  
  131.  
  132.  
  133.