Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jul 2014 13:58:33 -0700
From:      John-Mark Gurney <jmg@funkthat.com>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        sjg@freebsd.org, arch@freebsd.org, marcel@freebsd.org, Phil Shafer <phil@juniper.net>
Subject:   Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Message-ID:  <20140731205833.GU43962@funkthat.com>
In-Reply-To: <58087.1406837257@critter.freebsd.dk>
References:  <20140730193819.GM43962@funkthat.com> <201407302324.s6UNOB2H087915@idle.juniper.net> <20140731175547.GO43962@funkthat.com> <58087.1406837257@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
Poul-Henning Kamp wrote this message on Thu, Jul 31, 2014 at 20:07 +0000:
> --------
> In message <20140731175547.GO43962@funkthat.com>, John-Mark Gurney writes:
> >Phil Shafer wrote this message on Wed, Jul 30, 2014 at 19:24 -0400:
> >> John-Mark Gurney writes:
> >> >My vote would be to use and *enforce* UTF-8 by the API.   That means if
> >> >someone passes a string in, it must be properly formed UTF-8...
> >> 
> >> I can certainly see making this an option, detecting the high-bit
> >> and inspecting the following 1-5 bytes to ensure the corresponding
> >> high two bits are set appropriately.  But what action would you
> >> expect the library to take when invalid strings are passed in?
> >
> >Return an error?  printf can return an error, yet most people don't
> >check it.. so no real difference in API/bugs...
> 
> This is why we ended up with SIGPIPE in the first place.
> 
> Can I point discreetely at sbuf(3)'s accumulative error handling
> and suggest that libxo does something similar ?  That way applications

$ man 3 sbuf
No manual entry for sbuf

And looks like it isn't in libc:
$ cc -o q q.c
/tmp/q-41cfbe.o: In function `main':
q.c:(.text+0x23): undefined reference to `sbuf_new'
q.c:(.text+0x38): undefined reference to `sbuf_cat'
q.c:(.text+0x4c): undefined reference to `sbuf_cat'
q.c:(.text+0x58): undefined reference to `sbuf_finish'
q.c:(.text+0x64): undefined reference to `sbuf_data'
q.c:(.text+0x82): undefined reference to `sbuf_delete'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

Hmm... looks like libsbuf exists, and causes the above program to
compile and work...

Please write a man page for sbuf(3)...  Thanks.

> only need to check for errors once, rather than after every single
> call to every single function in the libxo library.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140731205833.GU43962>