euglug.org

[작성자:] admin

  • [Eug-lug] c and va_*



    T. Joseph CarterSun Jun 20 23:33:04 PDT 2004

    On Sun, Jun 20, 2004 at 08:50:24PM -0700, Rob Hudson wrote:
    > I discovered elmo, not the cartoon character, but the mail client:
    > http://elmo.sourceforge.net/  I thought it might make a nice replacement to
    > mutt, which I've been using on my server for years.
    > 
    > I wanted to try it on my FreeBSD server but it dies on the linking stage
    > saying: 
    > /usr/local/src/elmo-1.2.0/src/str.c(.text+0x28d): undefined reference to `va_copy'
    > 
    > Do you know what va_copy does?  Is it part of C?
    
    va_copy is C99.  If your libc provides C99 compliance (gcc 3.3 would do
    it) then you have it with the right thing enabled.
    
       va_copy
           An obvious implementation would have a va_list a pointer to  the
           stack frame of the variadic function.  In such a setup (by far the
           most common) there seems nothing against an assignment
                       va_list aq = ap;
           Unfortunately, there are also systems that make it an array of
           pointers (of length 1), and there one needs
                       va_list aq;
                       *aq = *ap;
           Finally, on systems where parameters are passed in registers, it
           may be necessary for va_start to allocate memory, store the
           parameters there, and also an indication of which parameter is
           next, so that va_arg can step through the list. Now va_end can free
           the allocated memory again.
           To accommodate this situation, C99 adds a macro va_copy, so that
           the above assignment can be replaced by
                       va_list aq;
                       va_copy(aq, ap);
                       ...
                       va_end(aq);
           Each invocation of va_copy must be matched by a corresponding
           invocation of va_end in the same function.  Some systems that do
           not supply va_copy have __va_copy instead, since that was the name
           used in the draft proposal.
    
    This is from a Linux system's manpage on the varargs functions.  My Mac
    lacks the manpage, but features the function protected by the explicit
    need to require C99 be enabled.
    
    
  • [Eug-lug] c and va_*



    Jacob MeuserSun Jun 20 23:04:56 PDT 2004

    On Sun, Jun 20, 2004 at 09:45:50PM -0700, Bob Miller wrote:
    > Rob Hudson wrote:
    > 
    > > No, but I did google it and found a man page.  I also found this:
    > > http://lists.helixcommunity.org/pipermail/common-dev/2003-June/000353.html
    > > 
    > > It says only Linux and Solaris have va_copy.
    
    In BSD land, use man -k before going to google.  I'm willing
    to bet you have va_copy ... OK, I cheated and went to
    http://freebsd.org/cgi/man.cgi
    
    > According to the man page, va_copy() is defined by C99.
    > I'm too lazy to look it up and verify that. (-:
    > 
    > > I'm thinking it's time to file a bug against elmo for the BSD platform.
    > 
    > Definitely.
    
    IMO, Rob should follow Senior Goat's advice, and then send a patch.
    
    -- 
    <jakemsr at jakemsr.com>
    
  • [Eug-lug] c and va_*



    Jacob MeuserSun Jun 20 22:59:37 PDT 2004

    On Sun, Jun 20, 2004 at 10:34:23PM -0700, larry wrote:
    > is your kernel built with with Linux compatibilty?
    > 
    > You would have clicked a box during the install or
    > set the COMPAT_LINUX  option during kernel configuration
    
    ?
    
    He's building a program.  COMPAT_LINUX is for running linux
    binaries.
    
    -- 
    <jakemsr at jakemsr.com>
    
  • [Eug-lug] simple script?



    Mr OSun Jun 20 22:39:46 PDT 2004

    Yeah, what Bob said. I'm not programming, I'm playing games.
    Simple and straightforward is what I'm looking for.
    
    Thanks,
    Mr O.
    
    
    --- Bob Miller <kbob at jogger-egg.com> wrote:
    
    > I wasn't going to go into this, because Mr. O probably doesn't
    > care.
    > But since you and Peter brought it up...
    
    
    
    		
    __________________________________
    Do you Yahoo!?
    Take Yahoo! Mail with you! Get it on your mobile phone.
    http://mobile.yahoo.com/maildemo 
    
  • [Eug-lug] c and va_*



    larrySun Jun 20 22:34:23 PDT 2004

    is your kernel built with with Linux compatibilty?
    
    You would have clicked a box during the install or
    set the COMPAT_LINUX  option during kernel configuration
    
    
    
    On Jun 20, 2004, at 9:00 PM, Rob Hudson wrote:
    
    > No, but I did google it and found a man page.  I also found this:
    > http://lists.helixcommunity.org/pipermail/common-dev/2003-June/ 
    > 000353.html
    >
    > It says only Linux and Solaris have va_copy.
    >
    > I'm thinking it's time to file a bug against elmo for the BSD platform.
    >
    > -Rob
    >
    > On 20040621.0357, Senior Goat said ...
    >
    >>
    >> Have you tried man va_copy?  Maybe man stdarg.
    >>
    >> Should list the requirements for va_copy.  Make sure the includes are  
    >> being
    >> included.
    >>
    >> Don't be afraid of man -k [term] to search for things.
    > _______________________________________________
    > EUGLUG mailing list
    > euglug at euglug.org
    > http://www.euglug.org/mailman/listinfo/euglug
    
    
  • [Eug-lug] c and va_*



    Bob MillerSun Jun 20 21:45:50 PDT 2004

    Rob Hudson wrote:
    
    > No, but I did google it and found a man page.  I also found this:
    > http://lists.helixcommunity.org/pipermail/common-dev/2003-June/000353.html
    > 
    > It says only Linux and Solaris have va_copy.
    
    According to the man page, va_copy() is defined by C99.
    I'm too lazy to look it up and verify that. (-:
    
    > I'm thinking it's time to file a bug against elmo for the BSD platform.
    
    Definitely.
    
    -- 
    Bob Miller                              K<bob>
    kbobsoft software consulting
    http://kbobsoft.com                     kbob at jogger-egg.com
    
  • [Eug-lug] simple script?



    Bob MillerSun Jun 20 21:41:31 PDT 2004

    Allen Brown wrote:
    
    > Not correct.  "$@" is handled as a special case by the shell.  (True
    > for bash and ksh.)  Each element on the command line becomes one
    > element at the insertion point.
    
    I wasn't going to go into this, because Mr. O probably doesn't care.
    But since you and Peter brought it up...
    
    "$@" (with the quotes) has been a valid way to pass "all arguments,
    correctly quoted" to the shell since the early days of the Bourne
    shell in the late 1970s.  The classic Bourne shell had a bug where, if
    there were zero arguments, "$@" would insert one zero-length argument.
    Newer shells have fixed that bug, and you're unlikely to run into the
    bug today.  But the workaround, for the pedantic (or the old fart who
    won't shut up (-: ) is ${1+"$@"}.  That means, "If the 1st argument is
    defined, substitute in all the args, correctly quoted."
    
    	wget --whatever ${1+"$@"}
    
    If you want to iterate over the arguments in sh, use "for i" with no
    "in ..." clause.  That bypasses quoting issues completely.
    
    	for i
    	do echo "argument is $i"
    	done
    
    > In general "$@" is the Right Way to write scripts.  In this case,
    > it probably doesn't matter since I don't think blanks are legal in
    > URLs.
    
    wget will translate a space into %20.
    
    > But it is better to maintain good programming habits, so that
    > argues for using "$@" even where it is moot.
    
    Seconded.
    
    -- 
    Bob Miller                              K<bob>
    kbobsoft software consulting
    http://kbobsoft.com                     kbob at jogger-egg.com
    
  • [Eug-lug] c and va_*



    Rob HudsonSun Jun 20 21:00:48 PDT 2004

    No, but I did google it and found a man page.  I also found this:
    http://lists.helixcommunity.org/pipermail/common-dev/2003-June/000353.html
    
    It says only Linux and Solaris have va_copy.
    
    I'm thinking it's time to file a bug against elmo for the BSD platform.
    
    -Rob
    
    On 20040621.0357, Senior Goat said ...
    
    > 
    > Have you tried man va_copy?  Maybe man stdarg.
    > 
    > Should list the requirements for va_copy.  Make sure the includes are being 
    > included.
    > 
    > Don't be afraid of man -k [term] to search for things.
    
  • [Eug-lug] c and va_*



    Senior GoatSun Jun 20 20:57:02 PDT 2004

    Have you tried man va_copy?  Maybe man stdarg.
    
    Should list the requirements for va_copy.  Make sure the includes are being 
    included.
    
    Don't be afraid of man -k [term] to search for things.
    
    &gt;From: Rob Hudson &lt;rob at euglug.net&gt;
    &gt;Reply-To: Eugene Unix and Gnu/Linux User Group &lt;euglug at euglug.org&gt;
    &gt;To: EUGLUG &lt;euglug at euglug.org&gt;
    &gt;Subject: [Eug-lug] c and va_*
    &gt;Date: Sun, 20 Jun 2004 20:50:24 -0700
    &gt;
    &gt;Hi EUGLUG,
    &gt;
    &gt;I discovered elmo, not the cartoon character, but the mail client:
    &gt;http://elmo.sourceforge.net/  I thought it might make a nice replacement 
    to
    &gt;mutt, which I've been using on my server for years.
    &gt;
    &gt;I wanted to try it on my FreeBSD server but it dies on the linking stage
    &gt;saying:
    &gt;/usr/local/src/elmo-1.2.0/src/str.c(.text+0x28d): undefined reference to 
    `va_copy'
    &gt;
    &gt;Do you know what va_copy does?  Is it part of C?
    &gt;
    &gt;Here's the actual function in str.c:
    &gt;
    &gt;int
    &gt;str_vsprintf (str_t *str, const char *fmt, va_list ap)
    &gt;{
    &gt;         int     n;
    &gt;         int     max_size;
    &gt;         va_list copy;
    &gt;
    &gt;         if (str == NULL || fmt == NULL)
    &gt;                 return -1;
    &gt;
    &gt;         while (1){
    &gt;                 max_size = str-&gt;size - str-&gt;len - 1;
    &gt;                 va_copy (copy, ap);
    &gt;                 n = vsnprintf (str-&gt;str + str-&gt;len, max_size, 
    fmt, copy);
    &gt;                 if (n &gt; -1 &amp;&amp; n &lt; max_size){
    &gt;                         str-&gt;len += n;
    &gt;                         return n;
    &gt;                 }
    &gt;                 if (n &gt; -1)
    &gt;                         while (max_size &lt; n + 1){
    &gt;                                 str-&gt;size *= 2;
    &gt;                                 max_size   = str-&gt;size - 
    str-&gt;len;
    &gt;                         }
    &gt;                 else {
    &gt;                         str-&gt;size *= 2;
    &gt;                 }
    &gt;
    &gt;                 str-&gt;str = xrealloc (str-&gt;str, str-&gt;size + 1);
    &gt;         }
    &gt;}
    &gt;
    &gt;_______________________________________________
    &gt;EUGLUG mailing list
    &gt;euglug at euglug.org
    &gt;http://www.euglug.org/mailman/listinfo/euglug
    
    _________________________________________________________________
    Is your PC infected? Get a FREE online computer virus scan from McAfee® 
    Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
    
    
  • [Eug-lug] c and va_*



    Rob HudsonSun Jun 20 20:50:24 PDT 2004

    Hi EUGLUG,
    
    I discovered elmo, not the cartoon character, but the mail client:
    http://elmo.sourceforge.net/  I thought it might make a nice replacement to
    mutt, which I've been using on my server for years.
    
    I wanted to try it on my FreeBSD server but it dies on the linking stage
    saying: 
    /usr/local/src/elmo-1.2.0/src/str.c(.text+0x28d): undefined reference to `va_copy'
    
    Do you know what va_copy does?  Is it part of C?
    
    Here's the actual function in str.c:
    
    int
    str_vsprintf (str_t *str, const char *fmt, va_list ap)
    {
            int     n; 
            int     max_size;
            va_list copy; 
    
            if (str == NULL || fmt == NULL)
                    return -1;
    
            while (1){
                    max_size = str->size - str->len - 1;
                    va_copy (copy, ap);
                    n = vsnprintf (str->str + str->len, max_size, fmt, copy);
                    if (n > -1 && n < max_size){
                            str->len += n;
                            return n;
                    }
                    if (n > -1)
                            while (max_size < n + 1){
                                    str->size *= 2;
                                    max_size   = str->size - str->len;
                            }
                    else {
                            str->size *= 2;
                    }
    
                    str->str = xrealloc (str->str, str->size + 1);
            }
    }