On Sun, Oct 25, 2009 at 11:14:43AM -0700, Ray Van Dolson wrote:
> On Sun, Oct 25, 2009 at 09:56:34AM -0700, Ray Van Dolson wrote:
> > Thanks Jonathan.  This is for the most part working now.  Just trying
> > to figure out the quirks of mdb_printf so the output all stays on one
> > line now when my function is not invoked directly in the mdb -k shell
> > by hand.
> 
> Alright, got this working:
> 
>   http://arthur2.bludgeon.org/~rayvd/devel/mdb/raytest.c
> 
> Please excuse my brute force way of making the mdb_snprintf output not
> line wrap. :-)

Yeah, the MDB line wrapping stuff can be annoying.  You don't need two output
buffers, though;  you could just do:

        /*
         * mdb_snprintf throws in a random newline because it wants to format
         * the output for the expected terminal width.  Cycle through our output
         * and copy it into a new output buffer stripping out this extra newline
         * along the way.
         */

        r = q = &outbuf[0];
        while (*q != '\0') {
                if (*q != '\n') {
                        if (r != q)
                                *r = *q;
                        r++;
                }
                q++;
        }
        *r = '\0';

Reply via email to