string splitting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Pfaff

    #16
    Re: string splitting

    Daniel Rudy <spamthis@spamt his.netwrites:
    Now I'm not too up on what functions comprise the standard C library and
    what doesn't, reading THIS man page you can see the cause of confusion:
    >
    STRTOK(3) FreeBSD Library Functions Manual
    >
    NAME
    strtok, strtok_r -- string tokens
    >
    LIBRARY
    Standard C Library (libc, -lc)
    File a bug against the FreeBSD manpage then. It's wrong.
    --
    "It wouldn't be a new C standard if it didn't give a
    new meaning to the word `static'."
    --Peter Seebach on C99

    Comment

    • CBFalconer

      #17
      Re: string splitting

      Richard Heathfield wrote:
      Daniel Rudy said:
      >
      .... snip ...
      >
      STRSEP(3) FreeBSD Library Functions Manual
      >
      What makes you think FreeBSD get to decide what is in the standard
      C library?
      >
      $ grep -i strsep c89.txt
      $
      and similarly for N869.txt (C99)

      --
      Chuck F (cbfalconer at maineline dot net)
      Available for consulting/temporary embedded and systems.
      <http://cbfalconer.home .att.net>


      Comment

      • CBFalconer

        #18
        Re: string splitting

        Daniel Rudy wrote:
        >
        .... snip ...
        >
        I didn't say that FreeBSD should decide what goes into the C library.
        What I was getting at is the fact that since the function has been
        around along time, and that it's superior to strtok (strsep handles
        situations that strtok doesn't), why hasn't it been included (at
        least in the POSIX standard if not the C standard)?
        Who says it is superior? Another candidate is toksplit (detailed
        elsethread). It all depends on what is required. There is no
        pressing need for any of these in the standard library, since they
        can all easily be written in standard C.

        --
        Chuck F (cbfalconer at maineline dot net)
        Available for consulting/temporary embedded and systems.
        <http://cbfalconer.home .att.net>


        Comment

        • Keith Thompson

          #19
          Re: string splitting

          Ben Pfaff <blp@cs.stanfor d.eduwrites:
          Daniel Rudy <spamthis@spamt his.netwrites:
          >
          >Now I'm not too up on what functions comprise the standard C library and
          >what doesn't, reading THIS man page you can see the cause of confusion:
          >>
          >STRTOK(3) FreeBSD Library Functions Manual
          >>
          >NAME
          > strtok, strtok_r -- string tokens
          >>
          >LIBRARY
          > Standard C Library (libc, -lc)
          >
          File a bug against the FreeBSD manpage then. It's wrong.
          The phrase "Standard C Library" doesn't necessarily imply that the
          function is defined by the C standard. Probably "libc" implements
          (most of) the functions defined by the C standard, plus some others.
          (I suspect the math functions are in a different library.)

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
          We must do something. This is something. Therefore, we must do this.

          Comment

          • Charlton Wilbur

            #20
            Re: string splitting

            >>>>"BP" == Ben Pfaff <blp@cs.stanfor d.eduwrites:
            >NAME strtok, strtok_r -- string tokens
            >>
            >LIBRARY Standard C Library (libc, -lc)
            BPFile a bug against the FreeBSD manpage then. It's wrong.

            Depends on which standard is being referred to, and which function;
            strtok() is in fact standard C. The word "standard" may also not be
            used in the c.l.c sense of ISO/ANSI standard C, but to refer to the C
            library generally shipped with FreeBSD.

            On the other hand, the BSDs I have access to at this very moment -- OS
            X and OpenBSD - both correctly note in the relevant manpages that
            strsep() is an improved version of the standard strtok(), and that
            strtok() is ANSI/ISO standard C while strtok_r and strsep are not. So
            this is most likely a FreeBSD issue.

            Charlton


            --
            Charlton Wilbur
            cwilbur@chromat ico.net

            Comment

            • Ben Pfaff

              #21
              Re: string splitting

              Charlton Wilbur <cwilbur@chroma tico.netwrites:
              >>>>>"BP" == Ben Pfaff <blp@cs.stanfor d.eduwrites:
              >
              >NAME strtok, strtok_r -- string tokens
              >>
              >LIBRARY Standard C Library (libc, -lc)
              >
              BPFile a bug against the FreeBSD manpage then. It's wrong.
              >
              Depends on which standard is being referred to, and which function;
              strtok() is in fact standard C. The word "standard" may also not be
              used in the c.l.c sense of ISO/ANSI standard C, but to refer to the C
              library generally shipped with FreeBSD.
              I missed the fact that the article I was directly following up
              was quoting from the strtok manpage. The article a few layers up
              was in fact quoting from the strsep manpage, which also claims
              that strsep is in the standard C library. That's the one that
              needs a bug report.
              --
              A competent C programmer knows how to write C programs correctly,
              a C expert knows enough to argue with Dan Pop, and a C expert
              expert knows not to bother.

              Comment

              • Ben Pfaff

                #22
                Re: string splitting

                Keith Thompson <kst-u@mib.orgwrites :
                Ben Pfaff <blp@cs.stanfor d.eduwrites:
                >Daniel Rudy <spamthis@spamt his.netwrites:
                >>
                >>Now I'm not too up on what functions comprise the standard C library and
                >>what doesn't, reading THIS man page you can see the cause of confusion:
                >>>
                >>STRTOK(3) FreeBSD Library Functions Manual
                >>>
                >>NAME
                >> strtok, strtok_r -- string tokens
                >>>
                >>LIBRARY
                >> Standard C Library (libc, -lc)
                >>
                >File a bug against the FreeBSD manpage then. It's wrong.
                >
                The phrase "Standard C Library" doesn't necessarily imply that the
                function is defined by the C standard. Probably "libc" implements
                (most of) the functions defined by the C standard, plus some others.
                If you call something the Standard C Library then you're just
                going to confuse people if it, in fact, isn't just the standard C
                library. At least the GNU folks don't call their library the
                Standard C Library (they call it the GNU C library).
                --
                "The lusers I know are so clueless, that if they were dipped in clue
                musk and dropped in the middle of pack of horny clues, on clue prom
                night during clue happy hour, they still couldn't get a clue."
                --Michael Girdwood, in the monastery

                Comment

                • Yevgen Muntyan

                  #23
                  Re: string splitting

                  Ben Pfaff wrote:
                  Keith Thompson <kst-u@mib.orgwrites :
                  >
                  >Ben Pfaff <blp@cs.stanfor d.eduwrites:
                  >>Daniel Rudy <spamthis@spamt his.netwrites:
                  >>>
                  >>>Now I'm not too up on what functions comprise the standard C library and
                  >>>what doesn't, reading THIS man page you can see the cause of confusion:
                  >>>>
                  >>>STRTOK(3) FreeBSD Library Functions Manual
                  >>>>
                  >>>NAME
                  >>> strtok, strtok_r -- string tokens
                  >>>>
                  >>>LIBRARY
                  >>> Standard C Library (libc, -lc)
                  >>File a bug against the FreeBSD manpage then. It's wrong.
                  >The phrase "Standard C Library" doesn't necessarily imply that the
                  >function is defined by the C standard. Probably "libc" implements
                  >(most of) the functions defined by the C standard, plus some others.
                  >
                  If you call something the Standard C Library then you're just
                  going to confuse people if it, in fact, isn't just the standard C
                  library.
                  In many situations "Standard C library" is simply a synonym of "libc"
                  which in turn is a word denoting the C library shipped with the
                  operating system. May be confusing, indeed.
                  At least the GNU folks don't call their library the
                  Standard C Library (they call it the GNU C library).
                  Perhaps because there is no (real) GNU operating system?

                  Yevgen

                  Comment

                  • Dik T. Winter

                    #24
                    Re: string splitting

                    In article <lnzm74bufh.fsf @nuthaus.mib.or gKeith Thompson <kst-u@mib.orgwrites :
                    ....
                    The phrase "Standard C Library" doesn't necessarily imply that the
                    function is defined by the C standard. Probably "libc" implements
                    (most of) the functions defined by the C standard, plus some others.
                    (I suspect the math functions are in a different library.)
                    The man page of the version of Linux I am using has a CONFORMING TO
                    section:

                    strtok():
                    SVr4, POSIX.1-2001, 4.3BSD, C89.
                    strtok_r():
                    POSIX.1-2001
                    strsep():
                    4.4BSD
                    --
                    dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
                    home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

                    Comment

                    • Randy Howard

                      #25
                      Re: string splitting

                      On Wed, 21 Feb 2007 06:13:14 -0600, Ian Malone wrote
                      (in article <45DC375A.60602 01@cam.ac.uk>):
                      Richard Heathfield wrote:
                      >Andrea said:
                      >>
                      >>I want to write a program that:
                      >>>
                      >>char * strplit(char* str1, char *str2, char * stroriginal,int
                      >>split_point )
                      >>>
                      >>that take stroriginal and split in the split_point element of the
                      >>string the string into two other strings,
                      >>>
                      >>example:
                      >>>
                      >>"Hello World"
                      >>i want to split this string into "Hello " "World"
                      >>
                      >What's stopping you?
                      >
                      An inappropriate prototype?
                      char * strplit(char* str1, char *str2, char * stroriginal,
                      int split_point)
                      >
                      Namespace violation with strplit() ??

                      Plus, wouldn't strsplit() make more sense anyway, if you didn't care
                      about that? How about splitstr() instead?

                      A purist might also say that stroriginal should be const.
                      Questions for the OP:
                      What should be passed in str1, str2, stroriginal and
                      split_point?
                      What is the expected behavior if str1 is NULL? If str2 is NULL? If
                      stroriginal should be NULL?
                      What is the significance of the return value going to be?
                      Right. Since you can only return one of them, I wonder what the point
                      of that is.
                      >
                      As written I suspect that you plan to put the two sub-
                      strings into the memory pointed to by str1 and str2,
                      how will your function know that the objects pointed
                      to by these are large enough to hold the sub-strings?
                      Indeed.


                      --
                      Randy Howard (2reply remove FOOBAR)
                      "The power of accurate observation is called cynicism by those
                      who have not got it." - George Bernard Shaw





                      Comment

                      • Randy Howard

                        #26
                        Re: string splitting

                        On Fri, 23 Feb 2007 13:06:22 -0600, Ben Pfaff wrote
                        (in article <87d540r8wh.fsf @blp.benpfaff.o rg>):
                        Keith Thompson <kst-u@mib.orgwrites :
                        >
                        >Ben Pfaff <blp@cs.stanfor d.eduwrites:
                        >>Daniel Rudy <spamthis@spamt his.netwrites:
                        >>>
                        >>>Now I'm not too up on what functions comprise the standard C library and
                        >>>what doesn't, reading THIS man page you can see the cause of confusion:
                        >>>>
                        >>>STRTOK(3) FreeBSD Library Functions Manual
                        >>>>
                        >>>NAME
                        >>>strtok, strtok_r -- string tokens
                        >>>>
                        >>>LIBRARY
                        >>>Standard C Library (libc, -lc)
                        >>>
                        >>File a bug against the FreeBSD manpage then. It's wrong.
                        >>
                        >The phrase "Standard C Library" doesn't necessarily imply that the
                        >function is defined by the C standard. Probably "libc" implements
                        >(most of) the functions defined by the C standard, plus some others.
                        >
                        If you call something the Standard C Library then you're just
                        going to confuse people if it, in fact, isn't just the standard C
                        library.
                        Take it up with almost every man page on any UNIX or Linux distro.
                        This is a very common problem, where all the kitchen sink addons get
                        stuck in there, and what they mean is really "No additional libraries
                        need to be included to get this function".

                        The key point was lower down in the man page posted upthread, where it
                        said it was in the C standard (incorrectly).


                        --
                        Randy Howard (2reply remove FOOBAR)
                        "The power of accurate observation is called cynicism by those
                        who have not got it." - George Bernard Shaw





                        Comment

                        • Randy Howard

                          #27
                          Re: string splitting

                          On Tue, 6 Mar 2007 12:20:40 -0600, Randy Howard wrote
                          (in article <0001HW.C2130D1 803DCC8C7F02036 48@news.verizon .net>):
                          On Fri, 23 Feb 2007 13:06:22 -0600, Ben Pfaff wrote
                          (in article <87d540r8wh.fsf @blp.benpfaff.o rg>):
                          >
                          >Keith Thompson <kst-u@mib.orgwrites :
                          >>
                          >>Ben Pfaff <blp@cs.stanfor d.eduwrites:
                          >>>Daniel Rudy <spamthis@spamt his.netwrites:
                          >>>>
                          >>>>Now I'm not too up on what functions comprise the standard C library and
                          >>>>what doesn't, reading THIS man page you can see the cause of confusion:
                          >>>>>
                          >>>>STRTOK(3) FreeBSD Library Functions Manual
                          >>>>>
                          >>>>NAME
                          >>>>strtok, strtok_r -- string tokens
                          >>>>>
                          >>>>LIBRARY
                          >>>>Standard C Library (libc, -lc)
                          >>>>
                          >>>File a bug against the FreeBSD manpage then. It's wrong.
                          >>>
                          >>The phrase "Standard C Library" doesn't necessarily imply that the
                          >>function is defined by the C standard. Probably "libc" implements
                          >>(most of) the functions defined by the C standard, plus some others.
                          >>
                          >If you call something the Standard C Library then you're just
                          >going to confuse people if it, in fact, isn't just the standard C
                          >library.
                          >
                          Take it up with almost every man page on any UNIX or Linux distro.
                          This is a very common problem, where all the kitchen sink addons get
                          stuck in there, and what they mean is really "No additional libraries
                          need to be included to get this function".
                          >
                          The key point was lower down in the man page posted upthread, where it
                          said it was in the C standard (incorrectly).

                          Correction on the last paragraph of my previous post, I read it too
                          quickly, it was referring to strtok, not strsep in that portion, and in
                          fact did refer to the portability issue with strsep().


                          --
                          Randy Howard (2reply remove FOOBAR)
                          "The power of accurate observation is called cynicism by those
                          who have not got it." - George Bernard Shaw





                          Comment

                          • Randy Howard

                            #28
                            Re: string splitting

                            On Fri, 23 Feb 2007 13:05:22 -0600, Ben Pfaff wrote
                            (in article <87hctcr8y5.fsf @blp.benpfaff.o rg>):
                            Charlton Wilbur <cwilbur@chroma tico.netwrites:
                            >
                            >>>>>>"BP" == Ben Pfaff <blp@cs.stanfor d.eduwrites:
                            >>
                            >>>NAME strtok, strtok_r -- string tokens
                            >>>>
                            >>>LIBRARY Standard C Library (libc, -lc)
                            >>
                            >BPFile a bug against the FreeBSD manpage then. It's wrong.
                            >>
                            >Depends on which standard is being referred to, and which function;
                            >strtok() is in fact standard C. The word "standard" may also not be
                            >used in the c.l.c sense of ISO/ANSI standard C, but to refer to the C
                            >library generally shipped with FreeBSD.
                            >
                            I missed the fact that the article I was directly following up
                            was quoting from the strtok manpage. The article a few layers up
                            was in fact quoting from the strsep manpage, which also claims
                            that strsep is in the standard C library. That's the one that
                            needs a bug report.
                            It's a convention thing. That top section is indicating that it is in
                            the "standard" library, in the sense that no additional -lfoo type
                            incantations are required to link in an extra library. By convention,
                            man pages like that do not care an iota about ANSI or ISO standards
                            there, but only in one gets linked without extra effort. The section
                            near the end of the same man pages usually calls out a source, either
                            as a version of a UNIX platform first supporting it, POSIX, ISO, or an
                            add-on library.



                            --
                            Randy Howard (2reply remove FOOBAR)
                            "The power of accurate observation is called cynicism by those
                            who have not got it." - George Bernard Shaw





                            Comment

                            • J. J. Farrell

                              #29
                              Re: string splitting

                              On Mar 6, 10:20 am, Randy Howard <randyhow...@FO OverizonBAR.net >
                              wrote:
                              On Fri, 23 Feb 2007 13:06:22 -0600, Ben Pfaff wrote
                              (in article <87d540r8wh.... @blp.benpfaff.o rg>):
                              Keith Thompson <k...@mib.orgwr ites:
                              Ben Pfaff <b...@cs.stanfo rd.eduwrites:
                              >Daniel Rudy <spamt...@spamt his.netwrites:
                              >
                              >>Now I'm not too up on what functions comprise the standard C library and
                              >>what doesn't, reading THIS man page you can see the cause of confusion:
                              >
                              >>STRTOK(3) FreeBSD Library Functions Manual
                              >
                              >>NAME
                              >>strtok, strtok_r -- string tokens
                              >
                              >>LIBRARY
                              >>Standard C Library (libc, -lc)
                              >
                              >File a bug against the FreeBSD manpage then. It's wrong.
                              >
                              The phrase "Standard C Library" doesn't necessarily imply that the
                              function is defined by the C standard. Probably "libc" implements
                              (most of) the functions defined by the C standard, plus some others.
                              >
                              If you call something the Standard C Library then you're just
                              going to confuse people if it, in fact, isn't just the standard C
                              library.
                              >
                              Take it up with almost every man page on any UNIX or Linux distro.
                              This is a very common problem, where all the kitchen sink addons get
                              stuck in there, and what they mean is really "No additional libraries
                              need to be included to get this function".
                              This is a question of history. The term "standard C library" was in
                              widespread use long before the C Standard came along. As Randy says,
                              it referred to the library which was searched by default when linking
                              a C program. There are archived discussions in this newsgroup from
                              before the Great Renaming (and hence years before the C Standard)
                              which use it in this way. The definitive write-up about the Internet
                              Worm of 1988 refers to gets() as a function in the "standard C
                              library" and goes on to remark that it probably won't go away any time
                              soon as it's slated to be included in the upcoming C Standard.

                              The confusion was caused when the Johnny-come-lately C Standard
                              appeared and usurped the term. The man pages in many UNIXalikes
                              continue to use the term in its traditional sense, which causes
                              confusion for those who don't know the history. It's perhaps time the
                              authors spotted that using "C" and "standard" together might make
                              readers think they are referring to the C Standard.

                              Comment

                              • CBFalconer

                                #30
                                Re: string splitting

                                Randy Howard wrote:
                                >>>Daniel Rudy <spamthis@spamt his.netwrites:
                                >>>>
                                >>>>Now I'm not too up on what functions comprise the standard C
                                >>>>library and what doesn't, reading THIS man page you can see
                                >>>>the cause of confusion:
                                >>>>>
                                >>>>STRTOK(3) FreeBSD Library Functions Manual
                                >>>>>
                                .... snip ...
                                >
                                The key point was lower down in the man page posted upthread,
                                where it said it was in the C standard (incorrectly).
                                One of us is confused. I find strtok in the C standard.

                                --
                                <http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
                                <http://www.securityfoc us.com/columnists/423>

                                "A man who is right every time is not likely to do very much."
                                -- Francis Crick, co-discover of DNA
                                "There is nothing more amazing than stupidity in action."
                                -- Thomas Matthews


                                Comment

                                Working...